23#ifndef TVM_TIRX_TILE_CONTEXT_H_
24#define TVM_TIRX_TILE_CONTEXT_H_
36inline constexpr ffi::reflection::AttrKey<ffi::Array<Bind>>
kPrivateAlloc{
"private_alloc"};
40inline constexpr ffi::reflection::AttrKey<ffi::Array<Stmt>>
kDeviceInitStmt{
"device_init_stmt"};
44inline constexpr ffi::reflection::AttrKey<ffi::Array<Stmt>>
kHostInitStmt{
"host_init_stmt"};
48inline constexpr ffi::reflection::AttrKey<ffi::Map<TensorVar, ffi::Array<Stmt>>>
kPostTensorDefStmt{
49 "post_tensor_def_stmt"};
85 ffi::Map<ffi::String, ffi::Array<PrimExpr>>
inter;
87 ffi::Map<ffi::String, ffi::Array<PrimExpr>>
intra;
92 namespace refl = tvm::ffi::reflection;
93 refl::ObjectDef<DispatchContextObj>()
108 ffi::Map<ffi::String, ffi::Any> annotations = {});
125 return ffi::Optional<ffi::ObjectRef>();
140 ffi::Map<ffi::String, ffi::Tuple<PrimVar, PrimExpr>> launch_params = {},
141 ffi::Map<Var, Range> var_range_map = {},
bool alloc_only =
false,
142 ffi::Map<ffi::String, ffi::ObjectRef> callbacks = {},
143 ffi::Map<ffi::String, ffi::ObjectRef> shared_state = {},
144 ffi::Map<ffi::String, ffi::Array<PrimExpr>> inter = {},
145 ffi::Map<ffi::String, ffi::Array<PrimExpr>> intra = {}, ffi::String scope_kind =
"");
#define TVM_TIRX_DLL
Definition base.h:55
TIRx statements and shared statement entry header.
Container of all statements.
Definition stmt.h:61
Managed reference class to TargetObj.
Definition target.h:155
Checked zero-state view over an ordinary VarObj with TensorType.
Definition expr.h:48
Canonical thread-scope identity, named as backend.scope.
Definition thread_scope.h:55
The context information of the kernel required by op dispatch.
Definition context.h:55
TVM_TIRX_DLL void AddInitStmt(Stmt stmt, bool host=false)
Add an initialization statement to be inserted.
ffi::String scope_kind
Scope kind string ("kernel"/"cta"/"warpgroup"/"warp"/"thread"/"cluster").
Definition context.h:89
DispatchContextObj(Target target, ThreadScope thread_scope)
Definition context.h:57
bool alloc_only
Whether the dispatch context is only used for tensor allocation.
Definition context.h:71
void SharedStateSet(ffi::String key, ffi::ObjectRef value)
Set a value in the shared state cache.
Definition context.h:117
ffi::Map< ffi::String, ffi::Array< PrimExpr > > inter
ExecContext inter-team view at this op site.
Definition context.h:85
DispatchContextObj(ffi::UnsafeInit)
Definition context.h:59
static constexpr bool _type_mutable
Definition context.h:130
ffi::Map< ffi::String, ffi::ObjectRef > callbacks
Callback to be handled when the operator is scheduled.
Definition context.h:73
ffi::Map< Var, Range > var_range_map
A map from loop variables to their ranges.
Definition context.h:69
ffi::Map< ffi::String, ffi::ObjectRef > shared_state
Shared state that persists across dispatch calls within a single lowering pass.
Definition context.h:75
ffi::Map< ffi::String, ffi::Array< PrimExpr > > intra
ExecContext intra-team view. Same encoding as inter.
Definition context.h:87
ThreadScope thread_scope
The thread scope of the operator.
Definition context.h:65
static void RegisterReflection()
Definition context.h:91
TVM_TIRX_DLL void AddPostTensorDefStmt(TensorVar tensor, Stmt stmt)
Add a statement to be inserted after a tensor's definition.
TVM_TIRX_DLL void AddAllocTensor(TensorVar tensor, ffi::Array< PrimExpr > allocated_addr={}, ffi::Map< ffi::String, ffi::Any > annotations={})
Add a tensor to be allocated in the kernel.
ffi::Optional< ffi::ObjectRef > SharedStateGet(ffi::String key)
Get a value from the shared state cache.
Definition context.h:120
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.DispatchContext", DispatchContextObj, ffi::Object)
ffi::Map< ffi::String, ffi::Tuple< PrimVar, PrimExpr > > launch_params
Hardware tag to (index variable, extent) launch parameters.
Definition context.h:67
Target target
The target of the kernel.
Definition context.h:63
Managed reference to DispatchContextObj.
Definition context.h:136
TVM_TIRX_DLL DispatchContext(Target target, ThreadScope thread_scope, ffi::Map< ffi::String, ffi::Tuple< PrimVar, PrimExpr > > launch_params={}, ffi::Map< Var, Range > var_range_map={}, bool alloc_only=false, ffi::Map< ffi::String, ffi::ObjectRef > callbacks={}, ffi::Map< ffi::String, ffi::ObjectRef > shared_state={}, ffi::Map< ffi::String, ffi::Array< PrimExpr > > inter={}, ffi::Map< ffi::String, ffi::Array< PrimExpr > > intra={}, ffi::String scope_kind="")
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(DispatchContext, ffi::ObjectRef, DispatchContextObj)
constexpr ffi::reflection::AttrKey< ffi::Array< Stmt > > kHostInitStmt
The initialization statement of the operator. which will be inserted at the beginning of the kernel.
Definition context.h:44
constexpr ffi::reflection::AttrKey< ffi::Array< Stmt > > kDeviceInitStmt
The initialization statement of the operator. which will be inserted at the beginning of the kernel.
Definition context.h:40
constexpr ffi::reflection::AttrKey< ffi::Map< TensorVar, ffi::Array< Stmt > > > kPostTensorDefStmt
Statements to be inserted after a specific tensor's definition (DeclTensor/AllocTensor)....
Definition context.h:48
constexpr ffi::reflection::AttrKey< ffi::Array< Bind > > kPrivateAlloc
The allocation Bind statements requested by the operator.
Definition context.h:36
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analysis.h:41
Compilation target object.
Enum identities for backend-defined thread hierarchies.