24 #ifndef TVM_TIRX_EXEC_SCOPE_H_
25 #define TVM_TIRX_EXEC_SCOPE_H_
27 #include <tvm/ffi/container/variant.h>
127 namespace refl = tvm::ffi::reflection;
128 refl::ObjectDef<ScopeIdDefNode>()
141 TVM_DLL
explicit ScopeIdDef(ffi::Array<Var> def_ids, ffi::Optional<ffi::Array<PrimExpr>> extents,
143 ffi::Optional<ffi::Array<PrimExpr>> preferred_extents =
144 ffi::Optional<ffi::Array<PrimExpr>>(std::nullopt));
158 using ScopeIdSet = std::unordered_map<ScopeBinding, ScopeIdDef>;
191 const ffi::Optional<ffi::Array<PrimExpr>>& extents,
192 int out_dim,
const ffi::String& target_kind,
206 return static_cast<int>(a) <
static_cast<int>(b);
224 namespace refl = tvm::ffi::reflection;
225 refl::ObjectDef<ExecScopeNode>()
239 TVM_DLL
explicit ExecScope(
const ffi::String& name, ffi::Array<ScopeIdDef> scope_id_def = {})
Reference to PrimExprNode.
Definition: expr.h:126
Definition: exec_scope.h:213
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition: exec_scope.h:230
ScopeKind kind
scope identity; one of the closed ScopeKind values.
Definition: exec_scope.h:218
static void RegisterReflection()
Definition: exec_scope.h:223
TVM_FFI_DECLARE_OBJECT_INFO("tirx.ExecScope", ExecScopeNode, ffi::Object)
ffi::Array< ScopeIdDef > scope_id_def
Definition: exec_scope.h:215
ffi::String name() const
Human-readable name derived from kind (for printing / errors).
Definition: exec_scope.h:221
Definition: exec_scope.h:234
ExecScope(const ffi::String &name, ffi::Array< ScopeIdDef > scope_id_def={})
Construct from a name string (FATALs on unknown name).
Definition: exec_scope.h:239
ExecScope(ScopeKind kind, ffi::Array< ScopeIdDef > scope_id_def={})
Construct from a ScopeKind (canonical).
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(ExecScope, ffi::ObjectRef, ExecScopeNode)
Definition: exec_scope.h:101
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.ScopeIdDef", ScopeIdDefNode, ffi::Object)
ScopeBinding scope
The (parent, cur) binding of this scope id as a closed enum.
Definition: exec_scope.h:119
static void RegisterReflection()
Definition: exec_scope.h:126
ffi::Optional< ffi::Array< PrimExpr > > extents
The extents of the ScopeId.
Definition: exec_scope.h:117
ffi::Array< Var > def_ids
The ScopeId defined.
Definition: exec_scope.h:104
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition: exec_scope.h:135
ffi::Optional< ffi::Array< PrimExpr > > preferred_extents
Optional preferred extents (cluster→cta only). Maps to cudaLaunchAttributePreferredClusterDimension (...
Definition: exec_scope.h:124
Definition: exec_scope.h:156
std::unordered_map< ScopeBinding, ScopeIdDef > ScopeIdSet
Definition: exec_scope.h:158
ScopeIdSet id_set
The resolved scope id set; id_set[binding] is the best-known def for that binding (extents filled in ...
Definition: exec_scope.h:178
Mode
Verification mode.
Definition: exec_scope.h:169
bool Verify(const ffi::Array< ScopeIdDef > &defs, Mode mode=Mode::kStrict)
Verify the scope id definitions are well formed.
Definition: exec_scope.h:139
TVM_DEFINE_OBJECT_REF_COW_METHOD(ScopeIdDefNode)
ScopeIdDef(ffi::Array< Var > def_ids, ffi::Optional< ffi::Array< PrimExpr >> extents, ScopeBinding scope, ffi::Optional< ffi::Array< PrimExpr >> preferred_extents=ffi::Optional< ffi::Array< PrimExpr >>(std::nullopt))
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(ScopeIdDef, ffi::ObjectRef, ScopeIdDefNode)
bool is_deferred() const
Whether this def has a deferred (unknown) extent.
Definition: exec_scope.h:147
PrimExpr fused_extent() const
Product of all extent dimensions. PRECONDITION: !is_deferred().
Static resolver for ScopeIdDef values. Replaces the former ScopeIdResolveTable runtime registry with ...
Definition: exec_scope.h:185
static ffi::Array< PrimExpr > Resolve(ScopeBinding binding, const ffi::Optional< ffi::Array< PrimExpr >> &extents, int out_dim, const ffi::String &target_kind, const LaunchParams ¶ms)
Resolve a ScopeIdDef for a given canonical binding + target.
static PrimExpr ComputeWarpIdInCta(const LaunchParams ¶ms)
Compute the warp_id_in_cta shuffle expression from threadIdx in launch params.
std::unordered_map< ffi::String, IterVar > LaunchParams
Definition: exec_scope.h:187
IRModule that holds the functions and type definitions.
std::pair< ffi::String, ffi::String > ScopeBindingToStringPair(ScopeBinding binding)
Convert a ScopeBinding to its (parent, cur) string pair.
bool ScopeKindHigher(ScopeKind a, ScopeKind b)
Strict-weak "a is wider than b" on scope kinds: world > kernel > cluster > cta > warpgroup > warp > t...
Definition: exec_scope.h:205
ScopeKind StringToScopeKind(const ffi::String &name)
Parse a string name to a ScopeKind. FATAL if unknown.
ScopeKind
The target execution scope kind of an ExecScopeStmt.
Definition: exec_scope.h:45
bool ScopeNameHigher(const ffi::String &a, const ffi::String &b)
String-keyed convenience over ScopeKindHigher. FATALs on bad name.
ScopeBinding
The binding between a parent scope and a child scope as used by a ScopeIdDef. The closed enum of vali...
Definition: exec_scope.h:81
ScopeBinding StringPairToScopeBinding(const ffi::String &parent, const ffi::String &cur)
Parse a (parent, cur) string pair to a ScopeBinding. FATAL if unknown.
std::string ScopeKindToString(ScopeKind kind)
Convert a ScopeKind to its string name (e.g. kKernel -> "kernel").
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition: analyzer.h:37