24 #ifndef TVM_TIRX_STMT_H_
25 #define TVM_TIRX_STMT_H_
27 #include <tvm/ffi/reflection/registry.h>
35 #include <type_traits>
54 namespace refl = tvm::ffi::reflection;
67 class Stmt :
public ffi::ObjectRef {
87 namespace refl = tvm::ffi::reflection;
88 refl::ObjectDef<BindNode>()
89 .def_ro(
"var", &
BindNode::var, refl::AttachFieldFlag::SEqHashDef())
129 namespace refl = tvm::ffi::reflection;
130 refl::ObjectDef<AttrStmtNode>()
171 namespace refl = tvm::ffi::reflection;
172 refl::ObjectDef<AssertStmtNode>()
215 namespace refl = tvm::ffi::reflection;
216 refl::ObjectDef<BufferStoreNode>()
232 ffi::Optional<PrimExpr> predicate = std::nullopt,
246 namespace refl = tvm::ffi::reflection;
274 namespace refl = tvm::ffi::reflection;
275 refl::ObjectDef<AllocBufferNode>()
287 ffi::Map<ffi::String, ffi::Any> annotations = ffi::Map<ffi::String, ffi::Any>(),
295 for (
const PrimExpr& extent : (*this)->buffer->shape) {
296 if (
const auto* int_size = extent.as<
IntImmNode>()) {
297 result *= int_size->value;
326 namespace refl = tvm::ffi::reflection;
344 namespace refl = tvm::ffi::reflection;
375 size_t size()
const {
return operator->()->size(); }
400 template <
typename... Args>
402 ffi::Array<Stmt> seq;
404 ffi::details::for_each(
Flattener(&seq), std::forward<Args>(seq_args)...);
408 }
else if (seq.size() == 1) {
415 if constexpr (
sizeof...(seq_args) == 1) {
417 SeqStmt original = opt.value();
418 bool all_same = [&]() {
419 if (original->seq.
size() != seq.size()) {
422 for (
size_t i = 0; i < seq.size(); i++) {
423 if (!original->seq[i].same_as(seq[i])) {
440 explicit Flattener(ffi::Array<Stmt>* seq) : seq_(seq) {}
442 template <
typename T>
444 if constexpr (std::is_same_v<T, SeqStmt>) {
447 if constexpr (!std::is_base_of_v<T, SeqStmt>) {
450 if constexpr (std::is_base_of_v<Stmt, T>) {
451 if (
const SeqStmtNode* ptr = t.template as<SeqStmtNode>()) {
452 return ffi::GetRef<SeqStmt>(ptr);
460 template <
typename T>
462 if constexpr (std::is_base_of_v<ObjectRef, T>) {
464 if (!stmt_or_seq.defined()) {
469 if constexpr (std::is_same_v<T, SeqStmt>) {
471 (*this)(0, stmt_or_seq->seq);
475 if constexpr (std::is_base_of_v<T, SeqStmt>) {
478 if (
auto* op = stmt_or_seq.template as<SeqStmtNode>()) {
484 if constexpr (std::is_base_of_v<T, Evaluate>) {
489 if (
auto* op = stmt_or_seq.template as<EvaluateNode>()) {
490 if (
auto* as_int = op->value.template as<IntImmNode>(); as_int && as_int->value == 0) {
496 if constexpr (std::is_base_of_v<Stmt, T>) {
498 seq_->push_back(stmt_or_seq);
501 for (
auto v : stmt_or_seq) {
508 ffi::Array<Stmt>* seq_;
528 namespace refl = tvm::ffi::reflection;
529 refl::ObjectDef<IfThenElseNode>()
544 ffi::Optional<Stmt> else_case = std::nullopt,
Span span =
Span());
620 namespace refl = tvm::ffi::reflection;
621 refl::ObjectDef<ForNode>()
645 ffi::Optional<IterVar> thread_binding = std::nullopt,
646 ffi::Map<ffi::String, ffi::Any> annotations = {},
647 ffi::Optional<PrimExpr> step = std::nullopt,
Span span =
Span());
671 namespace refl = tvm::ffi::reflection;
672 refl::ObjectDef<WhileNode>()
697 namespace refl = tvm::ffi::reflection;
698 refl::ObjectDef<BreakNode>();
722 namespace refl = tvm::ffi::reflection;
723 refl::ObjectDef<ContinueNode>();
752 namespace refl = tvm::ffi::reflection;
753 refl::ObjectDef<BufferRegionNode>()
808 namespace refl = tvm::ffi::reflection;
809 refl::ObjectDef<MatchBufferRegionNode>()
880 namespace refl = tvm::ffi::reflection;
881 refl::ObjectDef<SBlockNode>()
902 ffi::Array<IterVar> iter_vars, ffi::Array<BufferRegion> reads,
903 ffi::Array<BufferRegion> writes, ffi::String name_hint,
Stmt body,
904 ffi::Optional<Stmt> init = std::nullopt,
905 ffi::Array<Buffer> alloc_buffers = ffi::Array<Buffer>(),
906 ffi::Array<MatchBufferRegion> match_buffers = ffi::Array<MatchBufferRegion>(),
907 ffi::Map<ffi::String, ffi::Any> annotations = ffi::Map<ffi::String, ffi::Any>(),
911 ffi::Array<Buffer> alloc_buffers = ffi::Array<Buffer>(),
934 namespace refl = tvm::ffi::reflection;
935 refl::ObjectDef<SBlockRealizeNode>()
977 namespace refl = tvm::ffi::reflection;
978 refl::ObjectDef<ExecScopeStmtNode>()
1170 "tirx.manifest_shared_memory_local_stage";
1183 "meta_schedule.thread_extent_low_inclusive";
1187 "meta_schedule.thread_extent_high_inclusive";
1191 "meta_schedule.random_compute_producer";
1280 return attr_key.compare(0, 7,
"pragma_") == 0;
1303 return "vectorized";
1307 return "thread_binding";
1309 TVM_FFI_THROW(InternalError) <<
"Unknown ForKind" << t;
1310 TVM_FFI_UNREACHABLE();
Constant integer literals in the program.
Definition: expr.h:494
Base class for other IR constructs that can be converted to PrimExpr. This is useful for the FFI to c...
Definition: expr.h:156
Managed reference to PrimExprConvertibleNode.
Definition: expr.h:167
Reference to PrimExprNode.
Definition: expr.h:126
Definition: source_map.h:111
Runtime primitive data type.
Definition: data_type.h:45
Allocate a buffer and declare it in scope.
Definition: stmt.h:261
ffi::Map< ffi::String, ffi::Any > annotations
Additional annotations about the allocation.
Definition: stmt.h:271
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.AllocBuffer", AllocBufferNode, StmtNode)
static void RegisterReflection()
Definition: stmt.h:273
Buffer buffer
The buffer being allocated and declared.
Definition: stmt.h:264
Managed reference to AllocBufferNode.
Definition: stmt.h:283
AllocBuffer(Buffer buffer, ffi::Map< ffi::String, ffi::Any > annotations=ffi::Map< ffi::String, ffi::Any >(), Span span=Span())
std::optional< int64_t > ConstantAllocationSize() const
If the buffer's shape is constant, return the total number of elements.
Definition: stmt.h:293
TVM_DEFINE_OBJECT_REF_COW_METHOD(AllocBufferNode)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(AllocBuffer, Stmt, AllocBufferNode)
Assert condition, if an error occurs, return the error message.
Definition: stmt.h:161
PrimExpr condition
Condition to be checked.
Definition: stmt.h:164
StringImm error_kind
The error kind, e.g. "RuntimeError", "TypeError", "ValueError".
Definition: stmt.h:166
static void RegisterReflection()
Definition: stmt.h:170
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.AssertStmt", AssertStmtNode, StmtNode)
ffi::Array< StringImm > message_parts
Error message fragments, concatenated at runtime when assertion fails.
Definition: stmt.h:168
Managed reference to AssertStmtNode.
Definition: stmt.h:184
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(AssertStmt, Stmt, AssertStmtNode)
AssertStmt(PrimExpr condition, StringImm error_kind, ffi::Array< StringImm > message_parts, Span span=Span())
TVM_DEFINE_OBJECT_REF_COW_METHOD(AssertStmtNode)
Define certain auxiliary attribute for the body to be a symbolic value. This provide auxiliary inform...
Definition: stmt.h:117
static void RegisterReflection()
Definition: stmt.h:128
PrimExpr value
The attribute value, value is well defined at current scope.
Definition: stmt.h:124
ffi::Any node
this is attribute about certain node
Definition: stmt.h:120
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.AttrStmt", AttrStmtNode, StmtNode)
ffi::String attr_key
the type key of the attribute
Definition: stmt.h:122
Stmt body
The body statement to be executed.
Definition: stmt.h:126
Managed reference to AttrStmtNode.
Definition: stmt.h:143
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(AttrStmt, Stmt, AttrStmtNode)
AttrStmt(ffi::Any node, ffi::String attr_key, PrimExpr value, Stmt body, Span span=Span())
TVM_DEFINE_OBJECT_REF_COW_METHOD(AttrStmtNode)
Bind a variable to a value in the enclosing scope.
Definition: stmt.h:79
PrimExpr value
The value to bind to the variable.
Definition: stmt.h:84
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.Bind", BindNode, StmtNode)
static void RegisterReflection()
Definition: stmt.h:86
Var var
The variable being bound.
Definition: stmt.h:82
Managed reference to BindNode.
Definition: stmt.h:99
Bind(Var var, PrimExpr value, Span span=Span())
TVM_DEFINE_OBJECT_REF_COW_METHOD(BindNode)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(Bind, Stmt, BindNode)
A Break in control flow.
Definition: stmt.h:694
static void RegisterReflection()
Definition: stmt.h:696
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.Break", BreakNode, StmtNode)
Managed reference to BreakNode.
Definition: stmt.h:708
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(Break, Stmt, BreakNode)
TVM_DEFINE_OBJECT_REF_COW_METHOD(BreakNode)
Representing the region of multi-dimensional buffer access.
Definition: stmt.h:744
ffi::Array< Range > region
The region array of the buffer region.
Definition: stmt.h:749
PrimExpr ToPrimExpr() const final
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.BufferRegion", BufferRegionNode, PrimExprConvertibleNode)
static void RegisterReflection()
Definition: stmt.h:751
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition: stmt.h:760
Buffer buffer
The buffer of the buffer region.
Definition: stmt.h:747
Managed reference to BufferRegionNode.
Definition: stmt.h:768
static BufferRegion FullRegion(Buffer buffer)
Create a BufferRegion which is full region of the given buffer.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(BufferRegion, PrimExprConvertible, BufferRegionNode)
BufferRegion(Buffer buffer, ffi::Array< Range > region)
static BufferRegion FromPoint(Buffer buffer, ffi::Array< PrimExpr > indices)
Create a BufferRegion which is a single point of the given buffer.
TVM_DEFINE_OBJECT_REF_COW_METHOD(BufferRegionNode)
Store value to the high dimension buffer.
Definition: stmt.h:203
Buffer buffer
The buffer variable.
Definition: stmt.h:206
ffi::Array< PrimExpr > indices
The indices location to be stored.
Definition: stmt.h:210
static void RegisterReflection()
Definition: stmt.h:214
PrimExpr value
The value to be stored.
Definition: stmt.h:208
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.BufferStore", BufferStoreNode, StmtNode)
ffi::Optional< PrimExpr > predicate
The predicate mask for storing values.
Definition: stmt.h:212
Managed reference to BufferStoreNode.
Definition: stmt.h:229
BufferStore(Buffer buffer, PrimExpr value, ffi::Array< PrimExpr > indices, ffi::Optional< PrimExpr > predicate=std::nullopt, Span span=Span())
TVM_DEFINE_OBJECT_REF_COW_METHOD(BufferStoreNode)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(BufferStore, Stmt, BufferStoreNode)
Buffer is a symbolic n-darray structure. It is a composition of primitive symbolic types,...
Definition: buffer.h:172
A Continue in control flow.
Definition: stmt.h:719
static void RegisterReflection()
Definition: stmt.h:721
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.Continue", ContinueNode, StmtNode)
Managed reference to ContinueNode.
Definition: stmt.h:733
TVM_DEFINE_OBJECT_REF_COW_METHOD(ContinueNode)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(Continue, Stmt, ContinueNode)
Declare a buffer that can be used in the body.
Definition: stmt.h:240
Buffer buffer
The buffer being declared.
Definition: stmt.h:243
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.DeclBuffer", DeclBufferNode, StmtNode)
static void RegisterReflection()
Definition: stmt.h:245
Managed reference to DeclBufferNode.
Definition: stmt.h:253
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(DeclBuffer, Stmt, DeclBufferNode)
DeclBuffer(Buffer buffer, Span span=Span())
TVM_DEFINE_OBJECT_REF_COW_METHOD(DeclBufferNode)
Evaluates an expression. This is mostly used for putting a Call node into Stmt.
Definition: stmt.h:338
PrimExpr value
The expression to be evaluated.
Definition: stmt.h:341
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.Evaluate", EvaluateNode, StmtNode)
static void RegisterReflection()
Definition: stmt.h:343
Managed reference to EvaluateNode.
Definition: stmt.h:354
Evaluate(PrimExpr value, Span span=Span())
Evaluate(int value, Span span=Span())
Definition: stmt.h:358
TVM_DEFINE_OBJECT_REF_COW_METHOD(EvaluateNode)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(Evaluate, Stmt, EvaluateNode)
A statement that annotates the execution scope for its body.
Definition: stmt.h:969
static void RegisterReflection()
Definition: stmt.h:976
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.ExecScopeStmt", ExecScopeStmtNode, StmtNode)
Stmt body
The body statement under this execution scope.
Definition: stmt.h:974
ExecScope exec_scope
The execution scope.
Definition: stmt.h:972
Managed reference to ExecScopeStmtNode.
Definition: stmt.h:989
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(ExecScopeStmt, Stmt, ExecScopeStmtNode)
ExecScopeStmt(ExecScope exec_scope, Stmt body, Span span=Span())
TVM_DEFINE_OBJECT_REF_COW_METHOD(ExecScopeStmtNode)
Definition: exec_scope.h:234
A for loop, with possible type annotations.
Definition: stmt.h:588
PrimExpr min
The minimum value of iteration.
Definition: stmt.h:593
ffi::Optional< IterVar > thread_binding
Only valid when kind == ForKind::kThreadBinding The context thread that this loop variable bounds to.
Definition: stmt.h:604
ffi::Optional< PrimExpr > step
The loop step. It is one if not specified.
Definition: stmt.h:617
Var loop_var
The loop variable.
Definition: stmt.h:591
bool HasTrivialStep() const
Check it is a loop without nontrivial loop step.
Stmt body
The body of the for loop.
Definition: stmt.h:599
PrimExpr extent
The extent of the iteration.
Definition: stmt.h:595
ForKind kind
The kind of the for loop.
Definition: stmt.h:597
ffi::Map< ffi::String, ffi::Any > annotations
Additional annotations about the loop.
Definition: stmt.h:613
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.For", ForNode, StmtNode)
static void RegisterReflection()
Definition: stmt.h:619
Managed reference to ForNode.
Definition: stmt.h:642
For(Var loop_var, PrimExpr min, PrimExpr extent, ForKind kind, Stmt body, ffi::Optional< IterVar > thread_binding=std::nullopt, ffi::Map< ffi::String, ffi::Any > annotations={}, ffi::Optional< PrimExpr > step=std::nullopt, Span span=Span())
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(For, Stmt, ForNode)
TVM_DEFINE_OBJECT_REF_COW_METHOD(ForNode)
IfThenElse statement.
Definition: stmt.h:518
static void RegisterReflection()
Definition: stmt.h:527
ffi::Optional< Stmt > else_case
The branch to be executed when condition is false, can be null.
Definition: stmt.h:525
PrimExpr condition
The condition.
Definition: stmt.h:521
Stmt then_case
The branch to be executed when condition is true.
Definition: stmt.h:523
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.IfThenElse", IfThenElseNode, StmtNode)
Managed reference to IfThenElseNode.
Definition: stmt.h:541
TVM_DEFINE_OBJECT_REF_COW_METHOD(IfThenElseNode)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(IfThenElse, Stmt, IfThenElseNode)
IfThenElse(PrimExpr condition, Stmt then_case, ffi::Optional< Stmt > else_case=std::nullopt, Span span=Span())
Match introduces a constraint that the source buffer region can be remapped to the data layout specif...
Definition: stmt.h:800
Buffer buffer
The target buffer.
Definition: stmt.h:803
BufferRegion source
The source buffer region.
Definition: stmt.h:805
static void RegisterReflection()
Definition: stmt.h:807
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.MatchBufferRegion", MatchBufferRegionNode, ffi::Object)
Managed reference to MatchBufferRegionNode.
Definition: stmt.h:822
TVM_DEFINE_OBJECT_REF_COW_METHOD(MatchBufferRegionNode)
MatchBufferRegion(Buffer buffer, BufferRegion source)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(MatchBufferRegion, ffi::ObjectRef, MatchBufferRegionNode)
A block is a basic schedule unit in TIR.
Definition: stmt.h:852
ffi::Array< Buffer > alloc_buffers
The buffer allocated in the block.
Definition: stmt.h:863
Stmt body
The body of the block.
Definition: stmt.h:877
ffi::Array< BufferRegion > reads
The read buffer regions of the block.
Definition: stmt.h:857
static void RegisterReflection()
Definition: stmt.h:879
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.SBlock", SBlockNode, StmtNode)
ffi::Array< MatchBufferRegion > match_buffers
The match buffer regions.
Definition: stmt.h:865
ffi::String name_hint
The name_hint of the block.
Definition: stmt.h:861
ffi::Optional< Stmt > init
The init statement is executed during the first iteration of reduction loops in a reduction block....
Definition: stmt.h:875
ffi::Array< IterVar > iter_vars
The variables of the block.
Definition: stmt.h:855
ffi::Array< BufferRegion > writes
The write buffer regions of the block.
Definition: stmt.h:859
ffi::Map< ffi::String, ffi::Any > annotations
The annotation of the block.
Definition: stmt.h:867
A block realization node represents execution of the block at the binding values.
Definition: stmt.h:921
static void RegisterReflection()
Definition: stmt.h:933
PrimExpr predicate
The predicate of the block realization, the block will only be executed when the predicate is true.
Definition: stmt.h:929
ffi::Array< PrimExpr > iter_values
The corresponding values of the iter vars.
Definition: stmt.h:924
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.SBlockRealize", SBlockRealizeNode, StmtNode)
SBlock block
The block to be realized.
Definition: stmt.h:931
Managed reference to BlockRealizeNode.
Definition: stmt.h:947
TVM_DEFINE_OBJECT_REF_COW_METHOD(SBlockRealizeNode)
SBlockRealize(ffi::Array< PrimExpr > iter_values, PrimExpr predicate, SBlock block, Span span=Span())
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(SBlockRealize, Stmt, SBlockRealizeNode)
Managed reference to SBlockNode.
Definition: stmt.h:899
SBlock(ffi::String name_hint, Stmt body, ffi::Array< Buffer > alloc_buffers=ffi::Array< Buffer >(), Span span=Span())
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(SBlock, Stmt, SBlockNode)
TVM_DEFINE_OBJECT_REF_COW_METHOD(SBlockNode)
SBlock(ffi::Array< IterVar > iter_vars, ffi::Array< BufferRegion > reads, ffi::Array< BufferRegion > writes, ffi::String name_hint, Stmt body, ffi::Optional< Stmt > init=std::nullopt, ffi::Array< Buffer > alloc_buffers=ffi::Array< Buffer >(), ffi::Array< MatchBufferRegion > match_buffers=ffi::Array< MatchBufferRegion >(), ffi::Map< ffi::String, ffi::Any > annotations=ffi::Map< ffi::String, ffi::Any >(), Span span=Span())
The container of seq statement. Represent a sequence of statements.
Definition: stmt.h:313
size_t size() const
Definition: stmt.h:319
Stmt operator[](size_t index) const
Get the index-th element in the sequence.
Definition: stmt.h:323
ffi::Array< Stmt > seq
internal sequence content.
Definition: stmt.h:316
static void RegisterReflection()
Definition: stmt.h:325
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.SeqStmt", SeqStmtNode, StmtNode)
Helper class to flatten sequence of arguments into Array.
Definition: stmt.h:438
static ffi::Optional< SeqStmt > AsSeqStmt(const T &t)
Definition: stmt.h:443
void operator()(size_t i, const T &stmt_or_seq) const
Definition: stmt.h:461
Flattener(ffi::Array< Stmt > *seq)
Definition: stmt.h:440
Sequence statement.
Definition: stmt.h:365
TVM_DEFINE_OBJECT_REF_COW_METHOD(SeqStmtNode)
Stmt operator[](size_t index) const
Get the index-th element in the sequence.
Definition: stmt.h:379
static Stmt Flatten(Args &&... seq_args)
Construct a sequence statement by flattening all the arrays and sequences in the arguments recursivel...
Definition: stmt.h:401
size_t size() const
Definition: stmt.h:375
SeqStmt(ffi::Array< Stmt > seq, Span span=Span())
Construct SeqStmt.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(SeqStmt, Stmt, SeqStmtNode)
Base node of all statements.
Definition: stmt.h:42
static constexpr const uint32_t _type_child_slots
Definition: stmt.h:62
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition: stmt.h:60
Span span
Span that points to the original source code. Reserved debug information.
Definition: stmt.h:48
StmtNode(Span span)
Definition: stmt.h:51
TVM_FFI_DECLARE_OBJECT_INFO("tirx.Stmt", StmtNode, ffi::Object)
static void RegisterReflection()
Definition: stmt.h:53
TVM_OBJECT_ENABLE_SCRIPT_PRINTER()
Container of all statements.
Definition: stmt.h:67
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(Stmt, ffi::ObjectRef, StmtNode)
Managed reference to StringImmNode.
Definition: expr.h:69
a named variable in TIR
Definition: var.h:77
A While loop.
Definition: stmt.h:663
static void RegisterReflection()
Definition: stmt.h:670
PrimExpr condition
The termination condition.
Definition: stmt.h:666
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.While", WhileNode, StmtNode)
Stmt body
The body of the while loop.
Definition: stmt.h:668
Managed reference to WhileNode.
Definition: stmt.h:683
TVM_DEFINE_OBJECT_REF_COW_METHOD(WhileNode)
While(PrimExpr condition, Stmt body, Span span=Span())
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(While, Stmt, WhileNode)
Printer class to print repr string of each AST/IR nodes.
void Evaluate(PrimExpr value)
Evaluate the input expression.
Var var(std::string name_hint, DataType t=DataType::Int(32))
Construct a new Var expression.
constexpr const char * hand_threaded
Mark that the kernel is hand threaded and doesn't need syncs inserted.
Definition: stmt.h:1137
constexpr const char * script_parsing_detect_access
Mark whether the script-completer need to fill in missing access region during script parsing.
Definition: stmt.h:1146
constexpr const char * software_pipeline_stage
Mark the stage of a statement in the software pipeline.
Definition: stmt.h:1154
constexpr const char * irregular_loop_mark
,ark a ForNode represent an irregular loop of non-structural control flow edges.
Definition: stmt.h:1267
constexpr const char * fragment_layout
Mark that the layout of TensorCore fragment.
Definition: stmt.h:1132
constexpr const char * manifest_shared_memory_local_stage
Mark the local stage for the shared memory access should be added.
Definition: stmt.h:1169
constexpr const char * meta_schedule_vectorize
Mark auto-vectorize setting on the block.
Definition: stmt.h:1197
constexpr const char * explicit_write_region
Mark that a block has an explicitly specified write region. This is used to override the default writ...
Definition: stmt.h:1263
constexpr const int meta_schedule_cache_type_read
Definition: stmt.h:1232
constexpr const char * channel_write_scope
channel write scope
Definition: stmt.h:1090
constexpr const char * auto_copy
Mark auto copy for memhammer.
Definition: stmt.h:1238
constexpr const char * thread_extent
Mark launching extent of thread, used by device API.
Definition: stmt.h:1033
bool IsPragmaKey(const std::string &attr_key)
Check if attr_key is a pragma key extension.
Definition: stmt.h:1279
constexpr const char * double_buffer_scope
Marks production of double buffer data.
Definition: stmt.h:1054
constexpr const char * software_pipeline_async_stages
List stages in the software pipeline that should run asynchronously.
Definition: stmt.h:1163
constexpr const char * meta_schedule_cache_type
Mark a block as generated by cache_read or cache_write block. 0 means cache_read; 1 means cache_write...
Definition: stmt.h:1229
constexpr const char * meta_schedule_unroll_implicit
Mark auto-unroll setting on the block.
Definition: stmt.h:1203
constexpr const char * meta_schedule_thread_extent_low_inclusive
The allowed range of thread extent in thread bindings.
Definition: stmt.h:1182
constexpr const char * warp_execution
Mark that a block is executed by a warp. This implies the extend of threadIdx.x is warp size.
Definition: stmt.h:1250
constexpr const char * explicit_read_region
Mark that a block has an explicitly specified read region. This is used to override the default read ...
Definition: stmt.h:1258
constexpr const char * software_pipeline_order
Mark the order of a statement in the software pipeline.
Definition: stmt.h:1157
constexpr const char * pragma_unroll_explicit
Pragma: unroll explicit.
Definition: stmt.h:1029
constexpr const char * storage_alignment
Mark storage alignment requirement of buffers.
Definition: stmt.h:1031
constexpr const char * buffer_bound
Mark stores/loads with their bounds.
Definition: stmt.h:1000
constexpr const char * meta_schedule_cooperative_fetch
Mark that the loop should be further skip and bound to environment threads to enable cooperative fetc...
Definition: stmt.h:1179
constexpr const char * scan_init_scope
Mark of scan init scope.
Definition: stmt.h:1062
constexpr const char * layout_free_buffers
Mark the buffers which is const access and can be transformed layout.
Definition: stmt.h:1166
constexpr const char * buffer_data_alignment
Mark buffer initial addr alignment in bytes.
Definition: stmt.h:1071
constexpr const char * meta_schedule_inline_rule
Mark that a block is disallowed in auto inline.
Definition: stmt.h:1253
constexpr const char * kPersistentKernel
Mark the kernel as persistent.
Definition: stmt.h:1272
constexpr const char * device_id
The allocation device for global malloc in host.
Definition: stmt.h:1007
constexpr const char * meta_schedule_layout_rewrite_preproc
Mark that a block is a preprocessor block for layout rewrite.
Definition: stmt.h:1209
constexpr const char * scan_update_scope
Mark of scan update scope.
Definition: stmt.h:1060
constexpr const char * pragma_auto_unroll_max_step
Pragma: auto-unroll, max_step.
Definition: stmt.h:1019
constexpr const char * async_commit_queue_scope
Annotations for invoking and synchronizing asynchronous operations.
Definition: stmt.h:1120
constexpr const char * tensorized_nki_instruction
Definition: stmt.h:1264
constexpr const char * layout_transforms
Marks the layout transforms to be used for a tensor.
Definition: stmt.h:1042
constexpr const char * pragma_import_llvm
Import llvm source or file into the final code gen module.
Definition: stmt.h:1023
constexpr const char * meta_schedule_auto_tensorize_init
Mark that the init statement of a block should be further rewritten using tensorization.
Definition: stmt.h:1213
constexpr const char * pragma_import_c
Import C source or file into the final code gen module.
Definition: stmt.h:1021
constexpr const char * meta_schedule_tensor_core_enabled
Mark that tensor core is enabled in the PrimExpr.
Definition: stmt.h:1221
constexpr const char * compute_scope
Mark the scope as when computation start to happen. This can hint some code generator to create a new...
Definition: stmt.h:1005
constexpr const char * async_scope
Mark that the attached statement runs asynchronously.
Definition: stmt.h:1101
constexpr const char * pragma_tensor_core
Try to modify the AST to support Tensor Core.
Definition: stmt.h:1027
constexpr const char * buffer_allocated_addr
Mark buffer allocated addr in bytes.
Definition: stmt.h:1073
constexpr const char * buffer_bind_scope
Bind the buffer specification to the region of the op When this scope occurs, the stmt....
Definition: stmt.h:1083
constexpr const char * meta_schedule_unroll_explicit
Mark auto-unroll setting on the block.
Definition: stmt.h:1200
constexpr const char * async_wait_queue_scope
Definition: stmt.h:1121
constexpr const char * meta_schedule_auto_tensorize
Mark that a block should be further rewritten using tensorization.
Definition: stmt.h:1206
constexpr const char * channel_read_scope
channel read scope
Definition: stmt.h:1086
constexpr const char * meta_schedule_parallel
Mark auto-parallel setting on the block.
Definition: stmt.h:1194
constexpr const char * device_type
The device type.
Definition: stmt.h:1011
constexpr const char * axis_separators
Marks the physical axis separators.
Definition: stmt.h:1050
constexpr const char * async_wait_inflight_count
Definition: stmt.h:1122
constexpr const char * channel_read_advance
Advance step of channel after end of scope.
Definition: stmt.h:1088
constexpr const char * kVolatile
Annotation key on AllocBuffer marking the allocation as volatile.
Definition: stmt.h:1035
constexpr const char * device_scope
Mark that it is in the device scope.
Definition: stmt.h:1009
constexpr const char * extern_scope
Mark the scope as generated by extern primitive. Such scope can contain arbitrary ir program and we n...
Definition: stmt.h:1017
constexpr const char * double_buffer_write
Marks region used by double buffer write.
Definition: stmt.h:1058
constexpr const char * pipeline_exec_scope
pipeline execution scope, implies the scope can be pipelined.
Definition: stmt.h:1096
constexpr const char * local_stage
Mark local stage constraint on data copy.
Definition: stmt.h:1241
constexpr const char * fragment_shape
Mark that the shape of TensorCore fragment.
Definition: stmt.h:1127
constexpr const char * pipeline_stage_scope
pipeline stage scope, implies always execution
Definition: stmt.h:1094
constexpr const int meta_schedule_cache_type_write
Definition: stmt.h:1235
constexpr const char * channel_write_advance
Advance step of channel after end of scope.
Definition: stmt.h:1092
constexpr const char * pragma_scope_prefix
Mark region is guarded by the pragma extension.
Definition: stmt.h:1025
constexpr const char * buffer_dim_align
Mark alignment of buffer dimension stmt.node is Tensor stmt.value is tvm_tuple(dim,...
Definition: stmt.h:1069
constexpr const char * pragma_loop_partition_hint
Mark that the loop should be partitioned.
Definition: stmt.h:1151
constexpr const char * meta_schedule_tiling_structure
Mark the tiling structure of blocks that are applied by rule Multi-Level-Tiling.
Definition: stmt.h:1173
constexpr const char * meta_schedule_random_compute_producer
Mark the block whose producer needs to be applied by rule Random-Compute-Location.
Definition: stmt.h:1190
constexpr const char * meta_schedule_thread_extent_high_inclusive
The allowed range of thread extent in thread bindings.
Definition: stmt.h:1186
constexpr const char * vector_bytes
Mark vectorization length constraint on block.
Definition: stmt.h:1244
constexpr const char * require_block_var_bound_predicate
Mark that the block need to add predicate for block var bounds during lowering.
Definition: stmt.h:1218
@ kUnrolled
The execution is unrolled.
Definition: var.h:233
@ kVectorized
The loop is vectorized.
Definition: var.h:237
PrimExpr TypeAnnotation(DataType dtype, Span span=Span())
Create a type annotation expression.
std::ostream & operator<<(std::ostream &os, CallEffectKind side_effect)
Definition: op_attr_types.h:123
ForKind
The kind of the loop.
Definition: stmt.h:557
@ kThreadBinding
The loop variable is bound to a thread in an environment. In the final stage of lowering,...
@ kParallel
Parallel execution on CPU.
@ kSerial
default semantics – serial execution.
const char * ForKind2String(ForKind t)
Definition: stmt.h:1296
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition: analyzer.h:37