19 #ifndef TVM_SCRIPT_IR_BUILDER_TIR_FRAME_H_
20 #define TVM_SCRIPT_IR_BUILDER_TIR_FRAME_H_
30 namespace ir_builder {
41 ffi::Array<tvm::tir::Stmt>
stmts;
72 ffi::Optional<ffi::String>
name;
74 ffi::Array<tvm::tir::Var>
args;
82 ffi::Map<ffi::String, Any>
attrs;
90 refl::ObjectDef<PrimFuncFrameNode>()
119 TVM_FFI_ICHECK(data !=
nullptr);
120 data_ = std::move(data);
137 ffi::Optional<ffi::Array<tvm::tir::BufferRegion>>
reads;
139 ffi::Optional<ffi::Array<tvm::tir::BufferRegion>>
writes;
141 ffi::Optional<tvm::tir::Stmt>
init;
160 refl::ObjectDef<BlockFrameNode>()
193 TVM_FFI_ICHECK(data !=
nullptr);
194 data_ = std::move(data);
208 refl::ObjectDef<BlockInitFrameNode>();
234 TVM_FFI_ICHECK(data !=
nullptr);
235 data_ = std::move(data);
255 ffi::Array<tvm::tir::Var> loop_vars, ffi::Array<Range> loop_extents,
256 ffi::Array<ffi::Optional<PrimExpr>> loop_steps,
tvm::tir::Stmt loop_body)>;
258 ffi::Array<tvm::tir::Var>
vars;
262 ffi::Array<ffi::Optional<PrimExpr>>
steps;
268 refl::ObjectDef<ForFrameNode>()
291 TVM_FFI_ICHECK(data !=
nullptr);
292 data_ = std::move(data);
312 refl::ObjectDef<AssertFrameNode>()
335 TVM_FFI_ICHECK(data !=
nullptr);
336 data_ = std::move(data);
355 refl::ObjectDef<LetFrameNode>()
377 TVM_FFI_ICHECK(data !=
nullptr);
378 data_ = std::move(data);
398 refl::ObjectDef<LaunchThreadFrameNode>()
422 TVM_FFI_ICHECK(data !=
nullptr);
423 data_ = std::move(data);
444 refl::ObjectDef<RealizeFrameNode>()
468 TVM_FFI_ICHECK(data !=
nullptr);
469 data_ = std::move(data);
496 refl::ObjectDef<AllocateFrameNode>()
523 TVM_FFI_ICHECK(data !=
nullptr);
524 data_ = std::move(data);
549 refl::ObjectDef<AllocateConstFrameNode>()
576 TVM_FFI_ICHECK(data !=
nullptr);
577 data_ = std::move(data);
598 refl::ObjectDef<AttrFrameNode>()
621 TVM_FFI_ICHECK(data !=
nullptr);
622 data_ = std::move(data);
660 TVM_FFI_ICHECK(data !=
nullptr);
661 data_ = std::move(data);
682 refl::ObjectDef<IfFrameNode>()
705 TVM_FFI_ICHECK(data !=
nullptr);
719 refl::ObjectDef<ThenFrameNode>();
744 TVM_FFI_ICHECK(data !=
nullptr);
758 refl::ObjectDef<ElseFrameNode>();
783 TVM_FFI_ICHECK(data !=
nullptr);
798 refl::ObjectDef<DeclBufferFrameNode>()
812 TVM_FFI_ICHECK(data !=
nullptr);
Reference to PrimExprNode.
Definition: expr.h:124
Runtime primitive data type.
Definition: data_type.h:47
Managed Tensor. The array is backed by reference counted blocks.
Definition: tensor.h:53
Managed reference to an IRBuilderFrameNode.
Definition: base.h:104
A frame represents the allocate constant.
Definition: frame.h:534
tvm::runtime::Tensor data
The data associated with the constant.
Definition: frame.h:541
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.AllocateConstFrame", AllocateConstFrameNode, TIRFrameNode)
tvm::tir::Var buffer_var
The buffer var.
Definition: frame.h:543
ffi::Map< ffi::String, Any > annotations
Additional annotations about the allocation.
Definition: frame.h:545
void ExitWithScope() final
The method called when exiting RAII scope.
ffi::Array< PrimExpr > extents
The extents of the allocate.
Definition: frame.h:539
DataType dtype
The data type of the buffer.
Definition: frame.h:537
static void RegisterReflection()
Definition: frame.h:547
Managed reference to AllocateConstFrameNode.
Definition: frame.h:572
AllocateConstFrame(ObjectPtr< AllocateConstFrameNode > data)
Definition: frame.h:574
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(AllocateConstFrame, TIRFrame, AllocateConstFrameNode)
A frame represents the allocate.
Definition: frame.h:479
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.AllocateFrame", AllocateFrameNode, TIRFrameNode)
tvm::tir::Var buffer_var
The buffer var.
Definition: frame.h:492
ffi::Map< ffi::String, Any > annotations
Additional annotation hints.
Definition: frame.h:490
ffi::String storage_scope
The storage scope.
Definition: frame.h:486
DataType dtype
The data type of the buffer.
Definition: frame.h:484
PrimExpr condition
The condition.
Definition: frame.h:488
static void RegisterReflection()
Definition: frame.h:494
void ExitWithScope() final
The method called when exiting RAII scope.
ffi::Array< PrimExpr > extents
The extents of the allocate.
Definition: frame.h:482
Managed reference to AllocateFrameNode.
Definition: frame.h:520
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(AllocateFrame, TIRFrame, AllocateFrameNode)
AllocateFrame(ObjectPtr< AllocateFrameNode > data)
Definition: frame.h:522
A frame that represents the assert statement. Proceeds if the condition is true, otherwise aborts wit...
Definition: frame.h:303
static void RegisterReflection()
Definition: frame.h:310
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.AssertFrame", AssertFrameNode, TIRFrameNode)
PrimExpr message
The output error message when the assertion failed.
Definition: frame.h:308
PrimExpr condition
The PrimExpr to test.
Definition: frame.h:306
void ExitWithScope() final
The method called when exiting RAII scope.
Managed reference to AssertFrameNode.
Definition: frame.h:332
AssertFrame(ObjectPtr< AssertFrameNode > data)
Definition: frame.h:334
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(AssertFrame, TIRFrame, AssertFrameNode)
A frame that represents attribute node.
Definition: frame.h:587
ffi::String attr_key
Attribute type key.
Definition: frame.h:592
void ExitWithScope() final
The method called when exiting RAII scope.
static void RegisterReflection()
Definition: frame.h:596
Any node
The node to annotate the attribute.
Definition: frame.h:590
PrimExpr value
The value of the attribute.
Definition: frame.h:594
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.AttrFrame", AttrFrameNode, TIRFrameNode)
Managed reference to AttrFrameNode.
Definition: frame.h:618
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(AttrFrame, TIRFrame, AttrFrameNode)
AttrFrame(ObjectPtr< AttrFrameNode > data)
Definition: frame.h:620
A frame that represents the block.
Definition: frame.h:130
ffi::Optional< PrimExpr > predicate
The predicate of the block realization, the block will only be executed when the predicate is true.
Definition: frame.h:154
ffi::Array< tvm::tir::IterVar > iter_vars
The variables of the block.
Definition: frame.h:135
ffi::Optional< ffi::Array< tvm::tir::BufferRegion > > writes
The write buffer regions of the block.
Definition: frame.h:139
void ExitWithScope() final
The method called when exiting RAII scope.
ffi::Array< tvm::tir::Buffer > alloc_buffers
The buffer allocated in the block.
Definition: frame.h:143
static void RegisterReflection()
Definition: frame.h:158
ffi::String name
The name of the block.
Definition: frame.h:133
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.BlockFrame", BlockFrameNode, TIRFrameNode)
ffi::Optional< tvm::tir::Stmt > init
The init statement of the bolck.
Definition: frame.h:141
ffi::Array< PrimExpr > iter_values
The corresponding values of the iter vars.
Definition: frame.h:149
ffi::Optional< ffi::Map< ffi::String, Any > > annotations
The annotation of the block.
Definition: frame.h:147
ffi::Array< tvm::tir::MatchBufferRegion > match_buffers
The match buffer regions.
Definition: frame.h:145
ffi::Optional< ffi::Array< tvm::tir::BufferRegion > > reads
The read buffer regions of the block.
Definition: frame.h:137
bool no_realize
The flag whether to construct BlockRealize or Block.
Definition: frame.h:156
Managed reference to BlockFrameNode.
Definition: frame.h:190
BlockFrame(ObjectPtr< BlockFrameNode > data)
Definition: frame.h:192
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(BlockFrame, TIRFrame, BlockFrameNode)
A frame that represents the block initialization statment.
Definition: frame.h:204
static void RegisterReflection()
Definition: frame.h:206
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.BlockInitFrame", BlockInitFrameNode, TIRFrameNode)
void EnterWithScope() final
The method called when entering RAII scope.
Managed reference to BlockInitFrameNode.
Definition: frame.h:231
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(BlockInitFrame, TIRFrame, BlockInitFrameNode)
BlockInitFrame(ObjectPtr< BlockInitFrameNode > data)
Definition: frame.h:233
void ExitWithScope() final
The method called when exiting RAII scope.
static void RegisterReflection()
Definition: frame.h:796
tvm::tir::Buffer buffer
The declared buffer.
Definition: frame.h:792
bool allocated
The buffer allocated or not.
Definition: frame.h:794
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.DeclBufferFrame", DeclBufferFrameNode, TIRFrameNode)
DeclBufferFrame(ObjectPtr< DeclBufferFrameNode > data)
Definition: frame.h:811
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(DeclBufferFrame, TIRFrame, DeclBufferFrameNode)
A frame that represents else.
Definition: frame.h:754
static void RegisterReflection()
Definition: frame.h:756
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.ElseFrame", ElseFrameNode, TIRFrameNode)
void EnterWithScope() final
The method called when entering RAII scope.
Managed reference to ElseFrameNode.
Definition: frame.h:780
ElseFrame(ObjectPtr< ElseFrameNode > data)
Definition: frame.h:782
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ElseFrame, TIRFrame, ElseFrameNode)
A frame that represents the for loop.
Definition: frame.h:245
ffi::TypedFunction< tvm::tir::Stmt(ffi::Array< tvm::tir::Var > loop_vars, ffi::Array< Range > loop_extents, ffi::Array< ffi::Optional< PrimExpr > > loop_steps, tvm::tir::Stmt loop_body)> FMakeForLoop
Functions that generate loop nests.
Definition: frame.h:256
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.ForFrame", ForFrameNode, TIRFrameNode)
static void RegisterReflection()
Definition: frame.h:266
ffi::Array< Range > doms
The domains of iteration.
Definition: frame.h:260
FMakeForLoop f_make_for_loop
The for loop generating function.
Definition: frame.h:264
ffi::Array< tvm::tir::Var > vars
The loop variable.
Definition: frame.h:258
void ExitWithScope() final
The method called when exiting RAII scope.
ffi::Array< ffi::Optional< PrimExpr > > steps
The optional steps of iteration.
Definition: frame.h:262
Managed reference to ForFrameNode.
Definition: frame.h:288
ForFrame(ObjectPtr< ForFrameNode > data)
Definition: frame.h:290
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ForFrame, TIRFrame, ForFrameNode)
A frame that represents if statement.
Definition: frame.h:671
ffi::Optional< ffi::Array< tvm::tir::Stmt > > then_stmts
The statements in the true branch.
Definition: frame.h:676
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.IfFrame", IfFrameNode, TIRFrameNode)
void ExitWithScope() final
The method called when exiting RAII scope.
PrimExpr condition
The condition of the if statement.
Definition: frame.h:674
ffi::Optional< ffi::Array< tvm::tir::Stmt > > else_stmts
The stetements in the false branch.
Definition: frame.h:678
static void RegisterReflection()
Definition: frame.h:680
Managed reference to IfFrameNode.
Definition: frame.h:702
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(IfFrame, TIRFrame, IfFrameNode)
IfFrame(ObjectPtr< IfFrameNode > data)
Definition: frame.h:704
The LaunchThreadFrameNode.
Definition: frame.h:387
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.LaunchThreadFrame", LaunchThreadFrameNode, TIRFrameNode)
void ExitWithScope() final
The method called when exiting RAII scope.
tvm::tir::IterVar iter_var
The iteration variable.
Definition: frame.h:394
ffi::String attr_key
The attribute key, could be either virtual_thread or thread_extent.
Definition: frame.h:392
static void RegisterReflection()
Definition: frame.h:396
PrimExpr extent
The extent of environment thread.
Definition: frame.h:390
Managed reference to LaunchThreadFrameNode.
Definition: frame.h:419
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(LaunchThreadFrame, TIRFrame, LaunchThreadFrameNode)
LaunchThreadFrame(ObjectPtr< LaunchThreadFrameNode > data)
Definition: frame.h:421
A frame represents the let binding expression, which binds a var.
Definition: frame.h:346
tvm::tir::Var var
The variable we bind to.
Definition: frame.h:349
PrimExpr value
The value we bind var to.
Definition: frame.h:351
static void RegisterReflection()
Definition: frame.h:353
void ExitWithScope() final
The method called when exiting RAII scope.
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.LetFrame", LetFrameNode, TIRFrameNode)
Managed reference to LetFrameNode.
Definition: frame.h:374
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(LetFrame, TIRFrame, LetFrameNode)
LetFrame(ObjectPtr< LetFrameNode > data)
Definition: frame.h:376
A frame that represents the PrimFunc containing TIR statements.
Definition: frame.h:69
ffi::Array< tvm::tir::Buffer > root_alloc_buffers
The buffer allocated in root block.
Definition: frame.h:86
static void RegisterReflection()
Definition: frame.h:88
ffi::Map< tvm::tir::Var, tvm::tir::Buffer > buffer_map
Maps some parameters to specific Buffer data structures.
Definition: frame.h:80
void ExitWithScope() final
The method called when exiting RAII scope.
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.PrimFuncFrame", PrimFuncFrameNode, TIRFrameNode)
ffi::Optional< Type > ret_type
The return type of the function.
Definition: frame.h:78
ffi::Array< tvm::tir::Var > args
Function parameters.
Definition: frame.h:74
ffi::Optional< ffi::String > name
The name of the block.
Definition: frame.h:72
ffi::Map< ffi::String, Any > attrs
Additional attributes storing the meta-data.
Definition: frame.h:82
bool is_private
Whether the PrimFunc is annotated as private.
Definition: frame.h:76
ffi::Map< tvm::tir::Var, tvm::tir::IterVar > env_threads
The variable map bound to thread env.
Definition: frame.h:84
Managed reference to PrimFuncFrameNode.
Definition: frame.h:116
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(PrimFuncFrame, TIRFrame, PrimFuncFrameNode)
PrimFuncFrame(ObjectPtr< PrimFuncFrameNode > data)
Definition: frame.h:118
A frame that represents realization.
Definition: frame.h:433
static void RegisterReflection()
Definition: frame.h:442
void ExitWithScope() final
The method called when exiting RAII scope.
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.RealizeFrame", RealizeFrameNode, TIRFrameNode)
PrimExpr condition
The condition expression.
Definition: frame.h:440
tvm::tir::BufferRegion buffer_slice
The region of buffer access.
Definition: frame.h:436
ffi::String storage_scope
The storage scope associated with this realization.
Definition: frame.h:438
Managed reference to RealizeFrameNode.
Definition: frame.h:465
RealizeFrame(ObjectPtr< RealizeFrameNode > data)
Definition: frame.h:467
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(RealizeFrame, TIRFrame, RealizeFrameNode)
A base frame that represents the TIR fame with body of statements.
Definition: frame.h:38
ffi::Array< tvm::tir::Stmt > stmts
The Stmt within in this frame.
Definition: frame.h:41
TVM_FFI_DECLARE_OBJECT_INFO("script.ir_builder.tir.TIRFrame", TIRFrameNode, IRBuilderFrameNode)
static void RegisterReflection()
Definition: frame.h:43
Managed reference to TIRFrameNode.
Definition: frame.h:55
TIRFrame(ObjectPtr< TIRFrameNode > data)
Definition: frame.h:61
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(TIRFrame, IRBuilderFrame, TIRFrameNode)
A frame that represents then.
Definition: frame.h:715
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.ThenFrame", ThenFrameNode, TIRFrameNode)
static void RegisterReflection()
Definition: frame.h:717
void EnterWithScope() final
The method called when entering RAII scope.
Managed reference to ThenFrameNode.
Definition: frame.h:741
ThenFrame(ObjectPtr< ThenFrameNode > data)
Definition: frame.h:743
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ThenFrame, TIRFrame, ThenFrameNode)
A frame that represents while loop.
Definition: frame.h:632
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tir.WhileFrame", WhileFrameNode, TIRFrameNode)
static void RegisterReflection()
Definition: frame.h:637
PrimExpr condition
The termination condition of while.
Definition: frame.h:635
void ExitWithScope() final
The method called when exiting RAII scope.
Managed reference to WhileFrameNode.
Definition: frame.h:657
WhileFrame(ObjectPtr< WhileFrameNode > data)
Definition: frame.h:659
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(WhileFrame, TIRFrame, WhileFrameNode)
Managed reference to BufferRegionNode.
Definition: stmt.h:855
Buffer is a symbolic n-darray structure. It is a composition of primitive symbolic types,...
Definition: buffer.h:156
Iteration Variable, represents an iteration over an integer interval.
Definition: var.h:297
Container of all statements.
Definition: stmt.h:63
a named variable in TIR
Definition: var.h:77
Definition: repr_printer.h:91
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:37