24#ifndef TVM_RELAX_DATAFLOW_PATTERN_H_
25#define TVM_RELAX_DATAFLOW_PATTERN_H_
28#include <tvm/ffi/container/array.h>
29#include <tvm/ffi/optional.h>
30#include <tvm/ffi/reflection/registry.h>
63class SameShapeConstraint;
106 template <
typename... Args>
199 std::function<ffi::Optional<Var>(
const DFPatternObj*)> match_state)
const = 0;
220 namespace refl = tvm::ffi::reflection;
233 TVM_DLL
explicit PatternSeq(tvm::ffi::Array<DFPattern> patterns,
bool only_used_by =
false);
262 std::map<DFPattern, std::vector<std::pair<DFPattern, std::vector<PairCons>>>>
edge_constraints;
284 TVM_FFI_ICHECK(get() !=
nullptr);
289 TVM_FFI_ICHECK(get() !=
nullptr);
301 auto& pairs = (*this)->edge_constraints[producer];
302 auto it = std::find_if(pairs.begin(), pairs.end(),
303 [consumer](
auto p) { return p.first == consumer; });
304 if (it == pairs.end()) {
305 pairs.emplace_back(consumer, std::vector{cons});
307 auto& vec = it->second;
308 TVM_FFI_ICHECK(std::find(vec.cbegin(), vec.cend(), cons) == vec.cend())
309 <<
"Constraint already exists";
313 auto& patterns = (*this)->src_ordered;
314 if (std::find(patterns.begin(), patterns.end(), producer) == patterns.end()) {
315 patterns.push_back(producer);
325 (*this)->validation_constraints.push_back(constraint);
329 TVM_DLL
static ffi::Optional<PatternContext>
Current();
352 namespace refl = tvm::ffi::reflection;
379 namespace refl = tvm::ffi::reflection;
409 namespace refl = tvm::ffi::reflection;
410 refl::ObjectDef<DataflowVarPatternObj>();
455 namespace refl = tvm::ffi::reflection;
456 refl::ObjectDef<ConstantPatternObj>();
469 data_ = std::move(n);
489 tvm::ffi::Array<DFPattern>
args;
501 namespace refl = tvm::ffi::reflection;
502 refl::ObjectDef<CallPatternObj>()
525 namespace refl = tvm::ffi::reflection;
561 namespace refl = tvm::ffi::reflection;
562 refl::ObjectDef<FunctionPatternObj>()
594 namespace refl = tvm::ffi::reflection;
619 namespace refl = tvm::ffi::reflection;
651 namespace refl = tvm::ffi::reflection;
652 refl::ObjectDef<TupleGetItemPatternObj>()
685 namespace refl = tvm::ffi::reflection;
686 refl::ObjectDef<AndPatternObj>()
717 namespace refl = tvm::ffi::reflection;
718 refl::ObjectDef<OrPatternObj>()
747 namespace refl = tvm::ffi::reflection;
770 namespace refl = tvm::ffi::reflection;
771 refl::ObjectDef<WildcardPatternObj>();
784 TVM_FFI_ICHECK(data !=
nullptr);
785 data_ = std::move(data);
809 namespace refl = tvm::ffi::reflection;
810 refl::ObjectDef<TypePatternObj>()
836 namespace refl = tvm::ffi::reflection;
837 refl::ObjectDef<ShapePatternObj>()
865 std::function<ffi::Optional<Var>(
const DFPatternObj*)> match_state)
const override;
868 namespace refl = tvm::ffi::reflection;
899 namespace refl = tvm::ffi::reflection;
900 refl::ObjectDef<DataTypePatternObj>()
930 namespace refl = tvm::ffi::reflection;
931 refl::ObjectDef<AttrPatternObj>()
961 namespace refl = tvm::ffi::reflection;
962 refl::ObjectDef<ExternFuncPatternObj>().def_ro(
"global_symbol",
996 ffi::Optional<TuplePattern> args = std::nullopt);
1005template <
typename... Args>
1007 return CallPattern(ffi::GetRef<DFPattern>(this->get()),
1008 ffi::Array<DFPattern>({std::forward<Args>(args)...}));
Managed reference to DictAttrsObj.
Definition attrs.h:108
Managed reference to ExprObj.
Definition expr.h:101
Managed reference to TypeObj.
Definition type.h:75
static TVM_TIRX_DLL Type Missing()
Construct a MissingType for type information not yet populated.
RAII wrapper function to enter and exit a context object similar to python's with syntax.
Definition with_context.h:58
Match a conjunction of other patterns.
Definition dataflow_pattern.h:675
AndPatternObj(ffi::UnsafeInit)
Definition dataflow_pattern.h:679
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.dpl.AndPattern", AndPatternObj, DFPatternObj)
static void RegisterReflection()
Definition dataflow_pattern.h:684
DFPattern right
Definition dataflow_pattern.h:682
AndPatternObj(DFPattern left, DFPattern right)
Definition dataflow_pattern.h:677
DFPattern left
Definition dataflow_pattern.h:681
Managed reference to AndPatternObj.
Definition dataflow_pattern.h:697
AndPattern(DFPattern lhs, DFPattern rhs)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(AndPattern, DFPattern, AndPatternObj)
A pattern that asserting a root pattern has certain attributes.
Definition dataflow_pattern.h:921
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.dpl.AttrPattern", AttrPatternObj, DFPatternObj)
AttrPatternObj(DFPattern pattern)
Definition dataflow_pattern.h:923
DictAttrs attrs
Definition dataflow_pattern.h:927
static void RegisterReflection()
Definition dataflow_pattern.h:929
DFPattern pattern
Definition dataflow_pattern.h:926
AttrPatternObj(ffi::UnsafeInit)
Definition dataflow_pattern.h:924
Managed reference to AttrPatternObj.
Definition dataflow_pattern.h:942
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(AttrPattern, DFPattern, AttrPatternObj)
AttrPattern(DFPattern pattern, DictAttrs attrs)
A pattern to match a callable node in Relax.
Definition dataflow_pattern.h:478
static void RegisterReflection()
Definition dataflow_pattern.h:500
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.dpl.CallPattern", CallPatternObj, DFPatternObj)
bool varg_default_wildcard
Definition dataflow_pattern.h:496
tvm::ffi::Array< DFPattern > args
Definition dataflow_pattern.h:489
CallPatternObj(DFPattern op)
Definition dataflow_pattern.h:480
CallPatternObj(ffi::UnsafeInit)
Definition dataflow_pattern.h:481
DFPattern op
Definition dataflow_pattern.h:488
Definition dataflow_pattern.h:509
CallPattern(DFPattern op, ffi::Array< DFPattern > args, bool varg_default_wildcard=false)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(CallPattern, DFPattern, CallPatternObj)
A Pattern to Match a Relax GenericConst.
Definition dataflow_pattern.h:452
static void RegisterReflection()
Definition dataflow_pattern.h:454
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.dpl.ConstantPattern", ConstantPatternObj, DFPatternObj)
Managed reference to a ConstantPattern.
Definition dataflow_pattern.h:465
ConstantPattern(ffi::UnsafeInit tag, ffi::ObjectPtr< ConstantPatternObj > n)
Definition dataflow_pattern.h:467
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ConstantPattern, DFPattern, ConstantPatternObj)
Additional constraints on the graph.
Definition dataflow_pattern.h:166
static constexpr const uint32_t _type_child_slots
Definition dataflow_pattern.h:201
TVM_FFI_DECLARE_OBJECT_INFO("relax.dpl.DFConstraint", DFConstraintObj, ffi::Object)
virtual std::tuple< PrimExpr, bool > AsCondition(std::function< ffi::Optional< Var >(const DFPatternObj *)> match_state) const =0
Convert the constraint to a PrimExpr.
virtual ffi::Array< DFPattern > GetDependentPatterns() const =0
Return the patterns on which the constraint depends.
Definition dataflow_pattern.h:205
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(DFConstraint, ffi::ObjectRef, DFConstraintObj)
Base type of all dataflow patterns.
Definition dataflow_pattern.h:93
static constexpr const uint32_t _type_child_slots
Definition dataflow_pattern.h:95
TVM_FFI_DECLARE_OBJECT_INFO("relax.dpl.DFPattern", DFPatternObj, ffi::Object)
Managed reference to dataflow patterns.
Definition dataflow_pattern.h:103
CallPattern operator()(const std::vector< DFPattern > &args) const
Syntatic Sugar for creating a CallPattern.
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:1006
TypePattern HasType(const Type &ty) const
Syntatic Sugar for creating a TypePattern.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(DFPattern, ffi::ObjectRef, DFPatternObj)
AttrPattern HasAttr(const ffi::Map< ffi::String, Any > &attrs) const
Syntatic Sugar for creating an AttrPattern.
ShapePattern HasShape(const ffi::Array< PrimExpr > &shape) const
Syntatic Sugar for creating a ShapePattern.
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.
DataTypePattern HasDtype(const std::string &dtype) const
Syntatic Sugar for creating a DataTypePattern with a data type's name.
DataTypePattern HasDtype(DLDataType dtype) const
Syntatic Sugar for creating a DataTypePattern with a dtype.
A pattern that asserting a root pattern has a certain data type.
Definition dataflow_pattern.h:890
static void RegisterReflection()
Definition dataflow_pattern.h:898
DFPattern pattern
Definition dataflow_pattern.h:895
DataTypePatternObj(ffi::UnsafeInit)
Definition dataflow_pattern.h:893
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.dpl.DataTypePattern", DataTypePatternObj, DFPatternObj)
DataTypePatternObj(DFPattern pattern)
Definition dataflow_pattern.h:892
DLDataType dtype
Definition dataflow_pattern.h:896
Managed reference to DataTypePatternObj.
Definition dataflow_pattern.h:911
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(DataTypePattern, DFPattern, DataTypePatternObj)
DataTypePattern(DFPattern pattern, DLDataType dtype)
A Pattern to Match a Relax Dataflow Variable.
Definition dataflow_pattern.h:406
static void RegisterReflection()
Definition dataflow_pattern.h:408
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.dpl.DataflowVarPattern", DataflowVarPatternObj, VarPatternObj)
Managed reference to a DataflowVarPattern.
Definition dataflow_pattern.h:420
DataflowVarPattern(ffi::String name_hint)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(DataflowVarPattern, DFPattern, DataflowVarPatternObj)
Pattern for Relax Expression.
Definition dataflow_pattern.h:344
ExprPatternObj(Expr expr)
Definition dataflow_pattern.h:346
ExprPatternObj(ffi::UnsafeInit)
Definition dataflow_pattern.h:347
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.dpl.ExprPattern", ExprPatternObj, DFPatternObj)
Expr expr
Definition dataflow_pattern.h:349
static void RegisterReflection()
Definition dataflow_pattern.h:351
Managed reference to an ExprPattern.
Definition dataflow_pattern.h:362
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ExprPattern, DFPattern, ExprPatternObj)
A pattern of external function.
Definition dataflow_pattern.h:953
const ffi::String & global_symbol() const
The external function name.
Definition dataflow_pattern.h:958
ffi::String global_symbol_
Definition dataflow_pattern.h:955
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.dpl.ExternFuncPattern", ExternFuncPatternObj, DFPatternObj)
static void RegisterReflection()
Definition dataflow_pattern.h:960
Managed reference to ExternFuncPatternObj.
Definition dataflow_pattern.h:973
ExternFuncPattern(ffi::String global_symbol)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ExternFuncPattern, DFPattern, ExternFuncPatternObj)
A pattern to match a Relax Function.
Definition dataflow_pattern.h:546
tvm::ffi::Array< DFPattern > params
Definition dataflow_pattern.h:551
DFPattern body
Definition dataflow_pattern.h:558
FunctionPatternObj(DFPattern body)
Definition dataflow_pattern.h:548
static void RegisterReflection()
Definition dataflow_pattern.h:560
FunctionPatternObj(ffi::UnsafeInit)
Definition dataflow_pattern.h:549
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.dpl.FunctionPattern", FunctionPatternObj, DFPatternObj)
Managed reference to FunctionPatternObj.
Definition dataflow_pattern.h:573
FunctionPattern(tvm::ffi::Array< DFPattern > params, DFPattern body)
Constructor.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(FunctionPattern, DFPattern, FunctionPatternObj)
A Pattern to Match a Relax Global Variable.
Definition dataflow_pattern.h:432
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.dpl.GlobalVarPattern", GlobalVarPatternObj, DFPatternObj)
Managed reference to a GlobalVarPattern.
Definition dataflow_pattern.h:442
GlobalVarPattern(ffi::String name_hint)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(GlobalVarPattern, DFPattern, GlobalVarPatternObj)
Pattern for rejecting a certain pattern.
Definition dataflow_pattern.h:739
DFPattern reject
Definition dataflow_pattern.h:744
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.dpl.NotPattern", NotPatternObj, DFPatternObj)
static void RegisterReflection()
Definition dataflow_pattern.h:746
NotPatternObj(DFPattern reject)
Definition dataflow_pattern.h:741
NotPatternObj(ffi::UnsafeInit)
Definition dataflow_pattern.h:742
Managed reference to NotPatternObj.
Definition dataflow_pattern.h:757
NotPattern(DFPattern reject)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(NotPattern, DFPattern, NotPatternObj)
Match a disjunction of other patterns.
Definition dataflow_pattern.h:707
DFPattern right
Definition dataflow_pattern.h:714
OrPatternObj(DFPattern left, DFPattern right)
Definition dataflow_pattern.h:709
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.dpl.OrPattern", OrPatternObj, DFPatternObj)
OrPatternObj(ffi::UnsafeInit)
Definition dataflow_pattern.h:711
static void RegisterReflection()
Definition dataflow_pattern.h:716
DFPattern left
Definition dataflow_pattern.h:713
Managed reference to OrPatternObj.
Definition dataflow_pattern.h:729
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(OrPattern, DFPattern, OrPatternObj)
OrPattern(DFPattern left, DFPattern right)
A context to manage the graph-level pattern matching.
Definition dataflow_pattern.h:252
std::vector< DFPattern > src_ordered
Definition dataflow_pattern.h:266
ExternUse
Constrainting matched graph with assertion to external uses.
Definition dataflow_pattern.h:255
@ kMay
Definition dataflow_pattern.h:256
@ kMustNot
Definition dataflow_pattern.h:257
enum tvm::relax::PatternContextObj::ExternUse allow_extern_use
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.dpl.PatternContext", PatternContextObj, ffi::Object)
std::map< DFPattern, std::vector< std::pair< DFPattern, std::vector< PairCons > > > > edge_constraints
Definition dataflow_pattern.h:262
std::vector< DFConstraint > validation_constraints
Definition dataflow_pattern.h:269
Managed reference to a pattern context.
Definition dataflow_pattern.h:277
void add_constraint(DFConstraint constraint)
Add a validation constraint.
Definition dataflow_pattern.h:324
void ExitWithScope() const
The RAII-like exit of a constraint context scope.
static ffi::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:300
PatternContextObj * operator->()
Definition dataflow_pattern.h:288
const PatternContextObj * operator->() const
Definition dataflow_pattern.h:283
PatternContext(bool incremental=false)
static constexpr bool _type_is_nullable
Definition dataflow_pattern.h:280
PatternContext(ffi::UnsafeInit tag)
Definition dataflow_pattern.h:279
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:214
std::vector< PairCons > pair_constraints
Definition dataflow_pattern.h:217
static void RegisterReflection()
Definition dataflow_pattern.h:219
tvm::ffi::Array< DFPattern > patterns
Definition dataflow_pattern.h:216
TVM_FFI_DECLARE_OBJECT_INFO("relax.dpl.PatternSeq", PatternSeqObj, ffi::Object)
Managed reference to pattern sequences.
Definition dataflow_pattern.h:230
PatternSeq OnlyUsedBy(PatternSeq other, int index=-1) const
PatternSeq UsedBy(PatternSeq other, int index=-1) const
PatternSeq(tvm::ffi::Array< DFPattern > patterns, bool only_used_by=false)
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.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(PatternSeq, ffi::ObjectRef, PatternSeqObj)
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:520
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.dpl.PrimArrPattern", PrimArrPatternObj, DFPatternObj)
static void RegisterReflection()
Definition dataflow_pattern.h:524
ffi::Array< PrimExpr > fields
Definition dataflow_pattern.h:522
Managed reference to a PrimArrPattern.
Definition dataflow_pattern.h:535
PrimArrPattern(ffi::Array< PrimExpr > arr)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(PrimArrPattern, DFPattern, PrimArrPatternObj)
A pattern that asserting multiple root patterns have the same shape.
Definition dataflow_pattern.h:858
std::tuple< PrimExpr, bool > AsCondition(std::function< ffi::Optional< Var >(const DFPatternObj *)> match_state) const override
Convert the constraint to a PrimExpr.
ffi::Array< DFPattern > GetDependentPatterns() const override
Return the patterns on which the constraint depends.
Definition dataflow_pattern.h:862
ffi::Array< DFPattern > args
Definition dataflow_pattern.h:860
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.dpl.SameShapeConstraint", SameShapeConstraintObj, DFConstraintObj)
static void RegisterReflection()
Definition dataflow_pattern.h:867
Managed reference to SameShapePatternNode.
Definition dataflow_pattern.h:879
SameShapeConstraint(ffi::Array< DFPattern > args)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(SameShapeConstraint, DFConstraint, SameShapeConstraintObj)
A pattern that asserting a root pattern has a certain shape.
Definition dataflow_pattern.h:827
ffi::Array< PrimExpr > shape
Definition dataflow_pattern.h:833
ShapePatternObj(ffi::UnsafeInit)
Definition dataflow_pattern.h:830
ShapePatternObj(DFPattern pattern)
Definition dataflow_pattern.h:829
static void RegisterReflection()
Definition dataflow_pattern.h:835
DFPattern pattern
Definition dataflow_pattern.h:832
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.dpl.ShapePattern", ShapePatternObj, DFPatternObj)
Managed reference to ShapePatternObj.
Definition dataflow_pattern.h:848
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ShapePattern, DFPattern, ShapePatternObj)
ShapePattern(DFPattern pattern, ffi::Array< PrimExpr > type)
A pattern to match n'th indexing to a tuple.
Definition dataflow_pattern.h:642
TupleGetItemPatternObj(ffi::UnsafeInit)
Definition dataflow_pattern.h:645
int index
Definition dataflow_pattern.h:648
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.dpl.TupleGetItemPattern", TupleGetItemPatternObj, DFPatternObj)
static void RegisterReflection()
Definition dataflow_pattern.h:650
TupleGetItemPatternObj(DFPattern tuple)
Definition dataflow_pattern.h:644
DFPattern tuple
Definition dataflow_pattern.h:647
Managed reference to TupleGetItemPatternObj.
Definition dataflow_pattern.h:664
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(TupleGetItemPattern, DFPattern, TupleGetItemPatternObj)
TupleGetItemPattern(DFPattern tuple, int index)
Pattern to match a tuple of ordered expressions.
Definition dataflow_pattern.h:589
tvm::ffi::Array< DFPattern > fields
Definition dataflow_pattern.h:591
static void RegisterReflection()
Definition dataflow_pattern.h:593
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.dpl.TuplePattern", TuplePatternObj, DFPatternObj)
Managed reference to TuplePatternObj.
Definition dataflow_pattern.h:604
TuplePattern(tvm::ffi::Array< DFPattern > fields)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(TuplePattern, DFPattern, TuplePatternObj)
Pattern for matching a certain type.
Definition dataflow_pattern.h:800
TypePatternObj(DFPattern pattern)
Definition dataflow_pattern.h:802
static void RegisterReflection()
Definition dataflow_pattern.h:808
TypePatternObj(ffi::UnsafeInit)
Definition dataflow_pattern.h:803
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.dpl.TypePattern", TypePatternObj, DFPatternObj)
Type ty
Definition dataflow_pattern.h:806
DFPattern pattern
Definition dataflow_pattern.h:805
Definition dataflow_pattern.h:817
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(TypePattern, DFPattern, TypePatternObj)
TypePattern(DFPattern pattern, Type ty)
A pattern to match multiple expressions unorderedly.
Definition dataflow_pattern.h:614
static void RegisterReflection()
Definition dataflow_pattern.h:618
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.dpl.UnorderedTuplePattern", UnorderedTuplePatternObj, DFPatternObj)
tvm::ffi::Array< DFPattern > fields
Definition dataflow_pattern.h:616
Managed reference to UnorderedTuplePatternObj.
Definition dataflow_pattern.h:630
UnorderedTuplePattern(tvm::ffi::Array< DFPattern > fields)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(UnorderedTuplePattern, DFPattern, UnorderedTuplePatternObj)
A Pattern to Match a Relax Variable.
Definition dataflow_pattern.h:373
ffi::String name
Definition dataflow_pattern.h:375
static void RegisterReflection()
Definition dataflow_pattern.h:378
const ffi::String & name_hint() const
Definition dataflow_pattern.h:376
static constexpr const uint32_t _type_child_slots
Definition dataflow_pattern.h:383
TVM_FFI_DECLARE_OBJECT_INFO("relax.dpl.VarPattern", VarPatternObj, DFPatternObj)
Managed reference to a VarPattern.
Definition dataflow_pattern.h:391
VarPattern(ffi::String name_hint)
Create a pattern matching by variable name.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(VarPattern, DFPattern, VarPatternObj)
Wildcard Pattern is a pattern that can match anything.
Definition dataflow_pattern.h:767
static void RegisterReflection()
Definition dataflow_pattern.h:769
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.dpl.WildcardPattern", WildcardPatternObj, DFPatternObj)
Managed reference to WildcardPatternObj.
Definition dataflow_pattern.h:780
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(WildcardPattern, DFPattern, WildcardPatternObj)
WildcardPattern(ffi::ObjectPtr< WildcardPatternObj > data)
Definition dataflow_pattern.h:783
Coordinated symbolic analyses over an explicitly synchronized premise environment.
Definition analyzer.h:556
Managed reference to AnalyzerObj.
Definition analyzer.h:750
Parent compiler symbol visibility.
Relax types, including the richer dependent Relax type nodes.
PatternSeq operator^(const PatternSeq &lhs, const PatternSeq &rhs)
Syntax sugar of UsedBy(lhs, rhs, -1).
ExprPattern IsOp(const ffi::String &op_name)
Syntatic Sugar for creating a ExprPattern base on an Op.
DFPattern IsTuple(const ffi::Array< DFPattern > &fields, bool unordered=false)
Syntatic Sugar for creating TuplePattern or UnorderedTuplePattern (unordered=true)
CallPattern IsCallTIR(const ffi::String &name, ffi::Optional< TuplePattern > args=std::nullopt)
Syntatic Sugar for call_tir (return a tensor)
CallPattern IsCallDPSPacked(const ffi::String &name, ffi::Optional< TuplePattern > args=std::nullopt)
Syntatic Sugar for call_dps_packed (return a tensor)
WildcardPattern Wildcard()
Syntatic Sugar for creating a WildcardPattern.
VarPattern IsVar(const ffi::String &name)
Syntatic Sugar for creating a VarPattern with a name.
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.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analysis.h:41
Constraint of a DFPattern edge (producer -> consumer) in graph-level matching.
Definition dataflow_pattern.h:138
int index
Definition dataflow_pattern.h:144
bool operator==(const PairCons &other) const
Definition dataflow_pattern.h:154
enum tvm::relax::PairCons::Type type
Type
Constraint types of the edge.
Definition dataflow_pattern.h:140
@ kOnlyUsedBy
Definition dataflow_pattern.h:142
@ kUsedBy
Definition dataflow_pattern.h:141
PairCons(Type t, int index=-1)
Construct a new PairCons object.
Definition dataflow_pattern.h:152
RAII wrapper function to enter and exit a context object similar to python's with syntax.