24 #ifndef TVM_RELAY_EXPR_H_ 25 #define TVM_RELAY_EXPR_H_ 73 v->Visit(
"data", &data);
74 v->Visit(
"span", &
span);
84 static constexpr
const char*
_type_key =
"relay.Constant";
109 v->Visit(
"fields", &fields);
110 v->Visit(
"span", &
span);
116 if (fields.
size() == other->
fields.size() && fields.
size() == 0) {
125 if (fields.
size() != 0) {
180 v->Visit(
"vid", &vid);
181 v->Visit(
"type_annotation", &type_annotation);
182 v->Visit(
"span", &
span);
193 hash_reduce(type_annotation);
210 : Var(
Id(name_hint), type_annotation,
span) {}
233 static void Deleter_(
Object* ptr);
272 v->Visit(
"args", &args);
273 v->Visit(
"attrs", &attrs);
274 v->Visit(
"type_args", &type_args);
275 v->Visit(
"span", &
span);
292 hash_reduce(type_args);
345 v->Visit(
"var", &var);
346 v->Visit(
"value", &value);
347 v->Visit(
"body", &body);
348 v->Visit(
"span", &
span);
406 v->Visit(
"cond", &cond);
407 v->Visit(
"true_branch", &true_branch);
408 v->Visit(
"false_branch", &false_branch);
409 v->Visit(
"span", &
span);
422 hash_reduce(true_branch);
423 hash_reduce(false_branch);
454 v->Visit(
"tuple_value", &tuple);
455 v->Visit(
"index", &index);
456 v->Visit(
"span", &
span);
469 static constexpr
const char*
_type_key =
"relay.TupleGetItem";
494 v->Visit(
"value", &value);
495 v->Visit(
"span", &
span);
509 static constexpr
const char*
_type_key =
"relay.RefCreate";
533 v->Visit(
"ref", &ref);
534 v->Visit(
"span", &
span);
548 static constexpr
const char*
_type_key =
"relay.RefRead";
573 v->Visit(
"ref", &ref);
574 v->Visit(
"value", &value);
575 v->Visit(
"span", &
span);
590 static constexpr
const char*
_type_key =
"relay.RefWrite";
627 virtual Expr Realize()
const = 0;
629 static constexpr
const char*
_type_key =
"relay.TempExpr";
643 #endif // TVM_RELAY_EXPR_H_ tvm::Span Span
Definition: base.h:65
Expr true_branch
The expression evaluated when condition is true.
Definition: expr.h:401
bool SEqualReduce(const LetNode *other, SEqualReducer equal) const
Definition: expr.h:352
bool DefEqual(const ObjectRef &lhs, const ObjectRef &rhs)
Reduce condition to comparison of two definitions, where free vars can be mapped. ...
Definition: structural_equal.h:165
void SHashReduce(SHashReducer hash_reduce) const
Definition: expr.h:504
tvm::Array< relay::Expr > args
The arguments(inputs) of the call.
Definition: expr.h:245
tvm::BaseFuncNode BaseFuncNode
Definition: expr.h:46
Attrs attrs
The additional attributes.
Definition: expr.h:248
Base class of the temporary expression.
Definition: expr.h:619
bool SEqualReduce(const VarNode *other, SEqualReducer equal) const
Definition: expr.h:186
bool SEqualReduce(const TupleNode *other, SEqualReducer equal) const
Definition: expr.h:114
Managed reference to TensorTypeNode.
Definition: tensor_type.h:99
Call container.
Definition: expr.h:229
A Reducer class to reduce the structural equality result of two objects.
Definition: structural_equal.h:102
Managed reference to BaseAttrsNode.
Definition: attrs.h:190
static constexpr const bool _type_has_method_shash_reduce
Definition: expr.h:56
IRModule that holds the functions and type definitions.
Var(String name_hint, Type type_annotation, Span span=Span())
The constructor.
Definition: expr.h:209
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:36
A Reducer class to reduce the structural hash value.
Definition: structural_hash.h:101
void SHashReduce(SHashReducer hash_reduce) const
Definition: expr.h:82
void VisitAttrs(tvm::AttrVisitor *v)
Definition: expr.h:179
tvm::Array< relay::Expr > fields
the fields of the tuple
Definition: expr.h:106
PrimExpr equal(PrimExpr a, PrimExpr b, Span span=Span())
equal
Constant tensor type.
Definition: expr.h:61
void SHashReduce(SHashReducer hash_reduce) const
Definition: expr.h:419
bool is_scalar() const
Definition: expr.h:70
Expr cond
The condition.
Definition: expr.h:399
bool SEqualReduce(const RefWriteNode *other, SEqualReducer equal) const
Definition: expr.h:579
void VisitAttrs(tvm::AttrVisitor *v)
Definition: expr.h:572
Type type_annotation
type annotaion of the variable. This field records user provided type annotation of the Var...
Definition: expr.h:174
void VisitAttrs(tvm::AttrVisitor *v)
Definition: expr.h:453
static constexpr const char * _type_key
Definition: expr.h:84
tvm::BaseFunc BaseFunc
Definition: expr.h:45
Expr body
The body of the let binding.
Definition: expr.h:342
base class of all object containers.
Definition: object.h:165
void VisitAttrs(tvm::AttrVisitor *v)
Definition: expr.h:493
Managed NDArray. The array is backed by reference counted blocks.
Definition: ndarray.h:59
Container for Var.
Definition: expr.h:157
tvm::Array< Type > type_args
The type arguments passed to polymorphic(template) function.
Definition: expr.h:268
Expr ref
The Reference Expression.
Definition: expr.h:530
Helpers for attribute objects.
virtual void MarkGraphNode()=0
Mark current comparison as graph node equal comparison.
Expr tuple
The tuple Expression.
Definition: expr.h:449
Primitive operators(builtin intrinsics) and registry for them.
Expr op
The operator(function) being invoked.
Definition: expr.h:242
void SHashReduce(SHashReducer hash_reduce) const
Definition: expr.h:286
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
bool SEqualReduce(const IfNode *other, SEqualReducer equal) const
Definition: expr.h:413
void SHashReduce(SHashReducer hash_reduce) const
Definition: expr.h:191
tvm::GlobalVarNode GlobalVarNode
Definition: expr.h:48
A binding of a sub-network.
Definition: expr.h:335
size_t size() const
Definition: array.h:399
Span span
Span that points to the original source code. Reserved debug information.
Definition: expr.h:52
Var var
The variable we bind to.
Definition: expr.h:338
tvm::GlobalVar GlobalVar
Definition: expr.h:47
virtual void MarkGraphNode()=0
Mark current comparison as graph node in hashing. Graph node hash will depends on the graph structure...
Type checked_type_
Stores the result of type inference(type checking).
Definition: expr.h:150
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:270
void SHashReduce(SHashReducer hash_reduce) const
Definition: expr.h:584
static constexpr const bool _type_has_method_sequal_reduce
Definition: expr.h:55
bool IsPrimitiveOp(const RelayExpr &expr)
Check that an expression is a "primitive operator".
Definition: op.h:509
void(* FDeleter)(Object *self)
Object deleter.
Definition: object.h:171
void VisitAttrs(tvm::AttrVisitor *v)
Definition: expr.h:270
Managed reference to GlobalVarNode.
Definition: expr.h:220
Expr false_branch
The expression evaluated when condition is false.
Definition: expr.h:403
Tuple container.
Definition: expr.h:103
bool SEqualReduce(const ConstantNode *other, SEqualReducer equal) const
Definition: expr.h:78
TVM_DECLARE_FINAL_OBJECT_INFO(ConstantNode, ExprNode)
Reference to string objects.
Definition: string.h:129
void SHashReduce(SHashReducer hash_reduce) const
Definition: expr.h:543
Managed reference to RelayExprNode.
Definition: expr.h:177
#define TVM_DEFINE_OBJECT_REF_METHODS(TypeName, ParentType, ObjectName)
Definition: object.h:706
Object::FDeleter saved_deleter_
Definition: expr.h:232
bool SEqualReduce(const CallNode *other, SEqualReducer equal) const
Definition: expr.h:279
TVM_DECLARE_BASE_OBJECT_INFO(RelayExprNode, BaseExprNode)
String PrettyPrint(const ObjectRef &node)
Pretty print a node for debug purposes.
Var var(std::string name_hint, DataType t=DataType::Int(32))
Construct a new Var expression.
void SHashReduce(SHashReducer hash_reduce) const
Definition: expr.h:464
const String & name_hint() const
Definition: expr.h:177
TensorType tensor_type() const
bool SEqualReduce(const RefCreateNode *other, SEqualReducer equal) const
Definition: expr.h:499
void SHashReduce(SHashReducer hash_reduce) const
Definition: expr.h:124
Expr value
The initial value of the Reference.
Definition: expr.h:491
virtual ~TempExprNode()
virtual destructor
Definition: expr.h:622
Base node of all functions.
Definition: function.h:77
void VisitAttrs(tvm::AttrVisitor *v)
Definition: expr.h:344
Expr ref
The Reference Expression.
Definition: expr.h:568
Expr value
The value we bind var to.
Definition: expr.h:340
Managed reference to BaseFuncNode.
Definition: function.h:143
Base classes for the Relay IR.
void VisitAttrs(tvm::AttrVisitor *v)
Definition: expr.h:405
Managed reference to TypeNode.
Definition: type.h:93
void VisitAttrs(tvm::AttrVisitor *v)
Definition: expr.h:72
Expr value
The value to write into.
Definition: expr.h:570
bool SEqualReduce(const TupleGetItemNode *other, SEqualReducer equal) const
Definition: expr.h:460
void VisitAttrs(tvm::AttrVisitor *v)
Definition: expr.h:108
Global variable that lives in the top-level module.
Definition: expr.h:191
void SHashReduce(SHashReducer hash_reduce) const
Definition: expr.h:358
Base node of all non-primitive expressions.
Definition: expr.h:142
int index
which value to get
Definition: expr.h:451
runtime::NDArray data
The data of the tensor.
Definition: expr.h:64
static constexpr const uint32_t _type_child_slots
Definition: expr.h:169
container of If
Definition: expr.h:396
void VisitAttrs(tvm::AttrVisitor *v)
Definition: expr.h:532
void DefHash(const ObjectRef &key) const
Push hash of key to the current sequence of hash values.
Definition: structural_hash.h:178
bool SEqualReduce(const RefReadNode *other, SEqualReducer equal) const
Definition: expr.h:538
Id vid
The unique identifier of the Var.
Definition: expr.h:168