Unverified Commit cc8cacb1 by Tianqi Chen Committed by GitHub

[DOCS] Bring relay docs to the top-level flat view (#5343)

- Changes most of the relay docs to use autosummary.
- Bring relay API docs to the top-level flat view for easier discovery
- Removed a few cases of re-exports.
parent 3d18adf1
...@@ -29,10 +29,18 @@ Python API ...@@ -29,10 +29,18 @@ Python API
tir tir
te te
driver driver
relay/index
relay/frontend
relay/nn
relay/vision
relay/image
relay/transform
relay/analysis
relay/backend
relay/testing
autotvm autotvm
rpc rpc
contrib contrib
graph_runtime graph_runtime
relay/index
vta/index vta/index
topi topi
...@@ -20,19 +20,6 @@ tvm.relay.frontend ...@@ -20,19 +20,6 @@ tvm.relay.frontend
------------------ ------------------
.. automodule:: tvm.relay.frontend .. automodule:: tvm.relay.frontend
:members:
.. autofunction:: tvm.relay.frontend.from_mxnet :imported-members:
:autosummary:
.. autofunction:: tvm.relay.frontend.from_keras
.. autofunction:: tvm.relay.frontend.from_onnx
.. autofunction:: tvm.relay.frontend.from_tflite
.. autofunction:: tvm.relay.frontend.from_coreml
.. autofunction:: tvm.relay.frontend.from_caffe2
.. autofunction:: tvm.relay.frontend.from_tensorflow
.. autofunction:: tvm.relay.frontend.from_pytorch
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
tvm.relay.image tvm.relay.image
--------------- ---------------
.. automodule:: tvm.relay.op.image .. automodule:: tvm.relay.image
:members: :members:
:imported-members: :imported-members:
:exclude-members: :autosummary:
...@@ -16,32 +16,13 @@ ...@@ -16,32 +16,13 @@
under the License. under the License.
tvm.relay tvm.relay
========= ---------
This document contains the Python API for the Relay frontend, optimizer, and
compiler toolchain.
Relay is the second-generation, high-level intermediate representation (IR) for the TVM
compiler stack.
.. toctree::
:maxdepth: 2
analysis
backend
frontend
image
transform
nn
op
vision
testing
.. automodule:: tvm.relay .. automodule:: tvm.relay
:members: :members:
:imported-members: :imported-members:
:exclude-members: RelayExpr, Pass, PassInfo, function_pass, PassContext, :exclude-members: RelayExpr,
ModulePass, FunctionPass, Sequential, module_pass, Type, TypeKind, Type, TypeKind,
TypeVar, GlobalTypeVar, TypeConstraint, FuncType, TupleType, IncompleteType, TypeVar, GlobalTypeVar, TypeConstraint, FuncType, TupleType, IncompleteType,
TypeCall, TypeRelation, TensorType, RelayRefType, GlobalVar, SourceName, TypeCall, TypeRelation, TensorType, RelayRefType, GlobalVar, SourceName,
Span, Var, Op, Constructor Span, Var, Op, Constructor
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
tvm.relay.nn tvm.relay.nn
------------ ------------
.. automodule:: tvm.relay.op.nn.nn .. automodule:: tvm.relay.nn
:members: :members:
:imported-members: :imported-members:
:exclude-members: :autosummary:
.. 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.op
------------
.. automodule:: tvm.relay.op
:members:
:imported-members:
:exclude-members: Tuple, TupleWrapper
:autosummary:
...@@ -18,4 +18,34 @@ ...@@ -18,4 +18,34 @@
tvm.relay.testing tvm.relay.testing
----------------- -----------------
.. autoclass:: tvm.relay.testing.resnet .. automodule:: tvm.relay.testing
:members:
:imported-members:
:autosummary:
.. automodule:: tvm.relay.testing.mlp
:members:
.. automodule:: tvm.relay.testing.resnet
:members:
.. automodule:: tvm.relay.testing.dcgan
:members:
.. automodule:: tvm.relay.testing.mobilenet
:members:
.. automodule:: tvm.relay.testing.lstm
:members:
.. automodule:: tvm.relay.testing.inception_v3
:members:
.. automodule:: tvm.relay.testing.squeezenet
:members:
.. automodule:: tvm.relay.testing.vgg
:members:
.. automodule:: tvm.relay.testing.densenet
:members:
...@@ -21,5 +21,4 @@ tvm.relay.transform ...@@ -21,5 +21,4 @@ tvm.relay.transform
.. automodule:: tvm.relay.transform .. automodule:: tvm.relay.transform
:members: :members:
:imported-members: :imported-members:
:exclude-members: Object
:autosummary: :autosummary:
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
tvm.relay.vision tvm.relay.vision
---------------- ----------------
.. automodule:: tvm.relay.op.vision .. automodule:: tvm.relay.vision
:members: :members:
:imported-members: :imported-members:
:autosummary: :autosummary:
...@@ -16,6 +16,5 @@ ...@@ -16,6 +16,5 @@
# under the License. # under the License.
# pylint: disable=wildcard-import # pylint: disable=wildcard-import
"""Image network related operators.""" """Image network related operators."""
from __future__ import absolute_import as _abs
from .image import * from .image import *
from ._image import * from . import _image
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
"""Image operations.""" """Image operations."""
from __future__ import absolute_import as _abs
from . import _make from . import _make
def resize(data, def resize(data,
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
# under the License. # under the License.
#pylint: disable=invalid-name, too-many-lines #pylint: disable=invalid-name, too-many-lines
"""Neural network operations.""" """Neural network operations."""
from __future__ import absolute_import as _abs from tvm.relay import expr
from ...expr import TupleWrapper
from . import _make from . import _make
from .util import get_pad_tuple2d, get_pad_tuple3d from .util import get_pad_tuple2d, get_pad_tuple3d
...@@ -1457,7 +1457,7 @@ def dropout(data, rate=0.5): ...@@ -1457,7 +1457,7 @@ def dropout(data, rate=0.5):
result : tvm.relay.Expr result : tvm.relay.Expr
The result of dropout The result of dropout
""" """
return TupleWrapper(dropout_raw(data, rate), 2)[0] return expr.TupleWrapper(dropout_raw(data, rate), 2)[0]
def dropout_raw(data, rate=0.5): def dropout_raw(data, rate=0.5):
...@@ -1580,7 +1580,7 @@ def batch_norm(data, ...@@ -1580,7 +1580,7 @@ def batch_norm(data,
epsilon, epsilon,
center, center,
scale) scale)
return TupleWrapper(result, 3) return expr.TupleWrapper(result, 3)
def instance_norm(data, def instance_norm(data,
...@@ -1791,7 +1791,8 @@ def sparse_transpose(x): ...@@ -1791,7 +1791,8 @@ def sparse_transpose(x):
Tuple of output sparse tensor (same shape and format as input), Tuple of output sparse tensor (same shape and format as input),
i.e. if CSR then output is in ([data, indices, indptr]) form i.e. if CSR then output is in ([data, indices, indptr]) form
""" """
return TupleWrapper(_make.sparse_transpose(x.data, x.indices, x.indptr), 3) return expr.TupleWrapper(
_make.sparse_transpose(x.data, x.indices, x.indptr), 3)
def contrib_conv2d_winograd_without_weight_transform(data, def contrib_conv2d_winograd_without_weight_transform(data,
weight, weight,
......
...@@ -15,8 +15,9 @@ ...@@ -15,8 +15,9 @@
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
"""Multibox operations.""" """Multibox operations."""
from tvm.relay import expr
from . import _make from . import _make
from ...expr import TupleWrapper
def multibox_prior(data, def multibox_prior(data,
sizes=(1.0,), sizes=(1.0,),
...@@ -86,6 +87,7 @@ def multibox_transform_loc(cls_prob, ...@@ -86,6 +87,7 @@ def multibox_transform_loc(cls_prob,
------- -------
ret : tuple of tvm.relay.Expr ret : tuple of tvm.relay.Expr
""" """
return TupleWrapper(_make.multibox_transform_loc(cls_prob, loc_pred, return expr.TupleWrapper(
_make.multibox_transform_loc(cls_prob, loc_pred,
anchor, clip, threshold, anchor, clip, threshold,
variances), 2) variances), 2)
...@@ -15,8 +15,9 @@ ...@@ -15,8 +15,9 @@
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
"""Non-maximum suppression operations.""" """Non-maximum suppression operations."""
from tvm.relay import expr
from . import _make from . import _make
from ...expr import TupleWrapper
def get_valid_counts(data, def get_valid_counts(data,
score_threshold, score_threshold,
...@@ -47,7 +48,8 @@ def get_valid_counts(data, ...@@ -47,7 +48,8 @@ def get_valid_counts(data,
out_tensor : relay.Expr out_tensor : relay.Expr
Rearranged data tensor. Rearranged data tensor.
""" """
return TupleWrapper(_make.get_valid_counts(data, score_threshold, return expr.TupleWrapper(
_make.get_valid_counts(data, score_threshold,
id_index, score_index), 2) id_index, score_index), 2)
......
...@@ -23,9 +23,7 @@ import tvm ...@@ -23,9 +23,7 @@ import tvm
from tvm import te from tvm import te
import tvm.relay as relay import tvm.relay as relay
import tvm.relay.op as op import tvm.relay.op as op
from tvm.relay import transform
from tvm.relay import Function, GlobalVar, ScopeBuilder, Tuple, TupleGetItem, create_executor
from tvm.relay import TensorType, TupleType
from . import mlp from . import mlp
from . import resnet from . import resnet
...@@ -55,7 +53,7 @@ def run_opt_pass(expr, opt_pass): ...@@ -55,7 +53,7 @@ def run_opt_pass(expr, opt_pass):
def run_infer_type(expr): def run_infer_type(expr):
return run_opt_pass(expr, transform.InferType()) return run_opt_pass(expr, relay.transform.InferType())
def _np_randn_from_type(t, scale=1, mean=0): def _np_randn_from_type(t, scale=1, mean=0):
......
...@@ -140,7 +140,7 @@ def add_nat_definitions(prelude): ...@@ -140,7 +140,7 @@ def add_nat_definitions(prelude):
"""Given a Relay prelude, adds a Peano nat ADT, as well as functions """Given a Relay prelude, adds a Peano nat ADT, as well as functions
for adding nats and doubling nats. It also adds versions of for adding nats and doubling nats. It also adds versions of
update, nth, and iterate that take nats instead of scalars (the update, nth, and iterate that take nats instead of scalars (the
names are prefixed with 'nat_').""" names are prefixed with `nat_`)."""
define_nat_adt(prelude) define_nat_adt(prelude)
define_nat_double(prelude) define_nat_double(prelude)
define_nat_add(prelude) define_nat_add(prelude)
......
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