tvm
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Enumerations | Functions
tvm::tirx Namespace Reference

Namespaces

namespace  attr
 Function specific attribute names.
 
namespace  op_attr
 
namespace  thread_scope_attr
 
namespace  tile
 
namespace  transform
 
namespace  type_attr
 

Classes

class  Axis
 
class  AxisObj
 
struct  CallFFIKernelAttr
 Launch metadata for call_ffi_kernel. More...
 
class  ComposeLayout
 
class  ComposeLayoutObj
 
class  Dependency
 Managed reference to DependencyObj. More...
 
class  DependencyObj
 A tuple (src, dst, kind) representing certain types of dependency. For example, (A, B, kRAW) means block B depends on block A, and the dependency kind is read-after-write, which means block B reads the result written by block A. More...
 
class  Function
 Managed reference to FunctionObj. More...
 
class  FunctionObj
 Primitive functions that contains TIR statements. More...
 
class  IndexMap
 
class  IndexMapObj
 Defines a mapping between two representations of indices into a tensor. More...
 
class  Iter
 
class  IterObj
 
class  Layout
 Managed reference to a tensor-program coordinate layout. More...
 
class  LayoutObj
 Base object for tensor-program coordinate layouts. More...
 
class  ObjectMutatorWithConstraintContext
 Native object mutation over one constraint-aware engine and variable remap. More...
 
class  ObjectVisitorWithConstraintContext
 Native object dispatch over one constraint-aware structural visitor. More...
 
class  SBijectiveLayout
 Bijective function mapping for data layout transformation. Given two SLayout, SBijectiveLayout build and store the mapping rules, provides API to transform N-dimention tensor from the source indices (i0, i1, .., im) to the destination indices (j0, j1, .., jm). More...
 
class  SBijectiveLayoutObj
 
class  SBlockDependenceInfo
 Managed reference to SBlockDependenceInfoObj. More...
 
class  SBlockDependenceInfoObj
 An object that helps build and query block level dependences using the 2 core objects SBlockScope and StmtSRef. More...
 
class  SBlockScope
 Managed reference to SBlockScopeObj. More...
 
class  SBlockScopeObj
 An object with 1-to-1 correspondence with each block reference in the sref tree. This data structure is used to track the producer-consumer dependencies between blocks. For example even leaf nodes have a scope node, even though they have no dependencies. More...
 
class  SLayout
 Managed reference to SLayoutObj. More...
 
class  SLayoutAxis
 
class  SLayoutObj
 SLayout is to describe how data is organized within an N-dimention tensor. It is composed of upper cases, lower cases and numbers, where upper case indicates a primal axis and the corresponding lower case with factor size indicates the subordinate axis. For example, NCHW16c can describe a 5-D tensor of [batch_size, channel, height, width, channel_block]. Here subordinate axis channel_block=16 is the factor size of the primal axis C (channel). SLayout for scalar is defined, while both its name and axes have size 0. More...
 
class  SRefTreeCreator
 
class  StmtExprMutator
 Mutator that recursively mutates stmts and exprs on them. More...
 
class  StmtExprMutatorWithConstraintContext
 Native virtual mutation hooks over one structural constraint engine. More...
 
class  StmtExprVisitor
 Native visitor for TIRx statements and their expression operands. More...
 
class  StmtExprVisitorWithConstraintContext
 Native virtual node hooks using one constraint-aware structural visitor. Allocate with ffi::make_object<Derived>(). Override Visit_ for a known node or Visit for general dispatch. Defaults share matching native expression bodies and delegate scope-sensitive nodes to structural constraint hooks. A hook owns its descent; calling the qualified parent hook runs it once with the same context. Unknown types use structural fallback, which can reach specialized descendants. More...
 
class  StmtFunctor
 Type-dispatched statement functor with a caller-selected signature. More...
 
class  StmtFunctor< R(const Stmt &, Args...)>
 
class  StmtSRef
 Managed reference to StmtSRefObj. More...
 
class  StmtSRefObj
 An object that refers to schedulable elements (block/for-loop) in TensorIR, aka "sref". More...
 
class  StructuralMutatorWithConstraintContext
 Owning reference to the specialized mutator. More...
 
class  StructuralMutatorWithConstraintContextObj
 Mutates values using their structural mutation behavior while maintaining the constraint context relevant to each callback. Constraints use the resulting expressions and bindings. This semantic base contains only context state; concrete structural engines own the identity-remap environment. More...
 
class  StructuralVisitorWithConstraintContext
 Owning reference to the active specialized visitor. More...
 
class  StructuralVisitorWithConstraintContextObj
 Visits values using their structural visit behavior while maintaining the constraint context relevant to each callback. More...
 
class  TensorAxisGraphExtractor
 Construct an axis group graph from a tirx::Function. Two tensor axis are connected if they are accessed by the same index. More...
 
class  TensorAxisHash
 
class  TensorMapType
 Managed reference to TensorMapTypeObj. More...
 
class  TensorMapTypeObj
 The type of tensor map. More...
 
class  TensorType
 Managed reference to TensorTypeObj. More...
 
class  TensorTypeObj
 Structural type of a TIRx tensor variable. More...
 
class  TensorVar
 Checked zero-state view over an ordinary VarObj with TensorType. More...
 
class  ThreadScope
 Canonical thread-scope identity, named as backend.scope. More...
 
class  ThreadScopeObj
 
class  TileLayout
 
class  TileLayoutObj
 

Typedefs

using TIRVarAxis = std::pair< Var, int >
 
using TensorAxis = std::pair< TensorVar, int >
 
using FAxisFuser = ffi::TypedFunction< ffi::Optional< Iter >(ThreadScope, ThreadScope, Iter)>
 
using FLowerIntrinsic = ffi::TypedFunction< PrimExpr(PrimExpr, Target)>
 The intrinsic lowering function for given op, receiving its compilation target.
 
using FLegalize = ffi::TypedFunction< PrimExpr(PrimExpr, Target)>
 The legalization function for given tirx op, receiving its compilation target.
 
using FStructuralMutateWithConstraintContext = ffi::reflection::NativeFunctionView< ffi::UnchangedOr< ffi::Any >(StructuralMutatorWithConstraintContextObj *, ffi::AnyView)>
 Sparse constraint mutation hook, sharing the structural mutation ABI contract.
 
using FStructuralVisitWithConstraintContext = ffi::reflection::NativeFunctionView< ffi::Optional< ffi::VisitInterrupt >(StructuralVisitorWithConstraintContextObj *, ffi::AnyView)>
 Sparse hook with the same result/error contract as FStructuralVisit.
 

Enumerations

enum class  DepKind : int32_t { kRAW = 0 , kWAW = 1 , kWAR = 2 , kOpaque = 3 }
 Type of dependency. Right now we have 4 types of dependencies 1) Read-after-write (kRAW) 2) Write-after-write (kWAW) 3) Write-after-read (kWAR) 4) Opaque dependency (kOpaque) More...
 
enum  TVMStructFieldKind : int {
  kDLTensorAddr , kDLTensorData , kDLTensorShape , kDLTensorStrides ,
  kDLTensorNDim , kDLTensorTypeCode , kDLTensorTypeBits , kDLTensorTypeLanes ,
  kDLTensorByteOffset , kDLTensorDeviceId , kDLTensorDeviceType , kDLTensorKindBound_ ,
  kTVMValueContent , kTVMFFIAnyTypeIndex , kTVMFFIAnyZeroPadding , kTVMFFIAnyUnionValue ,
  kTVMValueKindBound_ , kInt64ArrayElem
}
 

Functions

ffi::Optional< Var > GetShardingVarFromIndex (PrimExpr index, ffi::Map< Var, Range > var_range, const sym::Analyzer &analyzer)
 Suppose we want to shard a tensor along a specific dimension, we need to know how to rewrite the access index of the tensor. To make it simple, we only support the case that the access can be rewritten by changing the extent of an iter var.
 
ffi::Array< ffi::Array< TensorRegion > > GetSBlockAccessRegion (const s_tir::SBlock &block, const ffi::Map< Var, TensorVar > &tensor_var_map)
 Auto detect the block access region according to its body stmt It will detect the access region as an array in order of appearance in AST.
 
ffi::Array< ffi::Array< TensorRegion > > GetSBlockReadWriteRegion (const s_tir::SBlock &block, const ffi::Map< Var, TensorVar > &tensor_var_map)
 Auto detect the block read/write region according to its body stmt. An opaque access will be counted as both a read and a write access.
 
ffi::Map< TensorVar, ffi::Optional< Stmt > > DetectTensorAccessLCA (const Function &func)
 Detect the lowest common ancestor(LCA) of tensor access, including both high-level access(TensorLoad, TensorStore) and low-level access(Load, Store and opaque access). The LCA may be a For loop or a Block.
 
const s_tir::SBlockObj * FindAnchorBlock (const IRModule &mod)
 Find the "anchor block" of the given module. We define the anchor block to be the block with (1) an init statement and (2) having the biggest flops count. The latter condition is only used when there are multiple blocks with an init statement. For example, if the input module is conv2d + fused spatial blocks, conv2d is the anchor block. The input module may not contain more than one such block. For example, a module having two conv2d is not allowed as an input. However, a module created from winograd convolution has multiple blocks with an init statement (input transform, batched GEMM, and output transform). We use the second condition, the flops count, to determine that the batched GEMM block is the anchor block.
 
void SetSeqIndex (std::unordered_map< const StmtObj *, StmtSRef > &stmt2ref, const Stmt &stmt, int seq_index, bool include_loops=true)
 Set the StmtSRefObj::seq_index field for stmt.
 
void SetSeqIndexInChildren (std::unordered_map< const StmtObj *, StmtSRef > &stmt2ref, const SeqStmtObj *seq_stmt, bool include_loops=true)
 Update seq_index of the children of a SeqStmt.
 
TVM_TIRX_DLL ffi::Array< PrimExpr > DetectLinearEquation (const PrimExpr &e, const ffi::Array< PrimVar > &vars)
 Detect if e can be rewritten as e = sum_{i=0}^{n-1} var[i] * coeff[i] + coeff[n] Where coeff[i] and base are invariant of var[j] for all i and j.
 
TVM_TIRX_DLL ffi::Array< ffi::Optional< PrimExpr > > DetectClipBound (const PrimExpr &e, const ffi::Array< PrimVar > &vars)
 Detect if expression corresponds to clip bound of the vars.
 
TVM_TIRX_DLL bool VerifyMemory (const Function &func)
 Verify if memory accesses are legal for a specific target device type.
 
TVM_TIRX_DLL size_t CalculateExprComplexity (const PrimExpr &expr)
 Calculate the expression complexity based on number of symbols it contains.
 
TVM_TIRX_DLL bool CheckWellFormed (const Function &func, bool assert_mode=true)
 Check whether a TIRx function is well formed.
 
TVM_TIRX_DLL bool CheckWellFormed (const IRModule &mod, bool assert_mode=true)
 Check whether a TIRx module is well formed.
 
TVM_TIRX_DLL const FunctionObj * FindEntryFunc (const IRModule &mod, GlobalVar *result_g_var)
 Find the entry function of the given IRModule, i.e, functions marked by tirx::attr::kIsEntryFunc.name, whose name is main or being the only Function.
 
bool operator== (const TensorVar &lhs, const TensorVar &rhs)
 
bool operator!= (const TensorVar &lhs, const TensorVar &rhs)
 
TVM_TIRX_DLL Function RenewDef (Function func)
 Renew variable definitions and remap their uses in a function.
 
TVM_TIRX_DLL const Op & call_extern_op ()
 Call an external C function with argument and result types supplied by the caller.
 
TVM_TIRX_DLL const Op & call_pure_extern_op ()
 Call a pure external C function with types supplied by the caller.
 
TVM_TIRX_DLL const Op & call_llvm_intrin_op ()
 Invoke an LLVM intrinsic.
 
TVM_TIRX_DLL const Op & call_llvm_pure_intrin_op ()
 Invoke a pure LLVM intrinsic.
 
TVM_TIRX_DLL const Op & call_spirv_pure_glsl450_op ()
 Invoke a pure GLSL450 SPIR-V intrinsic.
 
TVM_TIRX_DLL const Op & abi_field_get_op ()
 Read a runtime structure field.
 
TVM_TIRX_DLL const Op & abi_field_set_op ()
 Write a runtime structure field.
 
TVM_TIRX_DLL const Op & throw_last_error_op ()
 Raise the last runtime error.
 
TVM_TIRX_DLL const Op & stack_alloca_op ()
 Allocate stack storage for runtime values.
 
TVM_TIRX_DLL const Op & stack_make_shape_op ()
 Construct a stack-allocated shape tuple.
 
TVM_TIRX_DLL const Op & stack_make_dltensor_op ()
 Construct a stack-allocated DLTensor.
 
TVM_TIRX_DLL const Op & call_packed_op ()
 Invoke a runtime packed function.
 
TVM_TIRX_DLL const Op & call_ffi_kernel_op ()
 Launch a kernel using the packed-function argument convention.
 
TVM_TIRX_DLL const Op & call_cpacked_op ()
 Invoke a C packed function.
 
TVM_TIRX_DLL const Op & call_packed_lowered_op ()
 Invoke a packed function using an explicit argument stack.
 
TVM_TIRX_DLL const Op & call_cpacked_lowered_op ()
 Invoke a C packed function using an explicit argument stack.
 
TVM_TIRX_DLL const Op & assume_always_op ()
 Assert a predicate remains true throughout its containing scope, including mutations.
 
TVM_TIRX_DLL const Op & kernel_replace_point_op ()
 Marker where a transform should replace generated kernel initialization.
 
TVM_TIRX_DLL const Op & ignore_loop_partition_op ()
 Annotate a predicate not be considered as target condition of loop partition.
 
TVM_TIRX_DLL const Op & cpu_parallel_barrier_op ()
 Synchronize all workers in the current CPU parallel launch.
 
TVM_TIRX_DLL const Op & gpu_thread_return_op ()
 Return from a GPU thread without returning a function value.
 
TVM_TIRX_DLL PrimExpr gpu_thread_return (Location loc=UnknownLoc())
 Return from a GPU thread without returning a function value.
 
TVM_TIRX_DLL const Op & gpu_thread_filter_op ()
 Mark an opaque predicate that selects one thread on an active-set axis.
 
TVM_TIRX_DLL const Op & gpu_active_thread_selector_op ()
 Analysis-only active-thread selector.
 
TVM_TIRX_DLL const Op & gpu_thread_invariant_op ()
 Mark a condition to be thread invariant.
 
TVM_TIRX_DLL const Op & gpu_storage_sync_op ()
 Synchronize accesses in a storage scope.
 
TVM_TIRX_DLL const Op & gpu_warp_shuffle_op ()
 Read the value from a selected lane in the warp.
 
TVM_TIRX_DLL const Op & gpu_warp_shuffle_up_op ()
 Read the value from a lower lane in the warp.
 
TVM_TIRX_DLL const Op & gpu_warp_shuffle_down_op ()
 Read the value from a higher lane in the warp.
 
TVM_TIRX_DLL const Op & gpu_warp_shuffle_xor_op ()
 Read the value from the lane selected by an XOR mask.
 
TVM_TIRX_DLL const Op & gpu_warp_activemask_op ()
 Return the bit mask of active lanes in the warp.
 
TVM_TIRX_DLL const Op & gpu_thread_allreduce_op ()
 Cross-thread reduction with an explicit typed combiner and identities.
 
TVM_TIRX_DLL const Op & gpu_dp4a_op ()
 Dot product of two int8x4 vectors and add an optional accumulator.
 
TVM_TIRX_DLL PrimExpr logaddexp (PrimExpr a, PrimExpr b, Location loc=UnknownLoc())
 Compute log(exp(a) + exp(b)).
 
 TVM_DEFINE_INT_OP_CONST_VAL_OVERLOAD_SPANNED (logaddexp)
 
TVM_TIRX_DLL PrimExpr fast_erf_float_expr (PrimExpr arg, int bits)
 Fast_erf_float expression from Eigen.
 
TVM_TIRX_DLL const Op & alloc_tensor_op ()
 Allocate a tensor with exactly one TensorType in ty_args.
 
TVM_TIRX_DLL const Op & decl_tensor_op ()
 Declare a tensor view with exactly one TensorType in ty_args.
 
TVM_TIRX_DLL const Op & reinterpret_op ()
 Reinterpret the bits of a value as an explicit primitive or pointer type.
 
TVM_TIRX_DLL Expr reinterpret (Type target_ty, Expr value, Location loc=UnknownLoc())
 perform reinterpret cast value to type.
 
PrimExpr reinterpret (PrimType t, PrimExpr value, Location loc=UnknownLoc())
 
Expr ConstHandle (int64_t value, Location loc=UnknownLoc())
 Construct an opaque pointer from its integer payload.
 
TVM_TIRX_DLL const Op & address_of_op ()
 Return the address of a tensor element or addressable variable.
 
TVM_TIRX_DLL const Op & isnullptr_op ()
 Test whether a pointer is null.
 
TVM_TIRX_DLL const Op & prefetch_op ()
 Prefetch a memory address.
 
TVM_TIRX_DLL const Op & ptr_byte_offset_op ()
 Cast a handle to a typed pointer after adding a byte offset.
 
TVM_TIRX_DLL const Op & static_handle_op ()
 Create a function local static handle that iniitalizes to nullptr.
 
TVM_TIRX_DLL const Op & handle_add_byte_offset_op ()
 Add a byte offset to an opaque pointer.
 
TVM_TIRX_DLL const Op & atomic_add_op ()
 atomic add instruction, corresponding e.g. to atomicAdd in CUDA.
 
TVM_TIRX_DLL const Op & assume_aligned_op ()
 Assume a tensor's base address has the given constant byte alignment.
 
TVM_TIRX_DLL const Op & undef_op ()
 Returns an initialized but arbitrary value.
 
TVM_TIRX_DLL const Op & masked_load_op ()
 Masked tensor load.
 
TVM_TIRX_DLL const Op & masked_store_op ()
 Masked tensor store.
 
TVM_TIRX_DLL const Op & tensor_data_ptr_op ()
 Project the physical pointer associated with a TensorVar definition.
 
TVM_TIRX_DLL const Op & launch_thread_op ()
 Thread launch region: operands are a nonempty StringImm tag and a scalar signed or unsigned integer extent wider than one bit. The sole body parameter is a fresh thread-index PrimVar matching the extent type. Tags starting with vthread denote virtual threads. There are no attrs or results.
 
TVM_TIRX_DLL const Op & device_entry_op ()
 Mark a user-facing device entry containing device scope definitions. Operands are optional launch configuration values, each named by the cuda.launch_fields attribute; there are no body parameters or results.
 
TVM_TIRX_DLL const Op & device_context_op ()
 Supply lexical device context for allocation and packed-call lowering. Operands are integer device type and device ID; there are no body parameters, attributes or results. The region does not change the active runtime device.
 
TVM_TIRX_DLL const Op & compute_scope_op ()
 Outline the body as a CPU compute helper named by a StringImm operand. There are no body parameters, attributes or results.
 
TVM_TIRX_DLL const Op & parallel_launch_op ()
 Launch a CPU worker team around parallel loops and team barriers. Takes no operands, body parameters, attributes or results.
 
TVM_TIRX_DLL const Op & vector_high_op ()
 Get the high level half of the vector.
 
TVM_TIRX_DLL const Op & vector_low_op ()
 Get the low-level half of the vector.
 
TVM_TIRX_DLL const Op & vector_combine_op ()
 Concat two vectors.
 
TVM_TIRX_DLL const Op & get_active_lane_mask_op ()
 Calculate a predicate mask given an upper bound (limit) and a current value (base).
 
bool IsNoOp (const Stmt &stmt)
 Whether stmt is undefined, an integer Evaluate, or an empty sequence.
 
TVM_TIRX_DLL Stmt SubstituteWithDataTypeLegalization (Stmt stmt, ffi::TypedFunction< ffi::Optional< PrimExpr >(const Var &)> vmap)
 Substitute the var specified by vmap and legalize data types after substitution.
 
TVM_TIRX_DLL PrimExpr SubstituteWithDataTypeLegalization (PrimExpr expr, ffi::TypedFunction< ffi::Optional< PrimExpr >(const Var &)> vmap)
 Substitute the var specified by vmap and legalize data types after substitution.
 
template<typename Node , typename = std::enable_if_t<std::is_base_of_v<StmtObj, Node>>>
bool ContainsNode (const Stmt &stmt)
 Check if the statement contains the specified node type.
 
template<ffi::WalkOrder order, typename... Callbacks>
ffi::Expected< ffi::Any > StructuralMapWithConstraintContextExpected (ffi::Any root, Callbacks &&... callbacks) noexcept
 Expected form of StructuralMapWithConstraintContext.
 
template<ffi::WalkOrder order, typename... Callbacks>
ffi::Any StructuralMapWithConstraintContext (ffi::Any root, Callbacks &&... callbacks)
 Map with (value, const sym::ConstraintContext& [, def_region_kind]) callbacks. Callbacks return a replacement, Unchanged, or Expected thereof; they must not mutate their input. Pre/post behavior is that of ffi::StructuralMap. Pass std::move(root) to permit reuse; shared roots still copy. The position is restored before a scoped node's post callback. See the object documentation for timing.
 
template<typename... Callbacks>
ffi::Expected< ffi::Any > StructuralMutateWithConstraintContextExpected (ffi::Any root, Callbacks &&... callbacks) noexcept
 Expected form of StructuralMutateWithConstraintContext.
 
template<typename... Callbacks>
ffi::Any StructuralMutateWithConstraintContext (ffi::Any root, Callbacks &&... callbacks)
 Mutate with (value, StructuralMutatorWithConstraintContextObj* [, InplaceMode]). The first matching callback owns descent, exactly as in ffi::StructuralMutate. Return a replacement/Unchanged or Expected thereof. Delegate to mutator->DefaultMutateExpected(value, mode) for constraint-aware descent; recurse with MutateExpected(child, mode). Both use the same context and remap.
 
template<ffi::WalkOrder order, typename... Callbacks>
ffi::Expected< ffi::Optional< ffi::VisitInterrupt > > StructuralWalkWithConstraintContextExpected (ffi::AnyView root, Callbacks &&... callbacks) noexcept
 Expected form of StructuralWalkWithConstraintContext.
 
template<ffi::WalkOrder order, typename... Callbacks>
ffi::Optional< ffi::VisitInterrupt > StructuralWalkWithConstraintContext (ffi::AnyView root, Callbacks &&... callbacks)
 Walk every occurrence with (value, const sym::ConstraintContext&) callbacks. A trailing TVMFFIDefRegionKind is optional, as in ffi::StructuralWalk. Return Expected<WalkResult>; pre-order Skip prunes descent and Interrupt stops the walk. Post callbacks see a scoped node after its internal scope is restored. Sequence traversal visits its statements directly in order; lazy calls visit their arguments directly so each branch has its own scope. These two hooks do not dispatch a callback for their intermediate Array containers.
 
template<typename... Callbacks>
ffi::Expected< ffi::Optional< ffi::VisitInterrupt > > StructuralVisitWithConstraintContextExpected (ffi::AnyView root, Callbacks &&... callbacks) noexcept
 Expected form of StructuralVisitWithConstraintContext.
 
template<typename... Callbacks>
ffi::Optional< ffi::VisitInterrupt > StructuralVisitWithConstraintContext (ffi::AnyView root, Callbacks &&... callbacks)
 Visit with callbacks (value, StructuralVisitorWithConstraintContextObj*). The first matching callback owns descent. Return completion, interrupt, or error as in ffi::StructuralVisit. Recurse with visitor->VisitExpected(child) or visitor->DefaultVisitExpected(value); constraints is the active context handle.
 
TVM_TIRX_DLL bool ScopeHigher (const ThreadScope &a, const ThreadScope &b)
 Compare explicit ranks within one backend's hierarchy.
 
std::ostream & operator<< (std::ostream &os, const ThreadScope &scope)
 
PrimType DefaultIndexType ()
 if TVM_INDEX_DEFAULT_I64 is set, return int64, otherwise return int32
 
ffi::Optional< ffi::Tuple< ffi::Array< PrimExpr >, ffi::Array< PrimExpr >, PrimExpr > > MatchShapeStridePattern (const TensorType &tensor)
 Match a tensor's shape-aligned strided memory representation.
 

Typedef Documentation

◆ FAxisFuser

using tvm::tirx::FAxisFuser = typedef ffi::TypedFunction<ffi::Optional<Iter>(ThreadScope, ThreadScope, Iter)>

◆ FLegalize

using tvm::tirx::FLegalize = typedef ffi::TypedFunction<PrimExpr(PrimExpr, Target)>

The legalization function for given tirx op, receiving its compilation target.

◆ FLowerIntrinsic

using tvm::tirx::FLowerIntrinsic = typedef ffi::TypedFunction<PrimExpr(PrimExpr, Target)>

The intrinsic lowering function for given op, receiving its compilation target.

◆ FStructuralMutateWithConstraintContext

using tvm::tirx::FStructuralMutateWithConstraintContext = typedef ffi::reflection::NativeFunctionView<ffi::UnchangedOr<ffi::Any>( StructuralMutatorWithConstraintContextObj*, ffi::AnyView)>

Sparse constraint mutation hook, sharing the structural mutation ABI contract.

◆ FStructuralVisitWithConstraintContext

using tvm::tirx::FStructuralVisitWithConstraintContext = typedef ffi::reflection::NativeFunctionView<ffi::Optional<ffi::VisitInterrupt>( StructuralVisitorWithConstraintContextObj*, ffi::AnyView)>

Sparse hook with the same result/error contract as FStructuralVisit.

◆ TensorAxis

using tvm::tirx::TensorAxis = typedef std::pair<TensorVar, int>

◆ TIRVarAxis

using tvm::tirx::TIRVarAxis = typedef std::pair<Var, int>

Enumeration Type Documentation

◆ DepKind

enum class tvm::tirx::DepKind : int32_t
strong

Type of dependency. Right now we have 4 types of dependencies 1) Read-after-write (kRAW) 2) Write-after-write (kWAW) 3) Write-after-read (kWAR) 4) Opaque dependency (kOpaque)

Enumerator
kRAW 
kWAW 
kWAR 
kOpaque 

◆ TVMStructFieldKind

Enumerator
kDLTensorAddr 
kDLTensorData 
kDLTensorShape 
kDLTensorStrides 
kDLTensorNDim 
kDLTensorTypeCode 
kDLTensorTypeBits 
kDLTensorTypeLanes 
kDLTensorByteOffset 
kDLTensorDeviceId 
kDLTensorDeviceType 
kDLTensorKindBound_ 
kTVMValueContent 
kTVMFFIAnyTypeIndex 
kTVMFFIAnyZeroPadding 
kTVMFFIAnyUnionValue 
kTVMValueKindBound_ 
kInt64ArrayElem 

Function Documentation

◆ abi_field_get_op()

TVM_TIRX_DLL const Op & tvm::tirx::abi_field_get_op ( )

Read a runtime structure field.

Arguments, in order:

  • args[0]: arr, The array.
  • args[1]: index, The index.
  • args[2]: field, The field index.

◆ abi_field_set_op()

TVM_TIRX_DLL const Op & tvm::tirx::abi_field_set_op ( )

Write a runtime structure field.

Arguments, in order:

  • args[0]: arr, The array.
  • args[1]: index, The index.
  • args[2]: field, The field index.
  • args[3]: value, The value to use.

◆ address_of_op()

TVM_TIRX_DLL const Op & tvm::tirx::address_of_op ( )

Return the address of a tensor element or addressable variable.

Arguments, in order:

  • args[0]: obj, The referenced object.

◆ alloc_tensor_op()

TVM_TIRX_DLL const Op & tvm::tirx::alloc_tensor_op ( )

Allocate a tensor with exactly one TensorType in ty_args.

The optional args[0] is a Tuple of producer-owned placement coordinates. DictAttrs directly holds allocation annotations. The TensorType owns all shape, dtype, storage scope and access/layout metadata, and is the result type.

◆ assume_aligned_op()

TVM_TIRX_DLL const Op & tvm::tirx::assume_aligned_op ( )

Assume a tensor's base address has the given constant byte alignment.

This leaf operation carries a compiler fact, without checking or changing the address. Alignment must be a power of two between 1 and 2^27 bytes.

◆ assume_always_op()

TVM_TIRX_DLL const Op & tvm::tirx::assume_always_op ( )

Assert a predicate remains true throughout its containing scope, including mutations.

This void annotation records a scope-wide guarantee without a runtime check. args[0] is the boolean predicate. Constraint traversal records it with assume_always=true.

◆ atomic_add_op()

TVM_TIRX_DLL const Op & tvm::tirx::atomic_add_op ( )

atomic add instruction, corresponding e.g. to atomicAdd in CUDA.

Arguments, in order:

  • args[0]: ptr, The pointer.
  • args[1]: value, The value to use.

◆ CalculateExprComplexity()

TVM_TIRX_DLL size_t tvm::tirx::CalculateExprComplexity ( const PrimExpr &  expr)

Calculate the expression complexity based on number of symbols it contains.

Parameters
exprThe expr to be calculated.

◆ call_cpacked_lowered_op()

TVM_TIRX_DLL const Op & tvm::tirx::call_cpacked_lowered_op ( )

Invoke a C packed function using an explicit argument stack.

Arguments, in order:

  • args[0]: func_name, The function name.
  • args[1]: args_stack, The argument stack.
  • args[2]: begin, The start index.
  • args[3]: end, The end index.

◆ call_cpacked_op()

TVM_TIRX_DLL const Op & tvm::tirx::call_cpacked_op ( )

Invoke a C packed function.

Arguments, in order:

  • args[0]: func_name, The function name.
  • args[1...]: args, trailing Expr operands.

◆ call_extern_op()

TVM_TIRX_DLL const Op & tvm::tirx::call_extern_op ( )

Call an external C function with argument and result types supplied by the caller.

Arguments, in order:

  • args[0]: func_name, The function name.
  • args[1...]: args, trailing Expr operands.

◆ call_ffi_kernel_op()

TVM_TIRX_DLL const Op & tvm::tirx::call_ffi_kernel_op ( )

Launch a kernel using the packed-function argument convention.

Arguments are the kernel symbol, kernel operands, then launch values. CallFFIKernelAttr::launch_params describes the launch-value suffix. Host backends may consume this call directly or lower it to call_packed.

◆ call_llvm_intrin_op()

TVM_TIRX_DLL const Op & tvm::tirx::call_llvm_intrin_op ( )

Invoke an LLVM intrinsic.

Arguments, in order:

  • args[0]: intrin_id, The intrinsic identifier.
  • args[1...]: args, trailing Expr operands.

◆ call_llvm_pure_intrin_op()

TVM_TIRX_DLL const Op & tvm::tirx::call_llvm_pure_intrin_op ( )

Invoke a pure LLVM intrinsic.

Arguments, in order:

  • args[0]: intrin_id, The intrinsic identifier.
  • args[1...]: args, trailing Expr operands.

◆ call_packed_lowered_op()

TVM_TIRX_DLL const Op & tvm::tirx::call_packed_lowered_op ( )

Invoke a packed function using an explicit argument stack.

Arguments, in order:

  • args[0]: func_name, The function name.
  • args[1]: args_stack, The argument stack.
  • args[2]: begin, The start index.
  • args[3]: end, The end index.

◆ call_packed_op()

TVM_TIRX_DLL const Op & tvm::tirx::call_packed_op ( )

Invoke a runtime packed function.

Arguments, in order:

  • args[0]: func_name, The function name.
  • args[1...]: args, trailing Expr operands.

◆ call_pure_extern_op()

TVM_TIRX_DLL const Op & tvm::tirx::call_pure_extern_op ( )

Call a pure external C function with types supplied by the caller.

Arguments, in order:

  • args[0]: func_name, The function name.
  • args[1...]: args, trailing Expr operands.

◆ call_spirv_pure_glsl450_op()

TVM_TIRX_DLL const Op & tvm::tirx::call_spirv_pure_glsl450_op ( )

Invoke a pure GLSL450 SPIR-V intrinsic.

Arguments, in order:

  • args[0]: intrin_id, The intrinsic identifier.
  • args[1...]: args, trailing PrimExpr operands.

◆ CheckWellFormed() [1/2]

TVM_TIRX_DLL bool tvm::tirx::CheckWellFormed ( const Function &  func,
bool  assert_mode = true 
)

Check whether a TIRx function is well formed.

Parameters
funcThe Function to be verified.
assert_modeWhether to raise on invalid IR (default: true).
Returns
True for valid IR; false for invalid IR when assert_mode is false.

◆ CheckWellFormed() [2/2]

TVM_TIRX_DLL bool tvm::tirx::CheckWellFormed ( const IRModule &  mod,
bool  assert_mode = true 
)

Check whether a TIRx module is well formed.

Parameters
modThe IRModule to be verified.
assert_modeWhether to raise on invalid IR (default: true).
Returns
True for valid IR; false for invalid IR when assert_mode is false.

◆ compute_scope_op()

TVM_TIRX_DLL const Op & tvm::tirx::compute_scope_op ( )

Outline the body as a CPU compute helper named by a StringImm operand. There are no body parameters, attributes or results.

◆ ConstHandle()

Expr tvm::tirx::ConstHandle ( int64_t  value,
Location  loc = UnknownLoc() 
)
inline

Construct an opaque pointer from its integer payload.

◆ ContainsNode()

template<typename Node , typename = std::enable_if_t<std::is_base_of_v<StmtObj, Node>>>
bool tvm::tirx::ContainsNode ( const Stmt &  stmt)

Check if the statement contains the specified node type.

This utility potentially walks the entire statement, and should therefore not be used if it could otherwise be merged with another pass.

Parameters
stmtThe statement to be searched
Returns
Whether stmt contains Node

◆ cpu_parallel_barrier_op()

TVM_TIRX_DLL const Op & tvm::tirx::cpu_parallel_barrier_op ( )

Synchronize all workers in the current CPU parallel launch.

Every worker must reach this operation. It must be outside partitioned parallel loops, whose iteration counts can differ between workers.

◆ decl_tensor_op()

TVM_TIRX_DLL const Op & tvm::tirx::decl_tensor_op ( )

Declare a tensor view with exactly one TensorType in ty_args.

args[0] is the existing physical pointer backing the view. There are no attributes. The TensorType is the result type; no memory is allocated.

◆ DefaultIndexType()

PrimType tvm::tirx::DefaultIndexType ( )
inline

if TVM_INDEX_DEFAULT_I64 is set, return int64, otherwise return int32

◆ DetectClipBound()

TVM_TIRX_DLL ffi::Array< ffi::Optional< PrimExpr > > tvm::tirx::DetectClipBound ( const PrimExpr &  e,
const ffi::Array< PrimVar > &  vars 
)

Detect if expression corresponds to clip bound of the vars.

Parameters
eThe expression to be detected.
varsList of variables to be used in detection.
Returns
concat([min_value[i], max_value[i]]), None is returned if there is no min or max value return empty if the e does not match the pattern.

◆ DetectLinearEquation()

TVM_TIRX_DLL ffi::Array< PrimExpr > tvm::tirx::DetectLinearEquation ( const PrimExpr &  e,
const ffi::Array< PrimVar > &  vars 
)

Detect if e can be rewritten as e = sum_{i=0}^{n-1} var[i] * coeff[i] + coeff[n] Where coeff[i] and base are invariant of var[j] for all i and j.

Parameters
eThe expression to be detected.
varsList of variables to be used in detection.
Returns
[coeff[i]] if it is possible, empty array if it is not.

◆ DetectTensorAccessLCA()

ffi::Map< TensorVar, ffi::Optional< Stmt > > tvm::tirx::DetectTensorAccessLCA ( const Function &  func)

Detect the lowest common ancestor(LCA) of tensor access, including both high-level access(TensorLoad, TensorStore) and low-level access(Load, Store and opaque access). The LCA may be a For loop or a Block.

Parameters
funcThe Function to be detected.
Returns
The Map from tensor to the LCA of all access to it. The lca is function root if the return stmt is std::nullopt.

◆ device_context_op()

TVM_TIRX_DLL const Op & tvm::tirx::device_context_op ( )

Supply lexical device context for allocation and packed-call lowering. Operands are integer device type and device ID; there are no body parameters, attributes or results. The region does not change the active runtime device.

◆ device_entry_op()

TVM_TIRX_DLL const Op & tvm::tirx::device_entry_op ( )

Mark a user-facing device entry containing device scope definitions. Operands are optional launch configuration values, each named by the cuda.launch_fields attribute; there are no body parameters or results.

◆ fast_erf_float_expr()

TVM_TIRX_DLL PrimExpr tvm::tirx::fast_erf_float_expr ( PrimExpr  arg,
int  bits 
)

Fast_erf_float expression from Eigen.

Parameters
argThe input expression.
bitsThe number of bits in the type.
Returns
The constructed expression.

◆ FindAnchorBlock()

const s_tir::SBlockObj * tvm::tirx::FindAnchorBlock ( const IRModule &  mod)

Find the "anchor block" of the given module. We define the anchor block to be the block with (1) an init statement and (2) having the biggest flops count. The latter condition is only used when there are multiple blocks with an init statement. For example, if the input module is conv2d + fused spatial blocks, conv2d is the anchor block. The input module may not contain more than one such block. For example, a module having two conv2d is not allowed as an input. However, a module created from winograd convolution has multiple blocks with an init statement (input transform, batched GEMM, and output transform). We use the second condition, the flops count, to determine that the batched GEMM block is the anchor block.

Parameters
modThe input TIR module.
Returns
The anchor block if found, nullptr otherwise.

◆ FindEntryFunc()

TVM_TIRX_DLL const FunctionObj * tvm::tirx::FindEntryFunc ( const IRModule &  mod,
GlobalVar *  result_g_var 
)

Find the entry function of the given IRModule, i.e, functions marked by tirx::attr::kIsEntryFunc.name, whose name is main or being the only Function.

Parameters
modThe IRModule to find the entry function.
result_g_varThe result GlobalVar of the entry function.
Returns
The entry function.

◆ get_active_lane_mask_op()

TVM_TIRX_DLL const Op & tvm::tirx::get_active_lane_mask_op ( )

Calculate a predicate mask given an upper bound (limit) and a current value (base).

Arguments, in order:

  • args[0]: base, The base value.
  • args[1]: limit, The limit value.

◆ GetSBlockAccessRegion()

ffi::Array< ffi::Array< TensorRegion > > tvm::tirx::GetSBlockAccessRegion ( const s_tir::SBlock &  block,
const ffi::Map< Var, TensorVar > &  tensor_var_map 
)

Auto detect the block access region according to its body stmt It will detect the access region as an array in order of appearance in AST.

Parameters
blockThe block to be detected
tensor_var_mapThe outside tensors which may be accessed the block. It is a map from tensor var to the tensor.
Returns
Array of access regions. There are three arrays of TensorRegion:
  • first: read regions
  • second: write regions
  • third: opaque regions

◆ GetSBlockReadWriteRegion()

ffi::Array< ffi::Array< TensorRegion > > tvm::tirx::GetSBlockReadWriteRegion ( const s_tir::SBlock &  block,
const ffi::Map< Var, TensorVar > &  tensor_var_map 
)

Auto detect the block read/write region according to its body stmt. An opaque access will be counted as both a read and a write access.

Parameters
blockThe block to be detected
tensor_var_mapThe outside tensors which may be accessed the block. It is a map from tensor var to the tensor
Returns
An array only consisting of the read regions and write regions of the input block

◆ GetShardingVarFromIndex()

ffi::Optional< Var > tvm::tirx::GetShardingVarFromIndex ( PrimExpr  index,
ffi::Map< Var, Range >  var_range,
const sym::Analyzer &  analyzer 
)

Suppose we want to shard a tensor along a specific dimension, we need to know how to rewrite the access index of the tensor. To make it simple, we only support the case that the access can be rewritten by changing the extent of an iter var.

Parameters
indexThe access index
var_rangeThe range of each iter var
analyzerThe analyzer
Returns
The iter var whose extent to be changed

◆ gpu_active_thread_selector_op()

TVM_TIRX_DLL const Op & tvm::tirx::gpu_active_thread_selector_op ( )

Analysis-only active-thread selector.

gpu_active_thread_selector(var, pred) denotes the unique value of var in the current active domain for which pred is true. It is used only inside ExecContext/DispatchContext metadata, for predicates such as ptx.elect_sync() whose selected lane cannot be inferred structurally.

◆ gpu_dp4a_op()

TVM_TIRX_DLL const Op & tvm::tirx::gpu_dp4a_op ( )

Dot product of two int8x4 vectors and add an optional accumulator.

Arguments, in order:

  • args[0]: vec1, The first input vector.
  • args[1]: vec2, The second input vector.
  • args[2]: acc, The accumulator.

◆ gpu_storage_sync_op()

TVM_TIRX_DLL const Op & tvm::tirx::gpu_storage_sync_op ( )

Synchronize accesses in a storage scope.

Arguments, in order:

  • args[0]: storage_scope, The storage scope.

◆ gpu_thread_allreduce_op()

TVM_TIRX_DLL const Op & tvm::tirx::gpu_thread_allreduce_op ( )

Cross-thread reduction with an explicit typed combiner and identities.

void gpu_thread_allreduce(LambdaExpr combine, Expr identity, Expr values, PrimExpr predicate, Expr destinations, Expr thread_axes);

For N values, combine binds lhs[0:N] followed by rhs[0:N] and returns an N-element Tuple, or a scalar when N is one. Identity, values, destinations and thread_axes may each be a scalar or an explicit Tuple of fields. Each value, identity, pair of parameters and result have the same primitive type. Inactive inputs are replaced by their identities. Destinations are N tensor loads at index zero of one-element result temporaries (optionally cast for boolean storage). Each result temporary must be accessed only at index zero. Thread axes are reduction thread variables or zero for simplified unit axes. Other thread indices remain fixed. The operation writes the reduced values to the destination tensors and returns void.

◆ gpu_thread_filter_op()

TVM_TIRX_DLL const Op & tvm::tirx::gpu_thread_filter_op ( )

Mark an opaque predicate that selects one thread on an active-set axis.

Arguments, in order:

  • args[0]: var, The CUDA-index-bound thread-axis variable.
  • args[1]: pred, The runtime predicate used as an If condition. Canonical thread predicates can be used directly without this wrapper.

◆ gpu_thread_invariant_op()

TVM_TIRX_DLL const Op & tvm::tirx::gpu_thread_invariant_op ( )

Mark a condition to be thread invariant.

Arguments, in order:

  • args[0]: cond, The condition.

◆ gpu_thread_return()

TVM_TIRX_DLL PrimExpr tvm::tirx::gpu_thread_return ( Location  loc = UnknownLoc())

Return from a GPU thread without returning a function value.

Parameters
locThe location of this operation in the source.
Returns
The thread return expression.

◆ gpu_thread_return_op()

TVM_TIRX_DLL const Op & tvm::tirx::gpu_thread_return_op ( )

Return from a GPU thread without returning a function value.

◆ gpu_warp_activemask_op()

TVM_TIRX_DLL const Op & tvm::tirx::gpu_warp_activemask_op ( )

Return the bit mask of active lanes in the warp.

◆ gpu_warp_shuffle_down_op()

TVM_TIRX_DLL const Op & tvm::tirx::gpu_warp_shuffle_down_op ( )

Read the value from a higher lane in the warp.

Arguments, in order:

  • args[0]: mask, The mask.
  • args[1]: value, The value to use.
  • args[2]: offset, The offset.
  • args[3]: width, The width.
  • args[4]: warp_size, The number of threads per warp.

◆ gpu_warp_shuffle_op()

TVM_TIRX_DLL const Op & tvm::tirx::gpu_warp_shuffle_op ( )

Read the value from a selected lane in the warp.

Arguments, in order:

  • args[0]: mask, The mask.
  • args[1]: value, The value to use.
  • args[2]: warp_id, The warp identifier.
  • args[3]: width, The width.
  • args[4]: warp_size, The number of threads per warp.

◆ gpu_warp_shuffle_up_op()

TVM_TIRX_DLL const Op & tvm::tirx::gpu_warp_shuffle_up_op ( )

Read the value from a lower lane in the warp.

Arguments, in order:

  • args[0]: mask, The mask.
  • args[1]: value, The value to use.
  • args[2]: offset, The offset.
  • args[3]: width, The width.
  • args[4]: warp_size, The number of threads per warp.

◆ gpu_warp_shuffle_xor_op()

TVM_TIRX_DLL const Op & tvm::tirx::gpu_warp_shuffle_xor_op ( )

Read the value from the lane selected by an XOR mask.

Arguments, in order:

  • args[0]: mask, The mask.
  • args[1]: value, The value to use.
  • args[2]: lane_mask, The lane mask.
  • args[3]: width, The width.
  • args[4]: warp_size, The number of threads per warp.

◆ handle_add_byte_offset_op()

TVM_TIRX_DLL const Op & tvm::tirx::handle_add_byte_offset_op ( )

Add a byte offset to an opaque pointer.

Arguments, in order:

  • args[0]: handle, The handle.
  • args[1]: offset, The offset.

◆ ignore_loop_partition_op()

TVM_TIRX_DLL const Op & tvm::tirx::ignore_loop_partition_op ( )

Annotate a predicate not be considered as target condition of loop partition.

Arguments, in order:

  • args[0]: predicate, The predicate.

◆ IsNoOp()

bool tvm::tirx::IsNoOp ( const Stmt &  stmt)
inline

Whether stmt is undefined, an integer Evaluate, or an empty sequence.

◆ isnullptr_op()

TVM_TIRX_DLL const Op & tvm::tirx::isnullptr_op ( )

Test whether a pointer is null.

Arguments, in order:

  • args[0]: x, The input value.

◆ kernel_replace_point_op()

TVM_TIRX_DLL const Op & tvm::tirx::kernel_replace_point_op ( )

Marker where a transform should replace generated kernel initialization.

◆ launch_thread_op()

TVM_TIRX_DLL const Op & tvm::tirx::launch_thread_op ( )

Thread launch region: operands are a nonempty StringImm tag and a scalar signed or unsigned integer extent wider than one bit. The sole body parameter is a fresh thread-index PrimVar matching the extent type. Tags starting with vthread denote virtual threads. There are no attrs or results.

◆ logaddexp()

TVM_TIRX_DLL PrimExpr tvm::tirx::logaddexp ( PrimExpr  a,
PrimExpr  b,
Location  loc = UnknownLoc() 
)

Compute log(exp(a) + exp(b)).

Parameters
aLeft operand.
bRight operand.
locThe location of this operation in the source.
Returns
The result expression.

◆ masked_load_op()

TVM_TIRX_DLL const Op & tvm::tirx::masked_load_op ( )

Masked tensor load.

Arguments, in order:

  • args[0]: tensor, The tensor.
  • args[1...n-2]: The tensor indices (at least one).
  • args[n-1]: The boolean lane mask, matching the lanes of the loaded vector.

◆ masked_store_op()

TVM_TIRX_DLL const Op & tvm::tirx::masked_store_op ( )

Masked tensor store.

Arguments, in order:

  • args[0]: tensor, The tensor.
  • args[1]: value, The vector value to store.
  • args[2...n-2]: The tensor indices (at least one).
  • args[n-1]: The boolean lane mask, matching the lanes of value.

◆ MatchShapeStridePattern()

ffi::Optional< ffi::Tuple< ffi::Array< PrimExpr >, ffi::Array< PrimExpr >, PrimExpr > > tvm::tirx::MatchShapeStridePattern ( const TensorType &  tensor)
inline

Match a tensor's shape-aligned strided memory representation.

Returns (shape, strides, element offset). An absent layout yields contiguous row-major strides and zero offset. A TileLayout must have one memory iterator per shape dimension, no replicas, and only a memory-axis offset. Other layouts or mismatched extents return nullopt. Strides are always actual expressions; an empty stride array means rank zero, not an implicit compact contract.

ExprDeepEqual preserves variable identity without remapping or symbolic proofs, avoiding the overhead and broader equivalences of general structural matching.

◆ operator!=()

bool tvm::tirx::operator!= ( const TensorVar &  lhs,
const TensorVar &  rhs 
)
inline

◆ operator<<()

std::ostream & tvm::tirx::operator<< ( std::ostream &  os,
const ThreadScope &  scope 
)
inline

◆ operator==()

bool tvm::tirx::operator== ( const TensorVar &  lhs,
const TensorVar &  rhs 
)
inline

◆ parallel_launch_op()

TVM_TIRX_DLL const Op & tvm::tirx::parallel_launch_op ( )

Launch a CPU worker team around parallel loops and team barriers. Takes no operands, body parameters, attributes or results.

◆ prefetch_op()

TVM_TIRX_DLL const Op & tvm::tirx::prefetch_op ( )

Prefetch a memory address.

Arguments, in order:

  • args[0]: ptr, The pointer.
  • args[1]: rw, The read/write mode.
  • args[2]: locality, The locality hint.
  • args[3]: cache_type, The cache policy.

◆ ptr_byte_offset_op()

TVM_TIRX_DLL const Op & tvm::tirx::ptr_byte_offset_op ( )

Cast a handle to a typed pointer after adding a byte offset.

Arguments, in order:

  • args[0]: data, Base pointer.
  • args[1]: byte_offset, Offset in bytes. The result type specifies the pointed-to element type.

◆ reinterpret() [1/2]

PrimExpr tvm::tirx::reinterpret ( PrimType  t,
PrimExpr  value,
Location  loc = UnknownLoc() 
)
inline

◆ reinterpret() [2/2]

TVM_TIRX_DLL Expr tvm::tirx::reinterpret ( Type  target_ty,
Expr  value,
Location  loc = UnknownLoc() 
)

perform reinterpret cast value to type.

Parameters
target_tyThe target type.
valueThe value
locThe location of this operation in the source.
Returns
The result expression.
Note
This function may return value if the type is the same.

◆ reinterpret_op()

TVM_TIRX_DLL const Op & tvm::tirx::reinterpret_op ( )

Reinterpret the bits of a value as an explicit primitive or pointer type.

Arguments, in order:

  • args[0]: x, The input value.

◆ RenewDef()

TVM_TIRX_DLL Function tvm::tirx::RenewDef ( Function  func)

Renew variable definitions and remap their uses in a function.

Definition regions follow the registered structural hooks. Free variables and function attributes are preserved, and the function signature is rebuilt.

Parameters
funcThe function to renew.
Returns
The function with fresh variable definitions.

◆ ScopeHigher()

TVM_TIRX_DLL bool tvm::tirx::ScopeHigher ( const ThreadScope &  a,
const ThreadScope &  b 
)

Compare explicit ranks within one backend's hierarchy.

◆ SetSeqIndex()

void tvm::tirx::SetSeqIndex ( std::unordered_map< const StmtObj *, StmtSRef > &  stmt2ref,
const Stmt &  stmt,
int  seq_index,
bool  include_loops = true 
)
inline

Set the StmtSRefObj::seq_index field for stmt.

Parameters
stmt2refThe stmt2ref map to be updated with seq_index
stmtThe statement, or the realize node of the statement whose sref to be set
seq_indexThe seq_index to be set
include_loopsIgnore ForNodes if this value is false
Note
The method is NOP for statements that are not schedulable, i.e. not For or s_tir::SBlock

◆ SetSeqIndexInChildren()

void tvm::tirx::SetSeqIndexInChildren ( std::unordered_map< const StmtObj *, StmtSRef > &  stmt2ref,
const SeqStmtObj *  seq_stmt,
bool  include_loops = true 
)
inline

Update seq_index of the children of a SeqStmt.

Parameters
stmt2refThe stmt2ref map to be updated with indices
seq_stmtThe SeqStmt whose children need updating
include_loopsIgnore ForNodes if this value is false

◆ stack_alloca_op()

TVM_TIRX_DLL const Op & tvm::tirx::stack_alloca_op ( )

Allocate stack storage for runtime values.

Arguments, in order:

  • args[0]: dtype_str, The data type name.
  • args[1]: num, The number of entries.

◆ stack_make_dltensor_op()

TVM_TIRX_DLL const Op & tvm::tirx::stack_make_dltensor_op ( )

Construct a stack-allocated DLTensor.

Arguments, in order:

  • args[0]: data, The input data.
  • args[1]: shape, The shape.
  • args[2]: strides, The strides.
  • args[3]: ndim, The number of dimensions.
  • args[4]: arr_dtype, The array data type.
  • args[5]: elem_offset, The element offset.

◆ stack_make_shape_op()

TVM_TIRX_DLL const Op & tvm::tirx::stack_make_shape_op ( )

Construct a stack-allocated shape tuple.

Arguments, in order:

  • args[0...]: args, trailing IntExpr operands.

◆ static_handle_op()

TVM_TIRX_DLL const Op & tvm::tirx::static_handle_op ( )

Create a function local static handle that iniitalizes to nullptr.

◆ StructuralMapWithConstraintContext()

template<ffi::WalkOrder order, typename... Callbacks>
ffi::Any tvm::tirx::StructuralMapWithConstraintContext ( ffi::Any  root,
Callbacks &&...  callbacks 
)

Map with (value, const sym::ConstraintContext& [, def_region_kind]) callbacks. Callbacks return a replacement, Unchanged, or Expected thereof; they must not mutate their input. Pre/post behavior is that of ffi::StructuralMap. Pass std::move(root) to permit reuse; shared roots still copy. The position is restored before a scoped node's post callback. See the object documentation for timing.

◆ StructuralMapWithConstraintContextExpected()

template<ffi::WalkOrder order, typename... Callbacks>
ffi::Expected< ffi::Any > tvm::tirx::StructuralMapWithConstraintContextExpected ( ffi::Any  root,
Callbacks &&...  callbacks 
)
noexcept

Expected form of StructuralMapWithConstraintContext.

◆ StructuralMutateWithConstraintContext()

template<typename... Callbacks>
ffi::Any tvm::tirx::StructuralMutateWithConstraintContext ( ffi::Any  root,
Callbacks &&...  callbacks 
)

Mutate with (value, StructuralMutatorWithConstraintContextObj* [, InplaceMode]). The first matching callback owns descent, exactly as in ffi::StructuralMutate. Return a replacement/Unchanged or Expected thereof. Delegate to mutator->DefaultMutateExpected(value, mode) for constraint-aware descent; recurse with MutateExpected(child, mode). Both use the same context and remap.

ffi::InplaceMode mode) -> ffi::Expected<ffi::Any> {
auto mapped = mutator->DefaultMutateExpected(node, mode);
if (mapped.is_err()) return ffi::Unexpected(mapped.error());
return std::move(mapped).value().ValueOrUnchanged(ffi::Any(node));
});
If statement.
Definition stmt.h:401
Mutates values using their structural mutation behavior while maintaining the constraint context rele...
Definition structural_mutate_with_constraint_context.h:40
ffi::Expected< ffi::UnchangedOr< ffi::Any > > DefaultMutateExpected(ffi::AnyView value, ffi::InplaceMode mode=ffi::InplaceMode::kDisallow) noexcept
Default path, bypassing this node's engine callback.
Definition structural_mutate_with_constraint_context.h:207
ffi::Any StructuralMutateWithConstraintContext(ffi::Any root, Callbacks &&... callbacks)
Mutate with (value, StructuralMutatorWithConstraintContextObj* [, InplaceMode]). The first matching c...
Definition structural_mutate_with_constraint_context.h:179

◆ StructuralMutateWithConstraintContextExpected()

template<typename... Callbacks>
ffi::Expected< ffi::Any > tvm::tirx::StructuralMutateWithConstraintContextExpected ( ffi::Any  root,
Callbacks &&...  callbacks 
)
noexcept

Expected form of StructuralMutateWithConstraintContext.

◆ StructuralVisitWithConstraintContext()

template<typename... Callbacks>
ffi::Optional< ffi::VisitInterrupt > tvm::tirx::StructuralVisitWithConstraintContext ( ffi::AnyView  root,
Callbacks &&...  callbacks 
)

Visit with callbacks (value, StructuralVisitorWithConstraintContextObj*). The first matching callback owns descent. Return completion, interrupt, or error as in ffi::StructuralVisit. Recurse with visitor->VisitExpected(child) or visitor->DefaultVisitExpected(value); constraints is the active context handle.

◆ StructuralVisitWithConstraintContextExpected()

template<typename... Callbacks>
ffi::Expected< ffi::Optional< ffi::VisitInterrupt > > tvm::tirx::StructuralVisitWithConstraintContextExpected ( ffi::AnyView  root,
Callbacks &&...  callbacks 
)
noexcept

Expected form of StructuralVisitWithConstraintContext.

◆ StructuralWalkWithConstraintContext()

template<ffi::WalkOrder order, typename... Callbacks>
ffi::Optional< ffi::VisitInterrupt > tvm::tirx::StructuralWalkWithConstraintContext ( ffi::AnyView  root,
Callbacks &&...  callbacks 
)

Walk every occurrence with (value, const sym::ConstraintContext&) callbacks. A trailing TVMFFIDefRegionKind is optional, as in ffi::StructuralWalk. Return Expected<WalkResult>; pre-order Skip prunes descent and Interrupt stops the walk. Post callbacks see a scoped node after its internal scope is restored. Sequence traversal visits its statements directly in order; lazy calls visit their arguments directly so each branch has its own scope. These two hooks do not dispatch a callback for their intermediate Array containers.

StructuralWalkWithConstraintContext<ffi::WalkOrder::kPreOrder>(stmt,
[](const Var& var, const sym::ConstraintContext& facts)
-> ffi::Expected<ffi::WalkResult> {
auto snapshot = facts->ToArray();
return ffi::WalkResult::Advance();
});
Managed reference to VarObj.
Definition expr.h:571
Managed reference to ConstraintContextObj. Copies share the same context.
Definition constraint.h:306

◆ StructuralWalkWithConstraintContextExpected()

template<ffi::WalkOrder order, typename... Callbacks>
ffi::Expected< ffi::Optional< ffi::VisitInterrupt > > tvm::tirx::StructuralWalkWithConstraintContextExpected ( ffi::AnyView  root,
Callbacks &&...  callbacks 
)
noexcept

Expected form of StructuralWalkWithConstraintContext.

◆ SubstituteWithDataTypeLegalization() [1/2]

TVM_TIRX_DLL PrimExpr tvm::tirx::SubstituteWithDataTypeLegalization ( PrimExpr  expr,
ffi::TypedFunction< ffi::Optional< PrimExpr >(const Var &)>  vmap 
)

Substitute the var specified by vmap and legalize data types after substitution.

Parameters
exprThe source statement to be substituted
vmapreturns a new value if re-mapping is needed, otherwise returns nullptr.

Substitution may change the data type of the expression.

Returns
The result.

◆ SubstituteWithDataTypeLegalization() [2/2]

TVM_TIRX_DLL Stmt tvm::tirx::SubstituteWithDataTypeLegalization ( Stmt  stmt,
ffi::TypedFunction< ffi::Optional< PrimExpr >(const Var &)>  vmap 
)

Substitute the var specified by vmap and legalize data types after substitution.

Parameters
stmtThe source statement to be substituted
vmapreturns a new value if re-mapping is needed, otherwise returns nullptr.

This statement overload legalizes only core TIRX nodes. Dtype-changing substitutions must be applied after lowering dialect blocks: structural traversal of extension statements does not legalize their iterator domains or bindings. Type-preserving mappings continue to traverse schedulable blocks structurally before lowering.

Returns
The result.

◆ tensor_data_ptr_op()

TVM_TIRX_DLL const Op & tvm::tirx::tensor_data_ptr_op ( )

Project the physical pointer associated with a TensorVar definition.

Argument: tensor, the TensorVar whose physical pointer is projected. The result pointer type is derived from the TensorType dtype and storage scope of the sole TensorVar argument. This operation is consumed by TIRx lowering and code generation.

◆ throw_last_error_op()

TVM_TIRX_DLL const Op & tvm::tirx::throw_last_error_op ( )

Raise the last runtime error.

◆ TVM_DEFINE_INT_OP_CONST_VAL_OVERLOAD_SPANNED()

tvm::tirx::TVM_DEFINE_INT_OP_CONST_VAL_OVERLOAD_SPANNED ( logaddexp  )

◆ undef_op()

TVM_TIRX_DLL const Op & tvm::tirx::undef_op ( )

Returns an initialized but arbitrary value.

◆ vector_combine_op()

TVM_TIRX_DLL const Op & tvm::tirx::vector_combine_op ( )

Concat two vectors.

Arguments, in order:

  • args[0]: vec1, The first input vector.
  • args[1]: vec2, The second input vector.

◆ vector_high_op()

TVM_TIRX_DLL const Op & tvm::tirx::vector_high_op ( )

Get the high level half of the vector.

Arguments, in order:

  • args[0]: vec, The input vector.

◆ vector_low_op()

TVM_TIRX_DLL const Op & tvm::tirx::vector_low_op ( )

Get the low-level half of the vector.

Arguments, in order:

  • args[0]: vec, The input vector.

◆ VerifyMemory()

TVM_TIRX_DLL bool tvm::tirx::VerifyMemory ( const Function &  func)

Verify if memory accesses are legal for a specific target device type.

In the case that tgt is cuda, if not all workload is bound with threads, CPU code is generated that tries to access GPU memory, which is illegal. This pass performs verification for this case.

Parameters
funcThe function to be verified.
Returns
Success of memory verification.