19#ifndef TVM_SCRIPT_IR_BUILDER_FRAME_H_
20#define TVM_SCRIPT_IR_BUILDER_FRAME_H_
22#include <tvm/ffi/reflection/registry.h>
51 ffi::Map<ffi::String, Any>
attrs;
56 namespace refl = tvm::ffi::reflection;
57 refl::ObjectDef<IRModuleFrameObj>()
78 TVM_FFI_ICHECK(data !=
nullptr);
90 ffi::reflection::ObjectDef<StmtFrameObj>().def_ro(
"stmts", &StmtFrameObj::stmts);
120 ffi::Array<tvm::Var> loop_vars, ffi::Array<Range> loop_extents,
127 ffi::Array<ffi::Optional<PrimExpr>>
steps;
132 namespace refl = tvm::ffi::reflection;
133 refl::ObjectDef<ForFrameObj>()
134 .def_ro(
"vars", &ForFrameObj::vars)
135 .def_ro(
"doms", &ForFrameObj::doms);
142 void SetNames(ffi::Optional<ffi::Variant<ffi::String, ffi::Array<ffi::String>>> names);
155 TVM_FFI_ICHECK(data !=
nullptr);
156 data_ = std::move(data);
169 explicit AssertFrameObj(ffi::UnsafeInit tag) : condition(tag), error_kind(tag) {}
172 : condition(std::move(condition)), error_kind(std::move(error_kind)) {}
182 namespace refl = tvm::ffi::reflection;
183 refl::ObjectDef<AssertFrameObj>()
184 .def_ro(
"condition", &AssertFrameObj::condition)
185 .def_ro(
"error_kind", &AssertFrameObj::error_kind)
186 .def_ro(
"message_parts", &AssertFrameObj::message_parts);
207 TVM_FFI_ICHECK(data !=
nullptr);
208 data_ = std::move(data);
232 namespace refl = tvm::ffi::reflection;
233 refl::ObjectDef<RegionFrameObj>()
234 .def_ro(
"op", &RegionFrameObj::op)
235 .def_ro(
"args", &RegionFrameObj::args)
236 .def_ro(
"body_params", &RegionFrameObj::body_params)
237 .def_ro(
"attrs", &RegionFrameObj::attrs);
250 TVM_FFI_ICHECK(data !=
nullptr);
251 data_ = std::move(data);
271 namespace refl = tvm::ffi::reflection;
272 refl::ObjectDef<WhileFrameObj>().def_ro(
"condition", &WhileFrameObj::condition);
293 TVM_FFI_ICHECK(data !=
nullptr);
294 data_ = std::move(data);
318 namespace refl = tvm::ffi::reflection;
319 refl::ObjectDef<IfFrameObj>()
320 .def_ro(
"condition", &IfFrameObj::condition)
321 .def_ro(
"then_stmts", &IfFrameObj::then_stmts)
322 .def_ro(
"else_stmts", &IfFrameObj::else_stmts);
342 TVM_FFI_ICHECK(data !=
nullptr);
355 namespace refl = tvm::ffi::reflection;
356 refl::ObjectDef<ThenFrameObj>();
370 void ExitWithScope() final;
381 TVM_FFI_ICHECK(data !=
nullptr);
394 namespace refl = tvm::ffi::reflection;
395 refl::ObjectDef<ElseFrameObj>();
409 void ExitWithScope() final;
420 TVM_FFI_ICHECK(data !=
nullptr);
Managed reference to DictAttrsNode.
Definition attrs.h:108
Non-nullable source-location metadata.
Definition location.h:91
Reference-counted handle to a canonical named operator.
Definition op.h:147
Typed reference/view over any Expr whose ExprNode::ty is PrimType.
Definition base_expr.h:447
Sequence statement.
Definition stmt.h:92
Container of all statements.
Definition stmt.h:62
Managed reference to a string literal.
Definition expr.h:99
A stack frame of the IRBuilder used to keep track of the current scope. Furthermore,...
Definition base.h:43
Managed reference to an IRBuilderFrameObj.
Definition base.h:85
A frame that represents the assert statement. Proceeds if the condition is true, otherwise aborts wit...
Definition frame.h:167
tvm::StringImm error_kind
The error kind, e.g. "RuntimeError", "TypeError", "ValueError".
Definition frame.h:177
void ExitWithScope() final
The method called when exiting RAII scope.
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.AssertFrame", AssertFrameObj, StmtFrameObj)
static void RegisterReflection()
Definition frame.h:181
AssertFrameObj(PrimExpr condition, tvm::StringImm error_kind)
Definition frame.h:171
AssertFrameObj(ffi::UnsafeInit tag)
Definition frame.h:169
ffi::Array< tvm::StringImm > message_parts
Error message fragments, concatenated at runtime when assertion fails.
Definition frame.h:179
PrimExpr condition
The PrimExpr to test.
Definition frame.h:175
Managed reference to AssertFrameObj.
Definition frame.h:204
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(AssertFrame, StmtFrame, AssertFrameObj)
AssertFrame(ffi::ObjectPtr< AssertFrameObj > data)
Definition frame.h:206
A frame that represents else.
Definition frame.h:391
void EnterWithScope() final
The method called when entering RAII scope.
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.ElseFrame", ElseFrameObj, StmtFrameObj)
static void RegisterReflection()
Definition frame.h:393
Managed reference to ElseFrameObj.
Definition frame.h:417
ElseFrame(ffi::ObjectPtr< ElseFrameObj > data)
Definition frame.h:419
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ElseFrame, StmtFrame, ElseFrameObj)
A frame that represents the for loop.
Definition frame.h:110
static void RegisterReflection()
Definition frame.h:131
ffi::Array< Range > doms
The domains of iteration.
Definition frame.h:125
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.ForFrame", ForFrameObj, StmtFrameObj)
FMakeForLoop f_make_for_loop
The for loop generating function.
Definition frame.h:129
ffi::Array< ffi::Optional< PrimExpr > > steps
The optional steps of iteration.
Definition frame.h:127
ffi::TypedFunction< tvm::Stmt(ffi::Array< tvm::Var > loop_vars, ffi::Array< Range > loop_extents, ffi::Array< ffi::Optional< PrimExpr > > loop_steps, tvm::SeqStmt loop_body, Location loc)> FMakeForLoop
Functions that generate loop nests.
Definition frame.h:121
void ExitWithScope() final
Construct the loop nest with this frame's stored source location.
ffi::Array< tvm::Var > vars
The loop variable.
Definition frame.h:123
void SetNames(ffi::Optional< ffi::Variant< ffi::String, ffi::Array< ffi::String > > > names)
Apply source target names before entry, preserving variable identity.
Managed reference to ForFrameObj.
Definition frame.h:152
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ForFrame, StmtFrame, ForFrameObj)
ForFrame(ffi::ObjectPtr< ForFrameObj > data)
Definition frame.h:154
A frame that represents the IRModule frame with functions and global variables.
Definition frame.h:41
ffi::Map< GlobalVar, BaseFunc > functions
A map from GlobalVar to all global functions.
Definition frame.h:49
static void RegisterReflection()
Definition frame.h:55
ffi::Map< ffi::String, GlobalVar > global_var_map
A map from string names to global variables that ensures global uniqueness.
Definition frame.h:44
void ExitWithScope() final
The method called when exiting RAII scope.
ffi::Map< ffi::String, ffi::Array< GlobalInfo > > global_infos
IRModule's global_infos.
Definition frame.h:53
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.IRModuleFrame", IRModuleFrameObj, IRBuilderFrameObj)
ffi::Map< ffi::String, Any > attrs
IRModule's attributes.
Definition frame.h:51
Managed reference to IRModuleFrameObj.
Definition frame.h:75
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(IRModuleFrame, IRBuilderFrame, IRModuleFrameObj)
IRModuleFrame(ffi::ObjectPtr< IRModuleFrameObj > data)
Definition frame.h:77
A frame that represents if statement.
Definition frame.h:304
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.IfFrame", IfFrameObj, StmtFrameObj)
IfFrameObj(ffi::UnsafeInit tag)
Definition frame.h:306
PrimExpr condition
The condition of the if statement.
Definition frame.h:311
ffi::Optional< ffi::Array< tvm::Stmt > > then_stmts
The statements in the true branch.
Definition frame.h:313
ffi::Optional< ffi::Array< tvm::Stmt > > else_stmts
The stetements in the false branch.
Definition frame.h:315
void ExitWithScope() final
The method called when exiting RAII scope.
IfFrameObj(PrimExpr condition)
Definition frame.h:308
static void RegisterReflection()
Definition frame.h:317
Managed reference to IfFrameObj.
Definition frame.h:339
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(IfFrame, StmtFrame, IfFrameObj)
IfFrame(ffi::ObjectPtr< IfFrameObj > data)
Definition frame.h:341
A result-free region with lexical body parameters.
Definition frame.h:217
void ExitWithScope() final
Construct the region and add it to the enclosing builder frame.
RegionFrameObj(Op op)
Definition frame.h:220
ffi::Array< Expr > args
Operands evaluated in the enclosing scope.
Definition frame.h:225
RegionFrameObj(ffi::UnsafeInit tag)
Definition frame.h:219
static void RegisterReflection()
Definition frame.h:231
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.RegionFrame", RegionFrameObj, StmtFrameObj)
Op op
The operation represented by this region.
Definition frame.h:223
DictAttrs attrs
Additional operation attributes.
Definition frame.h:229
ffi::Array< Var > body_params
Variables defined at entry to the region body.
Definition frame.h:227
Managed reference to RegionFrameObj.
Definition frame.h:247
RegionFrame(ffi::ObjectPtr< RegionFrameObj > data)
Definition frame.h:249
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(RegionFrame, StmtFrame, RegionFrameObj)
A shared frame containing a sequence of core IR statements.
Definition frame.h:84
ffi::Array< tvm::Stmt > stmts
The statements within this frame.
Definition frame.h:87
static void RegisterReflection()
Definition frame.h:89
TVM_FFI_DECLARE_OBJECT_INFO("script.ir_builder.StmtFrame", StmtFrameObj, IRBuilderFrameObj)
Managed reference to StmtFrameObj.
Definition frame.h:96
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(StmtFrame, IRBuilderFrame, StmtFrameObj)
StmtFrame(ffi::ObjectPtr< StmtFrameObj > data)
Definition frame.h:102
A frame that represents then.
Definition frame.h:352
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.ThenFrame", ThenFrameObj, StmtFrameObj)
static void RegisterReflection()
Definition frame.h:354
void EnterWithScope() final
The method called when entering RAII scope.
Managed reference to ThenFrameObj.
Definition frame.h:378
ThenFrame(ffi::ObjectPtr< ThenFrameObj > data)
Definition frame.h:380
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(ThenFrame, StmtFrame, ThenFrameObj)
A frame that represents while loop.
Definition frame.h:261
WhileFrameObj(ffi::UnsafeInit tag)
Definition frame.h:263
void ExitWithScope() final
The method called when exiting RAII scope.
WhileFrameObj(PrimExpr condition)
Definition frame.h:265
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.tirx.WhileFrame", WhileFrameObj, StmtFrameObj)
static void RegisterReflection()
Definition frame.h:270
PrimExpr condition
The termination condition of while.
Definition frame.h:268
Managed reference to WhileFrameObj.
Definition frame.h:290
WhileFrame(ffi::ObjectPtr< WhileFrameObj > data)
Definition frame.h:292
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(WhileFrame, StmtFrame, WhileFrameObj)
Statements shared across IR dialects.
IRModule that holds the functions and type definitions.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition attr.h:23