19#ifndef TVM_SCRIPT_IR_BUILDER_TIR_FRAME_H_
20#define TVM_SCRIPT_IR_BUILDER_TIR_FRAME_H_
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;
81 ffi::Map<tvm::tirx::Var, tvm::tirx::BufferVar>
buffer_map;
83 ffi::Map<ffi::String, Any>
attrs;
97 namespace refl = tvm::ffi::reflection;
98 refl::ObjectDef<PrimFuncFrameNode>()
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>()
171 .def_ro(
"name", &SBlockFrameNode::name)
172 .def_ro(
"iter_vars", &SBlockFrameNode::iter_vars)
173 .def_ro(
"reads", &SBlockFrameNode::reads)
174 .def_ro(
"writes", &SBlockFrameNode::writes)
175 .def_ro(
"init", &SBlockFrameNode::init)
176 .def_ro(
"alloc_buffers", &SBlockFrameNode::alloc_buffers)
177 .def_ro(
"match_buffers", &SBlockFrameNode::match_buffers)
178 .def_ro(
"annotations", &SBlockFrameNode::annotations)
179 .def_ro(
"iter_values", &SBlockFrameNode::iter_values)
180 .def_ro(
"predicate", &SBlockFrameNode::predicate)
181 .def_ro(
"no_realize", &SBlockFrameNode::no_realize);
204 data_ = std::move(data);
217 namespace refl = tvm::ffi::reflection;
218 refl::ObjectDef<BlockInitFrameNode>();
245 data_ = std::move(data);
268 ffi::Array<tvm::tirx::Var>
vars;
272 ffi::Array<ffi::Optional<PrimExpr>>
steps;
277 namespace refl = tvm::ffi::reflection;
278 refl::ObjectDef<ForFrameNode>()
279 .def_ro(
"vars", &ForFrameNode::vars)
280 .def_ro(
"doms", &ForFrameNode::doms);
302 data_ = std::move(data);
323 namespace refl = tvm::ffi::reflection;
324 refl::ObjectDef<AssertFrameNode>()
325 .def_ro(
"condition", &AssertFrameNode::condition)
326 .def_ro(
"error_kind", &AssertFrameNode::error_kind)
327 .def_ro(
"message_parts", &AssertFrameNode::message_parts);
349 data_ = std::move(data);
368 namespace refl = tvm::ffi::reflection;
369 refl::ObjectDef<LaunchThreadFrameNode>()
370 .def_ro(
"extent", &LaunchThreadFrameNode::extent)
371 .def_ro(
"attr_key", &LaunchThreadFrameNode::attr_key)
372 .def_ro(
"iter_var", &LaunchThreadFrameNode::iter_var);
395 data_ = std::move(data);
415 namespace refl = tvm::ffi::reflection;
416 refl::ObjectDef<AttrFrameNode>()
417 .def_ro(
"node", &AttrFrameNode::node)
418 .def_ro(
"attr_key", &AttrFrameNode::attr_key)
419 .def_ro(
"value", &AttrFrameNode::value);
441 data_ = std::move(data);
457 namespace refl = tvm::ffi::reflection;
458 refl::ObjectDef<WhileFrameNode>().def_ro(
"condition", &WhileFrameNode::condition);
480 data_ = std::move(data);
500 namespace refl = tvm::ffi::reflection;
501 refl::ObjectDef<IfFrameNode>()
502 .def_ro(
"condition", &IfFrameNode::condition)
503 .def_ro(
"then_stmts", &IfFrameNode::then_stmts)
504 .def_ro(
"else_stmts", &IfFrameNode::else_stmts);
537 namespace refl = tvm::ffi::reflection;
538 refl::ObjectDef<ThenFrameNode>();
577 namespace refl = tvm::ffi::reflection;
578 refl::ObjectDef<ElseFrameNode>();
620 namespace refl = tvm::ffi::reflection;
621 refl::ObjectDef<DeclBufferFrameNode>()
622 .def_ro(
"buffer", &DeclBufferFrameNode::buffer)
623 .def_ro(
"data", &DeclBufferFrameNode::data)
624 .def_ro(
"allocated", &DeclBufferFrameNode::allocated);
648 ffi::Optional<ffi::String> dispatch{std::nullopt};
651 namespace refl = tvm::ffi::reflection;
652 refl::ObjectDef<ComposeOpFrameNode>()
653 .def_ro(
"workspace", &ComposeOpFrameNode::workspace)
654 .def_ro(
"config", &ComposeOpFrameNode::config)
655 .def_ro(
"dispatch", &ComposeOpFrameNode::dispatch);
668 data_ = std::move(data);
678 namespace refl = tvm::ffi::reflection;
679 refl::ObjectDef<AllocBufferFrameNode>().def_ro(
"buffer", &AllocBufferFrameNode::buffer);
694 data_ = std::move(data);
709 ffi::Map<ffi::String, ffi::Any>
attrs;
712 namespace refl = tvm::ffi::reflection;
713 refl::ObjectDef<HintFrameNode>()
714 .def_ro(
"message", &HintFrameNode::message)
715 .def_ro(
"attrs", &HintFrameNode::attrs);
733 data_ = std::move(data);
Managed reference to ExprNode.
Definition base_expr.h:335
Typed reference/view over any Expr whose ExprNode::ty is PrimType.
Definition base_expr.h:401
RAII wrapper function to enter and exit a context object similar to python's with syntax.
Definition with_context.h:59
Managed reference to StringImmNode.
Definition expr.h:68
Managed reference to an IRBuilderFrameNode.
Definition base.h:103
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.AllocBufferFrame", AllocBufferFrameNode, TIRFrameNode)
tvm::tirx::BufferVar buffer
The allocated buffer.
Definition frame.h:675
void ExitWithScope() final
The method called when exiting RAII scope.
static void RegisterReflection()
Definition frame.h:677
AllocBufferFrame(ffi::ObjectPtr< AllocBufferFrameNode > data)
Definition frame.h:691
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:313
static void RegisterReflection()
Definition frame.h:322
ffi::Array< tvm::prim::StringImm > message_parts
Error message fragments, concatenated at runtime when assertion fails.
Definition frame.h:320
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.AssertFrame", AssertFrameNode, TIRFrameNode)
void ExitWithScope() final
The method called when exiting RAII scope.
tvm::prim::StringImm error_kind
The error kind, e.g. "RuntimeError", "TypeError", "ValueError".
Definition frame.h:318
PrimExpr condition
The PrimExpr to test.
Definition frame.h:316
Managed reference to AssertFrameNode.
Definition frame.h:345
AssertFrame(ffi::ObjectPtr< AssertFrameNode > data)
Definition frame.h:347
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(AssertFrame, TIRFrame, AssertFrameNode)
A frame that represents attribute node.
Definition frame.h:405
ffi::String attr_key
Attribute type key.
Definition frame.h:410
Any node
The node to annotate the attribute.
Definition frame.h:408
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:414
PrimExpr value
The value of the attribute.
Definition frame.h:412
Managed reference to AttrFrameNode.
Definition frame.h:437
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(AttrFrame, TIRFrame, AttrFrameNode)
AttrFrame(ffi::ObjectPtr< AttrFrameNode > data)
Definition frame.h:439
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::Map< ffi::String, tvm::tirx::BufferVar > workspace
The workspace of the compose op.
Definition frame.h:644
static void RegisterReflection()
Definition frame.h:650
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:646
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:666
static void RegisterReflection()
Definition frame.h:619
bool allocated
The buffer allocated or not.
Definition frame.h:617
Expr data
Physical pointer expression backing the declaration.
Definition frame.h:615
tvm::tirx::BufferVar buffer
The declared buffer.
Definition frame.h:613
void ExitWithScope() final
The method called when exiting RAII scope.
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:635
A frame that represents else.
Definition frame.h:574
void EnterWithScope() final
The method called when entering RAII scope.
static void RegisterReflection()
Definition frame.h:576
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.ElseFrame", ElseFrameNode, TIRFrameNode)
Managed reference to ElseFrameNode.
Definition frame.h:601
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ElseFrame, TIRFrame, ElseFrameNode)
ElseFrame(ffi::ObjectPtr< ElseFrameNode > data)
Definition frame.h:603
A frame that represents the for loop.
Definition frame.h:255
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:266
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:274
static void RegisterReflection()
Definition frame.h:276
ffi::Array< Range > doms
The domains of iteration.
Definition frame.h:270
ffi::Array< tvm::tirx::Var > vars
The loop variable.
Definition frame.h:268
void ExitWithScope() final
The method called when exiting RAII scope.
ffi::Array< ffi::Optional< PrimExpr > > steps
The optional steps of iteration.
Definition frame.h:272
Managed reference to ForFrameNode.
Definition frame.h:298
ForFrame(ffi::ObjectPtr< ForFrameNode > data)
Definition frame.h:300
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ForFrame, TIRFrame, ForFrameNode)
A frame that represents a hint directive for the sketch language.
Definition frame.h:704
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:707
static void RegisterReflection()
Definition frame.h:711
ffi::Map< ffi::String, ffi::Any > attrs
Optional structured key-value attributes.
Definition frame.h:709
void ExitWithScope() final
The method called when exiting RAII scope.
Managed reference to HintFrameNode.
Definition frame.h:729
HintFrame(ffi::ObjectPtr< HintFrameNode > data)
Definition frame.h:731
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(HintFrame, TIRFrame, HintFrameNode)
A frame that represents if statement.
Definition frame.h:490
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:497
ffi::Optional< ffi::Array< tvm::tirx::Stmt > > then_stmts
The statements in the true branch.
Definition frame.h:495
void ExitWithScope() final
The method called when exiting RAII scope.
PrimExpr condition
The condition of the if statement.
Definition frame.h:493
static void RegisterReflection()
Definition frame.h:499
Managed reference to IfFrameNode.
Definition frame.h:521
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(IfFrame, TIRFrame, IfFrameNode)
IfFrame(ffi::ObjectPtr< IfFrameNode > data)
Definition frame.h:523
The LaunchThreadFrameNode.
Definition frame.h:358
PrimExpr extent
The extent of environment thread.
Definition frame.h:361
tvm::tirx::IterVar iter_var
The iteration variable.
Definition frame.h:365
ffi::String attr_key
The attribute key, could be either virtual_thread or thread_extent.
Definition frame.h:363
void ExitWithScope() final
The method called when exiting RAII scope.
static void RegisterReflection()
Definition frame.h:367
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.LaunchThreadFrame", LaunchThreadFrameNode, TIRFrameNode)
Managed reference to LaunchThreadFrameNode.
Definition frame.h:390
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(LaunchThreadFrame, TIRFrame, LaunchThreadFrameNode)
LaunchThreadFrame(ffi::ObjectPtr< LaunchThreadFrameNode > data)
Definition frame.h:392
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::BufferVar > 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
ffi::Array< tvm::tirx::BufferVar > root_alloc_buffers
The buffer allocated in root block.
Definition frame.h:87
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
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::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::BufferVar > alloc_buffers
The buffer allocated in the block.
Definition frame.h:153
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:534
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:536
Managed reference to ThenFrameNode.
Definition frame.h:561
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ThenFrame, TIRFrame, ThenFrameNode)
ThenFrame(ffi::ObjectPtr< ThenFrameNode > data)
Definition frame.h:563
A frame that represents while loop.
Definition frame.h:451
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.WhileFrame", WhileFrameNode, TIRFrameNode)
PrimExpr condition
The termination condition of while.
Definition frame.h:454
void ExitWithScope() final
The method called when exiting RAII scope.
static void RegisterReflection()
Definition frame.h:456
Managed reference to WhileFrameNode.
Definition frame.h:476
WhileFrame(ffi::ObjectPtr< WhileFrameNode > data)
Definition frame.h:478
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(WhileFrame, TIRFrame, WhileFrameNode)
Checked zero-state view over an ordinary VarNode with BufferType.
Definition buffer.h:179
Iteration Variable, represents an iteration over an integer interval.
Definition var.h:194
Container of all statements.
Definition stmt.h:67
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analyzer.h:40