From 3230c81eb80f0a9de3369e64fb79263428bf080b Mon Sep 17 00:00:00 2001 From: Zhi <5145158+zhiics@users.noreply.github.com> Date: Fri, 20 Mar 2020 19:58:48 -0700 Subject: [PATCH] [docs] Update relay docs (#5112) * Update relay docs * any -> py:func * make clean --- docs/api/python/relay/analysis.rst | 44 +------ docs/api/python/relay/base.rst | 26 ---- docs/api/python/relay/build_module.rst | 32 ----- docs/api/python/relay/expr.rst | 67 ---------- docs/api/python/relay/image.rst | 7 +- docs/api/python/relay/index.rst | 16 ++- docs/api/python/relay/nn.rst | 5 +- docs/api/python/relay/op.rst | 2 +- docs/api/python/relay/scope_builder.rst | 24 ---- docs/api/python/relay/transform.rst | 72 +---------- docs/api/python/relay/vision.rst | 10 +- docs/conf.py | 1 + docs/langref/relay_op.rst | 155 ------------------------ python/tvm/relay/analysis/__init__.py | 3 +- tests/scripts/task_sphinx_precheck.sh | 1 + tutorials/relay_quick_start.py | 9 +- 16 files changed, 34 insertions(+), 440 deletions(-) delete mode 100644 docs/api/python/relay/base.rst delete mode 100644 docs/api/python/relay/build_module.rst delete mode 100644 docs/api/python/relay/expr.rst delete mode 100644 docs/api/python/relay/scope_builder.rst diff --git a/docs/api/python/relay/analysis.rst b/docs/api/python/relay/analysis.rst index 1fd417b670c6..ee2ae2fe1e7b 100644 --- a/docs/api/python/relay/analysis.rst +++ b/docs/api/python/relay/analysis.rst @@ -19,43 +19,7 @@ tvm.relay.analysis ---------------------- .. automodule:: tvm.relay.analysis - -.. autofunction:: tvm.relay.analysis.post_order_visit - -.. autofunction:: tvm.relay.analysis.well_formed - -.. autofunction:: tvm.relay.analysis.check_kind - -.. autofunction:: tvm.relay.analysis.check_constant - -.. autofunction:: tvm.relay.analysis.free_vars - -.. autofunction:: tvm.relay.analysis.bound_vars - -.. autofunction:: tvm.relay.analysis.all_vars - -.. autofunction:: tvm.relay.analysis.free_type_vars - -.. autofunction:: tvm.relay.analysis.bound_type_vars - -.. autofunction:: tvm.relay.analysis.all_type_vars - -.. autofunction:: tvm.relay.analysis.alpha_equal - -.. autofunction:: tvm.relay.analysis.assert_alpha_equal - -.. autofunction:: tvm.relay.analysis.graph_equal - -.. autofunction:: tvm.relay.analysis.assert_graph_equal - -.. autofunction:: tvm.relay.analysis.collect_device_info - -.. autofunction:: tvm.relay.analysis.collect_device_annotation_ops - -.. autofunction:: tvm.relay.analysis.get_total_mac_number - -.. autofunction:: tvm.relay.analysis.unmatched_cases - -.. autofunction:: tvm.relay.analysis.detect_feature - -.. autofunction:: tvm.relay.analysis.structural_hash + :members: + :imported-members: + :exclude-members: Object, RelayExpr, IRModule, Type + :autosummary: diff --git a/docs/api/python/relay/base.rst b/docs/api/python/relay/base.rst deleted file mode 100644 index 8dcab78d3231..000000000000 --- a/docs/api/python/relay/base.rst +++ /dev/null @@ -1,26 +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.base --------------- -.. automodule:: tvm.relay.base - -.. autoclass:: tvm.relay.base.RelayNode - :members: - -.. autoclass:: tvm.relay.base.Id - :members: diff --git a/docs/api/python/relay/build_module.rst b/docs/api/python/relay/build_module.rst deleted file mode 100644 index f470b9aff80f..000000000000 --- a/docs/api/python/relay/build_module.rst +++ /dev/null @@ -1,32 +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.build_module ----------------------- - -.. automodule:: tvm.relay.build - -.. automodule:: tvm.relay.build_module - -.. autofunction:: tvm.relay.build_module.build - -.. autofunction:: tvm.relay.build_module.optimize - -.. autofunction:: tvm.relay.build_module.create_executor - -.. autoclass:: tvm.relay.build_module.GraphExecutor - :members: diff --git a/docs/api/python/relay/expr.rst b/docs/api/python/relay/expr.rst deleted file mode 100644 index cfb6df0f8e1d..000000000000 --- a/docs/api/python/relay/expr.rst +++ /dev/null @@ -1,67 +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.expr --------------- - -.. automodule:: tvm.relay.expr - -.. autofunction:: tvm.relay.expr.var - -.. autofunction:: tvm.relay.expr.const - -.. autofunction:: tvm.relay.expr.bind - -.. autoclass:: tvm.relay.expr.Expr - :members: - -.. autoclass:: tvm.relay.expr.Constant - :members: - -.. autoclass:: tvm.relay.expr.Tuple - :members: - -.. autoclass:: tvm.relay.expr.Call - :members: - -.. autoclass:: tvm.relay.expr.Let - :members: - -.. autoclass:: tvm.relay.expr.If - :members: - -.. autoclass:: tvm.relay.expr.TupleGetItem - :members: - -.. autoclass:: tvm.relay.expr.RefCreate - :members: - -.. autoclass:: tvm.relay.expr.RefRead - :members: - -.. autoclass:: tvm.relay.expr.RefWrite - :members: - -.. autoclass:: tvm.relay.expr.TupleGetItem - :members: - -.. autoclass:: tvm.relay.expr.TempExpr - :members: - -.. autoclass:: tvm.relay.expr.TupleWrapper - :members: - diff --git a/docs/api/python/relay/image.rst b/docs/api/python/relay/image.rst index 075edec202ec..e29cf3009a0b 100644 --- a/docs/api/python/relay/image.rst +++ b/docs/api/python/relay/image.rst @@ -19,8 +19,7 @@ tvm.relay.image --------------- -.. automodule:: tvm.relay.image - :members: - .. automodule:: tvm.relay.op.image - :members: + :members: + :imported-members: + :exclude-members: diff --git a/docs/api/python/relay/index.rst b/docs/api/python/relay/index.rst index 03c8a37c9c5a..49bb4ab22ad5 100644 --- a/docs/api/python/relay/index.rst +++ b/docs/api/python/relay/index.rst @@ -27,16 +27,22 @@ compiler stack. .. toctree:: :maxdepth: 2 + analysis backend - base - build_module - expr frontend image - analysis transform nn op - scope_builder vision testing + +.. automodule:: tvm.relay + :members: + :imported-members: + :exclude-members: RelayExpr, Pass, PassInfo, function_pass, PassContext, + ModulePass, FunctionPass, Sequential, module_pass, Type, TypeKind, + TypeVar, GlobalTypeVar, TypeConstraint, FuncType, TupleType, IncompleteType, + TypeCall, TypeRelation, TensorType, RelayRefType, GlobalVar, SourceName, + Span, Var, Op, Constructor + :autosummary: diff --git a/docs/api/python/relay/nn.rst b/docs/api/python/relay/nn.rst index 39a1f78592d1..c67c932006d5 100644 --- a/docs/api/python/relay/nn.rst +++ b/docs/api/python/relay/nn.rst @@ -17,8 +17,7 @@ tvm.relay.nn ------------ -.. automodule:: tvm.relay.nn - :members: - .. automodule:: tvm.relay.op.nn.nn :members: + :imported-members: + :exclude-members: diff --git a/docs/api/python/relay/op.rst b/docs/api/python/relay/op.rst index 898f103e89bf..8843b28be930 100644 --- a/docs/api/python/relay/op.rst +++ b/docs/api/python/relay/op.rst @@ -20,5 +20,5 @@ tvm.relay.op .. automodule:: tvm.relay.op :members: :imported-members: - :exclude-members: Tuple + :exclude-members: Tuple, TupleWrapper :autosummary: diff --git a/docs/api/python/relay/scope_builder.rst b/docs/api/python/relay/scope_builder.rst deleted file mode 100644 index 6d8e01428e31..000000000000 --- a/docs/api/python/relay/scope_builder.rst +++ /dev/null @@ -1,24 +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.scope_builder ------------------------ - -.. automodule:: tvm.relay.scope_builder - -.. autoclass:: tvm.relay.scope_builder.ScopeBuilder - :members: diff --git a/docs/api/python/relay/transform.rst b/docs/api/python/relay/transform.rst index 346152b9c769..b5040a0d0c68 100644 --- a/docs/api/python/relay/transform.rst +++ b/docs/api/python/relay/transform.rst @@ -19,73 +19,7 @@ tvm.relay.transform ---------------------- .. automodule:: tvm.relay.transform - -.. autofunction:: tvm.relay.transform.build_config - -.. autofunction:: tvm.relay.transform.module_pass - -.. autofunction:: tvm.relay.transform.function_pass - -.. autofunction:: tvm.relay.transform.InferType - -.. autofunction:: tvm.relay.transform.FoldScaleAxis - -.. autofunction:: tvm.relay.transform.BackwardFoldScaleAxis - -.. autofunction:: tvm.relay.transform.ForwardFoldScaleAxis - -.. autofunction:: tvm.relay.transform.SimplifyInference - -.. autofunction:: tvm.relay.transform.CanonicalizeOps - -.. autofunction:: tvm.relay.transform.DeadCodeElimination - -.. autofunction:: tvm.relay.transform.FoldConstant - -.. autofunction:: tvm.relay.transform.FuseOps - -.. autofunction:: tvm.relay.transform.CombineParallelConv2D - -.. autofunction:: tvm.relay.transform.CombineParallelDense - -.. autofunction:: tvm.relay.transform.AlterOpLayout - -.. autofunction:: tvm.relay.transform.Legalize - -.. autofunction:: tvm.relay.transform.RewriteAnnotatedOps - -.. autofunction:: tvm.relay.transform.ToANormalForm - -.. autofunction:: tvm.relay.transform.ToCPS - -.. autofunction:: tvm.relay.transform.EtaExpand - -.. autofunction:: tvm.relay.transform.ToGraphNormalForm - -.. autofunction:: tvm.relay.transform.EliminateCommonSubexpr - -.. autofunction:: tvm.relay.transform.PartialEvaluate - -.. autofunction:: tvm.relay.transform.CanonicalizeCast - -.. autofunction:: tvm.relay.transform.LambdaLift - -.. autofunction:: tvm.relay.transform.PrintIR - -.. autoclass:: tvm.relay.transform.Pass - :members: - -.. autoclass:: tvm.relay.transform.PassInfo - :members: - -.. autoclass:: tvm.relay.transform.PassContext - :members: - -.. autoclass:: tvm.relay.transform.ModulePass - :members: - -.. autoclass:: tvm.relay.transform.FunctionPass - :members: - -.. autoclass:: tvm.relay.transform.Sequential :members: + :imported-members: + :exclude-members: Object + :autosummary: diff --git a/docs/api/python/relay/vision.rst b/docs/api/python/relay/vision.rst index 624c6f177966..1b5ca7444ae0 100644 --- a/docs/api/python/relay/vision.rst +++ b/docs/api/python/relay/vision.rst @@ -19,11 +19,7 @@ tvm.relay.vision ---------------- -.. automodule:: tvm.relay.vision - :members: - -.. automodule:: tvm.relay.op.vision.multibox - :members: - -.. automodule:: tvm.relay.op.vision.nms +.. automodule:: tvm.relay.op.vision :members: + :imported-members: + :autosummary: diff --git a/docs/conf.py b/docs/conf.py index 95fd1c3c0467..db067098f5c2 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -250,6 +250,7 @@ def run_doxygen(folder): tvm_alias_check_map = { "tvm.te": ["tvm.tir"], "tvm.tir": ["tvm.ir", "tvm.runtime"], + "tvm.relay": ["tvm.ir", "tvm.tir"], } def update_alias_docstring(name, obj, lines): diff --git a/docs/langref/relay_op.rst b/docs/langref/relay_op.rst index 00c7ab9641e7..35f9eeb64063 100644 --- a/docs/langref/relay_op.rst +++ b/docs/langref/relay_op.rst @@ -218,158 +218,3 @@ This level supports dialect operators. tvm.relay.qnn.op.requantize tvm.relay.qnn.op.conv2d - - -Level 1 Definitions -------------------- -.. autofunction:: tvm.relay.log -.. autofunction:: tvm.relay.sqrt -.. autofunction:: tvm.relay.rsqrt -.. autofunction:: tvm.relay.exp -.. autofunction:: tvm.relay.sigmoid -.. autofunction:: tvm.relay.add -.. autofunction:: tvm.relay.subtract -.. autofunction:: tvm.relay.multiply -.. autofunction:: tvm.relay.divide -.. autofunction:: tvm.relay.floor_divide -.. autofunction:: tvm.relay.mod -.. autofunction:: tvm.relay.floor_mod -.. autofunction:: tvm.relay.tanh -.. autofunction:: tvm.relay.concatenate -.. autofunction:: tvm.relay.expand_dims -.. autofunction:: tvm.relay.nn.softmax -.. autofunction:: tvm.relay.nn.log_softmax -.. autofunction:: tvm.relay.nn.relu -.. autofunction:: tvm.relay.nn.dropout -.. autofunction:: tvm.relay.nn.batch_norm -.. autofunction:: tvm.relay.nn.bias_add - - -Level 2 Definitions -------------------- -.. autofunction:: tvm.relay.nn.conv2d -.. autofunction:: tvm.relay.nn.conv2d_transpose -.. autofunction:: tvm.relay.nn.dense -.. autofunction:: tvm.relay.nn.max_pool2d -.. autofunction:: tvm.relay.nn.max_pool3d -.. autofunction:: tvm.relay.nn.avg_pool2d -.. autofunction:: tvm.relay.nn.avg_pool3d -.. autofunction:: tvm.relay.nn.global_max_pool2d -.. autofunction:: tvm.relay.nn.global_avg_pool2d -.. autofunction:: tvm.relay.nn.upsampling -.. autofunction:: tvm.relay.nn.upsampling3d -.. autofunction:: tvm.relay.nn.batch_flatten -.. autofunction:: tvm.relay.nn.pad -.. autofunction:: tvm.relay.nn.lrn -.. autofunction:: tvm.relay.nn.l2_normalize -.. autofunction:: tvm.relay.nn.contrib_conv2d_winograd_without_weight_transform -.. autofunction:: tvm.relay.nn.contrib_conv2d_winograd_weight_transform - -Level 3 Definitions -------------------- -.. autofunction:: tvm.relay.nn.leaky_relu -.. autofunction:: tvm.relay.nn.prelu -.. autofunction:: tvm.relay.reshape -.. autofunction:: tvm.relay.reshape_like -.. autofunction:: tvm.relay.copy -.. autofunction:: tvm.relay.transpose -.. autofunction:: tvm.relay.squeeze -.. autofunction:: tvm.relay.floor -.. autofunction:: tvm.relay.ceil -.. autofunction:: tvm.relay.sign -.. autofunction:: tvm.relay.trunc -.. autofunction:: tvm.relay.clip -.. autofunction:: tvm.relay.round -.. autofunction:: tvm.relay.abs -.. autofunction:: tvm.relay.negative -.. autofunction:: tvm.relay.take -.. autofunction:: tvm.relay.zeros -.. autofunction:: tvm.relay.zeros_like -.. autofunction:: tvm.relay.ones -.. autofunction:: tvm.relay.ones_like -.. autofunction:: tvm.relay.gather_nd -.. autofunction:: tvm.relay.full -.. autofunction:: tvm.relay.full_like -.. autofunction:: tvm.relay.cast -.. autofunction:: tvm.relay.reinterpret -.. autofunction:: tvm.relay.split -.. autofunction:: tvm.relay.arange -.. autofunction:: tvm.relay.stack -.. autofunction:: tvm.relay.repeat -.. autofunction:: tvm.relay.tile -.. autofunction:: tvm.relay.reverse - - -Level 4 Definitions -------------------- -.. autofunction:: tvm.relay.right_shift -.. autofunction:: tvm.relay.left_shift -.. autofunction:: tvm.relay.equal -.. autofunction:: tvm.relay.not_equal -.. autofunction:: tvm.relay.greater -.. autofunction:: tvm.relay.greater_equal -.. autofunction:: tvm.relay.less -.. autofunction:: tvm.relay.less_equal -.. autofunction:: tvm.relay.all -.. autofunction:: tvm.relay.any -.. autofunction:: tvm.relay.logical_and -.. autofunction:: tvm.relay.logical_or -.. autofunction:: tvm.relay.logical_not -.. autofunction:: tvm.relay.maximum -.. autofunction:: tvm.relay.minimum -.. autofunction:: tvm.relay.power -.. autofunction:: tvm.relay.where -.. autofunction:: tvm.relay.argmax -.. autofunction:: tvm.relay.argmin -.. autofunction:: tvm.relay.sum -.. autofunction:: tvm.relay.max -.. autofunction:: tvm.relay.min -.. autofunction:: tvm.relay.mean -.. autofunction:: tvm.relay.variance -.. autofunction:: tvm.relay.std -.. autofunction:: tvm.relay.mean_variance -.. autofunction:: tvm.relay.mean_std -.. autofunction:: tvm.relay.prod -.. autofunction:: tvm.relay.strided_slice -.. autofunction:: tvm.relay.broadcast_to - - -Level 5 Definitions -------------------- -.. autofunction:: tvm.relay.image.resize -.. autofunction:: tvm.relay.image.crop_and_resize -.. autofunction:: tvm.relay.image.dilation2d -.. autofunction:: tvm.relay.vision.multibox_prior -.. autofunction:: tvm.relay.vision.multibox_transform_loc -.. autofunction:: tvm.relay.vision.nms -.. autofunction:: tvm.relay.vision.yolo_reorg - - -Level 6 Definitions -------------------- -.. autofunction:: tvm.relay.argsort -.. autofunction:: tvm.relay.topk - - -Level 10 Definitions --------------------- -.. autofunction:: tvm.relay.broadcast_to_like -.. autofunction:: tvm.relay.collapse_sum_like -.. autofunction:: tvm.relay.slice_like -.. autofunction:: tvm.relay.shape_of -.. autofunction:: tvm.relay.ndarray_size -.. autofunction:: tvm.relay.layout_transform -.. autofunction:: tvm.relay.device_copy -.. autofunction:: tvm.relay.annotation.on_device -.. autofunction:: tvm.relay.reverse_reshape -.. autofunction:: tvm.relay.sequence_mask -.. autofunction:: tvm.relay.nn.batch_matmul -.. autofunction:: tvm.relay.nn.adaptive_max_pool2d -.. autofunction:: tvm.relay.nn.adaptive_avg_pool2d -.. autofunction:: tvm.relay.one_hot - - -Level 11 Definitions --------------------- -.. autofunction:: tvm.relay.qnn.op.requantize -.. autofunction:: tvm.relay.qnn.op.conv2d diff --git a/python/tvm/relay/analysis/__init__.py b/python/tvm/relay/analysis/__init__.py index 957f5a3dcd94..e5185eaf42b4 100644 --- a/python/tvm/relay/analysis/__init__.py +++ b/python/tvm/relay/analysis/__init__.py @@ -21,8 +21,7 @@ # Call graph from . import call_graph +from .call_graph import CallGraph # Feature from . import feature - -CallGraph = call_graph.CallGraph diff --git a/tests/scripts/task_sphinx_precheck.sh b/tests/scripts/task_sphinx_precheck.sh index 1f4288632b9d..2179cb0cfedf 100755 --- a/tests/scripts/task_sphinx_precheck.sh +++ b/tests/scripts/task_sphinx_precheck.sh @@ -34,6 +34,7 @@ find . -type f -path "*.pyc" | xargs rm -f echo "PreCheck sphinx doc generation WARNINGS.." cd docs +make clean TVM_TUTORIAL_EXEC_PATTERN=none make html 2>/tmp/$$.log.txt grep -v -E "__mro__|RemovedInSphinx|UserWarning|FutureWarning|Keras" < /tmp/$$.log.txt > /tmp/$$.logclean.txt || true diff --git a/tutorials/relay_quick_start.py b/tutorials/relay_quick_start.py index b258d1bf3338..b2174a048035 100644 --- a/tutorials/relay_quick_start.py +++ b/tutorials/relay_quick_start.py @@ -56,7 +56,7 @@ # # In this tutorial, we assume we will do inference on our device # and the batch size is set to be 1. Input images are RGB color -# images of size 224 * 224. We can call the :any:`tvm.relay.expr.TupleWrapper.astext()` +# images of size 224 * 224. We can call the :any:`tvm.relay.TupleWrapper.astext()` # to show the network structure. batch_size = 1 @@ -79,14 +79,14 @@ # Currently this value can be 0 to 3. The optimization passes include # operator fusion, pre-computation, layout transformation and so on. # -# :any:`relay.build_module.build` returns three components: the execution graph in +# :py:func:`relay.build` returns three components: the execution graph in # json format, the TVM module library of compiled functions specifically # for this graph on the target hardware, and the parameter blobs of # the model. During the compilation, Relay does the graph-level # optimization while TVM does the tensor-level optimization, resulting # in an optimized runtime module for model serving. # -# We'll first compile for Nvidia GPU. Behind the scene, `relay.build_module.build` +# We'll first compile for Nvidia GPU. Behind the scene, :py:func:`relay.build` # first does a number of graph-level optimizations, e.g. pruning, fusing, etc., # then registers the operators (i.e. the nodes of the optimized graphs) to # TVM implementations to generate a `tvm.module`. @@ -97,8 +97,7 @@ opt_level = 3 target = tvm.target.cuda() with relay.build_config(opt_level=opt_level): - graph, lib, params = relay.build_module.build( - mod, target, params=params) + graph, lib, params = relay.build(mod, target, params=params) ##################################################################### # Run the generate library