24 #ifndef TVM_RELAX_DATAFLOW_PATTERN_H_
25 #define TVM_RELAX_DATAFLOW_PATTERN_H_
57 class StructInfoPattern;
59 class DataTypePattern;
61 class SameShapeConstraint;
93 static constexpr
const char*
_type_key =
"DFPatternNode";
105 template <
typename... Args>
202 static constexpr
const char*
_type_key =
"DFConstraintNode";
222 static constexpr
const char*
_type_key =
"relax.dpl.PatternSeq";
262 std::map<DFPattern, std::vector<std::pair<DFPattern, std::vector<PairCons>>>>
edge_constraints;
271 static constexpr
const char*
_type_key =
"relax.dpl.PatternContext";
285 ICHECK(
get() !=
nullptr);
290 ICHECK(
get() !=
nullptr);
302 auto& pairs = (*this)->edge_constraints[producer];
303 auto it = std::find_if(pairs.begin(), pairs.end(),
304 [consumer](
auto p) { return p.first == consumer; });
305 if (it == pairs.end()) {
306 pairs.emplace_back(consumer, std::vector{cons});
308 auto& vec = it->second;
309 ICHECK(std::find(vec.cbegin(), vec.cend(), cons) == vec.cend())
310 <<
"Constraint already exists";
314 auto& patterns = (*this)->src_ordered;
315 if (std::find(patterns.begin(), patterns.end(), producer) == patterns.end()) {
316 patterns.push_back(producer);
326 (*this)->validation_constraints.push_back(constraint);
351 static constexpr
const char*
_type_key =
"relax.dpl.ExprPattern";
376 static constexpr
const char*
_type_key =
"relax.dpl.VarPattern";
402 static constexpr
const char*
_type_key =
"relax.dpl.DataflowVarPattern";
423 static constexpr
const char*
_type_key =
"relax.dpl.GlobalVarPattern";
445 static constexpr
const char*
_type_key =
"relax.dpl.ConstantPattern";
483 v->Visit(
"args", &
args);
486 static constexpr
const char*
_type_key =
"relax.dpl.CallPattern";
505 static constexpr
const char*
_type_key =
"relax.dpl.PrimArrPattern";
536 v->Visit(
"params", &
params);
537 v->Visit(
"body", &
body);
540 static constexpr
const char*
_type_key =
"relax.dpl.FunctionPattern";
570 static constexpr
const char*
_type_key =
"relax.dpl.TuplePattern";
594 static constexpr
const char*
_type_key =
"relax.dpl.UnorderedTuplePattern";
619 v->Visit(
"tuple", &
tuple);
620 v->Visit(
"index", &
index);
623 static constexpr
const char*
_type_key =
"relax.dpl.TupleGetItemPattern";
647 v->Visit(
"left", &
left);
648 v->Visit(
"right", &
right);
651 static constexpr
const char*
_type_key =
"relax.dpl.AndPattern";
675 v->Visit(
"left", &
left);
676 v->Visit(
"right", &
right);
679 static constexpr
const char*
_type_key =
"relax.dpl.OrPattern";
703 static constexpr
const char*
_type_key =
"relax.dpl.NotPattern";
725 static constexpr
const char*
_type_key =
"relax.dpl.WildcardPattern";
756 v->Visit(
"type", &
type);
759 static constexpr
const char*
_type_key =
"relax.dpl.TypePattern";
787 static constexpr
const char*
_type_key =
"relax.dpl.StructInfoPattern";
808 v->Visit(
"shape", &
shape);
811 static constexpr
const char*
_type_key =
"relax.dpl.ShapePattern";
840 static constexpr
const char*
_type_key =
"relax.dpl.SameShapeConstraint";
865 v->Visit(
"dtype", &
dtype);
868 static constexpr
const char*
_type_key =
"relax.dpl.DataTypePattern";
893 v->Visit(
"attrs", &
attrs);
896 static constexpr
const char*
_type_key =
"relax.dpl.AttrPattern";
923 static constexpr
const char*
_type_key =
"relax.dpl.ExternFuncPattern";
962 template <
typename... Args>
Runtime Array container types.
Visitor class to get the attributes of an AST/IR node. The content is going to be called for each fie...
Definition: reflection.h:52
Managed reference to DictAttrsNode.
Definition: attrs.h:227
Managed reference to RelaxExprNode.
Definition: expr.h:405
Managed reference to TypeNode.
Definition: type.h:93
RAII wrapper function to enter and exit a context object similar to python's with syntax.
Definition: with.h:58
Match a conjunction of other patterns.
Definition: dataflow_pattern.h:641
DFPattern left
Definition: dataflow_pattern.h:643
DFPattern right
Definition: dataflow_pattern.h:644
static constexpr const char * _type_key
Definition: dataflow_pattern.h:651
TVM_DECLARE_FINAL_OBJECT_INFO(AndPatternNode, DFPatternNode)
void VisitAttrs(tvm::AttrVisitor *v)
Definition: dataflow_pattern.h:646
Managed reference to AndPatternNode.
Definition: dataflow_pattern.h:659
AndPattern(DFPattern lhs, DFPattern rhs)
TVM_DEFINE_OBJECT_REF_METHODS(AndPattern, DFPattern, AndPatternNode)
A pattern that asserting a root pattern has certain attributes.
Definition: dataflow_pattern.h:886
DictAttrs attrs
Definition: dataflow_pattern.h:889
DFPattern pattern
Definition: dataflow_pattern.h:888
void VisitAttrs(tvm::AttrVisitor *v)
Definition: dataflow_pattern.h:891
TVM_DECLARE_FINAL_OBJECT_INFO(AttrPatternNode, DFPatternNode)
static constexpr const char * _type_key
Definition: dataflow_pattern.h:896
Managed reference to AttrPatternNode.
Definition: dataflow_pattern.h:904
TVM_DEFINE_OBJECT_REF_METHODS(AttrPattern, DFPattern, AttrPatternNode)
AttrPattern(DFPattern pattern, DictAttrs attrs)
A pattern to match a callable node in Relax.
Definition: dataflow_pattern.h:462
TVM_DECLARE_FINAL_OBJECT_INFO(CallPatternNode, DFPatternNode)
bool varg_default_wildcard
Definition: dataflow_pattern.h:477
static constexpr const char * _type_key
Definition: dataflow_pattern.h:486
void VisitAttrs(tvm::AttrVisitor *v)
Definition: dataflow_pattern.h:481
tvm::Array< DFPattern > args
Definition: dataflow_pattern.h:470
DFPattern op
Definition: dataflow_pattern.h:469
Definition: dataflow_pattern.h:490
CallPattern(DFPattern op, Array< DFPattern > args, bool varg_default_wildcard=false)
TVM_DEFINE_OBJECT_REF_METHODS(CallPattern, DFPattern, CallPatternNode)
A Pattern to Match a Relax Constant.
Definition: dataflow_pattern.h:441
void VisitAttrs(tvm::AttrVisitor *v)
Definition: dataflow_pattern.h:443
TVM_DECLARE_FINAL_OBJECT_INFO(ConstantPatternNode, DFPatternNode)
static constexpr const char * _type_key
Definition: dataflow_pattern.h:445
Managed reference to a ConstantPattern.
Definition: dataflow_pattern.h:453
TVM_DEFINE_OBJECT_REF_METHODS(ConstantPattern, DFPattern, ConstantPatternNode)
Additional constraints on the graph.
Definition: dataflow_pattern.h:167
TVM_DECLARE_BASE_OBJECT_INFO(DFConstraintNode, Object)
virtual Array< DFPattern > GetDependentPatterns() const =0
Return the patterns on which the constraint depends.
static constexpr const uint32_t _type_child_slots
Definition: dataflow_pattern.h:203
virtual std::tuple< PrimExpr, bool > AsPrimExpr(std::function< Optional< Var >(const DFPatternNode *)> match_state) const =0
Convert the constraint to a PrimExpr.
static constexpr const char * _type_key
Definition: dataflow_pattern.h:202
Definition: dataflow_pattern.h:207
TVM_DEFINE_OBJECT_REF_METHODS(DFConstraint, ObjectRef, DFConstraintNode)
Base type of all dataflow patterns.
Definition: dataflow_pattern.h:91
static constexpr const uint32_t _type_child_slots
Definition: dataflow_pattern.h:94
TVM_DECLARE_BASE_OBJECT_INFO(DFPatternNode, Object)
static constexpr const char * _type_key
Definition: dataflow_pattern.h:93
Managed reference to dataflow patterns.
Definition: dataflow_pattern.h:102
CallPattern operator()(const std::vector< DFPattern > &args) const
Syntatic Sugar for creating a CallPattern.
ShapePattern HasShape(const Array< PrimExpr > &shape) const
Syntatic Sugar for creating a ShapePattern.
DataTypePattern HasDtype(const DataType &dtype) const
Syntatic Sugar for creating a DataTypePattern with a DataType.
SameShapeConstraint HasSameShapeAs(const DFPattern &other) const
Syntatic Sugar for creating a ShapePattern.
OrPattern operator|(const DFPattern &other) const
Syntatic Sugar for creating an OrPattern.
CallPattern operator()(Args &&... args) const
Syntatic Sugar for creating a CallPattern.
Definition: dataflow_pattern.h:963
TVM_DEFINE_OBJECT_REF_METHODS(DFPattern, ObjectRef, DFPatternNode)
TypePattern HasType(const Type &type) const
Syntatic Sugar for creating a TypePattern.
StructInfoPattern HasStructInfo(const StructInfo &struct_info) const
Syntatic Sugar for creating a StructInfoPattern.
AndPattern operator&(const DFPattern &other) const
Syntatic Sugar for creating an AndPattern.
DFPattern dup() const
Syntatic Sugar for duplicating the current pattern.
NotPattern operator~() const
Syntatic Sugar for creating a NotPattern.
AttrPattern HasAttr(const Map< String, ObjectRef > &attrs) const
Syntatic Sugar for creating an AttrPattern.
DataTypePattern HasDtype(const std::string &dtype) const
Syntatic Sugar for creating a DataTypePattern with a data type's name.
A pattern that asserting a root pattern has a certain data type.
Definition: dataflow_pattern.h:858
DFPattern pattern
Definition: dataflow_pattern.h:860
TVM_DECLARE_FINAL_OBJECT_INFO(DataTypePatternNode, DFPatternNode)
DataType dtype
Definition: dataflow_pattern.h:861
void VisitAttrs(tvm::AttrVisitor *v)
Definition: dataflow_pattern.h:863
static constexpr const char * _type_key
Definition: dataflow_pattern.h:868
Managed reference to DataTypePatternNode.
Definition: dataflow_pattern.h:876
DataTypePattern(DFPattern pattern, DataType dtype)
TVM_DEFINE_OBJECT_REF_METHODS(DataTypePattern, DFPattern, DataTypePatternNode)
A Pattern to Match a Relax Dataflow Variable.
Definition: dataflow_pattern.h:400
TVM_DECLARE_FINAL_OBJECT_INFO(DataflowVarPatternNode, DFPatternNode)
static constexpr const char * _type_key
Definition: dataflow_pattern.h:402
Managed reference to a DataflowVarPattern.
Definition: dataflow_pattern.h:410
DataflowVarPattern(String name_hint)
TVM_DEFINE_OBJECT_REF_METHODS(DataflowVarPattern, DFPattern, DataflowVarPatternNode)
Pattern for Relax Expression.
Definition: dataflow_pattern.h:345
Expr expr
Definition: dataflow_pattern.h:347
void VisitAttrs(tvm::AttrVisitor *v)
Definition: dataflow_pattern.h:349
TVM_DECLARE_FINAL_OBJECT_INFO(ExprPatternNode, DFPatternNode)
static constexpr const char * _type_key
Definition: dataflow_pattern.h:351
Managed reference to an ExprPattern.
Definition: dataflow_pattern.h:359
TVM_DEFINE_OBJECT_REF_METHODS(ExprPattern, DFPattern, ExprPatternNode)
A pattern of external function.
Definition: dataflow_pattern.h:915
const String & global_symbol() const
The external function name.
Definition: dataflow_pattern.h:920
String global_symbol_
Definition: dataflow_pattern.h:917
TVM_DECLARE_FINAL_OBJECT_INFO(ExternFuncPatternNode, DFPatternNode)
void VisitAttrs(tvm::AttrVisitor *v)
Definition: dataflow_pattern.h:921
static constexpr const char * _type_key
Definition: dataflow_pattern.h:923
Managed reference to ExternFuncPatternNode.
Definition: dataflow_pattern.h:931
ExternFuncPattern(String global_symbol)
TVM_DEFINE_OBJECT_REF_METHODS(ExternFuncPattern, DFPattern, ExternFuncPatternNode)
A pattern to match a Relax Function.
Definition: dataflow_pattern.h:524
DFPattern body
Definition: dataflow_pattern.h:533
void VisitAttrs(tvm::AttrVisitor *v)
Definition: dataflow_pattern.h:535
static constexpr const char * _type_key
Definition: dataflow_pattern.h:540
TVM_DECLARE_FINAL_OBJECT_INFO(FunctionPatternNode, DFPatternNode)
tvm::Array< DFPattern > params
Definition: dataflow_pattern.h:526
Managed reference to FunctionPatternNode.
Definition: dataflow_pattern.h:548
FunctionPattern(tvm::Array< DFPattern > params, DFPattern body)
Constructor.
TVM_DEFINE_OBJECT_REF_METHODS(FunctionPattern, DFPattern, FunctionPatternNode)
A Pattern to Match a Relax Global Variable.
Definition: dataflow_pattern.h:421
TVM_DECLARE_FINAL_OBJECT_INFO(GlobalVarPatternNode, DFPatternNode)
static constexpr const char * _type_key
Definition: dataflow_pattern.h:423
Managed reference to a GlobalVarPattern.
Definition: dataflow_pattern.h:431
GlobalVarPattern(String name_hint)
TVM_DEFINE_OBJECT_REF_METHODS(GlobalVarPattern, DFPattern, GlobalVarPatternNode)
Pattern for rejecting a certain pattern.
Definition: dataflow_pattern.h:697
DFPattern reject
Definition: dataflow_pattern.h:699
void VisitAttrs(tvm::AttrVisitor *v)
Definition: dataflow_pattern.h:701
TVM_DECLARE_FINAL_OBJECT_INFO(NotPatternNode, DFPatternNode)
static constexpr const char * _type_key
Definition: dataflow_pattern.h:703
Managed reference to NotPatternNode.
Definition: dataflow_pattern.h:711
NotPattern(DFPattern reject)
TVM_DEFINE_OBJECT_REF_METHODS(NotPattern, DFPattern, NotPatternNode)
Match a disjunction of other patterns.
Definition: dataflow_pattern.h:669
DFPattern left
Definition: dataflow_pattern.h:671
DFPattern right
Definition: dataflow_pattern.h:672
TVM_DECLARE_FINAL_OBJECT_INFO(OrPatternNode, DFPatternNode)
static constexpr const char * _type_key
Definition: dataflow_pattern.h:679
void VisitAttrs(tvm::AttrVisitor *v)
Definition: dataflow_pattern.h:674
Managed reference to OrPatternNode.
Definition: dataflow_pattern.h:687
TVM_DEFINE_OBJECT_REF_METHODS(OrPattern, DFPattern, OrPatternNode)
OrPattern(DFPattern left, DFPattern right)
A context to manage the graph-level pattern matching.
Definition: dataflow_pattern.h:252
ExternUse
Constrainting matched graph with assertion to external uses.
Definition: dataflow_pattern.h:255
@ kMustNot
Definition: dataflow_pattern.h:257
@ kMay
Definition: dataflow_pattern.h:256
TVM_DECLARE_FINAL_OBJECT_INFO(PatternContextNode, Object)
std::vector< DFConstraint > validation_constraints
Definition: dataflow_pattern.h:269
static constexpr const char * _type_key
Definition: dataflow_pattern.h:271
enum tvm::relax::PatternContextNode::ExternUse allow_extern_use
std::map< DFPattern, std::vector< std::pair< DFPattern, std::vector< PairCons > > > > edge_constraints
Definition: dataflow_pattern.h:262
std::vector< DFPattern > src_ordered
Definition: dataflow_pattern.h:266
Managed reference to a pattern context.
Definition: dataflow_pattern.h:279
void add_constraint(DFConstraint constraint)
Add a validation constraint.
Definition: dataflow_pattern.h:325
void ExitWithScope() const
The RAII-like exit of a constraint context scope.
PatternContextNode * operator->()
Definition: dataflow_pattern.h:289
static Optional< PatternContext > Current()
Get the constraint context object on the top of the stack.
void add_constraint(DFPattern producer, DFPattern consumer, PairCons cons)
Build an edge constraint between two patterns (producer and consumer).
Definition: dataflow_pattern.h:301
const PatternContextNode * operator->() const
Definition: dataflow_pattern.h:284
PatternContext(bool incremental=false)
PatternContext(ObjectPtr< Object > n)
Definition: dataflow_pattern.h:281
void EnterWithScope() const
The RAII-like entry of a constraint context scope.
A sequence of DFPatterns that the previous DFPattern is connected to the next one.
Definition: dataflow_pattern.h:216
TVM_DECLARE_BASE_OBJECT_INFO(PatternSeqNode, Object)
tvm::Array< DFPattern > patterns
Definition: dataflow_pattern.h:218
static constexpr const char * _type_key
Definition: dataflow_pattern.h:222
void VisitAttrs(tvm::AttrVisitor *v)
Definition: dataflow_pattern.h:221
std::vector< PairCons > pair_constraints
Definition: dataflow_pattern.h:219
Managed reference to pattern sequences.
Definition: dataflow_pattern.h:230
PatternSeq(tvm::Array< DFPattern > patterns, bool only_used_by=false)
PatternSeq OnlyUsedBy(PatternSeq other, int index=-1) const
TVM_DEFINE_OBJECT_REF_METHODS(PatternSeq, ObjectRef, PatternSeqNode)
PatternSeq UsedBy(PatternSeq other, int index=-1) const
friend PatternSeq UsedBy(const PatternSeq &lhs, const PatternSeq &rhs, int index)
Create used-by relationship between lhs[-1] and rhs[0], with [*lhs, *rhs] returned.
PatternSeq(DFPattern init_pattern)
friend PatternSeq OnlyUsedBy(const PatternSeq &lhs, const PatternSeq &rhs, int index)
Create only-used-by relationship between lhs[-1] and rhs[0], with [*lhs, *rhs] returned.
PatternSeq dup() const
Syntatic Sugar for duplicating the current pattern sequence.
A pattern to match an array of PrimExpr.
Definition: dataflow_pattern.h:501
TVM_DECLARE_FINAL_OBJECT_INFO(PrimArrPatternNode, DFPatternNode)
Array< PrimExpr > fields
Definition: dataflow_pattern.h:503
static constexpr const char * _type_key
Definition: dataflow_pattern.h:505
void VisitAttrs(tvm::AttrVisitor *v)
Definition: dataflow_pattern.h:504
Managed reference to a PrimArrPattern.
Definition: dataflow_pattern.h:513
TVM_DEFINE_OBJECT_REF_METHODS(PrimArrPattern, DFPattern, PrimArrPatternNode)
PrimArrPattern(Array< PrimExpr > arr)
A pattern that asserting multiple root patterns have the same shape.
Definition: dataflow_pattern.h:829
void VisitAttrs(tvm::AttrVisitor *v)
Definition: dataflow_pattern.h:838
Array< DFPattern > args
Definition: dataflow_pattern.h:831
TVM_DECLARE_FINAL_OBJECT_INFO(SameShapeConstraintNode, DFConstraintNode)
std::tuple< PrimExpr, bool > AsPrimExpr(std::function< Optional< Var >(const DFPatternNode *)> match_state) const override
Convert the constraint to a PrimExpr.
static constexpr const char * _type_key
Definition: dataflow_pattern.h:840
Array< DFPattern > GetDependentPatterns() const override
Return the patterns on which the constraint depends.
Definition: dataflow_pattern.h:833
Managed reference to SameShapePatternNode.
Definition: dataflow_pattern.h:848
TVM_DEFINE_OBJECT_REF_METHODS(SameShapeConstraint, DFConstraint, SameShapeConstraintNode)
SameShapeConstraint(Array< DFPattern > args)
A pattern that asserting a root pattern has a certain shape.
Definition: dataflow_pattern.h:801
static constexpr const char * _type_key
Definition: dataflow_pattern.h:811
void VisitAttrs(tvm::AttrVisitor *v)
Definition: dataflow_pattern.h:806
TVM_DECLARE_FINAL_OBJECT_INFO(ShapePatternNode, DFPatternNode)
DFPattern pattern
Definition: dataflow_pattern.h:803
Array< PrimExpr > shape
Definition: dataflow_pattern.h:804
Managed reference to ShapePatternNode.
Definition: dataflow_pattern.h:819
TVM_DEFINE_OBJECT_REF_METHODS(ShapePattern, DFPattern, ShapePatternNode)
ShapePattern(DFPattern pattern, Array< PrimExpr > type)
Pattern for matching a certain struct info.
Definition: dataflow_pattern.h:777
void VisitAttrs(tvm::AttrVisitor *v)
Definition: dataflow_pattern.h:782
StructInfo struct_info
Definition: dataflow_pattern.h:780
static constexpr const char * _type_key
Definition: dataflow_pattern.h:787
TVM_DECLARE_FINAL_OBJECT_INFO(StructInfoPatternNode, DFPatternNode)
DFPattern pattern
Definition: dataflow_pattern.h:779
Definition: dataflow_pattern.h:791
TVM_DEFINE_OBJECT_REF_METHODS(StructInfoPattern, DFPattern, StructInfoPatternNode)
StructInfoPattern(DFPattern pattern, StructInfo struct_info)
Managed reference to StructInfoNode.
Definition: expr.h:130
A pattern to match n'th indexing to a tuple.
Definition: dataflow_pattern.h:613
static constexpr const char * _type_key
Definition: dataflow_pattern.h:623
TVM_DECLARE_FINAL_OBJECT_INFO(TupleGetItemPatternNode, DFPatternNode)
DFPattern tuple
Definition: dataflow_pattern.h:615
void VisitAttrs(tvm::AttrVisitor *v)
Definition: dataflow_pattern.h:618
int index
Definition: dataflow_pattern.h:616
Managed reference to TupleGetItemPatternNode.
Definition: dataflow_pattern.h:631
TVM_DEFINE_OBJECT_REF_METHODS(TupleGetItemPattern, DFPattern, TupleGetItemPatternNode)
TupleGetItemPattern(DFPattern tuple, int index)
Pattern to match a tuple of ordered expressions.
Definition: dataflow_pattern.h:564
tvm::Array< DFPattern > fields
Definition: dataflow_pattern.h:566
TVM_DECLARE_FINAL_OBJECT_INFO(TuplePatternNode, DFPatternNode)
void VisitAttrs(tvm::AttrVisitor *v)
Definition: dataflow_pattern.h:568
static constexpr const char * _type_key
Definition: dataflow_pattern.h:570
Managed reference to TuplePatternNode.
Definition: dataflow_pattern.h:578
TVM_DEFINE_OBJECT_REF_METHODS(TuplePattern, DFPattern, TuplePatternNode)
TuplePattern(tvm::Array< DFPattern > fields)
Pattern for matching a certain type.
Definition: dataflow_pattern.h:749
void VisitAttrs(tvm::AttrVisitor *v)
Definition: dataflow_pattern.h:754
TVM_DECLARE_FINAL_OBJECT_INFO(TypePatternNode, DFPatternNode)
DFPattern pattern
Definition: dataflow_pattern.h:751
Type type
Definition: dataflow_pattern.h:752
static constexpr const char * _type_key
Definition: dataflow_pattern.h:759
Managed reference to TypePatternNode.
Definition: dataflow_pattern.h:767
TVM_DEFINE_OBJECT_REF_METHODS(TypePattern, DFPattern, TypePatternNode)
TypePattern(DFPattern pattern, Type type)
A pattern to match multiple expressions unorderedly.
Definition: dataflow_pattern.h:588
tvm::Array< DFPattern > fields
Definition: dataflow_pattern.h:590
static constexpr const char * _type_key
Definition: dataflow_pattern.h:594
void VisitAttrs(tvm::AttrVisitor *v)
Definition: dataflow_pattern.h:592
TVM_DECLARE_FINAL_OBJECT_INFO(UnorderedTuplePatternNode, DFPatternNode)
Managed reference to UnorderedTuplePatternNode.
Definition: dataflow_pattern.h:602
UnorderedTuplePattern(tvm::Array< DFPattern > fields)
TVM_DEFINE_OBJECT_REF_METHODS(UnorderedTuplePattern, DFPattern, UnorderedTuplePatternNode)
A Pattern to Match a Relax Variable.
Definition: dataflow_pattern.h:370
static constexpr const uint32_t _type_child_slots
Definition: dataflow_pattern.h:377
void VisitAttrs(tvm::AttrVisitor *v)
Definition: dataflow_pattern.h:374
String name
Definition: dataflow_pattern.h:372
const String & name_hint() const
Definition: dataflow_pattern.h:373
static constexpr const char * _type_key
Definition: dataflow_pattern.h:376
TVM_DECLARE_BASE_OBJECT_INFO(VarPatternNode, DFPatternNode)
Managed reference to a VarPattern.
Definition: dataflow_pattern.h:385
TVM_DEFINE_OBJECT_REF_METHODS(VarPattern, DFPattern, VarPatternNode)
VarPattern(String name_hint)
Create a pattern matching by variable name.
Wildcard Pattern is a pattern that can match anything.
Definition: dataflow_pattern.h:721
static constexpr const char * _type_key
Definition: dataflow_pattern.h:725
void VisitAttrs(tvm::AttrVisitor *v)
Definition: dataflow_pattern.h:723
TVM_DECLARE_FINAL_OBJECT_INFO(WildcardPatternNode, DFPatternNode)
Managed reference to WildcardPatternNode.
Definition: dataflow_pattern.h:733
TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(WildcardPattern, DFPattern, WildcardPatternNode)
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:289
Runtime primitive data type.
Definition: data_type.h:43
Map container of NodeRef->NodeRef in DSL graph. Map implements copy on write semantics,...
Definition: map.h:1271
A custom smart pointer for Object.
Definition: object.h:363
Base class of all object reference.
Definition: object.h:520
const Object * get() const
Definition: object.h:555
Object * get_mutable() const
Definition: object.h:608
base class of all object containers.
Definition: object.h:172
Optional container that to represent to a Nullable variant of T.
Definition: optional.h:51
Reference to string objects.
Definition: string.h:97
CallPattern IsCallTIR(const String &name, Optional< TuplePattern > args=NullOpt)
Syntatic Sugar for call_tir (return a tensor)
PatternSeq operator^(const PatternSeq &lhs, const PatternSeq &rhs)
Syntax sugar of UsedBy(lhs, rhs, -1).
CallPattern IsCallDPSPacked(const String &name, Optional< TuplePattern > args=NullOpt)
Syntatic Sugar for call_dps_packed (return a tensor)
ExprPattern IsOp(const String &op_name)
Syntatic Sugar for creating a ExprPattern base on an Op.
DFPattern IsTuple(const Array< DFPattern > &fields, bool unordered=false)
Syntatic Sugar for creating TuplePattern or UnorderedTuplePattern (unordered=true)
WildcardPattern Wildcard()
Syntatic Sugar for creating a WildcardPattern.
ConstantPattern IsConst()
Syntatic Sugar for creating a ConstantPattern.
PatternSeq UsedBy(const PatternSeq &lhs, const PatternSeq &rhs, int index=-1)
Create used-by relationship between lhs[-1] and rhs[0], with [*lhs, *rhs] returned.
PatternSeq OnlyUsedBy(const PatternSeq &lhs, const PatternSeq &rhs, int index=-1)
Create only-used-by relationship between lhs[-1] and rhs[0], with [*lhs, *rhs] returned.
ExprPattern IsExpr(const Expr &expr)
Syntatic Sugar for creating a ExprPattern.
PatternSeq operator>>(const PatternSeq &lhs, const PatternSeq &rhs)
Syntax sugar of OnlyUsedBy(lhs, rhs, -1).
TupleGetItemPattern IsTupleGetItem(const DFPattern tuple, int index=-1)
Syntatic Sugar for creating a TupleGetItemPattern.
VarPattern IsVar(const String &name)
Syntatic Sugar for creating a VarPattern with a name.
Tensor shape(const Tensor &src, DataType dtype, const std::string name="T_shape", const std::string tag=kInjective)
Get the shape of input tensor.
Definition: transform.h:1913
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:36
constexpr runtime::NullOptType NullOpt
Definition: optional.h:169
Runtime Optional container types.
Constraint of a DFPattern edge (producer -> consumer) in graph-level matching.
Definition: dataflow_pattern.h:139
int index
Definition: dataflow_pattern.h:145
bool operator==(const PairCons &other) const
Definition: dataflow_pattern.h:155
enum tvm::relax::PairCons::Type type
Type
Constraint types of the edge.
Definition: dataflow_pattern.h:141
@ kOnlyUsedBy
Definition: dataflow_pattern.h:143
@ kUsedBy
Definition: dataflow_pattern.h:142
PairCons(Type t, int index=-1)
Construct a new PairCons object.
Definition: dataflow_pattern.h:153
RAII wrapper function to enter and exit a context object similar to python's with syntax.