This is an automated email from the ASF dual-hosted git repository.

junrushao pushed a commit to branch unity
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/unity by this push:
     new 374b03f7e9 [Unity][Doc] Fix Python Docstring for Sphinx Build (#15848)
374b03f7e9 is described below

commit 374b03f7e94332dcc24bf41fa50bf371923a8880
Author: Siyuan Feng <[email protected]>
AuthorDate: Mon Oct 2 11:38:44 2023 +0800

    [Unity][Doc] Fix Python Docstring for Sphinx Build (#15848)
    
    This PR includes minor fixes for doc strings in Python API.
---
 python/tvm/relax/block_builder.py |  2 +-
 python/tvm/relax/expr.py          |  4 ++--
 python/tvm/relax/expr_functor.py  |  8 ++++++++
 python/tvm/relax/op/base.py       |  4 ++--
 python/tvm/relax/struct_info.py   |  2 +-
 python/tvm/relax/vm_build.py      |  1 +
 python/tvm/runtime/relax_vm.py    | 21 ++++++++++++---------
 7 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/python/tvm/relax/block_builder.py 
b/python/tvm/relax/block_builder.py
index 4f34bec928..331a3905f3 100644
--- a/python/tvm/relax/block_builder.py
+++ b/python/tvm/relax/block_builder.py
@@ -721,7 +721,7 @@ class BlockBuilder(Object):
         _ffi_api.BlockBuilderEmitNormalized(self, binding)  # type: ignore
 
     def lookup_binding(self, var: Var) -> Optional[Expr]:
-        """Lookup a var in the binding table binding_table_.
+        """Lookup a var in the binding table.
 
         Parameters
         ----------
diff --git a/python/tvm/relax/expr.py b/python/tvm/relax/expr.py
index cd5dfa2863..7e43506e97 100644
--- a/python/tvm/relax/expr.py
+++ b/python/tvm/relax/expr.py
@@ -426,7 +426,7 @@ class Var(ExprWithOp):
         )
 
     @property
-    def name_hint(self):
+    def name_hint(self) -> str:
         """Get name hint of the current var."""
         name = str(self.vid.name_hint)
         return name
@@ -671,7 +671,7 @@ class Function(BaseFunc, Scriptable):
         binding_map: Mapping[
                 Union[str, Var],
                 Union[int, float, PrimExpr, tvm.runtime.NDArray, _np.ndarray, 
Expr],
-            ]
+        ]
 
             The mapping of values to be replaced.
 
diff --git a/python/tvm/relax/expr_functor.py b/python/tvm/relax/expr_functor.py
index 0252720f6e..a0bb6df843 100644
--- a/python/tvm/relax/expr_functor.py
+++ b/python/tvm/relax/expr_functor.py
@@ -389,9 +389,13 @@ class PyExprVisitor:
     See also: visitor, _PyExprVisitor
 
     Example:
+
+    .. code-block:: python
+
         @relax.expr_functor.visitor
         def MyExprVisitor(PyExprVisitor):
             ...
+
     """
 
     _tvm_metadata = {
@@ -922,9 +926,13 @@ class PyExprMutator:
     See also: visitor, _PyExprVisitor
 
     Example:
+
+    .. code-block:: python
+
         @relax.expr_functor.mutator
         def MyExprMutator(PyExprMutator):
             ...
+
     """
 
     _tvm_metadata = {
diff --git a/python/tvm/relax/op/base.py b/python/tvm/relax/op/base.py
index ea6fd0a651..627722ff88 100644
--- a/python/tvm/relax/op/base.py
+++ b/python/tvm/relax/op/base.py
@@ -617,8 +617,8 @@ def call_pure_packed(
     The resulting call will have the same semantics as calling the packed 
function directly.
 
     Note: This should be used for cases when the user knows that calling the 
packed function
-    with these arguments will _in reality_ not cause any side effects.
-    If it is used for a call that _does_ result in side effects, then the 
compiler
+    with these arguments will **in reality** not cause any side effects.
+    If it is used for a call that **does** result in side effects, then the 
compiler
     may end up removing, reordering, or repeating that call, with no guarantees
     made about any side effects from the callee.
 
diff --git a/python/tvm/relax/struct_info.py b/python/tvm/relax/struct_info.py
index 38a4ab7491..4f89dc158c 100644
--- a/python/tvm/relax/struct_info.py
+++ b/python/tvm/relax/struct_info.py
@@ -148,7 +148,7 @@ class TensorStructInfo(StructInfo):
     dtype : Optional[str]
         The content data type.
 
-    vdevice : Optional[Vdevice]
+    vdevice : Optional[VDevice]
         The virtual device.
 
     ndim : Optional[int]
diff --git a/python/tvm/relax/vm_build.py b/python/tvm/relax/vm_build.py
index d5edeeec69..e6331e436f 100644
--- a/python/tvm/relax/vm_build.py
+++ b/python/tvm/relax/vm_build.py
@@ -291,6 +291,7 @@ def build(
     -------
 
     .. code-block:: python
+
         class InputModule:
             @R.function
             def foo(x: Tensor((3, 4), "float32"), y: Tensor((3, 4), 
"float32")):
diff --git a/python/tvm/runtime/relax_vm.py b/python/tvm/runtime/relax_vm.py
index 3856a1a1c9..b9d9a38fcf 100644
--- a/python/tvm/runtime/relax_vm.py
+++ b/python/tvm/runtime/relax_vm.py
@@ -338,7 +338,7 @@ class VirtualMachine(object):
 
         return get_output_rec(func_name)
 
-    def set_instrument(self, instrument: tvm.runtime.PackedFunc):
+    def set_instrument(self, instrument: tvm.runtime.PackedFunc) -> None:
         """Set an instrumentation function.
 
         If instrument is present, the function will be called
@@ -380,14 +380,14 @@ class VirtualMachine(object):
 
     def time_evaluator(
         self,
-        func_name,
-        dev,
-        number=10,
-        repeat=1,
-        min_repeat_ms=0,
-        cooldown_interval_ms=0,
-        repeats_to_cooldown=1,
-        f_preproc="",
+        func_name: str,
+        dev: Device,
+        number: int = 10,
+        repeat: int = 1,
+        min_repeat_ms: int = 0,
+        cooldown_interval_ms: int = 0,
+        repeats_to_cooldown: int = 1,
+        f_preproc: str = "",
     ) -> Callable[..., tvm.runtime.module.BenchmarkResult]:
         """
         Returns an evaluator that times a function in the module.
@@ -489,12 +489,15 @@ class VirtualMachine(object):
 
     def profile(self, func_name: str, *args):
         """Profile a function call.
+
         Parameters
         ----------
         func_name : str
             The name of the function.
+
         args: List of NDArray or other objects supported by PackedFunc.
             The arguments to the function.
+
         Returns
         -------
         report: tvm.runtime.profiling.Report

Reply via email to