19 #ifndef TVM_SCRIPT_IR_BUILDER_RELAX_FRAME_H_
20 #define TVM_SCRIPT_IR_BUILDER_RELAX_FRAME_H_
30 namespace ir_builder {
38 static constexpr
const char*
_type_key =
"script.ir_builder.relax.RelaxFrame";
63 v->Visit(
"output", &
output);
66 static constexpr
const char*
_type_key =
"script.ir_builder.relax.SeqExprFrame";
111 v->Visit(
"name", &
name);
112 v->Visit(
"params", &
params);
115 v->Visit(
"attrs", &
attrs);
117 v->Visit(
"output", &
output);
121 static constexpr
const char*
_type_key =
"script.ir_builder.relax.FunctionFrame";
155 v->Visit(
"is_dataflow", &is_dataflow);
156 v->Visit(
"emitted_vars", &emitted_vars);
157 v->Visit(
"output_vars", &output_vars);
161 static constexpr
const char*
_type_key =
"script.ir_builder.relax.BlockFrame";
194 v->Visit(
"condition", &condition);
195 v->Visit(
"then_expr", &then_expr);
196 v->Visit(
"else_expr", &else_expr);
197 v->Visit(
"var", &
var);
198 v->Visit(
"var_name", &var_name);
201 static constexpr
const char*
_type_key =
"script.ir_builder.relax.IfFrame";
234 static constexpr
const char*
_type_key =
"script.ir_builder.relax.ThenFrame";
267 static constexpr
const char*
_type_key =
"script.ir_builder.relax.ElseFrame";
The utility for constructing Relax binding blocks.
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 RelayExprNode.
Definition: expr.h:442
Definition: block_builder.h:264
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:289
Map container of NodeRef->NodeRef in DSL graph. Map implements copy on write semantics,...
Definition: map.h:1271
Optional container that to represent to a Nullable variant of T.
Definition: optional.h:51
Reference to string objects.
Definition: string.h:98
void VisitAttrs(tvm::AttrVisitor *v)
Definition: base.h:69
Managed reference to an IRBuilderFrameNode.
Definition: base.h:100
The ir_builder frame for relax binding blocks.
Definition: frame.h:135
TVM_DECLARE_FINAL_OBJECT_INFO(BlockFrameNode, RelaxFrameNode)
void EnterWithScope() final
The method called when entering RAII scope.
bool is_dataflow
The flag that indicates whether the block is a dataflow block.
Definition: frame.h:138
Array< tvm::relax::Var > output_vars
The output vars of the dataflow block.
Definition: frame.h:151
void VisitAttrs(tvm::AttrVisitor *v)
Definition: frame.h:153
Array< tvm::relax::Var > emitted_vars
The variables emitted in this block.
Definition: frame.h:140
bool block_ended
A boolean indicating if the dataflow block is ended of construction. If it is true,...
Definition: frame.h:146
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(BlockFrame, RelaxFrame, BlockFrameNode)
A frame that represents else.
Definition: frame.h:265
TVM_DECLARE_FINAL_OBJECT_INFO(ElseFrameNode, SeqExprFrameNode)
void EnterWithScope() final
The method called when entering RAII scope.
Managed reference to ElseFrameNode.
Definition: frame.h:288
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(ElseFrame, SeqExprFrame, ElseFrameNode)
The ir_builder frame for the relax function.
Definition: frame.h:80
tvm::relax::BlockBuilder block_builder
The block builder to create Relax function.
Definition: frame.h:107
Optional< String > name
The function name.
Definition: frame.h:87
void EnterWithScope() final
The method called when entering RAII scope.
Map< String, ObjectRef > attrs
The function attributes.
Definition: frame.h:105
void VisitAttrs(tvm::AttrVisitor *v)
Definition: frame.h:109
void ExitWithScope() final
The method called when exiting RAII scope.
Optional< Bool > is_private
Whether the function is annotated as private.
Definition: frame.h:103
static constexpr const char * _type_key
Definition: frame.h:121
Optional< tvm::relax::StructInfo > ret_struct_info
The function return struct info.
Definition: frame.h:99
Optional< Bool > is_pure
Whether the function is annotated as pure.
Definition: frame.h:101
TVM_DECLARE_FINAL_OBJECT_INFO(FunctionFrameNode, SeqExprFrameNode)
Array< tvm::relax::Var > params
The function params.
Definition: frame.h:89
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(FunctionFrame, SeqExprFrame, FunctionFrameNode)
A frame that represents if statement.
Definition: frame.h:179
void EnterWithScope() final
The method called when entering RAII scope.
TVM_DECLARE_FINAL_OBJECT_INFO(IfFrameNode, RelaxFrameNode)
tvm::relax::Var var
The Binding var.
Definition: frame.h:188
tvm::relax::Expr condition
The condition of the if statement.
Definition: frame.h:182
void VisitAttrs(tvm::AttrVisitor *v)
Definition: frame.h:192
String var_name
The binding var name.
Definition: frame.h:190
Optional< tvm::relax::Expr > then_expr
The Bindings in the true branch.
Definition: frame.h:184
Optional< tvm::relax::Expr > else_expr
The Bindings in the false branch.
Definition: frame.h:186
Managed reference to IfFrameNode.
Definition: frame.h:222
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(IfFrame, RelaxFrame, IfFrameNode)
The base ir_builder frame for the relax dialect.
Definition: frame.h:34
static constexpr const char * _type_key
Definition: frame.h:38
void VisitAttrs(tvm::AttrVisitor *v)
Definition: frame.h:36
TVM_DECLARE_BASE_OBJECT_INFO(RelaxFrameNode, IRBuilderFrameNode)
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(RelaxFrame, IRBuilderFrame, RelaxFrameNode)
The base ir_builder frame for frames with SeqExpr i.e. Functions, If branches.
Definition: frame.h:53
TVM_DECLARE_BASE_OBJECT_INFO(SeqExprFrameNode, RelaxFrameNode)
void EnterWithScope() override
The method called when entering RAII scope.
void ExitWithScope() override
The method called when exiting RAII scope.
Array< tvm::relax::BindingBlock > binding_blocks
The binding blocks inside the frame.
Definition: frame.h:56
Optional< tvm::relax::Expr > output
The frame output expr. NullOpt when undefined.
Definition: frame.h:58
void VisitAttrs(tvm::AttrVisitor *v)
Definition: frame.h:60
static constexpr const char * _type_key
Definition: frame.h:66
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(SeqExprFrame, RelaxFrame, SeqExprFrameNode)
A frame that represents then.
Definition: frame.h:232
void EnterWithScope() final
The method called when entering RAII scope.
TVM_DECLARE_FINAL_OBJECT_INFO(ThenFrameNode, SeqExprFrameNode)
Managed reference to ThenFrameNode.
Definition: frame.h:255
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(ThenFrame, SeqExprFrame, ThenFrameNode)
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