24 #ifndef TVM_RELAX_DATAFLOW_PATTERN_FUNCTOR_H_
25 #define TVM_RELAX_DATAFLOW_PATTERN_FUNCTOR_H_
29 #include <unordered_set>
42 template <
typename FType>
46 #define DFPATTERN_FUNCTOR_DEFAULT \
47 { return VisitDFPatternDefault_(op, std::forward<Args>(args)...); }
49 #define RELAX_DFPATTERN_FUNCTOR_DISPATCH(OP) \
50 vtable.template set_dispatch<OP>([](const ObjectRef& n, TSelf* self, Args... args) { \
51 return self->VisitDFPattern_(static_cast<const OP*>(n.get()), std::forward<Args>(args)...); \
54 template <
typename R,
typename... Args>
70 return VisitDFPattern(n, std::forward<Args>(args)...);
80 static FType vtable = InitVTable();
81 return vtable(n,
this, std::forward<Args>(args)...);
113 LOG(FATAL) <<
"Do not have a default for " << op->
GetTypeKey();
119 static FType InitVTable() {
A dynamically dispatched functor on the type of the first argument.
Definition: functor.h:64
Match a conjunction of other patterns.
Definition: dataflow_pattern.h:639
A pattern that asserting a root pattern has certain attributes.
Definition: dataflow_pattern.h:884
A pattern to match a callable node in Relax.
Definition: dataflow_pattern.h:460
A Pattern to Match a Relax Constant.
Definition: dataflow_pattern.h:439
Definition: dataflow_pattern_functor.h:55
R operator()(const DFPattern &n, Args... args)
Same as call.
Definition: dataflow_pattern_functor.h:69
virtual R VisitDFPattern_(const ShapePatternNode *op, Args... args)
Definition: dataflow_pattern_functor.h:93
virtual R VisitDFPattern_(const PrimArrPatternNode *op, Args... args)
Definition: dataflow_pattern_functor.h:108
virtual R VisitDFPattern_(const ConstantPatternNode *op, Args... args)
Definition: dataflow_pattern_functor.h:89
virtual R VisitDFPattern_(const GlobalVarPatternNode *op, Args... args)
Definition: dataflow_pattern_functor.h:105
virtual R VisitDFPattern_(const OrPatternNode *op, Args... args)
Definition: dataflow_pattern_functor.h:84
virtual R VisitDFPattern_(const ExprPatternNode *op, Args... args)
Definition: dataflow_pattern_functor.h:91
virtual R VisitDFPattern_(const UnorderedTuplePatternNode *op, Args... args)
Definition: dataflow_pattern_functor.h:109
virtual R VisitDFPattern_(const StructInfoPatternNode *op, Args... args)
Definition: dataflow_pattern_functor.h:97
virtual R VisitDFPattern_(const ExternFuncPatternNode *op, Args... args)
Definition: dataflow_pattern_functor.h:106
virtual R VisitDFPattern_(const VarPatternNode *op, Args... args)
Definition: dataflow_pattern_functor.h:101
virtual R VisitDFPattern_(const NotPatternNode *op, Args... args)
Definition: dataflow_pattern_functor.h:86
virtual R VisitDFPattern_(const DataflowVarPatternNode *op, Args... args)
Definition: dataflow_pattern_functor.h:103
virtual R VisitDFPattern_(const WildcardPatternNode *op, Args... args)
Definition: dataflow_pattern_functor.h:100
virtual R VisitDFPattern_(const TupleGetItemPatternNode *op, Args... args)
Definition: dataflow_pattern_functor.h:94
virtual R VisitDFPatternDefault_(const Object *op, Args...)
Definition: dataflow_pattern_functor.h:112
virtual R VisitDFPattern_(const AttrPatternNode *op, Args... args)
Definition: dataflow_pattern_functor.h:87
virtual R VisitDFPattern_(const AndPatternNode *op, Args... args)
Definition: dataflow_pattern_functor.h:85
virtual R VisitDFPattern_(const CallPatternNode *op, Args... args)
Definition: dataflow_pattern_functor.h:88
virtual R VisitDFPattern(const DFPattern &n, Args... args)
The functor call.
Definition: dataflow_pattern_functor.h:78
virtual R VisitDFPattern_(const FunctionPatternNode *op, Args... args)
Definition: dataflow_pattern_functor.h:92
virtual R VisitDFPattern_(const DataTypePatternNode *op, Args... args)
Definition: dataflow_pattern_functor.h:90
virtual ~DFPatternFunctor()
virtual destructor
Definition: dataflow_pattern_functor.h:62
virtual R VisitDFPattern_(const TypePatternNode *op, Args... args)
Definition: dataflow_pattern_functor.h:99
virtual R VisitDFPattern_(const TuplePatternNode *op, Args... args)
Definition: dataflow_pattern_functor.h:96
A dynamical functor that dispatches on in the first DFPattern argument.
Definition: dataflow_pattern_functor.h:43
A simple visitor wrapper around DFPatternFunctor. Recursively visit the content.
Definition: dataflow_pattern_functor.h:154
void VisitDFPattern_(const NotPatternNode *op) override
void VisitDFPattern_(const ShapePatternNode *op) override
void VisitDFPattern_(const FunctionPatternNode *op) override
void VisitDFPattern_(const OrPatternNode *op) override
void VisitDFPattern_(const ExternFuncPatternNode *op) override
void VisitDFPattern_(const AndPatternNode *op) override
void VisitDFPattern(const DFPattern &pattern) override
void VisitDFPattern_(const TuplePatternNode *op) override
void VisitDFPattern_(const VarPatternNode *op) override
void VisitDFPattern_(const AttrPatternNode *op) override
void VisitDFPattern_(const ExprPatternNode *op) override
void VisitDFPattern_(const ConstantPatternNode *op) override
void VisitDFPattern_(const UnorderedTuplePatternNode *op) override
void VisitDFPattern_(const TupleGetItemPatternNode *op) override
void VisitDFPattern_(const DataTypePatternNode *op) override
void VisitDFPattern_(const WildcardPatternNode *op) override
void VisitDFPattern_(const GlobalVarPatternNode *op) override
void VisitDFPattern_(const PrimArrPatternNode *op) override
void VisitDFPattern_(const DataflowVarPatternNode *op) override
void VisitDFPattern_(const TypePatternNode *op) override
void VisitDFPattern_(const CallPatternNode *op) override
void VisitDFPattern_(const StructInfoPatternNode *op) override
std::unordered_set< const Object * > visited_
Definition: dataflow_pattern_functor.h:182
Managed reference to dataflow patterns.
Definition: dataflow_pattern.h:101
A pattern that asserting a root pattern has a certain data type.
Definition: dataflow_pattern.h:856
A Pattern to Match a Relax Dataflow Variable.
Definition: dataflow_pattern.h:398
Pattern for Relax Expression.
Definition: dataflow_pattern.h:344
A pattern of external function.
Definition: dataflow_pattern.h:913
A pattern to match a Relax Function.
Definition: dataflow_pattern.h:522
A Pattern to Match a Relax Global Variable.
Definition: dataflow_pattern.h:419
Pattern for rejecting a certain pattern.
Definition: dataflow_pattern.h:695
Match a disjunction of other patterns.
Definition: dataflow_pattern.h:667
A pattern to match an array of PrimExpr.
Definition: dataflow_pattern.h:499
A pattern that asserting a root pattern has a certain shape.
Definition: dataflow_pattern.h:799
Pattern for matching a certain struct info.
Definition: dataflow_pattern.h:775
A pattern to match n'th indexing to a tuple.
Definition: dataflow_pattern.h:611
Pattern to match a tuple of ordered expressions.
Definition: dataflow_pattern.h:562
Pattern for matching a certain type.
Definition: dataflow_pattern.h:747
A pattern to match multiple expressions unorderedly.
Definition: dataflow_pattern.h:586
A Pattern to Match a Relax Variable.
Definition: dataflow_pattern.h:369
Wildcard Pattern is a pattern that can match anything.
Definition: dataflow_pattern.h:719
Base class of all object reference.
Definition: object.h:519
bool defined() const
Definition: object.h:552
base class of all object containers.
Definition: object.h:171
std::string GetTypeKey() const
Definition: object.h:184
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
A pattern language for matching dataflow properties.
#define RELAX_DFPATTERN_FUNCTOR_DISPATCH(OP)
Definition: dataflow_pattern_functor.h:49
#define DFPATTERN_FUNCTOR_DEFAULT
Definition: dataflow_pattern_functor.h:46