19 #ifndef TVM_SCRIPT_IR_BUILDER_TIR_FRAME_H_
20 #define TVM_SCRIPT_IR_BUILDER_TIR_FRAME_H_
31 namespace ir_builder {
42 ffi::Array<tvm::tirx::Stmt>
stmts;
45 namespace refl = tvm::ffi::reflection;
73 ffi::Optional<ffi::String>
name;
75 ffi::Array<tvm::tirx::Var>
args;
83 ffi::Map<ffi::String, Any>
attrs;
97 namespace refl = tvm::ffi::reflection;
98 refl::ObjectDef<PrimFuncFrameNode>()
129 TVM_FFI_ICHECK(data !=
nullptr);
130 data_ = std::move(data);
147 ffi::Optional<ffi::Array<tvm::tirx::BufferRegion>>
reads;
149 ffi::Optional<ffi::Array<tvm::tirx::BufferRegion>>
writes;
151 ffi::Optional<tvm::tirx::Stmt>
init;
169 namespace refl = tvm::ffi::reflection;
170 refl::ObjectDef<SBlockFrameNode>()
203 TVM_FFI_ICHECK(data !=
nullptr);
204 data_ = std::move(data);
217 namespace refl = tvm::ffi::reflection;
218 refl::ObjectDef<BlockInitFrameNode>();
244 TVM_FFI_ICHECK(data !=
nullptr);
245 data_ = std::move(data);
266 namespace refl = tvm::ffi::reflection;
267 refl::ObjectDef<ExecScopeFrameNode>()
290 TVM_FFI_ICHECK(data !=
nullptr);
291 data_ = std::move(data);
311 ffi::Array<tvm::tirx::Var> loop_vars, ffi::Array<Range> loop_extents,
312 ffi::Array<ffi::Optional<PrimExpr>> loop_steps,
tvm::tirx::Stmt loop_body)>;
314 ffi::Array<tvm::tirx::Var>
vars;
318 ffi::Array<ffi::Optional<PrimExpr>>
steps;
323 namespace refl = tvm::ffi::reflection;
324 refl::ObjectDef<ForFrameNode>()
347 TVM_FFI_ICHECK(data !=
nullptr);
348 data_ = std::move(data);
369 namespace refl = tvm::ffi::reflection;
370 refl::ObjectDef<AssertFrameNode>()
394 TVM_FFI_ICHECK(data !=
nullptr);
395 data_ = std::move(data);
414 namespace refl = tvm::ffi::reflection;
415 refl::ObjectDef<LaunchThreadFrameNode>()
440 TVM_FFI_ICHECK(data !=
nullptr);
441 data_ = std::move(data);
461 namespace refl = tvm::ffi::reflection;
462 refl::ObjectDef<AttrFrameNode>()
486 TVM_FFI_ICHECK(data !=
nullptr);
487 data_ = std::move(data);
503 namespace refl = tvm::ffi::reflection;
525 TVM_FFI_ICHECK(data !=
nullptr);
526 data_ = std::move(data);
546 namespace refl = tvm::ffi::reflection;
547 refl::ObjectDef<IfFrameNode>()
570 TVM_FFI_ICHECK(data !=
nullptr);
583 namespace refl = tvm::ffi::reflection;
584 refl::ObjectDef<ThenFrameNode>();
610 TVM_FFI_ICHECK(data !=
nullptr);
623 namespace refl = tvm::ffi::reflection;
624 refl::ObjectDef<ElseFrameNode>();
650 TVM_FFI_ICHECK(data !=
nullptr);
664 namespace refl = tvm::ffi::reflection;
665 refl::ObjectDef<DeclBufferFrameNode>()
679 TVM_FFI_ICHECK(data !=
nullptr);
691 ffi::Optional<ffi::String> dispatch{std::nullopt};
694 namespace refl = tvm::ffi::reflection;
695 refl::ObjectDef<ComposeOpFrameNode>()
710 TVM_FFI_ICHECK(data !=
nullptr);
711 data_ = std::move(data);
721 namespace refl = tvm::ffi::reflection;
736 TVM_FFI_ICHECK(data !=
nullptr);
737 data_ = std::move(data);
752 ffi::Map<ffi::String, ffi::Any>
attrs;
755 namespace refl = tvm::ffi::reflection;
756 refl::ObjectDef<HintFrameNode>()
775 TVM_FFI_ICHECK(data !=
nullptr);
776 data_ = std::move(data);
Reference to PrimExprNode.
Definition: expr.h:126
Managed reference to an IRBuilderFrameNode.
Definition: base.h:103
tvm::tirx::Buffer buffer
The allocated buffer.
Definition: frame.h:718
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.AllocBufferFrame", AllocBufferFrameNode, TIRFrameNode)
void ExitWithScope() final
The method called when exiting RAII scope.
static void RegisterReflection()
Definition: frame.h:720
AllocBufferFrame(ffi::ObjectPtr< AllocBufferFrameNode > data)
Definition: frame.h:734
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(AllocBufferFrame, TIRFrame, AllocBufferFrameNode)
A frame that represents the assert statement. Proceeds if the condition is true, otherwise aborts wit...
Definition: frame.h:359
static void RegisterReflection()
Definition: frame.h:368
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.AssertFrame", AssertFrameNode, TIRFrameNode)
tvm::tirx::StringImm error_kind
The error kind, e.g. "RuntimeError", "TypeError", "ValueError".
Definition: frame.h:364
void ExitWithScope() final
The method called when exiting RAII scope.
ffi::Array< tvm::tirx::StringImm > message_parts
Error message fragments, concatenated at runtime when assertion fails.
Definition: frame.h:366
PrimExpr condition
The PrimExpr to test.
Definition: frame.h:362
Managed reference to AssertFrameNode.
Definition: frame.h:391
AssertFrame(ffi::ObjectPtr< AssertFrameNode > data)
Definition: frame.h:393
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(AssertFrame, TIRFrame, AssertFrameNode)
A frame that represents attribute node.
Definition: frame.h:451
ffi::String attr_key
Attribute type key.
Definition: frame.h:456
Any node
The node to annotate the attribute.
Definition: frame.h:454
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.AttrFrame", AttrFrameNode, TIRFrameNode)
void ExitWithScope() final
The method called when exiting RAII scope.
static void RegisterReflection()
Definition: frame.h:460
PrimExpr value
The value of the attribute.
Definition: frame.h:458
Managed reference to AttrFrameNode.
Definition: frame.h:483
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(AttrFrame, TIRFrame, AttrFrameNode)
AttrFrame(ffi::ObjectPtr< AttrFrameNode > data)
Definition: frame.h:485
A frame that represents the block initialization statment.
Definition: frame.h:214
void EnterWithScope() final
The method called when entering RAII scope.
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.SBlockInitFrame", BlockInitFrameNode, TIRFrameNode)
static void RegisterReflection()
Definition: frame.h:216
Managed reference to BlockInitFrameNode.
Definition: frame.h:241
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(BlockInitFrame, TIRFrame, BlockInitFrameNode)
BlockInitFrame(ffi::ObjectPtr< BlockInitFrameNode > data)
Definition: frame.h:243
ffi::Optional< ffi::String > dispatch
The optional dispatch variant name of the compose op.
Definition: frame.h:691
static void RegisterReflection()
Definition: frame.h:693
ffi::Map< ffi::String, tvm::tirx::Buffer > workspace
The workspace of the compose op.
Definition: frame.h:687
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.ComposeOpFrame", ComposeOpFrameNode, TIRFrameNode)
ffi::Map< ffi::String, ffi::Any > config
The config of the compose op.
Definition: frame.h:689
void ExitWithScope() final
The method called when exiting RAII scope.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ComposeOpFrame, TIRFrame, ComposeOpFrameNode)
ComposeOpFrame(ffi::ObjectPtr< ComposeOpFrameNode > data)
Definition: frame.h:709
static void RegisterReflection()
Definition: frame.h:663
bool allocated
The buffer allocated or not.
Definition: frame.h:661
void ExitWithScope() final
The method called when exiting RAII scope.
tvm::tirx::Buffer buffer
The declared buffer.
Definition: frame.h:659
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.DeclBufferFrame", DeclBufferFrameNode, TIRFrameNode)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(DeclBufferFrame, TIRFrame, DeclBufferFrameNode)
DeclBufferFrame(ffi::ObjectPtr< DeclBufferFrameNode > data)
Definition: frame.h:678
A frame that represents else.
Definition: frame.h:620
void EnterWithScope() final
The method called when entering RAII scope.
static void RegisterReflection()
Definition: frame.h:622
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.ElseFrame", ElseFrameNode, TIRFrameNode)
Managed reference to ElseFrameNode.
Definition: frame.h:647
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ElseFrame, TIRFrame, ElseFrameNode)
ElseFrame(ffi::ObjectPtr< ElseFrameNode > data)
Definition: frame.h:649
A frame that represents an execution scope (e.g. cta, warp, thread).
Definition: frame.h:258
ffi::Optional< tvm::tirx::ExecScope > exec_scope
The execution scope (always plain kind; no slice).
Definition: frame.h:261
ffi::Array< PrimExpr > guards
Optional surface-syntax guards for with Tx.scope(cond).
Definition: frame.h:263
void ExitWithScope() final
The method called when exiting RAII scope.
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.ExecScopeFrame", ExecScopeFrameNode, TIRFrameNode)
static void RegisterReflection()
Definition: frame.h:265
Managed reference to ExecScopeFrameNode.
Definition: frame.h:287
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ExecScopeFrame, TIRFrame, ExecScopeFrameNode)
ExecScopeFrame(ffi::ObjectPtr< ExecScopeFrameNode > data)
Definition: frame.h:289
A frame that represents the for loop.
Definition: frame.h:301
ffi::TypedFunction< tvm::tirx::Stmt(ffi::Array< tvm::tirx::Var > loop_vars, ffi::Array< Range > loop_extents, ffi::Array< ffi::Optional< PrimExpr > > loop_steps, tvm::tirx::Stmt loop_body)> FMakeForLoop
Functions that generate loop nests.
Definition: frame.h:312
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.ForFrame", ForFrameNode, TIRFrameNode)
FMakeForLoop f_make_for_loop
The for loop generating function.
Definition: frame.h:320
static void RegisterReflection()
Definition: frame.h:322
ffi::Array< Range > doms
The domains of iteration.
Definition: frame.h:316
ffi::Array< tvm::tirx::Var > vars
The loop variable.
Definition: frame.h:314
void ExitWithScope() final
The method called when exiting RAII scope.
ffi::Array< ffi::Optional< PrimExpr > > steps
The optional steps of iteration.
Definition: frame.h:318
Managed reference to ForFrameNode.
Definition: frame.h:344
ForFrame(ffi::ObjectPtr< ForFrameNode > data)
Definition: frame.h:346
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ForFrame, TIRFrame, ForFrameNode)
A frame that represents a hint directive for the sketch language.
Definition: frame.h:747
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.HintFrame", HintFrameNode, TIRFrameNode)
ffi::String message
The free-form hint message string.
Definition: frame.h:750
static void RegisterReflection()
Definition: frame.h:754
ffi::Map< ffi::String, ffi::Any > attrs
Optional structured key-value attributes.
Definition: frame.h:752
void ExitWithScope() final
The method called when exiting RAII scope.
Managed reference to HintFrameNode.
Definition: frame.h:772
HintFrame(ffi::ObjectPtr< HintFrameNode > data)
Definition: frame.h:774
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(HintFrame, TIRFrame, HintFrameNode)
A frame that represents if statement.
Definition: frame.h:536
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.IfFrame", IfFrameNode, TIRFrameNode)
ffi::Optional< ffi::Array< tvm::tirx::Stmt > > else_stmts
The stetements in the false branch.
Definition: frame.h:543
ffi::Optional< ffi::Array< tvm::tirx::Stmt > > then_stmts
The statements in the true branch.
Definition: frame.h:541
void ExitWithScope() final
The method called when exiting RAII scope.
PrimExpr condition
The condition of the if statement.
Definition: frame.h:539
static void RegisterReflection()
Definition: frame.h:545
Managed reference to IfFrameNode.
Definition: frame.h:567
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(IfFrame, TIRFrame, IfFrameNode)
IfFrame(ffi::ObjectPtr< IfFrameNode > data)
Definition: frame.h:569
The LaunchThreadFrameNode.
Definition: frame.h:404
PrimExpr extent
The extent of environment thread.
Definition: frame.h:407
tvm::tirx::IterVar iter_var
The iteration variable.
Definition: frame.h:411
ffi::String attr_key
The attribute key, could be either virtual_thread or thread_extent.
Definition: frame.h:409
void ExitWithScope() final
The method called when exiting RAII scope.
static void RegisterReflection()
Definition: frame.h:413
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.LaunchThreadFrame", LaunchThreadFrameNode, TIRFrameNode)
Managed reference to LaunchThreadFrameNode.
Definition: frame.h:436
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(LaunchThreadFrame, TIRFrame, LaunchThreadFrameNode)
LaunchThreadFrame(ffi::ObjectPtr< LaunchThreadFrameNode > data)
Definition: frame.h:438
A frame that represents the PrimFunc containing TIR statements.
Definition: frame.h:70
bool s_tir
Whether this PrimFunc uses s_tir semantics (root SBlock wrap, parser layout default = None)....
Definition: frame.h:92
void ExitWithScope() final
The method called when exiting RAII scope.
ffi::Map< tvm::tirx::Var, tvm::tirx::Buffer > buffer_map
Maps some parameters to specific Buffer data structures.
Definition: frame.h:81
ffi::Optional< Type > ret_type
The return type of the function.
Definition: frame.h:79
ffi::Map< ffi::String, Any > attrs
Additional attributes storing the meta-data.
Definition: frame.h:83
bool is_private
Whether the PrimFunc is annotated as private.
Definition: frame.h:77
static void RegisterReflection()
Definition: frame.h:96
ffi::Optional< ffi::String > name
The name of the block.
Definition: frame.h:73
ffi::Array< tvm::tirx::Var > args
Function parameters.
Definition: frame.h:75
bool persistent
Whether it is a persistent kernel.
Definition: frame.h:94
ffi::Map< tvm::tirx::Var, tvm::tirx::IterVar > env_threads
The variable map bound to thread env.
Definition: frame.h:85
ffi::Array< tvm::tirx::Buffer > root_alloc_buffers
The buffer allocated in root block.
Definition: frame.h:87
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.PrimFuncFrame", PrimFuncFrameNode, TIRFrameNode)
Managed reference to PrimFuncFrameNode.
Definition: frame.h:126
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(PrimFuncFrame, TIRFrame, PrimFuncFrameNode)
PrimFuncFrame(ffi::ObjectPtr< PrimFuncFrameNode > data)
Definition: frame.h:128
A frame that represents the block.
Definition: frame.h:140
ffi::Optional< ffi::Array< tvm::tirx::BufferRegion > > writes
The write buffer regions of the block.
Definition: frame.h:149
ffi::Array< tvm::tirx::Buffer > alloc_buffers
The buffer allocated in the block.
Definition: frame.h:153
ffi::Optional< ffi::Array< tvm::tirx::BufferRegion > > reads
The read buffer regions of the block.
Definition: frame.h:147
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.SSBlockFrame", SBlockFrameNode, TIRFrameNode)
void ExitWithScope() final
The method called when exiting RAII scope.
ffi::Optional< tvm::tirx::Stmt > init
The init statement of the bolck.
Definition: frame.h:151
ffi::Optional< ffi::Map< ffi::String, Any > > annotations
The annotation of the block.
Definition: frame.h:157
ffi::Optional< PrimExpr > predicate
The predicate of the block realization, the block will only be executed when the predicate is true.
Definition: frame.h:164
ffi::Array< tvm::tirx::IterVar > iter_vars
The variables of the block.
Definition: frame.h:145
static void RegisterReflection()
Definition: frame.h:168
ffi::Array< PrimExpr > iter_values
The corresponding values of the iter vars.
Definition: frame.h:159
bool no_realize
The flag whether to construct BlockRealize or Block.
Definition: frame.h:166
ffi::Array< tvm::tirx::MatchBufferRegion > match_buffers
The match buffer regions.
Definition: frame.h:155
ffi::String name
The name of the block.
Definition: frame.h:143
Managed reference to SBlockFrameNode.
Definition: frame.h:200
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(SBlockFrame, TIRFrame, SBlockFrameNode)
SBlockFrame(ffi::ObjectPtr< SBlockFrameNode > data)
Definition: frame.h:202
A base frame that represents the TIR fame with body of statements.
Definition: frame.h:39
TVM_FFI_DECLARE_OBJECT_INFO("script.ir_builder.tirx.TIRFrame", TIRFrameNode, IRBuilderFrameNode)
static void RegisterReflection()
Definition: frame.h:44
ffi::Array< tvm::tirx::Stmt > stmts
The Stmt within in this frame.
Definition: frame.h:42
Managed reference to TIRFrameNode.
Definition: frame.h:56
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(TIRFrame, IRBuilderFrame, TIRFrameNode)
TIRFrame(ffi::ObjectPtr< TIRFrameNode > data)
Definition: frame.h:62
A frame that represents then.
Definition: frame.h:580
void EnterWithScope() final
The method called when entering RAII scope.
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.ThenFrame", ThenFrameNode, TIRFrameNode)
static void RegisterReflection()
Definition: frame.h:582
Managed reference to ThenFrameNode.
Definition: frame.h:607
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ThenFrame, TIRFrame, ThenFrameNode)
ThenFrame(ffi::ObjectPtr< ThenFrameNode > data)
Definition: frame.h:609
A frame that represents while loop.
Definition: frame.h:497
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.WhileFrame", WhileFrameNode, TIRFrameNode)
PrimExpr condition
The termination condition of while.
Definition: frame.h:500
void ExitWithScope() final
The method called when exiting RAII scope.
static void RegisterReflection()
Definition: frame.h:502
Managed reference to WhileFrameNode.
Definition: frame.h:522
WhileFrame(ffi::ObjectPtr< WhileFrameNode > data)
Definition: frame.h:524
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(WhileFrame, TIRFrame, WhileFrameNode)
Buffer is a symbolic n-darray structure. It is a composition of primitive symbolic types,...
Definition: buffer.h:172
Iteration Variable, represents an iteration over an integer interval.
Definition: var.h:297
Container of all statements.
Definition: stmt.h:67
Managed reference to StringImmNode.
Definition: expr.h:69
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition: analyzer.h:37