From bbe9b15d288647b6bd52fa5238bef9c20a38df71 Mon Sep 17 00:00:00 2001 From: Siyuan Feng Date: Tue, 20 Aug 2024 13:47:11 +0800 Subject: [PATCH 1/3] [Docs] Introduce Relax API and move legacy part to standalone page As the TVM project evolves, the Unity strategy has been the recommended way to use Apache TVM applications. Hence, we are pushing documentation for the Relax API to the forefront and moving the legacy part to a standalone page, which may be removed in the future. --- docs/index.rst | 15 ++- docs/reference/api/python/dlight.rst | 22 ++++ docs/reference/api/python/index.rst | 113 +++++++++++++----- docs/reference/api/python/instrument.rst | 22 ++++ docs/reference/api/python/relax/analysis.rst | 22 ++++ .../api/python/relax/block_builder.rst | 21 ++++ docs/reference/api/python/relax/frontend.rst | 48 ++++++++ docs/reference/api/python/relax/op.rst | 72 +++++++++++ docs/reference/api/python/relax/relax.rst | 23 ++++ docs/reference/api/python/relax/transform.rst | 24 ++++ docs/reference/api/python/runtime/disco.rst | 22 ++++ docs/reference/api/python/runtime/ndarray.rst | 21 ++++ .../api/python/runtime/profiling.rst | 21 ++++ .../{vta/index.rst => runtime/relax_vm.rst} | 30 +---- .../api/python/{ => runtime}/runtime.rst | 2 - docs/reference/api/python/tir/analysis.rst | 21 ++++ docs/reference/api/python/tir/schedule.rst | 22 ++++ .../reference/api/python/tir/stmt_functor.rst | 21 ++++ docs/reference/api/python/tir/tir.rst | 23 ++++ .../api/python/{tir.rst => tir/transform.rst} | 27 ----- docs/reference/api/python/transform.rst | 22 ++++ 21 files changed, 521 insertions(+), 93 deletions(-) create mode 100644 docs/reference/api/python/dlight.rst create mode 100644 docs/reference/api/python/instrument.rst create mode 100644 docs/reference/api/python/relax/analysis.rst create mode 100644 docs/reference/api/python/relax/block_builder.rst create mode 100644 docs/reference/api/python/relax/frontend.rst create mode 100644 docs/reference/api/python/relax/op.rst create mode 100644 docs/reference/api/python/relax/relax.rst create mode 100644 docs/reference/api/python/relax/transform.rst create mode 100644 docs/reference/api/python/runtime/disco.rst create mode 100644 docs/reference/api/python/runtime/ndarray.rst create mode 100644 docs/reference/api/python/runtime/profiling.rst rename docs/reference/api/python/{vta/index.rst => runtime/relax_vm.rst} (61%) rename docs/reference/api/python/{ => runtime}/runtime.rst (98%) create mode 100644 docs/reference/api/python/tir/analysis.rst create mode 100644 docs/reference/api/python/tir/schedule.rst create mode 100644 docs/reference/api/python/tir/stmt_functor.rst create mode 100644 docs/reference/api/python/tir/tir.rst rename docs/reference/api/python/{tir.rst => tir/transform.rst} (68%) create mode 100644 docs/reference/api/python/transform.rst diff --git a/docs/index.rst b/docs/index.rst index 95b1937671ea..fb916fc391e4 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -51,23 +51,22 @@ 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 - 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/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/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/runtime/ndarray.rst b/docs/reference/api/python/runtime/ndarray.rst new file mode 100644 index 000000000000..8c794f04b193 --- /dev/null +++ b/docs/reference/api/python/runtime/ndarray.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.ndarray +------------------- +.. automodule:: tvm.runtime.ndarray + :members: 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 98% rename from docs/reference/api/python/runtime.rst rename to docs/reference/api/python/runtime/runtime.rst index c51a2d452065..1175f75136d6 100644 --- a/docs/reference/api/python/runtime.rst +++ b/docs/reference/api/python/runtime/runtime.rst @@ -17,9 +17,7 @@ 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: From ae02e4e40ccdd4abfbac73127b00de19259b3233 Mon Sep 17 00:00:00 2001 From: Siyuan Feng Date: Wed, 21 Aug 2024 12:43:31 +0800 Subject: [PATCH 2/3] update for ci --- docs/reference/api/python/ir.rst | 16 ---------------- docs/reference/api/python/ndarray.rst | 6 ------ docs/reference/api/python/relax/relax.rst | 3 ++- 3 files changed, 2 insertions(+), 23 deletions(-) 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/ndarray.rst b/docs/reference/api/python/ndarray.rst index aa828905ca21..8c794f04b193 100644 --- a/docs/reference/api/python/ndarray.rst +++ b/docs/reference/api/python/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/relax/relax.rst b/docs/reference/api/python/relax/relax.rst index 4df1f1279b59..88d016b3804d 100644 --- a/docs/reference/api/python/relax/relax.rst +++ b/docs/reference/api/python/relax/relax.rst @@ -20,4 +20,5 @@ tvm.relax .. automodule:: tvm.relax :members: :imported-members: - :exclude-members: BlockBuilder, Span, GlobalVar, SourceName, TupleType, Type, FuncType + :exclude-members: BlockBuilder, Span, GlobalVar, SourceName, TupleType, Type, FuncType, + Var, Call From 1e42b1e6649853a5fab8d172201b79ea50773637 Mon Sep 17 00:00:00 2001 From: Siyuan Feng Date: Wed, 21 Aug 2024 14:35:22 +0800 Subject: [PATCH 3/3] update for ci --- docs/arch/index.rst | 9 ---- docs/conf.py | 41 +++++++++++++++++++ docs/dev/how_to/relay_add_op.rst | 6 +-- docs/index.rst | 7 ++++ docs/reference/api/python/ndarray.rst | 21 ---------- docs/reference/api/python/relax/relax.rst | 3 +- docs/reference/api/python/relay/transform.rst | 1 + docs/reference/api/python/runtime/runtime.rst | 1 - docs/{arch => reference}/security.rst | 0 python/tvm/driver/build_module.py | 4 +- python/tvm/relax/op/create.py | 2 +- python/tvm/relax/transform/transform.py | 27 +++++------- python/tvm/runtime/profiling/__init__.py | 3 +- python/tvm/target/__init__.py | 2 +- python/tvm/te/operation.py | 2 +- python/tvm/tir/buffer.py | 2 +- 16 files changed, 71 insertions(+), 60 deletions(-) delete mode 100644 docs/reference/api/python/ndarray.rst rename docs/{arch => reference}/security.rst (100%) 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 fb916fc391e4..55b0dd980992 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -70,3 +70,10 @@ driving its costs down. :caption: About reference/publications + reference/security + +.. toctree:: + :maxdepth: 1 + :caption: Index + + genindex diff --git a/docs/reference/api/python/ndarray.rst b/docs/reference/api/python/ndarray.rst deleted file mode 100644 index 8c794f04b193..000000000000 --- a/docs/reference/api/python/ndarray.rst +++ /dev/null @@ -1,21 +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.runtime.ndarray -------------------- -.. automodule:: tvm.runtime.ndarray - :members: diff --git a/docs/reference/api/python/relax/relax.rst b/docs/reference/api/python/relax/relax.rst index 88d016b3804d..4df1f1279b59 100644 --- a/docs/reference/api/python/relax/relax.rst +++ b/docs/reference/api/python/relax/relax.rst @@ -20,5 +20,4 @@ tvm.relax .. automodule:: tvm.relax :members: :imported-members: - :exclude-members: BlockBuilder, Span, GlobalVar, SourceName, TupleType, Type, FuncType, - Var, Call + :exclude-members: BlockBuilder, Span, GlobalVar, SourceName, TupleType, Type, FuncType 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/runtime.rst b/docs/reference/api/python/runtime/runtime.rst index 1175f75136d6..4dd9d9653369 100644 --- a/docs/reference/api/python/runtime/runtime.rst +++ b/docs/reference/api/python/runtime/runtime.rst @@ -19,5 +19,4 @@ tvm.runtime ----------- .. automodule:: tvm.runtime :members: - :imported-members: :exclude-members: NDArray 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