Backend Internals#
TIRx keeps the core IR and compiler machinery under tvm.tirx. A target
backend owns its script namespaces, intrinsic builders, dispatch variants,
pipeline additions, and code-generation support under tvm.backend.
Loading and registration#
tvm.backend.load imports a backend and calls its registration hook. A
backend can register the following target-owned behavior:
TVMScript namespaces such as
Tx.cuda,Tx.ptx, andTx.nki;tile-primitive dispatch implementations for that target kind;
target tags and, when the target owns one, compilation-pipeline entry points; and
code-generation helpers that translate backend calls to target source.
Registration imports some modules only for their side effects. Those modules are implementation surfaces, not additional kernel-authoring APIs.
CUDA ownership#
tvm.backend.cuda is divided by compiler responsibility:
Module |
Responsibility |
|---|---|
|
Construct the |
|
Define IR builders used by the CUDA script namespaces. |
|
Register CUDA implementations of common |
|
Register source-generation callbacks and CUDA C++ helpers. |
|
Provide CUDA-specific compiler passes. |
|
Register named NVIDIA targets. |
|
Provide reusable kernel utilities and profiling orchestration. |
The PTX namespace is table-driven. A table entry defines the legal modifier
and operand forms; construction creates a tirx.ptx.* call, and CUDA codegen
emits the corresponding instruction. See Direct PTX Instructions for the supported
public forms.
Trainium ownership#
tvm.backend.trn follows the same boundary. script and op construct
the Tx.nki surface, tile_primitive registers target dispatches,
layout and transform lower Trainium-specific memory mappings, and
pipeline assembles the Trainium pass sequence. target_tags registers
the named AWS Trainium targets.
Public integration hooks are listed in Backend Extension API; target-facing CUDA and Trainium utilities are listed in CUDA Authoring and Support APIs and Trainium Authoring and Support APIs.