Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
finish1
  • Loading branch information
tlopex committed Mar 29, 2026
commit e776638289a0d5c23435b16e0bf4a45159199912
30 changes: 25 additions & 5 deletions docs/arch/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,33 @@ in the IRModule. Please refer to the :ref:`Relax Deep Dive <relax-deep-dive>` fo
tvm/tirx
--------

tirx contains the definition of the low-level program representations. We use ``tirx::PrimFunc`` to represent functions that can be transformed by tirx passes.
Besides the IR data structures, the tirx module also includes:
``tirx`` contains the core IR definitions and lowering infrastructure for
TensorIR. ``tirx::PrimFunc`` represents low-level tensor functions that can be
transformed by tirx passes.

- A set of analysis passes to analyze the tirx functions in ``tirx/analysis``.
- A set of transformation passes to lower or optimize the tirx functions in ``tirx/transform``.
The tirx module includes:

The schedule primitives and tensor intrinsics are in ``s_tir/schedule`` and ``s_tir/tensor_intrin`` respectively.
- IR data structures (PrimFunc, Buffer, SBlock, expressions, statements).
- Analysis passes in ``tirx/analysis``.
- Transformation and lowering passes in ``tirx/transform``.
- Hardware-aware layout abstractions (TileLayout, SwizzleLayout, ComposeLayout).
- Operator dispatch framework for mapping high-level operators to hardware-specific
implementations.
- Async pipeline primitives (MBarrier, TMABar, TCGen05Bar) for Hopper/Blackwell.

tvm/s_tir
---------

``s_tir`` (Schedulable TIR) contains schedule primitives and auto-tuning tools
that operate on ``tirx::PrimFunc``:

- Schedule primitives to control code generation (tiling, vectorization, thread
binding) in ``s_tir/schedule``.
- Builtin tensor intrinsics in ``s_tir/tensor_intrin``.
- MetaSchedule for automated performance tuning.
- DLight for pre-defined, high-performance schedules.

``s_tir`` depends on ``tirx``; ``tirx`` does not depend on ``s_tir``.

Please refer to the :ref:`TensorIR Deep Dive <tensor-ir-deep-dive>` for more details.

Expand Down
12 changes: 6 additions & 6 deletions docs/arch/pass_infra.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ transformation using the analysis result collected during and/or before traversa
However, as TVM evolves quickly, the need for a more systematic and efficient
way to manage these passes is becoming apparent. In addition, a generic
framework that manages the passes across different layers of the TVM stack (e.g.
Relax and tirx) paves the way for developers to quickly prototype and plug the
Relax and TensorIR) paves the way for developers to quickly prototype and plug the
implemented passes into the system.

This doc describes the design of such an infra that takes the advantage of the
Expand Down Expand Up @@ -166,7 +166,7 @@ Pass Constructs
^^^^^^^^^^^^^^^

The pass infra is designed in a hierarchical manner, and it could work at
different granularities of Relax/tirx programs. A pure virtual class ``PassNode`` is
different granularities of Relax/TensorIR programs. A pure virtual class ``PassNode`` is
introduced to serve as the base of the different optimization passes. This class
contains several virtual methods that must be implemented by the
subclasses at the level of modules, functions, or sequences of passes.
Expand Down Expand Up @@ -222,13 +222,13 @@ Function-Level Passes
^^^^^^^^^^^^^^^^^^^^^

Function-level passes are used to implement various intra-function level
optimizations for a given Relax/tirx module. It fetches one function at a time from
optimizations for a given Relax/TensorIR module. It fetches one function at a time from
the function list of a module for optimization and yields a rewritten Relax
``Function`` or tirx ``PrimFunc``. Most of passes can be classified into this category, such as
``Function`` or TensorIR ``PrimFunc``. Most of passes can be classified into this category, such as
common subexpression elimination and inference simplification in Relax as well as vectorization
and flattening storage in tirx, etc.
and flattening storage in TensorIR, etc.

Note that the scope of passes at this level is either a Relax function or a tirx primitive function.
Note that the scope of passes at this level is either a Relax function or a TensorIR primitive function.
Therefore, we cannot add or delete a function through these passes as they are not aware of
the global information.

Expand Down
2 changes: 1 addition & 1 deletion docs/arch/runtimes/vulkan.rst
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,6 @@ string are all false boolean flags.
validated with `spvValidate`_.

* ``TVM_VULKAN_DEBUG_SHADER_SAVEPATH`` - A path to a directory. If
set to a non-empty string, the Vulkan codegen will save tirx, binary
set to a non-empty string, the Vulkan codegen will save TIR, binary
SPIR-V, and disassembled SPIR-V shaders to this directory, to be
used for debugging purposes.
2 changes: 1 addition & 1 deletion docs/deep_dive/tensor_ir/abstraction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
specific language governing permissions and limitations
under the License.

.. _tir-abstraction:
.. _tirx-abstraction-basics:

Tensor Program Abstraction
--------------------------
Expand Down
16 changes: 14 additions & 2 deletions docs/deep_dive/tensor_ir/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,20 @@

TensorIR
========
TensorIR is one of the core abstraction in Apache TVM stack, which is used to
represent and optimize the primitive tensor functions.
TensorIR is one of the core abstractions in the Apache TVM stack, used to
represent and optimize primitive tensor functions.

The TensorIR codebase is organized into two modules:

- **tirx** — Core IR definitions and lowering (PrimFunc, Buffer, SBlock,
expressions, statements, lowering passes).
- **s_tir** (Schedulable TIR) — Schedule primitives, MetaSchedule, DLight, and
tensor intrinsics. These tools operate on tirx IR to apply performance
optimizations.

In TVMScript, the recommended alias for new tirx code is
``from tvm.script import tirx as Tx``. Existing code uses
``from tvm.script import tirx as T``.
Comment thread
MasterJH5574 marked this conversation as resolved.

.. toctree::
:maxdepth: 2
Expand Down
2 changes: 1 addition & 1 deletion docs/deep_dive/tensor_ir/tutorials/tir_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# ruff: noqa: E402

"""
.. _tir-creation:
.. _tirx-creation:

TensorIR Creation
-----------------
Expand Down
8 changes: 4 additions & 4 deletions docs/deep_dive/tensor_ir/tutorials/tir_transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"""
.. _tirx-transform:

Transformation
--------------
In this section, we will get to the main ingredients of the compilation flows -
transformations of primitive tensor functions.
Transformation (s_tir)
----------------------
This section covers **s_tir** (Schedulable TIR) schedule primitives — the main
tools for transforming primitive tensor functions for performance optimization.
"""

######################################################################
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/api/python/tirx/tirx.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ tvm.tirx
.. automodule:: tvm.tirx
:members:
:imported-members:
:exclude-members: PrimExpr, const, StmtSRef, SBlockScope, ScheduleState, Schedule, ScheduleError
:exclude-members: PrimExpr, const