diff --git a/docs/arch/index.rst b/docs/arch/index.rst index b84afeea2818..17884a774253 100644 --- a/docs/arch/index.rst +++ b/docs/arch/index.rst @@ -408,15 +408,6 @@ Frontends ingest models from different frameworks into the TVM stack. frontend/tensorflow - -Security ---------- -.. toctree:: - :maxdepth: 1 - - security - - microTVM -------- .. toctree:: diff --git a/docs/conf.py b/docs/conf.py index be1ba11aa091..482cb6e8527f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -39,6 +39,7 @@ import re import sys from textwrap import dedent, indent +from typing import List from unittest.mock import patch # If extensions (or modules to document with autodoc) are in another directory, @@ -712,10 +713,50 @@ def update_alias_docstring(name, obj, lines): lines.append(".. rubric:: Alias of %s:`%s.%s`" % (obj_type, amod, target_name)) +tvm_class_name_rewrite_map = { + "tvm.tir": ["Var", "Call"], + "tvm.relax": ["Var", "Call"], + "tvm.relax.frontend.nn": ["Module"], +} + + +def distinguish_class_name(name: str, lines: List[str]): + """Distinguish the docstring of type annotations. + + In the whole TVM, there are many classes with the same name but in different modules, + e.g. ``tir.Var``, ``relax.Var``. This function is used to distinguish them in the docstring, + by adding the module name as prefix. + + To be specific, this function will check the current object name, and if it in the specific + module with specific name, it will add the module name as prefix to the class name to prevent + the confusion. Further, we only add the prefix to those standalone class name, but skip + the pattern of `xx.Var`, `Var.xx` and `xx.Var.xx`. + + Parameters + ---------- + name : str + The full name of the object in the doc. + + lines : list + The docstring lines, need to be modified inplace. + """ + remap = {} + for module_name in tvm_class_name_rewrite_map: + if name.startswith(module_name): + short_name = module_name[4:] if module_name.startswith("tvm.") else module_name + for class_name in tvm_class_name_rewrite_map[module_name]: + remap.update({class_name: f"{short_name}.{class_name}"}) + + for k, v in remap.items(): + for i in range(len(lines)): + lines[i] = re.sub(rf"(?`, :ref:`TVM's operator inventory (topi) ` and looking at the example cumulative sum and product implementations found in `python/tvm/topi/scan.py`_ and the gpu versions in -`python/tvm/topi/cuda/scan.py`_. In the case of our cumulative sum and product -operations we write things directly in :ref:`TIR ` which is the -representation where tensor expressions and topi will lower into. +`python/tvm/topi/cuda/scan.py`_. .. _python/tvm/topi/scan.py: https://github.com/apache/tvm/blob/main/python/tvm/topi/scan.py .. _python/tvm/topi/cuda/scan.py: https://github.com/apache/tvm/blob/main/python/tvm/topi/cuda/scan.py -5. Hooking up Compute and Strategy with Relay +1. Hooking up Compute and Strategy with Relay --------------------------------------------- After you have implemented your compute function we now need to glue it to our diff --git a/docs/index.rst b/docs/index.rst index 95b1937671ea..55b0dd980992 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -51,23 +51,29 @@ driving its costs down. .. toctree:: :maxdepth: 1 - :caption: Architecture Guide + :caption: API Reference - arch/index + reference/api/python/index + reference/api/links .. toctree:: :maxdepth: 1 - :caption: Topic Guides + :caption: Legacy + reference/langref/index + arch/index topic/microtvm/index topic/vta/index .. toctree:: :maxdepth: 1 - :caption: Reference Guide + :caption: About - reference/langref/index - reference/api/python/index - reference/api/links reference/publications + reference/security + +.. toctree:: + :maxdepth: 1 + :caption: Index + genindex diff --git a/docs/reference/api/python/dlight.rst b/docs/reference/api/python/dlight.rst new file mode 100644 index 000000000000..37859ed790f4 --- /dev/null +++ b/docs/reference/api/python/dlight.rst @@ -0,0 +1,22 @@ +.. 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.dlight +---------- +.. automodule:: tvm.dlight + :members: + :imported-members: diff --git a/docs/reference/api/python/index.rst b/docs/reference/api/python/index.rst index 5dc1ed806dfd..e64ea304cbee 100644 --- a/docs/reference/api/python/index.rst +++ b/docs/reference/api/python/index.rst @@ -18,34 +18,89 @@ Python API ========== +.. toctree:: + :maxdepth: 1 + :caption: tvm + + error + ir + instrument + transform + target + driver + +.. toctree:: + :maxdepth: 1 + :caption: tvm.runtime + + runtime/runtime + runtime/ndarray + runtime/relax_vm + runtime/disco + runtime/profiling + +.. toctree:: + :maxdepth: 1 + :caption: tvm.relax + + relax/relax + relax/analysis + relax/block_builder + relax/frontend + relax/op + relax/transform + +.. toctree:: + :maxdepth: 1 + :caption: tvm.tir + + tir/tir + tir/analysis + tir/schedule + tir/stmt_functor + tir/transform + +.. toctree:: + :maxdepth: 1 + :caption: tvm.te + + te + topi + +.. toctree:: + :maxdepth: 1 + :caption: tvm.meta_schedule + + meta_schedule + +.. toctree:: + :maxdepth: 1 + :caption: tvm.dlight + + dlight + +.. toctree:: + :maxdepth: 1 + :caption: Misc + + rpc + contrib .. toctree:: - :maxdepth: 2 - - runtime - ndarray - error - ir - target - tir - te - driver - relay/index - relay/frontend - relay/nn - relay/vision - relay/image - relay/transform - relay/analysis - relay/backend - relay/dataflow_pattern - relay/testing - autotvm - auto_scheduler - meta_schedule - rpc - micro - contrib - graph_executor - topi - vta/index + :maxdepth: 1 + :caption: Legacy + + relay/index + relay/frontend + relay/nn + relay/vision + relay/image + relay/transform + relay/analysis + relay/backend + relay/dataflow_pattern + relay/testing + autotvm + auto_scheduler + micro + graph_executor diff --git a/docs/reference/api/python/instrument.rst b/docs/reference/api/python/instrument.rst new file mode 100644 index 000000000000..270a19690b9e --- /dev/null +++ b/docs/reference/api/python/instrument.rst @@ -0,0 +1,22 @@ +.. 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.instrument +-------------- +.. automodule:: tvm.instrument + :members: + :imported-members: diff --git a/docs/reference/api/python/ir.rst b/docs/reference/api/python/ir.rst index e7fb3c114689..1f0dc0c5e23c 100644 --- a/docs/reference/api/python/ir.rst +++ b/docs/reference/api/python/ir.rst @@ -21,19 +21,3 @@ tvm.ir :members: :imported-members: :autosummary: - - -tvm.instrument --------------- -.. automodule:: tvm.instrument - :members: - :imported-members: - :autosummary: - - -tvm.transform -------------- -.. automodule:: tvm.transform - :members: - :imported-members: - :autosummary: diff --git a/docs/reference/api/python/relax/analysis.rst b/docs/reference/api/python/relax/analysis.rst new file mode 100644 index 000000000000..b6598b54574e --- /dev/null +++ b/docs/reference/api/python/relax/analysis.rst @@ -0,0 +1,22 @@ +.. 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.relax.analysis +------------------ +.. automodule:: tvm.relax.analysis + :members: + :imported-members: diff --git a/docs/reference/api/python/relax/block_builder.rst b/docs/reference/api/python/relax/block_builder.rst new file mode 100644 index 000000000000..a1c2a7c4354b --- /dev/null +++ b/docs/reference/api/python/relax/block_builder.rst @@ -0,0 +1,21 @@ +.. 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.relax.block_builder +----------------------- +.. automodule:: tvm.relax.block_builder + :members: diff --git a/docs/reference/api/python/relax/frontend.rst b/docs/reference/api/python/relax/frontend.rst new file mode 100644 index 000000000000..c037f323ed1a --- /dev/null +++ b/docs/reference/api/python/relax/frontend.rst @@ -0,0 +1,48 @@ +.. 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.relax.frontend +------------------ +.. automodule:: tvm.relax.frontend + :members: + :imported-members: + +tvm.relax.frontend.nn +********************* +.. automodule:: tvm.relax.frontend.nn + :members: + :imported-members: + :exclude-members: BlockBuilder + :noindex: + +tvm.relax.frontend.onnx +*********************** +.. automodule:: tvm.relax.frontend.onnx + :members: + :imported-members: + +tvm.relax.frontend.stablehlo +**************************** +.. automodule:: tvm.relax.frontend.stablehlo + :members: + :imported-members: + +tvm.relax.frontend.torch +************************ +.. automodule:: tvm.relax.frontend.torch + :members: + :imported-members: diff --git a/docs/reference/api/python/relax/op.rst b/docs/reference/api/python/relax/op.rst new file mode 100644 index 000000000000..21f638442a84 --- /dev/null +++ b/docs/reference/api/python/relax/op.rst @@ -0,0 +1,72 @@ +.. 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.relax.op +------------ + +tvm.relax.op +************ +.. automodule:: tvm.relax.op + :members: + :imported-members: + +tvm.relax.op.nn +*************** +.. automodule:: tvm.relax.op.nn + :members: + :imported-members: + +tvm.relax.op.builtin +******************** +.. automodule:: tvm.relax.op.builtin + :members: + :imported-members: + +tvm.relax.op.ccl +**************** +.. automodule:: tvm.relax.op.ccl + :members: + :imported-members: + +tvm.relax.op.distributed +************************ +.. automodule:: tvm.relax.op.distributed + :members: + :imported-members: + +tvm.relax.op.grad +***************** +.. automodule:: tvm.relax.op.grad + :members: + :imported-members: + +tvm.relax.op.image +****************** +.. automodule:: tvm.relax.op.image + :members: + :imported-members: + +tvm.relax.op.memory +******************* +.. automodule:: tvm.relax.op.memory + :members: + :imported-members: + +tvm.relax.op.op_attrs +********************* +.. automodule:: tvm.relax.op.op_attrs + :members: diff --git a/docs/reference/api/python/relax/relax.rst b/docs/reference/api/python/relax/relax.rst new file mode 100644 index 000000000000..4df1f1279b59 --- /dev/null +++ b/docs/reference/api/python/relax/relax.rst @@ -0,0 +1,23 @@ +.. 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.relax +--------- +.. automodule:: tvm.relax + :members: + :imported-members: + :exclude-members: BlockBuilder, Span, GlobalVar, SourceName, TupleType, Type, FuncType diff --git a/docs/reference/api/python/relax/transform.rst b/docs/reference/api/python/relax/transform.rst new file mode 100644 index 000000000000..dcb41e80fd67 --- /dev/null +++ b/docs/reference/api/python/relax/transform.rst @@ -0,0 +1,24 @@ +.. 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. + +.. _api-relax-transformation: + +tvm.relax.transform +------------------- +.. automodule:: tvm.relax.transform + :members: + :imported-members: diff --git a/docs/reference/api/python/relay/transform.rst b/docs/reference/api/python/relay/transform.rst index c66904d8bcba..4a8747606eb2 100644 --- a/docs/reference/api/python/relay/transform.rst +++ b/docs/reference/api/python/relay/transform.rst @@ -22,3 +22,4 @@ tvm.relay.transform :members: :imported-members: :autosummary: + :exclude-members: FunctionPass diff --git a/docs/reference/api/python/runtime/disco.rst b/docs/reference/api/python/runtime/disco.rst new file mode 100644 index 000000000000..6a9b60394732 --- /dev/null +++ b/docs/reference/api/python/runtime/disco.rst @@ -0,0 +1,22 @@ +.. 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.runtime.disco +----------------- +.. automodule:: tvm.runtime.disco + :members: + :imported-members: diff --git a/docs/reference/api/python/ndarray.rst b/docs/reference/api/python/runtime/ndarray.rst similarity index 88% rename from docs/reference/api/python/ndarray.rst rename to docs/reference/api/python/runtime/ndarray.rst index aa828905ca21..8c794f04b193 100644 --- a/docs/reference/api/python/ndarray.rst +++ b/docs/reference/api/python/runtime/ndarray.rst @@ -18,10 +18,4 @@ tvm.runtime.ndarray ------------------- .. automodule:: tvm.runtime.ndarray - -.. autoclass:: tvm.nd.NDArray :members: - :inherited-members: - -.. autofunction:: tvm.nd.array -.. autofunction:: tvm.nd.empty diff --git a/docs/reference/api/python/runtime/profiling.rst b/docs/reference/api/python/runtime/profiling.rst new file mode 100644 index 000000000000..d26f00af90c6 --- /dev/null +++ b/docs/reference/api/python/runtime/profiling.rst @@ -0,0 +1,21 @@ +.. 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.runtime.profiling +--------------------- +.. automodule:: tvm.runtime.profiling + :members: diff --git a/docs/reference/api/python/vta/index.rst b/docs/reference/api/python/runtime/relax_vm.rst similarity index 61% rename from docs/reference/api/python/vta/index.rst rename to docs/reference/api/python/runtime/relax_vm.rst index 479b8394f0cb..75afcb7939ab 100644 --- a/docs/reference/api/python/vta/index.rst +++ b/docs/reference/api/python/runtime/relax_vm.rst @@ -15,31 +15,7 @@ specific language governing permissions and limitations under the License. -vta -=== - -This document contains the python API to VTA compiler toolchain. - -.. automodule:: vta - -Hardware Information +tvm.runtime.relax_vm -------------------- - -.. autofunction:: vta.Environment -.. autofunction:: vta.get_env - -RPC Utilities -------------- - -.. autofunction:: vta.reconfig_runtime -.. autofunction:: vta.program_fpga - - -Compiler API ------------- -We program VTA using TVM, so the compiler API in vta package -is only a thin wrapper to provide VTA specific extensions. - -.. autofunction:: vta.build_config -.. autofunction:: vta.build -.. autofunction:: vta.lower +.. automodule:: tvm.runtime.relax_vm + :members: diff --git a/docs/reference/api/python/runtime.rst b/docs/reference/api/python/runtime/runtime.rst similarity index 95% rename from docs/reference/api/python/runtime.rst rename to docs/reference/api/python/runtime/runtime.rst index c51a2d452065..4dd9d9653369 100644 --- a/docs/reference/api/python/runtime.rst +++ b/docs/reference/api/python/runtime/runtime.rst @@ -17,9 +17,6 @@ tvm.runtime ----------- - .. automodule:: tvm.runtime :members: - :imported-members: :exclude-members: NDArray - :autosummary: diff --git a/docs/reference/api/python/tir/analysis.rst b/docs/reference/api/python/tir/analysis.rst new file mode 100644 index 000000000000..aa777358bcf2 --- /dev/null +++ b/docs/reference/api/python/tir/analysis.rst @@ -0,0 +1,21 @@ +.. 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.tir.analysis +---------------- +.. automodule:: tvm.tir.analysis.analysis + :members: diff --git a/docs/reference/api/python/tir/schedule.rst b/docs/reference/api/python/tir/schedule.rst new file mode 100644 index 000000000000..17e4a4593a47 --- /dev/null +++ b/docs/reference/api/python/tir/schedule.rst @@ -0,0 +1,22 @@ +.. 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.tir.schedule +----------------- +.. automodule:: tvm.tir.schedule + :members: + :imported-members: diff --git a/docs/reference/api/python/tir/stmt_functor.rst b/docs/reference/api/python/tir/stmt_functor.rst new file mode 100644 index 000000000000..3b6c9bb64a89 --- /dev/null +++ b/docs/reference/api/python/tir/stmt_functor.rst @@ -0,0 +1,21 @@ +.. 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.tir.stmt_functor +-------------------- +.. automodule:: tvm.tir.stmt_functor + :members: diff --git a/docs/reference/api/python/tir/tir.rst b/docs/reference/api/python/tir/tir.rst new file mode 100644 index 000000000000..3f82fe8261ac --- /dev/null +++ b/docs/reference/api/python/tir/tir.rst @@ -0,0 +1,23 @@ +.. 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.tir +------- +.. automodule:: tvm.tir + :members: + :imported-members: + :exclude-members: PrimExpr, const, StmtSRef, BlockScope, ScheduleState, Schedule, ScheduleError diff --git a/docs/reference/api/python/tir.rst b/docs/reference/api/python/tir/transform.rst similarity index 68% rename from docs/reference/api/python/tir.rst rename to docs/reference/api/python/tir/transform.rst index 2152be69ea6f..8ce641b6d3f6 100644 --- a/docs/reference/api/python/tir.rst +++ b/docs/reference/api/python/tir/transform.rst @@ -15,36 +15,9 @@ specific language governing permissions and limitations under the License. -.. _api-python-tir: - -tvm.tir -------- -.. automodule:: tvm.tir - :members: - :imported-members: - :exclude-members: PrimExpr, const - :autosummary: - tvm.tir.transform ----------------- .. automodule:: tvm.tir.transform :members: :imported-members: - :autosummary: - - -tvm.tir.analysis ----------------- -.. automodule:: tvm.tir.analysis - :members: - :imported-members: - :noindex: Buffer, Stmt - :autosummary: - - -tvm.tir.stmt_functor --------------------- -.. automodule:: tvm.tir.stmt_functor - :members: - :autosummary: diff --git a/docs/reference/api/python/transform.rst b/docs/reference/api/python/transform.rst new file mode 100644 index 000000000000..d200dfdd1139 --- /dev/null +++ b/docs/reference/api/python/transform.rst @@ -0,0 +1,22 @@ +.. 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.transform +------------- +.. automodule:: tvm.transform + :members: + :imported-members: diff --git a/docs/arch/security.rst b/docs/reference/security.rst similarity index 100% rename from docs/arch/security.rst rename to docs/reference/security.rst diff --git a/python/tvm/driver/build_module.py b/python/tvm/driver/build_module.py index c332062b37b9..08af27e32f04 100644 --- a/python/tvm/driver/build_module.py +++ b/python/tvm/driver/build_module.py @@ -105,7 +105,7 @@ def lower( inp : Union[tvm.te.schedule.Schedule, tvm.tir.PrimFunc, IRModule] The TE schedule or TensorIR PrimFunc/IRModule to be built - args : Optional[List[Union[tvm.tir.Buffer, tensor.Tensor, Var]]] + args : Optional[List[Union[tvm.tir.Buffer, tensor.Tensor, tir.Var]]] The argument lists to the function for TE schedule. It should be None if we want to lower TensorIR. @@ -156,7 +156,7 @@ def build( inputs : Union[tvm.te.schedule.Schedule, tvm.tir.PrimFunc, IRModule, Mapping[str, IRModule]] The input to be built - args : Optional[List[Union[tvm.tir.Buffer, tensor.Tensor, Var]]] + args : Optional[List[Union[tvm.tir.Buffer, tensor.Tensor, tir.Var]]] The argument lists to the function. target : Optional[Union[str, Target]] diff --git a/python/tvm/relax/op/create.py b/python/tvm/relax/op/create.py index 8fd3b2cde1e7..092d79a74dc4 100644 --- a/python/tvm/relax/op/create.py +++ b/python/tvm/relax/op/create.py @@ -241,7 +241,7 @@ def tril(x: Expr, k: Union[int, PrimExpr, Expr] = 0) -> Expr: return _ffi_api.tril(x, k) # type: ignore -def triu(x: Expr, k: [int, PrimExpr, Expr] = 0) -> Expr: +def triu(x: Expr, k: Union[int, PrimExpr, Expr] = 0) -> Expr: """Return the upper triangular part of a matrix or a batch of matrices. Parameters diff --git a/python/tvm/relax/transform/transform.py b/python/tvm/relax/transform/transform.py index 2546284625e9..95649f331f33 100644 --- a/python/tvm/relax/transform/transform.py +++ b/python/tvm/relax/transform/transform.py @@ -391,8 +391,8 @@ def ConvertToDataflow(min_size: int = 2) -> tvm.ir.transform.Pass: Note: ConvertToDataflow may need to be called first. - Params - ------ + Parameters + ---------- min_size: int The minimum number of consecutive dataflow bindings the pass needs to extract a new block. @@ -647,13 +647,8 @@ def BindParams( func_name: str The function name to be bound - params : Dict[ - Union[str,relax.Var], - Union[tvm.runtime.NDArray, np.ndarray], - ] - - The map from parameter or parameter name to constant - tensors. + params: Dict[Union[str,relax.Var], Union[tvm.runtime.NDArray, np.ndarray]] + The map from parameter or parameter name to constant tensors. Returns ------- @@ -994,16 +989,16 @@ def LiftTransformParams(shared_transform: Union[bool, List[str]] = False) -> tvm Indicates how the parameter transformation function will be produced - `False` (default): A separate parameter transformation function will be - produced for each function with the `"num_input"` attribute. + produced for each function with the `"num_input"` attribute. - `True`: A single parameter transformation function will be produced, - containing the preprocessing steps common across all functions with - the `"num_input"` attribute. + containing the preprocessing steps common across all functions with + the `"num_input"` attribute. - List[str]: A single parameter transformation function will be produced, - containing the preprocessing steps common across each function whose - name is in the list. Passing a list of all functions with the `"num_input"` - attribute or an empty list is equivalent to passing `True`. + containing the preprocessing steps common across each function whose + name is in the list. Passing a list of all functions with the `"num_input"` + attribute or an empty list is equivalent to passing `True`. Returns ------- @@ -1219,7 +1214,7 @@ def MetaScheduleTuneIRMod( maximum number of trials per task op_names: Optional[List[str]] A list of operator names to specify which op to tune. When it is None, all operators - are tuned. + are tuned. Returns ------- diff --git a/python/tvm/runtime/profiling/__init__.py b/python/tvm/runtime/profiling/__init__.py index 347d8b9f94f1..23ce5476f5b0 100644 --- a/python/tvm/runtime/profiling/__init__.py +++ b/python/tvm/runtime/profiling/__init__.py @@ -230,6 +230,7 @@ def profile_function(mod, dev, collectors, func_name=None, warmup_iters=10): ------- .. code-block: python + f = tvm.build(my_func, target="llvm", name="my_func") prof = tvm.runtime.profiling.profile_function( f, @@ -247,7 +248,7 @@ def profile_function(mod, dev, collectors, func_name=None, warmup_iters=10): Device to run the function on. collectors: List[MetricCollector] - :py:class:`MetricCollector`s which will collect performance information. + :py:class:`MetricCollector` which will collect performance information. func_name: Optional[str] Name of the function in `mod` to profile. Defaults to the `entry_name` of `mod`. warmup_iters: int diff --git a/python/tvm/target/__init__.py b/python/tvm/target/__init__.py index 78a7e0160db7..14bd4753d400 100644 --- a/python/tvm/target/__init__.py +++ b/python/tvm/target/__init__.py @@ -51,7 +51,7 @@ Build TVM system library module. System lib is a global module that contains self registered functions in program startup. User can get the module using - :any:`tvm.runtime.system_lib`. + `tvm.runtime.system_lib`. 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. diff --git a/python/tvm/te/operation.py b/python/tvm/te/operation.py index 64a282dcf755..63a3ecd57b1c 100644 --- a/python/tvm/te/operation.py +++ b/python/tvm/te/operation.py @@ -459,7 +459,7 @@ def var(name="tindex", dtype="int32", span=None): Returns ------- - var : Var + var : tir.Var The result symbolic variable. """ return tvm.tir.Var(name, dtype, span) diff --git a/python/tvm/tir/buffer.py b/python/tvm/tir/buffer.py index 501d13b17e3d..1109cc3d66d6 100644 --- a/python/tvm/tir/buffer.py +++ b/python/tvm/tir/buffer.py @@ -262,7 +262,7 @@ def decl_buffer( name : str, optional The name of the buffer. - data : Var, optional + data : tir.Var, optional The data pointer in the buffer. strides: array of Expr