This is an automated email from the ASF dual-hosted git repository.
tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm-tirx.git
The following commit(s) were added to refs/heads/main by this push:
new c63965fa [DOCS] Add the C++ API reference (#33)
c63965fa is described below
commit c63965faaac09288e413fc6b3e3b8bbd4036864d
Author: Tianqi Chen <[email protected]>
AuthorDate: Fri Oct 23 08:04:42 2026 -0400
[DOCS] Add the C++ API reference (#33)
Add an opt-in C++ reference generated from the public headers, following
the TVM FFI documentation setup. With `BUILD_CPP_DOCS=1`, Exhale runs
Doxygen from an inline configuration and Breathe renders the XML into a
full API index. Without it, a stub index keeps the Python-only site
self-contained.
The C++ landing page mirrors the TVM FFI reference: an opening remark
with navigation tips, a header organization table listing the
`include/tvm` folders in dependency order (support, runtime, ir, sym,
script, target, tirx, codegen, backend), key classes tables, and the
full API index. The key classes are grouped into Type, Expr, and Stmt
tables, a table of location, module, and supporting classes, and a table
of tensor program classes, each listed in header declaration order. The
Python reference lists `tvm_tirx.sym` before `tvm_tirx.script` so both
references follow the same order.
---
docs/.gitignore | 1 +
docs/README.md | 2 +
docs/{index.rst => _stubs/cpp_index.rst} | 25 +--
docs/conf.py | 114 ++++++++++-
docs/dev/doc_build.rst | 30 ++-
docs/index.rst | 1 +
docs/reference/cpp/index.rst | 276 ++++++++++++++++++++++++++
docs/reference/python/index.rst | 6 +-
include/tvm/ir/pattern_match.h | 22 +-
include/tvm/ir/prim/pattern_match.h | 52 ++---
include/tvm/script/printer/doc.h | 2 +-
include/tvm/script/printer/doc_translator.h | 4 +-
include/tvm/support/bytes_io.h | 4 +
include/tvm/tirx/layout.h | 3 +-
include/tvm/tirx/op/memory.h | 2 +-
include/tvm/tirx/stmt_functor_with_analyzer.h | 6 +-
pyproject.toml | 9 +-
tests/scripts/task_python_docs.sh | 2 +-
18 files changed, 495 insertions(+), 66 deletions(-)
diff --git a/docs/.gitignore b/docs/.gitignore
index fabfa519..c9511da1 100644
--- a/docs/.gitignore
+++ b/docs/.gitignore
@@ -17,3 +17,4 @@
_build/
reference/python/generated/
+reference/cpp/generated/
diff --git a/docs/README.md b/docs/README.md
index 1ec32a11..f963e32f 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -26,5 +26,7 @@ uv pip install --group docs
uv run python -m sphinx -b html -W docs docs/_build/html
```
+Set `BUILD_CPP_DOCS=1` to also generate the C++ API reference; this requires
Doxygen.
+
Open `docs/_build/html/index.html` to browse the Developer Manual and API
reference.
See [Build This Doc Site](dev/doc_build.rst) for local serving and clean
rebuilds.
diff --git a/docs/index.rst b/docs/_stubs/cpp_index.rst
similarity index 74%
copy from docs/index.rst
copy to docs/_stubs/cpp_index.rst
index 77fbe430..9e8fdf4c 100644
--- a/docs/index.rst
+++ b/docs/_stubs/cpp_index.rst
@@ -15,23 +15,12 @@
specific language governing permissions and limitations
under the License.
-tvm-tirx
-========
+:orphan:
-Table of Contents
------------------
+==============
+Full API Index
+==============
-.. toctree::
- :maxdepth: 1
- :caption: Reference
-
- Python API <reference/python/index>
-
-.. toctree::
- :maxdepth: 1
- :caption: Developer Manual
-
- dev/source_build
- dev/doc_build
- dev/ci_cd
- dev/release_process
+This page is a placeholder because the C++ API reference was not generated.
+Build the documentation with ``BUILD_CPP_DOCS=1`` to generate it; see
+:doc:`/dev/doc_build`.
diff --git a/docs/conf.py b/docs/conf.py
index ab7e7e74..864ae563 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -16,26 +16,88 @@
# under the License.
import os
+import re
import sys
+import xml.etree.ElementTree as ET
from pathlib import Path
from types import ModuleType
os.environ["TVM_FFI_BUILD_DOCS"] = "1"
+build_exhale = os.environ.get("BUILD_CPP_DOCS", "0") == "1"
+
+_DOCS_DIR = Path(__file__).resolve().parent
+
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "python"))
project = "tvm-tirx"
html_title = project
author = "Apache TVM Community"
extensions = [
+ "breathe",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.mathjax",
"sphinx.ext.napoleon",
]
+
+if build_exhale:
+ extensions.append("exhale")
+
+breathe_default_project = "tvm-tirx"
+
+breathe_projects = {"tvm-tirx": "./_build/doxygen/xml"}
+
+exhaleDoxygenStdin = """
+INPUT = ../include
+INCLUDE_PATH = ../include ../3rdparty/tvm-ffi/include
+PREDEFINED += TVM_TIRX_DLL= TVM_RUNTIME_DLL=
TVM_RUNTIME_DLL_EXPORT= \
+ TVM_FFI_DLL= TVM_FFI_DLL_EXPORT= TVM_FFI_INLINE= \
+ TVM_FFI_EXTRA_CXX_API= TVM_FFI_WEAK=
TVM_FFI_DOXYGEN_MODE \
+ TVM_FFI_COLD_CODE= \
+ TVM_FFI_PREDICT_FALSE(x)=x TVM_FFI_PREDICT_TRUE(x)=x
\
+ __cplusplus=202002
+EXCLUDE_SYMBOLS += *detail* *TypeTraits* std tvm::ffi tvm::ffi::* TVM_*
\
+ *_type_* *use_default_type_traits_v*
*object_ref_contains_v* \
+ WithAttr MatchesOneOf MakeConst FInferType
TFixedReturnType \
+ FRegionGetBodyParams FRegionValidate FTileOpDispatch
+EXTRACT_ALL = YES
+ENABLE_PREPROCESSING = YES
+MACRO_EXPANSION = YES
+WARNINGS = YES
+# Doxygen < 1.13 warns on FFI trait specializations whose primary templates
are not in INPUT.
+WARN_AS_ERROR = NO
+"""
+
+exhaleAfterTitleDescription = """
+This page contains the full API index for the C++ API.
+"""
+
+exhale_args = {
+ "containmentFolder": "reference/cpp/generated",
+ "rootFileName": "index.rst",
+ "doxygenStripFromPath": "../include",
+ "rootFileTitle": "Full API Index",
+ "createTreeView": False,
+ "exhaleExecutesDoxygen": True,
+ "exhaleDoxygenStdin": exhaleDoxygenStdin,
+ "afterTitleDescription": exhaleAfterTitleDescription,
+}
+cpp_id_attributes = [
+ "TVM_TIRX_DLL",
+ "TVM_RUNTIME_DLL",
+ "TVM_RUNTIME_DLL_EXPORT",
+ "TVM_FFI_DLL",
+ "TVM_FFI_DLL_EXPORT",
+ "TVM_FFI_INLINE",
+ "TVM_FFI_EXTRA_CXX_API",
+ "TVM_FFI_WEAK",
+ "TVM_FFI_COLD_CODE",
+]
+
autosummary_generate = True
templates_path = ["_templates"]
-exclude_patterns = ["_build"]
+exclude_patterns = ["_build", "_stubs"]
html_theme = "sphinx_book_theme"
autodoc_default_options = {
@@ -89,3 +151,53 @@ autosummary_filename_map = {
"tvm_tirx.support.utils.filelock":
"tvm_tirx.support.utils.filelock_function",
"tvm_tirx.runtime.Device": "tvm_tirx.runtime.Device_class",
}
+
+
+_STUBS = {
+ "_stubs/cpp_index.rst": "reference/cpp/generated/index.rst",
+}
+
+
+def _prepare_stub_files() -> None:
+ """Move stub files into place if they do not already exist."""
+ for src, dst in _STUBS.items():
+ src_path = _DOCS_DIR / src
+ dst_path = _DOCS_DIR / dst
+ dst_path.parent.mkdir(parents=True, exist_ok=True)
+ if not dst_path.exists():
+ dst_path.write_text(src_path.read_text(encoding="utf-8"),
encoding="utf-8")
+
+
+def _mark_exhale_root_orphan(app, docname, source):
+ """Prepend :orphan: to exhale-generated root so it stays out of the
sidebar."""
+ if docname == "reference/cpp/generated/index":
+ source[0] = ":orphan:\n\n" + source[0]
+
+
+_NESTED_TYPE_OF = re.compile(r"is a nested type of
:ref:`exhale_(?:class|struct|union)_(\w+)`")
+_CLASS_DIRECTIVE = re.compile(r"\.\. doxygen(class|struct|union):: (.+)\n(?:
:.*(?:\n|$))*")
+
+
+def _link_nested_class_to_enclosing_class(app, docname, source):
+ """Link a nested class page to the declaration its enclosing class page
renders.
+
+ Breathe renders public and protected nested classes inside the enclosing
+ class, and Exhale also gives each nested class its own page. Rendering the
+ nested class again would declare the same C++ entity twice.
+ """
+ prefix = "reference/cpp/generated/"
+ match = _NESTED_TYPE_OF.search(source[0]) if docname.startswith(prefix)
else None
+ if match is None:
+ return
+ parent = ET.parse(_DOCS_DIR / breathe_projects[breathe_default_project] /
f"{match[1]}.xml")
+ inner = parent.find(f"compounddef/innerclass[@refid='{docname[len(prefix)
:]}']")
+ if inner is not None and inner.get("prot") != "private":
+ source[0] = _CLASS_DIRECTIVE.sub(
+ r"Documented in the enclosing class as :cpp:\1:`\2`.\n",
source[0], count=1
+ )
+
+
+def setup(app):
+ _prepare_stub_files()
+ app.connect("source-read", _mark_exhale_root_orphan)
+ app.connect("source-read", _link_nested_class_to_enclosing_class)
diff --git a/docs/dev/doc_build.rst b/docs/dev/doc_build.rst
index dab72306..874bfbc0 100644
--- a/docs/dev/doc_build.rst
+++ b/docs/dev/doc_build.rst
@@ -28,6 +28,8 @@ Building the docs requires the Python package to be installed
first; see
- Use the activated mamba environment from :doc:`source_build`.
- Run commands from the repository root.
- Install the documentation tools with ``uv pip install --group docs``.
+ - Optional: install ``Doxygen`` if you plan to generate the C++ API
+ reference (see :ref:`build-cpp-docs`).
Interactive Build (Auto-Reload)
-------------------------------
@@ -36,7 +38,8 @@ Rebuild and serve the documentation locally with live reload:
.. code-block:: bash
- uv run sphinx-autobuild docs docs/_build/html --ignore
docs/reference/python/generated
+ uv run sphinx-autobuild docs docs/_build/html \
+ --ignore docs/reference/python/generated --ignore
docs/reference/cpp/generated
Open ``http://127.0.0.1:8000`` after the initial build completes.
@@ -51,6 +54,30 @@ Generate the HTML documentation once, with warnings treated
as errors:
Open ``docs/_build/html/index.html`` to browse the result.
+.. _build-cpp-docs:
+
+Build with C++ Docs
+-------------------
+
+Generating the C++ reference takes longer and requires Doxygen:
+
+.. code-block:: bash
+
+ brew install doxygen # macOS
+ sudo apt install doxygen # Linux
+
+Set ``BUILD_CPP_DOCS=1`` on the desired build command to enable the extra step:
+
+.. code-block:: bash
+
+ # Interactive build with auto-rebuild on C++ header changes
+ BUILD_CPP_DOCS=1 uv run sphinx-autobuild docs docs/_build/html \
+ --ignore docs/reference/python/generated --ignore
docs/reference/cpp/generated \
+ --watch include
+
+ # One-off build
+ BUILD_CPP_DOCS=1 uv run python -m sphinx -b html -W docs docs/_build/html
+
Cleanup
-------
@@ -60,3 +87,4 @@ Remove generated artifacts when they are no longer needed:
rm -rf docs/_build/
rm -rf docs/reference/python/generated
+ rm -rf docs/reference/cpp/generated
diff --git a/docs/index.rst b/docs/index.rst
index 77fbe430..cf288fe5 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -26,6 +26,7 @@ Table of Contents
:caption: Reference
Python API <reference/python/index>
+ C++ API <reference/cpp/index>
.. toctree::
:maxdepth: 1
diff --git a/docs/reference/cpp/index.rst b/docs/reference/cpp/index.rst
new file mode 100644
index 00000000..dbcd730d
--- /dev/null
+++ b/docs/reference/cpp/index.rst
@@ -0,0 +1,276 @@
+.. Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+.. http://www.apache.org/licenses/LICENSE-2.0
+
+.. Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+C++ API
+=======
+
+This page contains the API reference for the C++ API. The full API index below
+can be a bit dense, so we recommend the following tips first:
+
+- The :ref:`cpp-key-classes` lists the key classes that are most commonly used.
+- See :ref:`cpp-header-organization` for how the modules are organized.
+- You can go to the Full API Index at the bottom of this page to access the
full list of APIs.
+
+ - We usually group the APIs by files. You can look at the file hierarchy in
the
+ full API index and navigate to the specific file to find the APIs in that
file.
+
+.. _cpp-header-organization:
+
+Header Organization
+-------------------
+
+The C++ headers are organized into the following folders, in dependency order:
+each folder builds on those above it.
+
+.. list-table::
+ :header-rows: 1
+ :widths: 30 70
+
+ * - Folder
+ - Description
+ * - ``tvm/support/``
+ - Compiler-independent common utilities.
+ * - ``tvm/runtime/``
+ - Minimal runtime foundation for executing compiled code.
+ * - ``tvm/ir/``
+ - Core IR that language variants build upon, extend, and customize.
+ * - ``tvm/sym/``
+ - Symbolic analysis: integer arithmetic, integer sets, and iterator
affine maps.
+ * - ``tvm/script/``
+ - Extensible IR builder, printer, and Python parser support for language
variants.
+ * - ``tvm/target/``
+ - Target configuration schema and tag registry.
+ * - ``tvm/tirx/``
+ - Tensor program types, layouts, and operations.
+ * - ``tvm/codegen/``
+ - Generic host code generation and intrinsic lowering rules.
+ * - ``tvm/backend/``
+ - Backend-specific attributes, intrinsics, passes, and code generation.
+
+
+.. _cpp-key-classes:
+
+Key Classes
+-----------
+
+This section lists the key classes of the core IR and tensor programs.
+
+The IR follows a common convention: each IR node is a TVM FFI ``Object`` whose
+class name carries the ``Node`` suffix, such as
:cpp:class:`tvm::prim::AddNode`,
+paired with a named managed reference class, such as
:cpp:class:`tvm::prim::Add`.
+A reference class can define its own constructors, operators, and member
functions,
+and inherit from other reference classes to share and specialize its interface.
+It can also impose additional constraints on the node it holds, as described
below.
+The tables list the reference classes; to find the node class behind a
reference,
+check its ``ContainerType`` member. IR reference classes are non-nullable; use
+``ffi::Optional<T>`` when a value may be absent. See also `Object and Class
+<https://tvm.apache.org/ffi/concepts/object_and_class.html>`__.
+
+Besides the named reference for each node, some reference types add
constraints on
+the node they hold. For example, ``TypedExpr<T>`` holds any
+:cpp:class:`tvm::ExprNode` whose ``ty`` field is a ``T``, and
+:cpp:class:`tvm::PrimExpr`, defined as ``TypedExpr<PrimType>``, holds any
+``ExprNode`` whose ``ty`` is a :cpp:class:`tvm::PrimType`. These constraints
are
+defined by the TVM FFI ``TypeTraits`` specialization of the reference type.
+
+Type
+^^^^
+
+.. list-table::
+ :header-rows: 1
+ :widths: 30 70
+
+ * - Class
+ - Description
+ * - :cpp:class:`tvm::Type`
+ - The base class of all types.
+ * - :cpp:class:`tvm::MissingType`
+ - Type information that has not been supplied or computed.
+ * - :cpp:class:`tvm::OpaqueType`
+ - Type marker for opaque values that must be removed from finished IR.
+ * - :cpp:class:`tvm::PrimType`
+ - A primitive scalar or vector data type, including the void sentinel.
+ * - :cpp:class:`tvm::NoneType`
+ - The concrete type whose only value is None.
+ * - :cpp:class:`tvm::AnyType`
+ - The top type, which admits any value.
+ * - :cpp:class:`tvm::TensorRegionType`
+ - The type of a multi-dimensional tensor region.
+ * - :cpp:class:`tvm::StringType`
+ - Semantic string type, independent of the function's calling convention.
+ * - :cpp:class:`tvm::PtrType`
+ - A pointer to an element type in a specified memory scope.
+ * - :cpp:class:`tvm::TupleType`
+ - The type of tuple values.
+ * - :cpp:class:`tvm::FuncType`
+ - Function type.
+
+Expr
+^^^^
+
+.. list-table::
+ :header-rows: 1
+ :widths: 30 70
+
+ * - Class
+ - Description
+ * - :cpp:class:`tvm::Expr`
+ - Base class of typed IR expressions.
+ * - :cpp:class:`tvm::StagingExpr`
+ - A traversable expression eliminated before executable IR.
+ * - :cpp:class:`tvm::OpaqueExpr`
+ - Base class for opaque values that must be removed from finished IR.
+ * - :cpp:class:`tvm::Constant`
+ - Base class of literal constants.
+ * - :cpp:class:`tvm::GenericConst`
+ - A literal payload with an explicit expression type.
+ * - :cpp:class:`tvm::StringImm`
+ - A string literal with StringType.
+ * - :cpp:class:`tvm::DataTypeImm`
+ - A data type literal whose expression type is AnyType.
+ * - :cpp:class:`tvm::IntImm`
+ - Integer constant.
+ * - :cpp:class:`tvm::FloatImm`
+ - Floating-point constant.
+ * - :cpp:class:`tvm::Tuple`
+ - Tuple expression that groups several fields together.
+ * - :cpp:class:`tvm::TupleGetItem`
+ - Get the index-th item from a tuple.
+ * - :cpp:class:`tvm::TensorLoad`
+ - Load an element or vector from an indexed expression source.
+ * - :cpp:class:`tvm::Var`
+ - A local variable in the IR.
+ * - :cpp:class:`tvm::LambdaExpr`
+ - A typed staging expression representing a lambda computation.
+ * - :cpp:class:`tvm::GlobalVar`
+ - A global variable that refers to a function in the module.
+ * - :cpp:class:`tvm::Call`
+ - Call a registered operator or another callable IR expression.
+ * - :cpp:class:`tvm::TensorRegion`
+ - A region of an indexed expression source.
+ * - :cpp:class:`tvm::BaseFunc`
+ - Base class for callable IR function definitions.
+ * - :cpp:class:`tvm::Op`
+ - A registered primitive operator used as a Call callee.
+ * - :cpp:class:`tvm::OpAttrMap`
+ - The values of one operator attribute, keyed by operator.
+
+Stmt
+^^^^
+
+.. list-table::
+ :header-rows: 1
+ :widths: 30 70
+
+ * - Class
+ - Description
+ * - :cpp:class:`tvm::Stmt`
+ - Base class of all statements.
+ * - :cpp:class:`tvm::SeqStmt`
+ - Sequence of statements.
+ * - :cpp:class:`tvm::Bind`
+ - Bind a variable to a value in the enclosing scope.
+ * - :cpp:class:`tvm::RegionStmt`
+ - An operation with enclosing-scope operands and one lexical body.
+ * - :cpp:class:`tvm::AssertStmt`
+ - Check a condition and raise the specified error when it is false.
+ * - :cpp:class:`tvm::TensorStore`
+ - Store a primitive value into a tensor destination.
+ * - :cpp:class:`tvm::Evaluate`
+ - Evaluate an expression for its effects and discard its result.
+ * - :cpp:class:`tvm::If`
+ - Execute one branch according to a boolean condition.
+ * - :cpp:class:`tvm::For`
+ - Loop over an integer range.
+ * - :cpp:class:`tvm::While`
+ - Repeat the body while the condition evaluates to true.
+ * - :cpp:class:`tvm::Return`
+ - Exit the enclosing function with a return value.
+ * - :cpp:class:`tvm::Break`
+ - Exit the innermost enclosing loop.
+ * - :cpp:class:`tvm::Continue`
+ - Skip to the next iteration of the innermost enclosing loop.
+
+Location, IRModule, and Supporting Classes
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. list-table::
+ :header-rows: 1
+ :widths: 30 70
+
+ * - Class
+ - Description
+ * - :cpp:class:`tvm::SourceName`
+ - An identifier for a source location.
+ * - :cpp:class:`tvm::Location`
+ - Source-location metadata attached to IR nodes.
+ * - :cpp:class:`tvm::UnknownLoc`
+ - The location used when source information is unavailable.
+ * - :cpp:class:`tvm::SourceLoc`
+ - A source range in frontend coordinates.
+ * - :cpp:class:`tvm::CallSiteLoc`
+ - A callee's source location together with its caller's location.
+ * - :cpp:class:`tvm::IRModule`
+ - A collection of global functions and module-level metadata; the basic
unit of IR transformations.
+ * - :cpp:class:`tvm::GlobalInfo`
+ - Base class for module-level information referenced by the IR.
+ * - :cpp:class:`tvm::Attrs`
+ - Base class for structured operator and function attributes.
+ * - :cpp:class:`tvm::DictAttrs`
+ - A string-keyed attribute map for functions, modules, and calls.
+ * - :cpp:class:`tvm::EnvFunc`
+ - A registered global function referenced and serialized by name.
+ * - :cpp:class:`tvm::Range`
+ - A half-open interval stored as begin and extent.
+
+Tensor Program
+^^^^^^^^^^^^^^
+
+.. list-table::
+ :header-rows: 1
+ :widths: 30 70
+
+ * - Class
+ - Description
+ * - :cpp:class:`tvm::tirx::TensorType`
+ - Type of a tensor value: shape, dtype, and memory scope.
+ * - :cpp:class:`tvm::tirx::TensorMapType`
+ - Type of a hardware tensor map (TMA descriptor).
+ * - :cpp:class:`tvm::tirx::ThreadScope`
+ - Canonical thread-scope identity, named as backend.scope.
+ * - :cpp:class:`tvm::tirx::IndexMap`
+ - Mapping between index spaces used for layout transforms.
+ * - :cpp:class:`tvm::tirx::CallFFIKernelAttr`
+ - Attributes describing an FFI kernel call and its launch values.
+ * - :cpp:class:`tvm::tirx::Layout`
+ - Base reference for tensor-program coordinate layouts.
+ * - :cpp:class:`tvm::tirx::TileLayout`
+ - Tiled layout over hardware and memory axes.
+ * - :cpp:class:`tvm::tirx::ComposeLayout`
+ - Tile layout composed with an XOR swizzle on the memory coordinate.
+ * - :cpp:class:`tvm::tirx::TensorVar`
+ - Variable bound to a tensor.
+ * - :cpp:class:`tvm::tirx::Function`
+ - TIRx tensor-program function.
+
+
+.. _cpp-full-api-index:
+
+Full API Index
+--------------
+
+`Browse the full API index <generated/index.html>`__
diff --git a/docs/reference/python/index.rst b/docs/reference/python/index.rst
index 6ef4dba1..162d3a8d 100644
--- a/docs/reference/python/index.rst
+++ b/docs/reference/python/index.rst
@@ -40,14 +40,14 @@ Namespaces
- Primitive expressions and scalar operators.
* - :doc:`tvm_tirx.ir.transform <ir.transform>`
- Pass infrastructure and instrumentation.
+ * - :doc:`tvm_tirx.sym <sym>`
+ - Symbolic arithmetic, analysis, and simplification.
* - :doc:`tvm_tirx.script <script>`
- Python syntax registration for IR dialects.
* - :doc:`tvm_tirx.script.parser <script.parser>`
- Translate Python scripts into IR builder operations.
* - :doc:`tvm_tirx.script.ir_builder <script.ir_builder>`
- Shared IR builder contexts and statements.
- * - :doc:`tvm_tirx.sym <sym>`
- - Symbolic arithmetic, analysis, and simplification.
* - :doc:`tvm_tirx.target <target>`
- Compilation targets and device selection.
* - :doc:`tvm_tirx.tirx <tirx>`
@@ -116,10 +116,10 @@ Namespaces
tvm_tirx.ir <ir>
tvm_tirx.ir.prim <ir.prim>
tvm_tirx.ir.transform <ir.transform>
+ tvm_tirx.sym <sym>
tvm_tirx.script <script>
tvm_tirx.script.parser <script.parser>
tvm_tirx.script.ir_builder <script.ir_builder>
- tvm_tirx.sym <sym>
tvm_tirx.target <target>
tvm_tirx.tirx <tirx>
tvm_tirx.tirx.op <tirx.op>
diff --git a/include/tvm/ir/pattern_match.h b/include/tvm/ir/pattern_match.h
index b903dc4d..0e28aa6d 100644
--- a/include/tvm/ir/pattern_match.h
+++ b/include/tvm/ir/pattern_match.h
@@ -21,18 +21,20 @@
* \file tvm/ir/pattern_match.h
* \brief Shared expression-template pattern and capture protocol.
*
- * \code
- * #include <tvm/ir/prim/pattern_match.h>
+ * \rst
+ * .. code-block:: cpp
*
- * void MatchMultiplyAdd(const tvm::PrimExpr& expr) {
- * tvm::PVar<tvm::PrimExpr> a, b, c;
- * if ((a * b + c).Match(expr)) {
- * tvm::PrimExpr lhs = a.Eval();
- * tvm::PrimExpr rhs = b.Eval();
- * tvm::PrimExpr addend = c.Eval();
+ * #include <tvm/ir/prim/pattern_match.h>
+ *
+ * void MatchMultiplyAdd(const tvm::PrimExpr& expr) {
+ * tvm::PVar<tvm::PrimExpr> a, b, c;
+ * if ((a * b + c).Match(expr)) {
+ * tvm::PrimExpr lhs = a.Eval();
+ * tvm::PrimExpr rhs = b.Eval();
+ * tvm::PrimExpr addend = c.Eval();
+ * }
* }
- * }
- * \endcode
+ * \endrst
*/
#ifndef TVM_IR_PATTERN_MATCH_H_
#define TVM_IR_PATTERN_MATCH_H_
diff --git a/include/tvm/ir/prim/pattern_match.h
b/include/tvm/ir/prim/pattern_match.h
index 62506abb..9ed652f6 100644
--- a/include/tvm/ir/prim/pattern_match.h
+++ b/include/tvm/ir/prim/pattern_match.h
@@ -28,33 +28,35 @@
*
* The code below shows how to use the pattern matcher.
*
- * \code
+ * \rst
+ * .. code-block:: cpp
*
- * // max(x + z, y + z) => max(x, y) + z
- * tvm::PVar<PrimExpr> x, y, z;
*
- * // The following code tries to match the declared pattern.
- * // Match will fill the result of match into PVar if successful.
- * // Note that z occurs twice in the pattern,
- * // an equality check is performed to ensure each occurance of z
- * // is equivalent to each other.
- * if (max(x + z, y + z).Match(expr)) {
- * // Eval evaluates a pattern with the current matched value.
- * // The filled value is valid until the next call to Match.
- * return (max(x, y) + z).Eval();
- * }
+ * // max(x + z, y + z) => max(x, y) + z
+ * tvm::PVar<PrimExpr> x, y, z;
*
- * tvm::PrimVar tx("tx"), ty("ty");
- * tvm::PVar<IntImm> c;
- * tvm::PVar<Var> v;
- * // We can match integer and Var, both of which are
- * // special case container of Expr
- * TVM_FFI_ICHECK((v * c).Match(tx * 3));
- * TVM_FFI_ICHECK_EQ(c.Eval()->value, 3);
- * // cannot match c to ty
- * TVM_FFI_ICHECK(!(v * c).Match(tx * ty));
+ * // The following code tries to match the declared pattern.
+ * // Match will fill the result of match into PVar if successful.
+ * // Note that z occurs twice in the pattern,
+ * // an equality check is performed to ensure each occurance of z
+ * // is equivalent to each other.
+ * if (max(x + z, y + z).Match(expr)) {
+ * // Eval evaluates a pattern with the current matched value.
+ * // The filled value is valid until the next call to Match.
+ * return (max(x, y) + z).Eval();
+ * }
*
- * \endcode
+ * tvm::PrimVar tx("tx"), ty("ty");
+ * tvm::PVar<IntImm> c;
+ * tvm::PVar<Var> v;
+ * // We can match integer and Var, both of which are
+ * // special case container of Expr
+ * TVM_FFI_ICHECK((v * c).Match(tx * 3));
+ * TVM_FFI_ICHECK_EQ(c.Eval()->value, 3);
+ * // cannot match c to ty
+ * TVM_FFI_ICHECK(!(v * c).Match(tx * ty));
+ *
+ * \endrst
*
* \note The pattern matcher is not threadsafe,
* do not use the same PVar in multiple threads.
@@ -369,7 +371,7 @@ class PSelectExpr : public Pattern<PSelectExpr<TCond, TA,
TB>> {
*
* \param condition The condition expression.
* \param true_value The value when condition is true.
- * \param true_value The value when condition is false.
+ * \param false_value The value when condition is false.
*
* \return The result pattern.
*
@@ -651,7 +653,7 @@ struct PIfThenElseOp {
*
* \param cond The condition expression.
* \param true_value The value when condition is true.
- * \param true_value The value when condition is false.
+ * \param false_value The value when condition is false.
*
* \return The result pattern.
*
diff --git a/include/tvm/script/printer/doc.h b/include/tvm/script/printer/doc.h
index 16aff11d..ea44c9fa 100644
--- a/include/tvm/script/printer/doc.h
+++ b/include/tvm/script/printer/doc.h
@@ -519,7 +519,7 @@ class CallDoc : public ExprDoc {
* \param callee The callee of this function call.
* \param args The positional arguments.
* \param kwargs_keys Keys of keyword arguments.
- * \param kwargs_values Values of keyword arguments, must have the same
length as `kwargs_keys.
+ * \param kwargs_values Values of keyword arguments, must have the same
length as `kwargs_keys`.
*/
TVM_TIRX_DLL CallDoc(ExprDoc callee, ffi::Array<ExprDoc> args,
ffi::Array<ffi::String> kwargs_keys,
ffi::Array<ExprDoc> kwargs_values);
diff --git a/include/tvm/script/printer/doc_translator.h
b/include/tvm/script/printer/doc_translator.h
index 3287aac9..bea18b99 100644
--- a/include/tvm/script/printer/doc_translator.h
+++ b/include/tvm/script/printer/doc_translator.h
@@ -413,8 +413,8 @@ inline ffi::Array<StmtDoc> ToStmtDocArray(const
ffi::List<Doc>& docs) {
class DocTranslator : public ffi::ObjectRef {
public:
/*!
- * \brief Retain a translation context.
- * \param n The context object.
+ * \brief Initialize a reference to a translation context.
+ * \param tag The unsafe-initialization tag.
*/
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(DocTranslator, ffi::ObjectRef,
DocTranslatorObj);
};
diff --git a/include/tvm/support/bytes_io.h b/include/tvm/support/bytes_io.h
index 23339363..37796d4b 100644
--- a/include/tvm/support/bytes_io.h
+++ b/include/tvm/support/bytes_io.h
@@ -43,8 +43,10 @@ namespace support {
*/
class BytesInStream : public Stream {
public:
+ /// \cond Doxygen_Suppress
using Stream::Read;
using Stream::Write;
+ /// \endcond
BytesInStream(const void* data, size_t size)
: data_(reinterpret_cast<const char*>(data)), size_(size), pos_(0) {}
@@ -77,8 +79,10 @@ class BytesInStream : public Stream {
*/
class BytesOutStream : public Stream {
public:
+ /// \cond Doxygen_Suppress
using Stream::Read;
using Stream::Write;
+ /// \endcond
explicit BytesOutStream(std::string* buffer) : buffer_(buffer) {}
diff --git a/include/tvm/tirx/layout.h b/include/tvm/tirx/layout.h
index cadee745..32547409 100644
--- a/include/tvm/tirx/layout.h
+++ b/include/tvm/tirx/layout.h
@@ -47,13 +47,14 @@ class Iter;
using ffi::Array;
using ffi::Tuple;
-// Base class for layout
+/*! \brief Base object for tensor-program coordinate layouts. */
class LayoutNode : public ffi::Object {
public:
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind =
kTVMFFISEqHashKindTreeNode;
TVM_FFI_DECLARE_OBJECT_INFO("tirx.Layout", LayoutNode, ffi::Object);
};
+/*! \brief Managed reference to a tensor-program coordinate layout. */
class Layout : public ffi::ObjectRef {
public:
/*! \brief Verify if the layout is well-formed */
diff --git a/include/tvm/tirx/op/memory.h b/include/tvm/tirx/op/memory.h
index 68769721..df7a040d 100644
--- a/include/tvm/tirx/op/memory.h
+++ b/include/tvm/tirx/op/memory.h
@@ -58,7 +58,7 @@ TVM_TIRX_DLL const Op& reinterpret_op();
/*!
* \brief perform reinterpret cast value to type.
*
- * \param t the target type.
+ * \param target_ty The target type.
* \param value The value
* \param loc The location of this operation in the source.
* \return The result expression.
diff --git a/include/tvm/tirx/stmt_functor_with_analyzer.h
b/include/tvm/tirx/stmt_functor_with_analyzer.h
index 62535ac9..154fd433 100644
--- a/include/tvm/tirx/stmt_functor_with_analyzer.h
+++ b/include/tvm/tirx/stmt_functor_with_analyzer.h
@@ -46,7 +46,9 @@ class TVM_TIRX_DLL StmtExprVisitorWithAnalyzer : public
StmtExprVisitor {
PrimExpr Simplify(const PrimExpr& expr) { return analyzer_->Simplify(expr); }
+ /// \cond Doxygen_Suppress
using StmtExprVisitor::Visit_;
+ /// \endcond
ffi::Optional<VisitInterrupt> Visit_(const ForNode* op);
ffi::Optional<VisitInterrupt> Visit_(const BindNode* op);
@@ -89,7 +91,9 @@ class TVM_TIRX_DLL StmtExprVisitorWithAnalyzer : public
StmtExprVisitor {
class TVM_TIRX_DLL StmtExprMutatorWithAnalyzer : public StmtExprMutator {
public:
using StmtExprMutator::Mutate;
+ /// \cond Doxygen_Suppress
using StmtExprMutator::Mutate_;
+ /// \endcond
explicit StmtExprMutatorWithAnalyzer(const sym::Analyzer& analyzer)
: StmtExprMutatorWithAnalyzer(analyzer.get()) {}
explicit StmtExprMutatorWithAnalyzer(sym::AnalyzerObj* analyzer)
@@ -139,7 +143,7 @@ class TVM_TIRX_DLL StmtExprMutatorWithAnalyzer : public
StmtExprMutator {
ffi::Array<PrimExpr> iter_predicates_;
/*!
* \brief Run callback while trying to record iter predicate
- * \param conditon Condition to be checked.
+ * \param condition Condition to be checked.
* \param callback The callback to be called.
*/
template <typename FLambda>
diff --git a/pyproject.toml b/pyproject.toml
index 464e1b82..3be00098 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -75,7 +75,14 @@ test = [
]
lint = ["ruff", "pre-commit"]
dev = [{ include-group = "test" }, { include-group = "lint" }]
-docs = ["sphinx>=7", "sphinx-book-theme", "sphinx-autobuild", "pytest"]
+docs = [
+ "sphinx>=7",
+ "sphinx-book-theme",
+ "sphinx-autobuild",
+ "pytest",
+ "breathe!=5.0.0",
+ "exhale",
+]
[project.scripts]
tvm-tirx-config = "tvm_tirx.config:__main__"
diff --git a/tests/scripts/task_python_docs.sh
b/tests/scripts/task_python_docs.sh
index 8ce7be6b..24ac6c61 100755
--- a/tests/scripts/task_python_docs.sh
+++ b/tests/scripts/task_python_docs.sh
@@ -22,6 +22,6 @@ source ./tests/scripts/test_task_install_dist_wheels.sh
uv pip install --python python3 --target .local/python --group docs
export TVM_TIRX_LIBRARY_PATH="$PWD/.local/python/tvm_tirx/lib"
rm -rf docs/_build docs/reference/python/generated
-python3 -m sphinx -E -a -b html -d docs/_build/doctrees -W --keep-going docs
docs/_build/html
+BUILD_CPP_DOCS=1 python3 -m sphinx -E -a -b html -d docs/_build/doctrees -W
--keep-going docs docs/_build/html
git rev-parse HEAD > docs/_build/html/commit_hash
tar -czf docs.tgz -C docs/_build/html .