Unverified Commit d2ae8c95 by Tianqi Chen Committed by GitHub

[DOCS] Update API docs to reflect the status after the refactor. (#4907)

parent 41835d17
...@@ -38,3 +38,6 @@ nav .hidden-section { ...@@ -38,3 +38,6 @@ nav .hidden-section {
color: #404040 !important; color: #404040 !important;
} }
.wy-nav-content {
max-width: 950px !important;
}
.. 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:
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
tvm.build tvm.driver
--------- ----------
.. automodule:: tvm.driver
.. autofunction:: tvm.lower .. autofunction:: tvm.lower
.. autofunction:: tvm.build .. autofunction:: tvm.build
.. autofunction:: tvm.build_config
...@@ -20,3 +20,4 @@ tvm.error ...@@ -20,3 +20,4 @@ tvm.error
.. automodule:: tvm.error .. automodule:: tvm.error
:members: :members:
:imported-members: :imported-members:
:autosummary:
...@@ -18,11 +18,6 @@ ...@@ -18,11 +18,6 @@
tvm.hybrid tvm.hybrid
---------- ----------
.. automodule:: tvm.hybrid .. automodule:: tvm.hybrid
:members:
.. autosummary:: :imported-members:
:autosummary:
tvm.hybrid.parse
tvm.hybrid.script
.. autofunction:: tvm.hybrid.parse
.. autofunction:: tvm.hybrid.script
...@@ -21,23 +21,19 @@ Python API ...@@ -21,23 +21,19 @@ Python API
.. toctree:: .. toctree::
:maxdepth: 2 :maxdepth: 2
tvm
runtime runtime
ndarray ndarray
error error
ir ir
target target
intrin tir
tensor te
schedule driver
build
function
autotvm autotvm
rpc rpc
contrib contrib
graph_runtime graph_runtime
dev
topi
vta/index
hybrid hybrid
relay/index relay/index
vta/index
topi
.. 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
...@@ -20,3 +20,4 @@ tvm.ir ...@@ -20,3 +20,4 @@ tvm.ir
.. automodule:: tvm.ir .. automodule:: tvm.ir
:members: :members:
:imported-members: :imported-members:
:autosummary:
...@@ -23,14 +23,5 @@ tvm.runtime.ndarray ...@@ -23,14 +23,5 @@ tvm.runtime.ndarray
:members: :members:
:inherited-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.array
.. autofunction:: tvm.nd.empty .. autofunction:: tvm.nd.empty
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
Relay API tvm.relay
========= =========
This document contains the Python API for the Relay frontend, optimizer, and This document contains the Python API for the Relay frontend, optimizer, and
...@@ -35,9 +35,7 @@ compiler stack. ...@@ -35,9 +35,7 @@ compiler stack.
image image
analysis analysis
transform transform
module
nn nn
op op
scope_builder scope_builder
ty
vision vision
.. 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:
...@@ -18,22 +18,6 @@ ...@@ -18,22 +18,6 @@
tvm.rpc tvm.rpc
------- -------
.. automodule:: 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: :members:
:inherited-members: :imported-members:
:autosummary:
...@@ -19,6 +19,11 @@ tvm.runtime ...@@ -19,6 +19,11 @@ tvm.runtime
----------- -----------
.. automodule:: tvm.runtime .. automodule:: tvm.runtime
:members:
:imported-members:
:exclude-members: NDArray
:autosummary:
.. autoclass:: tvm.runtime.PackedFunc .. autoclass:: tvm.runtime.PackedFunc
:members: :members:
......
...@@ -20,3 +20,4 @@ tvm.target ...@@ -20,3 +20,4 @@ tvm.target
.. automodule:: tvm.target .. automodule:: tvm.target
:members: :members:
:imported-members: :imported-members:
:autosummary:
...@@ -15,22 +15,16 @@ ...@@ -15,22 +15,16 @@
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
tvm.schedule tvm.te
------------ ------
.. automodule:: tvm.schedule .. Exclude the ops imported from tir.
.. autoclass:: tvm.schedule.IterVar .. automodule:: tvm.te
:members: :members:
:imported-members:
.. autoclass:: tvm.schedule.Buffer :exclude-members:
:members: exp, erf, tanh, sigmoid, log, cos, sin, atan, sqrt, rsqrt, floor, ceil,
trunc, abs, round, nearbyint, isnan, power, popcount, fmod, if_then_else,
.. autofunction:: tvm.create_schedule div, indexdiv, indexmod, truncdiv, truncmod, floordiv, floormod,
comm_reducer, min, max, sum
.. autoclass:: tvm.schedule.Schedule :autosummary:
:members:
:inherited-members:
.. autoclass:: tvm.schedule.Stage
:members:
:inherited-members:
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
tvm.relay.module tvm.tir
---------------- -------
.. automodule:: tvm.tir
.. automodule:: tvm.relay.module
.. autoclass:: tvm.relay.module.Module
:members: :members:
:imported-members:
:exclude-members: PrimExpr
:autosummary:
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
TOPI topi
---- ----
.. automodule:: topi .. automodule:: topi
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
VTA API vta
======= ===
This document contains the python API to VTA compiler toolchain. This document contains the python API to VTA compiler toolchain.
......
...@@ -49,9 +49,9 @@ sys.path.insert(0, os.path.join(curr_path, '../vta/python')) ...@@ -49,9 +49,9 @@ sys.path.insert(0, os.path.join(curr_path, '../vta/python'))
# General information about the project. # General information about the project.
project = u'tvm' project = u'tvm'
author = u'%s developers' % project author = u'Apache Software Foundation'
copyright = u'2018, %s' % author copyright = u'2019, %s' % author
github_doc_root = 'https://github.com/tqchen/tvm/tree/master/docs/' github_doc_root = 'https://github.com/apache/incubator-tvm/tree/master/docs/'
# add markdown parser # add markdown parser
CommonMarkParser.github_doc_root = github_doc_root CommonMarkParser.github_doc_root = github_doc_root
...@@ -73,6 +73,7 @@ extensions = [ ...@@ -73,6 +73,7 @@ extensions = [
'sphinx.ext.napoleon', 'sphinx.ext.napoleon',
'sphinx.ext.mathjax', 'sphinx.ext.mathjax',
'sphinx_gallery.gen_gallery', 'sphinx_gallery.gen_gallery',
'autodocsumm'
] ]
breathe_projects = {'tvm' : 'doxygen/xml/'} breathe_projects = {'tvm' : 'doxygen/xml/'}
...@@ -139,9 +140,6 @@ pygments_style = 'sphinx' ...@@ -139,9 +140,6 @@ pygments_style = 'sphinx'
# If true, `todo` and `todoList` produce output, else they produce nothing. # If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False todo_include_todos = False
# sort autodoc order by the source file.
autodoc_member_order = 'bysource'
# -- Options for HTML output ---------------------------------------------- # -- Options for HTML output ----------------------------------------------
# The theme is set by the make target # The theme is set by the make target
...@@ -199,9 +197,9 @@ def run_doxygen(folder): ...@@ -199,9 +197,9 @@ def run_doxygen(folder):
intersphinx_mapping = { intersphinx_mapping = {
'python': ('https://docs.python.org/{.major}'.format(sys.version_info), None), 'python': ('https://docs.python.org/{.major}'.format(sys.version_info), None),
'numpy': ('http://docs.scipy.org/doc/numpy/', None), 'numpy': ('https://docs.scipy.org/doc/numpy/', None),
'scipy': ('http://docs.scipy.org/doc/scipy/reference', None), 'scipy': ('https://docs.scipy.org/doc/scipy/reference', None),
'matplotlib': ('http://matplotlib.org/', None), 'matplotlib': ('https://matplotlib.org/', None),
} }
from sphinx_gallery.sorting import ExplicitOrder from sphinx_gallery.sorting import ExplicitOrder
...@@ -242,8 +240,8 @@ sphinx_gallery_conf = { ...@@ -242,8 +240,8 @@ sphinx_gallery_conf = {
'doc_module': ('tvm', 'numpy'), 'doc_module': ('tvm', 'numpy'),
'reference_url': { 'reference_url': {
'tvm': None, 'tvm': None,
'matplotlib': 'http://matplotlib.org', 'matplotlib': 'https://matplotlib.org/',
'numpy': 'http://docs.scipy.org/doc/numpy-1.9.1'}, 'numpy': 'https://docs.scipy.org/doc/numpy/'},
'examples_dirs': examples_dirs, 'examples_dirs': examples_dirs,
'gallery_dirs': gallery_dirs, 'gallery_dirs': gallery_dirs,
'subsection_order': subsection_order, 'subsection_order': subsection_order,
...@@ -251,3 +249,7 @@ sphinx_gallery_conf = { ...@@ -251,3 +249,7 @@ sphinx_gallery_conf = {
'find_mayavi_figures': False, 'find_mayavi_figures': False,
'expected_failing_examples': [] 'expected_failing_examples': []
} }
autodoc_default_options = {
'member-order': 'bysource',
}
...@@ -59,7 +59,7 @@ Here are some example applications of this principle: ...@@ -59,7 +59,7 @@ Here are some example applications of this principle:
Shepherd a Pull Request Shepherd a Pull Request
---------------------- -----------------------
Here are some tips to 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`. You can also take a look at the :ref:`code_review_guide`.
......
...@@ -15,25 +15,27 @@ ...@@ -15,25 +15,27 @@
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
.. _error_guide: .. _error-handling-guide:
Error Handling Guide Error Handling Guide
==================== ====================
TVM contains structured error classes to indicate specific types of error. TVM contains structured error classes to indicate specific types of error.
Please raise a specific error type when possible, so that users can Please raise a specific error type when possible, so that users can
write code to handle a specific error category if necessary. 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. You can directly raise the specific error object in python.
In other languages like c++, you simply add ``<ErrorType>:`` prefix to In other languages like c++, you simply add ``<ErrorType>:`` prefix to
the error message(see below). the error message(see below).
.. note::
Please refer to :py:mod:`tvm.error` for the list of errors.
Raise a Specific Error in C++ Raise a Specific Error in C++
----------------------------- -----------------------------
You can add ``<ErrorType>:`` prefix to your error message to You can add ``<ErrorType>:`` prefix to your error message to
raise an error of the corresponding type. raise an error of the corresponding type.
Note that you do not have to add a new 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. there is no error type prefix in the message.
This mechanism works for both ``LOG(FATAL)`` and ``CHECK`` macros. This mechanism works for both ``LOG(FATAL)`` and ``CHECK`` macros.
The following code gives an example on how to do so. 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: ...@@ -55,7 +57,7 @@ Here is what will happen if we call the registered function:
.. code:: .. code::
>>> import tvm >>> import tvm
>>> tvm._api_internal._ErrorTest(0, 1) >>> tvm.testing.ErrorTest(0, 1)
Traceback (most recent call last): Traceback (most recent call last):
File "<stdin>", line 1, in <module> File "<stdin>", line 1, in <module>
File "/path/to/tvm/python/tvm/_ffi/_ctypes/function.py", line 190, in __call__ 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: ...@@ -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 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. 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): Traceback (most recent call last):
File "<stdin>", line 1, in <module> File "<stdin>", line 1, in <module>
File "/path/to/tvm/python/tvm/_ffi/_ctypes/function.py", line 190, in __call__ 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. ...@@ -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: 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. - 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. - Update the list in this file to include the new error type.
- Change the code to use the new error type. - Change the code to use the new error type.
...@@ -118,22 +120,3 @@ error messages when necessary. ...@@ -118,22 +120,3 @@ error messages when necessary.
If we need to introduce a wrapper function that constructs multi-line error messages, 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. 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
...@@ -183,7 +183,7 @@ RPC server on iPhone/android/raspberry pi or even the browser. The cross compila ...@@ -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. 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 TVM Object and Compiler Stack
--------------------------- -----------------------------
As we mentioned earlier, we build compiler stack API on top of the PackedFunc runtime system. 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. 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.
......
...@@ -45,20 +45,24 @@ class XGBTuner(ModelBasedTuner): ...@@ -45,20 +45,24 @@ class XGBTuner(ModelBasedTuner):
For cross-shape tuning (e.g. many convolutions with different shapes), For cross-shape tuning (e.g. many convolutions with different shapes),
'itervar' and 'curve' has better transferability, 'itervar' and 'curve' has better transferability,
'knob' is faster. 'knob' is faster.
For cross-device or cross-operator tuning, you can use 'curve' only. For cross-device or cross-operator tuning, you can use 'curve' only.
loss_type: str loss_type: str
If is 'reg', use regression loss to train cost model. 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. 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 num_threads: int, optional
The number of threads. optimizer: str or ModelOptimizer, optional The number of threads. optimizer: str or ModelOptimizer, optional
If is 'sa', use a default simulated annealing optimizer. If is 'sa', use a default simulated annealing optimizer.
Otherwise it should be a ModelOptimizer object. Otherwise it should be a ModelOptimizer object.
diversity_filter_ratio: int or float, optional diversity_filter_ratio: int or float, optional
If is not None, the tuner will first select If is not None, the tuner will first select
top-(plan_size * diversity_filter_ratio) candidates according to the cost model top-(plan_size * diversity_filter_ratio) candidates according to the cost model
and then pick batch_size of them according to the diversity metric. and then pick batch_size of them according to the diversity metric.
log_interval: int, optional log_interval: int, optional
The verbose level. The verbose level.
If is 0, output nothing. If is 0, output nothing.
......
...@@ -25,19 +25,23 @@ from ..rpc import base as rpc_base ...@@ -25,19 +25,23 @@ from ..rpc import base as rpc_base
def create(graph_json_str, libmod, ctx): def create(graph_json_str, libmod, ctx):
"""Create a runtime executor module given a graph and module. """Create a runtime executor module given a graph and module.
Parameters Parameters
---------- ----------
graph_json_str : str or graph class graph_json_str : str or graph class
The graph to be deployed in json format output by json graph. The graph to be deployed in json format output by json graph.
The graph can only contain one operator(tvm_op) that The graph can only contain one operator(tvm_op) that
points to the name of PackedFunc in the libmod. points to the name of PackedFunc in the libmod.
libmod : tvm.Module
libmod : tvm.runtime.Module
The module of the corresponding function The module of the corresponding function
ctx : TVMContext or list of TVMContext ctx : TVMContext or list of TVMContext
The context to deploy the module. It can be local or remote when there 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 is only one TVMContext. Otherwise, the first context in the list will
be used as this purpose. All context should be given for heterogeneous be used as this purpose. All context should be given for heterogeneous
execution. execution.
Returns Returns
------- -------
graph_module : GraphModule graph_module : GraphModule
...@@ -61,11 +65,14 @@ def create(graph_json_str, libmod, ctx): ...@@ -61,11 +65,14 @@ def create(graph_json_str, libmod, ctx):
def get_device_ctx(libmod, ctx): def get_device_ctx(libmod, ctx):
"""Parse and validate all the device context(s). """Parse and validate all the device context(s).
Parameters Parameters
---------- ----------
libmod : tvm.Module libmod : tvm.runtime.Module
The module of the corresponding function The module of the corresponding function
ctx : TVMContext or list of TVMContext ctx : TVMContext or list of TVMContext
Returns Returns
------- -------
ctx : list of TVMContext ctx : list of TVMContext
...@@ -113,12 +120,12 @@ class GraphModule(object): ...@@ -113,12 +120,12 @@ class GraphModule(object):
Parameters Parameters
---------- ----------
module : Module module : tvm.runtime.Module
The internal tvm module that holds the actual graph functions. The internal tvm module that holds the actual graph functions.
Attributes Attributes
---------- ----------
module : Module module : tvm.runtime.Module
The internal tvm module that holds the actual graph functions. The internal tvm module that holds the actual graph functions.
""" """
......
...@@ -20,6 +20,10 @@ Each error class takes an error message as its input. ...@@ -20,6 +20,10 @@ Each error class takes an error message as its input.
See the example sections for for suggested message conventions. See the example sections for for suggested message conventions.
To make the code more readable, we recommended developers to To make the code more readable, we recommended developers to
copy the examples and raise errors with the same message convention. 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 from tvm._ffi.base import register_error, TVMError
......
...@@ -1424,7 +1424,9 @@ def batch_norm(data, ...@@ -1424,7 +1424,9 @@ def batch_norm(data,
Besides the inputs and the outputs, this operator accepts two auxiliary Besides the inputs and the outputs, this operator accepts two auxiliary
states, ``moving_mean`` and ``moving_var``, which are *k*-length 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
.. code:: python
moving_mean = moving_mean * momentum + data_mean * (1 - momentum) moving_mean = moving_mean * momentum + data_mean * (1 - momentum)
moving_var = moving_var * momentum + data_var * (1 - momentum) moving_var = moving_var * momentum + data_var * (1 - momentum)
......
...@@ -847,6 +847,7 @@ def clip(a, a_min, a_max): ...@@ -847,6 +847,7 @@ def clip(a, a_min, a_max):
Examples Examples
-------- --------
.. code:: python .. code:: python
x = relay.Constant(tvm.nd.array([0, 1, 5, 3, 4, 2])) x = relay.Constant(tvm.nd.array([0, 1, 5, 3, 4, 2]))
relay.clip(x, 1., 4.) relay.clip(x, 1., 4.)
# [1, 1, 4, 3, 4, 2] # [1, 1, 4, 3, 4, 2]
......
...@@ -51,7 +51,7 @@ The list of options include: ...@@ -51,7 +51,7 @@ The list of options include:
It is useful in environments where dynamic loading api like dlopen is banned. 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. 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. We can also use other specific function in this module to create specific targets.
""" """
from .target import Target, create from .target import Target, create
......
...@@ -30,12 +30,12 @@ class Target(Object): ...@@ -30,12 +30,12 @@ class Target(Object):
---- ----
Do not use class constructor, you can create target using the following functions 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.create` create target from string
- :py:func:`~tvm.target.arm_cpu` create arm_cpu target - :py:func:`tvm.target.arm_cpu` create arm_cpu target
- :py:func:`~tvm.target.cuda` create CUDA target - :py:func:`tvm.target.cuda` create CUDA target
- :py:func:`~tvm.target.rocm` create ROCM target - :py:func:`tvm.target.rocm` create ROCM target
- :py:func:`~tvm.target.mali` create Mali target - :py:func:`tvm.target.mali` create Mali target
- :py:func:`~tvm.target.intel_graphics` create Intel Graphics target - :py:func:`tvm.target.intel_graphics` create Intel Graphics target
""" """
def __new__(cls): def __new__(cls):
# Always override new to enable class # Always override new to enable class
...@@ -262,7 +262,7 @@ def create(target_str): ...@@ -262,7 +262,7 @@ def create(target_str):
Note 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): if isinstance(target_str, Target):
return target_str return target_str
......
...@@ -15,12 +15,16 @@ ...@@ -15,12 +15,16 @@
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
# pylint: disable=unused-import, redefined-builtin, wildcard-import # 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 # expose all operators in tvm tir.op
from tvm.tir.op import * 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
from .schedule import Schedule, create_schedule from .schedule import Schedule, create_schedule
from .tensor import TensorSlice, Tensor from .tensor import Tensor
from .tensor_intrin import decl_tensor_intrin from .tensor_intrin import decl_tensor_intrin
from .tag import tag_scope from .tag import tag_scope
from .operation import placeholder, compute, scan, extern, var, size_var from .operation import placeholder, compute, scan, extern, var, size_var
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment