23#ifndef TVM_TIRX_TILE_PRIMITIVE_H_
24#define TVM_TIRX_TILE_PRIMITIVE_H_
26#include <tvm/ffi/object.h>
56 namespace refl = tvm::ffi::reflection;
57 refl::ObjectDef<LambdaExprNode>()
129 ffi::Map<ffi::String, ffi::Array<PrimExpr>>
inter;
131 ffi::Map<ffi::String, ffi::Array<PrimExpr>>
intra;
136 namespace refl = tvm::ffi::reflection;
137 refl::ObjectDef<DispatchContextNode>()
174 ffi::Map<ffi::String, IterVar> launch_params = {},
175 ffi::Map<Var, Range> var_range_map = {},
bool alloc_only =
false,
176 ffi::Map<ffi::String, ffi::ObjectRef> callbacks = {},
177 ffi::Map<ffi::String, ffi::ObjectRef> shared_state = {},
178 ffi::Map<ffi::String, ffi::Array<PrimExpr>> inter = {},
179 ffi::Map<ffi::String, ffi::Array<PrimExpr>> intra = {},
180 ffi::String scope_kind =
"");
193 ffi::Map<ffi::String, BufferVar>
workspace,
194 ffi::Map<ffi::String, ffi::Any>
config, ffi::Optional<ffi::String>
dispatch,
222 namespace refl = tvm::ffi::reflection;
223 refl::ObjectDef<TilePrimitiveCallNode>()
242 ffi::Map<ffi::String, BufferVar> workspace = {},
243 ffi::Map<ffi::String, ffi::Any> config = {},
244 ffi::Optional<ffi::String> dispatch = std::nullopt,
Managed reference class to OpNode.
Definition op.h:163
Typed reference/view over any Expr whose ExprNode::ty is PrimType.
Definition base_expr.h:401
Managed reference class to TargetNode.
Definition target.h:134
RAII wrapper function to enter and exit a context object similar to python's with syntax.
Definition with_context.h:59
Checked zero-state view over an ordinary VarNode with BufferType.
Definition buffer.h:179
The context information of the kernel required by op dispatch.
Definition tile_primitive.h:104
bool alloc_only
Whether the dispatch context is only used for buffer allocation.
Definition tile_primitive.h:115
ffi::Map< ffi::String, ffi::ObjectRef > shared_state
Shared state that persists across dispatch calls within a single lowering pass.
Definition tile_primitive.h:119
ffi::Map< ffi::String, ffi::ObjectRef > callbacks
Callback to be handled when the operator is scheduled.
Definition tile_primitive.h:117
ExecScope exec_scope
The exec scope of the operator.
Definition tile_primitive.h:109
static void RegisterReflection()
Definition tile_primitive.h:135
ffi::Map< ffi::String, IterVar > launch_params
The kernel launch parameters.
Definition tile_primitive.h:111
ffi::String scope_kind
Scope kind string ("kernel"/"cta"/"warpgroup"/"warp"/"thread"/"cluster").
Definition tile_primitive.h:133
Target target
The target of the kernel.
Definition tile_primitive.h:107
void AddPostBufferDefStmt(BufferVar buffer, Stmt stmt)
Add a statement to be inserted after a buffer's definition.
void SharedStateSet(ffi::String key, ffi::ObjectRef value)
Set a value in the shared state cache.
ffi::Map< ffi::String, ffi::Array< PrimExpr > > inter
ExecContext inter-team view at this op site.
Definition tile_primitive.h:129
ffi::Map< Var, Range > var_range_map
A map from loop variables to their ranges.
Definition tile_primitive.h:113
ffi::Optional< ffi::ObjectRef > SharedStateGet(ffi::String key)
Get a value from the shared state cache.
ffi::Map< ffi::String, ffi::Array< PrimExpr > > intra
ExecContext intra-team view. Same encoding as inter.
Definition tile_primitive.h:131
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.DispatchContext", DispatchContextNode, ffi::Object)
void AddAllocBuffer(BufferVar buffer)
Add a buffer to be allocated in the kernel.
void AddInitStmt(Stmt stmt, bool host=false)
Add an initialization statement to be inserted.
Managed reference to DispatchContextNode.
Definition tile_primitive.h:171
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(DispatchContext, ffi::ObjectRef, DispatchContextNode)
DispatchContext(Target target, ExecScope exec_scope, ffi::Map< ffi::String, IterVar > 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="")
Definition exec_scope.h:228
A reified Python lambda: a list of bound variables and a body over them.
Definition tile_primitive.h:45
Array< Var > vars
The bound variables of the lambda.
Definition tile_primitive.h:48
PrimExpr pred
The lambda body over vars.
Definition tile_primitive.h:50
PrimExpr Apply(const Array< PrimExpr > &indices) const
Replace the bound variables with the given indices, returning the substituted body.
static void RegisterReflection()
Definition tile_primitive.h:55
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.LambdaExpr", LambdaExprNode, ffi::Object)
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition tile_primitive.h:62
Managed reference to LambdaExprNode.
Definition tile_primitive.h:70
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(LambdaExpr, ffi::ObjectRef, LambdaExprNode)
LambdaExpr(Array< Var > vars, PrimExpr pred)
Base node of all statements.
Definition stmt.h:43
Container of all statements.
Definition stmt.h:67
TIRX TilePrimitiveCall stmt.
Definition tile_primitive.h:188
ffi::Optional< ffi::String > dispatch
Definition tile_primitive.h:216
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.TilePrimitiveCall", TilePrimitiveCallNode, StmtNode)
TilePrimitiveCallNode(ffi::UnsafeInit tag)
Definition tile_primitive.h:190
ffi::Array< ffi::Any > args
Definition tile_primitive.h:207
tvm::Op op
Definition tile_primitive.h:204
TilePrimitiveCallNode(tvm::Op op, ffi::Array< ffi::Any > args, ffi::Map< ffi::String, BufferVar > workspace, ffi::Map< ffi::String, ffi::Any > config, ffi::Optional< ffi::String > dispatch, ExecScope scope)
Definition tile_primitive.h:192
static void RegisterReflection()
Definition tile_primitive.h:221
ffi::Map< ffi::String, BufferVar > workspace
Definition tile_primitive.h:210
ExecScope scope
Definition tile_primitive.h:219
ffi::Map< ffi::String, ffi::Any > config
Definition tile_primitive.h:213
Managed reference to TilePrimitiveCallNode.
Definition tile_primitive.h:239
TVM_DEFINE_OBJECT_REF_COW_METHOD(TilePrimitiveCallNode)
TilePrimitiveCall(tvm::Op op, ffi::Array< ffi::Any > args, ffi::Map< ffi::String, BufferVar > workspace={}, ffi::Map< ffi::String, ffi::Any > config={}, ffi::Optional< ffi::String > dispatch=std::nullopt, ExecScope scope=ExecScope(ScopeKind::kThread))
static bool IsValidOpCallArgType(const ffi::Any &arg)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(TilePrimitiveCall, Stmt, TilePrimitiveCallNode)
Primitive operators(builtin intrinsics) and registry for them.
constexpr const char * kPrivateAlloc
The buffers allocated by the operator.
Definition tile_primitive.h:86
constexpr const char * kPostBufferDefStmt
Statements to be inserted after a specific buffer's definition (DeclBuffer/AllocBuffer)....
Definition tile_primitive.h:98
constexpr const char * kDeviceInitStmt
The initialization statement of the operator. which will be inserted at the beginning of the kernel.
Definition tile_primitive.h:90
constexpr const char * kHostInitStmt
The initialization statement of the operator. which will be inserted at the beginning of the kernel.
Definition tile_primitive.h:94
const Op & copy_async()
See pesudo code below:
const Op & cast()
See pesudo code below:
const Op & binary_chain()
const Op & reduce_negate()
const Op & gemm()
See pesudo code below:
const Op & gemm_async()
See pesudo code below:
const Op & fill()
See pesudo code below:
const Op & binary_reduce()
ffi::TypedFunction< void(tvm::Op, ffi::Array< ffi::ObjectRef >)> FArgSanitizer
The type of the function that sanitizes the arguments of a TIRX operator.
Definition tile_primitive.h:82
const Op & copy()
See pesudo code below:
const Op & unary_reduce()
const Op & permute_layout()
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analyzer.h:40
Compilation target object.