24 #ifndef TVM_TIRX_EXEC_SCOPE_H_
25 #define TVM_TIRX_EXEC_SCOPE_H_
27 #include <tvm/ffi/container/variant.h>
125 namespace refl = tvm::ffi::reflection;
126 refl::ObjectDef<ScopeIdDefNode>()
140 ffi::Optional<ffi::Array<PrimExpr>> extents,
ScopeBinding scope,
141 ffi::Optional<ffi::Array<PrimExpr>> preferred_extents =
142 ffi::Optional<ffi::Array<PrimExpr>>(std::nullopt));
156 using ScopeIdSet = std::unordered_map<ScopeBinding, ScopeIdDef>;
189 const ffi::Optional<ffi::Array<PrimExpr>>& extents,
190 int out_dim,
const ffi::String& target_kind,
204 return static_cast<int>(a) <
static_cast<int>(b);
220 namespace refl = tvm::ffi::reflection;
Typed reference/view over any Expr whose ExprNode::ty is PrimType.
Definition: base_expr.h:354
Definition: exec_scope.h:211
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition: exec_scope.h:224
ScopeKind kind
scope identity; one of the closed ScopeKind values.
Definition: exec_scope.h:214
static void RegisterReflection()
Definition: exec_scope.h:219
TVM_FFI_DECLARE_OBJECT_INFO("tirx.ExecScope", ExecScopeNode, ffi::Object)
ffi::String name() const
Human-readable name derived from kind (for printing / errors).
Definition: exec_scope.h:217
Definition: exec_scope.h:228
ExecScope(ScopeKind kind)
Construct from a ScopeKind (canonical).
ExecScope(const ffi::String &name)
Construct from a name string (FATALs on unknown name).
Definition: exec_scope.h:233
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(ExecScope, ffi::ObjectRef, ExecScopeNode)
Definition: exec_scope.h:99
ffi::Array< PrimVar > def_ids
The ScopeId defined.
Definition: exec_scope.h:102
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:117
static void RegisterReflection()
Definition: exec_scope.h:124
ffi::Optional< ffi::Array< PrimExpr > > extents
The extents of the ScopeId.
Definition: exec_scope.h:115
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition: exec_scope.h:133
ffi::Optional< ffi::Array< PrimExpr > > preferred_extents
Optional preferred extents (cluster→cta only). Maps to cudaLaunchAttributePreferredClusterDimension (...
Definition: exec_scope.h:122
Definition: exec_scope.h:154
std::unordered_map< ScopeBinding, ScopeIdDef > ScopeIdSet
Definition: exec_scope.h:156
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:176
Mode
Verification mode.
Definition: exec_scope.h:167
bool Verify(const ffi::Array< ScopeIdDef > &defs, Mode mode=Mode::kStrict)
Verify the scope id definitions are well formed.
Definition: exec_scope.h:137
TVM_DEFINE_OBJECT_REF_COW_METHOD(ScopeIdDefNode)
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:145
ScopeIdDef(ffi::Array< PrimVar > def_ids, ffi::Optional< ffi::Array< PrimExpr >> extents, ScopeBinding scope, ffi::Optional< ffi::Array< PrimExpr >> preferred_extents=ffi::Optional< ffi::Array< PrimExpr >>(std::nullopt))
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:183
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:185
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:203
ScopeKind StringToScopeKind(const ffi::String &name)
Parse a string name to a ScopeKind. FATAL if unknown.
ScopeKind
The target execution scope kind of a tile primitive call.
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:79
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. kThread -> "thread").
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition: analyzer.h:40