tvm
Loading...
Searching...
No Matches
Functions
tvm::tirx::transform Namespace Reference

Functions

TVM_TIRX_DLL Pass VerifyMemory ()
 Pass variant of VerifyMemory.
 
TVM_TIRX_DLL Pass DecorateDeviceScope ()
 Wrap a function body in a device scope region.
 
TVM_TIRX_DLL Pass CreateFunctionPass (std::function< ffi::Optional< Function >(Function, IRModule, PassContext)> pass_func, int opt_level, ffi::String name)
 
TVM_TIRX_DLL Pass VectorizeLoop (bool enable_vectorize=true)
 Lower vectorization loops.
 
TVM_TIRX_DLL Pass StorageRewrite ()
 Rewrite storage allocation pattern. Moves the allocation to outer most possible scope. Trying to share space between allocations to make a static allocation plan when possible.
 
TVM_TIRX_DLL Pass UnrollLoop ()
 unroll the constant loop marked by unroll. This pass also automatically attach pragma unroll tag to loops which meets the standard.
 
TVM_TIRX_DLL Pass RemoveNoOp ()
 Remove No Op from the Stmt.
 
TVM_TIRX_DLL Pass HoistIf ()
 Hoist loop-invariant If statements outside eligible loops.
 
TVM_TIRX_DLL Pass RenormalizeSplitPattern ()
 Renormalize the split pattern from floordiv(floormod()) to floormod(floordiv()).
 
TVM_TIRX_DLL Pass StmtSimplify ()
 Run statement-level arithmetic simplifications on the TIR Function.
 
TVM_TIRX_DLL Pass ConvertSSA ()
 Convert an IRModule to be SSA form.
 
TVM_TIRX_DLL Pass LowerThreadAllreduce ()
 Lower cross-thread reductions to target-specific communication.
 
TVM_TIRX_DLL Pass MakePackedAPI ()
 Transform the high-level Function to a low-level version that can be used as an API function.
 
TVM_TIRX_DLL Pass SplitHostDevice ()
 Annotate, split, and lower host/device functions.
 
TVM_TIRX_DLL Pass SkipAssert ()
 skip assert stmt.
 
TVM_TIRX_DLL Pass LowerTVMBuiltin ()
 Lower builtin intrinsics.
 
TVM_TIRX_DLL Pass LowerIntrin ()
 Lower the target specific function intrinsics in each of the function.
 
TVM_TIRX_DLL Pass LowerWarpMemory ()
 Lower warp memory access to low-level device related function calls.
 
TVM_TIRX_DLL Pass NarrowDataType (int target_bits)
 Narrow down PrimExpr datatype in stmt to target_bits.
 
TVM_TIRX_DLL Pass ForceNarrowIndexToInt32 ()
 Force to narrow down indexing expressions and integer tensors to int32 dtype.
 
TVM_TIRX_DLL Pass BF16ComputeLegalize ()
 Legalize bf16 compute Ops. Add a cast to fp32 before Ops, then add a cast back to bf16.
 
TVM_TIRX_DLL Pass FP8ComputeLegalize (ffi::String promote_dtype="float16")
 Legalize fp8 compute Ops. Add a cast to fp16/fp32 before Ops, then add a cast back to fp8.
 
TVM_TIRX_DLL Pass BF16StorageLegalize ()
 Legalize bf16 storage types to u16.
 
TVM_TIRX_DLL Pass FP8StorageLegalize ()
 Legalize fp8 storage types to u8.
 
TVM_TIRX_DLL Pass PointerValueTypeRewrite ()
 Rewrite the pointer content type of arguments, as well as Alloc internal to the function to use the most frequently accessed type for load/store to avoid pointer casting in backend when possible.
 
TVM_TIRX_DLL Pass FlattenTensor ()
 Flatten the multi-dimensional TensorLoad and TensorStore to single dimensional TensorLoad/TensorStore for the TIR not contains opaque block.
 
TVM_TIRX_DLL Pass CommonSubexprElim ()
 Implements Common Subexpression Elimination (CSE) for TIR which introduces Bind statements for duplicated sub-expressions.
 
TVM_TIRX_DLL Pass BindTarget (Target target)
 Annotate a Function with a given target.
 
TVM_TIRX_DLL Pass AnnotateEntryFunc ()
 Set a Function as the entry point if it is only function in IRModule.
 
TVM_TIRX_DLL Pass Filter (ffi::TypedFunction< bool(Function)> fcond)
 Filter Functions with a given condition.
 
TVM_TIRX_DLL Pass TileDispatch ()
 Lower TIRx op calls using registered op dispatchers for the given target.
 
TVM_TIRX_DLL Pass LowerTIRxCleanup ()
 Finalize TIRx lowering by applying layout rewriters and cleanup passes.
 
TVM_TIRX_DLL Pass LowerTIRx ()
 Lower the TIR to a lower level IR for the given target.
 

Function Documentation

◆ AnnotateEntryFunc()

TVM_TIRX_DLL Pass tvm::tirx::transform::AnnotateEntryFunc ( )

Set a Function as the entry point if it is only function in IRModule.

Returns
The pass.

◆ BF16ComputeLegalize()

TVM_TIRX_DLL Pass tvm::tirx::transform::BF16ComputeLegalize ( )

Legalize bf16 compute Ops. Add a cast to fp32 before Ops, then add a cast back to bf16.

Returns
The pass.

◆ BF16StorageLegalize()

TVM_TIRX_DLL Pass tvm::tirx::transform::BF16StorageLegalize ( )

Legalize bf16 storage types to u16.

Returns
The pass.

◆ BindTarget()

TVM_TIRX_DLL Pass tvm::tirx::transform::BindTarget ( Target  target)

Annotate a Function with a given target.

Note
Device calls must be enclosed in explicit launch_thread or device_entry regions. Lower dialect-specific thread bindings before classifying host/device calls.
Returns
The pass.

◆ CommonSubexprElim()

TVM_TIRX_DLL Pass tvm::tirx::transform::CommonSubexprElim ( )

Implements Common Subexpression Elimination (CSE) for TIR which introduces Bind statements for duplicated sub-expressions.

Returns
The pass.

◆ ConvertSSA()

TVM_TIRX_DLL Pass tvm::tirx::transform::ConvertSSA ( )

Convert an IRModule to be SSA form.

This pass handles cases where the same tvm::Var appears in multiple functions within the same module. For example, after extracting a fragment from one function into another, where the same tvm::Var may be defined both as within the body of the original function, and as a parameter within the hoisted function.

Returns
The pass.

◆ CreateFunctionPass()

TVM_TIRX_DLL Pass tvm::tirx::transform::CreateFunctionPass ( std::function< ffi::Optional< Function >(Function, IRModule, PassContext)>  pass_func,
int  opt_level,
ffi::String  name 
)

◆ DecorateDeviceScope()

TVM_TIRX_DLL Pass tvm::tirx::transform::DecorateDeviceScope ( )

Wrap a function body in a device scope region.

◆ Filter()

TVM_TIRX_DLL Pass tvm::tirx::transform::Filter ( ffi::TypedFunction< bool(Function)>  fcond)

Filter Functions with a given condition.

Returns
The pass.

◆ FlattenTensor()

TVM_TIRX_DLL Pass tvm::tirx::transform::FlattenTensor ( )

Flatten the multi-dimensional TensorLoad and TensorStore to single dimensional TensorLoad/TensorStore for the TIR not contains opaque block.

Returns
The pass.

◆ ForceNarrowIndexToInt32()

TVM_TIRX_DLL Pass tvm::tirx::transform::ForceNarrowIndexToInt32 ( )

Force to narrow down indexing expressions and integer tensors to int32 dtype.

The function must not contain S-TIR blocks.

Returns
The pass.
Note
This pass should not be used in default cases.

◆ FP8ComputeLegalize()

TVM_TIRX_DLL Pass tvm::tirx::transform::FP8ComputeLegalize ( ffi::String  promote_dtype = "float16")

Legalize fp8 compute Ops. Add a cast to fp16/fp32 before Ops, then add a cast back to fp8.

Parameters
promote_dtypeThe data type used for type promotion, defaults to float16
Note
Must be run after BindTarget, as it relies on target attributes for Functions
Returns
The pass.

◆ FP8StorageLegalize()

TVM_TIRX_DLL Pass tvm::tirx::transform::FP8StorageLegalize ( )

Legalize fp8 storage types to u8.

Note
Must be run after BindTarget, as it relies on target attributes for Functions
Returns
The pass.

◆ HoistIf()

TVM_TIRX_DLL Pass tvm::tirx::transform::HoistIf ( )

Hoist loop-invariant If statements outside eligible loops.

Returns
The pass.

◆ LowerIntrin()

TVM_TIRX_DLL Pass tvm::tirx::transform::LowerIntrin ( )

Lower the target specific function intrinsics in each of the function.

Returns
The pass.

◆ LowerThreadAllreduce()

TVM_TIRX_DLL Pass tvm::tirx::transform::LowerThreadAllreduce ( )

Lower cross-thread reductions to target-specific communication.

◆ LowerTIRx()

TVM_TIRX_DLL Pass tvm::tirx::transform::LowerTIRx ( )

Lower the TIR to a lower level IR for the given target.

Returns
The pass.

◆ LowerTIRxCleanup()

TVM_TIRX_DLL Pass tvm::tirx::transform::LowerTIRxCleanup ( )

Finalize TIRx lowering by applying layout rewriters and cleanup passes.

Returns
The pass.

◆ LowerTVMBuiltin()

TVM_TIRX_DLL Pass tvm::tirx::transform::LowerTVMBuiltin ( )

Lower builtin intrinsics.

Returns
The pass.

◆ LowerWarpMemory()

TVM_TIRX_DLL Pass tvm::tirx::transform::LowerWarpMemory ( )

Lower warp memory access to low-level device related function calls.

Returns
The pass.

◆ MakePackedAPI()

TVM_TIRX_DLL Pass tvm::tirx::transform::MakePackedAPI ( )

Transform the high-level Function to a low-level version that can be used as an API function.

The main task of this function is to create code to :

  • Map the values in the api_args to Var that is required by body.
  • Insert assertions to check type/value of the passed arguments.
Note
The function signature have two cases

let num_packed_args = len(api_args);

if num_packed_args is zero: f()

if num_packed_args is not zero: f(void *, TVMFFIAny* packed_args, int num_packed_args, api_arg_k, api_arg_k+1, ... api_arg_n, TVMFFIAny* out_ret_val)

where n == len(api_args), k == num_packed_args

Returns
The pass.

◆ NarrowDataType()

TVM_TIRX_DLL Pass tvm::tirx::transform::NarrowDataType ( int  target_bits)

Narrow down PrimExpr datatype in stmt to target_bits.

Parameters
target_bitsThe target bits
Note
Run this pass after storage flatten.
Returns
The pass.

◆ PointerValueTypeRewrite()

TVM_TIRX_DLL Pass tvm::tirx::transform::PointerValueTypeRewrite ( )

Rewrite the pointer content type of arguments, as well as Alloc internal to the function to use the most frequently accessed type for load/store to avoid pointer casting in backend when possible.

Returns
The pass.

◆ RemoveNoOp()

TVM_TIRX_DLL Pass tvm::tirx::transform::RemoveNoOp ( )

Remove No Op from the Stmt.

Returns
The pass.

◆ RenormalizeSplitPattern()

TVM_TIRX_DLL Pass tvm::tirx::transform::RenormalizeSplitPattern ( )

Renormalize the split pattern from floordiv(floormod()) to floormod(floordiv()).

Returns
The pass.

◆ SkipAssert()

TVM_TIRX_DLL Pass tvm::tirx::transform::SkipAssert ( )

skip assert stmt.

Returns
The pass.

◆ SplitHostDevice()

TVM_TIRX_DLL Pass tvm::tirx::transform::SplitHostDevice ( )

Annotate, split, and lower host/device functions.

This pass first annotates device regions within host functions, then splits them into host and device-side Functions, and finally lowers host-to-device calls into the device kernel launch ABI.

The resulting host-side function will keep the same tvm::attr::kTarget attribute (e.g. T.target("cuda", host=T.target("llvm"))). This ensures that MakePackedAPI knows which device type should be used for the input tensors.

The resulting device-side function will have the host stripped from its target attribute (e.g. T.target("cuda")).

Returns
The pass.

◆ StmtSimplify()

TVM_TIRX_DLL Pass tvm::tirx::transform::StmtSimplify ( )

Run statement-level arithmetic simplifications on the TIR Function.

Returns
The pass.

◆ StorageRewrite()

TVM_TIRX_DLL Pass tvm::tirx::transform::StorageRewrite ( )

Rewrite storage allocation pattern. Moves the allocation to outer most possible scope. Trying to share space between allocations to make a static allocation plan when possible.

Returns
The pass.

◆ TileDispatch()

TVM_TIRX_DLL Pass tvm::tirx::transform::TileDispatch ( )

Lower TIRx op calls using registered op dispatchers for the given target.

Lowers CUDA index calls to ordinary bindings using the independent device-entry launch configuration, preserving execution-context information during dispatch.

Returns
The pass.

◆ UnrollLoop()

TVM_TIRX_DLL Pass tvm::tirx::transform::UnrollLoop ( )

unroll the constant loop marked by unroll. This pass also automatically attach pragma unroll tag to loops which meets the standard.

Returns
The pass.

◆ VectorizeLoop()

TVM_TIRX_DLL Pass tvm::tirx::transform::VectorizeLoop ( bool  enable_vectorize = true)

Lower vectorization loops.

Target-dependent vectorization uses the Function's target attribute, not an ambient target context or nested target attributes. Target-independent fixed-width loops do not require a target. Code needing different vectorization targets must be separated into functions before this pass.

Parameters
enable_vectorizeWhether vectorization is enabled.
Returns
The pass.

◆ VerifyMemory()

TVM_TIRX_DLL Pass tvm::tirx::transform::VerifyMemory ( )

Pass variant of VerifyMemory.

Returns
The pass.
See also
tvm::tirx::VerifyMemory