24 #ifndef TVM_RELAY_ADT_H_
25 #define TVM_RELAY_ADT_H_
49 static constexpr
const char*
_type_key =
"relay.Pattern";
82 static constexpr
const char*
_type_key =
"relay.PatternWildcard";
102 (*this).
data_ = std::move(other.data_);
122 v->Visit(
"var", &
var);
123 v->Visit(
"span", &
span);
132 static constexpr
const char*
_type_key =
"relay.PatternVar";
160 v->Visit(
"span", &
span);
172 static constexpr
const char*
_type_key =
"relay.PatternConstructor";
199 v->Visit(
"span", &
span);
208 static constexpr
const char*
_type_key =
"relay.PatternTuple";
234 v->Visit(
"lhs", &
lhs);
235 v->Visit(
"rhs", &
rhs);
247 static constexpr
const char*
_type_key =
"relay.Clause";
291 v->Visit(
"data", &
data);
295 v->Visit(
"span", &
span);
300 equal->MarkGraphNode();
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
Span span
Span that points to the original source code. Reserved debug information.
Definition: expr.h:56
ADT constructor. Constructors compare by pointer equality.
Definition: adt.h:47
Managed reference to ConstructorNode.
Definition: adt.h:88
Base node of all non-primitive expressions.
Definition: expr.h:362
ObjectRef virtual_device_
The virtual device (VirtualDevice) for this node (the result of device planning). For first-order exp...
Definition: expr.h:418
Type checked_type_
Stores the result of type inference(type checking).
Definition: expr.h:370
Managed reference to RelayExprNode.
Definition: expr.h:442
A Reducer class to reduce the structural equality result of two objects.
Definition: structural_equal.h:137
virtual void MarkGraphNode()=0
Mark current comparison as graph node in hashing. Graph node hash will depends on the graph structure...
A Reducer class to reduce the structural hash value.
Definition: structural_hash.h:121
void DefHash(const ObjectRef &key) const
Push hash of key to the current sequence of hash values.
Definition: structural_hash.h:198
Definition: source_map.h:120
TypeData container node.
Definition: adt.h:102
Stores all data for an Algebraic Data Type (ADT).
Definition: adt.h:149
Clause container node.
Definition: adt.h:226
void SHashReduce(SHashReducer hash_reduce) const
Definition: adt.h:242
static constexpr const bool _type_has_method_shash_reduce
Definition: adt.h:249
bool SEqualReduce(const ClauseNode *other, SEqualReducer equal) const
Definition: adt.h:238
static constexpr const bool _type_has_method_sequal_reduce
Definition: adt.h:248
TVM_DECLARE_FINAL_OBJECT_INFO(ClauseNode, Object)
Pattern lhs
The pattern the clause matches.
Definition: adt.h:229
Expr rhs
The resulting value.
Definition: adt.h:231
void VisitAttrs(tvm::AttrVisitor *v)
Definition: adt.h:233
static constexpr const char * _type_key
Definition: adt.h:247
Clause(Pattern lhs, Expr rhs)
Constructor.
TVM_DEFINE_OBJECT_REF_METHODS(Clause, ObjectRef, ClauseNode)
TVM_DEFINE_OBJECT_REF_COW_METHOD(ClauseNode)
Match container node.
Definition: adt.h:277
bool complete
Should this match be complete (cover all cases)? If yes, the type checker will generate an error if t...
Definition: adt.h:288
tvm::Array< Clause > clauses
The match node clauses.
Definition: adt.h:283
Expr data
The input being deconstructed.
Definition: adt.h:280
TVM_DECLARE_FINAL_OBJECT_INFO(MatchNode, ExprNode)
void VisitAttrs(tvm::AttrVisitor *v)
Definition: adt.h:290
void SHashReduce(SHashReducer hash_reduce) const
Definition: adt.h:305
static constexpr const char * _type_key
Definition: adt.h:312
bool SEqualReduce(const MatchNode *other, SEqualReducer equal) const
Definition: adt.h:299
TVM_DEFINE_OBJECT_REF_COW_METHOD(MatchNode)
TVM_DEFINE_OBJECT_REF_METHODS(Match, RelayExpr, MatchNode)
Match(Expr data, tvm::Array< Clause > clauses, bool complete=true, Span span=Span())
Constructor.
PatternVar container node.
Definition: adt.h:150
tvm::Array< Pattern > patterns
Definition: adt.h:155
TVM_DECLARE_FINAL_OBJECT_INFO(PatternConstructorNode, PatternNode)
bool SEqualReduce(const PatternConstructorNode *other, SEqualReducer equal) const
Definition: adt.h:163
Constructor constructor
Definition: adt.h:153
void SHashReduce(SHashReducer hash_reduce) const
Definition: adt.h:167
void VisitAttrs(tvm::AttrVisitor *v)
Definition: adt.h:157
static constexpr const char * _type_key
Definition: adt.h:172
PatternConstructor(Constructor constructor, tvm::Array< Pattern > patterns)
Constructor.
TVM_DEFINE_OBJECT_REF_METHODS(PatternConstructor, Pattern, PatternConstructorNode)
Base type for declaring relay pattern.
Definition: adt.h:47
static constexpr const bool _type_has_method_shash_reduce
Definition: adt.h:51
static constexpr const bool _type_has_method_sequal_reduce
Definition: adt.h:50
static constexpr const char * _type_key
Definition: adt.h:49
TVM_DECLARE_BASE_OBJECT_INFO(PatternNode, Object)
PatternVar container node.
Definition: adt.h:191
void VisitAttrs(tvm::AttrVisitor *v)
Definition: adt.h:197
TVM_DECLARE_FINAL_OBJECT_INFO(PatternTupleNode, PatternNode)
static constexpr const char * _type_key
Definition: adt.h:208
tvm::Array< Pattern > patterns
Definition: adt.h:195
void SHashReduce(SHashReducer hash_reduce) const
Definition: adt.h:206
bool SEqualReduce(const PatternTupleNode *other, SEqualReducer equal) const
Definition: adt.h:202
TVM_DEFINE_OBJECT_REF_METHODS(PatternTuple, Pattern, PatternTupleNode)
PatternTuple(tvm::Array< Pattern > patterns)
Constructor.
PatternVar container node.
Definition: adt.h:116
void SHashReduce(SHashReducer hash_reduce) const
Definition: adt.h:130
bool SEqualReduce(const PatternVarNode *other, SEqualReducer equal) const
Definition: adt.h:126
void VisitAttrs(tvm::AttrVisitor *v)
Definition: adt.h:121
TVM_DECLARE_FINAL_OBJECT_INFO(PatternVarNode, PatternNode)
tvm::relay::Var var
Variable that stores the matched value.
Definition: adt.h:119
static constexpr const char * _type_key
Definition: adt.h:132
TVM_DEFINE_OBJECT_REF_METHODS(PatternVar, Pattern, PatternVarNode)
PatternVar(tvm::relay::Var var)
Constructor.
PatternWildcard container node.
Definition: adt.h:74
void SHashReduce(SHashReducer hash_reduce) const
Definition: adt.h:80
TVM_DECLARE_FINAL_OBJECT_INFO(PatternWildcardNode, PatternNode)
void VisitAttrs(tvm::AttrVisitor *v)
Definition: adt.h:76
bool SEqualReduce(const PatternNode *other, SEqualReducer equal) const
Definition: adt.h:78
static constexpr const char * _type_key
Definition: adt.h:82
const PatternWildcardNode * operator->() const
Definition: adt.h:106
PatternWildcard(ObjectPtr< Object > n)
Definition: adt.h:90
PatternWildcard & operator=(PatternWildcard &&other)
Definition: adt.h:101
PatternWildcard(PatternWildcard &&pat)
Definition: adt.h:94
PatternWildcard(const PatternWildcard &pat)
Definition: adt.h:92
PatternWildcard & operator=(const PatternWildcard &other)
Definition: adt.h:96
Pattern is the base type for an ADT match pattern in Relay.
Definition: adt.h:63
Pattern()
Definition: adt.h:65
Pattern(ObjectPtr< tvm::Object > p)
Definition: adt.h:66
This is the base node container of all relay structures.
Definition: base.h:71
Span span
The location of the program in a SourceFragment can be null, check with span.defined()
Definition: base.h:75
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:289
A custom smart pointer for Object.
Definition: object.h:362
Base class of all object reference.
Definition: object.h:519
const Object * get() const
Definition: object.h:554
ObjectPtr< Object > data_
Internal pointer that backs the reference.
Definition: object.h:605
base class of all object containers.
Definition: object.h:171
Optional container that to represent to a Nullable variant of T.
Definition: optional.h:51
Algebraic data type definitions.
Helpers for attribute objects.
tvm::TypeDataNode TypeDataNode
Definition: adt.h:44
tvm::ConstructorNode ConstructorNode
Definition: adt.h:41
tvm::TypeData TypeData
Definition: adt.h:43
Clause WithFields(Clause clause, Optional< Pattern > opt_lhs=Optional< Pattern >(), Optional< Expr > opt_rhs=Optional< Expr >())
Returns clause with the given properties. A null property denotes 'no change'. Returns clause if all ...
tvm::Constructor Constructor
Definition: adt.h:40
tvm::Span Span
Definition: base.h:65
Var var(std::string name_hint, DataType t=DataType::Int(32))
Construct a new Var expression.
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
PrimExpr equal(PrimExpr a, PrimExpr b, Span span=Span())
equal
Base classes for the Relay IR.
Relay expression language.