You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by tq...@apache.org on 2024/08/22 22:17:02 UTC
(tvm) branch main updated: [Docs] Introduce Relax API and move legacy part to standalone page (#17286)
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.git
The following commit(s) were added to refs/heads/main by this push:
new 9e865b4b8f [Docs] Introduce Relax API and move legacy part to standalone page (#17286)
9e865b4b8f is described below
commit 9e865b4b8fdf4cc624e94f8db9e5674c4519db05
Author: Siyuan Feng <Hz...@sjtu.edu.cn>
AuthorDate: Fri Aug 23 06:16:56 2024 +0800
[Docs] Introduce Relax API and move legacy part to standalone page (#17286)
* [Docs] Introduce Relax API and move legacy part to standalone page
As the TVM project evolves, the Unity strategy has been the recommended
way to use Apache TVM applications. Hence, we are pushing documentation
for the Relax API to the forefront and moving the legacy part to a
standalone page, which may be removed in the future.
* update for ci
* update for ci
---
docs/arch/index.rst | 9 --
docs/conf.py | 41 ++++++++
docs/dev/how_to/relay_add_op.rst | 6 +-
docs/index.rst | 20 ++--
.../api/python/{runtime.rst => dlight.rst} | 9 +-
docs/reference/api/python/index.rst | 113 +++++++++++++++------
.../api/python/{runtime.rst => instrument.rst} | 9 +-
docs/reference/api/python/ir.rst | 16 ---
.../api/python/{runtime.rst => relax/analysis.rst} | 9 +-
.../{runtime.rst => relax/block_builder.rst} | 10 +-
.../api/python/{tir.rst => relax/frontend.rst} | 42 ++++----
.../reference/api/python/{tir.rst => relax/op.rst} | 60 +++++++----
.../{relay/transform.rst => relax/relax.rst} | 9 +-
.../python/{runtime.rst => relax/transform.rst} | 9 +-
docs/reference/api/python/relay/transform.rst | 1 +
.../{relay/transform.rst => runtime/disco.rst} | 8 +-
.../reference/api/python/{ => runtime}/ndarray.rst | 6 --
.../{relay/transform.rst => runtime/profiling.rst} | 9 +-
.../{relay/transform.rst => runtime/relax_vm.rst} | 9 +-
.../reference/api/python/{ => runtime}/runtime.rst | 3 -
.../api/python/{runtime.rst => tir/analysis.rst} | 10 +-
.../{relay/transform.rst => tir/schedule.rst} | 8 +-
.../python/{runtime.rst => tir/stmt_functor.rst} | 10 +-
.../api/python/{runtime.rst => tir/tir.rst} | 10 +-
.../api/python/{runtime.rst => tir/transform.rst} | 8 +-
.../api/python/{runtime.rst => transform.rst} | 9 +-
docs/reference/api/python/vta/index.rst | 45 --------
docs/{arch => reference}/security.rst | 0
python/tvm/driver/build_module.py | 4 +-
python/tvm/relax/op/create.py | 2 +-
python/tvm/relax/transform/transform.py | 27 ++---
python/tvm/runtime/profiling/__init__.py | 3 +-
python/tvm/target/__init__.py | 2 +-
python/tvm/te/operation.py | 2 +-
python/tvm/tir/buffer.py | 2 +-
35 files changed, 269 insertions(+), 271 deletions(-)
diff --git a/docs/arch/index.rst b/docs/arch/index.rst
index b84afeea28..17884a7742 100644
--- a/docs/arch/index.rst
+++ b/docs/arch/index.rst
@@ -408,15 +408,6 @@ Frontends ingest models from different frameworks into the TVM stack.
frontend/tensorflow
-
-Security
----------
-.. toctree::
- :maxdepth: 1
-
- security
-
-
microTVM
--------
.. toctree::
diff --git a/docs/conf.py b/docs/conf.py
index c3472c15de..1c5c5cb5d6 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -39,6 +39,7 @@ from pathlib import Path
import re
import sys
from textwrap import dedent, indent
+from typing import List
from unittest.mock import patch
# If extensions (or modules to document with autodoc) are in another directory,
@@ -718,10 +719,50 @@ def update_alias_docstring(name, obj, lines):
lines.append(".. rubric:: Alias of %s:`%s.%s`" % (obj_type, amod, target_name))
+tvm_class_name_rewrite_map = {
+ "tvm.tir": ["Var", "Call"],
+ "tvm.relax": ["Var", "Call"],
+ "tvm.relax.frontend.nn": ["Module"],
+}
+
+
+def distinguish_class_name(name: str, lines: List[str]):
+ """Distinguish the docstring of type annotations.
+
+ In the whole TVM, there are many classes with the same name but in different modules,
+ e.g. ``tir.Var``, ``relax.Var``. This function is used to distinguish them in the docstring,
+ by adding the module name as prefix.
+
+ To be specific, this function will check the current object name, and if it in the specific
+ module with specific name, it will add the module name as prefix to the class name to prevent
+ the confusion. Further, we only add the prefix to those standalone class name, but skip
+ the pattern of `xx.Var`, `Var.xx` and `xx.Var.xx`.
+
+ Parameters
+ ----------
+ name : str
+ The full name of the object in the doc.
+
+ lines : list
+ The docstring lines, need to be modified inplace.
+ """
+ remap = {}
+ for module_name in tvm_class_name_rewrite_map:
+ if name.startswith(module_name):
+ short_name = module_name[4:] if module_name.startswith("tvm.") else module_name
+ for class_name in tvm_class_name_rewrite_map[module_name]:
+ remap.update({class_name: f"{short_name}.{class_name}"})
+
+ for k, v in remap.items():
+ for i in range(len(lines)):
+ lines[i] = re.sub(rf"(?<!\.)\b{k}\b(?!\.)", v, lines[i])
+
+
def process_docstring(app, what, name, obj, options, lines):
"""Sphinx callback to process docstring"""
if callable(obj) or inspect.isclass(obj):
update_alias_docstring(name, obj, lines)
+ distinguish_class_name(name, lines)
from legacy_redirect import build_legacy_redirect
diff --git a/docs/dev/how_to/relay_add_op.rst b/docs/dev/how_to/relay_add_op.rst
index df0a4f7286..39c6a2c480 100644
--- a/docs/dev/how_to/relay_add_op.rst
+++ b/docs/dev/how_to/relay_add_op.rst
@@ -196,14 +196,12 @@ on how to do this, we recommend looking up the tutorials on :ref:`tensor
expressions <tutorial-tensor-expr-get-started>`, :ref:`TVM's operator inventory
(topi) <tutorial-topi>` and looking at the example cumulative sum and product
implementations found in `python/tvm/topi/scan.py`_ and the gpu versions in
-`python/tvm/topi/cuda/scan.py`_. In the case of our cumulative sum and product
-operations we write things directly in :ref:`TIR <api-python-tir>` which is the
-representation where tensor expressions and topi will lower into.
+`python/tvm/topi/cuda/scan.py`_.
.. _python/tvm/topi/scan.py: https://github.com/apache/tvm/blob/main/python/tvm/topi/scan.py
.. _python/tvm/topi/cuda/scan.py: https://github.com/apache/tvm/blob/main/python/tvm/topi/cuda/scan.py
-5. Hooking up Compute and Strategy with Relay
+1. Hooking up Compute and Strategy with Relay
---------------------------------------------
After you have implemented your compute function we now need to glue it to our
diff --git a/docs/index.rst b/docs/index.rst
index 7f13101f74..2b7896c652 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -52,23 +52,29 @@ driving its costs down.
.. toctree::
:maxdepth: 1
- :caption: Architecture Guide
+ :caption: API Reference
- arch/index
+ reference/api/python/index
+ reference/api/links
.. toctree::
:maxdepth: 1
- :caption: Topic Guides
+ :caption: Legacy
+ reference/langref/index
+ arch/index
topic/microtvm/index
topic/vta/index
.. toctree::
:maxdepth: 1
- :caption: Reference Guide
+ :caption: About
- reference/langref/index
- reference/api/python/index
- reference/api/links
reference/publications
+ reference/security
+
+.. toctree::
+ :maxdepth: 1
+ :caption: Index
+
genindex
diff --git a/docs/reference/api/python/runtime.rst b/docs/reference/api/python/dlight.rst
similarity index 89%
copy from docs/reference/api/python/runtime.rst
copy to docs/reference/api/python/dlight.rst
index c51a2d4520..37859ed790 100644
--- a/docs/reference/api/python/runtime.rst
+++ b/docs/reference/api/python/dlight.rst
@@ -15,11 +15,8 @@
specific language governing permissions and limitations
under the License.
-tvm.runtime
------------
-
-.. automodule:: tvm.runtime
+tvm.dlight
+----------
+.. automodule:: tvm.dlight
:members:
:imported-members:
- :exclude-members: NDArray
- :autosummary:
diff --git a/docs/reference/api/python/index.rst b/docs/reference/api/python/index.rst
index 5dc1ed806d..e64ea304cb 100644
--- a/docs/reference/api/python/index.rst
+++ b/docs/reference/api/python/index.rst
@@ -18,34 +18,89 @@
Python API
==========
+.. toctree::
+ :maxdepth: 1
+ :caption: tvm
+
+ error
+ ir
+ instrument
+ transform
+ target
+ driver
+
+.. toctree::
+ :maxdepth: 1
+ :caption: tvm.runtime
+
+ runtime/runtime
+ runtime/ndarray
+ runtime/relax_vm
+ runtime/disco
+ runtime/profiling
+
+.. toctree::
+ :maxdepth: 1
+ :caption: tvm.relax
+
+ relax/relax
+ relax/analysis
+ relax/block_builder
+ relax/frontend
+ relax/op
+ relax/transform
+
+.. toctree::
+ :maxdepth: 1
+ :caption: tvm.tir
+
+ tir/tir
+ tir/analysis
+ tir/schedule
+ tir/stmt_functor
+ tir/transform
+
+.. toctree::
+ :maxdepth: 1
+ :caption: tvm.te
+
+ te
+ topi
+
+.. toctree::
+ :maxdepth: 1
+ :caption: tvm.meta_schedule
+
+ meta_schedule
+
+.. toctree::
+ :maxdepth: 1
+ :caption: tvm.dlight
+
+ dlight
+
+.. toctree::
+ :maxdepth: 1
+ :caption: Misc
+
+ rpc
+ contrib
.. toctree::
- :maxdepth: 2
-
- runtime
- ndarray
- error
- ir
- target
- tir
- te
- driver
- relay/index
- relay/frontend
- relay/nn
- relay/vision
- relay/image
- relay/transform
- relay/analysis
- relay/backend
- relay/dataflow_pattern
- relay/testing
- autotvm
- auto_scheduler
- meta_schedule
- rpc
- micro
- contrib
- graph_executor
- topi
- vta/index
+ :maxdepth: 1
+ :caption: Legacy
+
+ relay/index
+ relay/frontend
+ relay/nn
+ relay/vision
+ relay/image
+ relay/transform
+ relay/analysis
+ relay/backend
+ relay/dataflow_pattern
+ relay/testing
+ autotvm
+ auto_scheduler
+ micro
+ graph_executor
diff --git a/docs/reference/api/python/runtime.rst b/docs/reference/api/python/instrument.rst
similarity index 89%
copy from docs/reference/api/python/runtime.rst
copy to docs/reference/api/python/instrument.rst
index c51a2d4520..270a19690b 100644
--- a/docs/reference/api/python/runtime.rst
+++ b/docs/reference/api/python/instrument.rst
@@ -15,11 +15,8 @@
specific language governing permissions and limitations
under the License.
-tvm.runtime
------------
-
-.. automodule:: tvm.runtime
+tvm.instrument
+--------------
+.. automodule:: tvm.instrument
:members:
:imported-members:
- :exclude-members: NDArray
- :autosummary:
diff --git a/docs/reference/api/python/ir.rst b/docs/reference/api/python/ir.rst
index e7fb3c1146..1f0dc0c5e2 100644
--- a/docs/reference/api/python/ir.rst
+++ b/docs/reference/api/python/ir.rst
@@ -21,19 +21,3 @@ tvm.ir
:members:
:imported-members:
:autosummary:
-
-
-tvm.instrument
---------------
-.. automodule:: tvm.instrument
- :members:
- :imported-members:
- :autosummary:
-
-
-tvm.transform
--------------
-.. automodule:: tvm.transform
- :members:
- :imported-members:
- :autosummary:
diff --git a/docs/reference/api/python/runtime.rst b/docs/reference/api/python/relax/analysis.rst
similarity index 89%
copy from docs/reference/api/python/runtime.rst
copy to docs/reference/api/python/relax/analysis.rst
index c51a2d4520..b6598b5457 100644
--- a/docs/reference/api/python/runtime.rst
+++ b/docs/reference/api/python/relax/analysis.rst
@@ -15,11 +15,8 @@
specific language governing permissions and limitations
under the License.
-tvm.runtime
------------
-
-.. automodule:: tvm.runtime
+tvm.relax.analysis
+------------------
+.. automodule:: tvm.relax.analysis
:members:
:imported-members:
- :exclude-members: NDArray
- :autosummary:
diff --git a/docs/reference/api/python/runtime.rst b/docs/reference/api/python/relax/block_builder.rst
similarity index 87%
copy from docs/reference/api/python/runtime.rst
copy to docs/reference/api/python/relax/block_builder.rst
index c51a2d4520..a1c2a7c435 100644
--- a/docs/reference/api/python/runtime.rst
+++ b/docs/reference/api/python/relax/block_builder.rst
@@ -15,11 +15,7 @@
specific language governing permissions and limitations
under the License.
-tvm.runtime
------------
-
-.. automodule:: tvm.runtime
+tvm.relax.block_builder
+-----------------------
+.. automodule:: tvm.relax.block_builder
:members:
- :imported-members:
- :exclude-members: NDArray
- :autosummary:
diff --git a/docs/reference/api/python/tir.rst b/docs/reference/api/python/relax/frontend.rst
similarity index 63%
copy from docs/reference/api/python/tir.rst
copy to docs/reference/api/python/relax/frontend.rst
index 2152be69ea..c037f323ed 100644
--- a/docs/reference/api/python/tir.rst
+++ b/docs/reference/api/python/relax/frontend.rst
@@ -15,36 +15,34 @@
specific language governing permissions and limitations
under the License.
-.. _api-python-tir:
-
-tvm.tir
--------
-.. automodule:: tvm.tir
+tvm.relax.frontend
+------------------
+.. automodule:: tvm.relax.frontend
:members:
:imported-members:
- :exclude-members: PrimExpr, const
- :autosummary:
-
-tvm.tir.transform
------------------
-.. automodule:: tvm.tir.transform
+tvm.relax.frontend.nn
+*********************
+.. automodule:: tvm.relax.frontend.nn
:members:
:imported-members:
- :autosummary:
-
+ :exclude-members: BlockBuilder
+ :noindex:
-tvm.tir.analysis
-----------------
-.. automodule:: tvm.tir.analysis
+tvm.relax.frontend.onnx
+***********************
+.. automodule:: tvm.relax.frontend.onnx
:members:
:imported-members:
- :noindex: Buffer, Stmt
- :autosummary:
+tvm.relax.frontend.stablehlo
+****************************
+.. automodule:: tvm.relax.frontend.stablehlo
+ :members:
+ :imported-members:
-tvm.tir.stmt_functor
---------------------
-.. automodule:: tvm.tir.stmt_functor
+tvm.relax.frontend.torch
+************************
+.. automodule:: tvm.relax.frontend.torch
:members:
- :autosummary:
+ :imported-members:
diff --git a/docs/reference/api/python/tir.rst b/docs/reference/api/python/relax/op.rst
similarity index 52%
rename from docs/reference/api/python/tir.rst
rename to docs/reference/api/python/relax/op.rst
index 2152be69ea..21f638442a 100644
--- a/docs/reference/api/python/tir.rst
+++ b/docs/reference/api/python/relax/op.rst
@@ -15,36 +15,58 @@
specific language governing permissions and limitations
under the License.
-.. _api-python-tir:
+tvm.relax.op
+------------
-tvm.tir
--------
-.. automodule:: tvm.tir
+tvm.relax.op
+************
+.. automodule:: tvm.relax.op
:members:
:imported-members:
- :exclude-members: PrimExpr, const
- :autosummary:
+tvm.relax.op.nn
+***************
+.. automodule:: tvm.relax.op.nn
+ :members:
+ :imported-members:
+
+tvm.relax.op.builtin
+********************
+.. automodule:: tvm.relax.op.builtin
+ :members:
+ :imported-members:
+
+tvm.relax.op.ccl
+****************
+.. automodule:: tvm.relax.op.ccl
+ :members:
+ :imported-members:
-tvm.tir.transform
------------------
-.. automodule:: tvm.tir.transform
+tvm.relax.op.distributed
+************************
+.. automodule:: tvm.relax.op.distributed
:members:
:imported-members:
- :autosummary:
+tvm.relax.op.grad
+*****************
+.. automodule:: tvm.relax.op.grad
+ :members:
+ :imported-members:
-tvm.tir.analysis
-----------------
-.. automodule:: tvm.tir.analysis
+tvm.relax.op.image
+******************
+.. automodule:: tvm.relax.op.image
:members:
:imported-members:
- :noindex: Buffer, Stmt
- :autosummary:
+tvm.relax.op.memory
+*******************
+.. automodule:: tvm.relax.op.memory
+ :members:
+ :imported-members:
-tvm.tir.stmt_functor
---------------------
-.. automodule:: tvm.tir.stmt_functor
+tvm.relax.op.op_attrs
+*********************
+.. automodule:: tvm.relax.op.op_attrs
:members:
- :autosummary:
diff --git a/docs/reference/api/python/relay/transform.rst b/docs/reference/api/python/relax/relax.rst
similarity index 86%
copy from docs/reference/api/python/relay/transform.rst
copy to docs/reference/api/python/relax/relax.rst
index c66904d8bc..4df1f1279b 100644
--- a/docs/reference/api/python/relay/transform.rst
+++ b/docs/reference/api/python/relax/relax.rst
@@ -15,10 +15,9 @@
specific language governing permissions and limitations
under the License.
-tvm.relay.transform
-----------------------
-
-.. automodule:: tvm.relay.transform
+tvm.relax
+---------
+.. automodule:: tvm.relax
:members:
:imported-members:
- :autosummary:
+ :exclude-members: BlockBuilder, Span, GlobalVar, SourceName, TupleType, Type, FuncType
diff --git a/docs/reference/api/python/runtime.rst b/docs/reference/api/python/relax/transform.rst
similarity index 88%
copy from docs/reference/api/python/runtime.rst
copy to docs/reference/api/python/relax/transform.rst
index c51a2d4520..dcb41e80fd 100644
--- a/docs/reference/api/python/runtime.rst
+++ b/docs/reference/api/python/relax/transform.rst
@@ -15,11 +15,10 @@
specific language governing permissions and limitations
under the License.
-tvm.runtime
------------
+.. _api-relax-transformation:
-.. automodule:: tvm.runtime
+tvm.relax.transform
+-------------------
+.. automodule:: tvm.relax.transform
:members:
:imported-members:
- :exclude-members: NDArray
- :autosummary:
diff --git a/docs/reference/api/python/relay/transform.rst b/docs/reference/api/python/relay/transform.rst
index c66904d8bc..4a8747606e 100644
--- a/docs/reference/api/python/relay/transform.rst
+++ b/docs/reference/api/python/relay/transform.rst
@@ -22,3 +22,4 @@ tvm.relay.transform
:members:
:imported-members:
:autosummary:
+ :exclude-members: FunctionPass
diff --git a/docs/reference/api/python/relay/transform.rst b/docs/reference/api/python/runtime/disco.rst
similarity index 89%
copy from docs/reference/api/python/relay/transform.rst
copy to docs/reference/api/python/runtime/disco.rst
index c66904d8bc..6a9b603947 100644
--- a/docs/reference/api/python/relay/transform.rst
+++ b/docs/reference/api/python/runtime/disco.rst
@@ -15,10 +15,8 @@
specific language governing permissions and limitations
under the License.
-tvm.relay.transform
-----------------------
-
-.. automodule:: tvm.relay.transform
+tvm.runtime.disco
+-----------------
+.. automodule:: tvm.runtime.disco
:members:
:imported-members:
- :autosummary:
diff --git a/docs/reference/api/python/ndarray.rst b/docs/reference/api/python/runtime/ndarray.rst
similarity index 88%
rename from docs/reference/api/python/ndarray.rst
rename to docs/reference/api/python/runtime/ndarray.rst
index aa828905ca..8c794f04b1 100644
--- a/docs/reference/api/python/ndarray.rst
+++ b/docs/reference/api/python/runtime/ndarray.rst
@@ -18,10 +18,4 @@
tvm.runtime.ndarray
-------------------
.. automodule:: tvm.runtime.ndarray
-
-.. autoclass:: tvm.nd.NDArray
:members:
- :inherited-members:
-
-.. autofunction:: tvm.nd.array
-.. autofunction:: tvm.nd.empty
diff --git a/docs/reference/api/python/relay/transform.rst b/docs/reference/api/python/runtime/profiling.rst
similarity index 87%
copy from docs/reference/api/python/relay/transform.rst
copy to docs/reference/api/python/runtime/profiling.rst
index c66904d8bc..d26f00af90 100644
--- a/docs/reference/api/python/relay/transform.rst
+++ b/docs/reference/api/python/runtime/profiling.rst
@@ -15,10 +15,7 @@
specific language governing permissions and limitations
under the License.
-tvm.relay.transform
-----------------------
-
-.. automodule:: tvm.relay.transform
+tvm.runtime.profiling
+---------------------
+.. automodule:: tvm.runtime.profiling
:members:
- :imported-members:
- :autosummary:
diff --git a/docs/reference/api/python/relay/transform.rst b/docs/reference/api/python/runtime/relax_vm.rst
similarity index 87%
copy from docs/reference/api/python/relay/transform.rst
copy to docs/reference/api/python/runtime/relax_vm.rst
index c66904d8bc..75afcb7939 100644
--- a/docs/reference/api/python/relay/transform.rst
+++ b/docs/reference/api/python/runtime/relax_vm.rst
@@ -15,10 +15,7 @@
specific language governing permissions and limitations
under the License.
-tvm.relay.transform
-----------------------
-
-.. automodule:: tvm.relay.transform
+tvm.runtime.relax_vm
+--------------------
+.. automodule:: tvm.runtime.relax_vm
:members:
- :imported-members:
- :autosummary:
diff --git a/docs/reference/api/python/runtime.rst b/docs/reference/api/python/runtime/runtime.rst
similarity index 95%
copy from docs/reference/api/python/runtime.rst
copy to docs/reference/api/python/runtime/runtime.rst
index c51a2d4520..4dd9d96533 100644
--- a/docs/reference/api/python/runtime.rst
+++ b/docs/reference/api/python/runtime/runtime.rst
@@ -17,9 +17,6 @@
tvm.runtime
-----------
-
.. automodule:: tvm.runtime
:members:
- :imported-members:
:exclude-members: NDArray
- :autosummary:
diff --git a/docs/reference/api/python/runtime.rst b/docs/reference/api/python/tir/analysis.rst
similarity index 87%
copy from docs/reference/api/python/runtime.rst
copy to docs/reference/api/python/tir/analysis.rst
index c51a2d4520..aa777358bc 100644
--- a/docs/reference/api/python/runtime.rst
+++ b/docs/reference/api/python/tir/analysis.rst
@@ -15,11 +15,7 @@
specific language governing permissions and limitations
under the License.
-tvm.runtime
------------
-
-.. automodule:: tvm.runtime
+tvm.tir.analysis
+----------------
+.. automodule:: tvm.tir.analysis.analysis
:members:
- :imported-members:
- :exclude-members: NDArray
- :autosummary:
diff --git a/docs/reference/api/python/relay/transform.rst b/docs/reference/api/python/tir/schedule.rst
similarity index 89%
copy from docs/reference/api/python/relay/transform.rst
copy to docs/reference/api/python/tir/schedule.rst
index c66904d8bc..17e4a4593a 100644
--- a/docs/reference/api/python/relay/transform.rst
+++ b/docs/reference/api/python/tir/schedule.rst
@@ -15,10 +15,8 @@
specific language governing permissions and limitations
under the License.
-tvm.relay.transform
-----------------------
-
-.. automodule:: tvm.relay.transform
+tvm.tir.schedule
+-----------------
+.. automodule:: tvm.tir.schedule
:members:
:imported-members:
- :autosummary:
diff --git a/docs/reference/api/python/runtime.rst b/docs/reference/api/python/tir/stmt_functor.rst
similarity index 87%
copy from docs/reference/api/python/runtime.rst
copy to docs/reference/api/python/tir/stmt_functor.rst
index c51a2d4520..3b6c9bb64a 100644
--- a/docs/reference/api/python/runtime.rst
+++ b/docs/reference/api/python/tir/stmt_functor.rst
@@ -15,11 +15,7 @@
specific language governing permissions and limitations
under the License.
-tvm.runtime
------------
-
-.. automodule:: tvm.runtime
+tvm.tir.stmt_functor
+--------------------
+.. automodule:: tvm.tir.stmt_functor
:members:
- :imported-members:
- :exclude-members: NDArray
- :autosummary:
diff --git a/docs/reference/api/python/runtime.rst b/docs/reference/api/python/tir/tir.rst
similarity index 85%
copy from docs/reference/api/python/runtime.rst
copy to docs/reference/api/python/tir/tir.rst
index c51a2d4520..3f82fe8261 100644
--- a/docs/reference/api/python/runtime.rst
+++ b/docs/reference/api/python/tir/tir.rst
@@ -15,11 +15,9 @@
specific language governing permissions and limitations
under the License.
-tvm.runtime
------------
-
-.. automodule:: tvm.runtime
+tvm.tir
+-------
+.. automodule:: tvm.tir
:members:
:imported-members:
- :exclude-members: NDArray
- :autosummary:
+ :exclude-members: PrimExpr, const, StmtSRef, BlockScope, ScheduleState, Schedule, ScheduleError
diff --git a/docs/reference/api/python/runtime.rst b/docs/reference/api/python/tir/transform.rst
similarity index 89%
copy from docs/reference/api/python/runtime.rst
copy to docs/reference/api/python/tir/transform.rst
index c51a2d4520..8ce641b6d3 100644
--- a/docs/reference/api/python/runtime.rst
+++ b/docs/reference/api/python/tir/transform.rst
@@ -15,11 +15,9 @@
specific language governing permissions and limitations
under the License.
-tvm.runtime
------------
-.. automodule:: tvm.runtime
+tvm.tir.transform
+-----------------
+.. automodule:: tvm.tir.transform
:members:
:imported-members:
- :exclude-members: NDArray
- :autosummary:
diff --git a/docs/reference/api/python/runtime.rst b/docs/reference/api/python/transform.rst
similarity index 89%
rename from docs/reference/api/python/runtime.rst
rename to docs/reference/api/python/transform.rst
index c51a2d4520..d200dfdd11 100644
--- a/docs/reference/api/python/runtime.rst
+++ b/docs/reference/api/python/transform.rst
@@ -15,11 +15,8 @@
specific language governing permissions and limitations
under the License.
-tvm.runtime
------------
-
-.. automodule:: tvm.runtime
+tvm.transform
+-------------
+.. automodule:: tvm.transform
:members:
:imported-members:
- :exclude-members: NDArray
- :autosummary:
diff --git a/docs/reference/api/python/vta/index.rst b/docs/reference/api/python/vta/index.rst
deleted file mode 100644
index 479b8394f0..0000000000
--- a/docs/reference/api/python/vta/index.rst
+++ /dev/null
@@ -1,45 +0,0 @@
-.. 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.
-
-vta
-===
-
-This document contains the python API to VTA compiler toolchain.
-
-.. automodule:: vta
-
-Hardware Information
---------------------
-
-.. autofunction:: vta.Environment
-.. autofunction:: vta.get_env
-
-RPC Utilities
--------------
-
-.. autofunction:: vta.reconfig_runtime
-.. autofunction:: vta.program_fpga
-
-
-Compiler API
-------------
-We program VTA using TVM, so the compiler API in vta package
-is only a thin wrapper to provide VTA specific extensions.
-
-.. autofunction:: vta.build_config
-.. autofunction:: vta.build
-.. autofunction:: vta.lower
diff --git a/docs/arch/security.rst b/docs/reference/security.rst
similarity index 100%
rename from docs/arch/security.rst
rename to docs/reference/security.rst
diff --git a/python/tvm/driver/build_module.py b/python/tvm/driver/build_module.py
index c332062b37..08af27e32f 100644
--- a/python/tvm/driver/build_module.py
+++ b/python/tvm/driver/build_module.py
@@ -105,7 +105,7 @@ def lower(
inp : Union[tvm.te.schedule.Schedule, tvm.tir.PrimFunc, IRModule]
The TE schedule or TensorIR PrimFunc/IRModule to be built
- args : Optional[List[Union[tvm.tir.Buffer, tensor.Tensor, Var]]]
+ args : Optional[List[Union[tvm.tir.Buffer, tensor.Tensor, tir.Var]]]
The argument lists to the function for TE schedule.
It should be None if we want to lower TensorIR.
@@ -156,7 +156,7 @@ def build(
inputs : Union[tvm.te.schedule.Schedule, tvm.tir.PrimFunc, IRModule, Mapping[str, IRModule]]
The input to be built
- args : Optional[List[Union[tvm.tir.Buffer, tensor.Tensor, Var]]]
+ args : Optional[List[Union[tvm.tir.Buffer, tensor.Tensor, tir.Var]]]
The argument lists to the function.
target : Optional[Union[str, Target]]
diff --git a/python/tvm/relax/op/create.py b/python/tvm/relax/op/create.py
index 8fd3b2cde1..092d79a74d 100644
--- a/python/tvm/relax/op/create.py
+++ b/python/tvm/relax/op/create.py
@@ -241,7 +241,7 @@ def tril(x: Expr, k: Union[int, PrimExpr, Expr] = 0) -> Expr:
return _ffi_api.tril(x, k) # type: ignore
-def triu(x: Expr, k: [int, PrimExpr, Expr] = 0) -> Expr:
+def triu(x: Expr, k: Union[int, PrimExpr, Expr] = 0) -> Expr:
"""Return the upper triangular part of a matrix or a batch of matrices.
Parameters
diff --git a/python/tvm/relax/transform/transform.py b/python/tvm/relax/transform/transform.py
index 2546284625..95649f331f 100644
--- a/python/tvm/relax/transform/transform.py
+++ b/python/tvm/relax/transform/transform.py
@@ -391,8 +391,8 @@ def ConvertToDataflow(min_size: int = 2) -> tvm.ir.transform.Pass:
Note: ConvertToDataflow may need to be called first.
- Params
- ------
+ Parameters
+ ----------
min_size: int
The minimum number of consecutive dataflow bindings
the pass needs to extract a new block.
@@ -647,13 +647,8 @@ def BindParams(
func_name: str
The function name to be bound
- params : Dict[
- Union[str,relax.Var],
- Union[tvm.runtime.NDArray, np.ndarray],
- ]
-
- The map from parameter or parameter name to constant
- tensors.
+ params: Dict[Union[str,relax.Var], Union[tvm.runtime.NDArray, np.ndarray]]
+ The map from parameter or parameter name to constant tensors.
Returns
-------
@@ -994,16 +989,16 @@ def LiftTransformParams(shared_transform: Union[bool, List[str]] = False) -> tvm
Indicates how the parameter transformation function will be produced
- `False` (default): A separate parameter transformation function will be
- produced for each function with the `"num_input"` attribute.
+ produced for each function with the `"num_input"` attribute.
- `True`: A single parameter transformation function will be produced,
- containing the preprocessing steps common across all functions with
- the `"num_input"` attribute.
+ containing the preprocessing steps common across all functions with
+ the `"num_input"` attribute.
- List[str]: A single parameter transformation function will be produced,
- containing the preprocessing steps common across each function whose
- name is in the list. Passing a list of all functions with the `"num_input"`
- attribute or an empty list is equivalent to passing `True`.
+ containing the preprocessing steps common across each function whose
+ name is in the list. Passing a list of all functions with the `"num_input"`
+ attribute or an empty list is equivalent to passing `True`.
Returns
-------
@@ -1219,7 +1214,7 @@ def MetaScheduleTuneIRMod(
maximum number of trials per task
op_names: Optional[List[str]]
A list of operator names to specify which op to tune. When it is None, all operators
- are tuned.
+ are tuned.
Returns
-------
diff --git a/python/tvm/runtime/profiling/__init__.py b/python/tvm/runtime/profiling/__init__.py
index 347d8b9f94..23ce5476f5 100644
--- a/python/tvm/runtime/profiling/__init__.py
+++ b/python/tvm/runtime/profiling/__init__.py
@@ -230,6 +230,7 @@ def profile_function(mod, dev, collectors, func_name=None, warmup_iters=10):
-------
.. code-block: python
+
f = tvm.build(my_func, target="llvm", name="my_func")
prof = tvm.runtime.profiling.profile_function(
f,
@@ -247,7 +248,7 @@ def profile_function(mod, dev, collectors, func_name=None, warmup_iters=10):
Device to run the function on.
collectors: List[MetricCollector]
- :py:class:`MetricCollector`s which will collect performance information.
+ :py:class:`MetricCollector` which will collect performance information.
func_name: Optional[str]
Name of the function in `mod` to profile. Defaults to the `entry_name` of `mod`.
warmup_iters: int
diff --git a/python/tvm/target/__init__.py b/python/tvm/target/__init__.py
index 78a7e0160d..14bd4753d4 100644
--- a/python/tvm/target/__init__.py
+++ b/python/tvm/target/__init__.py
@@ -51,7 +51,7 @@ The list of options include:
Build TVM system library module. System lib is a global module that contains
self registered functions in program startup. User can get the module using
- :any:`tvm.runtime.system_lib`.
+ `tvm.runtime.system_lib`.
It is useful in environments where dynamic loading api like dlopen is banned.
The system lib will be available as long as the result code is linked by the program.
diff --git a/python/tvm/te/operation.py b/python/tvm/te/operation.py
index 64a282dcf7..63a3ecd57b 100644
--- a/python/tvm/te/operation.py
+++ b/python/tvm/te/operation.py
@@ -459,7 +459,7 @@ def var(name="tindex", dtype="int32", span=None):
Returns
-------
- var : Var
+ var : tir.Var
The result symbolic variable.
"""
return tvm.tir.Var(name, dtype, span)
diff --git a/python/tvm/tir/buffer.py b/python/tvm/tir/buffer.py
index 501d13b17e..1109cc3d66 100644
--- a/python/tvm/tir/buffer.py
+++ b/python/tvm/tir/buffer.py
@@ -262,7 +262,7 @@ def decl_buffer(
name : str, optional
The name of the buffer.
- data : Var, optional
+ data : tir.Var, optional
The data pointer in the buffer.
strides: array of Expr