From 8acddabbb4d56f8082fb69bca6c1348cbae62b79 Mon Sep 17 00:00:00 2001 From: tqchen Date: Fri, 14 Feb 2020 10:06:32 -0800 Subject: [PATCH] [DOCS] Update API docs to reflect the status after the refactor. --- docs/_static/css/tvm_theme.css | 3 + docs/api/python/dev.rst | 80 ------------------- docs/api/python/{build.rst => driver.rst} | 8 +- docs/api/python/error.rst | 1 + docs/api/python/hybrid.rst | 11 +-- docs/api/python/index.rst | 14 ++-- docs/api/python/intrin.rst | 58 -------------- docs/api/python/ir.rst | 1 + docs/api/python/ndarray.rst | 9 --- docs/api/python/relay/index.rst | 4 +- docs/api/python/relay/ty.rst | 49 ------------ docs/api/python/rpc.rst | 22 +---- docs/api/python/runtime.rst | 5 ++ docs/api/python/target.rst | 1 + docs/api/python/{schedule.rst => te.rst} | 32 +++----- docs/api/python/{relay/module.rst => tir.rst} | 14 ++-- docs/api/python/topi.rst | 2 +- docs/api/python/vta/index.rst | 4 +- docs/conf.py | 24 +++--- docs/contribute/committer_guide.rst | 2 +- docs/contribute/error_handling.rst | 35 +++----- docs/dev/runtime.rst | 2 +- python/tvm/autotvm/tuner/xgboost_tuner.py | 20 +++-- python/tvm/contrib/graph_runtime.py | 15 +++- python/tvm/error.py | 4 + python/tvm/relay/op/nn/nn.py | 8 +- python/tvm/relay/op/tensor.py | 1 + python/tvm/target/__init__.py | 2 +- python/tvm/target/target.py | 14 ++-- python/tvm/te/__init__.py | 12 ++- 30 files changed, 123 insertions(+), 334 deletions(-) delete mode 100644 docs/api/python/dev.rst rename docs/api/python/{build.rst => driver.rst} (94%) delete mode 100644 docs/api/python/intrin.rst delete mode 100644 docs/api/python/relay/ty.rst rename docs/api/python/{schedule.rst => te.rst} (66%) rename docs/api/python/{relay/module.rst => tir.rst} (86%) diff --git a/docs/_static/css/tvm_theme.css b/docs/_static/css/tvm_theme.css index 196aa05c2375f..93f4ea4d38c13 100644 --- a/docs/_static/css/tvm_theme.css +++ b/docs/_static/css/tvm_theme.css @@ -38,3 +38,6 @@ nav .hidden-section { color: #404040 !important; } +.wy-nav-content { + max-width: 950px !important; +} diff --git a/docs/api/python/dev.rst b/docs/api/python/dev.rst deleted file mode 100644 index f9d9410946c98..0000000000000 --- a/docs/api/python/dev.rst +++ /dev/null @@ -1,80 +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. - -Developer API -------------- -This page contains modules that are used by developers of TVM. -Many of these APIs are PackedFunc registered in C++ backend. - - - -tvm.expr -~~~~~~~~ -.. automodule:: tvm.expr - :members: - :undoc-members: - -tvm.codegen -~~~~~~~~~~~ -.. automodule:: tvm.codegen - :members: - :undoc-members: - -tvm.stmt -~~~~~~~~ -.. automodule:: tvm.stmt - :members: - :undoc-members: - -tvm.ir_pass -~~~~~~~~~~~ -.. autosummary:: - - tvm.ir_pass.Inline - tvm.ir_pass.Simplify - tvm.ir_pass.ConvertSSA - tvm.ir_pass.VerifySSA - tvm.ir_pass.CanonicalSimplify - tvm.ir_pass.StorageFlatten - tvm.ir_pass.VectorizeLoop - tvm.ir_pass.SkipVectorize - tvm.ir_pass.UnrollLoop - tvm.ir_pass.ThreadSync - tvm.ir_pass.StorageRewrite - tvm.ir_pass.MakeAPI - tvm.ir_pass.SplitHostDevice - tvm.ir_pass.InjectVirtualThread - tvm.ir_pass.LoopPartition - tvm.ir_pass.RemoveNoOp - tvm.ir_pass.SplitPipeline - tvm.ir_pass.LowerThreadAllreduce - tvm.ir_pass.LowerIntrin - tvm.ir_pass.LowerTVMBuiltin - tvm.ir_pass.NarrowChannelAccess - -.. automodule:: tvm.ir_pass - :members: - -tvm.ir_builder -~~~~~~~~~~~~~~ -.. automodule:: tvm.ir_builder - :members: - -tvm.make -~~~~~~~~ -.. automodule:: tvm.make - :members: diff --git a/docs/api/python/build.rst b/docs/api/python/driver.rst similarity index 94% rename from docs/api/python/build.rst rename to docs/api/python/driver.rst index 5eee7a5b23c4d..1f1bc8c7cf7b6 100644 --- a/docs/api/python/build.rst +++ b/docs/api/python/driver.rst @@ -15,10 +15,10 @@ specific language governing permissions and limitations under the License. -tvm.build ---------- +tvm.driver +---------- +.. automodule:: tvm.driver + .. autofunction:: tvm.lower .. autofunction:: tvm.build - -.. autofunction:: tvm.build_config diff --git a/docs/api/python/error.rst b/docs/api/python/error.rst index c32d82599af7d..a228f7b8bd851 100644 --- a/docs/api/python/error.rst +++ b/docs/api/python/error.rst @@ -20,3 +20,4 @@ tvm.error .. automodule:: tvm.error :members: :imported-members: + :autosummary: diff --git a/docs/api/python/hybrid.rst b/docs/api/python/hybrid.rst index 5acae640d2de7..1184c837d2deb 100644 --- a/docs/api/python/hybrid.rst +++ b/docs/api/python/hybrid.rst @@ -18,11 +18,6 @@ tvm.hybrid ---------- .. automodule:: tvm.hybrid - -.. autosummary:: - - tvm.hybrid.parse - tvm.hybrid.script - -.. autofunction:: tvm.hybrid.parse -.. autofunction:: tvm.hybrid.script + :members: + :imported-members: + :autosummary: diff --git a/docs/api/python/index.rst b/docs/api/python/index.rst index b37d44eda7b3f..f62a4b848650b 100644 --- a/docs/api/python/index.rst +++ b/docs/api/python/index.rst @@ -21,23 +21,19 @@ Python API .. toctree:: :maxdepth: 2 - tvm runtime ndarray error ir target - intrin - tensor - schedule - build - function + tir + te + driver autotvm rpc contrib graph_runtime - dev - topi - vta/index hybrid relay/index + vta/index + topi diff --git a/docs/api/python/intrin.rst b/docs/api/python/intrin.rst deleted file mode 100644 index 60141d020c9e5..0000000000000 --- a/docs/api/python/intrin.rst +++ /dev/null @@ -1,58 +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. - -tvm.intrin ----------- -.. automodule:: tvm.intrin - -.. autosummary:: - - tvm.call_packed - tvm.call_pure_intrin - tvm.call_intrin - tvm.call_pure_extern - tvm.call_extern - tvm.call_llvm_intrin - tvm.register_intrin_rule - tvm.if_then_else - tvm.exp - tvm.log - tvm.floor - tvm.ceil - tvm.trunc - tvm.round - tvm.nearbyint - tvm.abs - tvm.isnan - -.. autofunction:: tvm.call_packed -.. autofunction:: tvm.call_pure_intrin -.. autofunction:: tvm.call_intrin -.. autofunction:: tvm.call_pure_extern -.. autofunction:: tvm.call_extern -.. autofunction:: tvm.call_llvm_intrin -.. autofunction:: tvm.register_intrin_rule -.. autofunction:: tvm.if_then_else -.. autofunction:: tvm.exp -.. autofunction:: tvm.log -.. autofunction:: tvm.floor -.. autofunction:: tvm.ceil -.. autofunction:: tvm.trunc -.. autofunction:: tvm.round -.. autofunction:: tvm.nearbyint -.. autofunction:: tvm.abs -.. autofunction:: tvm.isnan diff --git a/docs/api/python/ir.rst b/docs/api/python/ir.rst index 9e7df8ffce69c..1f0dc0c5e23ca 100644 --- a/docs/api/python/ir.rst +++ b/docs/api/python/ir.rst @@ -20,3 +20,4 @@ tvm.ir .. automodule:: tvm.ir :members: :imported-members: + :autosummary: diff --git a/docs/api/python/ndarray.rst b/docs/api/python/ndarray.rst index 6f00eedac3e91..aa828905ca212 100644 --- a/docs/api/python/ndarray.rst +++ b/docs/api/python/ndarray.rst @@ -23,14 +23,5 @@ tvm.runtime.ndarray :members: :inherited-members: - -.. autoclass:: tvm.runtime.TVMContext - :members: - -.. autofunction:: tvm.context -.. autofunction:: tvm.cpu -.. autofunction:: tvm.gpu -.. autofunction:: tvm.opencl -.. autofunction:: tvm.metal .. autofunction:: tvm.nd.array .. autofunction:: tvm.nd.empty diff --git a/docs/api/python/relay/index.rst b/docs/api/python/relay/index.rst index 90746b8e5d4ee..b286386b12308 100644 --- a/docs/api/python/relay/index.rst +++ b/docs/api/python/relay/index.rst @@ -15,7 +15,7 @@ specific language governing permissions and limitations under the License. -Relay API +tvm.relay ========= This document contains the Python API for the Relay frontend, optimizer, and @@ -35,9 +35,7 @@ compiler stack. image analysis transform - module nn op scope_builder - ty vision diff --git a/docs/api/python/relay/ty.rst b/docs/api/python/relay/ty.rst deleted file mode 100644 index 5bd5321887a59..0000000000000 --- a/docs/api/python/relay/ty.rst +++ /dev/null @@ -1,49 +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. - -tvm.relay.ty ------------- - -.. automodule:: tvm.relay.ty - :members: - -.. autoclass:: tvm.relay.ty.Type - :members: - -.. autoclass:: tvm.relay.ty.TensorType - :members: - -.. autoclass:: tvm.relay.ty.Kind - :members: - -.. autoclass:: tvm.relay.ty.TypeVar - :members: - -.. autoclass:: tvm.relay.ty.TypeConstraint - :members: - -.. autoclass:: tvm.relay.ty.TupleType - :members: - -.. autoclass:: tvm.relay.ty.FuncType - :members: - -.. autoclass:: tvm.relay.ty.IncompleteType - :members: - -.. autoclass:: tvm.relay.ty.TypeRelation - :members: diff --git a/docs/api/python/rpc.rst b/docs/api/python/rpc.rst index da7dc83b1889a..d5d119201854f 100644 --- a/docs/api/python/rpc.rst +++ b/docs/api/python/rpc.rst @@ -18,22 +18,6 @@ tvm.rpc ------- .. automodule:: tvm.rpc - -.. autofunction:: tvm.rpc.connect -.. autofunction:: tvm.rpc.connect_tracker - -.. autoclass:: tvm.rpc.TrackerSession - :members: - :inherited-members: - -.. autoclass:: tvm.rpc.RPCSession - :members: - :inherited-members: - -.. autoclass:: tvm.rpc.LocalSession - :members: - :inherited-members: - -.. autoclass:: tvm.rpc.Server - :members: - :inherited-members: + :members: + :imported-members: + :autosummary: diff --git a/docs/api/python/runtime.rst b/docs/api/python/runtime.rst index 75523cf7b81dd..9e395712aa6d9 100644 --- a/docs/api/python/runtime.rst +++ b/docs/api/python/runtime.rst @@ -19,6 +19,11 @@ tvm.runtime ----------- .. automodule:: tvm.runtime + :members: + :imported-members: + :exclude-members: NDArray + :autosummary: + .. autoclass:: tvm.runtime.PackedFunc :members: diff --git a/docs/api/python/target.rst b/docs/api/python/target.rst index 625b98e9de431..b3e763379ab6a 100644 --- a/docs/api/python/target.rst +++ b/docs/api/python/target.rst @@ -20,3 +20,4 @@ tvm.target .. automodule:: tvm.target :members: :imported-members: + :autosummary: diff --git a/docs/api/python/schedule.rst b/docs/api/python/te.rst similarity index 66% rename from docs/api/python/schedule.rst rename to docs/api/python/te.rst index c5e902980692c..dc3d3dacd2cae 100644 --- a/docs/api/python/schedule.rst +++ b/docs/api/python/te.rst @@ -15,22 +15,16 @@ specific language governing permissions and limitations under the License. -tvm.schedule ------------- -.. automodule:: tvm.schedule - -.. autoclass:: tvm.schedule.IterVar - :members: - -.. autoclass:: tvm.schedule.Buffer - :members: - -.. autofunction:: tvm.create_schedule - -.. autoclass:: tvm.schedule.Schedule - :members: - :inherited-members: - -.. autoclass:: tvm.schedule.Stage - :members: - :inherited-members: +tvm.te +------ +.. Exclude the ops imported from tir. + +.. automodule:: tvm.te + :members: + :imported-members: + :exclude-members: + exp, erf, tanh, sigmoid, log, cos, sin, atan, sqrt, rsqrt, floor, ceil, + trunc, abs, round, nearbyint, isnan, power, popcount, fmod, if_then_else, + div, indexdiv, indexmod, truncdiv, truncmod, floordiv, floormod, + comm_reducer, min, max, sum + :autosummary: diff --git a/docs/api/python/relay/module.rst b/docs/api/python/tir.rst similarity index 86% rename from docs/api/python/relay/module.rst rename to docs/api/python/tir.rst index ae736db0532f9..d1017cdb46efb 100644 --- a/docs/api/python/relay/module.rst +++ b/docs/api/python/tir.rst @@ -15,10 +15,10 @@ specific language governing permissions and limitations under the License. -tvm.relay.module ----------------- - -.. automodule:: tvm.relay.module - -.. autoclass:: tvm.relay.module.Module - :members: +tvm.tir +------- +.. automodule:: tvm.tir + :members: + :imported-members: + :exclude-members: PrimExpr + :autosummary: diff --git a/docs/api/python/topi.rst b/docs/api/python/topi.rst index 75a4271291bfa..269d42dc36216 100644 --- a/docs/api/python/topi.rst +++ b/docs/api/python/topi.rst @@ -15,7 +15,7 @@ specific language governing permissions and limitations under the License. -TOPI +topi ---- .. automodule:: topi diff --git a/docs/api/python/vta/index.rst b/docs/api/python/vta/index.rst index 4975032179e4f..479b8394f0cb1 100644 --- a/docs/api/python/vta/index.rst +++ b/docs/api/python/vta/index.rst @@ -15,8 +15,8 @@ specific language governing permissions and limitations under the License. -VTA API -======= +vta +=== This document contains the python API to VTA compiler toolchain. diff --git a/docs/conf.py b/docs/conf.py index 0b29f2816c8b8..3ca622d6ff18f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -49,9 +49,9 @@ # General information about the project. project = u'tvm' -author = u'%s developers' % project -copyright = u'2018, %s' % author -github_doc_root = 'https://github.com/tqchen/tvm/tree/master/docs/' +author = u'Apache Software Foundation' +copyright = u'2019, %s' % author +github_doc_root = 'https://github.com/apache/incubator-tvm/tree/master/docs/' # add markdown parser CommonMarkParser.github_doc_root = github_doc_root @@ -73,6 +73,7 @@ 'sphinx.ext.napoleon', 'sphinx.ext.mathjax', 'sphinx_gallery.gen_gallery', + 'autodocsumm' ] breathe_projects = {'tvm' : 'doxygen/xml/'} @@ -139,9 +140,6 @@ # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False -# sort autodoc order by the source file. -autodoc_member_order = 'bysource' - # -- Options for HTML output ---------------------------------------------- # The theme is set by the make target @@ -199,9 +197,9 @@ def run_doxygen(folder): intersphinx_mapping = { 'python': ('https://docs.python.org/{.major}'.format(sys.version_info), None), - 'numpy': ('http://docs.scipy.org/doc/numpy/', None), - 'scipy': ('http://docs.scipy.org/doc/scipy/reference', None), - 'matplotlib': ('http://matplotlib.org/', None), + 'numpy': ('https://docs.scipy.org/doc/numpy/', None), + 'scipy': ('https://docs.scipy.org/doc/scipy/reference', None), + 'matplotlib': ('https://matplotlib.org/', None), } from sphinx_gallery.sorting import ExplicitOrder @@ -242,8 +240,8 @@ def setup(app): 'doc_module': ('tvm', 'numpy'), 'reference_url': { 'tvm': None, - 'matplotlib': 'http://matplotlib.org', - 'numpy': 'http://docs.scipy.org/doc/numpy-1.9.1'}, + 'matplotlib': 'https://matplotlib.org/', + 'numpy': 'https://docs.scipy.org/doc/numpy/'}, 'examples_dirs': examples_dirs, 'gallery_dirs': gallery_dirs, 'subsection_order': subsection_order, @@ -251,3 +249,7 @@ def setup(app): 'find_mayavi_figures': False, 'expected_failing_examples': [] } + +autodoc_default_options = { + 'member-order': 'bysource', +} diff --git a/docs/contribute/committer_guide.rst b/docs/contribute/committer_guide.rst index cc89a43aabdb3..6e553bd42a39a 100644 --- a/docs/contribute/committer_guide.rst +++ b/docs/contribute/committer_guide.rst @@ -59,7 +59,7 @@ Here are some example applications of this principle: Shepherd a Pull Request ----------------------- +----------------------- Here are some tips to shepherd a pull request. You can also take a look at the :ref:`code_review_guide`. diff --git a/docs/contribute/error_handling.rst b/docs/contribute/error_handling.rst index 4d5e5c54f03cb..8f71ee61aeb6b 100644 --- a/docs/contribute/error_handling.rst +++ b/docs/contribute/error_handling.rst @@ -15,25 +15,27 @@ specific language governing permissions and limitations under the License. -.. _error_guide: +.. _error-handling-guide: Error Handling Guide ==================== TVM contains structured error classes to indicate specific types of error. Please raise a specific error type when possible, so that users can write code to handle a specific error category if necessary. - -All the error types are defined in :any:`tvm.error` namespace. You can directly raise the specific error object in python. In other languages like c++, you simply add ``:`` prefix to the error message(see below). +.. note:: + + Please refer to :py:mod:`tvm.error` for the list of errors. + Raise a Specific Error in C++ ----------------------------- You can add ``:`` prefix to your error message to raise an error of the corresponding type. Note that you do not have to add a new type -:any:`tvm.error.TVMError` will be raised by default when +:py:class:`tvm.error.TVMError` will be raised by default when there is no error type prefix in the message. This mechanism works for both ``LOG(FATAL)`` and ``CHECK`` macros. The following code gives an example on how to do so. @@ -55,7 +57,7 @@ Here is what will happen if we call the registered function: .. code:: >>> import tvm - >>> tvm._api_internal._ErrorTest(0, 1) + >>> tvm.testing.ErrorTest(0, 1) Traceback (most recent call last): File "", line 1, in File "/path/to/tvm/python/tvm/_ffi/_ctypes/function.py", line 190, in __call__ @@ -68,7 +70,7 @@ Here is what will happen if we call the registered function: File "/path/to/tvm/src/api/api_test.cc", line 80 ValueError: Check failed: x == y (0 vs. 1) : expect x and y to be equal. >>> - >>> tvm._api_internal._ErrorTest(1, 1) + >>> tvm.testing.ErrorTest(1, 1) Traceback (most recent call last): File "", line 1, in File "/path/to/tvm/python/tvm/_ffi/_ctypes/function.py", line 190, in __call__ @@ -95,7 +97,7 @@ We try to keep a reasonable amount of error types. If you feel there is a need to add a new error type, do the following steps: - Send a RFC proposal with a description and usage examples in the current codebase. -- Add the new error type to :any:`tvm.error` with clear documents. +- Add the new error type to :py:mod:`tvm.error` with clear documents. - Update the list in this file to include the new error type. - Change the code to use the new error type. @@ -118,22 +120,3 @@ error messages when necessary. If we need to introduce a wrapper function that constructs multi-line error messages, please put wrapper in the same file so other developers can look up the implementation easily. - - -System-wide Errors ------------------- - -.. autoclass:: tvm.error.TVMError - -.. autoclass:: tvm.error.InternalError - - -Frontend Errors ---------------- -.. autoclass:: tvm.error.OpNotImplemented - -.. autoclass:: tvm.error.OpAttributeInvalid - -.. autoclass:: tvm.error.OpAttributeRequired - -.. autoclass:: tvm.error.OpAttributeNotImplemented diff --git a/docs/dev/runtime.rst b/docs/dev/runtime.rst index bb129b038aa97..353b3392d181e 100644 --- a/docs/dev/runtime.rst +++ b/docs/dev/runtime.rst @@ -183,7 +183,7 @@ RPC server on iPhone/android/raspberry pi or even the browser. The cross compila This instant feedback gives us a lot of advantages. For example, to test the correctness of generated code on iPhone, we no longer have to write test-cases in swift/objective-c from scratch -- We can use RPC to execute on iPhone, copy the result back and do verification on the host via numpy. We can also do the profiling using the same script. TVM Object and Compiler Stack ---------------------------- +----------------------------- As we mentioned earlier, we build compiler stack API on top of the PackedFunc runtime system. We faced a constant changing of the compiler API for the need of research. We need a new language object or IR node whenever we want to test out new primitives. diff --git a/python/tvm/autotvm/tuner/xgboost_tuner.py b/python/tvm/autotvm/tuner/xgboost_tuner.py index 2ebea86d8e3ed..a7ddf851db37b 100644 --- a/python/tvm/autotvm/tuner/xgboost_tuner.py +++ b/python/tvm/autotvm/tuner/xgboost_tuner.py @@ -37,28 +37,32 @@ class XGBTuner(ModelBasedTuner): Note on choosing feature type: For single task tuning, 'itervar' and 'knob' are good. - 'itervar' is more accurate but 'knob' is much faster. - There are some constraints on 'itervar', if you meet - problems with feature extraction when using 'itervar', - you can switch to 'knob'. + 'itervar' is more accurate but 'knob' is much faster. + There are some constraints on 'itervar', if you meet + problems with feature extraction when using 'itervar', + you can switch to 'knob'. For cross-shape tuning (e.g. many convolutions with different shapes), - 'itervar' and 'curve' has better transferability, - 'knob' is faster. + 'itervar' and 'curve' has better transferability, + 'knob' is faster. + For cross-device or cross-operator tuning, you can use 'curve' only. loss_type: str If is 'reg', use regression loss to train cost model. - The cost model predicts the normalized flops. + The cost model predicts the normalized flops. If is 'rank', use pairwise rank loss to train cost model. - The cost model predicts relative rank score. + The cost model predicts relative rank score. + num_threads: int, optional The number of threads. optimizer: str or ModelOptimizer, optional If is 'sa', use a default simulated annealing optimizer. Otherwise it should be a ModelOptimizer object. + diversity_filter_ratio: int or float, optional If is not None, the tuner will first select top-(plan_size * diversity_filter_ratio) candidates according to the cost model and then pick batch_size of them according to the diversity metric. + log_interval: int, optional The verbose level. If is 0, output nothing. diff --git a/python/tvm/contrib/graph_runtime.py b/python/tvm/contrib/graph_runtime.py index 6b7c099ff705b..73235f71c77ba 100644 --- a/python/tvm/contrib/graph_runtime.py +++ b/python/tvm/contrib/graph_runtime.py @@ -25,19 +25,23 @@ def create(graph_json_str, libmod, ctx): """Create a runtime executor module given a graph and module. + Parameters ---------- graph_json_str : str or graph class The graph to be deployed in json format output by json graph. The graph can only contain one operator(tvm_op) that points to the name of PackedFunc in the libmod. - libmod : tvm.Module + + libmod : tvm.runtime.Module The module of the corresponding function + ctx : TVMContext or list of TVMContext The context to deploy the module. It can be local or remote when there is only one TVMContext. Otherwise, the first context in the list will be used as this purpose. All context should be given for heterogeneous execution. + Returns ------- graph_module : GraphModule @@ -61,11 +65,14 @@ def create(graph_json_str, libmod, ctx): def get_device_ctx(libmod, ctx): """Parse and validate all the device context(s). + Parameters ---------- - libmod : tvm.Module + libmod : tvm.runtime.Module The module of the corresponding function + ctx : TVMContext or list of TVMContext + Returns ------- ctx : list of TVMContext @@ -113,12 +120,12 @@ class GraphModule(object): Parameters ---------- - module : Module + module : tvm.runtime.Module The internal tvm module that holds the actual graph functions. Attributes ---------- - module : Module + module : tvm.runtime.Module The internal tvm module that holds the actual graph functions. """ diff --git a/python/tvm/error.py b/python/tvm/error.py index 083c7e825255c..02bc90b7cf8fb 100644 --- a/python/tvm/error.py +++ b/python/tvm/error.py @@ -20,6 +20,10 @@ See the example sections for for suggested message conventions. To make the code more readable, we recommended developers to copy the examples and raise errors with the same message convention. + +.. note:: + + Please also refer to :ref:`error-handling-guide`. """ from tvm._ffi.base import register_error, TVMError diff --git a/python/tvm/relay/op/nn/nn.py b/python/tvm/relay/op/nn/nn.py index c76d5ed371354..9ee43438f83d4 100644 --- a/python/tvm/relay/op/nn/nn.py +++ b/python/tvm/relay/op/nn/nn.py @@ -1424,10 +1424,12 @@ def batch_norm(data, Besides the inputs and the outputs, this operator accepts two auxiliary states, ``moving_mean`` and ``moving_var``, which are *k*-length - vectors. They are global statistics for the whole dataset, which are updated by:: + vectors. They are global statistics for the whole dataset, which are updated by - moving_mean = moving_mean * momentum + data_mean * (1 - momentum) - moving_var = moving_var * momentum + data_var * (1 - momentum) + .. code:: python + + moving_mean = moving_mean * momentum + data_mean * (1 - momentum) + moving_var = moving_var * momentum + data_var * (1 - momentum) The parameter ``axis`` specifies which axis of the input shape denotes the 'channel' (separately normalized groups). The default is 1. diff --git a/python/tvm/relay/op/tensor.py b/python/tvm/relay/op/tensor.py index f1f8dd5a8c904..898038dea0043 100644 --- a/python/tvm/relay/op/tensor.py +++ b/python/tvm/relay/op/tensor.py @@ -847,6 +847,7 @@ def clip(a, a_min, a_max): Examples -------- .. code:: python + x = relay.Constant(tvm.nd.array([0, 1, 5, 3, 4, 2])) relay.clip(x, 1., 4.) # [1, 1, 4, 3, 4, 2] diff --git a/python/tvm/target/__init__.py b/python/tvm/target/__init__.py index 3975f30e644a5..3460be47aa95d 100644 --- a/python/tvm/target/__init__.py +++ b/python/tvm/target/__init__.py @@ -51,7 +51,7 @@ 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. -We can use :py:func:`~tvm.target.create` to create a tvm.target.Target from the target string. +We can use :py:func:`tvm.target.create` to create a tvm.target.Target from the target string. We can also use other specific function in this module to create specific targets. """ from .target import Target, create diff --git a/python/tvm/target/target.py b/python/tvm/target/target.py index 8405bb10720f0..e6046cef1839b 100644 --- a/python/tvm/target/target.py +++ b/python/tvm/target/target.py @@ -30,12 +30,12 @@ class Target(Object): ---- Do not use class constructor, you can create target using the following functions - - :py:func:`~tvm.target.create` create target from string - - :py:func:`~tvm.target.arm_cpu` create arm_cpu target - - :py:func:`~tvm.target.cuda` create CUDA target - - :py:func:`~tvm.target.rocm` create ROCM target - - :py:func:`~tvm.target.mali` create Mali target - - :py:func:`~tvm.target.intel_graphics` create Intel Graphics target + - :py:func:`tvm.target.create` create target from string + - :py:func:`tvm.target.arm_cpu` create arm_cpu target + - :py:func:`tvm.target.cuda` create CUDA target + - :py:func:`tvm.target.rocm` create ROCM target + - :py:func:`tvm.target.mali` create Mali target + - :py:func:`tvm.target.intel_graphics` create Intel Graphics target """ def __new__(cls): # Always override new to enable class @@ -262,7 +262,7 @@ def create(target_str): Note ---- - See the note on :py:mod:`~tvm.target` on target string format. + See the note on :py:mod:`tvm.target` on target string format. """ if isinstance(target_str, Target): return target_str diff --git a/python/tvm/te/__init__.py b/python/tvm/te/__init__.py index 0564fff0e5cbf..e53bf14382d71 100644 --- a/python/tvm/te/__init__.py +++ b/python/tvm/te/__init__.py @@ -15,13 +15,17 @@ # specific language governing permissions and limitations # under the License. # pylint: disable=unused-import, redefined-builtin, wildcard-import -"""Namespace for Tensor-level IR""" +"""Namespace for Tensor Expression Language +""" # expose all operators in tvm tir.op -from tvm.tir.op import * - from .schedule import Schedule, create_schedule -from .tensor import TensorSlice, Tensor +from .tensor import Tensor from .tensor_intrin import decl_tensor_intrin from .tag import tag_scope from .operation import placeholder, compute, scan, extern, var, size_var from .operation import thread_axis, reduce_axis + +from tvm.tir import exp, erf, tanh, sigmoid, log, cos, sin, atan, sqrt, rsqrt, floor, ceil +from tvm.tir import trunc, abs, round, nearbyint, isnan, power, popcount, fmod, if_then_else +from tvm.tir import div, indexdiv, indexmod, truncdiv, truncmod, floordiv, floormod +from tvm.tir import comm_reducer, min, max, sum