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
tir
te
driver
relay/index
relay/frontend
relay/nn
relay/vision
relay/image
relay/transform
relay/analysis
relay/backend
relay/testing
autotvm
rpc
contrib
graph_runtime
relay/index
vta/index
topi
......@@ -20,19 +20,6 @@ tvm.relay.frontend
------------------
.. automodule:: tvm.relay.frontend
.. autofunction:: tvm.relay.frontend.from_mxnet
.. 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
:members:
:imported-members:
:autosummary:
......@@ -19,7 +19,7 @@
tvm.relay.image
---------------
.. automodule:: tvm.relay.op.image
.. automodule:: tvm.relay.image
:members:
:imported-members:
:exclude-members:
:autosummary:
......@@ -16,32 +16,13 @@
under the License.
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
:members:
:imported-members:
:exclude-members: RelayExpr, Pass, PassInfo, function_pass, PassContext,
ModulePass, FunctionPass, Sequential, module_pass, Type, TypeKind,
:exclude-members: RelayExpr,
Type, TypeKind,
TypeVar, GlobalTypeVar, TypeConstraint, FuncType, TupleType, IncompleteType,
TypeCall, TypeRelation, TensorType, RelayRefType, GlobalVar, SourceName,
Span, Var, Op, Constructor
......
......@@ -17,7 +17,7 @@
tvm.relay.nn
------------
.. automodule:: tvm.relay.op.nn.nn
.. automodule:: tvm.relay.nn
: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 @@
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
.. automodule:: tvm.relay.transform
:members:
:imported-members:
:exclude-members: Object
:autosummary:
......@@ -19,7 +19,7 @@
tvm.relay.vision
----------------
.. automodule:: tvm.relay.op.vision
.. automodule:: tvm.relay.vision
:members:
:imported-members:
:autosummary:
......@@ -16,6 +16,5 @@
# under the License.
# pylint: disable=wildcard-import
"""Image network related operators."""
from __future__ import absolute_import as _abs
from .image import *
from ._image import *
from . import _image
......@@ -15,7 +15,6 @@
# specific language governing permissions and limitations
# under the License.
"""Image operations."""
from __future__ import absolute_import as _abs
from . import _make
def resize(data,
......
......@@ -16,8 +16,8 @@
# under the License.
#pylint: disable=invalid-name, too-many-lines
"""Neural network operations."""
from __future__ import absolute_import as _abs
from ...expr import TupleWrapper
from tvm.relay import expr
from . import _make
from .util import get_pad_tuple2d, get_pad_tuple3d
......@@ -1457,7 +1457,7 @@ def dropout(data, rate=0.5):
result : tvm.relay.Expr
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):
......@@ -1580,7 +1580,7 @@ def batch_norm(data,
epsilon,
center,
scale)
return TupleWrapper(result, 3)
return expr.TupleWrapper(result, 3)
def instance_norm(data,
......@@ -1791,7 +1791,8 @@ def sparse_transpose(x):
Tuple of output sparse tensor (same shape and format as input),
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,
weight,
......
......@@ -15,8 +15,9 @@
# specific language governing permissions and limitations
# under the License.
"""Multibox operations."""
from tvm.relay import expr
from . import _make
from ...expr import TupleWrapper
def multibox_prior(data,
sizes=(1.0,),
......@@ -86,6 +87,7 @@ def multibox_transform_loc(cls_prob,
-------
ret : tuple of tvm.relay.Expr
"""
return TupleWrapper(_make.multibox_transform_loc(cls_prob, loc_pred,
anchor, clip, threshold,
variances), 2)
return expr.TupleWrapper(
_make.multibox_transform_loc(cls_prob, loc_pred,
anchor, clip, threshold,
variances), 2)
......@@ -15,8 +15,9 @@
# specific language governing permissions and limitations
# under the License.
"""Non-maximum suppression operations."""
from tvm.relay import expr
from . import _make
from ...expr import TupleWrapper
def get_valid_counts(data,
score_threshold,
......@@ -47,8 +48,9 @@ def get_valid_counts(data,
out_tensor : relay.Expr
Rearranged data tensor.
"""
return TupleWrapper(_make.get_valid_counts(data, score_threshold,
id_index, score_index), 2)
return expr.TupleWrapper(
_make.get_valid_counts(data, score_threshold,
id_index, score_index), 2)
def non_max_suppression(data,
......
......@@ -23,9 +23,7 @@ import tvm
from tvm import te
import tvm.relay as relay
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 resnet
......@@ -55,7 +53,7 @@ def run_opt_pass(expr, opt_pass):
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):
......
......@@ -140,7 +140,7 @@ def add_nat_definitions(prelude):
"""Given a Relay prelude, adds a Peano nat ADT, as well as functions
for adding nats and doubling nats. It also adds versions of
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_double(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