tvm_tirx.tirx#

Tensor-level IR nodes, layouts, operators, analysis, and compilation.

Namespaces#

Classes#

TensorType(shape, dtype[, scope, align, ...])

The shape, element type, and storage contract of a TIRx tensor expression.

TensorMapType([loc])

The type of a tensor-map descriptor used by backend memory operations.

Function(params, body[, ret_type, attrs, loc])

A TIRx function definition or declaration.

IndexMap(initial_indices, final_indices, ...)

Map input index variables to expressions for output indices.

CallFFIKernelAttr([launch_params, ...])

Ordered launch tags for an explicit FFI kernel call.

ThreadScope(*args, **kwargs)

A registered thread scope, queried by its qualified backend.scope name.

TileLayout(spec)

Map logical indices to memory and ownership coordinates using strided factors.

Layout(*args, **kwargs)

Base class for mappings from logical indices to named physical axes.

ComposeLayout(per_element, swizzle_len, ...)

Apply an XOR swizzle to the memory coordinate of a tile layout.

Additional Structural Visit and Mutate APIs#

Traverse and transform TIRx with the facts available at each use.

Callbacks receive a tvm_tirx.sym.ConstraintContext: iterate it to read facts, or use list(context) to retain an independent list. Bind/Assert add facts for later statements; If/While/lazy calls add guards, For/thread launch add ranges, and Let adds a body binding. Mutation uses the transformed values. Call and RegionStmt use registered operator hooks; other calls follow ordinary descent, and other regions isolate their body facts.

Callbacks control descent. Normal exits and interrupts restore outer facts; errors propagate without restoration, so discard the traversal after failure. The C++ structural visitor and mutator docs describe the full collection rules.

See also

tvm_ffi.structural, the TVM-FFI utilities these variants build on.

StructuralVisitorWithConstraintContext()

Visits values using their structural visit behavior while maintaining the constraint context relevant to each callback.

StructuralMutatorWithConstraintContext()

Mutates values using their structural mutation behavior while maintaining the constraint context relevant to each callback.

structural_walk_with_constraint_context(...)

Walk a value structurally with its active symbolic facts.

structural_visit_with_constraint_context(...)

Visit a value structurally with a callback that owns child traversal.

structural_map_with_constraint_context(root, ...)

Structurally map a value with its active symbolic facts.

structural_mutate_with_constraint_context(...)

Mutate a value with a callback that owns recursive mutation.

Functions#

Use tvm_tirx.compile() as the public entry point for building programs. tvm_tirx.tirx.compile remains available as its implementation entry point.

tensor_data_ptr(tensor, *[, ty, loc])

Project a tensor variable's physical pointer.

is_tensor_var(value)

Return whether value is an ordinary Var carrying TensorType.

renew_def(func)

Renew variable definitions and remap their uses in a function.

call_packed_lowered(*args[, loc, ty])

Lowered version of call packed.

call_cpacked_lowered(*args[, loc, ty])

Lowered version of call c-packed.

register_intrin_lowering(op_name, target, *)

Register Op lowering function

call_packed(*args[, loc, ty])

Build expression by call an external packed function.

call_cpacked(*args[, loc, ty])

Build expression by call an external packed function.

call_intrin(func_name, *args, ty[, attrs, loc])

Build expression by calling an intrinsic function.

call_pure_extern(func_name, *args, ty[, loc])

Build expression by calling a pure extern function.

call_extern(func_name, *args, ty[, loc])

Build expression by calling a extern function.

call_ffi_kernel(*args[, launch, ...])

Call a kernel with its symbol, kernel operands, then launch values.

call_llvm_intrin(name, *args, ty[, loc])

Build expression by calling a llvm intrinsic function

call_llvm_pure_intrin(name, *args, ty[, loc])

Build expression by calling a pure llvm intrinsic function

stack_alloca(dtype_str, num, *[, ty, loc])

Return new on stack dtype[num]

stack_make_shape(*args[, ty, loc])

Allocate a shape tuple on stack, return the handle

stack_make_dltensor(data, shape, strides, ...)

Allocate a Tensor(DLTensor) on stack, return the handle

handle_add_byte_offset(handle, offset, *[, ...])

Add offset to handle

abi_field_get(arr, index, field, *, ty[, loc])

Get struct field value in array

abi_field_set(arr, index, field, value, *[, ...])

Set value in struct field in array

address_of(obj[, loc, ty])

Returns the address of a tensor element or addressable variable.

assume_aligned(tensor, alignment_bytes, *[, ...])

Assume the tensor's base address is aligned to alignment_bytes.

assume_always(predicate, *[, ty, loc])

Guarantee a predicate throughout its containing scope, including mutations.

undef(*[, ty, loc])

Returns an initialized but arbitrary value

gpu_thread_allreduce(combine, identity, ...)

Perform an all-reduce inside a thread block.

ptr_byte_offset(data, byte_offset, *, ty[, loc])

Return data + byte_offset with pointer type ty.

throw_last_error(*[, ty, loc])

Throw TVMGetLastError()

cpu_parallel_barrier(*[, ty, loc])

Synchronize all workers in the current CPU parallel launch.

gpu_load_matrix_sync(fragment, m, n, k, ...)

TVM intrinsic for tensor core load operators

gpu_store_matrix_sync(fragment, m, n, k, ...)

TVM intrinsic for tensor core store operators

gpu_mma_sync(fragment_d, index_d, ...[, ty, loc])

TVM intrinsic for tensor core mma_sync operators

gpu_fill_fragment(fragment, m, n, k, index, ...)

TVM intrinsic for tensor core fill_fragment operators

vector_low(vec, *, ty[, loc])

Get the low level half of the vector

vector_high(vec, *, ty[, loc])

Get the high level half of the vector

vector_combine(vec1, vec2, *, ty[, loc])

Concat two vectors

reinterpret(value, *, ty[, loc])

Reinterpret a value as an exact primitive or pointer type.

isnullptr(x[, loc, ty])

Check if input value is nullptr.

logaddexp(a, b[, loc])

Compute the logaddexp of two expressions.

alloc_workspace(device_type, device_id, ...)

Backend function to allocate temporal workspace

free_workspace(device_type, device_id, ptr, *)

Backend function to free temporal workspace.

get_active_lane_mask(base, limit, *, ty[, loc])

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

get_vscale_expr(dtype[, min_size])

Create a datatype dependent scalable expression.

gpu_dp4a(vec1, vec2[, acc])

Dot product of two int8x4 vectors and add an optional accumulator

ignore_loop_partition(predicate, *[, ty, loc])

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

compile(mod[, target, pipeline])

Compile a function or module to an executable for the target.

get_tir_pipeline([name, target])

Construct a registered pipeline by name.

get_default_tir_pipeline(target[, mod, ...])

Select the default pipeline for the input module and target.

register_tir_pipeline(name, pipeline_factory)

Register a factory returning lowering and host/device finalization stages.

Alias

Canonical API

convert

tvm_tirx.ir.prim.convert

all

tvm_tirx.ir.prim.all

any

tvm_tirx.ir.prim.any

min_value

tvm_tirx.ir.prim.min_value

max_value

tvm_tirx.ir.prim.max_value

assume

tvm_tirx.ir.prim.assume

infinity

tvm_tirx.ir.prim.infinity

exp

tvm_tirx.ir.prim.exp

exp2

tvm_tirx.ir.prim.exp2

exp10

tvm_tirx.ir.prim.exp10

log

tvm_tirx.ir.prim.log

log2

tvm_tirx.ir.prim.log2

log10

tvm_tirx.ir.prim.log10

log1p

tvm_tirx.ir.prim.log1p

ldexp

tvm_tirx.ir.prim.ldexp

clz

tvm_tirx.ir.prim.clz

sin

tvm_tirx.ir.prim.sin

sinh

tvm_tirx.ir.prim.sinh

asin

tvm_tirx.ir.prim.asin

asinh

tvm_tirx.ir.prim.asinh

cos

tvm_tirx.ir.prim.cos

cosh

tvm_tirx.ir.prim.cosh

acos

tvm_tirx.ir.prim.acos

acosh

tvm_tirx.ir.prim.acosh

tan

tvm_tirx.ir.prim.tan

tanh

tvm_tirx.ir.prim.tanh

atan

tvm_tirx.ir.prim.atan

atan2

tvm_tirx.ir.prim.atan2

atanh

tvm_tirx.ir.prim.atanh

bitwise_and

tvm_tirx.ir.prim.bitwise_and

bitwise_not

tvm_tirx.ir.prim.bitwise_not

bitwise_or

tvm_tirx.ir.prim.bitwise_or

bitwise_xor

tvm_tirx.ir.prim.bitwise_xor

erf

tvm_tirx.ir.prim.erf

sigmoid

tvm_tirx.ir.prim.sigmoid

sqrt

tvm_tirx.ir.prim.sqrt

rsqrt

tvm_tirx.ir.prim.rsqrt

floor

tvm_tirx.ir.prim.floor

ceil

tvm_tirx.ir.prim.ceil

hypot

tvm_tirx.ir.prim.hypot

trunc

tvm_tirx.ir.prim.trunc

abs

tvm_tirx.ir.prim.abs

round

tvm_tirx.ir.prim.round

nextafter

tvm_tirx.ir.prim.nextafter

nearbyint

tvm_tirx.ir.prim.nearbyint

power

tvm_tirx.ir.prim.power

pow

tvm_tirx.ir.prim.pow

popcount

tvm_tirx.ir.prim.popcount

fmod

tvm_tirx.ir.prim.fmod

if_then_else

tvm_tirx.ir.prim.if_then_else

likely

tvm_tirx.ir.prim.likely

isnan

tvm_tirx.ir.prim.isnan

isfinite

tvm_tirx.ir.prim.isfinite

isinf

tvm_tirx.ir.prim.isinf

copysign

tvm_tirx.ir.prim.copysign

div

tvm_tirx.ir.prim.div

indexdiv

tvm_tirx.ir.prim.indexdiv

indexmod

tvm_tirx.ir.prim.indexmod

truncdiv

tvm_tirx.ir.prim.truncdiv

truncmod

tvm_tirx.ir.prim.truncmod

floordiv

tvm_tirx.ir.prim.floordiv

floormod

tvm_tirx.ir.prim.floormod

ceildiv

tvm_tirx.ir.prim.ceildiv

min

tvm_tirx.ir.prim.min

max

tvm_tirx.ir.prim.max

shift_left

tvm_tirx.ir.prim.shift_left

shift_right

tvm_tirx.ir.prim.shift_right

vscale

tvm_tirx.ir.prim.vscale