19 #ifndef TVM_SCRIPT_IR_BUILDER_TIR_FRAME_H_
20 #define TVM_SCRIPT_IR_BUILDER_TIR_FRAME_H_
28 namespace ir_builder {
43 v->Visit(
"stmts", &
stmts);
46 static constexpr
const char*
_type_key =
"script.ir_builder.tir.TIRFrame";
89 v->Visit(
"name", &
name);
90 v->Visit(
"args", &
args);
94 v->Visit(
"attrs", &
attrs);
99 static constexpr
const char*
_type_key =
"script.ir_builder.tir.PrimFuncFrame";
155 v->Visit(
"name", &
name);
156 v->Visit(
"iter_vars", &iter_vars);
157 v->Visit(
"reads", &reads);
158 v->Visit(
"writes", &writes);
159 v->Visit(
"init", &init);
160 v->Visit(
"alloc_buffers", &alloc_buffers);
161 v->Visit(
"match_buffers", &match_buffers);
162 v->Visit(
"annotations", &annotations);
163 v->Visit(
"iter_values", &iter_values);
164 v->Visit(
"predicate", &predicate);
165 v->Visit(
"no_realize", &no_realize);
168 static constexpr
const char*
_type_key =
"script.ir_builder.tir.BlockFrame";
199 static constexpr
const char*
_type_key =
"script.ir_builder.tir.BlockInitFrame";
250 v->Visit(
"vars", &vars);
251 v->Visit(
"doms", &doms);
255 static constexpr
const char*
_type_key =
"script.ir_builder.tir.ForFrame";
291 v->Visit(
"condition", &condition);
292 v->Visit(
"message", &message);
295 static constexpr
const char*
_type_key =
"script.ir_builder.tir.AssertFrame";
330 v->Visit(
"var", &
var);
331 v->Visit(
"value", &value);
334 static constexpr
const char*
_type_key =
"script.ir_builder.tir.LetFrame";
370 v->Visit(
"extent", &extent);
371 v->Visit(
"attr_key", &attr_key);
372 v->Visit(
"iter_var", &iter_var);
375 static constexpr
const char*
_type_key =
"script.ir_builder.tir.LaunchThreadFrame";
413 v->Visit(
"buffer_slice", &buffer_slice);
414 v->Visit(
"storage_scope", &storage_scope);
415 v->Visit(
"condition", &condition);
418 static constexpr
const char*
_type_key =
"script.ir_builder.tir.RealizeFrame";
461 v->Visit(
"extents", &extents);
462 v->Visit(
"dtype", &dtype);
463 v->Visit(
"storage_scope", &storage_scope);
464 v->Visit(
"condition", &condition);
465 v->Visit(
"annotations", &annotations);
466 v->Visit(
"buffer_var", &buffer_var);
469 static constexpr
const char*
_type_key =
"script.ir_builder.tir.AllocateFrame";
510 v->Visit(
"dtype", &dtype);
511 v->Visit(
"extents", &extents);
512 v->Visit(
"data", &data);
513 v->Visit(
"buffer_var", &buffer_var);
514 v->Visit(
"annotations", &annotations);
517 static constexpr
const char*
_type_key =
"script.ir_builder.tir.AllocateConstFrame";
554 v->Visit(
"node", &node);
555 v->Visit(
"attr_key", &attr_key);
556 v->Visit(
"value", &value);
559 static constexpr
const char*
_type_key =
"script.ir_builder.tir.AttrFrame";
592 v->Visit(
"condition", &condition);
595 static constexpr
const char*
_type_key =
"script.ir_builder.tir.WhileFrame";
632 v->Visit(
"condition", &condition);
633 v->Visit(
"then_stmts", &then_stmts);
634 v->Visit(
"else_stmts", &else_stmts);
637 static constexpr
const char*
_type_key =
"script.ir_builder.tir.IfFrame";
665 static constexpr
const char*
_type_key =
"script.ir_builder.tir.ThenFrame";
698 static constexpr
const char*
_type_key =
"script.ir_builder.tir.ElseFrame";
733 v->Visit(
"buffer", &buffer);
734 v->Visit(
"allocated", &allocated);
737 static constexpr
const char*
_type_key =
"script.ir_builder.tir.DeclBufferFrame";
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
Reference to PrimExprNode.
Definition: expr.h:115
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:289
Runtime primitive data type.
Definition: data_type.h:43
Map container of NodeRef->NodeRef in DSL graph. Map implements copy on write semantics,...
Definition: map.h:1271
Managed NDArray. The array is backed by reference counted blocks.
Definition: ndarray.h:51
Base class of all object reference.
Definition: object.h:519
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
A frame represents the allocate constant.
Definition: frame.h:495
void VisitAttrs(tvm::AttrVisitor *v)
Definition: frame.h:508
tvm::tir::Var buffer_var
The buffer var.
Definition: frame.h:504
Map< String, ObjectRef > annotations
Additional annotations about the allocation.
Definition: frame.h:506
Array< PrimExpr > extents
The extents of the allocate.
Definition: frame.h:500
TVM_DECLARE_FINAL_OBJECT_INFO(AllocateConstFrameNode, TIRFrameNode)
tvm::runtime::NDArray data
The data associated with the constant.
Definition: frame.h:502
void ExitWithScope() final
The method called when exiting RAII scope.
DataType dtype
The data type of the buffer.
Definition: frame.h:498
Managed reference to AllocateConstFrameNode.
Definition: frame.h:533
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(AllocateConstFrame, TIRFrame, AllocateConstFrameNode)
A frame represents the allocate.
Definition: frame.h:444
void VisitAttrs(tvm::AttrVisitor *v)
Definition: frame.h:459
tvm::tir::Var buffer_var
The buffer var.
Definition: frame.h:457
TVM_DECLARE_FINAL_OBJECT_INFO(AllocateFrameNode, TIRFrameNode)
Map< String, ObjectRef > annotations
Additional annotation hints.
Definition: frame.h:455
DataType dtype
The data type of the buffer.
Definition: frame.h:449
PrimExpr condition
The condition.
Definition: frame.h:453
void ExitWithScope() final
The method called when exiting RAII scope.
String storage_scope
The storage scope.
Definition: frame.h:451
Array< PrimExpr > extents
The extents of the allocate.
Definition: frame.h:447
Managed reference to AllocateFrameNode.
Definition: frame.h:485
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(AllocateFrame, TIRFrame, AllocateFrameNode)
A frame that represents the assert statement. Proceeds if the condition is true, otherwise aborts wit...
Definition: frame.h:282
void VisitAttrs(tvm::AttrVisitor *v)
Definition: frame.h:289
TVM_DECLARE_FINAL_OBJECT_INFO(AssertFrameNode, TIRFrameNode)
PrimExpr message
The output error message when the assertion failed.
Definition: frame.h:287
PrimExpr condition
The PrimExpr to test.
Definition: frame.h:285
void ExitWithScope() final
The method called when exiting RAII scope.
Managed reference to AssertFrameNode.
Definition: frame.h:311
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(AssertFrame, TIRFrame, AssertFrameNode)
A frame that represents attribute node.
Definition: frame.h:543
TVM_DECLARE_FINAL_OBJECT_INFO(AttrFrameNode, TIRFrameNode)
String attr_key
Attribute type key.
Definition: frame.h:548
void ExitWithScope() final
The method called when exiting RAII scope.
ObjectRef node
The node to annotate the attribute.
Definition: frame.h:546
void VisitAttrs(tvm::AttrVisitor *v)
Definition: frame.h:552
PrimExpr value
The value of the attribute.
Definition: frame.h:550
Managed reference to AttrFrameNode.
Definition: frame.h:575
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(AttrFrame, TIRFrame, AttrFrameNode)
A frame that represents the block.
Definition: frame.h:125
Optional< tvm::tir::Stmt > init
The init statement of the bolck.
Definition: frame.h:136
String name
The name of the block.
Definition: frame.h:128
void ExitWithScope() final
The method called when exiting RAII scope.
void VisitAttrs(tvm::AttrVisitor *v)
Definition: frame.h:153
Array< tvm::tir::IterVar > iter_vars
The variables of the block.
Definition: frame.h:130
Optional< Array< tvm::tir::BufferRegion > > writes
The write buffer regions of the block.
Definition: frame.h:134
Array< tvm::tir::Buffer > alloc_buffers
The buffer allocated in the block.
Definition: frame.h:138
Optional< Map< String, ObjectRef > > annotations
The annotation of the block.
Definition: frame.h:142
Optional< PrimExpr > predicate
The predicate of the block realization, the block will only be executed when the predicate is true.
Definition: frame.h:149
Array< tvm::tir::MatchBufferRegion > match_buffers
The match buffer regions.
Definition: frame.h:140
Array< PrimExpr > iter_values
The corresponding values of the iter vars.
Definition: frame.h:144
Optional< Array< tvm::tir::BufferRegion > > reads
The read buffer regions of the block.
Definition: frame.h:132
TVM_DECLARE_FINAL_OBJECT_INFO(BlockFrameNode, TIRFrameNode)
bool no_realize
The flag whether to construct BlockRealize or Block.
Definition: frame.h:151
Managed reference to BlockFrameNode.
Definition: frame.h:185
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(BlockFrame, TIRFrame, BlockFrameNode)
A frame that represents the block initialization statment.
Definition: frame.h:195
TVM_DECLARE_FINAL_OBJECT_INFO(BlockInitFrameNode, TIRFrameNode)
void EnterWithScope() final
The method called when entering RAII scope.
void VisitAttrs(tvm::AttrVisitor *v)
Definition: frame.h:197
Managed reference to BlockInitFrameNode.
Definition: frame.h:220
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(BlockInitFrame, TIRFrame, BlockInitFrameNode)
void ExitWithScope() final
The method called when exiting RAII scope.
void VisitAttrs(tvm::AttrVisitor *v)
Definition: frame.h:731
tvm::tir::Buffer buffer
The declared buffer.
Definition: frame.h:727
TVM_DECLARE_FINAL_OBJECT_INFO(DeclBufferFrameNode, TIRFrameNode)
bool allocated
The buffer allocated or not.
Definition: frame.h:729
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(DeclBufferFrame, TIRFrame, DeclBufferFrameNode)
A frame that represents else.
Definition: frame.h:696
void EnterWithScope() final
The method called when entering RAII scope.
TVM_DECLARE_FINAL_OBJECT_INFO(ElseFrameNode, TIRFrameNode)
Managed reference to ElseFrameNode.
Definition: frame.h:719
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(ElseFrame, TIRFrame, ElseFrameNode)
A frame that represents the for loop.
Definition: frame.h:230
void VisitAttrs(tvm::AttrVisitor *v)
Definition: frame.h:248
FMakeForLoop f_make_for_loop
The for loop generating function.
Definition: frame.h:246
Array< Range > doms
The domains of iteration.
Definition: frame.h:244
Array< tvm::tir::Var > vars
The loop variable.
Definition: frame.h:242
void ExitWithScope() final
The method called when exiting RAII scope.
TVM_DECLARE_FINAL_OBJECT_INFO(ForFrameNode, TIRFrameNode)
Managed reference to ForFrameNode.
Definition: frame.h:271
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(ForFrame, TIRFrame, ForFrameNode)
A frame that represents if statement.
Definition: frame.h:621
TVM_DECLARE_FINAL_OBJECT_INFO(IfFrameNode, TIRFrameNode)
Optional< Array< tvm::tir::Stmt > > else_stmts
The stetements in the false branch.
Definition: frame.h:628
void ExitWithScope() final
The method called when exiting RAII scope.
Optional< Array< tvm::tir::Stmt > > then_stmts
The statements in the true branch.
Definition: frame.h:626
PrimExpr condition
The condition of the if statement.
Definition: frame.h:624
void VisitAttrs(tvm::AttrVisitor *v)
Definition: frame.h:630
Managed reference to IfFrameNode.
Definition: frame.h:653
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(IfFrame, TIRFrame, IfFrameNode)
The LaunchThreadFrameNode.
Definition: frame.h:359
void VisitAttrs(tvm::AttrVisitor *v)
Definition: frame.h:368
void ExitWithScope() final
The method called when exiting RAII scope.
tvm::tir::IterVar iter_var
The iteration variable.
Definition: frame.h:366
TVM_DECLARE_FINAL_OBJECT_INFO(LaunchThreadFrameNode, TIRFrameNode)
String attr_key
The attribute key, could be either virtual_thread or thread_extent.
Definition: frame.h:364
PrimExpr extent
The extent of environment thread.
Definition: frame.h:362
Managed reference to LaunchThreadFrameNode.
Definition: frame.h:391
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(LaunchThreadFrame, TIRFrame, LaunchThreadFrameNode)
A frame represents the let binding expression, which binds a var.
Definition: frame.h:321
tvm::tir::Var var
The variable we bind to.
Definition: frame.h:324
PrimExpr value
The value we bind var to.
Definition: frame.h:326
TVM_DECLARE_FINAL_OBJECT_INFO(LetFrameNode, TIRFrameNode)
void ExitWithScope() final
The method called when exiting RAII scope.
void VisitAttrs(tvm::AttrVisitor *v)
Definition: frame.h:328
Managed reference to LetFrameNode.
Definition: frame.h:350
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(LetFrame, TIRFrame, LetFrameNode)
A frame that represents the PrimFunc containing TIR statements.
Definition: frame.h:68
void VisitAttrs(tvm::AttrVisitor *v)
Definition: frame.h:87
void ExitWithScope() final
The method called when exiting RAII scope.
Map< tvm::tir::Var, tvm::tir::Buffer > buffer_map
Maps some parameters to specific Buffer data structures.
Definition: frame.h:79
Map< tvm::tir::Var, tvm::tir::IterVar > env_threads
The variable map bound to thread env.
Definition: frame.h:83
Array< tvm::tir::Buffer > root_alloc_buffers
The buffer allocated in root block.
Definition: frame.h:85
Optional< String > name
The name of the block.
Definition: frame.h:71
static constexpr const char * _type_key
Definition: frame.h:99
TVM_DECLARE_FINAL_OBJECT_INFO(PrimFuncFrameNode, TIRFrameNode)
Array< tvm::tir::Var > args
Function parameters.
Definition: frame.h:73
Optional< Type > ret_type
The return type of the function.
Definition: frame.h:77
bool is_private
Whether the PrimFunc is annotated as private.
Definition: frame.h:75
Map< String, ObjectRef > attrs
Additional attributes storing the meta-data.
Definition: frame.h:81
Managed reference to PrimFuncFrameNode.
Definition: frame.h:115
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(PrimFuncFrame, TIRFrame, PrimFuncFrameNode)
A frame that represents realization.
Definition: frame.h:402
TVM_DECLARE_FINAL_OBJECT_INFO(RealizeFrameNode, TIRFrameNode)
void ExitWithScope() final
The method called when exiting RAII scope.
String storage_scope
The storage scope associated with this realization.
Definition: frame.h:407
PrimExpr condition
The condition expression.
Definition: frame.h:409
void VisitAttrs(tvm::AttrVisitor *v)
Definition: frame.h:411
tvm::tir::BufferRegion buffer_slice
The region of buffer access.
Definition: frame.h:405
Managed reference to RealizeFrameNode.
Definition: frame.h:434
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(RealizeFrame, TIRFrame, RealizeFrameNode)
A base frame that represents the TIR fame with body of statements.
Definition: frame.h:36
Array< tvm::tir::Stmt > stmts
The Stmt within in this frame.
Definition: frame.h:39
TVM_DECLARE_BASE_OBJECT_INFO(TIRFrameNode, IRBuilderFrameNode)
void VisitAttrs(tvm::AttrVisitor *v)
Definition: frame.h:41
static constexpr const char * _type_key
Definition: frame.h:46
Managed reference to TIRFrameNode.
Definition: frame.h:55
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(TIRFrame, IRBuilderFrame, TIRFrameNode)
A frame that represents then.
Definition: frame.h:663
TVM_DECLARE_FINAL_OBJECT_INFO(ThenFrameNode, TIRFrameNode)
void EnterWithScope() final
The method called when entering RAII scope.
Managed reference to ThenFrameNode.
Definition: frame.h:686
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(ThenFrame, TIRFrame, ThenFrameNode)
A frame that represents while loop.
Definition: frame.h:585
TVM_DECLARE_FINAL_OBJECT_INFO(WhileFrameNode, TIRFrameNode)
PrimExpr condition
The termination condition of while.
Definition: frame.h:588
void VisitAttrs(tvm::AttrVisitor *v)
Definition: frame.h:590
void ExitWithScope() final
The method called when exiting RAII scope.
Managed reference to WhileFrameNode.
Definition: frame.h:611
TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS(WhileFrame, TIRFrame, WhileFrameNode)
Managed reference to BufferRegionNode.
Definition: stmt.h:1166
Buffer is a symbolic n-darray structure. It is a composition of primitive symbolic types,...
Definition: buffer.h:174
Iteration Variable, represents an iteration over an integer interval.
Definition: var.h:315
Container of all statements.
Definition: stmt.h:59
a named variable in TIR
Definition: var.h:89
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