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-ffi.git
The following commit(s) were added to refs/heads/main by this push:
new 24cf519 doc: Expose more Python APIs (#161)
24cf519 is described below
commit 24cf519179d17478619892069134ff8d99c0bee5
Author: Junru Shao <[email protected]>
AuthorDate: Fri Oct 17 04:46:09 2025 -0700
doc: Expose more Python APIs (#161)
---
docs/conf.py | 8 +++++
docs/reference/python/index.rst | 73 +++++++++++++++++++++++++++++-----------
python/tvm_ffi/__init__.py | 6 ++--
python/tvm_ffi/_tensor.py | 2 +-
python/tvm_ffi/cython/device.pxi | 1 +
5 files changed, 67 insertions(+), 23 deletions(-)
diff --git a/docs/conf.py b/docs/conf.py
index cc421af..28f87df 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -143,6 +143,14 @@ intersphinx_mapping = {
"torch": ("https://pytorch.org/docs/stable", None),
}
+autosummary_generate = True # actually create stub pages
+
+# Map object names -> stub docnames (no ".rst"; relative to your :toctree: dir)
+autosummary_filename_map = {
+ "tvm_ffi.device": "tvm_ffi.device_function",
+ "tvm_ffi.Device": "tvm_ffi.Device_class",
+}
+
_DOCS_DIR = Path(__file__).resolve().parent
_STUBS = {
"_stubs/cpp_index.rst": "reference/cpp/generated/index.rst",
diff --git a/docs/reference/python/index.rst b/docs/reference/python/index.rst
index 7cae49d..53ac71c 100644
--- a/docs/reference/python/index.rst
+++ b/docs/reference/python/index.rst
@@ -23,44 +23,53 @@ Python API
.. currentmodule:: tvm_ffi
+.. contents:: Table of Contents
+ :local:
+ :depth: 2
+
+
Object
------
.. autosummary::
:toctree: generated/
Object
- register_object
-Function and Module
--------------------
+Tensor
+~~~~~~
+.. autosummary::
+ :toctree: generated/
+
+ Tensor
+ Shape
+ Device
+ from_dlpack
+ DLDeviceType
+ device
+ dtype
+
+
+Function
+~~~~~~~~
.. autosummary::
:toctree: generated/
Function
- Module
- register_global_func
- get_global_func
- system_lib
- load_module
- init_ffi_api
- register_error
- convert
-Tensor
-------
+Module
+~~~~~~
.. autosummary::
:toctree: generated/
- Shape
- Tensor
- Device
- from_dlpack
+ Module
+ system_lib
+ load_module
Containers
-----------
+~~~~~~~~~~
.. autosummary::
:toctree: generated/
@@ -68,6 +77,20 @@ Containers
Map
+Global Registry
+---------------
+.. autosummary::
+ :toctree: generated/
+
+ register_error
+ register_object
+ register_global_func
+ get_global_func
+ get_global_func_metadata
+ init_ffi_api
+ remove_global_func
+
+
Stream Context
--------------
.. autosummary::
@@ -78,8 +101,8 @@ Stream Context
use_raw_stream
-Utility
--------
+Inline Loading
+--------------
C++ integration helpers for building and loading inline modules.
@@ -90,6 +113,16 @@ C++ integration helpers for building and loading inline
modules.
cpp.build_inline
+Misc
+----
+.. autosummary::
+ :toctree: generated/
+
+ serialization
+ access_path
+ convert
+ ObjectConvertible
+
.. (Experimental) Dataclasses
.. --------------------------
diff --git a/python/tvm_ffi/__init__.py b/python/tvm_ffi/__init__.py
index 5149ff5..130e893 100644
--- a/python/tvm_ffi/__init__.py
+++ b/python/tvm_ffi/__init__.py
@@ -64,14 +64,13 @@ __all__ = [
"Array",
"DLDeviceType",
"Device",
- "Device",
"Function",
"Map",
"Module",
"Object",
- "Object",
"ObjectConvertible",
"Shape",
+ "StreamContext",
"Tensor",
"__version__",
"access_path",
@@ -82,6 +81,7 @@ __all__ = [
"from_dlpack",
"get_global_func",
"get_global_func_metadata",
+ "get_raw_stream",
"init_ffi_api",
"load_module",
"register_error",
@@ -90,4 +90,6 @@ __all__ = [
"remove_global_func",
"serialization",
"system_lib",
+ "use_raw_stream",
+ "use_torch_stream",
]
diff --git a/python/tvm_ffi/_tensor.py b/python/tvm_ffi/_tensor.py
index a4714b2..4c9714b 100644
--- a/python/tvm_ffi/_tensor.py
+++ b/python/tvm_ffi/_tensor.py
@@ -36,7 +36,7 @@ from .core import (
@registry.register_object("ffi.Shape")
class Shape(tuple, PyNativeObject):
- """Shape tuple that represents ``ffi::Shape`` returned by an FFI call.
+ """Shape tuple that represents :cpp:class:`tvm::ffi::Shape` returned by an
FFI call.
Notes
-----
diff --git a/python/tvm_ffi/cython/device.pxi b/python/tvm_ffi/cython/device.pxi
index f25ee94..34cbf5c 100644
--- a/python/tvm_ffi/cython/device.pxi
+++ b/python/tvm_ffi/cython/device.pxi
@@ -73,6 +73,7 @@ cdef class Device:
assert tvm_ffi.device("cuda:0") == tvm_ffi.device("cuda", 0)
assert tvm_ffi.device("cpu:0") == tvm_ffi.device("cpu", 0)
+
"""
cdef DLDevice cdevice