diff --git a/docs/01-getting-started/01-overview.md b/docs/01-getting-started/01-overview.md index fce0cd4..7e5d21f 100644 --- a/docs/01-getting-started/01-overview.md +++ b/docs/01-getting-started/01-overview.md @@ -13,13 +13,13 @@ Apache TVM 是一个机器学习编译框架,**遵循Python 优先开发和通 ## 核心目标 * 优化机器学习任务的性能,组合使用库与代码生成器。 -* 部署机器学习任务至多种全新环境,包括新的运行时和新硬件。 +* 部署机器学习任务至多种全新环境,包括新的运行时和新硬件。 * 持续改进与定制机器学习部署流程,可通过 Python 快速定制库调度,引入定制算子与代码生成方式。 ## 关键流程 -以下是使用 TVM 部署机器学习模型的典型流程。可运行示例请参见 [快速开始](https://tvm.apache.org/docs/get_started/tutorials/quick_start.html#quick-start)。 +以下是使用 TVM 部署机器学习模型的典型流程。可运行示例请参见 [快速开始](/docs/getting-started/quick-start/)。 1. **导入 / 构建一个机器学习模型** @@ -31,7 +31,7 @@ TVM 支持从多种框架导入模型用于通用机器学习模型,如 PyTorc pipeline 封装了一系列转换,以实现两个目标: * **图优化:** 如算子融合、布局重写等。 - * **张量程序优化:** 将算子映射到底层实现(包括库或代码生成器)。 + * **张量程序优化:** 将算子映射到底层实现(包括库或代码生成器)。 :::note diff --git a/docs/01-getting-started/02-installing-tvm/01-install-from-source.md b/docs/01-getting-started/02-installing-tvm/01-install-from-source.md index 9ef3ad0..88abe27 100644 --- a/docs/01-getting-started/02-installing-tvm/01-install-from-source.md +++ b/docs/01-getting-started/02-installing-tvm/01-install-from-source.md @@ -9,19 +9,19 @@ title: 从源码安装 **目录** -* [步骤 1:安装依赖项](https://tvm.apache.org/docs/install/from_source.html#step-1-install-dependencies) -* [步骤 2:从 GitHub 获取源码](https://tvm.apache.org/docs/install/from_source.html#step-2-get-source-from-github) -* [步骤 3:配置与构建](https://tvm.apache.org/docs/install/from_source.html#step-3-configure-and-build) -* [步骤 4:验证安装](https://tvm.apache.org/docs/install/from_source.html#step-4-validate-installation) -* [步骤 5:额外 Python 依赖项](https://tvm.apache.org/docs/install/from_source.html#step-5-extra-python-dependencies) -* [高级构建配置](https://tvm.apache.org/docs/install/from_source.html#advanced-build-configuration) - * [Ccache](https://tvm.apache.org/docs/install/from_source.html#ccache) - * [在 Windows 上构建](https://tvm.apache.org/docs/install/from_source.html#building-on-windows) - * [构建 ROCm 支持](https://tvm.apache.org/docs/install/from_source.html#building-rocm-support) - * [启用 C++ 测试](https://tvm.apache.org/docs/install/from_source.html#enable-c-tests) +* [步骤 1:安装依赖项](/docs/getting-started/installing-tvm/install-from-source#%E6%AD%A5%E9%AA%A4-1%E5%AE%89%E8%A3%85%E4%BE%9D%E8%B5%96%E9%A1%B9) +* [步骤 2:从 GitHub 获取源码](/docs/getting-started/installing-tvm/install-from-source#%E6%AD%A5%E9%AA%A4-2%E4%BB%8E-github-%E8%8E%B7%E5%8F%96%E6%BA%90%E7%A0%81) +* [步骤 3:配置与构建](/docs/getting-started/installing-tvm/install-from-source#%E6%AD%A5%E9%AA%A4-3%E9%85%8D%E7%BD%AE%E4%B8%8E%E6%9E%84%E5%BB%BA) +* [步骤 4:验证安装](/docs/getting-started/installing-tvm/install-from-source#%E6%AD%A5%E9%AA%A4-4%E9%AA%8C%E8%AF%81%E5%AE%89%E8%A3%85) +* [步骤 5:额外 Python 依赖项](/docs/getting-started/installing-tvm/install-from-source#%E6%AD%A5%E9%AA%A4-5-%E9%A2%9D%E5%A4%96-python-%E4%BE%9D%E8%B5%96%E9%A1%B9) +* [高级构建配置](/docs/getting-started/installing-tvm/install-from-source#%E9%AB%98%E7%BA%A7%E6%9E%84%E5%BB%BA%E9%85%8D%E7%BD%AE) + * [Ccache](/docs/getting-started/installing-tvm/install-from-source#ccache) + * [在 Windows 上构建](/docs/getting-started/installing-tvm/install-from-source#%E5%9C%A8-windows-%E4%B8%8A%E6%9E%84%E5%BB%BA) + * [构建 ROCm 支持](/docs/getting-started/installing-tvm/install-from-source#%E6%9E%84%E5%BB%BA-rocm-%E6%94%AF%E6%8C%81) + * [启用 C++ 测试](/docs/getting-started/installing-tvm/install-from-source#%E5%90%AF%E7%94%A8-c-%E6%B5%8B%E8%AF%95) -## [步骤 1:安装依赖项](https://tvm.apache.org/docs/install/from_source.html#id2) +## 步骤 1:安装依赖项 Apache TVM 需要以下依赖项: * CMake (>= 3.24.0) @@ -62,7 +62,7 @@ conda activate tvm-build-venv ``` -## [步骤 2:从 GitHub 获取源码](https://tvm.apache.org/docs/install/from_source.html#id3) +## 步骤 2:从 GitHub 获取源码 你也可以选择从 GitHub 克隆源码仓库: @@ -80,7 +80,7 @@ git clone --recursive https://github.com/apache/tvm tvm ::: -## [步骤 3:配置与构建](https://tvm.apache.org/docs/install/from_source.html#id4) +## 步骤 3:配置与构建 创建一个构建目录并运行 CMake 进行配置。以下示例展示了如何构建: @@ -162,7 +162,7 @@ pip install -e /path-to-tvm/python ``` -## [步骤 4:验证安装](https://tvm.apache.org/docs/install/from_source.html#id5) +## 步骤 4:验证安装 由于 TVM 是一个支持多语言绑定的编译器基础设施,安装过程中容易出错。因此,强烈建议在使用前验证安装。 @@ -225,7 +225,7 @@ False # or True 请注意,上述命令验证的是本地机器上实际设备的存在情况,供 TVM 运行时(而非编译器)正确执行。然而,TVM 编译器可以在不需要物理设备的情况下执行编译任务。只要具备必要的工具链(如 NVCC),TVM 就支持在没有实际设备的情况下进行交叉编译。 -## [步骤 5. 额外 Python 依赖项](https://tvm.apache.org/docs/install/from_source.html#id6) +## 步骤 5. 额外 Python 依赖项 从源代码构建不会自动安装所有必要的 Python 依赖项。可以使用以下命令安装额外的 Python 依赖项: * 必要依赖项: @@ -243,9 +243,9 @@ pip3 install tornado ```plain pip3 install tornado psutil 'xgboost>=1.1.0' cloudpickle ``` -## [高级构建配置](https://tvm.apache.org/docs/install/from_source.html#id7) +## 高级构建配置 -### [Ccache](https://tvm.apache.org/docs/install/from_source.html#id8) +### Ccache 在支持的平台上,[Ccache 编译器包装器](https://ccache.dev/) 可以显著减少 TVM 的构建时间(尤其是构建 [cutlass](https://github.com/NVIDIA/cutlass) 或 [flashinfer](https://github.com/flashinfer-ai/flashinfer) 时)。启用 Ccache 的方式如下: @@ -255,12 +255,12 @@ pip3 install tornado psutil 'xgboost>=1.1.0' cloudpickle * 将 Ccache 作为 CMake 的 C++ 编译器前缀。配置时设置 `CMAKE_CXX_COMPILER_LAUNCHER`,例如:`cmake -DCMAKE_CXX_COMPILER_LAUNCHER=ccache ...`。 -### [在 Windows 上构建](https://tvm.apache.org/docs/install/from_source.html#id9) +### 在 Windows 上构建 TVM 支持通过 MSVC 和 CMake 在 Windows 上构建。你需要安装 Visual Studio 编译器(最低要求:**Visual Studio Enterprise 2019**)。我们测试了 [GitHub Actions 的 Windows 2019 Runner](https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md) 的配置,可访问该页面获取全部细节。 -推荐按照 [步骤 1:安装依赖项](https://tvm.apache.org/docs/install/from_source.html#install-dependencies) 获取依赖项并激活 tvm-build 环境后,运行以下命令构建: +推荐按照 [步骤 1:安装依赖项](/docs/getting-started/installing-tvm/install-from-source#%E6%AD%A5%E9%AA%A4-1%E5%AE%89%E8%A3%85%E4%BE%9D%E8%B5%96%E9%A1%B9) 获取依赖项并激活 tvm-build 环境后,运行以下命令构建: ```plain mkdir build @@ -277,14 +277,14 @@ cmake --build build --config Release -- /m ``` -### [构建 ROCm 支持](https://tvm.apache.org/docs/install/from_source.html#id10) +### 构建 ROCm 支持 目前,ROCm 仅支持 Linux 平台。以下是配置步骤: * 设置 `set(USE_ROCM ON)`,并将 ROCM_PATH 设置为正确的路径。 * 安装 ROCm 的 HIP 运行时,确保系统已正确安装 ROCm。 * 安装最新稳定版的 LLVM(如 v6.0.1)和 LLD,确保 `ld.lld` 可通过命令行调用。 -### [启用 C++ 测试](https://tvm.apache.org/docs/install/from_source.html#id11) +### 启用 C++ 测试 TVM 使用 [Google Test](https://github.com/google/googletest) 驱动 C++ 测试,最简单的安装方式是从源码构建: diff --git a/docs/01-getting-started/02-installing-tvm/index.md b/docs/01-getting-started/02-installing-tvm/index.md index 7e512b6..eb005a3 100644 --- a/docs/01-getting-started/02-installing-tvm/index.md +++ b/docs/01-getting-started/02-installing-tvm/index.md @@ -4,14 +4,14 @@ title: 安装 TVM --- -* [从源码安装](https://tvm.apache.org/docs/install/from_source.html) -* [Docker 镜像](https://tvm.apache.org/docs/install/docker.html) +* [从源码安装](/docs/getting-started/installing-tvm/install-from-source) +* [Docker 镜像](/docs/getting-started/installing-tvm/docker-images) -访问 [从源码安装 TVM](https://tvm.apache.org/docs/install/from_source.html#install-from-source) 页面,以从源代码安装 TVM。从源码安装可以让你最大程度地灵活配置构建选项,并确保使用官方发布的源代码。如果你希望在移动设备或嵌入式设备上部署 TVM,你不需要在设备上安装完整的 TVM 框架,而只需安装运行时环境即可。 +访问 [从源码安装](/docs/getting-started/installing-tvm/install-from-source) 页面,以从源代码安装 TVM。从源码安装可以让你最大程度地灵活配置构建选项,并确保使用官方发布的源代码。如果你希望在移动设备或嵌入式设备上部署 TVM,你不需要在设备上安装完整的 TVM 框架,而只需安装运行时环境即可。 -如果你想快速体验 TVM 或运行一些示例和教程,可以 [通过 Docker 安装](https://tvm.apache.org/docs/install/docker.html#docker-images)。你也可以通过 `pip` 在本地安装 TVM。 +如果你想快速体验 TVM 或运行一些示例和教程,可以 [通过 Docker 安装](/docs/getting-started/installing-tvm/docker-images)。你也可以通过 `pip` 在本地安装 TVM。 ```plain diff --git a/docs/01-getting-started/03-quick-start/index.md b/docs/01-getting-started/03-quick-start/index.md index 054b8e7..d5c6801 100644 --- a/docs/01-getting-started/03-quick-start/index.md +++ b/docs/01-getting-started/03-quick-start/index.md @@ -7,7 +7,7 @@ title: 快速入门 :::note -本教程可通过 Google Colab 交互运行!也可点击[此处](https://tvm.apache.org/docs/get_started/tutorials/quick_start.html#sphx-glr-download-get-started-tutorials-quick-start-py)在本地运行 Jupyter Notebook。 +本教程可通过 Google Colab 交互运行!也可点击[此处](/docs/getting-started/quick-start/#%E5%90%8E%E7%BB%AD%E9%98%85%E8%AF%BB)在本地运行 Jupyter Notebook。 [在 Google Colab 中打开](https://colab.research.google.com/github/apache/tvm-site/blob/asf-site/docs/_downloads/eceb05a9badb601d2def02240aa869e9/quick_start.ipynb) @@ -19,12 +19,12 @@ title: 快速入门 **目录** -* [概览](https://tvm.apache.org/docs/get_started/tutorials/quick_start.html#overview) -* [完整流程](https://tvm.apache.org/docs/get_started/tutorials/quick_start.html#overall-flow) - * [构建或导入模型](https://tvm.apache.org/docs/get_started/tutorials/quick_start.html#construct-or-import-a-model) - * [执行优化转换](https://tvm.apache.org/docs/get_started/tutorials/quick_start.html#perform-optimization-transformations) - * [构建和通用部署](https://tvm.apache.org/docs/get_started/tutorials/quick_start.html#build-and-universal-deployment) -* [阅读下文](https://tvm.apache.org/docs/get_started/tutorials/quick_start.html#read-next) +* [概览](/docs/getting-started/quick-start/#%E6%A6%82%E8%BF%B0) +* [完整流程](/docs/getting-started/quick-start/#%E5%AE%8C%E6%95%B4%E6%B5%81%E7%A8%8B) + * [构建或导入模型](/docs/getting-started/quick-start/#%E6%9E%84%E5%BB%BA%E6%88%96%E5%AF%BC%E5%85%A5%E6%A8%A1%E5%9E%8B) + * [执行优化转换](/docs/getting-started/quick-start/#%E6%89%A7%E8%A1%8C%E4%BC%98%E5%8C%96%E8%BD%AC%E6%8D%A2) + * [构建和通用部署](/docs/getting-started/quick-start/#%E6%9E%84%E5%BB%BA%E5%92%8C%E9%80%9A%E7%94%A8%E9%83%A8%E7%BD%B2) +* [阅读下文](/docs/getting-started/quick-start/#%E5%90%8E%E7%BB%AD%E9%98%85%E8%AF%BB) ## 概述 @@ -201,7 +201,8 @@ Tensor out = vm.getFunction("prefill").pushArg(data).pushArg(weight).pushArg(kv_ ## 后续阅读 -本教程演示了使用 Apache TVM 编译神经网络模型的整体流程。如需了解更高级或具体的主题,请参考以下教程: +本教程演示了使用 Apache TVM 编译神经网络模型的整体流程。如需了解更高级或具体的主题,请参考以下教程(可右键另存为下载): * [下载 Jupyter notebook: quick_start.ipynb](https://tvm.apache.org/docs/_downloads/eceb05a9badb601d2def02240aa869e9/quick_start.ipynb) * [下载 Python 源代码: quick_start.py](https://tvm.apache.org/docs/_downloads/baf675793174f2e9b3d5da483e35ef27/quick_start.py) * [下载压缩包: quick_start.zip](https://tvm.apache.org/docs/_downloads/bb7db6678496193ed0c55d3b95fa6778/quick_start.zip) + diff --git a/docs/01-getting-started/04-irmodule/index.md b/docs/01-getting-started/04-irmodule/index.md index f6fe0d9..bfe49dc 100644 --- a/docs/01-getting-started/04-irmodule/index.md +++ b/docs/01-getting-started/04-irmodule/index.md @@ -7,7 +7,7 @@ title: IRModule :::note -本教程可通过 Google Colab 交互式运行!也可点击[此处](https://tvm.apache.org/docs/get_started/tutorials/ir_module.html#sphx-glr-download-get-started-tutorials-ir-module-py)在本地运行 Jupyter Notebook。 +本教程可通过 Google Colab 交互式运行!也可点击[此处](/docs/getting-started/irmodule/#%E9%83%A8%E7%BD%B2%E5%88%B0%E5%85%B6%E4%BB%96%E5%90%8E%E7%AB%AF)在本地运行 Jupyter Notebook。 [在 Google Colab 中打开](https://colab.research.google.com/github/apache/tvm-site/blob/asf-site/docs/_downloads/a6d7947451d373bc811080cffa18dc7c/ir_module.ipynb) @@ -18,10 +18,10 @@ title: IRModule **目录** -* [创建 IRModule](https://tvm.apache.org/docs/get_started/tutorials/ir_module.html#create-irmodule) -* [IRModule 的属性](https://tvm.apache.org/docs/get_started/tutorials/ir_module.html#attributes-of-an-irmodule) -* [对 IRModule 进行转换](https://tvm.apache.org/docs/get_started/tutorials/ir_module.html#transformations-on-irmodules) -* [通用部署 IRModule](https://tvm.apache.org/docs/get_started/tutorials/ir_module.html#deploy-the-irmodule-universally) +* [创建 IRModule](/docs/getting-started/irmodule/#%E5%88%9B%E5%BB%BA-irmodule) +* [IRModule 的属性](/docs/getting-started/irmodule/#irmodule-%E7%9A%84%E5%B1%9E%E6%80%A7) +* [对 IRModule 进行转换](/docs/getting-started/irmodule/#%E5%AF%B9-irmodule-%E8%BF%9B%E8%A1%8C%E8%BD%AC%E6%8D%A2) +* [通用部署 IRModule](/docs/getting-started/irmodule/#%E9%80%9A%E7%94%A8%E9%83%A8%E7%BD%B2-irmodule) ```plain @@ -194,6 +194,7 @@ class TVMScriptModule: mod_from_script = TVMScriptModule mod_from_script.show() + ``` @@ -412,10 +413,10 @@ print(mod.get_global_vars()) 接着,Apache TVM Unity 提供了一套默认的转换流水线,以简化转换过程。我们可以将默认的转换流水线应用到模块上。其中默认的 zero 流水线包含以下基本转换步骤: -* **LegalizeOps:**将 Relax 操作转换为 call_tir 调用,配合相应的 TensorIR 函数。此转换会让 IRModule 同时包含 Relax 函数与 TensorIR 函数。 -* **AnnotateTIROpPattern:**为 TensorIR 函数打上模式标签,为后续的算子融合做好准备。 -* **FoldConstant:**进行常量折叠优化,简化涉及常量的运算。 -* **FuseOps 和 FuseTIR:**根据上一阶段 AnnotateTIROpPattern 所打的标签对 Relax 和 TensorIR 函数进行融合优化。 +* **LegalizeOps:** 将 Relax 操作转换为 call_tir 调用,配合相应的 TensorIR 函数。此转换会让 IRModule 同时包含 Relax 函数与 TensorIR 函数。 +* **AnnotateTIROpPattern:** 为 TensorIR 函数打上模式标签,为后续的算子融合做好准备。 +* **FoldConstant:** 进行常量折叠优化,简化涉及常量的运算。 +* **FuseOps 和 FuseTIR:** 根据上一阶段 AnnotateTIROpPattern 所打的标签对 Relax 和 TensorIR 函数进行融合优化。 :::note @@ -550,8 +551,9 @@ print(cpu_out) 输出: ```plain -[[ 0.13505758 -0.29273182 0.04422678 -0.06554039 0.02372958 0.00591143 - -0.11505812 -0.11465105 -0.08466949 0.1232063 ]] +[[ 6.4867303e-02 1.6763064e-01 9.3035400e-05 1.8091209e-01 + 8.0412276e-02 -1.4292052e-01 -3.2873321e-02 -7.4184828e-02 + -6.7507513e-02 1.5245053e-01]] ``` @@ -593,14 +595,15 @@ assert np.allclose(cpu_out, gpu_out, atol=1e-3) 输出: ```plain -[[ 0.13505754 -0.29273173 0.04422677 -0.06554036 0.02372959 0.00591139 - -0.115058 -0.11465096 -0.08466944 0.12320635]] +[[ 6.4867347e-02 1.6763058e-01 9.3113631e-05 1.8091221e-01 + 8.0412284e-02 -1.4292067e-01 -3.2873336e-02 -7.4184842e-02 + -6.7507453e-02 1.5245046e-01]] ``` ### 部署到其他后端 -Apache TVM Unity 也支持部署到其他后端,包括不同类型的 GPU(如 Metal、ROCm、Vulkan 和 OpenCL)、不同类型的 CPU(如 x86 和 ARM),以及其他新兴平台(例如 WebAssembly)。部署流程与 GPU 后端类似。 +Apache TVM Unity 也支持部署到其他后端,包括不同类型的 GPU(如 Metal、ROCm、Vulkan 和 OpenCL)、不同类型的 CPU(如 x86 和 ARM),以及其他新兴平台(例如 WebAssembly)。部署流程与 GPU 后端类似(可右键另存为下载)。 * [下载 Jupyter Notebook: ir_module.ipynb](https://tvm.apache.org/docs/_downloads/a6d7947451d373bc811080cffa18dc7c/ir_module.ipynb) * [下载 Python 源代码: ir_module.py](https://tvm.apache.org/docs/_downloads/0b64717d4cc6027368b96fad40119738/ir_module.py) * [下载压缩包: ir_module.zip](https://tvm.apache.org/docs/_downloads/11c11e53c7dace51a8be968ee169ed0d/ir_module.zip) diff --git a/docs/02-how-to/01-end-to-end-optimize-model.md b/docs/02-how-to/01-end-to-end-optimize-model.md index 0b2517c..ba73acf 100644 --- a/docs/02-how-to/01-end-to-end-optimize-model.md +++ b/docs/02-how-to/01-end-to-end-optimize-model.md @@ -7,7 +7,7 @@ title: 端到端优化模型 :::note -本教程可通过 Google Colab 交互式运行!也可点击[此处](https://tvm.apache.org/docs/get_started/tutorials/quick_start.html#sphx-glr-download-get-started-tutorials-quick-start-py)在本地运行 Jupyter Notebook。 +本教程可通过 Google Colab 交互式运行!也可点击[此处](/docs/how-to/end-to-end-optimize-model#%E6%9E%84%E5%BB%BA%E4%B8%8E%E9%83%A8%E7%BD%B2)在本地运行 Jupyter Notebook。 [在 Google Colab 中打开](https://colab.research.google.com/github/apache/tvm-site/blob/asf-site/docs/_downloads/317a8cc53139718b9a36a16ba052e44b/e2e_opt_model.ipynb) @@ -106,7 +106,7 @@ if not IS_IN_CI: ## 构建与部署 -最后,我们构建优化后的模型,并将其部署到目标设备。在 CI 环境中会跳过此步骤。 +最后,我们构建优化后的模型,并将其部署到目标设备。在 CI 环境中会跳过此步骤。可右键另存为下载。 ```plain @@ -126,3 +126,5 @@ if not IS_IN_CI: * [下载压缩包:e2e_opt_model.zip](https://tvm.apache.org/docs/_downloads/a7dd7652b2ad50f82d7b739ce3645799/e2e_opt_model.zip) + + diff --git a/docs/02-how-to/02-customize-optimization.md b/docs/02-how-to/02-customize-optimization.md index 8b46729..db4c657 100644 --- a/docs/02-how-to/02-customize-optimization.md +++ b/docs/02-how-to/02-customize-optimization.md @@ -7,7 +7,7 @@ title: 自定义优化 :::note -本教程可通过 Google Colab 交互式运行!也可点击[此处](https://tvm.apache.org/docs/how_to/tutorials/customize_opt.html#sphx-glr-download-how-to-tutorials-customize-opt-py)在本地运行 Jupyter Notebook。 +本教程可通过 Google Colab 交互式运行!也可点击[此处](/docs/how-to/customize-optimization#%E9%83%A8%E7%BD%B2%E4%BC%98%E5%8C%96%E5%90%8E%E7%9A%84%E6%A8%A1%E5%9E%8B)在本地运行 Jupyter Notebook。 [在 Google Colab 中打开](https://colab.research.google.com/github/apache/tvm-site/blob/asf-site/docs/_downloads/d64d105c8921b2ab908ef001ab382b45/customize_opt.ipynb) @@ -17,11 +17,9 @@ Apache TVM 的一个主要设计目标是便于自定义优化流程,无论是 **目录** -* [审查整体流程](https://tvm.apache.org/docs/how_to/tutorials/customize_opt.html#review-overall-flow) -* [可组合的 IRModule 优化](https://tvm.apache.org/docs/how_to/tutorials/customize_opt.html#composable-irmodule-optimization) -* [部署优化后的模型](https://tvm.apache.org/docs/how_to/tutorials/customize_opt.html#deploy-the-optimized-model) -* [总结](https://tvm.apache.org/docs/how_to/tutorials/customize_opt.html#summary) - +* [审查整体流程](/docs/how-to/customize-optimization#%E5%AE%A1%E6%9F%A5%E6%95%B4%E4%BD%93%E6%B5%81%E7%A8%8B) +* [可组合的 IRModule 优化](/docs/how-to/customize-optimization#%E5%8F%AF%E7%BB%84%E5%90%88%E7%9A%84-irmodule-%E4%BC%98%E5%8C%96) +* [部署优化后的模型](/docs/how-to/customize-optimization#%E9%83%A8%E7%BD%B2%E4%BC%98%E5%8C%96%E5%90%8E%E7%9A%84%E6%A8%A1%E5%9E%8B) ## 审查整体流程 @@ -152,7 +150,7 @@ mod.show() @I.ir_module class Module: - I.module_attrs({"external_mods": [metadata["runtime.Module"][0]]}) + I.module_attrs({"external_mods": [metadata["ffi.Module"][0]]}) @R.function def forward(x: R.Tensor((1, 784), dtype="float32"), fc1_weight: R.Tensor((256, 784), dtype="float32"), fc1_bias: R.Tensor((256,), dtype="float32"), fc2_weight: R.Tensor((10, 256), dtype="float32")) -> R.Tensor((1, 10), dtype="float32"): R.func_attr({"num_input": 1}) @@ -327,15 +325,18 @@ print(gpu_out) 输出: ```plain -[[25165.08 22909.219 25461.871 24852.129 24942.432 24389.219 24460.203 - 26586.521 23572.797 26839.176]] +[[26357.13 23372.246 25534.104 26006.512 23795.57 24571.258 25749.385 + 23908.93 26135.215 25507.008]] ``` +## 总结 -本教程展示了如何在 Apache TVM 中自定义机器学习模型的优化流程。我们可以轻松组合优化 pass,并针对计算图中的不同部分定制优化策略。优化流程的高度灵活性使我们能够快速迭代优化步骤,从而提升模型性能。 +本教程展示了如何在 Apache TVM 中自定义机器学习模型的优化流程。我们可以轻松组合优化 pass,并针对计算图中的不同部分定制优化策略。优化流程的高度灵活性使我们能够快速迭代优化步骤,从而提升模型性能(可右键另存为下载)。 * [下载 Jupyter Notebook:customize_opt.ipynb](https://tvm.apache.org/docs/_downloads/d64d105c8921b2ab908ef001ab382b45/customize_opt.ipynb) * [下载 Python 源代码:customize_opt.py](https://tvm.apache.org/docs/_downloads/42304b518561422fdab8c7d8ee640a55/customize_opt.py) * [下载压缩包:customize_opt.zip](https://tvm.apache.org/docs/_downloads/f69433a4a80715725df90d1386679956/customize_opt.zip) + + diff --git a/docs/02-how-to/03-optimize-large-language-model.md b/docs/02-how-to/03-optimize-large-language-model.md index fb66503..3d72e60 100644 --- a/docs/02-how-to/03-optimize-large-language-model.md +++ b/docs/02-how-to/03-optimize-large-language-model.md @@ -7,7 +7,7 @@ title: 优化大语言模型 :::note -本教程可通过 Google Colab 交互式运行!也可点击[此处](https://tvm.apache.org/docs/how_to/tutorials/optimize_llm.html#sphx-glr-download-how-to-tutorials-optimize-llm-py)在本地运行 Jupyter Notebook。 +本教程可通过 Google Colab 交互式运行!也可点击[此处](/docs/how-to/optimize-large-language-model#decode)在本地运行 Jupyter Notebook。 [在 Google Colab 中打开](https://colab.research.google.com/github/apache/tvm-site/blob/asf-site/docs/_downloads/ab03cb35cd7f92b5425a8974fcab921a/optimize_llm.ipynb) @@ -593,7 +593,7 @@ if not IS_IN_CI: ### Decode -Prefill 步骤完成后,我们可以开始 decode 步骤。decode 步骤用于持续生成 token,直到生成结束 token。我们使用 Relax IRModule 中编译的 decode 函数来生成 token。 +Prefill 步骤完成后,我们可以开始 decode 步骤。decode 步骤用于持续生成 token,直到生成结束 token。我们使用 Relax IRModule 中编译的 decode 函数来生成 token。可右键另存为下载。 ```plain @@ -617,3 +617,4 @@ if not IS_IN_CI: * [压缩包下载:optimize_llm.zip](https://tvm.apache.org/docs/_downloads/83e85f38cf16f1d926d06615fd54095c/optimize_llm.zip) + diff --git a/docs/02-how-to/04-cross-compilation-and-rpc.md b/docs/02-how-to/04-cross-compilation-and-rpc.md index 0d0e959..1d3dcfc 100644 --- a/docs/02-how-to/04-cross-compilation-and-rpc.md +++ b/docs/02-how-to/04-cross-compilation-and-rpc.md @@ -7,7 +7,7 @@ title: 交叉编译与 RPC :::note -本教程可通过 Google Colab 交互式运行!也可点击[此处](https://tvm.apache.org/docs/how_to/tutorials/optimize_llm.html#sphx-glr-download-how-to-tutorials-optimize-llm-py)在本地运行 Jupyter Notebook。 +本教程可通过 Google Colab 交互式运行!也可点击[此处](/docs/how-to/cross-compilation-and-rpc#%E6%80%BB%E7%BB%93)在本地运行 Jupyter Notebook。 [在 Google Colab 中打开](https://colab.research.google.com/github/apache/tvm-site/blob/asf-site/docs/_downloads/148819f3421b8d89b1723c3e15e3f19f/cross_compilation_and_rpc.ipynb) @@ -258,6 +258,7 @@ def run_opencl(): * 在本地设置目标设备的交叉编译配置; * 通过 RPC API 上传并远程运行内核程序。 +可右键另存为下载。 [下载 Jupyter notebook: ](https://tvm.apache.org/docs/_downloads/148819f3421b8d89b1723c3e15e3f19f/cross_compilation_and_rpc.ipynb)`cross_compilation_and_rpc.ipynb` diff --git a/docs/02-how-to/05-development-guides/01-python-target-parametrization.md b/docs/02-how-to/05-development-guides/01-python-target-parametrization.md index 7f218b8..a835be1 100644 --- a/docs/02-how-to/05-development-guides/01-python-target-parametrization.md +++ b/docs/02-how-to/05-development-guides/01-python-target-parametrization.md @@ -72,7 +72,7 @@ def test_function(target, dev): ``` -参数化功能是基于 `pytest marks` 实现的。每个测试函数都可以使用 [pytest marks](https://tvm.apache.org/docs/how_to/dev/pytest-marks) 进行装饰以添加元数据。最常用的标记如下: +参数化功能是基于 `pytest marks` 实现的。每个测试函数都可以使用 pytest marks 进行装饰以添加元数据。最常用的标记如下: * `@pytest.mark.gpu`:将函数标记为使用 GPU 能力。该标记本身无直接作用,但可配合命令行参数 `-m gpu` 或 `-m 'not gpu'` 使用,以限制 pytest 执行哪些测试。通常不单独使用,而是嵌入在其他单元测试装饰器中。 diff --git a/docs/02-how-to/05-development-guides/02-setup_rpc_system.md b/docs/02-how-to/05-development-guides/02-setup_rpc_system.md index a8f5118..e7234d0 100644 --- a/docs/02-how-to/05-development-guides/02-setup_rpc_system.md +++ b/docs/02-how-to/05-development-guides/02-setup_rpc_system.md @@ -37,7 +37,7 @@ Apache TVM 的 RPC 系统包含三个工具:RPC Tracker、RPC Proxy 和 RPC Se ## 设置 RPC 追踪器和 RPC 代理 -一般来说,RPC 追踪器和 RPC 代理只需在主机(例如开发服务器或 PC)上运行,它们不依赖于设备端环境。只需根据 TVM 官方文档([https://tvm.apache.org/docs/install/index.html](https://tvm.apache.org/docs/install/index.html))完成 TVM 安装后,在相应主机上执行以下命令即可: +一般来说,RPC 追踪器和 RPC 代理只需在主机(例如开发服务器或 PC)上运行,它们不依赖于设备端环境。只需根据 [TVM 文档](/docs/getting-started/installing-tvm/)完成 TVM 安装后,在相应主机上执行以下命令即可: * RPC 追踪器 ```plain @@ -63,7 +63,7 @@ TVM 社区提供了多个 RPC 服务器实现,例如:`apps/android_rpc`、`a RPC Server 需运行在设备端,通常依赖于 xPU 驱动、增强版支持 xPU 的 TVM 运行时及其他库,因此请先安装相关依赖组件,例如 KMD 驱动,并确保所需动态库路径已加入 `LD_LIBRARY_PATH` 环境变量。 -如果可以在设备上直接设置编译环境(无需交叉编译),请参考 [https://tvm.apache.org/docs/install/from_source.html](https://tvm.apache.org/docs/install/from_source.html) 完成编译,并直接跳转至 [步骤 3:启动 RPC Server](https://tvm.apache.org/docs/how_to/dev/setup_rpc_system.html#launch-rpc-server)。 +如果可以在设备上直接设置编译环境(无需交叉编译),请参考 [/docs/getting-started/installing-tvm/install-from-source](/docs/getting-started/installing-tvm/install-from-source) 完成编译,并直接跳转至 [步骤 3:启动 RPC Server](/docs/how-to/development-guides/setup_rpc_system#3-%E5%90%AF%E5%8A%A8-rpc-server)。 ### 1. 交叉编译 TVM 运行时 @@ -225,3 +225,4 @@ def exp(*args, **kwargs): 由于 `cloudpickle` 是一个纯 Python 包,因此只需将其从其他机器复制到设备机器上的目录(例如 `/usr/local/lib/python3.9/site-packages`),即可解决该问题。 + diff --git a/docs/02-how-to/05-development-guides/index.md b/docs/02-how-to/05-development-guides/index.md index e9fdf37..a1d4e19 100644 --- a/docs/02-how-to/05-development-guides/index.md +++ b/docs/02-how-to/05-development-guides/index.md @@ -6,8 +6,8 @@ title: 开发指南 本节包含关于如何在 TVM 各个模块中进行开发的一些实用建议。 -* [Python 目标参数配置](https://tvm.apache.org/docs/how_to/dev/pytest_target_parametrization.html) -* [配置 RPC 系统](https://tvm.apache.org/docs/how_to/dev/setup_rpc_system.html) -* [处理 TVM 错误](https://tvm.apache.org/docs/errors.html) +* [Python 目标参数配置](/docs/how-to/development-guides/python-target-parametrization) +* [配置 RPC 系统](/docs/how-to/development-guides/setup_rpc_system) +* [处理 TVM 错误](/docs/how-to/development-guides/handle-tvm-errors) diff --git a/docs/03-deep-dive/01-design-and-architecture/01-runtime/01-vulkan.md b/docs/03-deep-dive/01-design-and-architecture/01-runtime/01-vulkan.md new file mode 100644 index 0000000..54c7254 --- /dev/null +++ b/docs/03-deep-dive/01-design-and-architecture/01-runtime/01-vulkan.md @@ -0,0 +1,91 @@ +--- + +title: Vulkan 运行时 + +--- + + +TVM 支持使用 Vulkan 计算着色器来执行任务。 每个计算内核都会被编译成一个 SPIR-V 着色器,然后可通过 TVM 接口进行调用。 + +## Vulkan 功能与限制 + +由于不同的 Vulkan 实现可能启用了不同的可选特性,或具有不同的物理限制, +代码生成必须了解可用的特性。这些特性对应于特定的 Vulkan 能力与限制,如 `Vulkan Capabilities Table `{.interpreted-text role="ref"} 所示。 若未指定,TVM 会假定该能力不可用,或该限制为 Vulkan 规范中 [Required Limits](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#limits-minmax) 一节所定义的最小保证值。 + +这些参数既可以在定义 `Target `{.interpreted-text role="ref"} 时显式指定, 也可以从设备中查询。若要从设备查询,可使用特殊参数 +`-from_device=N`,以从设备 ID `N` 查询所有 Vulkan 参数。 +任何额外显式指定的参数将覆盖从设备查询到的参数。 + +| 参数名称(Target Parameter) | 所需 Vulkan 版本/扩展 | 查询的 Vulkan 参数结构体字段 | 默认值 | +|--------------------------------------------|--------------------------------------------|------------------------------------------------------------------------------------------------|--------| +| `supported_subgroup_operations`(支持的子群操作) | Vulkan 1.1+ | `VkPhysicalDeviceSubgroupProperties::supportedOperations` | 0(对应子群特性标志位 VkSubgroupFeatureFlagBits) | +| `max_push_constants_size`(最大 Push 常量大小) | | `VkPhysicalDeviceLimits::maxPushConstantsSize` | 128 字节 | +| `max_uniform_buffer_range`(最大 Uniform Buffer 范围) | | `VkPhysicalDeviceLimits::maxUniformBufferRange` | 16384 字节 | +| `max_storage_buffer_range`(最大 Storage Buffer 范围) | | `VkPhysicalDeviceLimits::maxStorageBufferRange` | 2^27 字节 | +| `max_per_stage_descriptor_storage_buffer`(每阶段可用 Storage Buffer 描述符数量) | | `VkPhysicalDeviceLimits::maxPerStageDescriptorStorageBuffers` | 4 | +| `supports_storage_buffer_storage_class`(支持 Storage Buffer 类型) | `VK_KHR_storage_buffer_storage_class` | (无需查询,取决于扩展是否启用) | false | +| `supports_storage_buffer_8bit_access`(支持 8 位 Storage Buffer 访问) | `VK_KHR_8bit_storage` | `VkPhysicalDevice8BitStorageFeaturesKHR::storageBuffer8BitAccess` | false | +| `supports_storage_buffer_16bit_access`(支持 16 位 Storage Buffer 访问) | `VK_KHR_16bit_storage` | `VkPhysicalDevice16BitStorageFeaturesKHR::storageBuffer16BitAccess` | false | +| `supports_float16`(支持 float16 浮点类型) | `VK_KHR_shader_float16_int8` | `VkPhysicalDeviceShaderFloat16Int8FeaturesKHR::shaderFloat16` | false | +| `supports_float64`(支持 float64 浮点类型) | | `VkPhysicalDeviceFeatures::shaderFloat64` | false | +| `supports_int8`(支持 int8 类型) | `VK_KHR_shader_float16_int8` | `VkPhysicalDeviceShaderFloat16Int8FeaturesKHR::shaderInt8` | false | +| `supports_int16`(支持 int16 类型) | | `VkPhysicalDeviceFeatures::shaderInt16` | false | +| `supports_int64`(支持 int64 类型) | | `VkPhysicalDeviceFeatures::shaderInt64` | false | + +截至 2021 年 5 月,并非所有 Vulkan 实现都受到支持。 例如,需要支持 64 +位整数。若 Vulkan 目标不受支持, 在生成 SPIR-V 代码时将会报错。 +目前也在努力消除此类限制,以支持更多 Vulkan 实现。 + +## SPIR-V 功能 + +某些设备特性也对应于 SPIR-V 的功能或扩展,必须在着色器中声明,或要求使用最低版本的 SPIR-V。 TVM 生成的着色器会声明执行所需的最小扩展、功能以及最低 SPIR-V 版本。 + +如果着色器生成需要的能力或扩展在 `Target` 中未启用,将会抛出异常。 + + +| 参数名称(Target Parameter) | 所需 SPIR-V 版本/扩展 | 声明的功能(Capability) | +|--------------------------------------------|--------------------------------------------|--------------------------| +| `supported_subgroup_operations`(支持的子群操作) | SPIR-V 1.3+ | 视具体子群特性而定(参考 VkSubgroupFeatureFlagBits) | +| `supports_storage_buffer_storage_class`(支持 Storage Buffer 类) | SPV_KHR_storage_buffer_storage_class | (使用该扩展隐式启用) | +| `supports_storage_buffer_8bit_access`(支持 8 位存储缓冲访问) | SPV_KHR_8bit_storage | StorageBuffer8BitAccess | +| `supports_storage_buffer_16bit_access`(支持 16 位存储缓冲访问) | SPV_KHR_16bit_storage | StorageBuffer16BitAccess | +| `supports_float16`(支持 Float16 浮点类型) | | Float16 | +| `supports_float64`(支持 Float64 浮点类型) | | Float64 | +| `supports_int8`(支持 Int8 类型) | | Int8 | +| `supports_int16`(支持 Int16 类型) | | Int16 | +| `supports_int64`(支持 Int64 类型) | | Int64 | + + +## Vulkan 特定环境变量 + +SPIR-V 代码生成器和 Vulkan 运行时均可通过环境变量修改部分运行时行为。 +这些变量主要用于调试,以便更轻松地测试特定代码路径或输出更多信息。 +所有布尔类型变量在设置为非零整数时视为"真"。 未设置、设为 0 +或空字符串时,视为"假"。 + +- `TVM_VULKAN_DISABLE_PUSH_DESCRIPTOR` ------ 布尔变量。 若为真,TVM + 将显式分配描述符,而不使用 + [VK_KHR_push_descriptor](https://khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_KHR_push_descriptor.html) + 或 + [VK_KHR_descriptor_update_template](https://khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_KHR_descriptor_update_template.html) + 扩展。 若为假,TVM 会根据扩展的可用性自动决定是否使用。 +- `TVM_VULKAN_DISABLE_DEDICATED_ALLOCATION` ------ 布尔变量。 + 若为真,TVM 不会将内存分配标记为「专用分配」, 也不会使用 + [VK_KHR_dedicated_allocation](https://khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_KHR_dedicated_allocation.html) + 扩展。 若为假,TVM 会依据 + [VkMemoryDedicatedRequirements](https://khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkMemoryDedicatedRequirements.html) + 判断是否应将内存标记为专用分配。 +- `TVM_VULKAN_ENABLE_VALIDATION_LAYERS` ------ 布尔变量。 若为真,TVM + 会启用设备支持的 [Vulkan validation + layers](https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/blob/master/layers/README.md)。 + 若为假,则不会启用任何验证层。 +- `TVM_VULKAN_DISABLE_SHADER_VALIDATION` ------ 布尔变量。 + 若为真,将跳过使用 + [spvValidate](https://github.com/KhronosGroup/SPIRV-Tools#validator) + 进行的 SPIR-V 着色器验证。 若为假(默认),TVM 生成的所有 SPIR-V + 着色器都将通过 + [spvValidate](https://github.com/KhronosGroup/SPIRV-Tools#validator) + 进行验证。 +- `TVM_VULKAN_DEBUG_SHADER_SAVEPATH` ------ 目录路径。 + 若设置为非空字符串,Vulkan 代码生成器会将 TIR、二进制 SPIR-V + 以及反汇编后的 SPIR-V 着色器保存到此目录,用于调试。 diff --git a/docs/03-deep-dive/01-design-and-architecture/01-runtime/index.md b/docs/03-deep-dive/01-design-and-architecture/01-runtime/index.md new file mode 100644 index 0000000..b7efec2 --- /dev/null +++ b/docs/03-deep-dive/01-design-and-architecture/01-runtime/index.md @@ -0,0 +1,195 @@ +--- + +title: TVM 运行时系统 + +--- + + +TVM 支持多种编程语言用于编译器栈的开发和部署。在本说明中,我们将解释 TVM 运行时的关键组成部分。 + +![图片](/img/docs/v21/03-deep-dive-01-design-and-architecture-01-runtime.png) + +VM 的运行时系统需要满足多种看似相互矛盾但又非常关键的需求: + +- 部署(Deployment):能够在 Python / JavaScript / C++ 等语言中调用已编译的函数。 + +- 调试(Debug):允许用户在 Python 中定义函数,并从已编译的代码中反向调用。 + +- 链接(Linking):需要编写驱动端代码来调用设备端实现(如 CUDA kernel),并且运行时需要能从主机端代码中调用它们。 + +- 原型开发(Prototyping):支持在 Python 中创建 IR Pass,并能从 C++ 后端调用。 + +- 接口暴露(Frontend Exposure):编译器的核心逻辑由 C++ 实现,但必须便捷地暴露给 Python 等前端语言。 + +- 实验与部署(Experiment & Deployment):能够将编译好的函数直接传输并运行在嵌入式设备上。 + +我们希望能够在任何语言中定义函数并在另一种语言中调用。我们还希望运行时核心尽可能小,以便部署到嵌入式设备上。 + +## PackedFunc + +[PackedFunc](https://github.com/apache/tvm/blob/main/include/tvm/runtime/packed_func.h)是我们找到的一个简单但优雅的解决方案来解决列出的挑战。 +一个 `PackedFunc` 对象就表示一次函数调用,而调用方和被调用方可以处于不同的语言环境中。 + +下面的代码块提供了一个 C++ 示例 + +``` c +#include + +void MyAdd(ffi::PackedArgs args, ffi::Any* rv) { + // automatically convert arguments to desired type. + int a = args[0].cast(); + int b = args[1].cast(); + // automatically assign value return to rv + *rv = a + b; +} + +void CallPacked() { + PackedFunc myadd = PackedFunc(MyAdd); + // get back 3 + int c = myadd(1, 2); +} +``` +在上面的代码块中,我们定义了一个 PackedFunc MyAdd。它接受两个参数:`args` 表示输入参数,`rv `表示返回值。该函数是类型擦除的,这意味着函数签名不会限制传入或返回值的类型。在底层,当我们调用一个 PackedFunc 时,它会将输入参数打包成 ffi::PackedArgs 放在栈上,并通过 ffi::Any 获取返回结果。 + +得益于 C++ 中的模板机制,我们可以像调用普通函数一样调用 PackedFunc。由于其类型擦除的特性,我们可以在诸如 Python 这样的动态语言中调用 PackedFunc,而不需要为每一种新函数类型额外编写 glue 代码。下面的例子展示了如何在 C++ 中注册一个 PackedFunc,并在 Python 中调用它。 + +``` c +// register a global packed function in c++ +TVM_FFI_STATIC_INIT_BLOCK() { + namespace refl = tvm::ffi::reflection; + refl::GlobalDef().def_packed("myadd", MyAdd); +} +``` +``` python +import tvm + +myadd = tvm.get_global_func("myadd") +# prints 3 +print(myadd(1, 2)) +``` +PackedFunc 的大部分「魔力」来自 `ffi::PackedArgs` 和 `ffi::Any` 这两个结构。我们对可传递的类型做了限制,常见的类型包括: + +- int、float 和 string + +- PackedFunc 本身 + +- Module,用于表示已编译模块 + +- DLTensor*,用于张量对象交换 + +- TVM Object,用于表示 IR 中的任意对象 + +这种限制使得实现变得简单,无需序列化。即使实现精简,PackedFunc 在深度学习部署的场景中依然绰绰有余,因为大多数函数只需要处理 DLTensor 或数字。 + +由于一个 PackedFunc 可以将另一个 PackedFunc 作为参数传递,因此我们可以将 Python 中的函数(转换为 PackedFunc)传递给 C++。 + +``` c +TVM_FFI_STATIC_INIT_BLOCK() { + namespace refl = tvm::ffi::reflection; + refl::GlobalDef().def_packed("callhello", [](ffi::PackedArgs args, ffi::Any* rv) { + ffi::Function f = args[0].cast(); + f("hello world"); + }); +} +``` + +``` python +import tvm + +def callback(msg): + print(msg) + +# convert to PackedFunc +f = tvm.convert(callback) +callhello = tvm.get_global_func("callhello") +# prints hello world +callhello(f) +``` + +TVM 提供了一个最小化的 C API [minimum C +API](https://github.com/apache/tvm/blob/main/include/tvm/runtime/base.h),它允许我们将 PackedFunc 嵌入到任意语言中。除了 Python 以外,目前还支持 [java](https://github.com/apache/tvm/tree/main/jvm) 和 [javascript](https://github.com/apache/tvm/tree/main/web)。这种嵌入式 API 的设计理念与 Lua 很相似,只不过我们并没有创造一门新的语言,而是直接使用了 C++。 + +关于 PackedFunc 有一个有趣的事实:我们在编译器栈和部署栈中都使用它。 + +- TVM 中所有编译器 Pass 函数都以 PackedFunc 的形式暴露给前端 + +- 已编译模块同样以 PackedFunc 的形式返回已生成的函数 + +为了保持运行时尽可能精简,我们将 IR Object 支持从部署运行时中分离开来。最终生成的运行时大小大约为 200K - 600K,具体取决于包含的运行时驱动模块数量(例如 CUDA)。 + +调用 PackedFunc 相比普通函数的开销很小,只多做了一些栈上值保存。因此,只要不频繁包装非常小的函数,这样的开销是可以接受的。总的来说,PackedFunc 是 TVM 的通用“胶水层”,我们在编译和部署模块中都大量依赖它。 + +## 组件 +由于 TVM 支持多种不同类型的硬件设备,我们也需要支持对应的不同驱动程序。我们必须使用这些驱动 API 来加载内核、以打包形式设置参数并启动内核执行。同时,我们还需要对驱动 API 进行封装,以确保暴露给用户的接口是线程安全的。因此,我们通常会在 C++ 中编写这些驱动层 Glue 代码,并通过 PackedFunc 将其暴露给用户。显然,我们不可能为每类函数都单独编写接口,因此 PackedFunc 再次成为解决方案。 + +TVM 将编译结果抽象为一个 [Module](https://github.com/apache/tvm/blob/main/include/tvm/runtime/module.h)。 + +用户可以从 Module 中以 PackedFunc 的形式获取已编译函数。生成的代码在运行时可以动态地从 Module 中获取目标函数,并在第一次调用时缓存句柄,后续复用。这使得我们可以在生成代码中链接设备端函数,并调用任意 PackedFunc(例如 Python 回调)。 + +ModuleNode 是一个抽象类,不同设备类型可以各自实现。例如,我们已支持 CUDA、Metal、OpenCL 以及动态库(Shared Library)。这种抽象设计使得引入新设备变得简单,而无需重新生成每种设备的主机端代码。 + +## 远程部署 +PackedFunc 和 Module 系统也使得我们可以将函数直接部署到远程设备上。在底层,我们提供了一个 RPCModule,它负责序列化参数、进行数据传输,并在远程设备上启动计算。 + +![图片](/img/docs/v21/03-deep-dive-01-design-and-architecture-01-runtime-2.png) + +RPC 服务器本身非常精简,可以直接与运行时一起打包。我们可以在 iPhone、Android、树莓派甚至浏览器中启动一个最小化的 TVM RPC 服务器。交叉编译、模块打包与测试都可以在同一个脚本中完成。更多细节可参考 `tutorial-cross-compilation-and-rpc`。 + +这种即时反馈带来了显著优势。例如,当我们希望验证生成的代码在 iPhone 上的正确性时,不再需要手动用 Swift/Objective-C 重写测试样例——我们可以直接使用 RPC 在 iPhone 上执行代码,将结果复制回主机,并使用 numpy 进行验证。同样,我们也可以使用同一个脚本进行性能分析。 + +## TVM 对象与编译器栈 + +如前所述,我们在 PackedFunc 运行时系统之上构建了编译器栈的 API。由于研究需求,编译器 API 经常需要不断变化。当我们想要测试新的语言原语时,就需要引入新的语言对象或 IR 节点。但是我们又不希望频繁修改 API。此外,我们还希望: + +- 能够序列化任意语言对象和 IR; + +- 能够在前端语言中探索、打印和操作 IR 对象,以便进行快速原型开发。 + +为了解决这些问题,我们引入了一个基类[Object](https://github.com/apache/tvm/blob/main/include/tvm/runtime/object.h)。 +编译器栈中的所有语言对象都是 `Object` 的子类。每个对象都包含一个字符串 type_key,用于唯一标识对象类型。我们选择字符串而不是整数作为类型键的原因是:这样可以以去中心化方式添加新的 `Object` 类,而无需往中心仓库中添加代码。为了加速调度,我们会在运行时为每个 type_key 分配一个整数 type_index。 + +由于一个 `Object` 通常会在语言中被多个地方引用,我们使用 shared_ptr 来管理对象引用。`ObjectRef` 类用于表示对 `Object` 的引用,可以将其视为指向`Object`容器的 shared_ptr。我们也可以定义 `ObjectRef` 的子类来对应不同的 `Object`子类型。每个 `Object` 子类都需要实现 RegisterReflection 函数。 + +每个`Object`子类会重写该函数来注册其成员。下面是 IntImmNode 的示例实现: + +``` c +class IntImmNode : public PrimExprNode { +public: + /*! \brief the Internal value. */ + int64_t value; + + static void RegisterReflection() { + namespace refl = tvm::ffi::reflection; + refl::ObjectDef().def_ro("value", &IntImmNode::value); + } + TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.IntImm", IntImmNode, PrimExprNode); +}; +// in cc file +TVM_FFI_STATIC_INIT_BLOCK() { IntImmNode::RegisterReflection(); } +``` +`RegisterReflection` 为我们提供了一个反射接口,用于注册对象的成员。我们可以利用这个函数递归地访问并序列化任何语言对象。同时,它也使我们可以在前端语言中轻松访问对象的字段。例如: + +``` python +import tvm + +x = tvm.tir.IntImm("int32", 1) +# access the value field of IntImmNode +print(x.value) +``` +新的 `Object` 可以仅在 C++ 中添加而无需修改前端运行时,从而方便扩展编译器栈。需要注意的是,这种机制不是访问成员的最高性能方式,但它是最简单的方法之一。我们发现这种方式非常适合我们的目的:用 Python 进行测试和原型开发,而真正的计算和重工作交由 C++ 完成。 + +## 实现细节 +PackedFunc 中的每个参数由一个联合体 [TVMValue](https://github.com/apache/tvm/blob/main/include/tvm/runtime/base.h#L135) 和一个类型码组成。这样的设计使得动态类型语言可以直接转换到对应类型,而静态类型语言则可以在转换过程中执行运行时类型检查。 + +相关文件包括: + +- [packed_func.h](https://github.com/apache/tvm/blob/main/include/tvm/runtime/packed_func.h) —— C++ API + +- [c_runtime_api.cc](https://github.com/apache/tvm/blob/main/src/runtime/c_runtime_api.cc#L262) —— C API 以及如何提供回调支持 + +为了支持扩展类型,我们使用了一个注册表系统来注册类型相关信息,例如允许 C++ 中对 `any`的支持。更多详情可参考:[Extension +types](https://github.com/apache/tvm/tree/main/apps/extension)。 + +# 与运行时相关的信息 + +* Vulkan Runtime diff --git a/docs/03-deep-dive/01-design-and-architecture/02-introduction_to_module_serialization.md b/docs/03-deep-dive/01-design-and-architecture/02-introduction_to_module_serialization.md new file mode 100644 index 0000000..8181e69 --- /dev/null +++ b/docs/03-deep-dive/01-design-and-architecture/02-introduction_to_module_serialization.md @@ -0,0 +1,148 @@ +--- + +title: 模块序列化指南 + + +--- + +在部署 TVM 运行时模块时,无论目标是 CPU 还是 GPU,TVM **最终只需要一个动态共享库(dynamic shared library)**。实现这一点的关键就在于 **统一的模块序列化机制**。本文将介绍 TVM 模块序列化的格式标准与实现细节。 + +## 序列化(Serialization) + +入口 API 为 `tvm.module.Module` 的 `export_library`。在此函数内部,我们会执行以下步骤: + +1. **收集所有 DSO 模块**(例如 LLVM 模块和 C 模块)。 +2. 在获得 DSO 模块后,调用 `save` 函数将它们保存到文件。 +3. 随后检查是否存在已导入的模块(imported modules),例如 CUDA、OpenCL 等。这里对模块类型不做限制。 + 如果存在导入模块,我们将创建一个名为 `devc.o` / `dev.cc` 的文件(用于将这些导入模块的二进制数据打包进最终的动态库中),然后调用 `_PackImportsToLLVM` 或 `_PackImportsToC` 来执行模块序列化。 +4. 最后,调用 `fcompile`,其内部会调用`_cc.create_shared`,生成动态共享库。 + + +:::note + +1. 对于 C 源码模块(CSourceModule),我们会将它们编译并与 DSO 模块一同进行链接。 +2. 是否使用 `_PackImportsToLLVM` 或 `_PackImportsToC` **取决于 TVM 是否启用了 LLVM**。它们本质上实现的是相同的目标。 + +::: + +## 序列化底层机制与格式标准 + +序列化主要发生在 `_PackImportsToLLVM` 或`_PackImportsToC` 中。它们都会调用 `SerializeModule` 来序列化 runtime module。在 `SerializeModule` 函数中,我们首先会构造一个辅助类 `ModuleSerializer`。它会以 `module` 为输入进行初始化,例如分配模块索引。随后可以调用其 `SerializeModule` 方法执行序列化。 + +为了更好地理解,让我们更深入地挖掘这个类的实现。 + +下面的代码用于构造 `ModuleSerializer`: + +```c++ +explicit ModuleSerializer(runtime::Module mod) : mod_(mod) { + Init(); +} +private: +void Init() { + CreateModuleIndex(); + CreateImportTree(); +} +``` + + +在 `CreateModuleIndex()` 中,我们使用 DFS 遍历模块的导入关系并为每个模块分配索引。根模块固定为索引 `0`。 + +例如: + +``` +llvm_mod:imported_modules + - cuda_mod +``` + +因此,LLVM 模块的索引将是 0,CUDA 模块的索引将是 1。 + +在构建完模块索引之后,我们将尝试构建导入树(`CreateImportTree()`),该导入树会在我们重新加载导出的库时用于恢复模块之间的导入关系。在我们的设计中,我们使用 CSR 格式来存储导入树,每一行对应父节点索引,而子数组中的索引对应其子模块索引。在代码中,我们使用 `import_tree_row_ptr_ `和`import_tree_child_indices_` 来表示它们。 + +在完成初始化之后,我们就可以使用 `SerializeModule` 函数来序列化模块。 + +在该函数的逻辑中,我们假设序列化格式如下所示: + +```c++ +binary_blob_size +binary_blob_type_key +binary_blob_logic +binary_blob_type_key +binary_blob_logic +... +_import_tree +_import_tree_logic +``` +`binary_blob_size` 是我们在本次序列化步骤中将会包含的 blob 数量。在我们的示例中会有三个 blob,分别对应 LLVM 模块、CUDA 模块以及 `_import_tree`。 + +`binary_blob_type_key` 是模块的 blob 类型键。 +对于 LLVM / C 模块,其 blob 类型键为 `_lib`。对于 CUDA 模块,其类型键为 `cuda`,可以通过 `module->type_key()` 获取。 + +`binary_blob_logic` 是处理该 blob 的逻辑。 +对于大多数 blob(例如 CUDA、OpenCL),我们会调用 `SaveToBinary` 函数将 blob 序列化为二进制。然而,对于 LLVM / C 模块,我们只会写入 `_lib`,用于表示这是一个 DSO 模块。 + + +:::note + +是否需要实现 SaveToBinary 虚函数取决于模块的使用方式。例如,如果模块中包含我们在重新加载动态共享库时需要的信息,那么我们就应该实现该函数。像 CUDA 模块,在重新加载动态共享库时我们需要将其二进制数据传递给 GPU 驱动,因此我们需要实现 `SaveToBinary` 来序列化其二进制数据。但对于主机侧模块(如 DSO 模块),在加载动态共享库时我们并不需要额外信息,因此不需要实现 `SaveToBinary`。不过,如果未来我们希望记录一些关于 DSO 模块的元信息,我们也可以为 DSO 模块实现 `SaveToBinary`。 + +::: + +最后,除非我们的模块中仅有一个 DSO 模块并且它位于根位置,否则我们会写入一个键` _import_tree`。该键用于在重新加载导出的库时恢复模块导入关系,如前文所述。`import_tree_logic` 的内容则是将 `import_tree_row_ptr_ `和 `import_tree_child_indices_` 写入到流中。 + +在上述步骤完成后,我们会将最终结果打包进一个符号 +`runtime::symbol::tvm_ffi_library_bin`,该符号可在动态库中恢复。 + +现在,我们已经完成序列化部分。正如你所看到的,我们理论上可以支持导入任意模块。 + + +--- + +## 反序列化 + +入口 API 是 `tvm.runtime.load`。实际上,该函数会调用 `_LoadFromFile`。 如果进一步展开,可以看到其对应的是 `Module::LoadFromFile`。 + +在我们的示例中,文件是 `deploy.so`。根据其函数逻辑,我们会在 `dso_library.cc` 中调用 `module.loadfile_so`,关键代码如下: + +```c++ +// Load the imported modules +const char* library_bin = reinterpret_cast( + lib->GetSymbol(runtime::symbol::tvm_ffi_library_bin)); +Module root_mod; +if (library_bin != nullptr) { + root_mod = ProcessLibraryBin(library_bin, lib); +} else { + // Only have one single DSO Module + root_mod = Module(n); +}``` + +如前所述,我们会将 blob 打包进符号 `runtime::symbol::tvm_ffi_library_bin`· 中。 +在反序列化阶段,我们会检查它。如果存在 `runtime::symbol::tvm_ffi_library_bin`,我们将调用 `ProcessLibraryBin`,其逻辑如下: + +```c++ +READ(blob_size) +READ(blob_type_key) +for (size_t i = 0; i < blob_size; i++) { + if (blob_type_key == "_lib") { + // construct dso module using lib + } else if (blob_type_key == "_import_tree") { + // READ(_import_tree_row_ptr) + // READ(_import_tree_child_indices) + } else { + // call module.loadbinary_blob_type_key, such as module.loadbinary_cuda + // to restore. + } +} +// Using _import_tree_row_ptr and _import_tree_child_indices to +// restore module import relationship. The first module is the +// root module according to our invariance as said before. +return root_module; +``` +完成上述步骤后,我们会将 `ctx_address` 设置为 `root_module`, +以便能够从根模块查找符号(使所有符号可见)。 + +最终,我们就完成了反序列化部分。 + + + + + diff --git a/docs/03-deep-dive/01-design-and-architecture/03-pass_infra.md b/docs/03-deep-dive/01-design-and-architecture/03-pass_infra.md new file mode 100644 index 0000000..50eddd9 --- /dev/null +++ b/docs/03-deep-dive/01-design-and-architecture/03-pass_infra.md @@ -0,0 +1,444 @@ +--- + +title: Pass 基础设施 + +--- + +Relax 与 TVM IR 都包含一系列优化传递(optimization +passes),用于改进模型在特定设备上的性能指标,例如推理平均时间、内存占用或功耗。这些优化包括标准优化与机器学习特定优化,如常量折叠(constant folding)、死代码消除、算子布局变换、算子融合、缓冲区处理和循环变换等。每个传递都是基于收集的分析结果进行的 IR-to-IR 转换。 + +然而,随着 TVM 的快速发展,越来越需要一种系统化且高效的方式来管理这些传递。此外,一个通用的框架能够在 TVM 栈的不同层次(例如 Relax 和 tir)之间管理传递,这为开发者快速原型化和集成新传递铺平了道路。 + +本文档介绍了这种基础设施的设计,它结合了生产级编译器中用于管理优化传递的方式,以及现代深度学习框架用于构建层次化结构的风格。 + +例如,许多现有的生产级编译器(如 GCC 与 LLVM) 采用「传递管理器(pass manager)」来高效管理传递执行。最初传递数量较少时管理很简单,但成熟编译器可能包含数百个独立传递。外部用户往往希望添加自定义传递,并能正确调度,而无需手动修改固定顺序。 + +类似地,现代深度学习框架(如 Pytorch 与 MXNet Gluon)也倾向于通过[Sequential](https://pytorch.org/docs/stable/nn.html?highlight=sequential#torch.nn.Sequential)和[Block](https://mxnet.apache.org/api/python/docs/api/gluon/block.html#gluon-block)实现类似「传递式」层构建机制。 +借助这些构造,框架能够轻松将模块或层添加到容器中,从而快速搭建神经网络。 + +TVM 的传递基础设施设计灵感主要来自 LLVM 的层次化传递管理器 +以及流行深度学习框架的模块化容器。 该系统的主要目标包括: + +1) 支持更灵活的优化编排,让用户能自由构建自定义优化流水线。 + +2) 提供便捷的调试机制。 + +3) 让开发者无需手动解决传递之间的依赖。 + +4) 简化新传递的实现方式,例如允许用户直接用 Python + 实现一个传递,由系统自动管理其执行。 + +## 设计概述 + +系统重点关注可扩展性,使用户能快速添加新传递而不破坏兼容性。 +其结构包括后端与前端:后端实现核心逻辑,前端则提供简单的 API +供用户创建与控制优化流程。 + +### C++ 后端 + +我们提供 `PassInfo`对象来存储单个传递所需的基本信息:`name`为传递名,`opt_level`指示该传递在哪个优化级别启用,`required`表示执行该传递前所需的其他传递(详见[include/tvm/ir/transform.h](https://github.com/apache/tvm/blob/main/include/tvm/ir/transform.h))。 +在注册传递时,开发者可以指定传递名称、优化级别与依赖。 `opt_level`可帮助系统在给定优化级别下判断某个传递是否需要执行; `required`字段用于自动解析传递依赖。 + +``` c++ +class PassInfoNode : public Object { + ffi::String name; + int opt_level; + ffi::Array required; +}; +``` + +#### PassContext + +`PassContext` 携带优化传递所需的关键信息。例如,它包含错误报告系统,方便优化作者诊断失败原因。 `PassContext`也取代了旧的 +`BuildConfig`(用于配置编译选项,如优化级别、必需/禁用传递等)。例如,我们可以配置在 `opt_level=3` 下执行所有传递,并通过`disabled_pass=xx` 禁用某些传递;系统会聚合该级别的所有传递并排除被禁用的项。`PassContext`还提供对所有传递进行"检测(instrumentation)"的能力,见 `pass_instrument_cpp_backend`。 + +该类支持 Python `with` 语法,便于在给定配置下执行优化。 +同时,用户可以通过 `PassContext::Current()`在线程安全的方式获取当前上下文, 因为系统使用线程本地存储`PassContextThreadLocalStore` 来保存上下文对象。 + +``` c++ +class PassContextNode : public Object { + public: + int opt_level{2}; + tvm::ffi::Array required_pass; + tvm::ffi::Array disabled_pass; + mutable ffi::Optional diag_ctx; + ffi::Map config; + ffi::Array instruments; +}; + +class PassContext : public NodeRef { + public: + TVM_DLL static PassContext Create(); + TVM_DLL static PassContext Current(); + TVM_DLL void InstrumentEnterPassContext(); + TVM_DLL void InstrumentExitPassContext(); + TVM_DLL bool InstrumentBeforePass(const IRModule& mod, const PassInfo& info) const; + TVM_DLL void InstrumentAfterPass(const IRModule& mod, const PassInfo& info) const; + /* 其他字段省略 */ + + private: + // 进入 pass 上下文作用域 + TVM_DLL void EnterWithScope(); + // 离开 pass 上下文作用域 + TVM_DLL void ExitWithScope(); + + // 用于支持 Python `with` 语法 + friend class tvm::With; +}; + +struct PassContextThreadLocalEntry { + /*! rief 默认 pass 上下文 */ + PassContext default_context; + /*! rief 当前 pass 上下文 */ + std::stack context_stack; + PassContextThreadLocalEntry() { + default_context = PassContext(make_node()); + } +}; + +/*! rief 线程本地存储,用于保存 pass 上下文 */ +typedef dmlc::ThreadLocalStore + PassContextThreadLocalStore; +``` + +#### Pass 构造 + +传递(Pass)基础设施以分层结构设计,可在 Relax/tir +程序的不同粒度上工作。 系统定义了一个纯虚类`PassNode`,作为各种优化传递的基类。此类包含多个必须在子类中实现的虚函数,适用于模块级、函数级或顺序传递级别。 + + +``` c++ +class PassNode : Object { + virtual PassInfo Info() const = 0; + virtual Module operator()(const IRModule& mod, + const PassContext& pass_ctx) const = 0; +}; +``` + +该函数对象定义了传递的执行方式: 每个传递都在特定上下文 `PassContext`下作用于一个 `IRModule`, 并以 `Module` 到 `Module` 的方式实现。因此,所有传递都以模块为单位更新整个 IR。 + +系统实现了多个 `PassNode` 子类来支持不同类型的优化: +包括函数级传递、模块级传递与顺序传递(sequential pass)。 +每个子类本身都可充当一个传递管理器,例如:它们可以收集所需传递并执行,或基于元信息建立依赖图。完整定义见[src/ir/transform.cc](https://github.com/apache/tvm/blob/main/src/ir/transform.cc)。 + +#### 模块级传递 + +模块级传递主要用于全局或过程间优化(IPO),类似于 LLVM 中的模块传递。Relax 中一些典型需要全局视图的优化(如 A-normal form 转换、lambda 提升)就属于此类。 在该级别,用户可以在模块中添加或删除函数。 + +``` c++ +class ModulePassNode : PassNode { + PassInfo pass_info; + std::function pass_func; + Module operator()(const Module& mod, const PassContext& pass_ctx) const final; + // 其他成员/方法省略 +}; +``` + +`pass_info` 存储模块传递的相关信息,`pass_func` 定义实际优化逻辑。例如,在模块上执行死代码消除可在 `pass_func` 中实现,它将删除模块中未使用的函数。 此字段被设计为「打包函数(packed function)」, 因此优化逻辑既可用 C++ 实现,也可用 Python 实现。 + +### 函数级传递 + +函数级传递用于实现 Relax/tir 模块中函数内的优化。它一次提取模块中的一个函数进行优化,输出优化后的 Relax `Function` 或 tir `PrimFunc`。多数优化都属于此类,如 Relax 的公共子表达式消除、推理简化,或 tir 的向量化与内存扁平化。 + +函数级传递仅作用于单个函数(Relax 或 tir),因此无法通过此类传递添加或删除函数,因为其不具备全局信息。 + +``` c++ +class FunctionPassNode : PassNode { + PassInfo pass_info; + std::function pass_func; + Module operator()(const Module& mod, const PassContext& pass_ctx) const final; + bool SkipFunction(const Function& func) const; + // 其他成员/方法省略 +}; +``` + +`pass_info` 与模块级传递相同。 `pass_func`接受函数与模块作为输入,可在函数上执行优化; 函数若被注解为`SkipOptimization`,将被跳过。 + +#### 顺序传递(Sequential Pass) + +`SequentialPass` 类似于 PyTorch 的 `nn.Sequential`,可包含多个顺序执行的传递。 + +``` c++ +class SequentialPassNode : PassNode { + PassInfo pass_info; + // 需要执行的传递列表 + ffi::Array passes; + bool PassEnabled(const PassInfo& info) const; + Module operator()(const Module& mod, const PassContext& pass_ctx) const final; +}; +``` + +以下展示顺序传递的执行逻辑:系统会按照传递添加的顺序依次执行。 + +``` c++ +Module SequentialNode::operator()(const Module& module, + const PassContext& pass_ctx) const { + Module mod = module; + for (const Pass& pass : passes) { + ICHECK(pass.defined()) << "Found undefined pass for optimization."; + const PassInfo& pass_info = pass->Info(); + if (!PassEnabled(pass_info)) continue; + for (const auto& it : pass_info->required) { + const auto* name = it.as(); + ICHECK(name); + mod = GetPass(name->value)(mod, pass_ctx); + } + mod = pass(mod, pass_ctx); + } + return mod; +} +``` + +在执行传递前,系统会判断该传递是否启用:首先检查是否被用户禁用,其次查看是否被显式声明为必需。若仍未确定,则根据 `opt_level` 判断是否执行。 + +执行时,系统会根据传递名从注册表中获取对应实现: + +``` c++ +Pass GetPass(const std::string& pass_name) { + using tvm::runtime::Registry; + std::string fpass_name = "relax.transform." + pass_name; + const std::optional f = tvm::ffi::Function::GetGlobal(fpass_name); + ICHECK(f.has_value()) << "Cannot find " << fpass_name + << "to create the pass " << pass_name; + return (*f)(); +} +``` + +系统还提供辅助函数用于创建各类传递,并暴露给 Python 前端: + +``` c++ +Pass CreateFunctionPass( + std::function pass_func, + int opt_level, + ffi::String name, + ffi::Array required); + +Pass CreatePrimFuncPass( + std::function pass_func, + int opt_level, + ffi::String name, + ffi::Array required); + +Pass CreateModulePass( + std::function pass_func, + int opt_level, + ffi::String name, + ffi::Array required); + +Pass Sequential(tvm::ffi::Array passes, PassInfo pass_info); +``` + +#### 传递注册 + +前文介绍了不同粒度的传递和编译上下文。 +下面展示如何注册一个传递。以常量折叠(constant folding)为例, 它用于在 Relax 函数中折叠常量(实现位于 [src/relax/transforms/fold_constant.cc](https://github.com/apache/tvm/blob/main/src/relax/transforms/fold_constant.cc))。 + +该传递提供了 `Expr` 到 `Expr` 的转换 API: + +``` c++ +Expr FoldConstant(const Expr& expr); +``` + +要将其注册到传递基础设施中,首先需要确定传递的粒度。常量折叠作用于函数级,因此通过 `CreateFunctionPass` 创建:`pass_func` 以打包函数形式返回,用于对 [IRModule]{.title-ref} 中的每个函数调用该转换 API。 `{}` 表示该传递没有前置依赖;若有依赖,开发者需明确列出。 + +同时,注册名为 `"relax.transform.FoldConstant"` 的 API 入口,使该传递可被 C++ (例如以上的 `GetPass` )与 Python 访问: + +``` c++ +namespace transform { + +Pass FoldConstant() { + auto pass_func = + [=](Function f, IRModule m, PassContext pc) { return ConstantFolder::Fold(f, m); }; + return CreateFunctionPass(pass_func, 0, "FoldConstant", {}); +} + +TVM_FFI_STATIC_INIT_BLOCK() { + namespace refl = tvm::ffi::reflection; + refl::GlobalDef().def("relax.transform.FoldConstant", FoldConstant); +} + +} // namespace transform +``` + +为方便其他 C++ 模块调用,在[include/tvm/relax/transform.h](https://github.com/apache/tvm/blob/main/include/tvm/relax/transform.h)中声明: + +``` c++ +TVM_DLL Pass FoldConstant(); +``` + + +#### 传递检测(Pass Instrument) + +传递检测机制用于分析传递本身,例如统计执行时间与内存占用,或观察 IR 如何被改变。 + +我们在 `PassContext` 生命周期中引入四个检测点: + +``` c++ +TVM_DLL void InstrumentEnterPassContext(); +TVM_DLL void InstrumentExitPassContext(); +TVM_DLL bool InstrumentBeforePass(const IRModule& mod, const PassInfo& info) const; +TVM_DLL void InstrumentAfterPass(const IRModule& mod, const PassInfo& info) const; +``` + +`InstrumentEnterPassContext` 在进入 `PassContext` 作用域时调用。 + +`InstrumentExitPassContext` 在离开 `PassContext` 或执行发生异常时调用。当通过 :py`tvm.transform.PassContext`的`override_instruments` 覆盖检测器时也会触发,见`pass_instrument_overriden`。 + +`InstrumentBeforePass` 在传递执行前调用; 若该传递应执行,则在执行后调用 +`InstrumentAfterPass`。其伪代码如下: + +``` c++ +if (pass_ctx.InstrumentBeforePass(ir_module, pass_info)) { + new_ir_module = run_pass(ir_module, pass_ctx); + pass_ctx.InstrumentAfterPass(new_ir_module, pass_info); + return new_ir_module; +} +``` + +`PassInstrument`接口允许你在上述四个阶段插入自定义逻辑。 可向单个`PassContext` 注册多个检测器实例,它们将按 `instruments`指定的顺序依次调用。 + +接口定义如下: + +``` c++ +namespace instrument { + +class PassInstrumentNode : public Object { + public: + ffi::String name; + virtual void EnterPassContext() const = 0; + virtual void ExitPassContext() const = 0; + virtual bool ShouldRun(const IRModule& mod, const transform::PassInfo& info) const = 0; + virtual void RunBeforePass(const IRModule& mod, const transform::PassInfo& info) const = 0; + virtual void RunAfterPass(const IRModule& mod, const transform::PassInfo& info) const = 0; + /* 其他字段省略 */ +}; + +class PassInstrument : public ObjectRef { + public: + TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(PassInstrument, ObjectRef, PassInstrumentNode); +}; + +} // namespace instrument +``` + +Python 前端提供了便捷方式来实现 `PassInstrument`,见`pass_instrument_py_frontend`。 + +在一个 `PassContext` 中,某个 `PassInstrument` 实例的调用顺序如下: + + with PassContext(instruments=[pi]) # pi 为某个 PassInstrument 实现 + pi.EnterPassContext() + + if pi.ShouldRun(Pass1): + pi.RunBeforePass() + Pass1() + pi.RunAfterPass() + + if pi.ShouldRun(Pass2): + pi.RunBeforePass() + Pass2() + pi.RunAfterPass() + + pi.ExitPassContext() + +以下简述 `PassInstrument` 与 `PassContext` 方法之间的关系,详见 +[src/ir/transform.cc](https://github.com/apache/tvm/blob/main/src/ir/transform.cc): + +- `InstrumentEnterPassContext` + - `EnterPassContext()` 按传入 `instruments` 的顺序执行。 + - 若执行中抛出异常,`PassContext` 会清空所有已注册的检测器。 + - 然后对已成功执行 `EnterPassContext()` 的检测器依次调用 + `ExitPassContext()`。 + - 例如,注册了 A、B、C 三个检测器,A 成功,B 抛异常,则 C + 不会执行;随后调用 A 的 `ExitPassContext()`。 +- `InstrumentExitPassContext` + - 各检测器的 `ExitPassContext()` 按 `instruments` 顺序执行。 + - 若发生异常,`instruments` 会被清空。 + - 抛出异常后注册的检测器不会执行 `ExitPassContext`。 +- `InstrumentBeforePass` + - 若该传递未被显式列为"必需",则会调用 `ShouldRun`。 + - 若未被 `ShouldRun` 阻塞,则按顺序调用 `RunBeforePass`。 + - 该函数返回布尔值,指示该传递是否应执行。 + - 若发生异常,将立即抛出;Python + 依靠上下文管理器安全退出(确保各检测器的 `ExitPassContext` + 被调用;C++ 见 + [include/tvm/support/with.h](https://github.com/apache/tvm/blob/main/include/tvm/support/with.h))。 +- `InstrumentAfterPass` + - 按顺序调用 `RunAfterPass`。 + - 若发生异常,将立即抛出;依靠上下文管理器或 `With` + 类([include/tvm/support/with.h](https://github.com/apache/tvm/blob/main/include/tvm/support/with.h))安全退出。 + +#### 内置检测器 + +系统内置若干检测器(标注 *TODO* 的尚未实现): + +- **PassTimingInstrument**(见 + [src/ir/instrument.cc](https://github.com/apache/tvm/blob/main/src/ir/instrument.cc)) + - 用于分析各传递的执行时间。 +- **PrintIRBefore**(TODO) + - 在传递执行前打印 IR。也可通过 + :py`tvm.transform.PrintIR`{.interpreted-text role="func"} + 在传递周围插入打印实现;但使用检测器无需修改传递序列。 +- **PrintAfter**(TODO) + - 在传递执行后打印 IR。 + +### Python 前端 + +前端仅需少量 API 即可创建并执行传递(完整实现见[python/tvm/relax/transform/transform.py](https://github.com/apache/tvm/blob/main/python/tvm/relax/transform/transform.py)与[python/tvm/ir/transform.py](https://github.com/apache/tvm/blob/main/python/tvm/ir/transform.py))。后端将根据提供的信息决定如何创建 Pass 对象。 + +#### PassContext + +Python 前端为 `PassContext` 提供了包装以支持 `with` 语法,并提供`current` 静态方法: + +``` python +@tvm_ffi.register_object("transform.PassContext") +class PassContext(tvm.runtime.Object): + def __enter__(self): + _transform.EnterPassContext(self) + return self + + def __exit__(self, ptype, value, trace, config): + _transform.ExitPassContext(self) + + @staticmethod + def current(): + """Return the current pass context.""" + return _transform.GetCurrentPassContext() +``` + +`PassContext`用于配置编译选项(优化级别、必需/禁用传递等),并可传入配置字典,以便不同传递读取需要的数据(如回退设备信息、循环展开步数/深度等)。若要从 `config` 中获取某项配置,其键名需通过`TVM_REGISTER_PASS_CONFIG_OPTION` 注册,例如循环展开传递: + +``` c++ +TVM_REGISTER_PASS_CONFIG_OPTION("tir.UnrollLoop", UnrollLoopConfig); +``` + +详见[src/tir/transforms/unroll_loop.cc](https://github.com/apache/tvm/blob/main/src/tir/transforms/unroll_loop.cc)。 + +#### Python 中的传递检测 + +使用装饰器([python/tvm/ir/instrument.py](https://github.com/apache/tvm/blob/main/python/tvm/ir/instrument.py))可以快速实现 +`PassInstrument`。 推荐使用装饰器方式而非继承: + +- `enter_pass_ctx`:进入 `PassContext` 时执行; +- `exit_pass_ctx`:退出 `PassContext` 时执行; +- `should_run`:在传递执行前调用,返回该传递是否应执行; +- `run_before_pass`:传递执行前调用; +- `run_after_pass`:传递执行后调用。 + +可通过 :py`tvm.transform.PassContext` 的 +`instruments` 参数注册实例。更多示例见[use pass +instrument](https://github.com/apache/tvm/blob/main/tutorials/dev/use_pass_instrument.py)教程。 + +#### 覆盖当前 PassContext 中的检测器 + +`override_instruments` 方法可覆盖当前 `PassContext` 中的 `instruments`。例如,当未显式创建新 `PassContext` +而直接运行传递时,仍可将检测器注册到全局上下文: + +``` python +cur_pass_ctx = tvm.transform.PassContext.current() +# 覆盖 PassInstrument 实例 +cur_pass_ctx.override_instruments([pass_inst]) +mod = pass_seq(mod) +result = pass_inst.get_result() +``` + +注意:调用 `override_instruments` 时,旧检测器的 `exit_pass_ctx`会被调用,随后新检测器的 `enter_pass_ctx` 会被调用。 diff --git a/docs/03-deep-dive/01-design-and-architecture/04-device_target_interactions.md b/docs/03-deep-dive/01-design-and-architecture/04-device_target_interactions.md new file mode 100644 index 0000000..94153eb --- /dev/null +++ b/docs/03-deep-dive/01-design-and-architecture/04-device_target_interactions.md @@ -0,0 +1,104 @@ +--- + +title: 设备/目标交互 + +--- + +本文档面向希望了解 TVM 框架如何与特定设备 API 进行交互的开发者,或希望为新的 API 或新硬件添加支持的开发者。 + +对于任何新的运行时环境,需要实现三个主要部分: + +- `DeviceAPI `{.interpreted-text role="ref"} 类提供对特定设备的句柄,以及用于与其交互的 API。它定义了一套通用接口,用于查询设备参数(例如:可用内存、线程数量等),以及执行简单操作(例如:从主机复制内存,或在设备缓冲区之间复制数据)。 +- `Target `{.interpreted-text role="ref"} 类包含将要运行函数的设备描述。它同时暴露给目标代码生成器和优化 Pass。 +- `目标代码生成器 `{.interpreted-text role="ref"} 从 IRModule 构建一个由一个或多个 `PackedFunc `{.interpreted-text role="ref"} 组成的 `Module `{.interpreted-text role="ref"}。 + +## DeviceAPI {#tvm-target-specific-device-api} + +`DeviceAPI`(设备 API)表示对特定硬件设备 API 的访问句柄。(例如,`CUDADeviceAPI` 处理所有通过 CUDA 框架的交互。)大多数 `DeviceAPI` 方法都接受一个 `device_id` 参数,用于指定访问哪个设备。 + +在 Python 中,通常使用 `tvm.runtime.device`{.interpreted-text role="py:func"} 函数访问特定设备,该函数返回指定 API 所访问设备的句柄。(例如,`tvm.runtime.device('cuda', 0)` 表示访问通过 CUDA API 访问的物理设备 `0`。) + +- **属性查询** — `GetAttr` 用于查询不同的设备特定参数,例如设备名称、线程数量等。可查询的参数定义在 + `enum DeviceAttrKind`,文件位置: + [device_api.h](https://github.com/apache/tvm/blob/main/include/tvm/runtime/device_api.h)。 + 并非所有参数都适用于所有设备。如果某个参数无法查询(例如 Vulkan 上的 `kMaxClockRate`),或不适用(例如 CPU 上的 `kWarpSize`),应返回 `nullptr`。 +- **设置活动设备** — `SetDevice` 应将某个设备设置为当前活动设备。如果目标代码生成器生成的 `PackedFunc` 需要在设备上执行,该执行应发生在当前活动设备上。 +- **内存管理** — 用于在设备上分配和释放内存的工具函数。 + - **分配数据空间** — `AllocDataSpace` 和 `FreeDataSpace` 用于在设备上分配和释放数据存储空间。这些空间可作为算子输入和输出,并构成算子图的主要数据流。必须支持主机与数据空间之间的数据传输。返回值为不透明指针 `void*`。某些实现返回真实地址,但这不是必须的,该指针也可能是仅可由设备后端解释的句柄。该 `void*` 将作为参数传递给其他后端函数(例如 `CopyDataFromTo`)。 + - **分配工作空间** — `AllocWorkspace` 和 `FreeWorkspace` 用于分配和释放工作区。这些区域用于算子内部中间值存储,不要求可与主机传输。如果子类未实现,则默认调用对应的数据空间分配函数。 + - **数据复制** — `CopyDataFromTo` 应在不同位置之间复制数据。复制类型由 `dev_from` 和 `dev_to` 决定。实现应该支持将内存从CPU复制到设备,从设备复制到CPU,以及在单个设备上从一个缓冲区复制到另一个缓冲区。如果源或目标位于 CPU,则指针为可直接用于 `memcpy` 的主机地址;如果位于设备,则指针必定由 `AllocDataSpace` 或 `AllocWorkspace` 生成。 + 这些复制会排队在某个 `TVMStreamHandle` 流中执行。但是实现不应假设 CPU 缓冲区在函数返回后仍然有效或可访问。 +- **执行流管理** — 管理 `TVMStreamHandle`(执行命令的并行流)。 + - **创建流** — `CreateStream` / `FreeStream` 负责分配和释放执行流。如果设备只有单一指令队列,则 `CreateStream` 应返回 `nullptr`。 + - **设置活动流** — `SetStream` 用于将某个流设置为当前活跃流。目标代码生成器生成的函数执行时应提交到该流。 + - **同步到 CPU** — `StreamSync` 应同步流,使之在执行完成前阻塞返回。 + - **流间同步** — `SyncStreamFromTo` 应在两个流之间插入同步屏障,使目标流在源流执行完当前排队命令前无法继续执行。 + +为了使 TVM 能够使用新的 DeviceAPI,需要执行以下注册步骤: + +1. 创建一个实例化 DeviceAPI 并返回其指针的函数: + + ```cpp + FooDeviceAPI* FooDeviceAPI::Global() { + static FooDeviceAPI inst; + return &inst; + } + ``` + +2. 在 TVM 注册表中注册: + + ```cpp + TVM_FFI_STATIC_INIT_BLOCK() { + namespace refl = tvm::ffi::reflection; + refl::GlobalDef().def("device_api.foo", FooDeviceAPI::Global); + } + ``` + + + +3. 在 [base.h](https://github.com/apache/tvm/blob/main/include/tvm/runtime/base.h) 的 `TVMDeviceExtType` 枚举中为新的 DeviceAPI 添加条目。值需大于 `DLDeviceType::kDLExtDev`,且小于 `DeviceAPIManager::kMaxDeviceAPI`。 +4. 在 [device_api.h](https://github.com/apache/tvm/blob/main/include/tvm/runtime/device_api.h) 的 `DeviceName` 中添加对应枚举 → 字符串映射,该字符串需与 `GlobalDef().def` 中一致。 +5. 在 `tvm.runtime.Device`的 `_DEVICE_TYPE_TO_NAME` 与 `_DEVICE_NAME_TO_TYPE` 字典中添加对应映射。 + +## Target 定义 + +`Target` 对象是有关物理设备、其硬件/驱动限制和能力的属性查询表。`Target` 可在优化阶段和代码生成阶段使用。虽然所有运行时共享相同的 `Target` 类,但不同运行时可能需要额外的 target 特定属性。 + +在 [target_kind.cc](https://github.com/apache/tvm/blob/main/src/target/target_kind.cc) 中使用 `TVM_REGISTER_TARGET_KIND` 注册新的 target,需传入 target 名称,以及对应运行设备的 `TVMDeviceExtType` 或 `DLDeviceType`。通常情况下,target 名称和设备名称一致(如 `"cuda"` 运行于 `kDLCUDA`),但也有例外(例如 `"llvm"` 与 `"c"` 目标都运行于 `kDLCPU`)。 + +所有 target 选项通过 `add_attr_option` 添加,可带默认值。可以使用 `set_target_parser` 添加解析器,用于处理依赖其他参数或硬件属性的动态参数。 + +该参数解析器定义了如何从字符串格式构造 target。这由 `Target::Target(const String&)` 构造函数执行,该构造函数接受 JSON 格式字符串,通常通过 Python: + +```python +tvm.target.Target('{"kind": "cuda", "max_num_threads": 1024}') +``` + +在代码生成器中,可通过以下方式访问 target 属性: + +- C++:`target->GetAttr(param_name)` +- Python:`target.attrs` + +## Target 代码生成器 + +代码生成器将优化后的 `IRModule` 转换为可执行表示。每个代码生成器必须注册到 TVM 框架中,其名称为: + +``` +"target.build.foo" +``` + +其中 `foo` 与先前 `TVM_REGISTER_TARGET_KIND` 中的名称一致。 + +示例: + +```cpp +tvm::runtime::Module GeneratorFooCode(IRModule mod, Target target); +TVM_FFI_STATIC_INIT_BLOCK() { + namespace refl = tvm::ffi::reflection; + refl::GlobalDef().def("target.build.foo", GeneratorFooCode); +} +``` + +代码生成器有两个参数。第一个是要编译的`IRModule`,第二个是描述代码应该运行在哪个设备上的目标 `Target`。由于编译环境不一定与执行环境相同,因此代码生成器**不应直接向设备查询属性**,而应始终使用 `Target` 中的属性。 + +输入 `IRModule` 中的每个函数都应在输出的 `runtime::Module` 中可通过名称访问。 diff --git a/docs/03-deep-dive/01-design-and-architecture.md b/docs/03-deep-dive/01-design-and-architecture/index.md similarity index 92% rename from docs/03-deep-dive/01-design-and-architecture.md rename to docs/03-deep-dive/01-design-and-architecture/index.md index 2ab8957..b5bd48d 100644 --- a/docs/03-deep-dive/01-design-and-architecture.md +++ b/docs/03-deep-dive/01-design-and-architecture/index.md @@ -6,8 +6,8 @@ title: 设计与架构 本文档适用于想要了解 TVM 架构或积极开发项目的开发者。本文档组织结构如下: -* [整体流程](https://tvm.apache.org/docs/arch/index.html#overall-flow):概述 TVM 如何将一个高级模型描述转换为可部署模块的各个步骤。建议首先阅读本节以了解基础流程。 -* 简要介绍 TVM 栈中的关键组件。您也可以参考 [TensorIR 深度解析](https://tvm.apache.org/docs/deep_dive/tensor_ir/index.html#tensor-ir-deep-dive) 和 [Relax 深度解析](https://tvm.apache.org/docs/deep_dive/relax/index.html#relax-deep-dive),了解 TVM 栈中两个核心部分的详细内容。 +* [整体编译流程示例](/docs/deep-dive/design-and-architecture#%E7%BC%96%E8%AF%91%E6%B5%81%E7%A8%8B%E7%A4%BA%E4%BE%8B):概述 TVM 如何将一个高级模型描述转换为可部署模块的各个步骤。建议首先阅读本节以了解基础流程。 +* 简要介绍 TVM 栈中的关键组件。您也可以参考 [TensorIR 深度解析](/docs/deep-dive/tensorir/) 和 [Relax 深度解析](/docs/deep-dive/relax/),了解 TVM 栈中两个核心部分的详细内容。 本指南提供了架构的一些补充视图。首先研究端到端的编译流程,并讨论关键的数据结构和转换。这种基于 runtime 的视图侧重于运行编译器时每个组件的交互,接下来我们将研究代码库的逻辑模块及其关系。本部分将提供该设计的静态总体视图。 @@ -52,7 +52,7 @@ Relax 转换包括一系列应用于 Relax 函数的 Pass。优化内容包括 #### tir 转换 tir 转换包含一组应用于 tir 函数的 pass,主要包括两类: -* **TensorIR 调度(TensorIR schedule):** TensorIR 调度旨在为特定目标优化 TensorIR 函数,通常由用户指导控制目标代码的生成。对于 CPU 目标,TIR PrimFunc 即使没有调度也可以生成有效代码并在目标设备上运行,但性能较低。对于 GPU 目标,调度是生成有效线程绑定代码的关键。详情请参考 [TensorIR 转换教程](https://tvm.apache.org/docs/deep_dive/tensor_ir/tutorials/tir_transformation.html#tir-transform)。此外,TVM 提供了 `MetaSchedule` 来自动搜索最优的 TensorIR 调度。 +* **TensorIR 调度(TensorIR schedule):** TensorIR 调度旨在为特定目标优化 TensorIR 函数,通常由用户指导控制目标代码的生成。对于 CPU 目标,TIR PrimFunc 即使没有调度也可以生成有效代码并在目标设备上运行,但性能较低。对于 GPU 目标,调度是生成有效线程绑定代码的关键。详情请参考 [TensorIR 转换教程](/docs/deep-dive/tensorir/tir_transformation)。此外,TVM 提供了 `MetaSchedule` 来自动搜索最优的 TensorIR 调度。 * **降层 Pass(Lowering Passes):** 这些 Pass 通常在应用调度后执行,将 TIR PrimFunc 转换为功能等价但更贴近目标表示的版本。例如,有些 Pass 会将多维访问扁平化为一维指针访问,或者将中间表示中的 intrinsic 扩展为目标特定的形式,并对函数入口进行修饰以符合运行时调用约定。 @@ -229,7 +229,7 @@ target 模块包含将 IRModule 转换为目标运行时代码的所有代码生 ## tvm/relax -Relax 是用于表示模型计算图的高级 IR。多种优化过程定义在 `relax.transform` 中。需要注意的是,Relax 通常与 TensorIR 的 IRModule 协同工作,许多转换会同时作用于 Relax 和 TensorIR 函数。更多信息可参考: [Relax 深度解析](https://tvm.apache.org/docs/deep_dive/relax/index.html#relax-deep-dive)。 +Relax 是用于表示模型计算图的高级 IR。多种优化过程定义在 `relax.transform` 中。需要注意的是,Relax 通常与 TensorIR 的 IRModule 协同工作,许多转换会同时作用于 Relax 和 TensorIR 函数。更多信息可参考: [Relax 深度解析](/docs/deep-dive/relax/)。 ## tvm/tir @@ -242,7 +242,7 @@ TIR 定义了低级程序表示。我们使用 tir::PrimFunc 来表示可以由 * 位于 `tir/transform` 中的转换/优化 Pass -更多信息请参考: [TensorIR 深度解析](https://tvm.apache.org/docs/deep_dive/tensor_ir/index.html#tensor-ir-deep-dive)。 +更多信息请参考: [TensorIR 深度解析](/docs/deep-dive/tensorir/)。 ## tvm/arith @@ -276,3 +276,4 @@ DLight 提供一套预定义、易用且高性能的 TIR 调度策略。其目 + diff --git a/docs/03-deep-dive/02-tensorir/03-tir_creation.md b/docs/03-deep-dive/02-tensorir/03-tir_creation.md index d77fe0f..7179f00 100644 --- a/docs/03-deep-dive/02-tensorir/03-tir_creation.md +++ b/docs/03-deep-dive/02-tensorir/03-tir_creation.md @@ -6,14 +6,14 @@ title: TensorIR 创建 :::note -本教程可通过 Google Colab 交互式运行!也可点击[此处](https://tvm.apache.org/docs/deep_dive/tensor_ir/tutorials/tir_transformation.html#sphx-glr-download-deep-dive-tensor-ir-tutorials-tir-transformation-py)在本地运行 Jupyter Notebook。 +本教程可通过 Google Colab 交互式运行!也可点击[此处](/docs/deep-dive/tensorir/tir_creation/#%E5%88%9B%E5%BB%BA%E5%8A%A8%E6%80%81%E5%BD%A2%E7%8A%B6%E5%87%BD%E6%95%B0)在本地运行 Jupyter Notebook。 [在 Google Colab 中打开](https://colab.research.google.com/github/apache/tvm-site/blob/asf-site/docs/_downloads/c43b2ae5210f95ce8dae6102e9b060fd/tir_creation.ipynb) ::: -本节将介绍在 Apache TVM Unity 中编写 TensorIR 函数的方法。此教程假设你已经了解 TensorIR 的基本概念。如果你不熟悉,请先阅读:[理解 TensorIR 抽象](https://tvm.apache.org/docs/deep_dive/tensor_ir/learning.html#tir-learning)。 +本节将介绍在 Apache TVM Unity 中编写 TensorIR 函数的方法。此教程假设你已经了解 TensorIR 的基本概念。如果你不熟悉,请先阅读:[理解 TensorIR 抽象](/docs/deep-dive/tensorir/understand-tensorir-abstraction)。 :::note @@ -39,7 +39,7 @@ title: TensorIR 创建 ### 标准格式 -我们来看一个来自「[理解 TensorIR 抽象](https://tvm.apache.org/docs/deep_dive/tensor_ir/learning.html#tir-learning)」中的 `mm_relu` 示例。以下是完整的 `ir_module` 和 TVMScript 格式: +我们来看一个来自「[理解 TensorIR 抽象](/docs/deep-dive/tensorir/understand-tensorir-abstraction)」中的 `mm_relu` 示例。以下是完整的 `ir_module` 和 TVMScript 格式: ```plain import numpy as np @@ -215,17 +215,17 @@ print(evaluate_dynamic_shape(dyn_shape_lib, m=64, n=64, k=128)) ``` 输出: ```plain -[[1.0943729 0.73494804 1.2914591 1.0499114 ] - [0.8291257 0.44333526 0.8333979 0.34442422] - [0.6537921 0.34794778 0.63963825 0.31868583] - [1.081526 0.668489 0.9351669 1.1250921 ]] -[[36.871822 35.663208 32.37985 ... 32.534687 37.040905 34.348488] - [34.477898 35.738644 31.485312 ... 31.066946 35.29616 32.309055] - [34.64592 35.177345 32.446205 ... 32.236755 36.346832 35.233383] +[[1.6744074 1.8393843 0.9076001 0.32640088] + [1.3455076 1.5298209 0.75502187 0.32371795] + [1.9979694 2.221868 1.0828729 0.43582058] + [1.7054784 1.8512932 0.89285195 0.34154552]] +[[30.544813 29.938599 33.654526 ... 29.934391 30.73088 25.106636] + [30.644558 31.062693 32.34803 ... 29.584583 32.756992 25.280499] + [33.73643 33.23441 34.2736 ... 34.284283 35.100815 27.748833] ... - [33.381042 32.140255 29.88045 ... 30.113594 32.092564 31.41969 ] - [30.7086 32.14088 27.741928 ... 27.910046 33.892036 31.567467] - [33.512432 35.648975 31.990215 ... 29.893415 35.56177 33.823544]] + [31.313179 30.462463 30.996958 ... 28.831778 32.279408 25.663143] + [33.129818 31.630735 33.334507 ... 29.682335 32.925854 26.043703] + [32.44726 30.645096 33.926357 ... 29.750242 32.810432 25.420698]] ``` ## 使用 Tensor Expression 创建 TensorIR @@ -353,6 +353,7 @@ class Module: C[v_i, v_j] = T.max(Y[v_i, v_j], T.float32(0.0)) ``` +可右键另存为下载。 [下载 Jupyter Notebook:tir_creation.ipynb](https://tvm.apache.org/docs/_downloads/c43b2ae5210f95ce8dae6102e9b060fd/tir_creation.ipynb) diff --git a/docs/03-deep-dive/02-tensorir/04-tir_transformation.md b/docs/03-deep-dive/02-tensorir/04-tir_transformation.md index 3938c85..e19a4da 100644 --- a/docs/03-deep-dive/02-tensorir/04-tir_transformation.md +++ b/docs/03-deep-dive/02-tensorir/04-tir_transformation.md @@ -7,7 +7,7 @@ title: 转换 :::note -本教程可通过 Google Colab 交互式运行!也可点击[此处](https://tvm.apache.org/docs/deep_dive/tensor_ir/tutorials/tir_transformation.html#sphx-glr-download-deep-dive-tensor-ir-tutorials-tir-transformation-py)在本地运行 Jupyter Notebook。 +本教程可通过 Google Colab 交互式运行!也可点击[此处](/docs/deep-dive/tensorir/tir_transformation#%E8%BF%BD%E8%B8%AA%E8%BD%AC%E6%8D%A2)在本地运行 Jupyter Notebook。 [在 Google Colab 中打开](https://colab.research.google.com/github/apache/tvm-site/blob/asf-site/docs/_downloads/e2a9c4bfdec7a9365ef67c5335b1aaa4/tir_transformation.ipynb) @@ -18,7 +18,7 @@ title: 转换 在本节中,我们将深入编译流程的核心内容 —— 原始张量函数的转换(Transformation)。 -在[上一节](https://tvm.apache.org/docs/deep_dive/tensor_ir/learning.html#tir-learning)中,我们展示了如何使用 TensorIR 编写 `mm_relu`。在实际应用中,同一个功能可能有多种实现方式,而不同实现可能会带来不同的性能表现。 +在[上一节](/docs/deep-dive/tensorir/understand-tensorir-abstraction)中,我们展示了如何使用 TensorIR 编写 `mm_relu`。在实际应用中,同一个功能可能有多种实现方式,而不同实现可能会带来不同的性能表现。 :::note @@ -73,26 +73,25 @@ a_nd = tvm.runtime.tensor(a_np) b_nd = tvm.runtime.tensor(b_np) c_nd = tvm.runtime.tensor(np.zeros((128, 128), dtype="float32")) + def evaluate(mod: tvm.IRModule): lib = tvm.tir.build(mod, target="llvm") - # check correctness # 检查正确性 lib(a_nd, b_nd, c_nd) np.testing.assert_allclose(c_nd.numpy(), c_np, rtol=1e-5) - # evaluate performance # 评估性能 f_timer = lib.time_evaluator("main", tvm.cpu()) print(f_timer(a_nd, b_nd, c_nd)) - evaluate(MyModule) +evaluate(MyModule) ``` 输出: ```plain Execution time summary: mean (ms) median (ms) max (ms) min (ms) std (ms) - 2.3069 2.3069 2.3069 2.3069 0.0000 + 2.7253 2.7253 2.7253 2.7253 0.0000 ``` @@ -198,7 +197,7 @@ class Module: Execution time summary: mean (ms) median (ms) max (ms) min (ms) std (ms) - 0.8776 0.8776 0.8776 0.8776 0.0000 + 0.8571 0.8571 0.8571 0.8571 0.0000 ``` @@ -296,7 +295,7 @@ class Module: Execution time summary: mean (ms) median (ms) max (ms) min (ms) std (ms) - 0.3313 0.3313 0.3313 0.3313 0.0000 + 0.3377 0.3377 0.3377 0.3377 0.0000 ``` @@ -377,7 +376,7 @@ def apply_trace(sch: tir.Schedule) -> None: b7 = sch.decompose_reduction(block=b0, loop=l3) ``` - +可右键另存为下载。 [下载 Jupyter Notebook: tir_transformation.ipynb](https://tvm.apache.org/docs/_downloads/e2a9c4bfdec7a9365ef67c5335b1aaa4/tir_transformation.ipynb) diff --git a/docs/03-deep-dive/02-tensorir/index.md b/docs/03-deep-dive/02-tensorir/index.md index 1ebcbc8..d5d24ba 100644 --- a/docs/03-deep-dive/02-tensorir/index.md +++ b/docs/03-deep-dive/02-tensorir/index.md @@ -6,24 +6,24 @@ title: TensorIR TensorIR 是 Apache TVM 栈中的核心抽象之一,用于表示和优化原始的张量函数。 -* [张量程序抽象](https://tvm.apache.org/docs/deep_dive/tensor_ir/abstraction.html) - * [张量程序的关键元素](https://tvm.apache.org/docs/deep_dive/tensor_ir/abstraction.html#key-elements-of-tensor-programs) - * [TensorIR 中的额外结构](https://tvm.apache.org/docs/deep_dive/tensor_ir/abstraction.html#extra-structure-in-tensorir) -* [理解 TensorIR 抽象](https://tvm.apache.org/docs/deep_dive/tensor_ir/learning.html) - * [函数参数与缓冲区](https://tvm.apache.org/docs/deep_dive/tensor_ir/learning.html#function-parameters-and-buffers) - * [循环迭代](https://tvm.apache.org/docs/deep_dive/tensor_ir/learning.html#loop-iterations) - * [计算块](https://tvm.apache.org/docs/deep_dive/tensor_ir/learning.html#computational-block) - * [块轴属性](https://tvm.apache.org/docs/deep_dive/tensor_ir/learning.html#block-axis-properties) - * [为什么计算块中需要额外信息](https://tvm.apache.org/docs/deep_dive/tensor_ir/learning.html#why-extra-information-in-block) - * [绑定块轴的简洁写法](https://tvm.apache.org/docs/deep_dive/tensor_ir/learning.html#sugars-for-block-axes-binding) -* [TensorIR 的创建](https://tvm.apache.org/docs/deep_dive/tensor_ir/tutorials/tir_creation.html) - * [使用 TVMScript 创建 TensorIR](https://tvm.apache.org/docs/deep_dive/tensor_ir/tutorials/tir_creation.html#create-tensorir-using-tvmscript) - * [使用张量表达式创建 TensorIR](https://tvm.apache.org/docs/deep_dive/tensor_ir/tutorials/tir_creation.html#create-tensorir-using-tensor-expression) -* [变换](https://tvm.apache.org/docs/deep_dive/tensor_ir/tutorials/tir_transformation.html) - * [初始化调度](https://tvm.apache.org/docs/deep_dive/tensor_ir/tutorials/tir_transformation.html#initialization-schedule) - * [循环切分(Tiling)](https://tvm.apache.org/docs/deep_dive/tensor_ir/tutorials/tir_transformation.html#loop-tiling) - * [利用数据局部性](https://tvm.apache.org/docs/deep_dive/tensor_ir/tutorials/tir_transformation.html#leverage-localities) - * [重写归约操作](https://tvm.apache.org/docs/deep_dive/tensor_ir/tutorials/tir_transformation.html#rewrite-reduction) - * [追踪变换过程](https://tvm.apache.org/docs/deep_dive/tensor_ir/tutorials/tir_transformation.html#trace-the-transformation) +* [张量程序抽象](/docs/deep-dive/tensorir/tensor-program-abstraction) + * [张量程序的关键元素](/docs/deep-dive/tensorir/tensor-program-abstraction#%E5%BC%A0%E9%87%8F%E7%A8%8B%E5%BA%8F%E7%9A%84%E5%85%B3%E9%94%AE%E5%85%83%E7%B4%A0) + * [TensorIR 中的额外结构](/docs/deep-dive/tensorir/tensor-program-abstraction#tensorir-%E4%B8%AD%E7%9A%84%E9%A2%9D%E5%A4%96%E7%BB%93%E6%9E%84) +* [理解 TensorIR 抽象](/docs/deep-dive/tensorir/understand-tensorir-abstraction) + * [函数参数与缓冲区](/docs/deep-dive/tensorir/understand-tensorir-abstraction#%E5%87%BD%E6%95%B0%E5%8F%82%E6%95%B0%E4%B8%8E%E7%BC%93%E5%86%B2%E5%8C%BA) + * [循环迭代](/docs/deep-dive/tensorir/understand-tensorir-abstraction#%E5%BE%AA%E7%8E%AF%E8%BF%AD%E4%BB%A3) + * [计算块](/docs/deep-dive/tensorir/understand-tensorir-abstraction#%E8%AE%A1%E7%AE%97%E5%9D%97) + * [块轴属性](/docs/deep-dive/tensorir/understand-tensorir-abstraction#%E5%9D%97%E8%BD%B4%E5%B1%9E%E6%80%A7) + * [为什么计算块中需要额外信息](/docs/deep-dive/tensorir/understand-tensorir-abstraction#%E4%B8%BA%E4%BB%80%E4%B9%88%E5%9C%A8%E5%9D%97%E4%B8%AD%E6%9C%89%E9%A2%9D%E5%A4%96%E7%9A%84%E4%BF%A1%E6%81%AF) + * [绑定块轴的语法](/docs/deep-dive/tensorir/understand-tensorir-abstraction#%E5%9D%97%E8%BD%B4%E7%BB%91%E5%AE%9A%E7%9A%84%E8%AF%AD%E6%B3%95) +* [TensorIR 的创建](/docs/deep-dive/tensorir/tir_creation) + * [使用 TVMScript 创建 TensorIR](/docs/deep-dive/tensorir/tir_creation#%E4%BD%BF%E7%94%A8-tvmscript-%E5%88%9B%E5%BB%BA-tensorir) + * [使用张量表达式创建 TensorIR](/docs/deep-dive/tensorir/tir_creation#%E4%BD%BF%E7%94%A8-tensor-expression-%E5%88%9B%E5%BB%BA-tensorir) +* [转换](/docs/deep-dive/tensorir/tir_transformation) + * [初始化调度](/docs/deep-dive/tensorir/tir_transformation#%E5%88%9D%E5%A7%8B%E5%8C%96%E8%AE%A1%E5%88%92) + * [循环切分(Tiling)](/docs/deep-dive/tensorir/tir_transformation#%E5%BE%AA%E7%8E%AF%E5%88%86%E5%9D%97loop-tiling) + * [利用数据局部性](/docs/deep-dive/tensorir/tir_transformation#%E5%88%A9%E7%94%A8%E5%B1%80%E9%83%A8%E6%80%A7) + * [重写归约操作](/docs/deep-dive/tensorir/tir_transformation#%E9%87%8D%E5%86%99%E5%BD%92%E7%BA%A6%E6%93%8D%E4%BD%9C) + * [追踪变换过程](/docs/deep-dive/tensorir/tir_transformation#%E8%BF%BD%E8%B8%AA%E8%BD%AC%E6%8D%A2) diff --git a/docs/03-deep-dive/03-relax/02-understand-relax-abstraction.md b/docs/03-deep-dive/03-relax/02-understand-relax-abstraction.md index 058491e..7a17e8b 100644 --- a/docs/03-deep-dive/03-relax/02-understand-relax-abstraction.md +++ b/docs/03-deep-dive/03-relax/02-understand-relax-abstraction.md @@ -156,7 +156,7 @@ class Module: 上面的代码包括两类函数:原始张量函数(`T.prim_func`)和 Relax 函数(`R.function`)。Relax 函数是一种新型抽象,用于表示高层神经网络的执行过程。 -请注意,上述 Relax 模块原生支持符号形状(symbolic shape),如 `main` 函数中张量形状里的`"n"`**,**以及 `linear` 函数中的 `M`**、**`N`**、**`K`**。**这是 Relax 抽象层的一项关键特性,使得编译器能够在张量操作符和函数调用之间,全局追踪动态形状关系。 +请注意,上述 Relax 模块原生支持符号形状(symbolic shape),如 `main` 函数中张量形状里的`"n"`,**以及 `linear` 函数中的 `M`**、**`N`**、**`K`**。这是 Relax 抽象层的一项关键特性,使得编译器能够在张量操作符和函数调用之间,全局追踪动态形状关系。 再次并排查看 TVMScript 代码与底层 numpy 代码,并检查它们之间的对应关系是非常有帮助的,我们将逐步详细地分析它们。由于我们已经学习了基本的张量函数,这里我们将重点关注高层执行部分。 @@ -198,7 +198,7 @@ lnumpy_linear(x, w0, b0, lv0) -**这种约定被称为destination passing(目标传递),**其思想是输入与输出张量都在外部显式分配,然后传入低层函数。这种风格在底层库设计中非常常见,便于高层框架自行控制内存的分配。需要注意的是,并非所有张量操作都适用于这种风格(特别是当输出形状依赖于输入时)。尽管如此,在实际使用中,尽量采用这种风格编写低层函数通常是很有益的。 +**这种约定被称为destination passing(目标传递),** 其思想是输入与输出张量都在外部显式分配,然后传入低层函数。这种风格在底层库设计中非常常见,便于高层框架自行控制内存的分配。需要注意的是,并非所有张量操作都适用于这种风格(特别是当输出形状依赖于输入时)。尽管如此,在实际使用中,尽量采用这种风格编写低层函数通常是很有益的。 ### 数据流块 @@ -242,3 +242,4 @@ with R.dataflow(): 通过手动标记数据流块,我们可以确保编译器拥有最准确的信息,从而实现更有效的优化。 + diff --git a/docs/03-deep-dive/03-relax/03-relax-creation.md b/docs/03-deep-dive/03-relax/03-relax-creation.md index 73c97d4..61a2776 100644 --- a/docs/03-deep-dive/03-relax/03-relax-creation.md +++ b/docs/03-deep-dive/03-relax/03-relax-creation.md @@ -7,7 +7,7 @@ title: 创建 Relax :::note -本教程可通过 Google Colab 交互式运行!也可点击[此处](https://tvm.apache.org/docs/deep_dive/relax/tutorials/relax_creation.html#sphx-glr-download-deep-dive-relax-tutorials-relax-creation-py)在本地运行 Jupyter Notebook。 +本教程可通过 Google Colab 交互式运行!也可点击[此处](/docs/deep-dive/relax/relax-creation#%E6%80%BB%E7%BB%93)在本地运行 Jupyter Notebook。 [在 Google Colab 中打开](https://colab.research.google.com/github/apache/tvm-site/blob/asf-site/docs/_downloads/315fcda965a8d605f81705edf19ea2c6/relax_creation.ipynb) @@ -496,7 +496,7 @@ class Module: ## 总结 -本教程演示了如何使用 TVMScript、NNModule API、Block Builder API 以及 PackedFunc API,根据不同的应用场景来创建 Relax 程序。 +本教程演示了如何使用 TVMScript、NNModule API、Block Builder API 以及 PackedFunc API,根据不同的应用场景来创建 Relax 程序(可右键另存为下载)。 * [下载 Jupyter notebook: relax_creation.ipynb](https://tvm.apache.org/docs/_downloads/315fcda965a8d605f81705edf19ea2c6/relax_creation.ipynb) * [下载 Python 源码: relax_creation.py](https://tvm.apache.org/docs/_downloads/a67d9d8c1ea48d5e0c95591f8c9bfd6f/relax_creation.py) * [下载压缩包: relax_creation.zip](https://tvm.apache.org/docs/_downloads/4753776bbe68e7c9ee4d19117973fc8b/relax_creation.zip) diff --git a/docs/03-deep-dive/03-relax/04-transformation.md b/docs/03-deep-dive/03-relax/04-transformation.md index 0422d04..8ffb2a5 100644 --- a/docs/03-deep-dive/03-relax/04-transformation.md +++ b/docs/03-deep-dive/03-relax/04-transformation.md @@ -5,10 +5,18 @@ title: 转换 --- +:::note + +本教程可通过 Google Colab 交互式运行!也可点击[此处](/docs/deep-dive/relax/transformation#%E6%80%BB%E7%BB%93)在本地运行 Jupyter Notebook。 + +[在 Google Colab 中打开](https://colab.research.google.com/github/apache/tvm-site/blob/asf-site/docs/_downloads/315fcda965a8d605f81705edf19ea2c6/relax_creation.ipynb) + +::: + 本节我们将深入介绍 Relax 程序的转换。转换是编译流程中实现优化和对接硬件后端的关键环节之一。 -我们首先像[上一节](https://tvm.apache.org/docs/deep_dive/relax/tutorials/relax_creation.html#relax-creation)那样,创建一个简单的 Relax 程序。 +我们首先像[上一节](/docs/deep-dive/relax/relax-creation)那样,创建一个简单的 Relax 程序。 ```plain import tvm @@ -401,7 +409,7 @@ class Module: ## 总结 -在本节中,我们展示了如何对 Relax 程序进行转换,并介绍了如何定义和应用自定义转换。 +在本节中,我们展示了如何对 Relax 程序进行转换,并介绍了如何定义和应用自定义转换(可右键另存为下载)。 * [下载 Jupyter notebook:relax_transformation.ipynb](https://tvm.apache.org/docs/_downloads/31d077cfa7c55c0edcd16ad5d4faf483/relax_transformation.ipynb) * [下载 Python 源码:relax_transformation.py](https://tvm.apache.org/docs/_downloads/4e684410fb30ce02332f55fde123c42e/relax_transformation.py) * [下载压缩包:relax_transformation.zip](https://tvm.apache.org/docs/_downloads/7d201684dfa095a5ea48d98e9a2ef7ad/relax_transformation.zip) diff --git a/docs/03-deep-dive/03-relax/index.md b/docs/03-deep-dive/03-relax/index.md index 0fee43e..bf8e8d2 100644 --- a/docs/03-deep-dive/03-relax/index.md +++ b/docs/03-deep-dive/03-relax/index.md @@ -7,21 +7,21 @@ title: Relax Relax 是 Apache TVM 栈中用于图优化和转换的高级抽象层。此外,Apache TVM 将 Relax 和 TensorIR 结合在一起,作为跨层优化的统一策略。因此,Relax 通常与 TensorIR 紧密协作,用于表示和优化整个 IRModule。 -* 机器学习模型的图抽象 - * 什么是图抽象? - * Relax 的关键特性 -* 理解 Relax 抽象层 - * 端到端模型执行 - * Relax 的核心元素 -* 创建 Relax - * 使用 TVMScript 创建 Relax 程序 - * 使用 NNModule API 创建 Relax 程序 - * 使用 Block Builder API 创建 Relax 程序 - * 总结 -* 转换与优化 - * 应用转换 - * 自定义 Pass - * 总结 +* [机器学习模型的图抽象](/docs/deep-dive/relax/graph-abstraction-for-ml-models) + * [什么是图抽象?](/docs/deep-dive/relax/graph-abstraction-for-ml-models#%E4%BB%80%E4%B9%88%E6%98%AF%E5%9B%BE%E6%8A%BD%E8%B1%A1) + * [Relax 的关键特性](/docs/deep-dive/relax/graph-abstraction-for-ml-models#relax-%E7%9A%84%E5%85%B3%E9%94%AE%E7%89%B9%E6%80%A7) +* [理解 Relax 抽象层](/docs/deep-dive/relax/understand-relax-abstraction) + * [端到端模型执行](/docs/deep-dive/relax/understand-relax-abstraction#%E7%AB%AF%E5%88%B0%E7%AB%AF%E6%A8%A1%E5%9E%8B%E6%89%A7%E8%A1%8C) + * [Relax 的核心元素](/docs/deep-dive/relax/understand-relax-abstraction#relax-%E7%9A%84%E5%85%B3%E9%94%AE%E5%85%83%E7%B4%A0) +* [创建 Relax ](/docs/deep-dive/relax/relax-creation) + * [使用 TVMScript 创建 Relax 程序](/docs/deep-dive/relax/relax-creation#%E4%BD%BF%E7%94%A8-tvmscript-%E5%88%9B%E5%BB%BA-relax-%E7%A8%8B%E5%BA%8F) + * [使用 NNModule API 创建 Relax 程序](/docs/deep-dive/relax/relax-creation#%E4%BD%BF%E7%94%A8-nnmodule-api-%E6%9E%84%E5%BB%BA-relax-%E7%A8%8B%E5%BA%8F) + * [使用 Block Builder API 创建 Relax 程序](/docs/deep-dive/relax/relax-creation#%E4%BD%BF%E7%94%A8-block-builder-api-%E5%88%9B%E5%BB%BA-relax-%E7%A8%8B%E5%BA%8F) + * [总结](/docs/deep-dive/relax/relax-creation#%E6%80%BB%E7%BB%93) +* [转换与优化](/docs/deep-dive/relax/transformation) + * [应用转换](/docs/deep-dive/relax/transformation#%E5%BA%94%E7%94%A8%E8%BD%AC%E6%8D%A2) + * [自定义 Pass](/docs/deep-dive/relax/transformation#%E8%87%AA%E5%AE%9A%E4%B9%89-pass) + * [总结](/docs/deep-dive/relax/transformation#%E6%80%BB%E7%BB%93) diff --git a/docs/04-api-reference/01-python-api/01-tvm-error.md b/docs/04-api-reference/01-python-api/01-tvm-error.md index f5abf3a..d0740e5 100644 --- a/docs/04-api-reference/01-python-api/01-tvm-error.md +++ b/docs/04-api-reference/01-python-api/01-tvm-error.md @@ -12,30 +12,30 @@ TVM 中的结构化错误类。 :::note -另请参阅[错误处理指南](https://tvm.apache.org/docs/contribute/error_handling.html#error-handling-guide)。 +另请参阅[错误处理指南](/docs/about/contribute/error_handling-guide)。 ::: **函数:** -|[register_error](https://tvm.apache.org/docs/reference/api/python/error.html#tvm.error.register_error)([name_or_cls, cls])|注册一个错误类,以便 FFI 错误处理器能够识别它。| +|[register_error](/docs/api-reference/python-api/tvm-error#tvmerrorregister_errorname_or_clsnoneclsnone)([name_or_cls, cls])|注册一个错误类,以便 FFI 错误处理器能够识别它。| |:----|:----| **异常:** -|[TVMError](https://tvm.apache.org/docs/reference/api/python/error.html#tvm.error.TVMError)|TVM 的通用错误基类。| +|[TVMError](/docs/api-reference/python-api/tvm-error#exceptiontvmerrortvmerror)|TVM 的通用错误基类。| |:----|:----| -|[InternalError](https://tvm.apache.org/docs/reference/api/python/error.html#tvm.error.InternalError)|系统内部错误。| -|[RPCError](https://tvm.apache.org/docs/reference/api/python/error.html#tvm.error.RPCError)|由远程服务器在处理 RPC 调用时抛出的错误。| -|[RPCSessionTimeoutError](https://tvm.apache.org/docs/reference/api/python/error.html#tvm.error.RPCSessionTimeoutError)|当 RPC 会话过期时由远程服务器抛出的错误。| -|[OpError](https://tvm.apache.org/docs/reference/api/python/error.html#tvm.error.OpError)|前端所有算子错误的基类。| -|[OpNotImplemented](https://tvm.apache.org/docs/reference/api/python/error.html#tvm.error.OpNotImplemented)|算子未实现。| -|[OpAttributeRequired](https://tvm.apache.org/docs/reference/api/python/error.html#tvm.error.OpAttributeRequired)|找不到所需的算子属性。| -|[OpAttributeInvalid](https://tvm.apache.org/docs/reference/api/python/error.html#tvm.error.OpAttributeInvalid)|前端算子接收的属性值无效。| -|[OpAttributeUnImplemented](https://tvm.apache.org/docs/reference/api/python/error.html#tvm.error.OpAttributeUnImplemented)|在某些前端中不支持该属性。| -|[DiagnosticError](https://tvm.apache.org/docs/reference/api/python/error.html#tvm.error.DiagnosticError)|在执行某个 Pass 时报告的错误诊断。| +|[InternalError](/docs/api-reference/python-api/tvm-error#exceptiontvmerrorinternalerror)|系统内部错误。| +|[RPCError](/docs/api-reference/python-api/tvm-error#exceptiontvmerrorrpcerror)|由远程服务器在处理 RPC 调用时抛出的错误。| +|[RPCSessionTimeoutError](/docs/api-reference/python-api/tvm-error#exceptiontvmerrorrpcsessiontimeouterror)|当 RPC 会话过期时由远程服务器抛出的错误。| +|[OpError](/docs/api-reference/python-api/tvm-error#exceptiontvmerroroperror)|前端所有算子错误的基类。| +|[OpNotImplemented](/docs/api-reference/python-api/tvm-error#exceptiontvmerroropnotimplemented)|算子未实现。| +|[OpAttributeRequired](/docs/api-reference/python-api/tvm-error#exceptiontvmerroropattributerequired)|找不到所需的算子属性。| +|[OpAttributeInvalid](/docs/api-reference/python-api/tvm-error#exceptiontvmerroropattributeinvalid)|前端算子接收的属性值无效。| +|[OpAttributeUnImplemented](/docs/api-reference/python-api/tvm-error#exceptiontvmerroropattributeunimplemented)|在某些前端中不支持该属性。| +|[DiagnosticError](/docs/api-reference/python-api/tvm-error#exceptiontvmerrordiagnosticerror)|在执行某个 Pass 时报告的错误诊断。| diff --git a/docs/04-api-reference/01-python-api/02-tvm-ir.md b/docs/04-api-reference/01-python-api/02-tvm-ir.md index a3f0059..e2cbba4 100644 --- a/docs/04-api-reference/01-python-api/02-tvm-ir.md +++ b/docs/04-api-reference/01-python-api/02-tvm-ir.md @@ -10,46 +10,46 @@ title: tvm.ir **类:** -|[Attrs](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Attrs)|属性节点,主要用于定义运算符的属性| +|[Attrs](/docs/api-reference/python-api/tvm-ir#classtvmirattrs)|属性节点,主要用于定义运算符的属性| |:----|:----| -|[DictAttrs](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.DictAttrs)|字典属性| -|[EnvFunc](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.EnvFunc)|环境函数| -|[Node](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Node)|所有 IR 节点的基类| -|[SourceName](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.SourceName)(name)|源位置的标识符| -|[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)(source_name, line, end_line, column, ...)|指定源程序中的位置| -|[SequentialSpan](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.SequentialSpan)(spans)|源跨度序列| -|[Array](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Array)(input_list)|数组容器| -|[Map](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Map)(input_dict)|映射容器| -|[BaseExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.BaseExpr)|所有表达式的基类| -|[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar)(name_hint[, type_annot])|IR 中的全局变量| -|[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)|所有原始表达式的基类| -|[Range](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Range)(begin[, end, span])|表示 TVM 中的范围| -|[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)|所有非原始表达式的基类| -|[BaseFunc](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.BaseFunc)|所有函数的基类| -|[CallingConv](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.CallingConv)(value)|可能的调用约定种类| -|[GlobalInfo](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalInfo)|所有可出现在 IR 中的全局信息的基础节点| -|[DummyGlobalInfo](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.DummyGlobalInfo)()|| -|[VDevice](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.VDevice)([target, vdevice_id, memory_scope])|| -|[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)([functions, attrs, global_infos])|包含函数和类型定义的 IRModule| -|[Op](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Op)()|IR 中的原始运算符| -|[FuncType](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.FuncType)(arg_types, ret_type)|函数类型| -|[PointerType](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PointerType)(element_type[, storage_scope])|低级 TIR 中使用的 PointerType| -|[PrimType](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimType)(dtype)|低级 IR 中的原始数据类型| -|[TupleType](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.TupleType)(fields)|元组值的类型| -|[Type](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Type)|所有类型的基类| +|[DictAttrs](/docs/api-reference/python-api/tvm-ir#class-tvmirdictattrs)|字典属性| +|[EnvFunc](/docs/api-reference/python-api/tvm-ir#class-tvmirenvfunc)|环境函数| +|[Node](/docs/api-reference/python-api/tvm-ir#class-tvmirnode)|所有 IR 节点的基类| +|[SourceName](/docs/api-reference/python-api/tvm-ir#class-tvmirsourcenamename)(name)|源位置的标识符| +|[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)(source_name, line, end_line, column, ...)|指定源程序中的位置| +|[SequentialSpan](/docs/api-reference/python-api/tvm-ir#class-tvmirsequentialspanspans)(spans)|源跨度序列| +|[Array](/docs/api-reference/python-api/tvm-ir#class-tvmirarrayinput_listsequenceany)(input_list)|数组容器| +|[Map](/docs/api-reference/python-api/tvm-ir#class-tvmirmapinput_dictmappinganyany)(input_dict)|映射容器| +|[BaseExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirbaseexpr)|所有表达式的基类| +|[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none)(name_hint[, type_annot])|IR 中的全局变量| +|[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)|所有原始表达式的基类| +|[Range](/docs/api-reference/python-api/tvm-ir#class-tvmirrangebeginprimexpr-endprimexprnone-none-spanspannone-none)(begin[, end, span])|表示 TVM 中的范围| +|[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)|所有非原始表达式的基类| +|[BaseFunc](/docs/api-reference/python-api/tvm-ir#classtvmirbasefunc)|所有函数的基类| +|[CallingConv](/docs/api-reference/python-api/tvm-ir#class-tvmircallingconvvalue)(value)|可能的调用约定种类| +|[GlobalInfo](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalinfo)|所有可出现在 IR 中的全局信息的基础节点| +|[DummyGlobalInfo](/docs/api-reference/python-api/tvm-ir#class-tvmirdummyglobalinfo)()|| +|[VDevice](/docs/api-reference/python-api/tvm-ir#class-tvmirvdevicetargetnone-vdevice_idint-0-memory_scopestr-global)([target, vdevice_id, memory_scope])|| +|[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)([functions, attrs, global_infos])|包含函数和类型定义的 IRModule| +|[Op](/docs/api-reference/python-api/tvm-ir#class-tvmirop)()|IR 中的原始运算符| +|[FuncType](/docs/api-reference/python-api/tvm-ir#class-tvmirfunctypearg_types-ret_type)(arg_types, ret_type)|函数类型| +|[PointerType](/docs/api-reference/python-api/tvm-ir#class-tvmirpointertypeelement_type-storage_scope)(element_type[, storage_scope])|低级 TIR 中使用的 PointerType| +|[PrimType](/docs/api-reference/python-api/tvm-ir#class-tvmirprimtypedtype)(dtype)|低级 IR 中的原始数据类型| +|[TupleType](/docs/api-reference/python-api/tvm-ir#class-tvmirtupletypefields)(fields)|元组值的类型| +|[Type](/docs/api-reference/python-api/tvm-ir#class-tvmirtype)|所有类型的基类| **函数:** -|[make_node](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.make_node)(type_key, **kwargs)|根据类型键和字段创建一个新的 IR 节点| +|[make_node](/docs/api-reference/python-api/tvm-ir#tvmirmake_nodetype_key-kwargs)(type_key, **kwargs)|根据类型键和字段创建一个新的 IR 节点| |:----|:----| -|[assert_structural_equal](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.assert_structural_equal)(lhs, rhs[, …])|断言 lhs 和 rhs 在结构上彼此相等| -|[load_json](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.load_json)(json_str)|从 json_str 加载 tvm 对象| -|[save_json](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.save_json)(node)|将 tvm 对象保存为 json 字符串| -|[structural_equal](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.structural_equal)(lhs, rhs[, map_free_vars])|检查 lhs 和 rhs 的结构相等性| -|[structural_hash](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.structural_hash)(node[, map_free_vars])|计算节点的结构哈希| -|[register_intrin_lowering](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.register_intrin_lowering)(op_name, target, *)|寄存器操作数降低函数| -|[register_op_attr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.register_op_attr)(op_name, attr_key[, value, …])|通过名称注册一个运算符的运算符属性| +|[assert_structural_equal](/docs/api-reference/python-api/tvm-ir#tvmirassert_structural_equallhsrhsmap_free_varsfalse)(lhs, rhs[, …])|断言 lhs 和 rhs 在结构上彼此相等| +|[load_json](/docs/api-reference/python-api/tvm-ir#tvmirload_jsonjson_strobject)(json_str)|从 json_str 加载 tvm 对象| +|[save_json](/docs/api-reference/python-api/tvm-ir#tvmirsave_jsonnode--str)(node)|将 tvm 对象保存为 json 字符串| +|[structural_equal](/docs/api-reference/python-api/tvm-ir#tvmirstructural_equallhsrhsmap_free_varsfalse)(lhs, rhs[, map_free_vars])|检查 lhs 和 rhs 的结构相等性| +|[structural_hash](/docs/api-reference/python-api/tvm-ir#tvmirstructural_hashnodemap_free_varsfalse)(node[, map_free_vars])|计算节点的结构哈希| +|[register_intrin_lowering](/docs/api-reference/python-api/tvm-ir#tvmirregister_intrin_loweringop_nametargetfnonelevel10)(op_name, target, *)|寄存器操作数降低函数| +|[register_op_attr](/docs/api-reference/python-api/tvm-ir#tvmirregister_op_attrop_nameattr_keyvaluenonelevel10)(op_name, attr_key[, value, …])|通过名称注册一个运算符的运算符属性| ## ***class*tvm.ir.Attrs** @@ -61,16 +61,16 @@ title: tvm.ir **方法:** -|[get_int_tuple](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Attrs.get_int_tuple)(key)|获取键的 Python int 元组| +|[get_int_tuple](/docs/api-reference/python-api/tvm-ir#get_int_tuplekey)(key)|获取键的 Python int 元组| |:----|:----| -|[get_int](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Attrs.get_int)(key)|获取某个键的 Python int 值| -|[get_str](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Attrs.get_str)(key)|获取某个键的 Python int 值| +|[get_int](/docs/api-reference/python-api/tvm-ir#get_intkey)(key)|获取某个键的 Python int 值| +|[get_str](/docs/api-reference/python-api/tvm-ir#get_strkey)(key)|获取某个键的 Python int 值| ### **get_int_tuple(*key*)** 获取键的 Python 整数元组。 * **参数: key** ([str](https://docs.python.org/3/library/stdtypes.html#str)) * **返回: value  值** -* **返回类型:**[int](https://docs.python.org/3/library/functions.html#int)[元组](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple) +* **返回类型:**[int](https://docs.python.org/3/library/functions.html#int)[元组](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone) @@ -95,10 +95,10 @@ title: tvm.ir **方法:** -|[keys](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.DictAttrs.keys)()|获取属性中的名称列表| +|[keys](/docs/api-reference/python-api/tvm-ir#keys)()|获取属性中的名称列表| |:----|:----| -|[get](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.DictAttrs.get)(key[, default])|获取具有默认值的元素| -|[items](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.DictAttrs.items)()|从映射上获取项目| +|[get](/docs/api-reference/python-api/tvm-ir#getkey-defaultnone)(key[, default])|获取具有默认值的元素| +|[items](/docs/api-reference/python-api/tvm-ir#items)()|从映射上获取项目| ### keys() @@ -121,10 +121,10 @@ title: tvm.ir * **type_key** ([str](https://docs.python.org/3/library/stdtypes.html#str)):节点的类型键 * ***kwargs** ([dict](https://docs.python.org/3/library/stdtypes.html#dict)) :节点的字段 * **返回:node** :相应的 IR 节点 -* **返回类型:**[Node](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Node) +* **返回类型:**[Node](/docs/api-reference/python-api/tvm-ir#class-tvmirnode) -:::Note +:::note 如果创建的节点是 AttrsNode 的实例,那么创建函数还将运行 Attrs 支持的边界检查和默认值设置 @@ -151,7 +151,7 @@ assert x.value == 10 **方法:** -|[get](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.EnvFunc.get)(name)|获取静态环境函数| +|[get](/docs/api-reference/python-api/tvm-ir#static-getname)(name)|获取静态环境函数| |:----|:----| ### *static* get(*name*) @@ -172,7 +172,7 @@ assert x.value == 10 指定源程序中的位置。 * **参数:** - * **source** ([SourceName](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.SourceName)) – 源名称 + * **source** ([SourceName](/docs/api-reference/python-api/tvm-ir#class-tvmirsourcenamename)) – 源名称 * **lineno** ([int](https://docs.python.org/3/library/functions.html#int)) – 行号 * **col_offset** ([int](https://docs.python.org/3/library/functions.html#int)) – 位置的列偏移量 @@ -182,7 +182,7 @@ assert x.value == 10 此跨度特定于一个表达式,它来自 IR 变换后的多个表达式。 -* **参数:spans** ([Array](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Array)):跨度数组。 +* **参数:spans** ([Array](/docs/api-reference/python-api/tvm-ir#class-tvmirarrayinput_listsequenceany)):跨度数组。 @@ -283,41 +283,76 @@ structural_hash 与 structural_equal 保持一致。如果两个节点在结构 ::: -## *class* tvm.ir.Array(*input_list:*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[Any](https://docs.python.org/3/library/typing.html#typing.Any)*]*) +## *class* tvm.ir.Array(*input_list:*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)[*[Any](https://docs.python.org/3/library/typing.html#typing.Any)*]) -数组容器。 +表示ffi值序列的数组容器。 -## *class* tvm.ir.Map(*input_dict:*[Mapping](https://docs.python.org/3/library/typing.html#typing.Mapping)*[*[Any](https://docs.python.org/3/library/typing.html#typing.Any)*,*[Any](https://docs.python.org/3/library/typing.html#typing.Any)*]*) +`tvm_ffi.convert()`将python列表/元组映射到这个类。 +* **参数:input_list**—要存储在数组中的值的列表 + +:::info 另见 -映射容器。 +`tvm_ffi.convert()` +::: +示例 +```python +import tvm_ffi -**方法:** +a = tvm_ffi.convert([1, 2, 3]) +assert isinstance(a, tvm_ffi.Array) +assert len(a) == 3 +``` -|[keys](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Map.keys)()|[values](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Map.values)()| -|:----|:----| -|[values](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Map.values)()|| -|[items](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Map.items)()|从映射中获取项目| -|[get](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Map.get)(key[, default])|获取具有默认值的元素| +## *class* tvm.ir.Map(*input_dict:[Mapping](https://docs.python.org/3/library/typing.html#typing.Mapping)[[Any](https://docs.python.org/3/library/typing.html#typing.Any),[Any](https://docs.python.org/3/library/typing.html#typing.Any)]*) -### keys() → a set-like object providing a view on D's keys -### values() → an object providing a view on D's values +映射容器。 +`tvm_ffi.convert()`将python字典映射到这个类。 +* **参数:input_dict**—要存储在映射中的值的字典。 + +:::info 另见 -### items() -从映射中获取项目。 +`tvm_ffi.convert()` -### get(*key*, *default=None*) +::: +示例 +```python +import tvm_ffi + +amap = tvm_ffi.convert({"a": 1, "b": 2}) +assert isinstance(amap, tvm_ffi.Map) +assert len(amap) == 2 +assert amap["a"] == 1 +assert amap["b"] == 2 +``` + +**方法:** + +|[keys](/docs/api-reference/python-api/tvm-ir#keys--a-set-like-object-providing-a-view-on-ds-keys)()|[values](/docs/api-reference/python-api/tvm-ir#values--an-object-providing-a-view-on-ds-values)()| +|:----|:----| +|[values](/docs/api-reference/python-api/tvm-ir#values--an-object-providing-a-view-on-ds-values)()|| +|[items](/docs/api-reference/python-api/tvm-ir#items-1)()|从映射中获取项目| +|[get](/docs/api-reference/python-api/tvm-ir#getkey-defaultnone-1)(key[, default])|获取具有默认值的元素| + +### keys()→ KeysView[K] +返回映射键的动态视图。 +### values()→ ValuesView[V] +返回映射值的动态视图。 +### items()→ ItemsView[K,V] +从地图上获取物品。 +### get(*key:K*)→V|[None](https://docs.python.org/3/library/constants.html#None) +### get(*key:K,default: V|_DefaultT*)→ V|_DefaultT 获取具有默认值的元素。 * **参数:** - * **key** ([object](https://docs.python.org/3/library/functions.html#object)) – 属性键 - * **默认** ([object](https://docs.python.org/3/library/functions.html#object)) – 默认对象 + * **key** – 属性键 + * **默认** – 默认对象 * **返回:value** – 结果值 -* **返回类型:**[object](https://docs.python.org/3/library/functions.html#object) +* **返回类型:value** 结果值 ## *class* tvm.ir.BaseExpr 所有表达式的基类。 -## *class* tvm.ir.GlobalVar(*name_hint:*[str](https://docs.python.org/3/library/stdtypes.html#str), *type_annot:*[Type](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Type)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.ir.GlobalVar(*name_hint:*[str](https://docs.python.org/3/library/stdtypes.html#str), *type_annot:*[Type](/docs/api-reference/python-api/tvm-ir#class-tvmirprimtypedtype)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) IR 中的全局变量。 @@ -332,20 +367,20 @@ GlobalVar 用于引用存储在 IRModule 中的全局函数。 PrimExpr 用于低级代码优化和整数分析。 -## *class* tvm.ir.Range(*begin:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *end:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.ir.Range(*begin:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *end:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) 表示 TVM 中的范围。 您无需显式创建 Range。Python 列表和元组将在 API 函数中自动转换为 Range。 * **参数:** - * **begin** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)) – 当 end 为 None 时,为范围的起始值。否则,为范围的长度 - * **end** (*Optional[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*) – 范围的结束值 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*) – 此节点在源代码中的位置 + * **begin** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)) – 当 end 为 None 时,为范围的起始值。否则,为范围的长度 + * **end** (*Optional[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*) – 范围的结束值 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*) – 此节点在源代码中的位置 -:::Note +:::note 如果 `end` 参数不为 `None`,构造函数会创建范围 `[begin, end)`。否则,它会创建范围 `[0, begin)` @@ -354,21 +389,21 @@ PrimExpr 用于低级代码优化和整数分析。 方法: -|[from_min_extent](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Range.from_min_extent)(min_value, extent[, span])|通过最小值和范围构造一个 Range| +|[from_min_extent](/docs/api-reference/python-api/tvm-ir#static-from_min_extentmin_valueprimexpr-extentprimexpr-spanspannone-none--range)(min_value, extent[, span])|通过最小值和范围构造一个 Range| |:----|:----| -### *static* from_min_extent(*min_value:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *extent:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Range](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Range) +### *static* from_min_extent(*min_value:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *extent:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Range](/docs/api-reference/python-api/tvm-ir#class-tvmirrangebeginprimexpr-endprimexprnone-none-spanspannone-none) 通过最小值和范围构建范围。 这构建了一个范围 [min_value, min_value + extent)。 * **参数:** - * **min_value** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)) – 范围的最小值 - * **extent** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)) – 范围的范围 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*) – 此节点在源代码中的位置 + * **min_value** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)) – 范围的最小值 + * **extent** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)) – 范围的范围 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*) – 此节点在源代码中的位置 * **返回:rng** – 构建的范围 -* **返回类型:**[Range](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Range) +* **返回类型:**[Range](/docs/api-reference/python-api/tvm-ir#class-tvmirrangebeginprimexpr-endprimexprnone-none-spanspannone-none) ## *class* tvm.ir.RelaxExpr 所有非原始表达式的基类。 @@ -376,14 +411,14 @@ PrimExpr 用于低级代码优化和整数分析。 **属性:** -|[struct_info](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr.struct_info)|Get the struct info field获取结构信息字段| +|[struct_info](/docs/api-reference/python-api/tvm-ir#propertystruct_infostructinfonone)|Get the struct info field获取结构信息字段| |:----|:----| -### ***property*struct_info*:***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)***|***[None](https://docs.python.org/3/library/constants.html#None) +### ***property*struct_info*:***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)***|***[None](https://docs.python.org/3/library/constants.html#None) 获取结构体信息字段 * **返回:** struct_info – 如果可用,则为结构信息。 -* **返回类型:**[tvm.relax.StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo) +* **返回类型:**[tvm.relax.StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo) ## ***class*tvm.ir.BaseFunc** @@ -392,16 +427,16 @@ PrimExpr 用于低级代码优化和整数分析。 属性: -|[attrs](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.BaseFunc.attrs)|返回函数的 attrs 成员。| +|[attrs](/docs/api-reference/python-api/tvm-ir#propertyattrs)|返回函数的 attrs 成员。| |:----|:----| **方法:** -|[with_attr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.BaseFunc.with_attr)(attr_key_or_dict[, attr_value])|创建函数的新副本并更新属性。| +|[with_attr](/docs/api-reference/python-api/tvm-ir#with_attrattr_key_or_dictattr_valuenonebasefunc)(attr_key_or_dict[, attr_value])|创建函数的新副本并更新属性。| |:----|:----| -|[with_attrs](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.BaseFunc.with_attrs)(attr_map)|复制 IRModule 并将给定的属性映射添加到其中。| -|[without_attr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.BaseFunc.without_attr)(attr_key)|创建一个带有未提供键的属性的新函数副本。| +|[with_attrs](/docs/api-reference/python-api/tvm-ir#with_attrsattr_mapdictattrsdictstrobjectbasefunc)(attr_map)|复制 IRModule 并将给定的属性映射添加到其中。| +|[without_attr]()(attr_key)|创建一个带有未提供键的属性的新函数副本。| ### ***property*attrs** @@ -409,22 +444,28 @@ PrimExpr 用于低级代码优化和整数分析。 返回函数的 attrs 成员。 -### **with_attr(*attr_key_or_dict*,*attr_value=None*)→**[BaseFunc](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.BaseFunc) +### **with_attr(*attr_key_or_dict*,*attr_value=None*)→**[BaseFunc](/docs/api-reference/python-api/tvm-ir#classtvmirbasefunc) 创建函数的新副本并更新属性。 * **参数:** * attr_key_or_dict (Union[str, dict]) – 用于指定属性键或包含多个键值对字典。 * attr_value (对象) –- 新的属性值。 * **返回:** func – 函数的新副本 -* **返回类型:** [BaseFunc](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.BaseFunc) +* **返回类型:** [BaseFunc](/docs/api-reference/python-api/tvm-ir#classtvmirbasefunc) -### **with_attrs(*attr_map:***[DictAttrs](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.DictAttrs)***|***[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)***[***[str](https://docs.python.org/3/library/stdtypes.html#str)***, Object]*)→**[BaseFunc](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.BaseFunc) +### **with_attrs(*attr_map:***[DictAttrs](/docs/api-reference/python-api/tvm-ir#class-tvmirdictattrs)***|***[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)***[***[str](https://docs.python.org/3/library/stdtypes.html#str)***, Object]*)→**[BaseFunc](/docs/api-reference/python-api/tvm-ir#classtvmirbasefunc) 复制 IRModule 并添加给定的属性映射到它。 :param attr_map: 属性映射 :type attr_map: Union[DictAttrs, Dict[str, Object]] +* **返回:** func – 函数的新副本 +* **返回类型:** [BaseFunc](/docs/api-reference/python-api/tvm-ir#classtvmirbasefunc) + +### **without_attr(*attr_key:***[str](https://docs.python.org/3/library/stdtypes.html#str)***)→**[BaseFunc](/docs/api-reference/python-api/tvm-ir#classtvmirbasefunc) + +创建函数的新副本,其中包含一个没有提供键的属性。 * **参数:** attr_key (str) – 要从属性对中删除的属性键。 * **返回:** func – 函数的新副本 -* **返回类型:** [BaseFunc](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.BaseFunc) +* **返回类型:** [BaseFunc](/docs/api-reference/python-api/tvm-ir#classtvmirbasefunc) ## *class* tvm.ir.CallingConv(*value*) @@ -437,7 +478,7 @@ PrimExpr 用于低级代码优化和整数分析。 **方法:** -|[same_as](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalInfo.same_as)(其他)|使用结构等式重载。| +|[same_as](/docs/api-reference/python-api/tvm-ir#same_asother)(其他)|使用结构等式重载。| |:----|:----| ### **same_as(*other*)** @@ -461,60 +502,60 @@ IRModule 是整个堆栈中所有 IR 转换的基本单元。 **方法:** -|[functions_items](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule.functions_items)()|按字母顺序获取 self.functions.items() 中的项。| +|[functions_items](/docs/api-reference/python-api/tvm-ir#functions_items)()|按字母顺序获取 self.functions.items() 中的项。| |:----|:----| -|[update](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule.update)(other)   **update** (其他)|将其他模块中的函数插入当前模块。| -|[update_func](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule.update_func)(var, func)   **update_func** (变量, 函数)|更新模块中对应全局变量的函数。| -|[update_global_info](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule.update_global_info)(name, global_info)|更新模块中的全局信息。| -|[get_global_var](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule.get_global_var)(name)   **get_global_var** (名称)|通过名称在函数中获取一个全局变量。| -|[get_global_vars](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule.get_global_vars)()|收集在此模块中定义的所有全局变量。| -|[replace_global_vars](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule.replace_global_vars)(replacements)   **replace_global_vars** (替换)|替换模块中的 GlobalVar 实例。| -|[from_expr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule.from_expr)(expr[, functions])|从一个独立的表达式中构建一个模块。| -|[get_attr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule.get_attr)(attr_key)|获取 IRModule 属性。| -|[with_attr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule.with_attr)(attr_key, attr_value)|复制 IRModule 并为其添加一个属性。| -|[without_attr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule.without_attr)(attr_key)|复制 IRModule 并删除一个属性键及其关联的值。| -|[with_attrs](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule.with_attrs)(attr_map)|复制 IRModule 并将给定的属性映射添加到其中。| +|[update](/docs/api-reference/python-api/tvm-ir#updateother)(other)   **update** (其他)|将其他模块中的函数插入当前模块。| +|[update_func](/docs/api-reference/python-api/tvm-ir#update_funcvar-func)(var, func)   **update_func** (变量, 函数)|更新模块中对应全局变量的函数。| +|[update_global_info](/docs/api-reference/python-api/tvm-ir#update_global_infoname-global_info)(name, global_info)|更新模块中的全局信息。| +|[get_global_var](/docs/api-reference/python-api/tvm-ir#get_global_varname)(name)   **get_global_var** (名称)|通过名称在函数中获取一个全局变量。| +|[get_global_vars](/docs/api-reference/python-api/tvm-ir#get_global_vars)()|收集在此模块中定义的所有全局变量。| +|[replace_global_vars](/docs/api-reference/python-api/tvm-ir#replace_global_varsreplacementsdictstrglobalvarstrglobalvar--irmodule)(replacements)   **replace_global_vars** (替换)|替换模块中的 GlobalVar 实例。| +|[from_expr](/docs/api-reference/python-api/tvm-ir#static-from_exprexpr-functionsnone)(expr[, functions])|从一个独立的表达式中构建一个模块。| +|[get_attr](/docs/api-reference/python-api/tvm-ir#get_attrattr_key)(attr_key)|获取 IRModule 属性。| +|[with_attr](/docs/api-reference/python-api/tvm-ir#with_attrattr_key-attr_value)(attr_key, attr_value)|复制 IRModule 并为其添加一个属性。| +|[without_attr](/docs/api-reference/python-api/tvm-ir#without_attrattr_keystr--irmodule)(attr_key)|复制 IRModule 并删除一个属性键及其关联的值。| +|[with_attrs](/docs/api-reference/python-api/tvm-ir#with_attrsattr_mapdictattrsdictstr-object--irmodule)(attr_map)|复制 IRModule 并将给定的属性映射添加到其中。| ### **functions_items()** 按字母顺序获取 self.functions.items() 中的项。 * **返回:** items – items 函数。 -* **返回类型:** List[[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)[[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar), [Function](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Function)]] +* **返回类型:** List[[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)[[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none), [Function](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfunctionparamslistvarbodyrelaxexprret_struct_infostructinfononenoneis_pureboolnonetrueattrsdictattrsnonenonespanspannonenone)]] ### update(*other*) 将另一个模块中的函数插入当前模块。 -* **参数:other** ([IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)) – 要合并到当前模块的模块 +* **参数:other** ([IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)) – 要合并到当前模块的模块 ### update_func(*var*, *func*) 更新模块中某个全局变量对应的函数。 * **参数:** - * **var** ([GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar)) – 全局变量 - * **func** ([tvm.ir.BaseFunc](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.BaseFunc)) – 要插入的函数 + * **var** ([GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none)) – 全局变量 + * **func** ([tvm.ir.BaseFunc](/docs/api-reference/python-api/tvm-ir#classtvmirbasefunc)) – 要插入的函数 ### update_global_info(*name*, *global_info*) 更新模块中的全局信息。 * **参数:** * **name** ([str](https://docs.python.org/3/library/stdtypes.html#str)) – 全局信息的名称 - * **global_info** (*List[*[GlobalInfo](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalInfo)*]*) – 需要更新的全局信息 + * **global_info** (*List[*[GlobalInfo](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalinfo)*]*) – 需要更新的全局信息 ### get_global_var(*name*) 通过名称获取函数中的全局变量。 * **参数:name** ([str](https://docs.python.org/3/library/stdtypes.html#str)) – 全局变量的名称 * **返回:global_var** – 映射到的全局变量`name` -* **返回类型:**[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar) +* **返回类型:**[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none) * **抛出:tvm.error.TVMError 找不到相应的全局变量时抛出。** ### get_global_vars() 收集此模块中定义的所有全局变量。 * **返回:global_vars** – 全局变量数组 -* **返回类型:**[Array](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Array)[[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar)] +* **返回类型:**[Array](/docs/api-reference/python-api/tvm-ir#class-tvmirarrayinput_listsequenceany)[[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none)] -## replace_global_vars(*replacements:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar)*]*) → [IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule) +## replace_global_vars(*replacements:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none)*]*) → [IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone) 替换模块内的 GlobalVar 实例。 @@ -523,13 +564,13 @@ IRModule 是整个堆栈中所有 IR 转换的基本单元。 * **参数:** * **replacements** (*Dict[Union[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,_ expr.GlobalVar],_ *Union[[str](https://docs.python.org/3/library/stdtypes.html#str),_ expr.GlobalVar]_*]*) – 一个字典,其中每个键都是一个要替换的 GlobalVar,相应的值是用来替换它的 GlobalVar * **返回:** 更新后的模块 -* **返回类型:**[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule) +* **返回类型:**[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone) ### *static* from_expr(*expr*, *functions=None*) 从独立表达式构建模块。 * **参数:** - * **expr** ([RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) – 起始表达式 + * **expr** ([RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) – 起始表达式 * **global_funcs** (*Optional[*[dict](https://docs.python.org/3/library/stdtypes.html#dict)*]*) – 全局变量到函数定义的映射 * **返回:mod** – 包含传递的定义的模块,其中 expr 被设置为入口点(如果需要,可以包装在函数中) * **返回类型:** Module @@ -548,19 +589,19 @@ IRModule 是整个堆栈中所有 IR 转换的基本单元。 * **attr_key** ([str](https://docs.python.org/3/library/stdtypes.html#str)) – 属性键 * **attr_value** (*Object*) – 新的属性值 * **返回:mod** – 具有属性的 IRModule 的新拷贝 -* **返回类型:**[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule) +* **返回类型:**[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone) -### without_attr(*attr_key:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule) +### without_attr(*attr_key:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnonee) 复制 IRModule 并删除属性键及其关联值。:param attr_key: 属性键。:type attr_key: str * **返回:mod** – 没有属性的 IRModule 的新拷贝 -* **返回类型:**[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule) +* **返回类型:**[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone) -### with_attrs(*attr_map:*[DictAttrs](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.DictAttrs)*|*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*, Object]*) → [IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule) +### with_attrs(*attr_map:*[DictAttrs](/docs/api-reference/python-api/tvm-ir#class-tvmirdictattrs)*|*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*, Object]*) → [IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone) 复制 IRModule 并将给定的属性映射添加到其中。:param attr_map:属性映射:type attr_map:Union[DictAttrs, Dict[str, Object]] * **返回:mod** – 具有属性的 IRModule 的新拷贝 -* **返回类型:**[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule) +* **返回类型:**[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone) ## *class* tvm.ir.Op @@ -569,23 +610,23 @@ IR 中的原始运算符。 **方法:** -|[get](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Op.get)(op_name)|获取给定名称的 Op。| +|[get](/docs/api-reference/python-api/tvm-ir#static-getop_name)(op_name)|获取给定名称的 Op。| |:----|:----| -|[get_attr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Op.get_attr)(attr_name)|获取有关操作员的附加属性。| -|[has_attr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Op.has_attr)(attr_name)|检查操作员是否具有附加属性。| -|[set_attr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Op.set_attr)(attr_name, value[, plevel])|设置有关操作员的属性。| -|[reset_attr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Op.reset_attr)(attr_name)|重置有关操作员的属性。| -|[add_argument](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Op.add_argument)(name, type, description)|向函数添加参数信息。| -|[set_support_level](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Op.set_support_level)(level)|设置op的支持级别。| -|[set_num_inputs](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Op.set_num_inputs)(n)|设置op的支持级别。| -|[set_attrs_type_key](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Op.set_attrs_type_key)(key)|设置op的属性类型键。| -|[list_op_names](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Op.list_op_names)()|列出 op 注册表中的所有 op 名称。| +|[get_attr](/docs/api-reference/python-api/tvm-ir#get_attrattr_name)(attr_name)|获取有关操作员的附加属性。| +|[has_attr](/docs/api-reference/python-api/tvm-ir#has_attrattr_name)(attr_name)|检查操作员是否具有附加属性。| +|[set_attr](/docs/api-reference/python-api/tvm-ir#set_attrattr_name-value-plevel10)(attr_name, value[, plevel])|设置有关操作员的属性。| +|[reset_attr](/docs/api-reference/python-api/tvm-ir#reset_attrattr_name)(attr_name)|重置有关操作员的属性。| +|[add_argument](/docs/api-reference/python-api/tvm-ir#add_argumentname-type-description)(name, type, description)|向函数添加参数信息。| +|[set_support_level](/docs/api-reference/python-api/tvm-ir#set_support_levellevel)(level)|设置op的支持级别。| +|[set_num_inputs](/docs/api-reference/python-api/tvm-ir#set_num_inputsn)(n)|设置op的支持级别。| +|[set_attrs_type_key](/docs/api-reference/python-api/tvm-ir#set_attrs_type_keykey)(key)|设置op的属性类型键。| +|[list_op_names](/docs/api-reference/python-api/tvm-ir#static-list_op_names)()|列出 op 注册表中的所有 op 名称。| ### *static* get(*op_name*) 获取给定名称的 Op。 * **参数:op_name** ([str](https://docs.python.org/3/library/stdtypes.html#str)) – 操作名称 * **返回:op** – 对应名称的 op -* **返回类型:**[Op](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Op) +* **返回类型:**[Op](/docs/api-reference/python-api/tvm-ir#class-tvmirop) ### get_attr(*attr_name*) @@ -671,14 +712,14 @@ IR 中的原始运算符。 一个函数类型由以下部分组成:一组类型参数,用于定义泛型函数;一组类型约束(暂时省略);一系列参数类型;以及返回类型。 * **参数:** - * **arg_types** (*List[*[tvm.ir.Type](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Type)*]*) – 参数类型 - * **ret_type** ([tvm.ir.Type](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Type)) – 返回类型 + * **arg_types** (*List[*[tvm.ir.Type](/docs/api-reference/python-api/tvm-ir#class-tvmirtype)*]*) – 参数类型 + * **ret_type** ([tvm.ir.Type](/docs/api-reference/python-api/tvm-ir#class-tvmirtype)) – 返回类型 ## *class* tvm.ir.PointerType(*element_type*, *storage_scope=''*) 低级 TIR 中使用的 PointerType。 * **参数:** - * **element_type** ([tvm.ir.Type](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Type)) – 指针元素的类型 + * **element_type** ([tvm.ir.Type](/docs/api-reference/python-api/tvm-ir#class-tvmirtype)) – 指针元素的类型 * **storage_scope** ([str](https://docs.python.org/3/library/stdtypes.html#str)) – 指针寻址的存储范围 ## *class* tvm.ir.PrimType(*dtype*) @@ -689,7 +730,7 @@ IR 中的原始运算符。 ## *class* tvm.ir.TupleType(*fields*) 元组值的类型。 -* **参数:fields** (*List[*[Type](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Type)*]*) – 元组中的字段 +* **参数:fields** (*List[*[Type](/docs/api-reference/python-api/tvm-ir#class-tvmirtype)*]*) – 元组中的字段 ## *class* tvm.ir.Type @@ -698,7 +739,7 @@ IR 中的原始运算符。 **方法:** -|[same_as](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Type.same_as)(other)|通过引用相等性比较两种 TVM 类型| +|[same_as](/docs/api-reference/python-api/tvm-ir#same_asother-1)(other)|通过引用相等性比较两种 TVM 类型| |:----|:----| ### same_as(*other*) diff --git a/docs/04-api-reference/01-python-api/03-tvm-instrument.md b/docs/04-api-reference/01-python-api/03-tvm-instrument.md index caa365d..2477187 100644 --- a/docs/04-api-reference/01-python-api/03-tvm-instrument.md +++ b/docs/04-api-reference/01-python-api/03-tvm-instrument.md @@ -35,8 +35,8 @@ pass 工具的实现。 当检测上下文处于活动状态时,每次运行都会调用一次。 * **参数:** - * **mod** ([tvm.ir.module.IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)) – 正在运行优化过程的模块。 - * **info** ([tvm.transform.PassInfo](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.PassInfo)) – Pass 信息。 + * **mod** ([tvm.ir.module.IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)) – 正在运行优化过程的模块。 + * **info** ([tvm.transform.PassInfo](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpassinfoopt_level-name-requirednone-traceablefalse)) – Pass 信息。 * **返回:should_run** – True 表示运行 pass ,False 表示跳过 pass 。 * **返回类型:**[bool](https://docs.python.org/3/library/functions.html#bool)。 @@ -48,8 +48,8 @@ pass 运行前的工具。 当检测上下文处于活动状态时,每次运行 pass 都会调用一次。 * **参数:** - * **mod** ([tvm.ir.module.IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)) – 正在运行优化过程的模块。 - * **info** ([tvm.transform.PassInfo](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.PassInfo)) – Pass 信息。 + * **mod** ([tvm.ir.module.IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)) – 正在运行优化过程的模块。 + * **info** ([tvm.transform.PassInfo](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpassinfoopt_level-name-requirednone-traceablefalse)) – Pass 信息。 * **返回类型:** 无。 ### run_after_pass(*mod*, info) @@ -60,8 +60,8 @@ pass 后的工具运行。 当检测上下文处于活动状态时,每次运行都会调用一次。 * **参数:** - * **mod** ([tvm.ir.module.IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)) – 正在运行优化过程的模块。 - * **info** ([tvm.transform.PassInfo](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.PassInfo)) – [ Pass ](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.PassInfo)信息。 + * **mod** ([tvm.ir.module.IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)) – 正在运行优化过程的模块。 + * **info** ([tvm.transform.PassInfo](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpassinfoopt_level-name-requirednone-traceablefalse)) – Pass信息。 * **返回类型:** 无。 ## *class* tvm.instrument.PassPrintingInstrument(*print_before_pass_names*, *print_after_pass_names*) diff --git a/docs/04-api-reference/01-python-api/04-tvm-transform.md b/docs/04-api-reference/01-python-api/04-tvm-transform.md index d1499d2..48d8a39 100644 --- a/docs/04-api-reference/01-python-api/04-tvm-transform.md +++ b/docs/04-api-reference/01-python-api/04-tvm-transform.md @@ -9,18 +9,18 @@ title: tvm.transform 跨 IR 变体的通用基础设施。 -## tvm.transform.ApplyPassToFunction(*transform:*[Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass), *func_name_regex:*[str](https://docs.python.org/3/library/stdtypes.html#str), *error_if_no_function_matches_regex:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.transform.ApplyPassToFunction(*transform:*[Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass), *func_name_regex:*[str](https://docs.python.org/3/library/stdtypes.html#str), *error_if_no_function_matches_regex:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 将 pass 应用于 IRModule 中特定函数的实用工具。 TVM 在降阶的所有阶段都使用 IRModule 到 IRModule 的转换。这些转换在手动编写优化模型或对 IRModule 中的特定内核进行优化时非常有用。此实用工具允许将 pass 应用于指定函数,而不改变模块中的其他函数。 * **参数:** - * **transform**([Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)) – 要应用的 IRModule 到 IRModule pass。 + * **transform**([Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)) – 要应用的 IRModule 到 IRModule pass。 * **func_name_regex** ([str](https://docs.python.org/3/library/stdtypes.html#str)) – 用于选择要更新函数的正则表达式。pass 将应用于所有名称匹配该正则表达式的函数。 * **error_if_no_function_matches_regex** ([bool](https://docs.python.org/3/library/functions.html#bool)) – 指定当 IRModule 不包含任何匹配正则表达式的函数时的行为。如果为 true,将引发错误;如果为 false(默认值),则返回未修改的 IRModule。 * **返回: new_transform** – 修改后的 IRModule 到 IRModule pass。 -* **返回类型:** [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:** [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## *class* tvm.transform.ModulePass @@ -119,7 +119,7 @@ pass 检测工具的实现列表。 注意用户也可以提供一系列在运行顺序 pass 时不希望应用的 pass。pass 依赖关系也将在后端解析。 * **参数:** - * **passes** (_Optional**[**List[_[_Pass_](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)]]) – 待优化的 pass 候选序列。 + * **passes** (_Optional**[**List[_[_Pass_](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)]]) – 待优化的 pass 候选序列。 * **opt_level** (_Optional[_[_int_](https://docs.python.org/3/library/functions.html#int)_]_) – 此顺序 pass 的优化级别。默认顺序 pass 的 opt_level 设置为 0。注意如果 Sequantial 中某些 pass 的 opt_level 高于提供的 opt_level,它们可能仍不会被执行。 * **name** (_Optional[_[_str_](https://docs.python.org/3/library/stdtypes.html#str)_]_) – 顺序 pass 的名称。 * **required** (_Optional**[**List[_[_str_](https://docs.python.org/3/library/stdtypes.html#str)]]) – 顺序 pass 所依赖的 pass 列表。 @@ -133,13 +133,13 @@ pass 检测工具的实现列表。 pass_func 也可以是具有 transform_module 方法的类类型。此函数将使用 transform_module 作为 pass 函数创建装饰后的 ModulePass。 * **参数:** - * **pass_func** (_Optional**[**Callable**[**(**Module**,_ [_PassContext_](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.PassContext)_)_ _->Module**]**]_) – 转换函数或类。 + * **pass_func** (_Optional**[**Callable**[**(**Module**,_ [_PassContext_](/docs/api-reference/python-api/tvm-transform#classtvmtransformpasscontextopt_level2required_passnonedisabled_passnoneinstrumentsnoneconfignone)_)_ _->Module**]**]_) – 转换函数或类。 * **opt_level** ([_int_](https://docs.python.org/3/library/functions.html#int)) – 此模块 pass 的优化级别。 * **name** (_Optional[_[_str_](https://docs.python.org/3/library/stdtypes.html#str)_]_) – 模块 pass 名称。名称可为空,此时将使用优化函数的名称作为 pass 名称。 * **required** (_Optional**[**List[_[_str_](https://docs.python.org/3/library/stdtypes.html#str)]]) – 模块 pass 所依赖的 pass 列表。 * **traceable** (_Boolean_) – 模块 pass 是否可跟踪的布尔值。 * **返回:** **create_module_pass** – 如果未提供 pass_func 则返回装饰器,否则返回装饰后的结果。返回的装饰器根据输入有两种行为:当装饰 pass 函数时返回新的 ModulePass;当装饰类类型时返回新的 ModulePass 类。 -* **返回类型:** Union[Callable, [ModulePass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.ModulePass)]。 +* **返回类型:** Union[Callable, [ModulePass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformmodulepass)]。 **示例** diff --git a/docs/04-api-reference/01-python-api/05-tvm-target.md b/docs/04-api-reference/01-python-api/05-tvm-target.md index 9372f97..0d1009c 100644 --- a/docs/04-api-reference/01-python-api/05-tvm-target.md +++ b/docs/04-api-reference/01-python-api/05-tvm-target.md @@ -11,7 +11,7 @@ title: tvm.target TVM 的目标字符串格式为。` [-option=value]...`。 -:::Note +:::note 选项列表包括: * **-device=** @@ -27,29 +27,29 @@ TVM 的目标字符串格式为。` [-option=value]...`。 **类:** -|[Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target)(target[, host])|目标设备信息,通过TVM API使用。| +|[Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone)(target[, host])|目标设备信息,通过TVM API使用。| |:----|:----| -|[TargetKind](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.TargetKind)|一种编译目标。| -|[VirtualDevice](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.VirtualDevice)([device, target, memory_scope])|编译时表示数据在运行时的存储位置以及如何编译代码来计算它。| +|[TargetKind](/docs/api-reference/python-api/tvm-target#class-tvmtargettargetkind)|一种编译目标。| +|[VirtualDevice](/docs/api-reference/python-api/tvm-target#classtvmtargetvirtualdevicedevicenonetargetnonememory_scope)([device, target, memory_scope])|编译时表示数据在运行时的存储位置以及如何编译代码来计算它。| **函数:** -|[create](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.create)(target)|已弃用。| +|[create](/docs/api-reference/python-api/tvm-target#tvmtargetcreatetarget)(target)|已弃用。| |:----|:----| -|[cuda](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.cuda)([model, arch, options])|返回一个 cuda 目标。| -|[rocm](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.rocm)([model, options])|返回 ROCM 目标。| -|[mali](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.mali)([model, options])|返回 ARM Mali GPU 目标。| -|[intel_graphics](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.intel_graphics)([model, options])|返回 Intel Graphics 目标。| -|[arm_cpu](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.arm_cpu)([model, options])|返回 ARM CPU 目标。| -|[rasp](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.rasp)([options])|返回 Raspberry 3b 目标。| -|[bifrost](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.bifrost)([model, options])|返回 ARM Mali GPU 目标(Bifrost 架构)。| -|[riscv_cpu](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.riscv_cpu)([model, options])|返回 RISC-V CPU 目标。| -|[hexagon](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.hexagon)([cpu_ver])|返回 Hexagon 目标。| -|[stm32](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.stm32)([series, options])|返回 STM32 目标。| -|[adreno](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.adreno)([model, options, clml])|返回 Qualcomm GPU 目标。| -|[make_compilation_config](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.make_compilation_config)(ctxt, target[, …])|返回适用于 target 和 target_host 的 CompilationConfig,使用与标准构建接口相同的表示约定。| -|[list_tags](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.list_tags)()|返回标签字典,将每个标签名称映射到其对应的目标。| +|[cuda](/docs/api-reference/python-api/tvm-target#tvmtargetcudamodelunknown-archnone-optionsnone)([model, arch, options])|返回一个 cuda 目标。| +|[rocm](/docs/api-reference/python-api/tvm-target#tvmtargetrocmmodelunknown-optionsnone)([model, options])|返回 ROCM 目标。| +|[mali](/docs/api-reference/python-api/tvm-target#tvmtargetmalimodelunknown-optionsnone)([model, options])|返回 ARM Mali GPU 目标。| +|[intel_graphics](/docs/api-reference/python-api/tvm-target#tvmtargetintel_graphicsmodelunknown-optionsnone)([model, options])|返回 Intel Graphics 目标。| +|[arm_cpu](/docs/api-reference/python-api/tvm-target#tvmtargetarm_cpumodelunknown-optionsnone)([model, options])|返回 ARM CPU 目标。| +|[rasp](/docs/api-reference/python-api/tvm-target#tvmtargetraspoptionsnone)([options])|返回 Raspberry 3b 目标。| +|[bifrost](/docs/api-reference/python-api/tvm-target#tvmtargetbifrostmodelunknown-optionsnone)([model, options])|返回 ARM Mali GPU 目标(Bifrost 架构)。| +|[riscv_cpu](/docs/api-reference/python-api/tvm-target#tvmtargetriscv_cpumodelsifive-u54-optionsnone)([model, options])|返回 RISC-V CPU 目标。| +|[hexagon](/docs/api-reference/python-api/tvm-target#tvmtargethexagoncpu_verv68-kwargs)([cpu_ver])|返回 Hexagon 目标。| +|[stm32](/docs/api-reference/python-api/tvm-target#tvmtargetstm32seriesunknown-optionsnone)([series, options])|返回 STM32 目标。| +|[adreno](/docs/api-reference/python-api/tvm-target#tvmtargetadrenomodelunknown-optionsnone-clmlfalse)([model, options, clml])|返回 Qualcomm GPU 目标。| +|[make_compilation_config](/docs/api-reference/python-api/tvm-target#tvmtargetmake_compilation_configctxttargettarget_hostnone)(ctxt, target[, …])|返回适用于 target 和 target_host 的 CompilationConfig,使用与标准构建接口相同的表示约定。| +|[list_tags](/docs/api-reference/python-api/tvm-target#tvmtargetlist_tagsdictstrtargetnone)()|返回标签字典,将每个标签名称映射到其对应的目标。| ## *class* tvm.target.Target(*target*, *host=None*) @@ -57,7 +57,7 @@ TVM 的目标字符串格式为。` [-option=value]...`。 目标设备信息,通过 TVM API 使用。 -:::Note +:::note 您可以使用构造函数或以下函数创建目标: * `tvm.target.arm_cpu()`创建 arm_cpu 目标。 @@ -71,39 +71,39 @@ TVM 的目标字符串格式为。` [-option=value]...`。 **方法:** -|[from_device](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target.from_device)(device)|检测与给定设备关联的目标。| +|[from_device](/docs/api-reference/python-api/tvm-target#static-from_devicedevicestr-device--target)(device)|检测与给定设备关联的目标。| |:----|:----| -|[current](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target.current)([allow_none])|返回当前目标。| -|[get_kind_attr](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target.get_kind_attr)(attr_name)|获取有关目标类型的附加属性。| -|[get_target_device_type](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target.get_target_device_type)()|返回此目标的设备类型。| -|[list_kinds](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target.list_kinds)()|返回可用目标名称的列表。| -|[canon_target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target.canon_target)(target)|给定一个类似目标的对象,返回代表它的 TVM Target 对象。| -|[canon_target_and_host](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target.canon_target_and_host)(target[, target_host])|返回一个 TVM Target,用于表示 target 和 target_host。| -|[canon_multi_target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target.canon_multi_target)(multi_targets)|给定一个类似目标的对象,或者类似目标对象的类似集合的对象,返回代表该对象的 TVM 目标对象的 TVM 数组。| -|[canon_multi_target_and_host](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target.canon_multi_target_and_host)(target[, …])|返回一个 TVM Array,用于表示 target 和 target_host。| -|[canon_target_map_and_host](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target.canon_target_map_and_host)(target_map[, …])|将 target_map 作为从 TVM Target 的规范形式到 IRModules 的映射返回。| -|[target_or_current](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target.target_or_current)(target)|返回目标,如果目标为 None,则返回环境中的当前目标。| +|[current](/docs/api-reference/python-api/tvm-target#static-currentallow_nonetrue)([allow_none])|返回当前目标。| +|[get_kind_attr](/docs/api-reference/python-api/tvm-target#get_kind_attrattr_name)(attr_name)|获取有关目标类型的附加属性。| +|[get_target_device_type](/docs/api-reference/python-api/tvm-target#get_target_device_type)()|返回此目标的设备类型。| +|[list_kinds](/docs/api-reference/python-api/tvm-target#static-list_kinds)()|返回可用目标名称的列表。| +|[canon_target](/docs/api-reference/python-api/tvm-target#static-canon_targettarget)(target)|给定一个类似目标的对象,返回代表它的 TVM Target 对象。| +|[canon_target_and_host](/docs/api-reference/python-api/tvm-target#static-canon_target_and_hosttarget-target_hostnone)(target[, target_host])|返回一个 TVM Target,用于表示 target 和 target_host。| +|[canon_multi_target](/docs/api-reference/python-api/tvm-target#static-canon_multi_targetmulti_targets)(multi_targets)|给定一个类似目标的对象,或者类似目标对象的类似集合的对象,返回代表该对象的 TVM 目标对象的 TVM 数组。| +|[canon_multi_target_and_host](/docs/api-reference/python-api/tvm-target#static-canon_multi_target_and_hosttarget-target_hostnone)(target[, …])|返回一个 TVM Array,用于表示 target 和 target_host。| +|[canon_target_map_and_host](/docs/api-reference/python-api/tvm-target#static-canon_target_map_and_hosttarget_map-target_hostnone)(target_map[, …])|将 target_map 作为从 TVM Target 的规范形式到 IRModules 的映射返回。| +|[target_or_current](/docs/api-reference/python-api/tvm-target#static-target_or_currenttarget)(target)|返回目标,如果目标为 None,则返回环境中的当前目标。| **属性:** -|[arch](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target.arch)|如果存在,则返回目标的 cuda arch。| +|[arch](/docs/api-reference/python-api/tvm-target#property-arch)|如果存在,则返回目标的 cuda arch。| |:----|:----| -|[max_num_threads](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target.max_num_threads)|如果存在,则返回目标的 max_num_threads。| -|[max_block_size_x](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target.max_block_size_x)|如果存在,则返回目标 x 维度上的最大块大小。| -|[max_block_size_y](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target.max_block_size_y)|如果存在,则返回目标 y 维度上的最大块大小。| -|[thread_warp_size](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target.thread_warp_size)|如果存在,则返回目标的thread_warp_size。| -|[model](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target.model)|如果存在,则返回目标模型。| -|[mcpu](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target.mcpu)|如果存在,则返回目标的 mcpu。| -|[mattr](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target.mattr)|如果存在,则返回目标的 mattr。| +|[max_num_threads](/docs/api-reference/python-api/tvm-target#property-max_num_threads)|如果存在,则返回目标的 max_num_threads。| +|[max_block_size_x](/docs/api-reference/python-api/tvm-target#property-max_block_size_x)|如果存在,则返回目标 x 维度上的最大块大小。| +|[max_block_size_y](/docs/api-reference/python-api/tvm-target#property-max_block_size_y)|如果存在,则返回目标 y 维度上的最大块大小。| +|[thread_warp_size]()|如果存在,则返回目标的thread_warp_size。| +|[model](/docs/api-reference/python-api/tvm-target#property-model)|如果存在,则返回目标模型。| +|[mcpu](/docs/api-reference/python-api/tvm-target#property-mcpu)|如果存在,则返回目标的 mcpu。| +|[mattr](/docs/api-reference/python-api/tvm-target#property-mattr)|如果存在,则返回目标的 mattr。| -### *static* from_device(*device:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| Device*) → [Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target) +### *static* from_device(*device:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| Device*) → [Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone) 检测与指定设备关联的目标。如果设备不存在,则会引发错误。 * **参数:dev** (*Union**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,*** ***Device****]*) – 用于检测目标的设备。支持的设备类型:[“cuda”, “metal”, “rocm”, “vulkan”, “opencl”, “cpu”]。 * **返回:target** – 检测到的目标。 -* **返回类型:**[Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target)。 +* **返回类型:**[Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnonet)。 ### *static* current(*allow_none=True*) @@ -214,13 +214,13 @@ TVM 的目标字符串格式为。` [-option=value]...`。 **属性:** -|[options](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.TargetKind.options)|返回可用选项名称和类型的字典。| +|[options](/docs/api-reference/python-api/tvm-target#property-options)|返回可用选项名称和类型的字典。| |:----|:----| **方法:** -|[options_from_name](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.TargetKind.options_from_name)(kind_name)|从 TargetKind 名称返回可用选项名称和类型的字典。| +|[options_from_name](/docs/api-reference/python-api/tvm-target#static-options_from_namekind_namestr)(kind_name)|从 TargetKind 名称返回可用选项名称和类型的字典。| |:----|:----| ### *property* options @@ -246,7 +246,7 @@ TVM 的目标字符串格式为。` [-option=value]...`。 返回 ROCM 目标。 * **参数:** * **model** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :该设备的型号。 - * **options** ([str](https://docs.python.org/3/library/stdtypes.html#str) *或*[str](https://docs.python.org/3/library/stdtypes.html#str)*列表*) :附加[选项](https://docs.python.org/3/library/stdtypes.html#str)。 + * **options** ([str](https://docs.python.org/3/library/stdtypes.html#str) *或*[str](https://docs.python.org/3/library/stdtypes.html#str)*[列表](https://docs.python.org/3/library/stdtypes.html#list)*) :附加选项。 ## tvm.target.mali(*model='unknown'*, *options=None*) @@ -254,7 +254,7 @@ TVM 的目标字符串格式为。` [-option=value]...`。 返回 ARM Mali GPU 目标。 * **参数:** * **model** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :该设备的型号。 - * **options** ([str](https://docs.python.org/3/library/stdtypes.html#str) *或*[str](https://docs.python.org/3/library/stdtypes.html#str)*列表*) :附加[选项](https://docs.python.org/3/library/stdtypes.html#str)。 + * **options** ([str](https://docs.python.org/3/library/stdtypes.html#str) *或*[str](https://docs.python.org/3/library/stdtypes.html#str)*[列表](https://docs.python.org/3/library/stdtypes.html#list)*) :附加选项。 ## tvm.target.intel_graphics(*model='unknown'*, *options=None*) @@ -262,7 +262,7 @@ TVM 的目标字符串格式为。` [-option=value]...`。 返回 Intel Graphics 目标。 * **参数:** * **model** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :该设备的型号。 - * **options** ([str](https://docs.python.org/3/library/stdtypes.html#str) *或*[str](https://docs.python.org/3/library/stdtypes.html#str)*列表*) :附加[选项](https://docs.python.org/3/library/stdtypes.html#str)。 + * **options** ([str](https://docs.python.org/3/library/stdtypes.html#str) *或*[str](https://docs.python.org/3/library/stdtypes.html#str)*[列表](https://docs.python.org/3/library/stdtypes.html#list)*) :附加选项。 ## tvm.target.arm_cpu(*model='unknown'*, *options=None*) @@ -270,19 +270,19 @@ TVM 的目标字符串格式为。` [-option=value]...`。 返回 ARM CPU 目标。若没有预调操作参数,此函数也会下载。 * **参数:** * **model** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :arm 板的 SoC 名称或电话名称。 - * **options** ([str](https://docs.python.org/3/library/stdtypes.html#str) *或*[str](https://docs.python.org/3/library/stdtypes.html#str)*列表*) :附加[选项](https://docs.python.org/3/library/stdtypes.html#str)。 + * **options** ([str](https://docs.python.org/3/library/stdtypes.html#str) *或*[str](https://docs.python.org/3/library/stdtypes.html#str)*[列表](https://docs.python.org/3/library/stdtypes.html#list)*) :附加选项。 ## tvm.target.rasp(*options=None*) 返回 Raspberry 3b 目标。 -* **参数:options** ([str](https://docs.python.org/3/library/stdtypes.html#str) *或*[str](https://docs.python.org/3/library/stdtypes.html#str)*列表*) :附加[选项](https://docs.python.org/3/library/stdtypes.html#str)。 +* **参数:options** ([str](https://docs.python.org/3/library/stdtypes.html#str) *或*[str](https://docs.python.org/3/library/stdtypes.html#str)*[列表](https://docs.python.org/3/library/stdtypes.html#list)*) :附加选项。 ## tvm.target.bifrost(*model='unknown'*, *options=None*) 返回 ARM Mali GPU 目标(Bifrost 架构)。 -* **参数:options** ([str](https://docs.python.org/3/library/stdtypes.html#str) *或*[str](https://docs.python.org/3/library/stdtypes.html#str)*列表*) :附加[选项](https://docs.python.org/3/library/stdtypes.html#str)。 +* **参数:options** ([str](https://docs.python.org/3/library/stdtypes.html#str) *或*[str](https://docs.python.org/3/library/stdtypes.html#str)*[列表](https://docs.python.org/3/library/stdtypes.html#list)*) :附加选项。 ## tvm.target.riscv_cpu(*model='sifive-u54'*, *options=None*) @@ -290,7 +290,7 @@ TVM 的目标字符串格式为。` [-option=value]...`。 返回 RISC-V CPU 目标。默认值:sifive-u54 rv64gc * **参数:** * **model** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :CPU 名称。 - * **options** ([str](https://docs.python.org/3/library/stdtypes.html#str) *或*[str](https://docs.python.org/3/library/stdtypes.html#str)*列表*) :附加[选项](https://docs.python.org/3/library/stdtypes.html#str)。 + * **options** ([str](https://docs.python.org/3/library/stdtypes.html#str) *或*[str](https://docs.python.org/3/library/stdtypes.html#str)*[列表](https://docs.python.org/3/library/stdtypes.html#list)*) :附加选项。 ## tvm.target.hexagon(*cpu_ver='v68'*, ***kwargs*) @@ -301,7 +301,7 @@ TVM 的目标字符串格式为。` [-option=value]...`。 * **parameters** (*Recognized keyword*)。 * **-----------------------------** * **hvx** ([int](https://docs.python.org/3/library/functions.html#int)*(**default: 128****)*) :HVX 向量的大小(以字节为单位)。值为 0 表示禁用 HVX 代码生成。 - * **llvm_options** ([str](https://docs.python.org/3/library/stdtypes.html#str) *或*[str](https://docs.python.org/3/library/stdtypes.html#str)*列表(**default: None****)*) :用户定义的编译器参数[。](https://docs.python.org/3/library/stdtypes.html#str) + * **llvm_options** ([str](https://docs.python.org/3/library/stdtypes.html#str) *或*[str](https://docs.python.org/3/library/stdtypes.html#str)*[列表](https://docs.python.org/3/library/stdtypes.html#list)(**default: None****)*) :用户定义的编译器参数。 * **use_qfloat** ([bool](https://docs.python.org/3/library/functions.html#bool)*(**default: True for cpu_ver >= v68****,False otherwise)*) :是否使用 QFloat HVX 指令。 * **use_ieee_fp** ([bool](https://docs.python.org/3/library/functions.html#bool)*(**default: False****)*) :是否使用 IEEE HVX 指令。 * **num_cores** ([int](https://docs.python.org/3/library/functions.html#int)*(**default: 4****)*) :HVX 线程数。此属性是元调度程序所必需的。 @@ -314,7 +314,7 @@ TVM 的目标字符串格式为。` [-option=value]...`。 返回 STM32 目标。 * **参数:** * **series** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :STM32 开发板系列的名称,例如 stm32H7xx 或 stm32F4xx。 - * **options** ([str](https://docs.python.org/3/library/stdtypes.html#str) *或*[str](https://docs.python.org/3/library/stdtypes.html#str)*列表*) :附加[选项](https://docs.python.org/3/library/stdtypes.html#str)。 + * **options** ([str](https://docs.python.org/3/library/stdtypes.html#str) *或*[str](https://docs.python.org/3/library/stdtypes.html#str)*[列表](https://docs.python.org/3/library/stdtypes.html#list)*) :附加选项。 ## tvm.target.adreno(*model='unknown'*, *options=None*, *clml=False*) @@ -330,11 +330,11 @@ TVM 的目标字符串格式为。` [-option=value]...`。 **属性:** -|[device_type_int](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.VirtualDevice.device_type_int)|虚拟设备的类型。| +|[device_type_int](/docs/api-reference/python-api/tvm-target#propertydevice_type_int)|虚拟设备的类型。| |:----|:----| -|[memory_scope](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.VirtualDevice.memory_scope)|关于内存的面积。| -|[target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.VirtualDevice.target)|描述如何为虚拟设备编译的目标。| -|[virtual_device_id](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.VirtualDevice.virtual_device_id)|虚拟设备的设备 ID。| +|[memory_scope](/docs/api-reference/python-api/tvm-target#propertymemory_scope)|关于内存的面积。| +|[target](/docs/api-reference/python-api/tvm-target#propertytarget)|描述如何为虚拟设备编译的目标。| +|[virtual_device_id](/docs/api-reference/python-api/tvm-target#propertyvirtual_device_id)|虚拟设备的设备 ID。| ### ***property*device_type_int** @@ -361,8 +361,8 @@ TVM 的目标字符串格式为。` [-option=value]...`。 返回适用于 target 和 target_host 的 CompilationConfig,使用与标准构建接口相同的表示约定。仅用于单元测试。 -## **tvm.target.list_tags()→**[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)**[**[str](https://docs.python.org/3/library/stdtypes.html#str)**,**[Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target)**] |**[None](https://docs.python.org/3/library/constants.html#None) +## **tvm.target.list_tags()→**[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)**[**[str](https://docs.python.org/3/library/stdtypes.html#str)**,**[Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone)**] |**[None](https://docs.python.org/3/library/constants.html#None) 返回一个包含标签的字典,将每个标签名映射到其对应的目标。 * **返回:** tag_dict:标签字典,将每个标签名映射到其对应的目标。如果 TVM 以仅运行时模式构建,则为 None。 -* **返回类型:** Optional[Dict[[str](https://docs.python.org/3/library/stdtypes.html#str), [Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target)]]。 +* **返回类型:** Optional[Dict[[str](https://docs.python.org/3/library/stdtypes.html#str), [Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone)]]。 diff --git a/docs/04-api-reference/01-python-api/06-tvm-driver.md b/docs/04-api-reference/01-python-api/06-tvm-driver.md index 85f26ab..4d8a936 100644 --- a/docs/04-api-reference/01-python-api/06-tvm-driver.md +++ b/docs/04-api-reference/01-python-api/06-tvm-driver.md @@ -6,16 +6,16 @@ title: tvm.driver 驱动程序 API 的命名空间 -## **tvm.compile(*mod:***[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)***|***[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)**,*target:***[Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,***,*relax_pipeline:***[Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)***|***[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)***|***[str](https://docs.python.org/3/library/stdtypes.html#str)***|***[None](https://docs.python.org/3/library/constants.html#None)***= 'default'*,*tir_pipeline:***[Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)***|***[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)***|***[str](https://docs.python.org/3/library/stdtypes.html#str)***|***[None](https://docs.python.org/3/library/constants.html#None)***= 'default'*)→ Executable* +## **tvm.compile(*mod:***[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)***|***[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)**,*target:***[Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,***,*relax_pipeline:***[Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)***|***[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)***|***[str](https://docs.python.org/3/library/stdtypes.html#str)***|***[None](https://docs.python.org/3/library/constants.html#None)***= 'default'*,*tir_pipeline:***[Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)***|***[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)***|***[str](https://docs.python.org/3/library/stdtypes.html#str)***|***[None](https://docs.python.org/3/library/constants.html#None)***= 'default'*)→ Executable* 将 IRModule 编译为运行时可执行文件。 此函数作为编译 TIR 和 Relax 模块的统一入口点。它会自动检测模块类型并路由到相应的构建函数。 * **参数:** - * **mod** ( *Union [*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)*,*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)*]* ) :待编译的输入模块。可以是包含 TIR 或 Relax 函数的 PrimFunc 或 IRModule。 - * **target** (*Optional[*[Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target)*]*) :要编译的目标平台。 - * **Relax_pipeline** ( *Optional [ Union [*[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)*, Callable ,*[str](https://docs.python.org/3/library/stdtypes.html#str)*] ]* ) :Relax 函数使用的编译管道。仅当模块包含 Relax 函数时使用。 - * **tir_pipeline** ( *Optional [ Union [*[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)*, Callable ,*[str](https://docs.python.org/3/library/stdtypes.html#str)*] ]* ) :用于 TIR 函数的编译管道。 + * **mod** ( *Union [*[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)*,*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)*]* ) :待编译的输入模块。可以是包含 TIR 或 Relax 函数的 PrimFunc 或 IRModule。 + * **target** (*Optional[*[Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone)*]*) :要编译的目标平台。 + * **Relax_pipeline** ( *Optional [ Union [*[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)*, Callable ,*[str](https://docs.python.org/3/library/stdtypes.html#str)*] ]* ) :Relax 函数使用的编译管道。仅当模块包含 Relax 函数时使用。 + * **tir_pipeline** ( *Optional [ Union [*[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)*, Callable ,*[str](https://docs.python.org/3/library/stdtypes.html#str)*] ]* ) :用于 TIR 函数的编译管道。 * **返回:** 可以加载和执行的运行时可执行文件。 * **返回类型:** Executable. diff --git a/docs/04-api-reference/01-python-api/07-tvm-runtime.md b/docs/04-api-reference/01-python-api/07-tvm-runtime.md index 02bb805..91b9493 100644 --- a/docs/04-api-reference/01-python-api/07-tvm-runtime.md +++ b/docs/04-api-reference/01-python-api/07-tvm-runtime.md @@ -1,6 +1,6 @@ --- -title: tvm 运行时命名空间。 +title: tvm.runtime --- diff --git a/docs/04-api-reference/01-python-api/08-tvm-runtime-vm.md b/docs/04-api-reference/01-python-api/08-tvm-runtime-vm.md index 5d59892..8aabac4 100644 --- a/docs/04-api-reference/01-python-api/08-tvm-runtime-vm.md +++ b/docs/04-api-reference/01-python-api/08-tvm-runtime-vm.md @@ -22,7 +22,7 @@ Relax VM 运行时。 调用一个闭包。 * **参数:** * **closure** (*Object*) :VMClosure 对象。 - * **args** ([list](https://docs.python.org/3/library/stdtypes.html#list)*[**tvm.runtime.NDArray****] or*[list](https://docs.python.org/3/library/stdtypes.html#list)*[**np.ndarray****]*) :闭包的参数。 + * **args** ([list](https://docs.python.org/3/library/stdtypes.html#list)*[**tvm.runtime.Tensor****] or*[list](https://docs.python.org/3/library/stdtypes.html#list)*[**np.ndarray****]*) :闭包的参数。 * **返回:** result:输出。 * **返回类型:** Object。 @@ -52,7 +52,7 @@ Relax VM 运行时。 注意:如果使用 set_input ,必须使用 invoke_stateful 调用该函数,并且必须使用 get_outputs 获取结果。 * **参数:** * **func_name** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :函数的名称。 - * **args** (*List**[****tvm.runtime.NDArray**] or*** ***List****[**np.ndarray****]*) :函数的参数。 + * **args** (*List**[****tvm.runtime.Tensor**] or*** ***List****[**np.ndarray****]*) :函数的参数。 * **kwargs** ([dict](https://docs.python.org/3/library/stdtypes.html#dict)*ofstr to tvm.runtime.NDArrayornp.ndarray*) :函数的命名参数。 @@ -73,7 +73,7 @@ Relax VM 运行时。 如果没有先调用 invoke_stateful 就调用此函数是错误的。 * **参数:func_name** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :应获取其输出的函数的名称。 * **返回:ret** :先前通过 invoke_stateful 调用该函数的结果。若结果是一个元组,则返回一个字段列表。这些字段也可能是元组,因此可以任意嵌套。 -* **返回类型:** Union[tvm.Object, [Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)[Any]]。 +* **返回类型:** Union[tvm.Object, [Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)[Any]]。 ### set_instrument(*instrument: Function*) → [None](https://docs.python.org/3/library/constants.html#None) @@ -125,7 +125,7 @@ VM 中可能的返回值。 * **f_preproc** ([str](https://docs.python.org/3/library/stdtypes.html#str)*,optional*) – 在执行时间评估器之前我们要执行的预处理函数名称。 -:::Note +:::note 该函数将被调用 (1 + 数字 x 重复) 次,如果存在延迟初始化,则第一次调用将被丢弃。 @@ -174,8 +174,8 @@ timing_res = vm.time_evaluator("func_name_saved", tvm.cpu())() 分析函数调用。 * **参数:** * **func_name** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :函数的名称。 - * **args** (*Listof*[NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray)*orother objects supported by PackedFunc.*) :函数的参数。 + * **args** (*List of [Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) or other objects supported by PackedFunc.*) :函数的参数。 * **返回:report** :格式化的分析结果,显示每个操作的时间测量。 -* **返回类型:**[tvm.runtime.profiling.Report](https://tvm.apache.org/docs/reference/api/python/runtime/profiling.html#tvm.runtime.profiling.Report)。 +* **返回类型:**[tvm.runtime.profiling.Report](/docs/api-reference/python-api/tvm-runtime-profiling#class-tvmruntimeprofilingreportcallssequencedictstr-object-device_metricsdictstrdictstr-object-configurationdictstr-object)。 diff --git a/docs/04-api-reference/01-python-api/09-tvm-runtime-disco.md b/docs/04-api-reference/01-python-api/09-tvm-runtime-disco.md index d9a12e8..c50826a 100644 --- a/docs/04-api-reference/01-python-api/09-tvm-runtime-disco.md +++ b/docs/04-api-reference/01-python-api/09-tvm-runtime-disco.md @@ -1,18 +1,18 @@ --- -title: tvm 运行时的一个模块 +title: tvm.runtime.disco --- TVM 分布式运行时 API。 -## *class* tvm.runtime.disco.DModule(*dref:*[DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef), *session:*[Session](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.Session)) +## *class* tvm.runtime.disco.DModule(*dref:*[DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref), *session:*[Session](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscosession)) Disco 会话中的一个模块。 -## *class* tvm.runtime.disco.DPackedFunc(*dref:*[DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef), *session:*[Session](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.Session)) +## *class* tvm.runtime.disco.DPackedFunc(*dref:*[DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref), *session:*[Session](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscosession)) 一个 Disco 会话中的 PackedFunc。 @@ -29,12 +29,12 @@ Disco 会话中的一个模块。 * **返回类型:**[object](https://docs.python.org/3/library/functions.html#object)。 -### debug_copy_from(*worker_id:*[int](https://docs.python.org/3/library/functions.html#int), *value: ndarray |*[NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray)) → [None](https://docs.python.org/3/library/constants.html#None) +### debug_copy_from(*worker_id:*[int](https://docs.python.org/3/library/functions.html#int),*value: ndarray |Tensor*)) → [None](https://docs.python.org/3/library/constants.html#None) 将 NDArray 值复制到远程以用于调试目的。 * **参数:** * **worker_id** ([int](https://docs.python.org/3/library/functions.html#int)) :要复制到的 worker 的 ID。 - * **value** (*Union**[****numpy.ndarray,*[NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray)*]*) :要复制的值。 + * **value** (*Union**[****numpy.ndarray,*[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*]*) :要复制的值。 ## *class* tvm.runtime.disco.ProcessSession(*num_workers:*[int](https://docs.python.org/3/library/functions.html#int), *num_groups:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *entrypoint:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'tvm.exec.disco_worker'*) @@ -47,7 +47,7 @@ Disco 会话中的一个模块。 一个 Disco 交互式会话。它允许用户使用各种 PackedFunc 调用约定与 Disco 命令队列进行交互。 -### empty(*shape:*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str), *device: Device |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *worker0_only:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *in_group:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef) +### empty(*shape:*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str), *device: Device |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *worker0_only:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *in_group:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref) 在所有 worker 上创建一个空的 NDArray 并将它们附加到 DRef。 * **参数:** @@ -57,7 +57,7 @@ Disco 会话中的一个模块。 * **worker0_only** ([bool](https://docs.python.org/3/library/functions.html#bool)) :如果为 False(默认值),则为每个 worker 分配一个数组。如果为 True,则仅在 worker0 上分配一个数组。 * **in_group** ([bool](https://docs.python.org/3/library/functions.html#bool)) :当worker0_only为 True时生效。如果为 True(默认),则在每个组的第一个 Worker 上分配一个数组。如果为 False,则仅在全局范围内为 worker0 分配一个数组。 * **返回:array** :创建的 NDArray。 -* **返回类型:** [DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef)。 +* **返回类型:** [DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref)。 ### shutdown() @@ -70,12 +70,12 @@ Disco 会话中的一个模块。 返回会话中的 worker 数量。 -### get_global_func(*name:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef) +### get_global_func(*name:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref) 获取 worker 的全局函数。 * **参数:name** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :全局函数的名称。 * **返回:func** :全局打包函数。 -* **返回类型:**[DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef)。 +* **返回类型:**[DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref)。 ### import_python_module(*module_name:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [None](https://docs.python.org/3/library/constants.html#None) @@ -86,7 +86,7 @@ Disco 会话中的一个模块。 * **参数:module_name** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :Python 模块名称,它将用于 Python 导入语句中。 -### call_packed(*func:*[DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef), *args) → [DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef) +### call_packed(*func:*[DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref), *args) → [DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref) 在提供可变参数的 worker 上调用 PackedFunc。 * **参数:** @@ -96,7 +96,7 @@ Disco 会话中的一个模块。 * **返回类型:** 各种类型。 -:::Note +:::note 不支持的类型的示例: - NDArray、DLTensor; - TVM 对象,包括 PackedFunc、Module 和 String。 @@ -108,32 +108,32 @@ Disco 会话中的一个模块。 将控制器与 worker-0 同步,它会等待直到 worker-0 执行完所有现有的指令。 -### copy_from_worker_0(*host_array:*[NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray), *remote_array:*[DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef)) → [None](https://docs.python.org/3/library/constants.html#None) +### copy_from_worker_0(*host_array:Tensor, remote_array:[DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref)*) → [None](https://docs.python.org/3/library/constants.html#None) 将 NDArray 从 worker-0 复制到控制器端 NDArray。 * **参数:** * **host_array** (*numpy.ndarray*) :0的数组。 - * **remote_array** ([NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray)) :0 上的 NDArray。 + * **remote_array** (*[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)* :0 上的 NDArray。 -### copy_to_worker_0(*host_array:*[NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray), *remote_array:*[DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef) +### copy_to_worker_0(*host_array:*Tensor, *remote_array:*[DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref) 将控制器端 NDArray 复制到 worker-0。 * **参数:** - * **host_array** ([NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray)) :要复制到 worker-0 的数组 - * **remote_array** (*Optiona[*[DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef)*]*) :0 上的目标 NDArray。 + * **host_array** (*[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)* ) :要复制到 worker-0 的数组 + * **remote_array** (*Optiona[*[DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref)*]*) :0 上的目标 NDArray。 * **返回:output_array:** 包含 worker0 上复制数据的 DRef,以及所有其他 Worker 上的 std::nullopt。如果提供了remote_array ,则此返回值与remote_array相同。否则,它是新分配的空间。 -* **返回类型:** [DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef)。 +* **返回类型:** [DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref)。 -### load_vm_module(*path:*[str](https://docs.python.org/3/library/stdtypes.html#str), *device: Device |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [DModule](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DModule) +### load_vm_module(*path:*[str](https://docs.python.org/3/library/stdtypes.html#str), *device: Device |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [DModule](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodmoduledrefdref-sessionsession) 从文件加载 VM 模块。 * **参数:** * **path** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :VM 模块文件的路径。 * **device** (*Optional**[****Device]= None*) :加载 VM 模块的设备。默认为每个 Worker 的默认设备。 * **返回:module** :已加载的 VM 模块。 -* **返回类型:**[DModule](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DModule) +* **返回类型:**[DModule](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodmoduledrefdref-sessionsession) ### init_ccl(*ccl:*[str](https://docs.python.org/3/library/stdtypes.html#str), *device_ids) @@ -144,60 +144,60 @@ Disco 会话中的一个模块。 * ****device_ids** (*[int*](https://docs.python.org/3/library/functions.html#int)) :底层通信库使用的设备 ID。 -### broadcast(*src: ndarray |*[NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray), *dst:*[DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *in_group:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef) +### broadcast(*src: ndarray |*Tensor, *dst:*[DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *in_group:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref) 向所有 worker 广播一个数组。 * **参数:** - * **src** (*Union**[****np.ndarray,*[NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray)*]*) :要广播的数组。 - * **dst** (*Optional[*[DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef)*]*) :输出数组。如果为 None,则将在每个 Worker 上分配一个与src的形状和数据类型匹配的数组。 + * **src** (*Union**[****np.ndarray,*NDArray*]*) :要广播的数组。 + * **dst** (*Optional[*[DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref)*]*) :输出数组。如果为 None,则将在每个 Worker 上分配一个与src的形状和数据类型匹配的数组。 * **in_group** ([bool](https://docs.python.org/3/library/functions.html#bool)) :广播操作默认是全局执行还是按组执行。 * **返回:output_array:** 包含所有 Worker 上广播数据的 DRef。如果提供了 dst ,则此返回值与 dst 相同 。否则,返回新分配的空间。 -* **返回类型:** [DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef)。 +* **返回类型:** [DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref)。 -### broadcast_from_worker0(*src:*[DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef), *dst:*[DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef), *in_group:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef) +### broadcast_from_worker0(*src:*[DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref), *dst:*[DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref), *in_group:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref) 将数组从 worker-0 广播到所有其他 worker。 * **参数:** - * **src** (*Union**[****np.ndarray,*[NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray)*]*) :要广播的数组。 - * **dst** (*Optional[*[DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef)*]*) :输出数组。如果为 None,则将在每个 Worker 上分配一个与src的形状和数据类型匹配的数组。 + * **src** (*Union**[****np.ndarray,*NDArray*]*) :要广播的数组。 + * **dst** (*Optional[*[DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref)*]*) :输出数组。如果为 None,则将在每个 Worker 上分配一个与src的形状和数据类型匹配的数组。 * **in_group** ([bool](https://docs.python.org/3/library/functions.html#bool)) 广播操作默认是全局执行还是按组执行。 -### scatter(*src: ndarray |*[NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray), *dst:*[DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *in_group:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef) +### scatter(*src: ndarray |*NDArray, *dst:*[DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *in_group:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref) 将数组分散到所有 worker 中。 * **参数:** - * **src** (*Union**[****np.ndarray,*[NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray)*]*) :待分散的数组。该数组的第一个维度src.shape[0]必须等于工作线程的数量。 - * **dst** (*Optional[*[DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef)*]*) :输出数组。如果为 None,则将在每个 Worker 上分配一个形状兼容且数据类型与 src 相同的数组。 + * **src** (*Union**[****np.ndarray,*NDArray*]*) :待分散的数组。该数组的第一个维度src.shape[0]必须等于工作线程的数量。 + * **dst** (*Optional[*[DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref)*]*) :输出数组。如果为 None,则将在每个 Worker 上分配一个形状兼容且数据类型与 src 相同的数组。 * **in_group** ([bool](https://docs.python.org/3/library/functions.html#bool)) :分散操作是全局执行还是默认在组中执行。 * **返回:output_array**:包含所有 Worker 的分散数据的 DRef。如果提供了dst ,则此返回值与dst相同 。否则,返回新分配的空间。 -* **返回类型:**[DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef)。 +* **返回类型:**[DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref)。 -### scatter_from_worker0(*from_array:*[DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef), *to_array:*[DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef), *in_group:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [None](https://docs.python.org/3/library/constants.html#None) +### scatter_from_worker0(*from_array:*[DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref), *to_array:*[DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref), *in_group:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [None](https://docs.python.org/3/library/constants.html#None) 将数组从 worker-0 分散到所有其他 workers。 * **参数:** - * **src** (*Union**[****np.ndarray,*[NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray)*]*) :待分散的数组。该数组的第一个维度src.shape[0]必须等于工作线程的数量。 - * **dst** (*Optional[*[DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef)*]*) :输出数组。如果为 None,则将在每个 Worker 上分配一个形状兼容且数据类型与src相同的数组。 + * **src** (*Union**[****np.ndarray,*[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*]*) :待分散的数组。该数组的第一个维度src.shape[0]必须等于工作线程的数量。 + * **dst** (*Optional[*[DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref)*]*) :输出数组。如果为 None,则将在每个 Worker 上分配一个形状兼容且数据类型与src相同的数组。 * **in_group** ([bool](https://docs.python.org/3/library/functions.html#bool)) :分散操作是全局执行还是默认在组中执行。 -### gather_to_worker0(*from_array:*[DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef), *to_array:*[DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef), *in_group:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [None](https://docs.python.org/3/library/constants.html#None) +### gather_to_worker0(*from_array:*[DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref), *to_array:*[DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref), *in_group:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [None](https://docs.python.org/3/library/constants.html#None) 将所有其他 worker 的数组收集到 worker-0。 * **参数:** - * **from_array** ([DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef)) :要从中收集的数组。 - * **to_array** ([DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef)) :要收集的数组。 + * **from_array** ([DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref)) :要从中收集的数组。 + * **to_array** ([DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref)) :要收集的数组。 * **in_group** ([bool](https://docs.python.org/3/library/functions.html#bool)) :收集操作是全局执行还是默认以组执行。 -### allreduce(*src:*[DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef), *dst:*[DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef), *op:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'sum'*, *in_group:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef) +### allreduce(*src:*[DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref), *dst:*[DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref), *op:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'sum'*, *in_group:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref) 对数组执行 allreduce 操作。 * **参数:** - * **array** ([DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef)) :要缩减的数组。 + * **array** ([DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref)) :要缩减的数组。 * **op** (*str = "sum"*) :要执行的归约操作。可用选项包括:- “sum”(求和)- “prod”(求积)- “min”(求最小值)- “max”(求最大值)- “avg”(求平均值)。 * **in_group** ([bool](https://docs.python.org/3/library/functions.html#bool)) :减少操作是否全局执行或默认在组中执行。 @@ -206,8 +206,8 @@ Disco 会话中的一个模块。 对一个数组执行 allgather 操作。 * **参数:** - * **src** ([DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef)) :要收集的数组。 - * **dst** ([DRef](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html#tvm.runtime.disco.DRef)) :要收集的数组。 + * **src** ([DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref)) :要收集的数组。 + * **dst** ([DRef](/docs/api-reference/python-api/tvm-runtime-disco#class-tvmruntimediscodref)) :要收集的数组。 * **in_group** ([bool](https://docs.python.org/3/library/functions.html#bool)) :减少操作是否全局执行或默认在组中执行。 diff --git a/docs/04-api-reference/01-python-api/10-tvm-runtime-profiling.md b/docs/04-api-reference/01-python-api/10-tvm-runtime-profiling.md index 2b6fe76..b2c9857 100644 --- a/docs/04-api-reference/01-python-api/10-tvm-runtime-profiling.md +++ b/docs/04-api-reference/01-python-api/10-tvm-runtime-profiling.md @@ -14,7 +14,7 @@ title: tvm 运行时分析 ### calls 每次调用的分析指标(函数名称、运行时、设备等)。 -* 类型:[Array](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Array)[Dict[[str](https://docs.python.org/3/library/stdtypes.html#str), Object]] +* 类型:[Array](/docs/api-reference/python-api/tvm-ir#class-tvmirarrayinput_listsequenceany)[Dict[[str](https://docs.python.org/3/library/stdtypes.html#str), Object]] ### device_metrics @@ -59,7 +59,7 @@ title: tvm 运行时分析 从 JSON 反序列化报告。 * **参数:s** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :通过 序列化报告`json()`。 * **返回:report**:反序列化的报告。 -* **返回类型:**[Report](https://tvm.apache.org/docs/reference/api/python/runtime/profiling.html#tvm.runtime.profiling.Report) +* **返回类型:**[Report](/docs/api-reference/python-api/tvm-runtime-profiling#class-tvmruntimeprofilingreportcallssequencedictstr-object-device_metricsdictstrdictstr-object-configurationdictstr-object) ## *class* tvm.runtime.profiling.Count(*count:*[int](https://docs.python.org/3/library/functions.html#int)) @@ -104,7 +104,7 @@ title: tvm 运行时分析 * **参数:** * **mod** (*Module*) :包含要分析的功能的模块。 * **dev** (*Device*) :运行该功能的设备。 - * **collectors** (*List[*[MetricCollector](https://tvm.apache.org/docs/reference/api/python/runtime/profiling.html#tvm.runtime.profiling.MetricCollector)*]*) :`MetricCollector`将收集性能信息。 + * **collectors** (*List[*[MetricCollector](/docs/api-reference/python-api/tvm-runtime-profiling#class-tvmruntimeprofilingmetriccollector)*]*) :`MetricCollector`将收集性能信息。 * **func_name** (*Optional[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :要配置的mod中的函数名称。默认为mod的entry_name。 * **warmup_iters** ([int](https://docs.python.org/3/library/functions.html#int)) :收集性能信息之前运行函数的迭代次数。建议将其设置为大于 0,以获得一致的缓存效果。默认为 10。 * **返回:prof**:PackedFunc 采用与**mod[func_name]相同的参数,并以Dict[str, ObjectRef] 的形式返回性能指标,其中值可以是CountNode、DurationNode、PercentNode。 diff --git a/docs/04-api-reference/01-python-api/11-tvm-relax.md b/docs/04-api-reference/01-python-api/11-tvm-relax.md index 5dbc547..0b4ebe2 100644 --- a/docs/04-api-reference/01-python-api/11-tvm-relax.md +++ b/docs/04-api-reference/01-python-api/11-tvm-relax.md @@ -70,7 +70,7 @@ relax 从 VM 模块使用 set_input 设置的参数调用命名函数。如果 如果没有先调用 invoke_stateful 则调用此函数是错误的。 * **参数:func_name** () :应获取其输出的函数的名称。 * **返回:** **ret** :先前通过 invoke_stateful 调用该函数的结果。如果结果是一个元组,则返回一个字段列表。这些字段也可能是元组,因此可以任意嵌套。 -* **返回类型:** Union[tvm.Object, [Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)[Any]] +* **返回类型:** Union[tvm.Object, [Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)[Any]] ### **set_instrument(*instrument: Function*)→**[None](https://docs.python.org/3/library/constants.html#None) @@ -121,7 +121,7 @@ VM 中可能的返回值。 * **f_preproc** (*,* *optional*) :在执行时间评估器之前我们要执行的预处理函数名称。 -:::Note +:::note 该函数将被调用(1 + 数字 x 重复)次,如果存在延迟初始化,则第一次调用将被丢弃。 @@ -174,7 +174,7 @@ timing_res = vm.time_evaluator("invoke_stateful", tvm.cpu())("func_name") * **func_name** () :函数的名称。 * **args** (*List* *of* *or* *other objects supported by PackedFunc.*) :函数的参数。 * **返回:** **report**:格式化的分析结果,显示每个操作的时间测量。 -* **返回类型:** [tvm.runtime.profiling.Report](https://tvm.apache.org/docs/reference/api/python/runtime/profiling.html#tvm.runtime.profiling.Report)。 +* **返回类型:** [tvm.runtime.profiling.Report](/docs/api-reference/python-api/tvm-runtime-profiling#class-tvmruntimeprofilingreportcallssequencedictstr-object-device_metricsdictstrdictstr-object-configurationdictstr-object)。 ## ***class*tvm.relax.VMInstrumentReturnKind(*value*)** @@ -192,13 +192,13 @@ RelaxExpr 的别名。 Var 中使用的唯一标识符(名称)。保证在所有过程中保持稳定。 -## ***class*tvm.relax.Var(*name_hint:***[str](https://docs.python.org/3/library/stdtypes.html#str)***|***[Id](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Id)**,*struct_info:***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.Var(*name_hint:***[str](https://docs.python.org/3/library/stdtypes.html#str)***|***[Id](/docs/api-reference/python-api/tvm-relax#classtvmrelaxid)**,*struct_info:***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** 所有 Relax 绑定的变量类。 * **参数:** * **name_hint** (*Union*[[str](https://docs.python.org/3/library/stdtypes.html#str), Id]) :变量的名称提示。 - * **struct_info** (*Optional*[[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)]):变量的结构信息注释。 - * **span** (*Optional*[[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)]):指向原始源代码的 Span。 + * **struct_info** (*Optional*[[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)]):变量的结构信息注释。 + * **span** (*Optional*[[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)]):指向原始源代码的 Span。 ### ***property*name_hint*:* [str](https://docs.python.org/3/library/stdtypes.html#str) @@ -206,21 +206,21 @@ Var 中使用的唯一标识符(名称)。保证在所有过程中保持稳 获取当前变量的名称提示。 -## ***class*tvm.relax.DataflowVar(*name_hint:***[str](https://docs.python.org/3/library/stdtypes.html#str)***|***[Id](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Id)**,*struct_info:***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.DataflowVar(*name_hint:***[str](https://docs.python.org/3/library/stdtypes.html#str)***|***[Id](/docs/api-reference/python-api/tvm-relax#classtvmrelaxid)**,*struct_info:***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** 变量节点的子类型,用于标记来自正常可见的“function local”绑定的数据流变量。 * **参数:** * **name_hint** (Union[[str](https://docs.python.org/3/library/stdtypes.html#str), Id]) :变量的名称提示。 - * **struct_info** (Optional[[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)]) *:变量的结构信息注释。* - * **span** (Optional[[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)]) *:指向原始源代码的 Span。* + * **struct_info** (Optional[[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)]) *:变量的结构信息注释。* + * **span** (Optional[[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)]) *:指向原始源代码的 Span。* -## ***class*tvm.relax.Binding**[](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Binding) +## ***class*tvm.relax.Binding** Relax 中绑定的基类。 -## ***class*tvm.relax.MatchCast(*var:***[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)**,*value:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**,*struct_info:***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)**,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.MatchCast(*var:***[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**,*value:***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**,*struct_info:***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)**,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** 运行时将值与结构信息匹配。 @@ -231,7 +231,7 @@ Relax 中绑定的基类。 * **struct_info** () :要匹配的结构信息。 -## ***class*tvm.relax.VarBinding(*var:***[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)**,*value:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.VarBinding(*var:***[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**,*value:***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***= None*)** 变量绑定,将 lhs 的变量与 rhs 的变量绑定。 * **参数:** @@ -239,21 +239,21 @@ Relax 中绑定的基类。 * **value** (*Expr*) :输入值表达式。 -## ***class*tvm.relax.BindingBlock(*bindings:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[Binding](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Binding)***]*,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.BindingBlock(*bindings:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[Binding](/docs/api-reference/python-api/tvm-relax#classtvmrelaxbinding)***]*,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** 绑定块的基类,内部绑定可以是不纯的(具有副作用或控制流)。 -## ***class*tvm.relax.DataflowBlock(*bindings:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[Binding](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Binding)***]*,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.DataflowBlock(*bindings:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[Binding](/docs/api-reference/python-api/tvm-relax#classtvmrelaxbinding)***]*,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** 数据流块,内部绑定是纯粹的(没有副作用,也没有控制流)。 -## ***class*tvm.relax.SeqExpr(*blocks:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[BindingBlock](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.BindingBlock)***]*,*body:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.SeqExpr(*blocks:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[BindingBlock](/docs/api-reference/python-api/tvm-relax#classtvmrelaxbindingblockbindingslistbindingspanspannonenone)***]*,*body:***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** 一系列绑定块后跟一个表达式。 -## ***class*tvm.relax.ShapeExpr(*values:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)***] |***[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)***[***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)***, ...] |***[Array](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Array)**,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.ShapeExpr(*values:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)***] |***[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)***[***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)***, ...] |***[Array](/docs/api-reference/python-api/tvm-ir#class-tvmirarrayinput_listsequenceany)**,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** 形状表达式允许用户构建包含 PrimExpr 的形状。 * **参数:** @@ -261,7 +261,7 @@ Relax 中绑定的基类。 * **span** (Optional[]) *:*指向原始源代码的 Span。 -## ***class*tvm.relax.Tuple(*fields:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)***] |***[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)***[***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)***, ...]*,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.Tuple(*fields:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)***] |***[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)***[***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)***, ...]*,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** 将多个字段组合在一起的元组表达式。 * **参数:** @@ -269,7 +269,7 @@ Relax 中绑定的基类。 * **span** (Optional[]) :指向原始源代码的 Span。 -## ***class*tvm.relax.TupleGetItem(*tuple_value:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**,*index:***[int](https://docs.python.org/3/library/functions.html#int)**,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.TupleGetItem(*tuple_value:***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**,*index:***[int](https://docs.python.org/3/library/functions.html#int)**,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** 从元组中获取第 index 项。 * **参数:** @@ -279,11 +279,11 @@ Relax 中绑定的基类。 # -## ***class*tvm.relax.Function(*params:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)***]*,*body:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**,*ret_struct_info:***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*is_pure:***[bool](https://docs.python.org/3/library/functions.html#bool)***|***[None](https://docs.python.org/3/library/constants.html#None)***= True*,*attrs:***[DictAttrs](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.DictAttrs)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.Function(*params:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)***]*,*body:***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**,*ret_struct_info:***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*is_pure:***[bool](https://docs.python.org/3/library/functions.html#bool)***|***[None](https://docs.python.org/3/library/constants.html#None)***= True*,*attrs:***[DictAttrs](/docs/api-reference/python-api/tvm-ir#class-tvmirdictattrs)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** Relax 函数。 -### ***static*create_empty(*params:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)***]*,*ret_struct_info:***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)**,*is_pure:***[bool](https://docs.python.org/3/library/functions.html#bool)***|***[None](https://docs.python.org/3/library/constants.html#None)***= True*,*attrs:***[DictAttrs](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.DictAttrs)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +### ***static*create_empty(*params:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)***]*,*ret_struct_info:***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)**,*is_pure:***[bool](https://docs.python.org/3/library/functions.html#bool)***|***[None](https://docs.python.org/3/library/constants.html#None)***= True*,*attrs:***[DictAttrs](/docs/api-reference/python-api/tvm-ir#class-tvmirdictattrs)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** 构建一个不带主体的 Relax.Function。 @@ -293,10 +293,10 @@ Relax 函数。 * **参数:** * **binding_map** (Mapping[**Union**[, ], ]) :待替换值的映射。键可以是 tir.Var 或变量的字符串名称。如果通过名称引用变量,则该名称必须唯一地标识函数中的符号变量。 * **返回:** **func**:更新后的函数 - * **返回类型:** [Function](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Function) + * **返回类型:** [Function](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfunctionparamslistvarbodyrelaxexprret_struct_infostructinfononenoneis_pureboolnonetrueattrsdictattrsnonenonespanspannonenone) -### **bind_symbolic_vars(*binding_map:***[Mapping](https://docs.python.org/3/library/typing.html#typing.Mapping)***[***[str](https://docs.python.org/3/library/stdtypes.html#str)***|***[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)***,***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)***]*)→**[Function](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Function) +### **bind_symbolic_vars(*binding_map:***[Mapping](https://docs.python.org/3/library/typing.html#typing.Mapping)***[***[str](https://docs.python.org/3/library/stdtypes.html#str)***|***[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)***,***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)***]*)→**[Function](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfunctionparamslistvarbodyrelaxexprret_struct_infostructinfononenoneis_pureboolnonetrueattrsdictattrsnonenonespanspannonenone) 返回具有更新的符号变量的新函数。 @@ -306,13 +306,13 @@ Relax 函数。 * 键(Key)可以是类型,也可以是 Relax 变量的字符串名称。如果通过名称来指定变量,该名称必须唯一标识函数中的一个参数。 * 值(Value)必须是一个 Relax 表达式,或者转换可以为 Relax 表达式的值。该值必须与被替换的变量类型兼容。 * **返回:** **func** :更新后的函数。 - * **返回类型:** [Function](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Function)。 + * **返回类型:** [Function](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfunctionparamslistvarbodyrelaxexprret_struct_infostructinfononenoneis_pureboolnonetrueattrsdictattrsnonenonespanspannonenone)。 -## ***class*tvm.relax.ExternFunc(*global_symbol: String*,*struct_info:***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.ExternFunc(*global_symbol: String*,*struct_info:***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** 外部函数,代表一个 PackedFunc。 -## ***class*tvm.relax.Call(*op:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)***|***[Op](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Op)**,*args:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)***] |***[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)***[***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)***, ...]*,*attrs:***[Attrs](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Attrs)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*sinfo_args:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)***] |***[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)***[***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)***, ...] |***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.Call(*op:***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)***|***[Op](/docs/api-reference/python-api/tvm-ir#class-tvmirop)**,*args:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)***] |***[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)***[***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)***, ...]*,*attrs:***[Attrs](/docs/api-reference/python-api/tvm-ir#classtvmirattrs)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*sinfo_args:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)***] |***[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)***[***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)***, ...] |***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** Relax 中的函数调用节点。 @@ -325,7 +325,7 @@ Relax.Call 节点对应于计算图术语中的运算符应用节点。 * **sinfo_args** (*Optional[**Union**[**List**[*]*,***[,* ...]**]**]) :CallNode 的结构信息参数。sinfo_args 设计为仅对内部操作(例如,call_tir、call_builtin_with_ctx 等)和对 ExternFuncs 的调用为非空,主要用于结构信息推断。 * **span** (*Optional*[*]):指向原始源代码的 Span。* -## ***class*tvm.relax.If(*cond:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**,*true_branch:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**,*false_branch:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.If(*cond:***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**,*true_branch:***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**,*false_branch:***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** Relax 中的条件表达式。 * **参数:** @@ -334,30 +334,30 @@ Relax 中的条件表达式。 * **false_branch** (*Expr*) :当条件为假时计算的表达式。 * **span** (Optional[]) *:指向原始源代码的 Span。* -## ***class*tvm.relax.Constant(*data:***[NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray)**,*struct_info:***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.Constant(*data:***NDArray**,*struct_info:***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** 常数张量 * **参数:** * **data** (*tvm.nd.NDArray*) :常数张量的数据。 * **struct_info** (Optional[]) *:*常量张量的结构信息。若未指定,则根据数据推断。 * **span** (Optional[]*):*指向原始源代码的 Span。 -:::Note +:::note 标量常数由 ndim-0 常数张量表示。 ::: -## ***class*tvm.relax.PrimValue(*value:***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)***|***[int](https://docs.python.org/3/library/functions.html#int)**,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.PrimValue(*value:***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)***|***[int](https://docs.python.org/3/library/functions.html#int)**,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** prim expr 表示值。 -## ***class*tvm.relax.DataTypeImm(*value: dtype |***[str](https://docs.python.org/3/library/stdtypes.html#str)**,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.DataTypeImm(*value: dtype |***[str](https://docs.python.org/3/library/stdtypes.html#str)**,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** 表示数据类型常量。 -## ***class*tvm.relax.StringImm(*value:***[str](https://docs.python.org/3/library/stdtypes.html#str)**,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.StringImm(*value:***[str](https://docs.python.org/3/library/stdtypes.html#str)**,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** 表示字符串文字常量。 -## **tvm.relax.const(*value:***[bool](https://docs.python.org/3/library/functions.html#bool)***|***[int](https://docs.python.org/3/library/functions.html#int)***|***[float](https://docs.python.org/3/library/functions.html#float)***| ndarray |***[NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray)**,*dtype:***[str](https://docs.python.org/3/library/stdtypes.html#str)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)→**[Constant](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Constant) +## **tvm.relax.const(*value:***[bool](https://docs.python.org/3/library/functions.html#bool)***|***[int](https://docs.python.org/3/library/functions.html#int)***|***[float](https://docs.python.org/3/library/functions.html#float)***| ndarray |***NDArray**,*dtype:***[str](https://docs.python.org/3/library/stdtypes.html#str)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)→**[Constant](/docs/api-reference/python-api/tvm-relax#classtvmrelaxconstantdatandarraystruct_infostructinfononenonespanspannonenone) 创建一个常数值。 * **参数:** @@ -365,7 +365,7 @@ prim expr 表示值。 * **dtype** (*Optional*[*]):结果常量的数据类型。* -:::Note +:::note 当 dtype 为 None 时,我们使用以下规则: * int 映射到“int32”。 @@ -375,11 +375,11 @@ prim expr 表示值。 ::: -## **tvm.relax.extern(*name:***[str](https://docs.python.org/3/library/stdtypes.html#str)**,*struct_info:***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## **tvm.relax.extern(*name:***[str](https://docs.python.org/3/library/stdtypes.html#str)**,*struct_info:***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** 创建外部函数。 -## **tvm.relax.get_shape_of(*expr:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**)→**[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## **tvm.relax.get_shape_of(*expr:***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**)→**[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 获取 expr 的形状。 * **参数:expr** (*Expr*) :输入表达式。 @@ -387,22 +387,22 @@ prim expr 表示值。 * **返回类型:** Expr -:::Note +:::note 此函数要求对 expr 进行归一化。如果 expr 的 StructInfo 不是 TensorStructInfo,函数将报错。它会尽可能尝试返回符号函数。如果张量没有编译时符号形状,函数将选择返回 Relax.Call(relax.op.shape_of, [expr])。 ::: -## ***class*tvm.relax.ObjectType(*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.ObjectType(*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** 与 tvm::runtime::Object 对应的类型是 TVM 中所有可能的对象值的基础。 -## ***class*tvm.relax.ShapeType(*ndim:***[int](https://docs.python.org/3/library/functions.html#int)***= -1*,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.ShapeType(*ndim:***[int](https://docs.python.org/3/library/functions.html#int)***= -1*,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** Relax 中的形状类型。 * **参数:ndim** (*Optional*[*]):形状的大小。 -## ***class*tvm.relax.TensorType(*ndim=-1*,*dtype='float32'*,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.TensorType(*ndim=-1*,*dtype='float32'*,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** Relax 中的动态张量类型。 @@ -411,14 +411,14 @@ Relax 中的动态张量类型。 * **参数:ndim** (Optional[]) :张量的 ndim。 * **dtype** (Optional[]) :内容数据类型。 -## ***class*tvm.relax.PackedFuncType(*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.PackedFuncType(*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** Relax 中的 ExternFunc 的类型。 -## ***class*tvm.relax.ExecBuilder**[](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ExecBuilder) +## ***class*tvm.relax.ExecBuilder** 用于发出指令并为虚拟机构建可执行文件的构建器。 -### **r(*idx:***[int](https://docs.python.org/3/library/functions.html#int)**)→**[int](https://docs.python.org/3/library/functions.html#int)[](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ExecBuilder.r) +### **r(*idx:***[int](https://docs.python.org/3/library/functions.html#int)**)→**[int](https://docs.python.org/3/library/functions.html#int) 将指令的参数设置为寄存器。 @@ -445,7 +445,7 @@ Relax 中的 ExternFunc 的类型。 注释 VM 函数。 -### **emit_call(*name:***[str](https://docs.python.org/3/library/stdtypes.html#str)**,*args:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray)***| dtype] |***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*dst:***[int](https://docs.python.org/3/library/functions.html#int)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)→**[None](https://docs.python.org/3/library/constants.html#None) +### **emit_call(*name:***[str](https://docs.python.org/3/library/stdtypes.html#str)**,*args:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***NDArray***| dtype] |***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*dst:***[int](https://docs.python.org/3/library/functions.html#int)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)→**[None](https://docs.python.org/3/library/constants.html#None) 发出调用打包函数的调用指令。 @@ -454,22 +454,22 @@ Relax 中的 ExternFunc 的类型。 发出返回指令。 -### **emit_goto(*pc_offset*)**[](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ExecBuilder.emit_goto) +### **emit_goto(*pc_offset*)** 发出 goto 指令。 -### emit_if(cond, false_offset)[](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ExecBuilder.emit_if) +### emit_if(cond, false_offset) 发出 if 指令。 -### **get()→**[VMExecutable](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.VMExecutable)[](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ExecBuilder.get) +### **get()→**[VMExecutable](http://tvm.hyper.ai/docs/api-reference/python-api/tvm-relax#classtvmrelaxvmexecutablemodmodule) 返回可执行文件。 -## **tvm.relax.call_tir(*gvar:***[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar)**,*args:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**,*out_sinfo:***[TensorStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TensorStructInfo)***|***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[TensorStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TensorStructInfo)***]*,*tir_vars:***[ShapeExpr](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ShapeExpr)***|***[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)***[***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)***] |***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)***] |***[None](https://docs.python.org/3/library/constants.html#None)***= None*)→**[Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call) +## **tvm.relax.call_tir(*gvar:***[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none)**,*args:***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**,*out_sinfo:***[TensorStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtensorstructinfoshaperelaxexprnonelistprimexprnonedtypestrfloat32vdevicevdevicenonestrnonendimint-1spanspannonenone)***|***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[TensorStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtensorstructinfoshaperelaxexprnonelistprimexprnonedtypestrfloat32vdevicevdevicenonestrnonendimint-1spanspannonenone)***]*,*tir_vars:***[ShapeExpr](/docs/api-reference/python-api/tvm-relax#classtvmrelaxshapeexprvalueslistprimexprtupleprimexprarrayspanspannonenone)***|***[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)***[***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)***] |***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)***] |***[None](https://docs.python.org/3/library/constants.html#None)***= None*)→**[Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone) relax.Call 调用一个 tir.prim_func 并返回输出。 @@ -479,9 +479,10 @@ relax.Call 调用一个 tir.prim_func 并返回输出。 * **out_sinfo** (Union[, List[]]) :call_tir 输出的结构信息。它应该是一个 TensorStructInfo 或一个 TensorStructInfo 列表。每个 TensorStructInfo 表示返回张量的结构信息。 * **tir_vars** (Optional[**Union**[, [], List[]**]**]) :ShapeExpr 表示调用 func 时需要解包的整数元组。若未使用则为 null。 * **返回:** **ret**:call_tir 运算符的调用节点。 -* **返回类型:** [relax.Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call)。 +* **返回类型:** [relax.Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone)。 + +## **tvm.relax.call_tir_inplace(*gvar:***[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none)**,*args:***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**,*inplace_indices:***[int](https://docs.python.org/3/library/functions.html#int)***|***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[int](https://docs.python.org/3/library/functions.html#int)***]*,*out_sinfo:***[TensorStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtensorstructinfoshaperelaxexprnonelistprimexprnonedtypestrfloat32vdevicevdevicenonestrnonendimint-1spanspannonenone)***|***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[TensorStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtensorstructinfoshaperelaxexprnonelistprimexprnonedtypestrfloat32vdevicevdevicenonestrnonendimint-1spanspannonenone)***]*,*tir_vars:***[ShapeExpr](/docs/api-reference/python-api/tvm-relax#classtvmrelaxshapeexprvalueslistprimexprtupleprimexprarrayspanspannonenone)***|***[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)***[***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)***] |***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)***] |***[None](https://docs.python.org/3/library/constants.html#None)***= None*)→**[Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone) -## **tvm.relax.call_tir_inplace(*gvar:***[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar)**,*args:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**,*inplace_indices:***[int](https://docs.python.org/3/library/functions.html#int)***|***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[int](https://docs.python.org/3/library/functions.html#int)***]*,*out_sinfo:***[TensorStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TensorStructInfo)***|***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[TensorStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TensorStructInfo)***]*,*tir_vars:***[ShapeExpr](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ShapeExpr)***|***[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)***[***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)***] |***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)***] |***[None](https://docs.python.org/3/library/constants.html#None)***= None*)→**[Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call) relax.Call 调用 TIR PrimFunc 并返回结果,就地执行指定的计算(基于 inplace_indices 参数;输出将为就地索引选择的输入设置别名)。 @@ -497,9 +498,9 @@ relax.Call 调用 TIR PrimFunc 并返回结果,就地执行指定的计算( * **out_sinfo** (Union[, List[]]) :call_tir_inplace 输出的结构信息。它应该是一个 TensorStructInfo 或一个 TensorStructInfo 列表。每个列表表示返回张量的结构信息。如果给出一个 TensorStructInfo 列表,则结果将是一个 TensorStructInfo 元组。 * **tir_vars** (Optional[**Union**[,[], List[]**]**]) :ShapeExpr 表示调用 func 时需要解包的整数元组。若未使用则为 null。 * **返回:** **ret**:call_tir 运算符的调用节点。 -* **返回类型:** [relax.Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call) +* **返回类型:** [relax.Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone) -## **tvm.relax.call_pure_packed(*func:***[str](https://docs.python.org/3/library/stdtypes.html#str)***|***[ExternFunc](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ExternFunc)***|***[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar)**,**args:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**,*sinfo_args:***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)***|***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)***]*)→**[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## **tvm.relax.call_pure_packed(*func:***[str](https://docs.python.org/3/library/stdtypes.html#str)***|***[ExternFunc](/docs/api-reference/python-api/tvm-relax#classtvmrelaxexternfuncglobal_symbolstringstruct_infostructinfononenonespanspannonenone)***|***[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none)**,**args:***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**,*sinfo_args:***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)***|***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)***]*)→**[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr ) 构造一个对打包函数的调用,该调用应被视为纯粹的,即使打包调用通常不被视为纯粹的。 @@ -516,7 +517,7 @@ relax.Call 调用 TIR PrimFunc 并返回结果,就地执行指定的计算( * **返回:** **result**:Relax 调用,对应于 call_pure_packed(ExternFunc(func), args, DictAttrs(kwargs), sinfo_args)。 * **返回类型:** Expr。 -## **tvm.relax.call_dps_packed(*func:***[str](https://docs.python.org/3/library/stdtypes.html#str)***|***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**,*args:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**,*out_sinfo:***[TensorStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TensorStructInfo)***|***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[TensorStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TensorStructInfo)***]*)→**[Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call) +## **tvm.relax.call_dps_packed(*func:***[str](https://docs.python.org/3/library/stdtypes.html#str)***|***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**,*args:***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**,*out_sinfo:***[TensorStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtensorstructinfoshaperelaxexprnonelistprimexprnonedtypestrfloat32vdevicevdevicenonestrnonendimint-1spanspannonenone)***|***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[TensorStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtensorstructinfoshaperelaxexprnonelistprimexprnonedtypestrfloat32vdevicevdevicenonestrnonendimint-1spanspannonenoneo)***]*)→**[Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone) @@ -529,9 +530,9 @@ Relax。调用目的地传递式打包函数并返回输出。 * **args** (Expr) :输入参数。 * **out_sinfo** (Union[, List[]]) :call_dps_packed 输出的结构信息。它应该是一个 TensorStructInfo 或一个 TensorStructInfo 列表。每个 TensorStructInfo 表示返回张量的结构信息。 * **返回:** **ret**:call_dps_packed 运算符的调用节点。 -* **返回类型:** [relax.Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call) +* **返回类型:** [relax.Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone) -## **tvm.relax.call_tir_with_grad(*gvar:***[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar)**,*args:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**,*out_sinfo:***[TensorStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TensorStructInfo)***|***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[TensorStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TensorStructInfo)***]*,*te_grad_name:***[str](https://docs.python.org/3/library/stdtypes.html#str)**,*te_grad_kwargs:***[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)***[***[str](https://docs.python.org/3/library/stdtypes.html#str)***, Object] = None*,*tir_vars:***[ShapeExpr](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ShapeExpr)***|***[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)***[***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)***] |***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)***] |***[None](https://docs.python.org/3/library/constants.html#None)***= None*)→**[Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call) +## **tvm.relax.call_tir_with_grad(*gvar:***[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none)**,*args:***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**,*out_sinfo:***[TensorStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtensorstructinfoshaperelaxexprnonelistprimexprnonedtypestrfloat32vdevicevdevicenonestrnonendimint-1spanspannonenone)***|***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[TensorStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtensorstructinfoshaperelaxexprnonelistprimexprnonedtypestrfloat32vdevicevdevicenonestrnonendimint-1spanspannonenone)***]*,*te_grad_name:***[str](https://docs.python.org/3/library/stdtypes.html#str)**,*te_grad_kwargs:***[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)***[***[str](https://docs.python.org/3/library/stdtypes.html#str)***, Object] = None*,*tir_vars:***[ShapeExpr](/docs/api-reference/python-api/tvm-relax#classtvmrelaxshapeexprvalueslistprimexprtupleprimexprarrayspanspannonenone)***|***[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)***[***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)***] |***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)***] |***[None](https://docs.python.org/3/library/constants.html#None)***= None*)→**[Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenonel) relax.Call 调用 tir.prim_func 并返回输出。此内在函数会将 te 梯度函数(由 te_grad_name 引用)绑定到 call_tir_with_grad 节点。该 te 梯度函数将被梯度传递调用。 * **参数:** @@ -542,13 +543,13 @@ relax.Call 调用 tir.prim_func 并返回输出。此内在函数会将 te 梯 * **te_grad_kwargs** (Dict[, Object], optional) :传递给 te 梯度函数的关键字参数。可选地,以关键字参数的形式提供。默认值:{} * **tir_vars** (Optional[**Union**[,[], List[]**]**]) :ShapeExpr 表示调用 func 时需要解包的整数元组。若未使用则为 null。 * **返回:** **ret:** call_tir_with_grad 运算符的调用节点。 -* **返回类型:** [relax.Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call) +* **返回类型:** [relax.Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenonel) ## ***class*tvm.relax.ExprFunctor** 在 Expr 上定义的抽象 visitor 。定义表达式的默认分派,并实现存储。 -### **visit_expr(*expr:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**)→**[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +### **visit_expr(*expr:***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**)→**[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 将 visitor 应用到表达式。 ## ***class*tvm.relax.PyExprVisitor** @@ -579,159 +580,159 @@ def MyExprVisitor(PyExprVisitor): Expr 的通用调度程序。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr(const Expr& expr)。 * **参数:expr** (*Expr*) :要访问的 expr。 -### **visit_expr(*expr:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_expr(*expr:***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**)→**[None](https://docs.python.org/3/library/constants.html#None) 通用的 Binding 调度器。用户可以自定义此函数,在 C++ 端覆盖 VisitBinding(const Binding& binding)。 * **参数:binding** () :要访问的绑定。 -### **visit_binding(*binding:***[Binding](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Binding)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_binding(*binding:***[Binding](/docs/api-reference/python-api/tvm-relax#classtvmrelaxbinding)**)→**[None](https://docs.python.org/3/library/constants.html#None) BindingBlock 的通用调度器。用户可以自定义此函数,在 C++ 端覆盖 VisitBindingBlock(const BindingBlock& block)。 * **参数:block** () :要访问的块。 -### **visit_binding_block(*block:***[BindingBlock](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.BindingBlock)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_binding_block(*block:***[BindingBlock](/docs/api-reference/python-api/tvm-relax#classtvmrelaxbindingblockbindingslistbindingspanspannonenone)**)→**[None](https://docs.python.org/3/library/constants.html#None) 用于访问 var 定义点的通用调度器。用户可以自定义此函数,在 C++ 端覆盖 VisitVarDef(const Relax.Var& var)。需要注意的是,visit_var_() 只会访问 Var 的使用点。 * **参数:var** () :要访问的 var。 -### **visit_var_def(*var:***[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_var_def(*var:***[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**)→**[None](https://docs.python.org/3/library/constants.html#None) 访问常量。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const ConstantNode op)。 * **参数:op** () :要访问的常量。 -### **visit_constant_(*op:***[Constant](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Constant)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_constant_(*op:***[Constant](/docs/api-reference/python-api/tvm-relax#classtvmrelaxconstantdatandarraystruct_infostructinfononenonespanspannonenone)**)→**[None](https://docs.python.org/3/library/constants.html#None) 访问 Tuple。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const TupleNode op)。 * **参数:op** () :要访问的元组。 -### **visit_tuple_(*op:***[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_tuple_(*op:***[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)**)→**[None](https://docs.python.org/3/library/constants.html#None) 访问变量。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const VarNode op)。 * **参数:op** () :要访问的 relax.Var。 -### **visit_var_(*op:***[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_var_(*op:***[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**)→**[None](https://docs.python.org/3/library/constants.html#None) 访问 DataflowVar。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const DataflowVarNode op)。 * **参数:op** () :要访问的 DataflowVar。 -### **visit_dataflow_var_(*op:***[DataflowVar](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.DataflowVar)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_dataflow_var_(*op:***[DataflowVar](/docs/api-reference/python-api/tvm-relax#classtvmrelaxdataflowvarname_hintstridstruct_infostructinfononenonespanspannonenone)**)→**[None](https://docs.python.org/3/library/constants.html#None) 访问 ShapeExpr。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const ShapeExprNode op)。 * **参数:op** () :要访问的 ShapeExpr。 -### **visit_shape_expr_(*op:***[ShapeExpr](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ShapeExpr)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_shape_expr_(*op:***[ShapeExpr](/docs/api-reference/python-api/tvm-relax#classtvmrelaxshapeexprvalueslistprimexprtupleprimexprarrayspanspannonenone)**)→**[None](https://docs.python.org/3/library/constants.html#None) 访问 ExternFunc。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const ExternFuncNode* op)。 * **参数:op** () :要访问的 ExternFunc。 -### **visit_extern_func_(*op:***[ExternFunc](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ExternFunc)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_extern_func_(*op:***[ExternFunc](/docs/api-reference/python-api/tvm-relax#classtvmrelaxexternfuncglobal_symbolstringstruct_infostructinfononenonespanspannonenone)**)→**[None](https://docs.python.org/3/library/constants.html#None) 访问 GlobalVar。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const GlobalVarNode op)。 * **参数:op** () :要访问的 GlobalVar。 -### **visit_global_var_(*op:***[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_global_var_(*op:***[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none)**)→**[None](https://docs.python.org/3/library/constants.html#None) 访问函数。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const FunctionNode op)。 * **参数:op** () :要访问的函数。 -### **visit_function_(*op:***[Function](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Function)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_function_(*op:***[Function](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfunctionparamslistvarbodyrelaxexprret_struct_infostructinfononenoneis_pureboolnonetrueattrsdictattrsnonenonespanspannonenone)**)→**[None](https://docs.python.org/3/library/constants.html#None) 访问调用。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const CallNode op)。 * **参数:op** () :要访问的 relax.Call。 -### **visit_seq_expr_(*op:***[SeqExpr](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.SeqExpr)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_seq_expr_(*op:***[SeqExpr](/docs/api-reference/python-api/tvm-relax#classtvmrelaxseqexprblockslistbindingblockbodyrelaxexprspanspannonenone)**)→**[None](https://docs.python.org/3/library/constants.html#None) 访问 SeqExpr。用户可以自定义此函数,在 C++端覆盖 VisitExpr_(const SeqExprNode op)。 * **参数:op** () :要访问的 SeqExpr。 -### **visit_if_(*op:***[If](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.If)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_if_(*op:***[If](/docs/api-reference/python-api/tvm-relax#classtvmrelaxifcondrelaxexprtrue_branchrelaxexprfalse_branchrelaxexprspanspannonenone)**)→**[None](https://docs.python.org/3/library/constants.html#None) 访问 If。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const IfNode op)。 * **参数:op** () :要访问的 If。 -### **visit_op_(*op:***[Op](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Op)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_op_(*op:***[Op](/docs/api-reference/python-api/tvm-ir#class-tvmirop)**)→**[None](https://docs.python.org/3/library/constants.html#None) 访问 Op。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const OpNode op)。 * **参数:op** () :要访问的 Op。 -### **visit_tuple_getitem_(*op:***[TupleGetItem](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TupleGetItem)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_tuple_getitem_(*op:***[TupleGetItem](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplegetitemtuple_valuerelaxexprindexintspanspannonenone)**)→**[None](https://docs.python.org/3/library/constants.html#None) 访问 TupleGetItem。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const TupleGetItemNode op)。 * **参数:op** () :要访问的 TupleGetItem。 -### **visit_prim_value_(*op:***[PrimValue](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.PrimValue)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_prim_value_(*op:***[PrimValue](/docs/api-reference/python-api/tvm-relax#classtvmrelaxprimvaluevalueprimexprintspanspannonenone)**)→**[None](https://docs.python.org/3/library/constants.html#None) 访问 PrimValue。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const PrimValueNode op)。 * **参数:op** () :要访问的 PrimValue。 -### **visit_string_imm_(*op:***[StringImm](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StringImm)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_string_imm_(*op:***[StringImm](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstringimmvaluestrspanspannonenone)**)→**[None](https://docs.python.org/3/library/constants.html#None) 访问 StringImm。用户可以自定义此函数,在 C++端覆盖 VisitExpr_(const StringImmNode op)。 * **参数:op** () :要访问的 StringImm。 -### **visit_data_type_imm_(*op:***[DataTypeImm](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.DataTypeImm)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_data_type_imm_(*op:***[DataTypeImm](/docs/api-reference/python-api/tvm-relax#classtvmrelaxdatatypeimmvaluedtypestrspanspannonenone)**)→**[None](https://docs.python.org/3/library/constants.html#None) 访问 DataTypeImm。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const 。 * **参数:op** () :要访问的 DataTypeImm。 -### **visit_var_binding_(*binding:***[VarBinding](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.VarBinding)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_var_binding_(*binding:***[VarBinding](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarbindingvarvarvaluerelaxexprspanspannonenone)**)→**[None](https://docs.python.org/3/library/constants.html#None) 访问 VarBinding。用户可以自定义此函数,在 C++ 端覆盖 VisitBinding_(const VarBindingNode* binding)。 * **参数:binding** () :要访问的 VarBinding。 -### **visit_match_cast_(*binding:***[MatchCast](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.MatchCast)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_match_cast_(*binding:***[MatchCast](/docs/api-reference/python-api/tvm-relax#classtvmrelaxmatchcastvarvarvaluerelaxexprstruct_infostructinfospanspannonenone)**)→**[None](https://docs.python.org/3/library/constants.html#None) 访问 MatchCast。用户可以自定义此函数,在 C++ 端覆盖 VisitBinding_(const MatchCastNode binding)。 * **参数:binding** () :要访问的 MatchCast。 -### **visit_binding_block_(*block:***[BindingBlock](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.BindingBlock)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_binding_block_(*block:***[BindingBlock](/docs/api-reference/python-api/tvm-relax#classtvmrelaxbindingblockbindingslistbindingspanspannonenone)**)→**[None](https://docs.python.org/3/library/constants.html#None) 访问 BindingBlock。用户可以自定义此函数,在 C++端覆盖 VisitBlock_(const BindingBlockNode block)。 * **参数:block** () :要访问的 BindingBlock。 -### **visit_dataflow_block_(*block:***[DataflowBlock](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.DataflowBlock)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_dataflow_block_(*block:***[DataflowBlock](/docs/api-reference/python-api/tvm-relax#classtvmrelaxdataflowblockbindingslistbindingspanspannonenone)**)→**[None](https://docs.python.org/3/library/constants.html#None) 访问 DataflowBlock。用户可以自定义此函数,在 C++ 端覆盖 VisitBindingBlock_(const DataflowBlockNode block)。 * **参数:block** () :要访问的 DataflowBlock。 -### **visit_var_def_(*var:***[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_var_def_(*var:***[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**)→**[None](https://docs.python.org/3/library/constants.html#None) 访问 relax.Var 定义站点。用户可以自定义此函数,在 C++端覆盖 VisitVarDef_(const VarNode var)。 * **参数:var** () :要访问的 relax.Var。 -### **visit_dataflow_var_def_(*var:***[DataflowVar](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.DataflowVar)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_dataflow_var_def_(*var:***[DataflowVar](/docs/api-reference/python-api/tvm-relax#classtvmrelaxdataflowvarname_hintstridstruct_infostructinfononenonespanspannonenone)**)→**[None](https://docs.python.org/3/library/constants.html#None) 访问 DataflowVar 定义站点。用户可以自定义此函数,在 C++ 端覆盖 VisitVarDef_(const DataflowVarNode var)。 * **参数:var** () :要访问的 DataflowVar。 -### **visit_span(*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_span(*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)**)→**[None](https://docs.python.org/3/library/constants.html#None) 访问 Span。用户可以自定义此函数,在 C++ 端覆盖 VisitSpan(const Span& span)。 * **参数:span** () :要访问的 Span。 -## ***class*tvm.relax.PyExprMutator(*mod:***[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.PyExprMutator(*mod:***[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** 一个抽象的 ExprMutator,在 Python 端具有自定义方法。这是面向用户的用于方法覆盖继承的类。*tvm_metadata* 描述了要继承的类(“cls”)、用户可以覆盖的方法(“methods”)以及构造函数的参数(“fields”)。 @@ -752,7 +753,7 @@ def MyExprMutator(PyExprMutator): ``` -### **visit_expr(*expr:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**)→**[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +### **visit_expr(*expr:***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**)→**[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) Expr 的通用调度程序。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr(const Expr& expr)。 @@ -760,29 +761,29 @@ Expr 的通用调度程序。用户可以自定义此函数,在 C++ 端覆盖 * **返回:** **result**:转换后的 Expr。 * **返回类型:** Expr。 -### **visit_binding(*binding:***[Binding](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Binding)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_binding(*binding:***[Binding](/docs/api-reference/python-api/tvm-relax#classtvmrelaxbinding)**)→**[None](https://docs.python.org/3/library/constants.html#None) 通用的 Binding 调度器。用户可以自定义此函数,在 C++ 端覆盖 VisitBinding(const Binding& binding)。 * **参数:binding** () :要访问的绑定。 -### **visit_binding_block(*block:***[BindingBlock](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.BindingBlock)**)→**[BindingBlock](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.BindingBlock) +### **visit_binding_block(*block:***[BindingBlock](/docs/api-reference/python-api/tvm-relax#classtvmrelaxbindingblockbindingslistbindingspanspannonenone)**)→**[BindingBlock](/docs/api-reference/python-api/tvm-relax#classtvmrelaxbindingblockbindingslistbindingspanspannonenone) BindingBlock 的通用调度器。用户可以自定义此函数,在 C++ 端覆盖 VisitBindingBlock(const BindingBlock& block)。 * **参数:block** () :要访问的块。 * **返回:** **result**:转换后的绑定块。 -* **返回类型:** [BindingBlock](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.BindingBlock)。 +* **返回类型:** [BindingBlock](/docs/api-reference/python-api/tvm-relax#classtvmrelaxbindingblockbindingslistbindingspanspannonenone)。 -### **visit_var_def(*var:***[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)**)→**[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var) +### **visit_var_def(*var:***[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**)→**[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenoner) 用于访问 var 定义点的通用调度器。用户可以自定义此函数,在 C++ 端覆盖 VisitVarDef(const Relax.Var& var)。需要注意的是,visit_var_() 只会访问 Var 的使用点。 * **参数:var** () :要访问的 var。 * **返回:** **result**:后序重写后的 var。 -* **返回类型:** [relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)。 +* **返回类型:** [relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)。 -### **visit_constant_(*op:***[Constant](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Constant)**)→**[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +### **visit_constant_(*op:***[Constant](/docs/api-reference/python-api/tvm-relax#classtvmrelaxconstantdatandarraystruct_infostructinfononenonespanspannonenone)**)→**[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 访问常量。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const ConstantNode op)。 @@ -790,7 +791,7 @@ BindingBlock 的通用调度器。用户可以自定义此函数,在 C++ 端 * **返回:** **result** :转换后的 Expr。 * **返回类型:** Expr。 -### **visit_tuple_(*op:***[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)**)→**[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +### **visit_tuple_(*op:***[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)**)→**[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 访问 Tuple。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const TupleNode op)。 @@ -798,7 +799,7 @@ BindingBlock 的通用调度器。用户可以自定义此函数,在 C++ 端 * **返回:** **result**:转换后的 Expr。 * **返回类型:** Expr。 -### **visit_var_(*op:***[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)**)→**[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +### **visit_var_(*op:***[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**)→**[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 访问变量。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const VarNode op)。 @@ -806,7 +807,7 @@ BindingBlock 的通用调度器。用户可以自定义此函数,在 C++ 端 * **返回:** **result:**转换后的 Expr。 * **返回类型:** Expr。 -### **visit_dataflow_var_(*op:***[DataflowVar](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.DataflowVar)**)→**[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +### **visit_dataflow_var_(*op:***[DataflowVar](/docs/api-reference/python-api/tvm-relax#classtvmrelaxdataflowvarname_hintstridstruct_infostructinfononenonespanspannonenone)**)→**[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 访问 DataflowVar。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const DataflowVarNode op)。 @@ -814,14 +815,14 @@ BindingBlock 的通用调度器。用户可以自定义此函数,在 C++ 端 * **返回:** **result**:转换后的 Expr。 * **返回类型:** Expr。 -### **visit_shape_expr_(*op:***[ShapeExpr](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ShapeExpr)**)→**[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +### **visit_shape_expr_(*op:***[ShapeExpr](/docs/api-reference/python-api/tvm-relax#classtvmrelaxshapeexprvalueslistprimexprtupleprimexprarrayspanspannonenone)**)→**[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 访问 ShapeExpr。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const ShapeExprNode op)。 * **参数:op** () :要访问的 ShapeExpr。 * **返回:** **result**:转换后的 Expr。 * **返回类型:** Expr。 -### **visit_extern_func_(*op:***[ExternFunc](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ExternFunc)**)→**[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +### **visit_extern_func_(*op:***[ExternFunc](/docs/api-reference/python-api/tvm-relax#classtvmrelaxexternfuncglobal_symbolstringstruct_infostructinfononenonespanspannonenone)**)→**[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 访问 ExternFunc。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const ExternFuncNode op)。 @@ -829,7 +830,7 @@ BindingBlock 的通用调度器。用户可以自定义此函数,在 C++ 端 * **返回:** **result**:转换后的 Expr。 * **返回类型:** Expr。 -### **visit_global_var_(*op:***[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar)**)→**[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +### **visit_global_var_(*op:***[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none)**)→**[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 访问 GlobalVar。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const GlobalVarNode op)。 @@ -837,14 +838,14 @@ BindingBlock 的通用调度器。用户可以自定义此函数,在 C++ 端 * **返回:** **result**:转换后的 Expr。 * **返回类型:** Expr。 -### **visit_function_(*op:***[Function](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Function)**)→**[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +### **visit_function_(*op:***[Function](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfunctionparamslistvarbodyrelaxexprret_struct_infostructinfononenoneis_pureboolnonetrueattrsdictattrsnonenonespanspannonenone)**)→**[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 访问函数。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const FunctionNode op)。 * **参数:op** () :要访问的函数。 * **返回:** **result**:转换后的 Expr。 * **返回类型:** Expr。 -### **visit_call_(*op:***[Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call)**)→**[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +### **visit_call_(*op:***[Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone)**)→**[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 访问调用。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const CallNode op)。 @@ -852,7 +853,7 @@ BindingBlock 的通用调度器。用户可以自定义此函数,在 C++ 端 * **返回:** **result**:转换后的 Expr。 * **返回类型:** Expr。 -### **visit_seq_expr_(*op:***[SeqExpr](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.SeqExpr)**)→**[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +### **visit_seq_expr_(*op:***[SeqExpr](/docs/api-reference/python-api/tvm-relax#classtvmrelaxseqexprblockslistbindingblockbodyrelaxexprspanspannonenone)**)→**[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 访问 SeqExpr。用户可以自定义此函数,在 C++端覆盖 VisitExpr_(const SeqExprNode op)。 @@ -860,7 +861,7 @@ BindingBlock 的通用调度器。用户可以自定义此函数,在 C++ 端 * **返回:** **result**:转换后的 Expr。 * **返回类型:** Expr。 -### **visit_if_(*op:***[If](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.If)**)→**[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +### **visit_if_(*op:***[If](/docs/api-reference/python-api/tvm-relax#classtvmrelaxifcondrelaxexprtrue_branchrelaxexprfalse_branchrelaxexprspanspannonenone)**)→**[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 访问 If。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const IfNode op)。 @@ -868,7 +869,7 @@ BindingBlock 的通用调度器。用户可以自定义此函数,在 C++ 端 * **返回:** **result**– 转换后的 Expr。 * **返回类型:** Expr。 -### **visit_op_(*op:***[Op](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Op)**)→**[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +### **visit_op_(*op:***[Op](/docs/api-reference/python-api/tvm-ir#class-tvmirop)**)→**[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 访问 Op。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const OpNode op)。 @@ -876,7 +877,7 @@ BindingBlock 的通用调度器。用户可以自定义此函数,在 C++ 端 * **返回:** **result**:转换后的 Expr。 * **返回类型:** Expr。 -### **visit_tuple_getitem_(*op:***[TupleGetItem](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TupleGetItem)**)→**[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +### **visit_tuple_getitem_(*op:***[TupleGetItem](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplegetitemtuple_valuerelaxexprindexintspanspannonenone)**)→**[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 访问 TupleGetItem。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const TupleGetItemNode op)。 @@ -884,7 +885,7 @@ BindingBlock 的通用调度器。用户可以自定义此函数,在 C++ 端 * **返回:** **result**:转换后的 Expr。 * **返回类型:** Expr。 -### **visit_prim_value_(*op:***[PrimValue](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.PrimValue)**)→**[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +### **visit_prim_value_(*op:***[PrimValue](/docs/api-reference/python-api/tvm-relax#classtvmrelaxprimvaluevalueprimexprintspanspannonenone)**)→**[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 访问 PrimValue。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const PrimValueNode op)。 @@ -892,7 +893,7 @@ BindingBlock 的通用调度器。用户可以自定义此函数,在 C++ 端 * **返回:** **result**:转换后的 Expr。 * **返回类型:** Expr。 -### **visit_string_imm_(*op:***[StringImm](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StringImm)**)→**[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +### **visit_string_imm_(*op:***[StringImm](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstringimmvaluestrspanspannonenone)**)→**[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 访问 StringImm。用户可以自定义此函数,在 C++端覆盖 VisitExpr_(const StringImmNode op)。 @@ -900,66 +901,66 @@ BindingBlock 的通用调度器。用户可以自定义此函数,在 C++ 端 * **返回:** **result**:转换后的 Expr。 * **返回类型:** Expr。 -### **visit_data_type_imm_(*op:***[DataTypeImm](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.DataTypeImm)**)→**[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +### **visit_data_type_imm_(*op:***[DataTypeImm](/docs/api-reference/python-api/tvm-relax#classtvmrelaxdatatypeimmvaluedtypestrspanspannonenone)**)→**[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 访问 DataTypeImm。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr_(const DataTypeImmNode op)。 * **参数:op** () :要访问的 DataTypeImm。 * **返回:** **result**:转换后的 Expr。 * **返回类型:** Expr。 -### **visit_var_binding_(*binding:***[VarBinding](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.VarBinding)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_var_binding_(*binding:***[VarBinding](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarbindingvarvarvaluerelaxexprspanspannonenone)**)→**[None](https://docs.python.org/3/library/constants.html#None) 访问 VarBinding。用户可以自定义此函数,在 C++ 端覆盖 VisitBinding_(const VarBindingNode binding)。 * **参数:binding** () :要访问的 VarBinding。 -### **visit_match_cast_(*binding:***[MatchCast](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.MatchCast)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **visit_match_cast_(*binding:***[MatchCast](/docs/api-reference/python-api/tvm-relax#classtvmrelaxmatchcastvarvarvaluerelaxexprstruct_infostructinfospanspannonenone)**)→**[None](https://docs.python.org/3/library/constants.html#None) 访问 MatchCast。用户可以自定义此函数,在 C++ 端覆盖 VisitBinding_(const MatchCastNode* binding)。 * **参数:binding** () :要访问的 MatchCast。 -### **visit_binding_block_(*block:***[BindingBlock](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.BindingBlock)**)→**[BindingBlock](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.BindingBlock) +### **visit_binding_block_(*block:***[BindingBlock](/docs/api-reference/python-api/tvm-relax#classtvmrelaxbindingblockbindingslistbindingspanspannonenone)**)→**[BindingBlock](/docs/api-reference/python-api/tvm-relax#classtvmrelaxbindingblockbindingslistbindingspanspannonenone) 访问 BindingBlock。用户可以自定义此函数,在 C++端覆盖 VisitBlock_(const BindingBlockNode block)。 * **参数:block** () :要访问的 BindingBlock。 * **返回:** **result**:转换后的绑定块。 -* **返回类型:** [BindingBlock](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.BindingBlock)。 +* **返回类型:** [BindingBlock](/docs/api-reference/python-api/tvm-relax#classtvmrelaxbindingblockbindingslistbindingspanspannonenone)。 -### **visit_dataflow_block_(*block:***[DataflowBlock](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.DataflowBlock)**)→**[BindingBlock](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.BindingBlock) +### **visit_dataflow_block_(*block:***[DataflowBlock](/docs/api-reference/python-api/tvm-relax#classtvmrelaxdataflowblockbindingslistbindingspanspannonenone)**)→**[BindingBlock](/docs/api-reference/python-api/tvm-relax#classtvmrelaxbindingblockbindingslistbindingspanspannonenon) 访问 DataflowBlock。用户可以自定义此函数,在 C++ 端覆盖 VisitBindingBlock_(const DataflowBlockNode block)。 * **参数:block** () :要访问的 DataflowBlock。 * **返回:** **result**:转换后的绑定块。 -* **返回类型:** [BindingBlock](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.BindingBlock)。 +* **返回类型:** [BindingBlock](/docs/api-reference/python-api/tvm-relax#classtvmrelaxbindingblockbindingslistbindingspanspannonenon)。 -### **visit_var_def_(*var:***[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)**)→**[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var) +### **visit_var_def_(*var:***[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**)→**[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone) 访问 relax.Var 定义站点。用户可以自定义此函数,在 C++端覆盖 VisitVarDef_(const VarNode var)。 * **参数:var** () :要访问的 relax.Var。 * **返回:** **result**:后序重写后的 var。 -* **返回类型:** [relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)。 +* **返回类型:** [relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)。 -### **visit_dataflow_var_def_(*var:***[DataflowVar](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.DataflowVar)**)→**[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var) +### **visit_dataflow_var_def_(*var:***[DataflowVar](/docs/api-reference/python-api/tvm-relax#classtvmrelaxdataflowblockbindingslistbindingspanspannonenone)**)→**[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone) 访问 DataflowVar 定义站点。用户可以自定义此函数,在 C++ 端覆盖 VisitVarDef_(const DataflowVarNode var)。 * **参数:var** () :要访问的 DataflowVar。 * **返回:** **result**:后序重写后的 var。 -* **返回类型:** [relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)。 +* **返回类型:** [relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)。 -### **visit_span(*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)**)→**[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span) +### **visit_span(*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)**)→**[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column) 访问 Span。用户可以自定义此函数,在 C++ 端覆盖 VisitSpan(const Span& span)。 * **参数:span** ():要访问的 Span。 * **返回:** **result**:转换后的跨度。 -* **返回类型:** [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)。 +* **返回类型:** [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)。 -### **visit_expr_post_order(*expr:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**)→**[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +### **visit_expr_post_order(*expr:***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**)→**[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 按后序重写 Expr 并进行规范化。 @@ -967,45 +968,45 @@ BindingBlock 的通用调度器。用户可以自定义此函数,在 C++ 端 * **返回:** **result**:后序重写后的 Expr。 * **返回类型:** Expr。 -### **set_var_remap(*vid:***[Id](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Id)**,*var:***[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **set_var_remap(*vid:***[Id](/docs/api-reference/python-api/tvm-relax#classtvmrelaxid)**,*var:***[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**)→**[None](https://docs.python.org/3/library/constants.html#None) 在使用站点中将 var 重新映射到新的 var。 * **参数:vid** ():旧变量的 vid。 * **var** ():新的 var。 -### **get_var_remap(*vid:***[Id](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Id)**)→**[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var) +### **get_var_remap(*vid:***[Id](/docs/api-reference/python-api/tvm-relax#classtvmrelaxid)**)→**[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone) 在使用站点中将 var 重新映射到新的 var。 * **参数:vid** ():旧 var 的 vid。 * **返回:** **var**:重新映射的 var。 -* **返回类型:** [relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)。 +* **返回类型:** [relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)。 -### **visit_with_new_scope(*expr:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**)→**[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +### **visit_with_new_scope(*expr:***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**)→**[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 用新的作用域重写 expr,用于函数主体和 If 的分支。 * **参数:expr** (*Expr*):要访问的 expr。 * **返回:** **var**:访问后的表达式。 -* **返回类型:** [relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)。 +* **返回类型:** [relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)。 -### **lookup_binding(*var:***[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)**)→**[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**|**[None](https://docs.python.org/3/library/constants.html#None) +### **lookup_binding(*var:***[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**)→**[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**|**[None](https://docs.python.org/3/library/constants.html#None) 查找绑定到变量的值。注意:对于函数参数,此函数返回 std::nullopt。 * **参数:var** ():要查找的变量。 * **返回:** **var**:绑定到输入变量的值。 -* **返回类型:** [relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var) +* **返回类型:** [relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)。 -### **with_struct_info(*var:***[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)**,*struct_info:***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)**)→**[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var) +### **with_struct_info(*var:***[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**,*struct_info:***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)**)→**[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone) 如果原始变量的形状或类型与指定的形状或类型不匹配,则创建一个具有指定形状和类型的新变量。 * **参数:var** ():要更新的变量。 * **struct_info** ():结构信息。 * **返回:** **var**:填充有形状和类型的 var。 -* **返回类型:** [relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)。 +* **返回类型:** [relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)。 ## ***class*tvm.relax.StructInfo** @@ -1020,7 +1021,7 @@ StructInfo 包含静态类型和运行时结构信息。 结构平等导致超载。 -### **is_base_of(*derived:***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)**)→**[bool](https://docs.python.org/3/library/functions.html#bool) +### **is_base_of(*derived:***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)**)→**[bool](https://docs.python.org/3/library/functions.html#bool) 检查自身是否是另一个派生结构信息的基础。 @@ -1028,29 +1029,29 @@ StructInfo 包含静态类型和运行时结构信息。 * **返回:** **result**:检查结果。 * **返回类型:** [bool](https://docs.python.org/3/library/functions.html#bool)。 -## ***class*tvm.relax.ObjectStructInfo(*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.ObjectStructInfo(*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** 对象的 StructInfo。 -## ***class*tvm.relax.PrimStructInfo(*dtype:***[str](https://docs.python.org/3/library/stdtypes.html#str)***| dtype |***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*value:***[int](https://docs.python.org/3/library/functions.html#int)***|***[float](https://docs.python.org/3/library/functions.html#float)***|***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.PrimStructInfo(*dtype:***[str](https://docs.python.org/3/library/stdtypes.html#str)***| dtype |***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*value:***[int](https://docs.python.org/3/library/functions.html#int)***|***[float](https://docs.python.org/3/library/functions.html#float)***|***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** 原始 POD 值的结构信息。 * **参数:dtype_or_expr** (Union[, DataType, ]):原始值的数据类型,或原始值的已知表达式。 -## ***class*tvm.relax.ShapeStructInfo(*values:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)***] |***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*ndim:***[int](https://docs.python.org/3/library/functions.html#int)***= -1*,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.ShapeStructInfo(*values:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)***] |***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*ndim:***[int](https://docs.python.org/3/library/functions.html#int)***= -1*,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** 形状值的结构信息。 * **参数:values** (*O*ptional[**List**[]]):如果已知,则为符号形状值。 * **ndim** (Optional[]):形状的大小。 -:::Note +:::note 不要同时指定值和 ndim。 ::: -## ***class*tvm.relax.TensorStructInfo(*shape:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)***|***[None](https://docs.python.org/3/library/constants.html#None)***|***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)***] = None*,*dtype:***[str](https://docs.python.org/3/library/stdtypes.html#str)***= 'float32'*,*vdevice:***[VDevice](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.VDevice)***|***[None](https://docs.python.org/3/library/constants.html#None)***|***[str](https://docs.python.org/3/library/stdtypes.html#str)***= None*,*ndim:***[int](https://docs.python.org/3/library/functions.html#int)***= -1*,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.TensorStructInfo(*shape:***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)***|***[None](https://docs.python.org/3/library/constants.html#None)***|***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)***] = None*,*dtype:***[str](https://docs.python.org/3/library/stdtypes.html#str)***= 'float32'*,*vdevice:***[VDevice](/docs/api-reference/python-api/tvm-ir#class-tvmirvdevicetargetnone-vdevice_idint-0-memory_scopestr-global)***|***[None](https://docs.python.org/3/library/constants.html#None)***|***[str](https://docs.python.org/3/library/stdtypes.html#str)***= None*,*ndim:***[int](https://docs.python.org/3/library/functions.html#int)***= -1*,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** 张量值的结构信息。 @@ -1059,18 +1060,18 @@ StructInfo 包含静态类型和运行时结构信息。 * **vdevice** (Optional[**Vdevice**]):虚拟设备。 * **ndim** (Optional[]):张量的维数。 -:::Note +:::note 不要同时指定 shape 和 ndim。 ::: -## ***class*tvm.relax.TupleStructInfo(*fields:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)***]*,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.TupleStructInfo(*fields:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)***]*,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** Tuple 值的 StructInfo。 * **参数:fields** (List[]):字段的结构信息。 -## ***class*tvm.relax.FuncStructInfo(*params:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)***]*,*ret:***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)**,*purity:***[bool](https://docs.python.org/3/library/functions.html#bool)***= True*,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** +## ***class*tvm.relax.FuncStructInfo(*params:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)***]*,*ret:***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)**,*purity:***[bool](https://docs.python.org/3/library/functions.html#bool)***= True*,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)** 函数值的结构信息。 @@ -1079,7 +1080,7 @@ Tuple 值的 StructInfo。 * **ret** ():返回值的结构信息。 * **purity** ():函数是否纯(没有可见的副作用)。注意:只有当函数对所有输入都为纯函数时,我们才认为它是纯函数。如果函数仅在某些情况下才有可见的副作用,我们仍然认为它是非纯函数。 -### ***static*opaque_func(***,*ret:***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*derive_func:***[str](https://docs.python.org/3/library/stdtypes.html#str)***|***[EnvFunc](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.EnvFunc)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*purity:***[bool](https://docs.python.org/3/library/functions.html#bool)***= False*,*span:***[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)→**[FuncStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.FuncStructInfo) +### ***static*opaque_func(***,*ret:***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*derive_func:***[str](https://docs.python.org/3/library/stdtypes.html#str)***|***[EnvFunc](/docs/api-reference/python-api/tvm-ir#class-tvmirenvfunc)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*purity:***[bool](https://docs.python.org/3/library/functions.html#bool)***= False*,*span:***[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)→**[FuncStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfuncstructinfoparamsliststructinforetstructinfopuritybooltruespanspannonenone) 创建一个不透明的 FuncStructInfo。 @@ -1090,7 +1091,7 @@ Tuple 值的 StructInfo。 * **purity** ():函数是否纯(默认为 false,因为大多数不透明函数都不是纯函数)。 * **span** (Optional[]):ast 的可选跨度信息。 * **返回:** **info。** -* **返回类型:** [FuncStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.FuncStructInfo)。 +* **返回类型:** [FuncStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfuncstructinfoparamsliststructinforetstructinfopuritybooltruespanspannonenone)。 :::note @@ -1099,20 +1100,20 @@ Tuple 值的 StructInfo。 ::: -## **tvm.relax.get_default_pipeline(*target:***[Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target)**)** +## **tvm.relax.get_default_pipeline(*target:***[Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone)**)** 获取给定目标的默认 Relax 编译管道。 -## **tvm.relax.get_pipeline(*name:***[str](https://docs.python.org/3/library/stdtypes.html#str)***= 'zero'*,***kwargs*)→**[Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## **tvm.relax.get_pipeline(*name:***[str](https://docs.python.org/3/library/stdtypes.html#str)***= 'zero'*,***kwargs*)→**[Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 按名称获取预构建管道。 * **参数:** * **name** (Optional[]):管道的名称。 * **kwargs** (Dict[, ])**:** 用于配置管道的关键字参数。 -* **返回:** **pipeline**[:](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)转换管道。 -* **返回类型:** [tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回:** **pipeline**:转换管道。 +* **返回类型:** [tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## **tvm.relax.register_pipeline(*name:***[str](https://docs.python.org/3/library/stdtypes.html#str)**)** @@ -1120,7 +1121,7 @@ Tuple 值的 StructInfo。 注册新管道。 * **参数:name** ()**:**管道的名称 -## **tvm.relax.convert_to_expr(*value:***[Any](https://docs.python.org/3/library/typing.html#typing.Any)**)→**[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## **tvm.relax.convert_to_expr(*value:***[Any](https://docs.python.org/3/library/typing.html#typing.Any)**)→**[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 辅助函数将输入转换为 Expr,遵循以下规则:1. 如果输入已经是 Relax.Expr ,则返回输入本身;2.如果输入是 PrimExpr ,则返回 Relax.PrimValue;3.如果输入是 tvm.String 或 str ,则返回 Relax.StringImm;4.如果输入是 Expr 的元组/列表,则返回 Relax.Tuple。 @@ -1129,7 +1130,7 @@ Tuple 值的 StructInfo。 1. tvm.tir.StringImm 因歧义而不被允许,它可以是 Relax.StringImm 或 Relax.PrimValue。 -## **tvm.relax.build(*mod:***[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)**,*target:***[Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target)***|***[str](https://docs.python.org/3/library/stdtypes.html#str)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*params:***[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)***[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,***[list](https://docs.python.org/3/library/stdtypes.html#list)***] |***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*relax_pipeline:***[None](https://docs.python.org/3/library/constants.html#None)***|***[str](https://docs.python.org/3/library/stdtypes.html#str)***|***[Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)***= 'default'*,*tir_pipeline:***[None](https://docs.python.org/3/library/constants.html#None)***|***[str](https://docs.python.org/3/library/stdtypes.html#str)***|***[Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)***= 'default'*,*exec_mode:***[str](https://docs.python.org/3/library/stdtypes.html#str)***= 'bytecode'*,***,*system_lib:***[bool](https://docs.python.org/3/library/functions.html#bool)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)→ Executable** +## **tvm.relax.build(*mod:***[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)**,*target:***[Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone)***|***[str](https://docs.python.org/3/library/stdtypes.html#str)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*params:***[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)***[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,***[list](https://docs.python.org/3/library/stdtypes.html#list)***] |***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*relax_pipeline:***[None](https://docs.python.org/3/library/constants.html#None)***|***[str](https://docs.python.org/3/library/stdtypes.html#str)***|***[Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)***= 'default'*,*tir_pipeline:***[None](https://docs.python.org/3/library/constants.html#None)***|***[str](https://docs.python.org/3/library/stdtypes.html#str)***|***[Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)***= 'default'*,*exec_mode:***[str](https://docs.python.org/3/library/stdtypes.html#str)***= 'bytecode'*,***,*system_lib:***[bool](https://docs.python.org/3/library/functions.html#bool)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)→ Executable** 构建一个 IRModule 到 VM 可执行文件。 @@ -1180,24 +1181,24 @@ VM 编译器或 ExecBuilder 发出的虚拟机可执行对象。 将指令打印为 python 程序。 -## ***class*tvm.relax.DataflowBlockRewrite(*dfb:***[DataflowBlock](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.DataflowBlock)**,*root_fn:***[Function](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Function)**)** +## ***class*tvm.relax.DataflowBlockRewrite(*dfb:***[DataflowBlock](/docs/api-reference/python-api/tvm-relax#classtvmrelaxdataflowblockbindingslistbindingspanspannonenone)**,*root_fn:***[Function](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfunctionparamslistvarbodyrelaxexprret_struct_infostructinfononenoneis_pureboolnonetrueattrsdictattrsnonenonespanspannonenone)**)** 一个绑定/语句级数据流块重写器。 -:::Note +:::note 由于 TVM AST 节点的不可变性和写时复制特性,重写并非就地完成。相反,会创建一个新的 DataflowBlock,并通过 mutated_dfb 返回。同样,其新的根函数也会由 mutated_root_fn 创建并返回。要将此更改应用于 IRModule,请使用 mutate_irmodule 重写构造函数中注册的旧函数。 -### **replace_all_uses(*old_var:***[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)**,*new_var:***[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **replace_all_uses(*old_var:***[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**,*new_var:***[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**)→**[None](https://docs.python.org/3/library/constants.html#None) 将所有 old_var 替换为 new_var。 * **参数:old_var** ()**:** 要替换的旧变量。 * **new_var** ()**:** 要替换的新变量。 -### **add(*expr:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**,*name:***[str](https://docs.python.org/3/library/stdtypes.html#str)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*is_dfvar:***[bool](https://docs.python.org/3/library/functions.html#bool)***= False*)→**[None](https://docs.python.org/3/library/constants.html#None) +### **add(*expr:***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**,*name:***[str](https://docs.python.org/3/library/stdtypes.html#str)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*is_dfvar:***[bool](https://docs.python.org/3/library/functions.html#bool)***= False*)→**[None](https://docs.python.org/3/library/constants.html#None) 使用自动生成的变量名向 DataflowBlock 添加新语句。 @@ -1207,12 +1208,12 @@ VM 编译器或 ExecBuilder 发出的虚拟机可执行对象。 * **is_dfvar** (, optional):变量类型,默认为 False。 -:::Note +:::note 如果未指定变量名,则会自动生成“tmp$”形式的变量。如果 is_dfvar 为 True,则变量类型为 DataflowVar,否则为 Var。relax.Var 表示变量是 DataflowBlock 的输出变量,而 DataflowVar 表示变量是 DataflowBlock 的内部变量。 -### **remove_unused(*var:***[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)**,*allow_undef=False*)→**[None](https://docs.python.org/3/library/constants.html#None) +### **remove_unused(*var:***[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**,*allow_undef=False*)→**[None](https://docs.python.org/3/library/constants.html#None) 当且仅当语句未使用时,才通过其变量定义删除该语句。 @@ -1232,17 +1233,17 @@ VM 编译器或 ExecBuilder 发出的虚拟机可执行对象。 这也可以删除其他 DataflowBlocks 中未使用的变量。 -### **mutated_dfb()→**[DataflowBlock](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.DataflowBlock) +### **mutated_dfb()→**[DataflowBlock](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfunctionparamslistvarbodyrelaxexprret_struct_infostructinfononenoneis_pureboolnonetrueattrsdictattrsnonenonespanspannonenone) 返回转换的 DataflowBlock。 -### **mutated_root_fn()→**[Function](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Function) +### **mutated_root_fn()→**[Function](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfunctionparamslistvarbodyrelaxexprret_struct_infostructinfononenoneis_pureboolnonetrueattrsdictattrsnonenonespanspannonenone) 返回转换的根函数。 -### **mutate_irmodule(*irmodule:***[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)**)→**[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule) +### **mutate_irmodule(*irmodule:***[IRModule](h/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)**)→**[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone) 通过用转换的根函数替换旧函数来返回更新的 IRModule。 diff --git a/docs/04-api-reference/01-python-api/12-tvm-relax-analysis.md b/docs/04-api-reference/01-python-api/12-tvm-relax-analysis.md index e803442..2570ef7 100644 --- a/docs/04-api-reference/01-python-api/12-tvm-relax-analysis.md +++ b/docs/04-api-reference/01-python-api/12-tvm-relax-analysis.md @@ -1,6 +1,6 @@ --- -title: tvm.relax.分析 +title: tvm.relax.analysis --- @@ -12,7 +12,7 @@ Relax IR 分析。 返回细粒度基础检查的结果。 -:::Note +:::note 基本检查带有细粒度的失败级别。 * FAIL_L0:lhs 和 rhs 根本没有交集。 @@ -21,28 +21,28 @@ Relax IR 分析。 ::: -## **tvm.relax.analysis.all_global_vars(*expr:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**)→**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar)**]** +## **tvm.relax.analysis.all_global_vars(*expr:***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**)→**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none)**]** 返回表达式 expr 中的所有全局变量。:param expr: 表达式。:type expr: Expr * **返回:** **ret**:expr 中的全局变量列表,按 DFS 后顺序排列。 -* **返回类型:** List[[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar)] +* **返回类型:** List[[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none)] -## **tvm.relax.analysis.all_vars(*expr:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**)→**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)**]** +## **tvm.relax.analysis.all_vars(*expr:***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**)→**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**]** 返回表达式 expr 中的所有(局部)变量。:param expr: 表达式。:type expr: Expr * **返回:** **ret**:expr 中的变量列表,按 DFS 后顺序排列。 -* **返回类型:** List[[relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)]。 +* **返回类型:** List[[relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)]。 -## **tvm.relax.analysis.bound_vars(*expr:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**)→**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)**]** +## **tvm.relax.analysis.bound_vars(*expr:***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**)→**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**]** 返回表达式 expr 中的所有绑定变量。绑定变量是指所有在 expr 中声明的变量。它们仅在该 expr 内部有意义,并且只能在该 expr 中使用。:param expr: 表达式。:type expr: Expr * **返回:** **ret**:expr 中绑定变量的列表,按 DFS 后顺序排列。 -* **返回类型:** List[[relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)]。 +* **返回类型:** List[[relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)]。 -## **tvm.relax.analysis.collect_non_negative_expressions(*sinfo:***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)**)→**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)**]** +## **tvm.relax.analysis.collect_non_negative_expressions(*sinfo:***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)**)→**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)**]** 收集非负面语境中使用的 TIR 表达式。 @@ -54,9 +54,9 @@ Relax IR 分析。 返回的列表已去重:每个 TIR 表达式最多出现一次。列表的顺序与结构体 info 中的出现顺序一致。 * **参数:sinfo** ():要分析的结构信息对象。 * **返回:** **ret**:可以从 StructInfo 定义的 TIR 变量列表。 -* **返回类型:** List[[tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)]。 +* **返回类型:** List[[tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)]。 -## **tvm.relax.analysis.computable_at_compile_time(*func:***[Function](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Function)**)→**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)**]** +## **tvm.relax.analysis.computable_at_compile_time(*func:***[Function](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfunctionparamslistvarbodyrelaxexprret_struct_infostructinfononenoneis_pureboolnonetrueattrsdictattrsnonenonespanspannonenone)**)→**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**]** 收集可以在编译时计算值的变量。 @@ -65,9 +65,9 @@ Relax IR 分析。 如果函数具有 kNumInput 属性,则前 kNumInput 个参数在运行时提供,而所有剩余参数可能在编译时已知。此实用程序会收集所有仅直接或间接依赖于编译时已知参数的变量绑定。 * **参数:func** ():要分析的 Relax.Function。 * **返回:** **ret**:可以在编译时计算的变量集,按照它们在函数中出现的顺序排列。 -* **返回类型:** List[[relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)] +* **返回类型:** List[[relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)] -## **tvm.relax.analysis.contains_impure_call(*expr:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**,*own_name:***[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)***|***[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)→**[bool](https://docs.python.org/3/library/functions.html#bool) +## **tvm.relax.analysis.contains_impure_call(*expr:***[RelaxExpr]((/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**,*own_name:***[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)***|***[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none)***|***[None](https://docs.python.org/3/library/constants.html#None)***= None*)→**[bool](https://docs.python.org/3/library/functions.html#bool) 检查给定的表达式(可能是函数体)是否包含任何不纯调用。 * **参数:** @@ -80,22 +80,22 @@ Relax IR 分析。 依赖于 StructInfo 注解,因此请确保模块已先进行规范化。此外,嵌套*函数中的非纯调用并不意味着*外部表达式包含非纯调用——只有当嵌套函数*稍后被调用时*,才意味着外部表达式包含非纯调用。 -## **tvm.relax.analysis.definable_tir_vars_in_struct_info(*sinfo:***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)**)→**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)**]** +## **tvm.relax.analysis.definable_tir_vars_in_struct_info(*sinfo:***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)**)→**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**]** 从输入结构体信息中获取可能定义的 TIR 变量。返回的列表已去重 - 每个 TIR 变量最多出现一次。 * **参数:sinfo** ():要分析的结构信息对象。 * **返回:** **ret**:可以从 StructInfo 定义的 TIR 变量列表。 -* **返回类型:** List[[tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)]。 +* **返回类型:** List[[tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)]。 -## **tvm.relax.analysis.defined_symbolic_vars(*func:***[Function](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Function)**)→**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)**]** +## **tvm.relax.analysis.defined_symbolic_vars(*func:***[Function](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfunctionparamslistvarbodyrelaxexprret_struct_infostructinfononenoneis_pureboolnonetrueattrsdictattrsnonenonespanspannonenone)**)→**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**]** 获取输入函数中定义的 TIR 变量。返回的列表已去重 - 每个 TIR 变量最多出现一次。 * **参数:func** ():要分析的函数对象。 * **返回:** **ret**:输入函数中定义的符号变量列表。 -* **返回类型:** List[[relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)]。 +* **返回类型:** List[[relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)]。 -## **tvm.relax.analysis.derive_call_ret_struct_info(*func_sinfo:***[FuncStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.FuncStructInfo)**,*call:***[Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call)**,*ctx:***[BlockBuilder](https://tvm.apache.org/docs/reference/api/python/relax/block_builder.html#tvm.relax.block_builder.BlockBuilder)**)→**[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo) +## **tvm.relax.analysis.derive_call_ret_struct_info(*func_sinfo:***[FuncStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfuncstructinfoparamsliststructinforetstructinfopuritybooltruespanspannonenone)**,*call:***[Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone)**,*ctx:***[BlockBuilder](/docs/api-reference/python-api/tvm-relax_block_builder#class-tvmrelaxblock_builderblockbuildermodirmodulenone-none)**)→**[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo) 从输入中获取调用的 ret 值结构信息。 @@ -104,15 +104,15 @@ Relax IR 分析。 * **call** ():调用表达式。 * **ctx** (tvm.relax.BlockBuilder):上下文块构建器。 * **返回:** **ret**:派生的返回值结构信息。 -* **返回类型:** [StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)。 +* **返回类型:** [StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)。 -:::Note +:::note 这是一个内部派生函数,在这种情况下,call.op 字段被忽略,并且派生仅依赖于 func_sinfo。 ::: -## **tvm.relax.analysis.detect_recursion(*mod:***[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)**)→**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar)**]]** +## **tvm.relax.analysis.detect_recursion(*mod:***[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)**)→**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-non)**]]** 查找模块中所有递归或相互递归函数集。 @@ -127,9 +127,9 @@ Relax IR 分析。 如果一个函数只是递归的,而不是与任何其他函数相互递归的,那么它将被报告为一个单独的组。 * **参数:mod** (*The module*)。 * **返回:** **ret**:列表中的每个成员都是一个全局函数列表,这些函数相互递归引用。如果一个函数只是递归函数,且不与其他函数互相递归,那么它将是此列表中的单例函数。 -* **返回类型:** List[List[[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar)]]。 +* **返回类型:** List[List[[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-non)]]。 -## **tvm.relax.analysis.erase_to_well_defined(*sinfo:***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)**,*shape_var_map:***[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)***[***[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)***,***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)***] |***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*var_map:***[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)***[***[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)***,***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)***] |***[None](https://docs.python.org/3/library/constants.html#None)***= None*)→**[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo) +## **tvm.relax.analysis.erase_to_well_defined(*sinfo:***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)**,*shape_var_map:***[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)***[***[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)***,***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)***] |***[None](https://docs.python.org/3/library/constants.html#None)***= None*,*var_map:***[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)***[***[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)***,***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)***] |***[None](https://docs.python.org/3/library/constants.html#None)***= None*)→**[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo) 将 sinfo 擦除为明确定义的形式。 @@ -141,40 +141,40 @@ Relax IR 分析。 * **shape_var_map** (Dict[, tir.PrimExpr]):指定定义的形状变量及其应映射到的值。 * **var_map** (Dict[, Expr]):指定定义的变量及其应映射到的值。 * **返回:** **ret**:相应的已擦除结构信息。 -* **返回类型:** [StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)。 +* **返回类型:** [StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)。 -## **tvm.relax.analysis.free_symbolic_vars(*func:***[Function](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Function)**)→**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)**]** +## **tvm.relax.analysis.free_symbolic_vars(*func:***[Function](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfunctionparamslistvarbodyrelaxexprret_struct_infostructinfononenoneis_pureboolnonetrueattrsdictattrsnonenonespanspannonenone)**)→**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**]** 获取输入函数中使用但未定义的 TIR 变量。返回的列表已去重:每个 TIR 变量最多出现一次。 * **参数:func** ():要分析的函数对象。 * **返回:** **ret**:在输入函数中使用但未定义的符号变量列表。 -* **返回类型:** List[[relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)]。 +* **返回类型:** List[[relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)]。 -## **tvm.relax.analysis.free_vars(*expr:***[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**)→**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)**]** +## **tvm.relax.analysis.free_vars(*expr:***[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**)→**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**]** 返回表达式 expr 中的所有自由变量。自由变量是指表达式中未受 VarBinding 或函数参数绑定的变量。:param expr: 表达式。:type expr: Expr * **返回:** **ret**:expr 中的自由变量列表,按 DFS 后顺序排列。 -* **返回类型:** List[[relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)]。 +* **返回类型:** List[[relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)]。 -## **tvm.relax.analysis.get_static_type(*sinfo:***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)**)→**[Type](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Type) +## **tvm.relax.analysis.get_static_type(*sinfo:***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)**)→**[Type](/docs/api-reference/python-api/tvm-ir#class-tvmirtype) 从 StructInfo 中获取相应的静态类型。 * **参数:sinfo** ():输入结构信息。 * **返回:** **ret:**相应的静态类型。 -* **返回类型:** [Type](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Type)。 +* **返回类型:** [Type](/docs/api-reference/python-api/tvm-ir#class-tvmirtype)。 -## **tvm.relax.analysis.get_var2val(*func:***[Function](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Function)**)→**[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)**[**[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)**,**[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)**]**[](https://tvm.apache.org/docs/reference/api/python/relax/analysis.html#tvm.relax.analysis.get_var2val) +## **tvm.relax.analysis.get_var2val(*func:***[Function](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfunctionparamslistvarbodyrelaxexprret_struct_infostructinfononenoneis_pureboolnonetrueattrsdictattrsnonenonespanspannonenone)**)→**[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)**[**[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**,**[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)**]** 为函数中的每个变量获取从 Relax.Var 到 Expr 的映射。 * **参数:func** ():要分析的输入函数。 * **返回:** A mapping from relax.Var to Expr。 -* **返回类型:** Dict[[relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var), Expr]。 +* **返回类型:** Dict[[relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone), Expr]。 -## **tvm.relax.analysis.has_reshape_pattern(*func:***[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)**)→**[bool](https://docs.python.org/3/library/functions.html#bool) +## **tvm.relax.analysis.has_reshape_pattern(*func:***[PrimFunc](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)**)→**[bool](https://docs.python.org/3/library/functions.html#bool) 检查给定的 PrimFunc 是否本质上执行了重塑操作。重塑操作还包括 expand_dims、squeeze、flatten 等。 @@ -191,7 +191,7 @@ Relax IR 分析。 根据上面的描述,返回的结果只能是假阴性,而不能是假阳性,因为只要我们无法证明相等性,我们就会返回 false。此属性保证了该函数的安全性。 -## **tvm.relax.analysis.name_to_binding(*func:***[Function](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Function)**)→**[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)**[**[str](https://docs.python.org/3/library/stdtypes.html#str)**,**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[Binding](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Binding)**]]** +## **tvm.relax.analysis.name_to_binding(*func:***[Function](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfunctionparamslistvarbodyrelaxexprret_struct_infostructinfononenoneis_pureboolnonetrueattrsdictattrsnonenonespanspannonenone)**)→**[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)**[**[str](https://docs.python.org/3/library/stdtypes.html#str)**,**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[Binding](/docs/api-reference/python-api/tvm-relax#classtvmrelaxbinding)**]]** 返回从变量名到其绑定的映射。 @@ -204,7 +204,7 @@ Relax IR 分析。 * **expr** (*tvm.relax.Expr*):输入表达式。 * **fvisit** (*function*)**:** 要应用的访问者函数。 -## **tvm.relax.analysis.remove_all_unused(*func:***[Function](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Function)**)→**[Function](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Function) +## **tvm.relax.analysis.remove_all_unused(*func:***[Function](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfunctionparamslistvarbodyrelaxexprret_struct_infostructinfononenoneis_pureboolnonetrueattrsdictattrsnonenonespanspannonenone)**)→**[Function](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfunctionparamslistvarbodyrelaxexprret_struct_infostructinfononenoneis_pureboolnonetrueattrsdictattrsnonenonespanspannonenone) 它会删除:1. DataflowBlock 中未使用的本地 VarBindings。2. 函数中未使用的 DataflowBlocks。 @@ -216,9 +216,9 @@ Relax IR 分析。 对于 IRModule-wise DCE,使用 py:func: tvm.relax.transform.DeadCodeElimination。 * **返回:** 移除了未使用变量的函数。 -* **返回类型:** [Function](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Function) +* **返回类型:** [Function](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfunctionparamslistvarbodyrelaxexprret_struct_infostructinfononenoneis_pureboolnonetrueattrsdictattrsnonenonespanspannonenone) -## **tvm.relax.analysis.struct_info_base_check(*base:***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)**,*derived:***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)**)→**[BaseCheckResult](https://tvm.apache.org/docs/reference/api/python/relax/analysis.html#tvm.relax.analysis.BaseCheckResult) +## **tvm.relax.analysis.struct_info_base_check(*base:***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)**,*derived:***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)**)→**[BaseCheckResult](/docs/api-reference/python-api/tvm-relax-analysis#classtvmrelaxanalysisbasecheckresultvalue) 运行基础检查来查看基础是否包含派生。 @@ -226,19 +226,19 @@ Relax IR 分析。 * **base** ():基本结构信息。 * **derived** ():派生的结构信息。 * **返回:** **ret:** 派生的返回值结构信息。 -* **返回类型:** [StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)。 +* **返回类型:** [StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)。 -## **tvm.relax.analysis.struct_info_lca(*lhs:***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)**,*rhs:***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)**)→**[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo) +## **tvm.relax.analysis.struct_info_lca(*lhs:***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)**,*rhs:***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)**)→**[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo) 将两个结构信息统一到它们最近的祖先。 * **参数:** - * **lhs** ()[:](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)左操作数。 + * **lhs** ()[:](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)左操作数。 * **rhs** ()**:** 右操作数。 * **返回:** **ret:** 相应的 lca 结果。 -* **返回类型:** [StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)。 +* **返回类型:** [StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)。 -## **tvm.relax.analysis.suggest_layout_transforms(*func:***[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)**,*write_buffer_transforms:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap)***|***[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)***]*)→**[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)**[**[Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block)**,**[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)**[**[Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block)**|**[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)**,**[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap)**]]** +## **tvm.relax.analysis.suggest_layout_transforms(*func:***[PrimFunc](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)**,*write_buffer_transforms:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map)***|***[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)***]*)→**[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)**[**[Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none)**,**[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)**[**[Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none)**|**[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)**,**[IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map)**]]** 建议在 PrimFunc 中对块和缓冲区进行布局转换。 @@ -246,25 +246,25 @@ Relax IR 分析。 * **func** ():将对其执行分析并建议转换的 PrimFunc。 * **write_buffer_transforms** (List[**Union**[, Callable]):输出缓冲区的布局转换列表。布局转换的数量必须与 PrimFunc 的输出数量匹配。 * **返回:** **ret**: func 中每个块的建议转换。对于每个块,返回的值是从对象(块或缓冲区)到其索引映射转换的映射。 -* **返回类型:** Dict[[Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block), Dict[Union[[Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block), [Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)], [IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap)]] +* **返回类型:** Dict[[Block](ttps://tvm.hyper.ai/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none), Dict[Union[[Block](ttps://tvm.hyper.ai/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none), [Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)], [IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map)]] -## **tvm.relax.analysis.tir_vars_in_struct_info(*sinfo:***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)**)→**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)**]** +## **tvm.relax.analysis.tir_vars_in_struct_info(*sinfo:***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)**)→**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**]** 获取输入结构体信息中出现的 TIR 变量。返回的列表已去重 - 每个 TIR 变量最多出现一次。 * **参数:sinfo** ()**:** 要分析的结构信息对象。 * **返回:** **ret:** 输入结构信息中出现的 TIR 变量列表。 -* **返回类型:** List[[tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)] +* **返回类型:** List[[tir.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)] -## **tvm.relax.analysis.tir_vars_in_struct_info(*sinfo:***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)**)→**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)**]** +## **tvm.relax.analysis.tir_vars_in_struct_info(*sinfo:***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)**)→**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**]** 分析数据流块中的变量 use-def 链。 -* **参数:dfb** ()[:](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)要分析的数据流块。 +* **参数:dfb** ()[:](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)要分析的数据流块。 * **返回:** A mapping from variable definition to its uses. -* **返回类型:** Dict[[relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var), List[[relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)]] +* **返回类型:** Dict[[relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone), List[[relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)]] -## **tvm.relax.analysis.udchain(*dfb:***[DataflowBlock](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.DataflowBlock)**)→**[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)**[**[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)**,**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)**]]** +## **tvm.relax.analysis.udchain(*dfb:***[DataflowBlock](/docs/api-reference/python-api/tvm-relax#classtvmrelaxdataflowblockbindingslistbindingspanspannonenone)**)→**[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)**[**[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**,**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**]]** 检查 IRModule 是否格式正确。 * **参数:** @@ -277,7 +277,7 @@ Relax IR 分析。 默认情况下,始终会检查结构信息。只有在测试用例中,check_struct_info 才可能为 false,这样其他格式良好的需求才能得到良好的测试,而不会因为缺少结构信息而受阻。 -## **tvm.relax.analysis.well_formed(*obj:***[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)***|***[Function](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Function)**,*check_struct_info:***[bool](https://docs.python.org/3/library/functions.html#bool)***= True*)→**[bool](https://docs.python.org/3/library/functions.html#bool) +## **tvm.relax.analysis.well_formed(*obj:***[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)***|***[Function](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfunctionparamslistvarbodyrelaxexprret_struct_infostructinfononenoneis_pureboolnonetrueattrsdictattrsnonenonespanspannonenone)**,*check_struct_info:***[bool](https://docs.python.org/3/library/functions.html#bool)***= True*)→**[bool](https://docs.python.org/3/library/functions.html#bool) 用于估算 IRModule 中 Relax 函数内存使用情况的分析函数。估算内容包括内存规划前后需要分配的总内存大小。 diff --git a/docs/04-api-reference/01-python-api/13-tvm-relax_block_builder.md b/docs/04-api-reference/01-python-api/13-tvm-relax_block_builder.md index bd38c4f..c51c3d8 100644 --- a/docs/04-api-reference/01-python-api/13-tvm-relax_block_builder.md +++ b/docs/04-api-reference/01-python-api/13-tvm-relax_block_builder.md @@ -23,7 +23,7 @@ title: tvm.relax_block_builder 用于测试目的的辅助范围。 -## *class* tvm.relax.block_builder.BlockBuilder(*mod:*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.relax.block_builder.BlockBuilder(*mod:*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) 用于构建 Relax IR 以进行测试和开发的构建器。 @@ -73,48 +73,48 @@ with bb.function("main"): builder.emit_func_output(output, params=params) mod = bb.get() ``` -### *static* current() → [BlockBuilder](https://tvm.apache.org/docs/reference/api/python/relax/block_builder.html#tvm.relax.block_builder.BlockBuilder) | [None](https://docs.python.org/3/library/constants.html#None) +### *static* current() → [BlockBuilder](/docs/reference/api/python/relax/block_builder.html#tvm.relax.block_builder.BlockBuilder) | [None](https://docs.python.org/3/library/constants.html#None) 返回当前的 BlockBuilder。 -### function(*name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *params:*[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)*|*[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *attrs:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*, Object] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *pure:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *private:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [FunctionScope](https://tvm.apache.org/docs/reference/api/python/relax/block_builder.html#tvm.relax.block_builder.FunctionScope) +### function(*name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *params:*[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)*|*[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *attrs:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*, Object] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *pure:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *private:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [FunctionScope](/docs/api-reference/python-api/tvm-relax_block_builder#class-tvmrelaxblock_builderfunctionscopeblock_builder-name-params-attrs-is_pure) 注释一个 Relax 函数。 * **参数:** * **name** ([str](https://docs.python.org/3/library/stdtypes.html#str)*,optional*):函数的名称。 - * **params** ([tvm.relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)*|*[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)*|List **[***[tvm.relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)***]****,optional*):函数的参数。如果 params 为 None,则表示将函数参数的初始化推迟到 emit_func_output。 + * **params** ([tvm.relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)*|*[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)*|List **[***[tvm.relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)***]****,optional*):函数的参数。如果 params 为 None,则表示将函数参数的初始化推迟到 emit_func_output。 * **attrs** (*Dict*[***[str](https://docs.python.org/3/library/stdtypes.html#str),*** ***Object***],optional):函数 attrs。 * **pure** ([bool](https://docs.python.org/3/library/functions.html#bool)*,optional*):函数是否被注释为纯函数。 * **private** ([bool](https://docs.python.org/3/library/functions.html#bool)*,optional*):函数是否被注释为私有函数。如果函数是私有的,则它没有全局符号属性。如果它不是私有的且不是内部函数,则它将具有全局符号属性(映射到函数名称)。 * **返回:ret**:用于构建 Relax 函数节点的 FunctionScope。 -* **返回类型:**[FunctionScope](https://tvm.apache.org/docs/reference/api/python/relax/block_builder.html#tvm.relax.block_builder.FunctionScope) +* **返回类型:**[FunctionScope](/docs/api-reference/python-api/tvm-relax_block_builder#class-tvmrelaxblock_builderfunctionscopeblock_builder-name-params-attrs-is_pure) -## testing_scope(*def_vars:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)*]*) → [TestingScope](https://tvm.apache.org/docs/reference/api/python/relax/block_builder.html#tvm.relax.block_builder.TestingScope) +## testing_scope(*def_vars:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)*]*) → [TestingScope](/docs/api-reference/python-api/tvm-relax_block_builder#class-tvmrelaxblock_buildertestingscopeblock_builder-def_vars) 启动用于单元测试的范围。 -* **参数:def_vars** (*List[*[tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)*]*):标记为范围内定义的符号变量列表。 +* **参数:def_vars** (*List[*[tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)*]*):标记为范围内定义的符号变量列表。 * **返回:ret**:用于设置用于发射和其他目的的构建器的 TestingScope。 -* **返回类型:**[TestingScope](https://tvm.apache.org/docs/reference/api/python/relax/block_builder.html#tvm.relax.block_builder.TestingScope) +* **返回类型:**[TestingScope](/docs/api-reference/python-api/tvm-relax_block_builder#class-tvmrelaxblock_buildertestingscopeblock_builder-def_vars) -## dataflow() → [DataflowScope](https://tvm.apache.org/docs/reference/api/python/relax/block_builder.html#tvm.relax.block_builder.DataflowScope) +## dataflow() → [DataflowScope](/docs/api-reference/python-api/tvm-relax_block_builder#class-tvmrelaxblock_builderdataflowscopeblock_builder) 注释 Relax 数据流块。 * **返回:ret**:用于构建 Relax 数据流块的 DataflowScope。 -* **返回类型:**[DataflowScope](https://tvm.apache.org/docs/reference/api/python/relax/block_builder.html#tvm.relax.block_builder.DataflowScope)。 +* **返回类型:**[DataflowScope](/docs/api-reference/python-api/tvm-relax_block_builder#class-tvmrelaxblock_builderdataflowscopeblock_builder)。 -## emit(*expr:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *name_hint:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= ''*) → [Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var) +## emit(*expr:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *name_hint:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= ''*) → [Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone) 发出一个 expr。这将推断 expr 的形状和类型,创建一个变量,并将 expr 绑定到该变量。 * **参数:** * **expr** (*tvm.relax.Expr*):要发出的 Expr。 * **name_hint** ([str](https://docs.python.org/3/library/stdtypes.html#str)):绑定变量的名称提示。 -* **返回:ret**[:](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)与输入 expr 绑定的新创建的变量。 -* **返回类型:**[tvm.relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var) +* **返回:ret**:与输入 expr 绑定的新创建的变量。 +* **返回类型:**[tvm.relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone) -### call_te(*func:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable), **args:*[Any](https://docs.python.org/3/library/typing.html#typing.Any), ***kwargs:*[Any](https://docs.python.org/3/library/typing.html#typing.Any)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +### call_te(*func:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable), **args:*[Any](https://docs.python.org/3/library/typing.html#typing.Any), ***kwargs:*[Any](https://docs.python.org/3/library/typing.html#typing.Any)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 根据 te 函数生成一个调用节点。该函数将参数从 Relax 表达式转换为 te 张量。回调函数应返回一个 te 张量或一个 te 张量列表。请参阅 emit_te 中的详细示例。 @@ -126,9 +126,9 @@ mod = bb.get() * ’primfunc_name_hint’ 用语将名称提示传递给生成的PrimFunc。 * ’primfunc_attrs’保留用于传递要添加到创造的 PrimFunc 的函数属性。 * **返回:ret**:新创建的调用节点。 -* **返回类型:**[tvm.relax.Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call) +* **返回类型:**[tvm.relax.Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone) -### call_te_with_grad(*func:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable), **args:*[Any](https://docs.python.org/3/library/typing.html#typing.Any), *te_grad_name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *te_grad_kwargs:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*, Object] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, ***kwargs:*[Any](https://docs.python.org/3/library/typing.html#typing.Any)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +### call_te_with_grad(*func:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable), **args:*[Any](https://docs.python.org/3/library/typing.html#typing.Any), *te_grad_name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *te_grad_kwargs:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*, Object] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, ***kwargs:*[Any](https://docs.python.org/3/library/typing.html#typing.Any)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 根据 te 函数生成 call 节点。该方法会生成一个 call_tir_with_grad 节点,即绑定了 te 梯度函数(以 te_grad_name 为参数)的 call_tir 节点。 @@ -141,9 +141,9 @@ mod = bb.get() * ’primfunc_name_hint’ 用于将名称提示传递给生成的 PrimFunc。 * ’primfunc_attrs’ 保留用于传递要添加到创建的 PrimFunc 的函数属性。 * **返回:ret**:新创建的调用节点。 -* **返回类型:**[tvm.relax.Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call) +* **返回类型:**[tvm.relax.Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone) -### emit_te(*func:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable), *args:[Any](https://docs.python.org/3/library/typing.html#typing.Any), ***kwargs:*[Any](https://docs.python.org/3/library/typing.html#typing.Any)) → [Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var) +### emit_te(*func:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable), *args:[Any](https://docs.python.org/3/library/typing.html#typing.Any), ***kwargs:*[Any](https://docs.python.org/3/library/typing.html#typing.Any)) → [Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone) 根据 te 函数发出一个调用节点。该函数将参数从松弛表达式转换为 te 张量。回调函数应返回一个 te 张量或一个 te 张量列表。 @@ -152,7 +152,7 @@ mod = bb.get() * **args** (*Any,optional*):传递给函数的参数。 * **kwargs** (*Any,optional*):传递给函数的关键字参数。请注意,“primfunc_name_hint”键保留用于将名称提示传递给生成的 PrimFunc。 * **返回:ret**:与调用代码绑定的新创建的变量。 -* **返回类型:**[tvm.relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var) +* **返回类型:**[tvm.relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone) **示例** @@ -251,38 +251,38 @@ class Module: gv = relax.call_tir(te_func, (y,), R.Tensor((n + 1,), "float32"), (n,)) return gv ``` -### match_cast(*value:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *struct_info:*[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo), *name_hint:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= ''*) → [Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var) +### match_cast(*value:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *struct_info:*[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo), *name_hint:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= ''*) → [Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone) 发出 MatchCast。 * **参数:** * **value** (*tvm.relax.Expr*):要发出的 MatchCast 的值。 - * **struct_info** ([StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo))[:](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)要匹配的结构信息。 - * **name_hint** ([str](https://docs.python.org/3/library/stdtypes.html#str))[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)匹配转换的名称。 -* **返回:ret**[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)一个新创建的变量,其界限是转换结果。 -* **返回类型:**[tvm.relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var) + * **struct_info** ([StructInfo](https://tvm..org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo))[:](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)要匹配的结构信息。 + * **name_hint** ([str](https://docs.python.org/3/library/stdtypes.html#str))[:](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)匹配转换的名称。 +* **返回:ret**[:](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)一个新创建的变量,其界限是转换结果。 +* **返回类型:**[tvm.relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone) -### emit_output(*output:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*|*[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*]*, *name_hint:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= ''*) → [Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var) +### emit_output(*output:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*|*[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*]*, *name_hint:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= ''*) → [Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone) 发出当前数据流块或函数的输出。 * **参数:** - * **output** (*Expr|*[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)|List[Expr]):当前块/函数的输出。 - * **name_hint** ([str](https://docs.python.org/3/library/stdtypes.html#str))[:](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)绑定变量的名称提示。 + * **output** (*Expr|*[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)|List[Expr]):当前块/函数的输出。 + * **name_hint** ([str](https://docs.python.org/3/library/stdtypes.html#str))[:](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)绑定变量的名称提示。 * **返回:ret**:与输出绑定的返回变量。 -* **返回类型:**[tvm.relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var) +* **返回类型:**[tvm.relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone) -### emit_func_output(*output:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*|*[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*]*, *params:*[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)*|*[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar) +### emit_func_output(*output:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*|*[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*]*, *params:*[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)*|*[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none) 为函数发出输出。 * **参数:** - * **output** (*Expr|*[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)|List[*Expr]*):当前块/函数的输出。 - * **params** ([tvm.relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)*|*[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)*|List[***[tvm.relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)***]*,optional)[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar)要构建的函数的参数。如果 params 为 None,则表示 params 已在函数中初始化并具有作用域。 + * **output** (*Expr|*[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)|List[*Expr]*):当前块/函数的输出。 + * **params** ([tvm.relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)*|*[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)*|List[***[tvm.relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)***]*,optional)[:](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none)要构建的函数的参数。如果 params 为 None,则表示 params 已在函数中初始化并具有作用域。 * **返回:gvar:** 代表函数的 GlobalVar。 -* **返回类型:**[tvm.ir.GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar) +* **返回类型:**[tvm.ir.GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none) -### normalize(*expr:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +### normalize(*expr:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 规范化 Expr 以完成其形状和类型。 @@ -290,14 +290,14 @@ class Module: * **返回:ret**:具有规范化形状和类型的 expr。 * **返回类型:** Expr -### get() → [IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule) +### get() → [IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone) 返回中间 IRModule。适用于在构建过程中需要 IRModule 的情况。 * **返回:ret**:正在构建具有 Relax 和 TIR 功能的 IRModule。 * **返回类型:** tvm.IRModule。 -### finalize() → [IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule) +### finalize() → [IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone) 完成构建过程并返回结果 IRModule。 @@ -317,23 +317,23 @@ class Module: * **返回:ret:** 生成的名称。 * **返回类型:** [str](https://docs.python.org/3/library/stdtypes.html#str) -### add_func(*func:*[BaseFunc](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.BaseFunc), *func_name:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar) +### add_func(*func:*[BaseFunc](https://tvm..org/docs/reference/api/python/ir.html#tvm.ir.BaseFunc), *func_name:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none) 向正在构建的 IRModule 添加 Relax 函数或 TIR PrimFunc。 * **参数:** - * **func** ([BaseFunc](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.BaseFunc))[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.BaseFunc)要添加的函数。 + * **func** ([BaseFunc](https://tvm..org/docs/reference/api/python/ir.html#tvm.ir.BaseFunc))[:](https://tvm..org/docs/reference/api/python/ir.html#tvm.ir.BaseFunc)要添加的函数。 * **func_name** ([str](https://docs.python.org/3/library/stdtypes.html#str)):要添加的函数的名称。 * **返回:gvar**:与添加的函数绑定的全局变量。 -* **返回类型:**[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar) +* **返回类型:**[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none) -### update_func(*gv:*[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar), *updated_func:*[BaseFunc](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.BaseFunc)) → [None](https://docs.python.org/3/library/constants.html#None) +### update_func(*gv:*[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none), *updated_func:*[BaseFunc](https://tvm..org/docs/reference/api/python/ir.html#tvm.ir.BaseFunc)) → [None](https://docs.python.org/3/library/constants.html#None) 向正在构建的 IRModule 添加 Relax 函数或 TIR PrimFunc。 * **参数:** - * **gv** ([GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar)):引用要更新的函数的全局变量。 - * **updated_func** ([BaseFunc](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.BaseFunc)):更新后的函数。 + * **gv** ([GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none)):引用要更新的函数的全局变量。 + * **updated_func** ([BaseFunc](https://tvm..org/docs/reference/api/python/ir.html#tvm.ir.BaseFunc)):更新后的函数。 ### current_block_is_dataflow() → [bool](https://docs.python.org/3/library/functions.html#bool) @@ -341,28 +341,28 @@ class Module: * **返回:ret**:一个布尔值,指示正在构建的块是否为 DataflowBlock。 * **返回类型:**[bool](https://docs.python.org/3/library/functions.html#bool) -### emit_normalized(*binding:*[Binding](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Binding)) → [None](https://docs.python.org/3/library/constants.html#None) +### emit_normalized(*binding:*[Binding](https://tvm..org/docs/reference/api/python/relax/relax.html#tvm.relax.Binding)) → [None](https://docs.python.org/3/library/constants.html#None) 发出已经规范化的绑定。 -* **参数:binding** ([Binding](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Binding)):要发出的绑定。 +* **参数:binding** ([Binding](https://tvm..org/docs/reference/api/python/relax/relax.html#tvm.relax.Binding)):要发出的绑定。 -### lookup_binding(*var:*[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) | [None](https://docs.python.org/3/library/constants.html#None) +### lookup_binding(*var:*[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) | [None](https://docs.python.org/3/library/constants.html#None) 在绑定表中查找变量。 -* **参数:var** ([relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)):输入变量。 +* **参数:var** ([relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)):输入变量。 * **返回:expr**:与输入变量绑定的 Expr。 * **返回类型:** Expr。 -### begin_scope(*params:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [None](https://docs.python.org/3/library/constants.html#None) +### begin_scope(*params:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [None](https://docs.python.org/3/library/constants.html#None) 开始一个新的范围,带有范围内可见的可选参数。 -* **参数:params** (*Optional*[***List**[***[relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)***]***]*):范围内可见的参数。 +* **参数:params** (*Optional*[***List**[***[relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)***]***]*):范围内可见的参数。 -:::Note +:::note 当引入新范围(函数、序列)时应调用此函数,以正确跟踪变量可用性并帮助尽力推断。 diff --git a/docs/04-api-reference/01-python-api/14-tvm-relax-frontend.md b/docs/04-api-reference/01-python-api/14-tvm-relax-frontend.md index 37ebb62..0133629 100644 --- a/docs/04-api-reference/01-python-api/14-tvm-relax-frontend.md +++ b/docs/04-api-reference/01-python-api/14-tvm-relax-frontend.md @@ -8,7 +8,7 @@ title: tvm.relax.frontend 用于构建 Relax 程序的前端,以及模型导入器。 -### tvm.relax.frontend.detach_params(*mod:*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)) → [Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)[[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule), [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)[[str](https://docs.python.org/3/library/stdtypes.html#str), [List](https://docs.python.org/3/library/typing.html#typing.List)[[NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray)]]] +### tvm.relax.frontend.detach_params(*mod:*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)) → [Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)[[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone), [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)[[str](https://docs.python.org/3/library/stdtypes.html#str), [List](https://docs.python.org/3/library/typing.html#typing.List)[NDArray]]] 将输入 IRModule 函数中的属性「params」分离为单独的参数字典。 @@ -26,22 +26,22 @@ title: tvm.relax.frontend 效果是一种特殊的非面向用户的类型,用于表示具有副作用的作,例如打印。它用于表示计算的输出。 -### emit_init(*name_hint:*[str](https://docs.python.org/3/library/stdtypes.html#str), *builder:*[BlockBuilder](https://tvm.apache.org/docs/reference/api/python/relax/block_builder.html#tvm.relax.block_builder.BlockBuilder)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[DataflowVar](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.DataflowVar)] +### emit_init(*name_hint:*[str](https://docs.python.org/3/library/stdtypes.html#str), *builder:*[BlockBuilder](/docs/api-reference/python-api/tvm-relax_block_builder#class-tvmrelaxblock_builderblockbuildermodirmodulenone-none)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[DataflowVar](/docs/api-reference/python-api/tvm-relax#classtvmrelaxdataflowvarname_hintstridstruct_infostructinfononenonespanspannonenone)] 发出效果的初始化。此方法由编译器调用来初始化效果。 -### create(*name_hint:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)] +### create(*name_hint:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)] 创建代表副作用的 Relax.Function 的隐式输入。 -### set_state(*state_vars:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)*]*) → [None](https://docs.python.org/3/library/constants.html#None) +### set_state(*state_vars:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)*]*) → [None](https://docs.python.org/3/library/constants.html#None) 设置代表效果的变量。 -### finalize() → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)] +### finalize() → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)] 将效果最终确定为 Relax.Function 的隐式返回值。 @@ -87,14 +87,14 @@ title: tvm.relax.frontend * **state_dict** (*Dict*[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,***Parameter*** *]*):包含模块整个状态的字典。 * **返回:(missing_keys, unexpected_keys)**:两个列表的元组:缺失的键和意外的键。 * **返回**:(missing_keys, unexpected_keys):一个包含两个列表的元组:缺失的键和意外的键。 -* **返回类型**:[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)[List[[str](https://docs.python.org/3/library/stdtypes.html#str)], List[[str](https://docs.python.org/3/library/stdtypes.html#str)]]。 +* **返回类型**:[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)[List[[str](https://docs.python.org/3/library/stdtypes.html#str)], List[[str](https://docs.python.org/3/library/stdtypes.html#str)]]。 ### to(*dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [None](https://docs.python.org/3/library/constants.html#None) 递归地将模块转换为特定的数据类型。 -### export_tvm(*spec: *spec.ModuleSpecType*, *debug: [bool](https://docs.python.org/3/library/functions.html#bool) = False*, *allow_extern: [bool](https://docs.python.org/3/library/functions.html#bool) = False*) → [Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)[[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule), [List](https://docs.python.org/3/library/typing.html#typing.List)[[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)[[str](https://docs.python.org/3/library/stdtypes.html#str), Parameter]]] | [Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)[[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule), [List](https://docs.python.org/3/library/typing.html#typing.List)[[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)[[str](https://docs.python.org/3/library/stdtypes.html#str), Parameter]], [List](https://docs.python.org/3/library/typing.html#typing.List)[ExternModule]] +### export_tvm(*spec: *spec.ModuleSpecType*, *debug: [bool](https://docs.python.org/3/library/functions.html#bool) = False*, *allow_extern: [bool](https://docs.python.org/3/library/functions.html#bool) = False*) → [Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)[[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone), [List](https://docs.python.org/3/library/typing.html#typing.List)[[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)[[str](https://docs.python.org/3/library/stdtypes.html#str), Parameter]]] | [Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)[[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone), [List](https://docs.python.org/3/library/typing.html#typing.List)[[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)[[str](https://docs.python.org/3/library/stdtypes.html#str), Parameter]], [List](https://docs.python.org/3/library/typing.html#typing.List)[ExternModule]] 将模块导出到 TVM IRModule 及参数。 @@ -107,7 +107,7 @@ title: tvm.relax.frontend * ext_mods (List[nn.ExternModule]):模型中使用的 ExternModule 列表。 -### jit(*spec: *spec.ModuleSpec*, *device: [str](https://docs.python.org/3/library/stdtypes.html#str) | Device = 'cpu'*, *pipeline: [None](https://docs.python.org/3/library/constants.html#None) | [str](https://docs.python.org/3/library/stdtypes.html#str) | [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) = 'default_build'*, *out_format: [str](https://docs.python.org/3/library/stdtypes.html#str) = 'torch'*, *debug: [bool](https://docs.python.org/3/library/functions.html#bool) = False*) → [Any](https://docs.python.org/3/library/typing.html#typing.Any) +### jit(*spec: *spec.ModuleSpec*, *device: [str](https://docs.python.org/3/library/stdtypes.html#str) | Device = 'cpu'*, *pipeline: [None](https://docs.python.org/3/library/constants.html#None) | [str](https://docs.python.org/3/library/stdtypes.html#str) | [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) = 'default_build'*, *out_format: [str](https://docs.python.org/3/library/stdtypes.html#str) = 'torch'*, *debug: [bool](https://docs.python.org/3/library/functions.html#bool) = False*) → [Any](https://docs.python.org/3/library/typing.html#typing.Any) 即时编译 nn.model 为可执行文件。 @@ -134,17 +134,17 @@ title: tvm.relax.frontend 模块的前馈传递。 -## *class* tvm.relax.frontend.nn.Object(***, expr:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), name:*[str](https://docs.python.org/3/library/stdtypes.html#str)) +## *class* tvm.relax.frontend.nn.Object(***, expr:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), name:*[str](https://docs.python.org/3/library/stdtypes.html#str)) 基于 Relax.Expr 的包装器,其 struct_info 是基础 ObjectStructInfo(而非其任何子类)。Object 有效地表示非张量前端组件,例如键值缓存。 -## *class* tvm.relax.frontend.nn.Parameter(*shape:*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.relax.frontend.nn.Parameter(*shape:*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) 参数表示神经网络层的权重。它是一种特殊的张量,可以绑定或不绑定到具体值。如果参数绑定到具体值,则称为绑定参数;否则,称为非绑定参数。 -### *property* data:*[NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray)*|[None](https://docs.python.org/3/library/constants.html#None) +### *property* data:*NDArray*|[None](https://docs.python.org/3/library/constants.html#None) 如果参数绑定到具体值,则返回该参数的具体值,否则返回 None。返回值是一个 tvm.runtime.NDArray。 @@ -154,7 +154,7 @@ title: tvm.relax.frontend 如果参数未绑定到任何具体数据,则更改其 dtype。 -## *class* tvm.relax.frontend.nn.Tensor(* *, expr:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) +## *class* tvm.relax.frontend.nn.Tensor(* *, expr:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) 基于 Relax.Expr 的包装器,其 struct_info 为 TensorStructInfo,提供更便捷的形状和数据类型信息访问。张量始终为符号,不绑定任何具体值。形状和数据类型推断在张量创建时立即完成,即,当运算符应用于张量时,形状和数据类型信息已可用。 @@ -169,12 +169,12 @@ title: tvm.relax.frontend 从具有指定 dtype 的标量构造张量。 -### *static* from_struct_info(*struct_info:*[TensorStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TensorStructInfo), *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'tensor'*) → Tensor +### *static* from_struct_info(*struct_info:*[TensorStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtensorstructinfoshaperelaxexprnonelistprimexprnonedtypestrfloat32vdevicevdevicenonestrnonendimint-1spanspannonenone), *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'tensor'*) → Tensor 从 Relax TensorStructInfo 构建一个 nn.Tensor。 -### *static* placeholder(*shape:*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str), *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'tensor'*) → Tensor +### *static* placeholder(*shape:*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str), *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'tensor'*) → Tensor 创建一个具有给定形状和数据类型的占位符张量。通常情况下,用户不应直接创建占位符张量,唯一的例外是指示外部函数返回值的形状/数据类型。 @@ -182,7 +182,7 @@ title: tvm.relax.frontend 如果形状是字符串名称,我们将创建一个符号形状 tvm.tir.Var(name, “int64”)。 -### *property* shape*:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*] +### *property* shape*:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*] 以整数列表形式返回张量的形状。 @@ -336,9 +336,9 @@ Relax.frontend.nn.Module 用于 conv1d 层。 conv1d 层的前向方法。 -* **参数:x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入张量。 +* **参数:x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入张量。 * **返回:ret**:conv1d 层的输出张量。 -* 返回类型:- [Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:- [Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## *class* tvm.relax.frontend.nn.Conv2D(*in_channels:*[int](https://docs.python.org/3/library/functions.html#int), *out_channels:*[int](https://docs.python.org/3/library/functions.html#int), *kernel_size:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[int](https://docs.python.org/3/library/functions.html#int), *stride:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*= 0*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *groups:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *bias:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *data_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCHW'*) @@ -349,9 +349,9 @@ Relax.frontend.nn.Module 用于 conv2d 层。 conv2d 层的前向方法。 -* **参数:x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)输入张量。 +* **参数:x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)输入张量。 * **返回:ret**:conv2d 层的输出张量。 -* 返回类型:- [Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:- [Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## *class* tvm.relax.frontend.nn.Conv3D(*in_channels:*[int](https://docs.python.org/3/library/functions.html#int), *out_channels:*[int](https://docs.python.org/3/library/functions.html#int), *kernel_size:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[int](https://docs.python.org/3/library/functions.html#int), *stride:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *padding:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[int](https://docs.python.org/3/library/functions.html#int)*= 0*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *groups:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *bias:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *data_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCDHW'*) @@ -362,9 +362,9 @@ Relax.frontend.nn.Module 用于 conv3d 层。 conv3d 层的前向方法。 -* **参数:x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入张量。 +* **参数:x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入张量。 * **返回:ret**:conv3d 层的输出张量。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## *class* tvm.relax.frontend.nn.ConvTranspose1D(*in_channels:*[int](https://docs.python.org/3/library/functions.html#int), *out_channels:*[int](https://docs.python.org/3/library/functions.html#int), *kernel_size:*[int](https://docs.python.org/3/library/functions.html#int), *stride:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*= 0*, *output_padding:*[int](https://docs.python.org/3/library/functions.html#int)*= 0*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *groups:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *bias:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) @@ -375,11 +375,11 @@ ConvTranspose1D 层的 Relax.frontend.nn.Module。 conv 转置 1d 层的前向方法。 -* **参数:x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入张量。 +* **参数:x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入张量。 * **返回:ret**:conv 转置 1d 层的输出张量。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 -## *class* tvm.relax.frontend.nn.Embedding(*num:*[int](https://docs.python.org/3/library/functions.html#int)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *dim:*[int](https://docs.python.org/3/library/functions.html#int)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.relax.frontend.nn.Embedding(*num:*[int](https://docs.python.org/3/library/functions.html#int)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *dim:*[int](https://docs.python.org/3/library/functions.html#int)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) Relax.frontend.nn.Module 用于嵌入层。 @@ -389,7 +389,7 @@ Relax.frontend.nn.Module 用于嵌入层。 嵌入层的前向方法。 -* **参数:x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入张量。 +* **参数:x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入张量。 * **返回:ret**:嵌入层的输出张量。 * 返回类型:Tensor 张量。 @@ -405,33 +405,33 @@ Relax.frontend.nn.Module 用于组规范层。 群体范数层的前向方法。 * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入张量。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入张量。 * channel_axis (int):输入数据的通道轴。 * axes (Optional[List[int]]):可选,计算范数的轴列表,如果未指定,则假设前两个轴保持不变。 * **返回:ret**:组范数层的输出张量。 -* 返回类型;[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型;[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## *class* tvm.relax.frontend.nn.IOEffect 建模 IO 副作用,例如在屏幕上打印 NDArrays 的内容、插入调试断点等。 -### emit_init(*name_hint*, *builder:*[BlockBuilder](https://tvm.apache.org/docs/reference/api/python/relax/block_builder.html#tvm.relax.block_builder.BlockBuilder)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[DataflowVar](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.DataflowVar)] +### emit_init(*name_hint*, *builder:*[BlockBuilder](/docs/api-reference/python-api/tvm-relax_block_builder#class-tvmrelaxblock_builderblockbuildermodirmodulenone-none)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[DataflowVar](/docs/api-reference/python-api/tvm-relax#classtvmrelaxdataflowvarname_hintstridstruct_infostructinfononenonespanspannonenone)] 发出效果的初始化。此方法由编译器调用来初始化效果。 -### create(*name_hint:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)] +### create(*name_hint:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)] 创建代表副作用的 Relax.Function 的隐式输入。 -### set_state(*state_vars:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)*]*) → [None](https://docs.python.org/3/library/constants.html#None) +### set_state(*state_vars:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)*]*) → [None](https://docs.python.org/3/library/constants.html#None) 设置代表效果的变量。 -### finalize() → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)] +### finalize() → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)] 将效果最终确定为 Relax.Function 的隐式返回值。 @@ -441,7 +441,7 @@ Relax.frontend.nn.Module 用于组规范层。 实现 KVCache 的效果。 -### emit_init(*name_hint:*[str](https://docs.python.org/3/library/stdtypes.html#str), *bb:*[BlockBuilder](https://tvm.apache.org/docs/reference/api/python/relax/block_builder.html#tvm.relax.block_builder.BlockBuilder)) +### emit_init(*name_hint:*[str](https://docs.python.org/3/library/stdtypes.html#str), *bb:*[BlockBuilder](/docs/api-reference/python-api/tvm-relax_block_builder#class-tvmrelaxblock_builderblockbuildermodirmodulenone-none)) 发出 KVCache 效果的初始化。 @@ -449,20 +449,20 @@ Relax.frontend.nn.Module 用于组规范层。 * **name_hint** ([str](https://docs.python.org/3/library/stdtypes.html#str)):初始化绑定 Var 的名称提示。 * bb (relax.BlockBuilder):用于生成 relax BlockBuilder。 -### **create(*name_hint:***[str](https://docs.python.org/3/library/stdtypes.html#str)**)→**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)**]** +### **create(*name_hint:***[str](https://docs.python.org/3/library/stdtypes.html#str)**)→**[List](https://docs.python.org/3/library/typing.html#typing.List)**[**[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)**]** 为表示 KVCache 效应的 relax.Function 创建隐式输入。 * 参数 **:** * name_hint (str):relax.Var 的名称提示。 * 返回:ret:KVCache 的 relax.Var。 -* **返回类型:** List[[relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)]。 +* **返回类型:** List[[relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)]。 -### **set_state(*state_vars:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)***]*)→**[None](https://docs.python.org/3/library/constants.html#None) +### **set_state(*state_vars:***[List](https://docs.python.org/3/library/typing.html#typing.List)***[***[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)***]*)→**[None](https://docs.python.org/3/library/constants.html#None) 设置代表效果的变量。 -### finalize() → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)] +### finalize() → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)] 将 KVCache 效果最终确定为 Relax.Function 的隐式返回值。 @@ -476,19 +476,19 @@ Relax.frontend.nn.Module 用于组规范层。 * **参数:dtype** (*Optional[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):要转换的目标数据类型。 -### **view(*seq_len:***[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)**)→ Tensor** +### **view(*seq_len:***[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)**)→ Tensor** 查看 KVCache 中的最后元素。 * 参数: seq_len (tir.Var):查看最后元素的个数。 -* 返回: ret[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)最后查看的张量。 -* 返回类型 **:** [Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回: ret:最后查看的张量。 +* 返回类型 **:** [Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ### append(*new_element: Tensor*) → [None](https://docs.python.org/3/library/constants.html#None) 在 KVCache 中附加一个新元素。 -* **参数:new_element** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):要附加的新张量。 +* **参数:new_element** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):要附加的新张量。 @@ -500,11 +500,11 @@ Relax.frontend.nn.Module 用于组规范层。 ### forward(*x: Tensor*) → Tensor 层归一化层的正向方法。 -* **参数:x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入张量。 +* **参数:x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入张量。 * **返回:ret**:层规范化层的输出张量。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 -## *class* tvm.relax.frontend.nn.Linear(*in_features:*[int](https://docs.python.org/3/library/functions.html#int)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *out_features:*[int](https://docs.python.org/3/library/functions.html#int)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *bias:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *out_dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.relax.frontend.nn.Linear(*in_features:*[int](https://docs.python.org/3/library/functions.html#int)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *out_features:*[int](https://docs.python.org/3/library/functions.html#int)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *bias:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *out_dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) Relax.frontend.nn.Module 用于线性层。 @@ -513,9 +513,9 @@ Relax.frontend.nn.Module 用于线性层。 线性层的前向方法。 -* **参数:x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入张量。 +* **参数:x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入张量。 * **返回:ret**:线性层的输出张量。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ### to(*dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [None](https://docs.python.org/3/library/constants.html#None) @@ -537,9 +537,9 @@ Relax.frontend.nn.Module 用于 rms 范数层。 均方根范数层的前向方法。 -* **参数:x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入张量。 +* **参数:x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入张量。 * **返回:ret**:均方根范数层的输出张量。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 @@ -660,11 +660,11 @@ T.**name** == ‘T’ T.**constraints** == () T.**covariant** == False T.**contr 添加 numpy 风格的广播。 * **参数:** - * **a** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):第一个输入张量。 + * **a** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):第一个输入张量。 * b (Tensor)**:** 第二个输入张量。 - * name (str)[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)名称提示。 + * name (str)[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)名称提示。 * **返回:result**:计算结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 **示例** @@ -676,7 +676,7 @@ c = add(a, b) 沿给定轴执行排序,并返回与按排序顺序索引数据的输入数组具有相同形状的索引数组。 * **参数:** - * **data** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入数据张量。 + * **data** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入数据张量。 * axis (int):按此轴对输入张量进行排序。 * 降序(bool)是否按降序排序,默认为 False * **返回:out**:排序张量的索引。 @@ -685,22 +685,22 @@ c = add(a, b) 将输入张量转换为给定的数据类型。 * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))*:*运算符的输入数据。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))*:*运算符的输入数据。 * dtype (str):目标数据类型。 * name (str):名称提示。 * **返回:result**:转换结果。 -* **返回类型**:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型**:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 -## tvm.relax.frontend.nn.broadcast_to(*x: Tensor*, *shape:*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'broadcast_to'*) → Tensor +## tvm.relax.frontend.nn.broadcast_to(*x: Tensor*, *shape:*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'broadcast_to'*) → Tensor 将张量广播到指定形状。 * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):运算符的输入数据。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):运算符的输入数据。 * shape (Sequence[IntExpr]):目标形状。 * name (str):名称提示。 * **返回:result**:广播的张量。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ## tvm.relax.frontend.nn.ccl_allgather(*x: Tensor*, *num_workers:*[int](https://docs.python.org/3/library/functions.html#int), *name='ccl_allgather'*) @@ -708,9 +708,9 @@ CCL Allgather 运算符。 * **参数:** * **x** (*relax.Expr*):输入张量。 * num_workers (int):工作线程数。 - * name (str)[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)该操作的名称提示。 + * name (str)[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)该操作的名称提示。 * **返回:result**:allgather 的结果张量。 -* 返回类型:[Tensor 张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor 张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.ccl_allreduce(*x: Tensor*, *op_type:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'sum'*, *in_group:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *name='ccl_allreduce'*) @@ -720,14 +720,14 @@ CCL Allreduce 运算符。 * op_type (str):应用于输入数据的归约操作类型。目前支持「sum」、「prod」、「min」、「max」和「avg」。 * name (str):该操作的名称提示。 * **返回:result**:allreduce 的结果张量。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.ccl_broadcast_from_worker0(*x: Tensor*, *name='broadcast_from_worker'*) 将数据从 worker-0 广播到所有其他 worker。 * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):要广播的张量。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):要广播的张量。 * name (str):该操作的名称提示。 * **返回:result**:相同的张量,已广播给所有其他工作者。 * 返回类型:Tensor  张量。 @@ -737,23 +737,23 @@ CCL Allreduce 运算符。 将张量沿 dim 分成指定数量的块。 * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):要分割的输入张量。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):要分割的输入张量。 * chunks (int):将 x 切成多少块。 * dim (int):在哪个维度上分割 x。 * name (str):该操作的名称提示。 * **返回:result**:具有包含 x 切片的块元素的元组。 -* 返回类型;[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)[[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)]。 +* 返回类型;[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)[[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)]。 ## tvm.relax.frontend.nn.concat(*x:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[Tensor]*, *dim:*[int](https://docs.python.org/3/library/functions.html#int), *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'concat'*) → Tensor 沿轴连接张量列表。 * **参数:** - * **x** (*List[*[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*]*):要连接的张量列表。 + * **x** (*List[*[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*]*):要连接的张量列表。 * dim (int):连接的维度。 * name (str):该算子的名称提示。 * **返回:result**:扩展结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.conv1d(*x: Tensor*, *weight: Tensor*, *bias: Tensor |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *stride:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*|*[None](https://docs.python.org/3/library/constants.html#None)*= 1*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= 0*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*|*[None](https://docs.python.org/3/library/constants.html#None)*= 1*, *groups:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= 1*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'conv1d'*) → Tensor @@ -770,16 +770,16 @@ $$\text{out}[b,c,x] = \sum_{dx,k} \text{data}[b,k,\text{strides} \ast x + dx] \a 在计算之前,分别对数据和权重应用填充和膨胀。该算子接受数据布局规范。从语义上讲,该算子会将布局转换为规范布局(数据为 NCW ,权重为 OIW),执行计算,然后转换为 out_layout。 * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):运算符的输入数据。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):运算符的输入数据。 * weight (Tensor):权重表达式。 * bias (Optional[Tensor]):可选的偏置张量,形状为 [O]。 * strides (Optional[Union[int, Tuple]]):卷积的步长。必须具有长度 1。 * padding (Optional[Union[int, Tuple, str]]):卷积前输入两边的填充。必须具有长度 1 或 2。 * dilation (Optional[Union[int, Tuple]]):指定用于扩张卷积的扩张率。必须具有长度 1。 - * groups (Optional[int])[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)分组卷积将输入分成多少组。输入和输出通道的数量应该能被组数整除。 + * groups (Optional[int])[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)分组卷积将输入分成多少组。输入和输出通道的数量应该能被组数整除。 * name (str):名称提示。 * **返回:result**:计算结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.conv1d_transpose(*x: Tensor*, *weight: Tensor*, *bias: Tensor |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *stride:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= 1*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*, …] |*[None](https://docs.python.org/3/library/constants.html#None)*= 0*, *output_padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= 0*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*|*[None](https://docs.python.org/3/library/constants.html#None)*= 1*, *groups:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= 1*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'conv1d_transpose'*) → Tensor @@ -793,7 +793,7 @@ $$\text{out}[b,c,x] = \sum_{dx,k} \text{data}[b,k,\text{strides} \ast x + dx] \a 输出形状可以用 data_layout == “NCW”和 kernel_layout == “IOW” 的简单情况来解释。假设数据形状为(N, in_channel, in_w),权重形状为(in_channel, out_channel, weight_w),我们需要确保 in_channel % groups == 0。输出形状为(N, out_channel * groups, out_w),其中 * out_w = ((in_w - 1) * strides[0] + weight_w - 2 * padding[0] + output_padding[0]) * **参数:** - * **data** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):运算符的输入数据。 + * **data** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):运算符的输入数据。 * 权重(Tensor)权重张量。 * 步长(Union[int, Tuple[int]])卷积的步长。必须具有长度 1。 * 填充(Union[int, Tuple[int, ...]])卷积前在输入两侧的填充。必须具有长度 1 或 2。 @@ -805,13 +805,13 @@ $$\text{out}[b,c,x] = \sum_{dx,k} \text{data}[b,k,\text{strides} \ast x + dx] \a * out_layout (Optional[str]):输出的布局。如果未指定,则与 data_layout 相同。 * out_dtype (Optional[Union[str, DataType]])*:*指定混合精度 conv2d 的输出数据类型。 * **返回:result**:计算结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.conv2d(*x: Tensor*, *weight: Tensor*, *bias: Tensor |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *stride:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*|*[None](https://docs.python.org/3/library/constants.html#None)*= 1*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= 0*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*|*[None](https://docs.python.org/3/library/constants.html#None)*= 1*, *groups:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= 1*, *data_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= 'NCHW'*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'conv2d'*) → Tensor 对由多个输入平面组成的输入图像应用二维卷积。 * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):形状为 [B, N, H, W] 的输入张量。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):形状为 [B, N, H, W] 的输入张量。 * 权重 (Tensor):形状为 [O, N/groups, kH, kW] 的过滤器 * 偏置 (Optional[Tensor]):形状为 [O] 的可选偏置张量。 * 步长 (Optional[Union[int, Tuple]]):卷积核的步长。可以是单个数字或 (sH, sW) 元组。 @@ -821,7 +821,7 @@ $$\text{out}[b,c,x] = \sum_{dx,k} \text{data}[b,k,\text{strides} \ast x + dx] \a * data_layout (Optional[str]):输入和输出数据的布局。 * name (str):名称提示。 * **返回:result**:计算结果,形状为 [B, O, oH, oW]。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.conv3d(*x: Tensor*, *weight: Tensor*, *bias: Tensor |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *stride:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*|*[None](https://docs.python.org/3/library/constants.html#None)*= 1*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= 0*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*|*[None](https://docs.python.org/3/library/constants.html#None)*= 1*, *groups:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= 1*, *data_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= 'NCDHW'*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'conv3d'*) → Tensor @@ -829,28 +829,28 @@ $$\text{out}[b,c,x] = \sum_{dx,k} \text{data}[b,k,\text{strides} \ast x + dx] \a 对由多个输入平面组成的输入图像应用 3D 卷积。 * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):形状为 [B, N, D, H, W] 的输入张量。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):形状为 [B, N, D, H, W] 的输入张量。 * weight (Tensor):滤波器,形状为 [O, N/groups, kD, kH, kW] * bias (Optional[Tensor]):可选的偏置张量,形状为 [O]. * stride (Optional[Union[int, Tuple]]):卷积核的步长。可以是单个数字或 (sD, sH, sW) 元组。 * padding (可选[[Union[int, Tuple]]]):输入两边的隐式填充。 * dilation (Optional[Union[int, Tuple]]):卷积核元素之间的间距。可以是一个数字或一个元组(dD, dH, dW)。 - * groups (可选[int])[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)将输入分成若干组。 + * groups (可选[int])[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)将输入分成若干组。 * data_layout (Optional[str]):可选的输入和输出数据布局。 * name (str):名称提示。 * **返回:result**:计算结果,形状为 [B, O, oD, oH, oW]。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.cumsum(*data: Tensor*, *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *exclusive:*[bool](https://docs.python.org/3/library/functions.html#bool)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'cumsum'*) → Tensor Numpy 风格的 cumsum op。返回沿给定轴的元素的累积包含总和。 * **参数:** - * **data** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):运算符的输入数据。 - * axis (可选[int]):沿着哪个轴计算累积和。默认值(None)是计算扁平化数组的 cumsum。dtype (Optional[str])**:** 返回数组的类型以及用于累加元素的累加器的类型。如果未指定 dtype,则默认为 data 的类型。exclusive (Optional[bool])[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)如果为 true,将返回不包含第一个元素的排他性求和。 + * **data** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):运算符的输入数据。 + * axis (可选[int]):沿着哪个轴计算累积和。默认值(None)是计算扁平化数组的 cumsum。dtype (Optional[str])**:** 返回数组的类型以及用于累加元素的累加器的类型。如果未指定 dtype,则默认为 data 的类型。exclusive (Optional[bool])[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)如果为 true,将返回不包含第一个元素的排他性求和。 * name (str):名称提示。 * **返回:result**:如果 axis 不为 None,则结果的大小与数据相同,形状也与数据相同。如果 axis 为 None,则结果为一维数组。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 **示例** @@ -876,7 +876,7 @@ a = [1, 0, 1, 0, 1, 1, 0] # a is a boolean array # a 是布尔数组 cumsum(a, dtype=int32) # dtype should be provided to get the expected results # dtype 必须提供,才能得到预期的结果 -> [1, 1, 2, 2, 3, 4, 4] ``` -## tvm.relax.frontend.nn.debug_func(*name:*[str](https://docs.python.org/3/library/stdtypes.html#str), args: Tensor |*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*|*[int](https://docs.python.org/3/library/functions.html#int)*|*[float](https://docs.python.org/3/library/functions.html#float)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), line_info:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## tvm.relax.frontend.nn.debug_func(*name:*[str](https://docs.python.org/3/library/stdtypes.html#str), args: Tensor |*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*|*[int](https://docs.python.org/3/library/functions.html#int)*|*[float](https://docs.python.org/3/library/functions.html#float)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), line_info:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) relax.Call 在运行时调用调试函数。调试函数必须使用以下类型签名注册: @@ -895,11 +895,11 @@ def debug_func(lineno: str, arg*0, arg*1, ...) -> None: 使用 numpy 风格广播进行除法。 * **参数:** - * **a** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):第一个输入张量。 - * b (Tensor)[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)第二个输入张量。 + * **a** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):第一个输入张量。 + * b (Tensor)[:](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)第二个输入张量。 * name (str):名称提示。 * **返回:result**:计算结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 **示例** @@ -907,7 +907,7 @@ def debug_func(lineno: str, arg*0, arg*1, ...) -> None: ```python c = divide(a, b) ``` -## tvm.relax.frontend.nn.empty(*shape:*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'float32'*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'empty'*) → Tensor +## tvm.relax.frontend.nn.empty(*shape:*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'float32'*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'empty'*) → Tensor 构建一个未初始化的张量,具有输入形状和 dtype。 @@ -916,18 +916,18 @@ c = divide(a, b) * dtype (str):创建的张量的数据类型。 * name (str):名称提示。 * **返回:result**:结果张量。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.equal(*a: Tensor*, *b: Tensor*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'equal'*) → Tensor 广播元素比较(lhs == rhs)。 * **参数:** - * **a** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):第一个输入张量。 + * **a** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):第一个输入张量。 * b (Tensor)**:** 第二个输入张量。 * name (str):名称提示。 * **返回:result**:计算结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.exp(*x: Tensor*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'exp'*) → Tensor @@ -936,19 +936,19 @@ c = divide(a, b) $$\text{Exp}(x) = e^x$$ * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):运算符的输入数据。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):运算符的输入数据。 * name (str):名称提示。 * **返回:result**:计算结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 -:::Note +:::note 输入张量需要具有浮点型。 ::: -## tvm.relax.frontend.nn.extern(*name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *args:*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[Tensor |*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*|*[int](https://docs.python.org/3/library/functions.html#int)*|*[float](https://docs.python.org/3/library/functions.html#float)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*, *out: OutType*) → OutType +## tvm.relax.frontend.nn.extern(*name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *args:*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[Tensor |*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*|*[int](https://docs.python.org/3/library/functions.html#int)*|*[float](https://docs.python.org/3/library/functions.html#float)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*, *out: OutType*) → OutType 在运行时调用外部函数。该外部函数必须使用 TVM_FFI_REGISTER_GLOBAL (C++) 或 tvm.register_func (Python)在 TVM 运行时注册。 @@ -957,9 +957,9 @@ $$\text{Exp}(x) = e^x$$ * args (Sequence[Union[Tensor, _tir.PrimExpr, int, float, str]]):传递给 extern 函数的参数。 * out (Union[Tensor, List[Tensor]]):仅输出张量。 * **返回:result**:结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 -## tvm.relax.frontend.nn.full(*shape:*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*, *fill_value: Tensor*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'float32'*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'full'*) → Tensor +## tvm.relax.frontend.nn.full(*shape:*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*, *fill_value: Tensor*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'float32'*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'full'*) → Tensor 用标量值填充数组。 @@ -968,7 +968,7 @@ $$\text{Exp}(x) = e^x$$ * args (Sequence[Union[Tensor, _tir.PrimExpr, int, float, str]])[:](https://docs.python.org/3/library/constants.html#None)传递给 extern 函数的参数。 * out (Union[Tensor, List[Tensor]]):仅输出张量。 * **返回:result**:结果张量。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.gelu(*x: Tensor*, *approximate:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'gelu'*) → Tensor @@ -979,14 +979,14 @@ $$\text{GeLU}(x) = 0.5 * x * (1 + \text{erf}(x * 0.5**0.5))$$ 在那里 erf 是高斯误差函数。 * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入数据。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入数据。 * approximate (Optional[str]):如果设置为 tanh,则在计算 CDF 时使用近似值。 * name (str):名称提示。 * **返回:result**[:](https://docs.python.org/3/library/functions.html#bool)计算结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 -:::Note +:::note 输入张量需要具有浮点型 @@ -1005,35 +1005,35 @@ $$\text{GeLU}(x) = 0.5 * x * (1 + \text{erf}(x * 0.5**0.5))$$ 时间步长的计算如去噪扩散概率模型中所述。 * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):N 个索引的一维张量。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):N 个索引的一维张量。 * embedding_dim (int):输出的维度。flip_sin_to_cos (bool):如果为 True,则改变正弦和余弦嵌入的顺序。 * downscale_freq_shift (float):调整正弦采样频率。 * scale (float):嵌入幅度权重调整。max_period (int):控制嵌入的最小频率。 * name (str):用以标记此算子的名称。 * **返回:result**:[N x dim] 位置嵌入的张量。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.greater(*a: Tensor*, *b: Tensor*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'greater'*) → Tensor 广播元素比较(lhs > rhs)。 * **参数:** - * **a** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):第一个输入张量。 + * **a** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):第一个输入张量。 * b (Tensor):第二个输入张量。 * name (str):名称提示。 * **返回:result**:计算结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.greater_equal(*a: Tensor*, *b: Tensor*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'greater_equal'*) → Tensor 广播逐元素比较 (lhs >= rhs)。 * **参数:** - * **a** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))*:*第一个输入张量。 + * **a** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))*:*第一个输入张量。 * b (Tensor):第二个输入张量。 * name (str):名称提示。 * **返回:result**[:](https://arxiv.org/abs/1803.08494)计算结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.group_norm(*x: Tensor*, *num_groups:*[int](https://docs.python.org/3/library/functions.html#int), *weight: Tensor |*[None](https://docs.python.org/3/library/constants.html#None), *bias: Tensor |*[None](https://docs.python.org/3/library/constants.html#None), *eps:*[float](https://docs.python.org/3/library/functions.html#float)*= 1e-05*, *channel_axis:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *axes:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'group_norm'*) → Tensor @@ -1042,27 +1042,27 @@ $$\text{GeLU}(x) = 0.5 * x * (1 + \text{erf}(x * 0.5**0.5))$$ $$y = \frac{x - \mathrm{E}[x]}{ \sqrt{\mathrm{relax.Var}[x] + \epsilon}} * \gamma + \beta$$ * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):将应用 rms_norm 的输入。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):将应用 rms_norm 的输入。 * num_groups (int):将通道分成多少组的数量。 * weight (Tensor):伽马缩放因子。 - * bias (Tensor)[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)Beta 偏移因子。 + * bias (Tensor)[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)Beta 偏移因子。 * epsilon (float):在平方均值上添加的小浮点数,以避免除以零。channel_axis (int)*:*数据的通道轴。axes (Optional[int])[:](https://docs.python.org/3/library/functions.html#float)计算 groupnorm 的轴。如果为 None,则假定应忽略前两个通道。 * name (str):名称提示。 * **返回:result**:计算结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.interpolate(*x: Tensor*, *size:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *scale_factor:*[float](https://docs.python.org/3/library/functions.html#float)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[float](https://docs.python.org/3/library/functions.html#float)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *mode:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'nearest'*, *align_corners:*[bool](https://docs.python.org/3/library/functions.html#bool)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *recompute_scale_factor:*[bool](https://docs.python.org/3/library/functions.html#bool)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *antialias:*[bool](https://docs.python.org/3/library/functions.html#bool)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *data_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= 'NCHW'*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'interpolate'*) 使用指定的模式调整张量的大小。 * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):需要调整大小的输入张量。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):需要调整大小的输入张量。 * size (Optional[Union[int, Tuple[int]]]):请求的输出尺寸,仅能指定 size 或 scale_factor 中的一个。 * scale_factor (Optional[Union[float, Tuple[float]]]):空间尺寸的乘数。mode (str):采样所使用的算法。 * align_corners (Optional[bool]):采样前后像素的映射方式。recompute_scale_factor (Optional[bool]):为插值重新计算 scale_factor。抗锯齿 (Optional[bool])*:*对输出应用抗锯齿。 * data_layout (Optional[str])*:*输入和输出数据的布局。 * name (str):该操作的名称提示。 * **返回:result**:具有请求形状的输出张量。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.layer_norm(*x: Tensor*, *normalized_shape:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*, *weight: Tensor |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *bias: Tensor |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *eps:*[float](https://docs.python.org/3/library/functions.html#float)*= 1e-05*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'layer_norm'*) → Tensor @@ -1077,38 +1077,38 @@ $$out = \frac{data - mean(data, axis)}{\sqrt{var(data, axis)+\epsilon}} * gamma 假设输入在轴 1 上的大小为 k,则 gamma 和 beta 的形状均为 (k,)。 -:::Note +:::note 该运算符可以进行优化以进行推理。 ::: * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):将应用 layer_norm 的输入。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):将应用 layer_norm 的输入。 * normalized_shape (Union[int, List[int]]):归一化的轴的形状。如果使用单个整数,它被视为一个单元素列表,此模块将在最后一个维度上归一化。 * weight (Tensor):伽马缩放因子。 * bias (Tensor):Beta 偏移因子。 * eps (float):添加到方差的小浮点数,以避免除以零。 * name (str):名称提示。 * **返回:result***:*计算结果。 -* 返回了类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回了类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.less(*a: Tensor*, *b: Tensor*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'less'*) → Tensor 广播元素比较(lhs < rhs)。 * **参数:** - * **a** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):第一个输入张量。 + * **a** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):第一个输入张量。 * b (Tensor):第二个输入张量。 * name (str)**:** 名称提示。 * **返回:result**:计算结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.less_equal(*a: Tensor*, *b: Tensor*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'less_equal'*) → Tensor 广播逐元素比较 (lhs <= rhs)。 * **参数:** - * **a** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))[:](https://data-apis.org/array-api/latest/API_specification/generated/array_api.matmul.html)第一个输入张量。 + * **a** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))[:](https://data-apis.org/array-api/latest/API_specification/generated/array_api.matmul.html)第一个输入张量。 * b (Tensor)[:](https://data-apis.org/array-api/latest/API_specification/generated/array_api.matmul.html)第二个输入张量。 * name (str)[:](https://data-apis.org/array-api/latest/API_specification/generated/array_api.matmul.html)名称提示。 * **返回:result**:计算结果。 @@ -1122,12 +1122,12 @@ $$out = \frac{data - mean(data, axis)}{\sqrt{var(data, axis)+\epsilon}} * gamma 语义和输出形状推断规则指定为 [https://data-apis.org/array-api/latest/API_specification/generated/array_api.matmul.html](https://data-apis.org/array-api/latest/API_specification/generated/array_api.matmul.html)。 * **参数:** - * **a** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):第一个输入张量。 + * **a** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):第一个输入张量。 * b (Tensor):第二个输入张量。 * out_dtype (Optional[Union[str, DataType]])*:*矩阵乘法结果的数值类型。当未指定时,输出 dtype 将与输入 dtype 相同。 * name (str):名称提示。 * **返回:result**:计算结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 @@ -1142,23 +1142,23 @@ c = matmul(a, b) 计算给定轴上张量元素的最大值。 * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 输入数据张量。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 输入数据张量。 * axis (Optional[Union[int, List[int]]]):指定执行最大值操作的轴或轴。默认值 axis=None 将对输入张量的所有元素执行最大值操作。支持负索引。 * keepdims (bool):如果设置为 True,被缩减的轴将保留为结果中的尺寸为一的维度。使用此选项,结果将正确地广播与输入张量。 * name (str):该操作的名称提示。 * **返回:result**[:](https://docs.python.org/3/library/functions.html#bool)计算结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.maximum(*x1: Tensor*, *x2: Tensor*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'maximum'*) 元素最大值。 * **参数:** - * **x1** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):第一个输入张量。 - * x2 (Tensor)[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)第二个输入张量。 + * **x1** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):第一个输入张量。 + * x2 (Tensor)[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)第二个输入张量。 * name (str):名称提示。 * **返回:result**:计算结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 @@ -1172,22 +1172,22 @@ c = maximum(a, b) 计算给定轴上张量元素的最小值。 * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入数据张量。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入数据张量。 * axis (Optional[Union[int, List[int]]])**:** 指定执行最小值操作的轴或轴。默认值 axis=None 将对输入张量的所有元素执行最小值操作。支持负索引。 * keepdims (bool)**:** 如果设置为 True,被缩减的轴将保留为结果中的尺寸为一的维度。使用此选项,结果将正确地广播与输入张量。 * **返回:result**:计算结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.minimum(*x1: Tensor*, *x2: Tensor*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'minimum'*) 元素最小值。 * **参数:** - * **x1** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):第一个输入张量。 + * **x1** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):第一个输入张量。 * x2 (Tensor):第二个输入张量。 * name (str):名称提示。 * **返回:result**:计算结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 **示例** @@ -1204,12 +1204,12 @@ c = minimum(a, b) 为了获得更好的 CPU 性能,请使用「vm.builtin.multinomial_from_uniform」。为了获得准确的结果,请确保概率介于 0 到 1 之间,且总和为 1。 * **参数:** - * **prob** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):一个二维张量,形状为 (batch, vocab_size),表示概率分布。每一行代表一个批次中词汇表的分布,其中:值的范围为 [0, 1],表示每个词汇表项目的概率。每行值的总和为 1,构成一个有效的分布。 + * **prob** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):一个二维张量,形状为 (batch, vocab_size),表示概率分布。每一行代表一个批次中词汇表的分布,其中:值的范围为 [0, 1],表示每个词汇表项目的概率。每行值的总和为 1,构成一个有效的分布。 * uniform_sample (Tensor):均匀采样的 2-D 张量,形状为(n, 1)。值范围从 0 到 1,表示均匀采样的概率。 * sample_indices (Optional[Tensor]):可选的 2-D 张量,形状为[n, 1],用于指示需要从中采样的特定概率分布。sample_indices[i]的值决定了第 i 个 token 应该从第 sample_indices[i]个概率分布中采样。例如,如果有 3 个不同的概率分布,并且需要从每个分布中采样 2、3 和 4 个 token,那么 sample_indices 将是[0, 0, 1, 1, 1, 2, 2, 2, 2]。 * dtype (str):输出张量的数据类型。 * **返回:result**:计算的形状为 (n, 1) 的张量。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 **示例** @@ -1229,11 +1229,11 @@ multinomial_from_uniform(prob, usample, sample_indices) 使用 numpy 风格广播进行乘法。 * **参数:** - * **a** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):第一个输入张量。 + * **a** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):第一个输入张量。 * b (Tensor):第二个输入张量。 * name (str):名称提示。 * **返回:result**:计算结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 **示例** @@ -1246,24 +1246,24 @@ c = multiply(a, b) 输入张量的数值负数。 * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):运算符的输入数据。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):运算符的输入数据。 * name (str):名称提示。 * result:计算结果。 * **返回:result**:计算结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.not_equal(*a: Tensor*, *b: Tensor*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'not_equal'*) → Tensor 广播逐元素比较 (lhs != rhs)。 * **参数:** - * **a** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):第一个输入张量。 + * **a** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):第一个输入张量。 * b (Tensor):第二个输入张量。 * name (str)**:** 名称提示。 * **返回:result**:计算结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 -## tvm.relax.frontend.nn.ones(*shape:*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'float32'*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'ones'*) → Tensor +## tvm.relax.frontend.nn.ones(*shape:*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'float32'*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'ones'*) → Tensor 构建一个全零的张量,具有输入形状和 dtype。 @@ -1272,42 +1272,42 @@ c = multiply(a, b) * dtype (str):创建的张量的数据类型。 * name (str):名称提示。 * **返回:result**:结果张量。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.pad(*x: Tensor*, *pad:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*, *mode:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'constant'*, *value:*[float](https://docs.python.org/3/library/functions.html#float)*= 0.0*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'pad'*) → Tensor 对输入张量应用空间填充。 * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):要填充的输入张量。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):要填充的输入张量。 * pad (List[int]):格式为 [before_0, after_0, before_1, after_1, …] 的列表,表示如何对 x 的每个轴进行填充。 * mod (str):使用的填充模式,constant 表示填充的元素将使用 value 参数的值。 * value (float):常数模式下用什么来填充。 * name (str):该算子的名称提示。 * **返回:result**:填充的输出张量。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.permute(*x: Tensor*, *axes:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None), *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'permute'*) → Tensor 排列输入张量的维度。 * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):运算符的输入数据。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):运算符的输入数据。 * axes (Optional[List[int]]):目标轴顺序。 * name (str):名称提示。 * **返回:result**:转置的结果。 -* 返回类型:[Tensor 张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor 张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.permute_dims(*x: Tensor*, *axes:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → Tensor 排列数组的维度。 * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):运算符的输入数据。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):运算符的输入数据。 * axes (Optional[List[int]]):目标轴顺序,若未指定则逆序。 * name (str):名称提示。 * **返回:result**:转置的结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.prelu(*x: Tensor*, *alpha: Tensor*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'prelu'*) @@ -1316,11 +1316,11 @@ c = multiply(a, b) $$\begin{split}\text{PReLU}(x) = \begin{cases} x & \text{if } x \geq 0 \\ \alpha \cdot x & \text{if } x < 0\end{cases}\end{split}$$ * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入数据。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入数据。 * alpha (Tensor):输入负部分的斜率系数。 * name (str, optional):可选的操作名称。默认为“prelu”。 * **返回:result**:计算结果。 -* 返回类型;[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型;[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.print*(*tensor: Tensor*) @@ -1334,10 +1334,10 @@ $$\begin{split}\text{PReLU}(x) = \begin{cases} x & \text{if } x \geq 0 \\ $$ext{ReLU}(x) = ext{max}(x, 0)$$ * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 输入数据。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 输入数据。 * name (str):名称提示。 * **返回:result**:计算结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.relu6(*x: Tensor*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'relu6'*) → Tensor @@ -1346,35 +1346,35 @@ ReLU6 激活函数。 $$\text{ReLU6}(x) = \min(\max(x, 0), 6)$$ * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入数据。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入数据。 * name (str):名称提示。 * **返回:result**:计算结果。 -* 返回类型;[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型;[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.renormalize_top_p_top_k_prob(*prob*, *sorted_prob*, *top_p*, *top_k*) 使用 top_p 和 top_k 过滤后重新规范化概率,确保它们的总和为 1。 -:::Note +:::note 为了获得准确的结果,请确保概率介于 0 和 1 之间且总和为 1。 ::: * **参数:** - * **prob** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):表示概率分布的形状为(batch,vocab_size)的二维张量。 - * sorted_prob (Tensor)[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)按降序排列的概率。 + * **prob** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):表示概率分布的形状为(batch,vocab_size)的二维张量。 + * sorted_prob (Tensor)[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)按降序排列的概率。 * top_p (Tensor):核心采样中使用的累积概率阈值,形状为 (batch, 1)。 * top_k (Tensor):形状为 (batch, 1) 的张量,表示用于 top-k 采样时考虑的顶级概率数量。 * **返回:result**:经过过滤和标准化的张量,以样本形状作为输入概率。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ### tvm.relax.frontend.nn.repeat(*x: Tensor*, *repeats:*[int](https://docs.python.org/3/library/functions.html#int), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *name='repeat'*) → Tensor 重复数组的元素。 * **参数:** - * **data** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入张量。 + * **data** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入张量。 * repeats (int):重复次数。 * axis (Optional[int]):重复值的轴。负数从后向前计数。默认情况下,使用展平的输入数组,并返回一个展平的输出数组。 * name (str):名称提示。 @@ -1392,7 +1392,7 @@ lv1 = repeat(x, repeats=2) # lv1 == [1, 1, 2, 2, 3, 3, 4, 4] lv2 = repeat(x, repeats=2, axis=1) # lv2 == [[1., 1., 2., 2.], # [3., 3., 4., 4.]] ``` -## tvm.relax.frontend.nn.reshape(*x: Tensor*, *shape:*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*, *name='reshape'*) → Tensor +## tvm.relax.frontend.nn.reshape(*x: Tensor*, *shape:*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*, *name='reshape'*) → Tensor 变形输入数组。 @@ -1404,13 +1404,13 @@ lv2 = repeat(x, repeats=2, axis=1) # lv2 == [[1., 1., 2., 2.], >x.shape = (2, 3, 4), shape = (3, -1, 8), result.shape = (3, 1, 8) >x.shape = (2, 3, 4), shape = (-1,), result.shape = (24,) * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):运算符的输入数据。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):运算符的输入数据。 * shape (Sequence[IntExpr]):新的形状。应与原始形状兼容。 * name (str):名称提示。 * **返回:result**:变形的结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 -:::Note +:::note 推断`-1`仅在编译时进行。也就是说,如果`-1`在编译时无法推断出维度的长度,则会抛出错误。 @@ -1423,13 +1423,13 @@ lv2 = repeat(x, repeats=2, axis=1) # lv2 == [[1., 1., 2., 2.], $$out = \frac{data}{\sqrt{mean(data, axis)+\epsilon}} * weight$$ * **参数:** - * **data** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):将应用 rms_norm 的输入。 + * **data** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):将应用 rms_norm 的输入。 * 权重 (Tensor):缩放因子。 * 轴 (Union[int, List[int]]):沿着这些轴应用归一化的轴。 * epsilon (float):在平方均值上添加的小浮点数,以避免除以零。 * name (str)**:** 名称提示。 * **返回:result**:计算结果。 -* 返回类型;[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型;[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.sample_top_p_top_k_from_sorted_prob(*sorted_prob: Tensor*, *sorted_index: Tensor*, *top_p: Tensor*, *top_k: Tensor*, *uniform_sample: Tensor*, *sample_indices: Tensor |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) @@ -1440,13 +1440,13 @@ $$out = \frac{data}{\sqrt{mean(data, axis)+\epsilon}} * weight$$ 为了获得准确的结果,请确保概率介于 0 和 1 之间且总和为 1。 * **参数:** - * **sorted_prob** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):一个二维张量,形状为(batch,vocab_size),包含按降序排列的概率。 + * **sorted_prob** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):一个二维张量,形状为(batch,vocab_size),包含按降序排列的概率。 * sorted_index (张量):形状为 (batch, vocab_size) 的索引张量,对应于 sorted_prob。可能来自对原始概率张量按降序应用 argsort。 * top_p (Tensor):核心采样中使用的累积概率阈值,形状为 (batch, 1)。top_k (Tensor):形状为 (batch, 1) 的张量,表示用于 top-k 采样时考虑的顶级概率数量。 * uniform_sample (张量):使用形状为 (n, 1) 的均匀采样值来选择输出索引。 * sample_indices (Optional[Tensor]):可选的 2-D 张量,形状为[n, 1],用于指示需要从中采样的特定概率分布。sample_indices[i]的值决定了第 i 个 token 应该从第 sample_indices[i]个概率分布中采样。例如,如果有 3 个不同的概率分布,并且需要从每个分布中采样 2、3 和 4 个 token,那么 sample_indices 将是[0, 0, 1, 1, 1, 2, 2, 2, 2]。 * **返回:result**:选定的形状为 (n, 1) 的索引。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 **示例** @@ -1471,7 +1471,7 @@ sample_indices = [[0], [1]] 计算给定注意力查询、键和值的缩放点积注意力。与 torch 函数实现兼容。 * **参数:** - * **query** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):表示当前形状为 [batch, seq_len, num_heads, head_size] 的注意力。 + * **query** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):表示当前形状为 [batch, seq_len, num_heads, head_size] 的注意力。 * key (Tensor):代表交叉注意力映射的张量,形状为 [batch, seq_len_kv, num_heads_kv, head_size]。查找的张量。 * value (Tensor):代表嵌入注意力值的张量,形状为 [batch, seq_len_kv, num_heads_kv, head_size_value]。 * attn_mask (Optional[Tensor]):可选的注意力掩码,目前尚未支持。 @@ -1486,10 +1486,10 @@ sample_indices = [[0], [1]] $$\text{sigmoid}(x) = \frac{1}{1 + \exp(-x)}$$ * **参数:** - * **data** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):运算符的输入数据。 + * **data** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):运算符的输入数据。 * name (str):名称提示。 * **返回:result**:计算结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 :::note @@ -1504,12 +1504,12 @@ Sigmoid 线性单元函数。 $$\text{SiLU}(x) = x * \text{sigmoid}(x)$$ * **参数:** - * **data** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入数据。 + * **data** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入数据。 * name (str):名称提示。 * **返回:result**:计算结果。 * 返回类型:Tensor  张量。 -:::Note +:::note 输入张量需要具有浮点型。 @@ -1522,13 +1522,13 @@ $$\text{SiLU}(x) = x * \text{sigmoid}(x)$$ $$\text{softmax}(x)_i = \frac{\exp(x_i)}{\sum_j \exp(x_j)}$$ * **参数:** - * **data** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):运算符的输入数据。 + * **data** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):运算符的输入数据。 * axis (int):计算 softmax 时沿其进行求和的轴。如果未指定,默认为输入张量的最后一个轴。支持负索引。 * name (str):名称提示。 * **返回:result**:计算结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 -:::Note +:::note 输入张量需要具有浮点型。 @@ -1542,7 +1542,7 @@ Softplus 激活函数。 $$\text{Softplus}(x) = \frac{1}{\beta} \log(1 + e^{\beta x})$$ * **参数:** * **data** (*relax.Expr*):输入数据。 - * beta (float, 可选)[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)控制过渡的平滑度。默认值为 1.0。 + * beta (float, 可选)[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)控制过渡的平滑度。默认值为 1.0。 * 阈值(float,可选)超过该值后,函数被视为线性以避免数值不稳定性。默认为 20.0。 * **返回:result**:计算结果。 * 返回类型:relax.Expr。 @@ -1552,24 +1552,24 @@ $$\text{Softplus}(x) = \frac{1}{\beta} \log(1 + e^{\beta x})$$ 沿给定轴执行排序并按排序顺序返回数组。 * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)输入张量。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)输入张量。 * axis (int):沿着哪个轴对输入张量进行排序。默认情况下使用输入的最后一个轴。 * 降序(bool)是否按降序排序,默认为 False。 * name (str):名称提示。 * **返回:out**:排序后的张量。 -* 返回类型:[Tensor 张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor 张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.split(*ary: Tensor*, *indices_or_sections:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*, *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= 0*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'split'*) → [Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)[Tensor, …] 将数组拆分为多个子数组。 * **参数:** - * **ary** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):要分割的输入张量。 + * **ary** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):要分割的输入张量。 * indices_or_sections (Union[int, Sequence[int]]):用于分割的索引或片段。 * axis (int = 0):沿其分割的轴,默认为 0。 * name (str)**:** 名称提示。 * **返回:result**:拆分结果的子数组列表。 -* 返回类型:[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)[[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor), …] +* 返回类型:[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)[[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor), …] @@ -1578,12 +1578,12 @@ $$\text{Softplus}(x) = \frac{1}{\beta} \log(1 + e^{\beta x})$$ 计算输入张量的逐元素平方根。 * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入张量。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入张量。 * name (str):名称提示。 * **返回:result**:计算结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 -:::Note +:::note 输入张量需要具有浮点型。 @@ -1593,17 +1593,17 @@ $$\text{Softplus}(x) = \frac{1}{\beta} \log(1 + e^{\beta x})$$ 计算输入张量的逐元素平方。 * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入张量。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入张量。 * name (str):名称提示。 * **返回:result**:计算结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.squeeze(*x: Tensor*, *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= -1*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'squeeze'*) → Tensor 挤压阵列中的轴。 * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):运算符的输入数据。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):运算符的输入数据。 * axis (可选[Union[int, List[int]]):要移除的轴集。如果 axis = None,则移除所有维度为 1 的轴。如果任何指定的轴的维度不等于 1,则会产生错误。 * name (str):名称提示。 * **返回:result**:压缩的结果。 @@ -1614,11 +1614,11 @@ $$\text{Softplus}(x) = \frac{1}{\beta} \log(1 + e^{\beta x})$$ 使用 numpy 风格的广播进行减法。 * **参数:** - * **a** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):第一个输入张量。 + * **a** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):第一个输入张量。 * b (Tensor):第二个输入张量。 * name (str):名称提示。 * **返回:result**:计算结果。 -* 返回类型:[Tensor 张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor 张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 **示例** @@ -1631,12 +1631,12 @@ c = subtract(a, b) 计算给定轴上张量元素的总和。 * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))[:](https://pytorch.org/docs/stable/generated/torch.take.html)输入数据张量。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))[:](https://pytorch.org/docs/stable/generated/torch.take.html)输入数据张量。 * axis (Optional[Union[int, List[int]]]):指定进行求和的轴或轴。默认值 axis=None 将对输入张量的所有元素求和。支持负索引。 * keepdims (bool)[:](https://pytorch.org/docs/stable/generated/torch.take.html)如果设置为 True,被缩减的轴将保留为结果中的尺寸为一的维度。使用此选项,结果将正确地广播与输入张量。 * name (str)[:](https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Gather-13)该操作的名称提示。 * **返回:result**:计算结果。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 @@ -1645,12 +1645,12 @@ c = subtract(a, b) 沿某个轴从张量中获取元素。其语义与 numpy.take ( [https://numpy.org/doc/stable/reference/generated/numpy.take.html](https://numpy.org/doc/stable/reference/generated/numpy.take.html) )非常相似,后者可以覆盖 torch.take ( [https://pytorch.org/docs/stable/generated/torch.take.html](https://pytorch.org/docs/stable/generated/torch.take.html) ) 和 onnx.gather ( [https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Gather-13](https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Gather-13) ) 。 * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):源张量。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):源张量。 * indices (Tensor):要提取的值的索引。 * axis (可选[int]):指定选择值的轴。如果为 none,输入张量必须是一维的。 * name (str):名称提示。 * **返回:ret**:获取的结果。 -* 返回类型:[Tensor 张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor 张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.tanh(*x: Tensor*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'tanh'*) → Tensor @@ -1659,18 +1659,18 @@ c = subtract(a, b) $$\text{Tanh}(x) = \frac{e^x - e^{-x}}{e^x + e^{-x}}$$ * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):运算符的输入数据。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):运算符的输入数据。 * name (str):名称提示。 * **返回:result**:计算结果。 * 返回类型:Tensor  张量。 -:::Note +:::note 输入张量需要具有浮点型。 ::: -## tvm.relax.frontend.nn.tensor_expr_op(*tensor_expr_func:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable), *name_hint:*[str](https://docs.python.org/3/library/stdtypes.html#str), *args:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[Tensor |*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)*|*[int](https://docs.python.org/3/library/functions.html#int)*]*, *, *attrs: [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)[[str](https://docs.python.org/3/library/stdtypes.html#str), [Any](https://docs.python.org/3/library/typing.html#typing.Any)] | [None](https://docs.python.org/3/library/constants.html#None) = None*) +## tvm.relax.frontend.nn.tensor_expr_op(*tensor_expr_func:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable), *name_hint:*[str](https://docs.python.org/3/library/stdtypes.html#str), *args:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[Tensor |*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)*|*[int](https://docs.python.org/3/library/functions.html#int)*]*, *, *attrs: [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)[[str](https://docs.python.org/3/library/stdtypes.html#str), [Any](https://docs.python.org/3/library/typing.html#typing.Any)] | [None](https://docs.python.org/3/library/constants.html#None) = None*) 使用 te 构建给定的 tensor_expr_func。 @@ -1682,7 +1682,7 @@ $$\text{Tanh}(x) = \frac{e^x - e^{-x}}{e^x + e^{-x}}$$ * **返回:result**:结果张量。 * 返回类型:Tensor  张量。 -## tvm.relax.frontend.nn.tensor_ir_inplace_op(*func:*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc), *name_hint:*[str](https://docs.python.org/3/library/stdtypes.html#str), *args: Tensor |*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[Tensor |*[ShapeExpr](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ShapeExpr)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*, *inplace_indices:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*, *out: OutType*) → OutType +## tvm.relax.frontend.nn.tensor_ir_inplace_op(*func:*[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone), *name_hint:*[str](https://docs.python.org/3/library/stdtypes.html#str), *args: Tensor |*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[Tensor |*[ShapeExpr](/docs/api-reference/python-api/tvm-relax#classtvmrelaxshapeexprvalueslistprimexprtupleprimexprarrayspanspannonenone)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*, *inplace_indices:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*, *out: OutType*) → OutType 使用给定的 PrimFunc 创建 call_tir_inplace 绑定 @@ -1695,7 +1695,7 @@ $$\text{Tanh}(x) = \frac{e^x - e^{-x}}{e^x + e^{-x}}$$ * **返回:result**:结果张量。 * 返回类型:Tensor  张量。 -## tvm.relax.frontend.nn.tensor_ir_op(*func:*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc), *name_hint:*[str](https://docs.python.org/3/library/stdtypes.html#str), *args: Tensor |*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[Tensor |*[ShapeExpr](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ShapeExpr)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*, *out: OutType*) → OutType +## tvm.relax.frontend.nn.tensor_ir_op(*func:*[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone), *name_hint:*[str](https://docs.python.org/3/library/stdtypes.html#str), *args: Tensor |*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[Tensor |*[ShapeExpr](/docs/api-reference/python-api/tvm-relax#classtvmrelaxshapeexprvalueslistprimexprtupleprimexprarrayspanspannonenone)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*, *out: OutType*) → OutType 使用给定的 PrimFunc 创建 call_tir 绑定。 @@ -1705,7 +1705,7 @@ $$\text{Tanh}(x) = \frac{e^x - e^{-x}}{e^x + e^{-x}}$$ * args (Union[Tensor, Sequence[Union[Tensor, rx.ShapeExpr, _tir.PrimExpr]]]):传递给 PrimFunc 的参数。 * out (Union[Tensor, List[Tensor]]):输出张量。 * **返回:result**:结果张量。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.topk(*data: Tensor*, *k:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= -1*, *ret_type:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'both'*, *largest:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'int32'*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'topk'*) @@ -1714,7 +1714,7 @@ $$\text{Tanh}(x) = \frac{e^x - e^{-x}}{e^x + e^{-x}}$$ ret_type specifies the return type, can be one of (“both”, “values”, “indices”). * **参数:** - * **data** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入数据张量。 + * **data** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入数据张量。 * k (int)**:** 选择顶部元素的数量。如果 k < 1,则返回所有元素。 * axis (int):按此轴对输入张量进行排序。 * ret_type (str):返回类型 [both, values, indices]。“both”:同时返回顶部 k 数据和索引。“values”:仅返回顶部 k 数据。“indices”:仅返回顶部 k 索引。 @@ -1729,11 +1729,11 @@ ret_type specifies the return type, can be one of (“both”, “values”, “ 返回矩阵或一批矩阵的上三角部分。 * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 将应用 triu 的张量。它至少需要两个维度。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 将应用 triu 的张量。它至少需要两个维度。 * k (int):指示要置零元素的 diagonals 以下索引。如果 k = 0,对角线是主对角线。如果 k < 0,对角线在主对角线下方。如果 k > 0,对角线在主对角线上方。 * name (str):名称提示。 * **返回:ret**:结果张量。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.relax.frontend.nn.unsqueeze(*x: Tensor*, *dim:*[int](https://docs.python.org/3/library/functions.html#int), *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'unsqueeze'*) → Tensor @@ -1741,7 +1741,7 @@ ret_type specifies the return type, can be one of (“both”, “values”, “ 向张量添加新轴 * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):要扩展的输入张量。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):要扩展的输入张量。 * dim (int):要扩展的维度。 * name (str):该算子的名称提示。 * **返回:result**:扩展结果。 @@ -1755,14 +1755,14 @@ ret_type specifies the return type, can be one of (“both”, “values”, “ 对于给定的位置,如果条件为 True,则返回 x1中的对应值,否则返回 x2中的对应值。 * **参数:** - * **condition** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):为 True 时,输出 x1;否则,输出 x2。必须与 x1和 x2广播兼容。必须为布尔类型。 + * **condition** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):为 True 时,输出 x1;否则,输出 x2。必须与 x1和 x2广播兼容。必须为布尔类型。 * x1 (Tensor):第一个输入张量。必须与 condition 和 x2 兼容广播。 * x2 (Tensor):第二个输入张量。必须与 condition 和 x1 兼容广播。 * name (str):名称提示。 * **返回:result**:结果张量。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 -## tvm.relax.frontend.nn.wrap_nested(*expr:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → Tensor | [Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)[Tensor] +## tvm.relax.frontend.nn.wrap_nested(*expr:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → Tensor | [Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)[Tensor] 包装给定的 relax.Expr,使用当前的 BlockBuilder 发出它,并且如果 expr 代表 Tuple 则自动处理嵌套情况。 @@ -1772,7 +1772,7 @@ ret_type specifies the return type, can be one of (“both”, “values”, “ * **返回:result**:计算结果。 * 返回类型:Union[Tensor, Tuple[Tensor]]。 -## tvm.relax.frontend.nn.zeros(*shape:*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'float32'*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'zeros'*) → Tensor +## tvm.relax.frontend.nn.zeros(*shape:*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'float32'*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'zeros'*) → Tensor 构建一个全零的张量,具有输入形状和 dtype。 * **参数:** @@ -1780,7 +1780,7 @@ ret_type specifies the return type, can be one of (“both”, “values”, “ * dtype (str):创建的张量的数据类型。 * name (str)**:** 名称提示。 * **返回:result** :结果张量。 -* 返回类型:[Tensor  张量](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* 返回类型:[Tensor  张量](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## @@ -1790,7 +1790,7 @@ ret_type specifies the return type, can be one of (“both”, “values”, “ 将 ONNX 图转换为 Relax 图的工具。 -## tvm.relax.frontend.onnx.from_onnx(*model: GraphProto*, *shape_dict:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[List](https://docs.python.org/3/library/typing.html#typing.List)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *dtype_dict:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= 'float32'*, *opset:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *keep_params_in_input:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *sanitize_input_names:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule) +## tvm.relax.frontend.onnx.from_onnx(*model: GraphProto*, *shape_dict:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[List](https://docs.python.org/3/library/typing.html#typing.List)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *dtype_dict:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= 'float32'*, *opset:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *keep_params_in_input:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *sanitize_input_names:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone) 将 ONNX 模型转换为等效的 Relax 函数。ONNX 图表示为 Python Protobuf 对象。 @@ -1814,7 +1814,7 @@ ret_type specifies the return type, can be one of (“both”, “values”, “ 用于构建 Relax 程序的 StableHLO 前端,包含模型导入器。 -## tvm.relax.frontend.stablehlo.from_stablehlo(*stablehlo_module*, *input_info:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*],*[str](https://docs.python.org/3/library/stdtypes.html#str)*]] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule) +## tvm.relax.frontend.stablehlo.from_stablehlo(*stablehlo_module*, *input_info:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*],*[str](https://docs.python.org/3/library/stdtypes.html#str)*]] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone) 将 StableHLO 模块转换为 Relax 程序 @@ -1828,7 +1828,7 @@ ret_type specifies the return type, can be one of (“both”, “values”, “ 用于构建 Relax 程序的 PyTorch 前端,带有模型导入器。 -## tvm.relax.frontend.torch.from_exported_program(*exported_program: ExportedProgram*, *, *keep_params_as_input: [bool](https://docs.python.org/3/library/functions.html#bool) = False*, *unwrap_unit_return_tuple: [bool](https://docs.python.org/3/library/functions.html#bool) = False*, *no_bind_return_tuple: [bool](https://docs.python.org/3/library/functions.html#bool) = False*) → [IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule) +## tvm.relax.frontend.torch.from_exported_program(*exported_program: ExportedProgram*, *, *keep_params_as_input: [bool](https://docs.python.org/3/library/functions.html#bool) = False*, *unwrap_unit_return_tuple: [bool](https://docs.python.org/3/library/functions.html#bool) = False*, *no_bind_return_tuple: [bool](https://docs.python.org/3/library/functions.html#bool) = False*) → [IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone) 将 PyTorch ExportedProgram 转换为 Relax 程序。 @@ -1873,7 +1873,7 @@ exported_program = export(torch_model, args=example_args) # 使用导入器导入 ExportedProgram 到 Relax。 mod: tvm.IRModule = from_exported_program(exported_program) ``` -## tvm.relax.frontend.torch.from_fx(*model*, *input_info:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*],*[str](https://docs.python.org/3/library/stdtypes.html#str)*]]*, *, *keep_params_as_input: [bool](https://docs.python.org/3/library/functions.html#bool) = False*, *unwrap_unit_return_tuple: [bool](https://docs.python.org/3/library/functions.html#bool) = False*, *no_bind_return_tuple: [bool](https://docs.python.org/3/library/functions.html#bool) = False*, *custom_convert_map: [dict](https://docs.python.org/3/library/stdtypes.html#dict) | [None](https://docs.python.org/3/library/constants.html#None) = None*) → [IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule) +## tvm.relax.frontend.torch.from_fx(*model*, *input_info:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*],*[str](https://docs.python.org/3/library/stdtypes.html#str)*]]*, *, *keep_params_as_input: [bool](https://docs.python.org/3/library/functions.html#bool) = False*, *unwrap_unit_return_tuple: [bool](https://docs.python.org/3/library/functions.html#bool) = False*, *no_bind_return_tuple: [bool](https://docs.python.org/3/library/functions.html#bool) = False*, *custom_convert_map: [dict](https://docs.python.org/3/library/stdtypes.html#dict) | [None](https://docs.python.org/3/library/constants.html#None) = None*) → [IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone) 将 PyTorch FX GraphModule 转换为 Relax 程序。 @@ -1942,14 +1942,14 @@ fx.symbolic_trace(model).graph.print_tabular() 打印出 PyTorch 模块的表格表示,然后检查表格开头的占位符行。 -## tvm.relax.frontend.torch.relax_dynamo(*pipeline:*[Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## tvm.relax.frontend.torch.relax_dynamo(*pipeline:*[Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) 用于创建 Relax 后端的辅助函数。 -* **参数:pipeline** (*Optional[*[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)*]*):在发送构建之前要应用于 Relax 模块的管道。 +* **参数:pipeline** (*Optional[*[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)*]*):在发送构建之前要应用于 Relax 模块的管道。 * **返回:backend**:Relax Dynamo 后端。 * 返回类型:Callable[[torch.fx.GraphModule, List[torch.Tensor]], Callable]。 -## tvm.relax.frontend.torch.dynamo_capture_subgraphs(*model*, params*, ***kwargs*) → [IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule) +## tvm.relax.frontend.torch.dynamo_capture_subgraphs(*model*, params*, ***kwargs*) → [IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone) 使用 torch.compile 将 PyTorch 模型的子图捕获到 IRModule 中。 diff --git a/docs/04-api-reference/01-python-api/15-tvm-relax-op.md b/docs/04-api-reference/01-python-api/15-tvm-relax-op.md index f3a84fe..ad52867 100644 --- a/docs/04-api-reference/01-python-api/15-tvm-relax-op.md +++ b/docs/04-api-reference/01-python-api/15-tvm-relax-op.md @@ -7,28 +7,28 @@ title: tvm.relax.op Relax 核心运算符。 -## tvm.relax.op.assert_op(*condition:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *format_args:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *format:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*= ''*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.assert_op(*condition:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *format_args:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *format:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*= ''*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 创建一个对 Relax 的 assert_op 操作的调用(在 Python 中,assert 是保留字,因此名称必须不同)。 * **参数:** - * **condition** (*Union*[***Expr,*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*):断言条件。 + * **condition** (*Union*[***Expr,*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*):断言条件。 * **format_args** (*Optional*[****Union**[**Expr,*** ***List****[**Expr**]]*]*):如果条件失败,则为错误消息提供格式化参数。 * **format** (*Union*[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,***Expr***]):错误消息的格式字符串或 StringImm。 * **返回:result**:一个调用 Relax 断言操作的 relax.Call。 * **返回类型:** Expr。 -## tvm.relax.op.call_builtin_with_ctx(*func:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *args:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *, *sinfo_args: [StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo) | [List](https://docs.python.org/3/library/typing.html#typing.List)[[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)] | [None](https://docs.python.org/3/library/constants.html#None) = None*) → [Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call) +## tvm.relax.op.call_builtin_with_ctx(*func:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *args:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *, *sinfo_args: [StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo) | [List](https://docs.python.org/3/library/typing.html#typing.List)[[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)] | [None](https://docs.python.org/3/library/constants.html#None) = None*) → [Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone) relax.Call 内置函数。 * **参数:** * **func** (*Expr*):要调用的内置函数。 * **args** (*Expr*)**:** 输入参数。 - * **sinfo_args** (*Optional*[****Union**[***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)***,** **List**[*[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)*]**]** *]*):调用节点中的结构信息参数。 -* **返回:ret**[:](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call)创建的调用节点。 -* **返回类型:**[relax.Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call)。 + * **sinfo_args** (*Optional*[****Union**[***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)***,** **List**[*[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)*]**]** *]*):调用节点中的结构信息参数。 +* **返回:ret**:创建的调用节点。 +* **返回类型:**[relax.Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone)。 -## tvm.relax.op.call_dps_packed(*func:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *args:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *out_sinfo:*[TensorStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TensorStructInfo)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[TensorStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TensorStructInfo)*]*) → [Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call) +## tvm.relax.op.call_dps_packed(*func:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *args:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *out_sinfo:*[TensorStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtensorstructinfoshaperelaxexprnonelistprimexprnonedtypestrfloat32vdevicevdevicenonestrnonendimint-1spanspannonenone)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[TensorStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtensorstructinfoshaperelaxexprnonelistprimexprnonedtypestrfloat32vdevicevdevicenonestrnonendimint-1spanspannonenone)*]*) → [Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone) relax.Call 一个目标传递风格的打包函数并返回输出。 @@ -38,11 +38,11 @@ relax.Call 一个目标传递风格的打包函数并返回输出。 * **参数:** * **func** (*Union[***[str](https://docs.python.org/3/library/stdtypes.html#str)**,****Expr****]):目标传递风格的函数,可以是 ExternFunc。 * **args** (*Expr*):输入参数。 - * **out_sinfo** (*Union*[***[TensorStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TensorStructInfo)***,***List***[*[TensorStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TensorStructInfo)*]]*):call_dps_packed 输出的结构信息。它应该是一个 TensorStructInfo 或 TensorStructInfo 列表。每个元素表示一个返回张量的结构信息。 + * **out_sinfo** (*Union*[***[TensorStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtensorstructinfoshaperelaxexprnonelistprimexprnonedtypestrfloat32vdevicevdevicenonestrnonendimint-1spanspannonenone)***,***List***[*[TensorStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtensorstructinfoshaperelaxexprnonelistprimexprnonedtypestrfloat32vdevicevdevicenonestrnonendimint-1spanspannonenone)*]]*):call_dps_packed 输出的结构信息。它应该是一个 TensorStructInfo 或 TensorStructInfo 列表。每个元素表示一个返回张量的结构信息。 * **返回:ret:** 一个用于 call_dps_packed 操作的调用节点。 -* **返回类型:**[relax.Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call) +* **返回类型:**[relax.Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone) -## tvm.relax.op.call_inplace_packed(*func:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[ExternFunc](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ExternFunc)*|*[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar), args:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *inplace_indices:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*, *sinfo_args:*[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)*]*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.call_inplace_packed(*func:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[ExternFunc](/docs/api-reference/python-api/tvm-relax#classtvmrelaxexternfuncglobal_symbolstringstruct_infostructinfononenonespanspannonenone)*|*[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none), args:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *inplace_indices:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*, *sinfo_args:*[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)*]*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 构造一个调用打包函数的调用,该函数会消耗其部分参数「就地」并返回被修改的参数(别名),但应被视为其他方面是纯函数。inplace_indices 参数指示哪些输出是被修改的参数。 @@ -56,14 +56,14 @@ relax.Call 一个目标传递风格的打包函数并返回输出。 警告:此运算符在类型系统中被视为纯操作,即使它执行了副作用(修改某些参数)。因此,用户必须确保它被安全使用(即,修改后的参数在修改后不应处于活动状态,它们不应在修改后别名化值)。 * **参数:** - * **func** ( *Union [*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[ExternFunc](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ExternFunc)*]* ):PackedFunc 或 ExternFunc 节点的名称(全局符号)。 + * **func** ( *Union [*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[ExternFunc](/docs/api-reference/python-api/tvm-relax#classtvmrelaxexternfuncglobal_symbolstringstruct_infostructinfononenonespanspannonenone)*]* ):PackedFunc 或 ExternFunc 节点的名称(全局符号)。 * **args** ( *Expr* ):PackedFunc 的参数。 * **inplace_indices** ( *Union [*[int](https://docs.python.org/3/library/functions.html#int)*, List [*[int](https://docs.python.org/3/library/functions.html#int)*] ]* ):指定哪些参数应用于就地计算。如果inplace_indices是单个整数,它将被转换为单例列表。假设inplace_indices[i] = j,其中j >= 0。则第 i 个输出将是 `args[j] 的别名。如果inplace_indices[i] = -1,则第 i 个输出将是新分配的张量。`inplace_indices 中至少有一个成员不能为 -1。 - * **sinfo_args** ( *Union [*[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)*, List [*[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)*] ]* ):结构信息参数列表(提供返回值的结构信息)。 + * **sinfo_args** ( *Union [*[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)*, List [*[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)*] ]* ):结构信息参数列表(提供返回值的结构信息)。 * **返回:result**:Relax 调用,对应于 call_pure_packed(ExternFunc(func), args, DictAttrs(kwargs), sinfo_args)。 * **返回类型:** Expr。 -## tvm.relax.op.call_pure_packed(*func:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[ExternFunc](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ExternFunc)*|*[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar), args:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *sinfo_args:*[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)*]*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.call_pure_packed(*func:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[ExternFunc](/docs/api-reference/python-api/tvm-relax#classtvmrelaxexternfuncglobal_symbolstringstruct_infostructinfononenonespanspannonenone)*|*[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none), args:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *sinfo_args:*[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)*]*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 构建一个调用打包函数的调用,即使打包调用通常不被视为纯函数。 @@ -74,25 +74,25 @@ relax.Call 一个目标传递风格的打包函数并返回输出。 注意:这应该用于用户知道使用这些参数调用打包函数实际上不会产生任何副作用的情况。如果用于一个确实会导致副作用的调用,那么编译器可能会最终移除、重新排序或重复该调用,并且对被调用方的任何副作用不做任何保证。 * **参数:** - * **func** (*Union[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[ExternFunc](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ExternFunc)*]*):PackedFunc 或 ExternFunc 节点的名称(全局符号)。 + * **func** (*Union[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[ExternFunc](/docs/api-reference/python-api/tvm-relax#classtvmrelaxexternfuncglobal_symbolstringstruct_infostructinfononenonespanspannonenone)*]*):PackedFunc 或 ExternFunc 节点的名称(全局符号)。 * **args** (*Expr*):PackedFunc 的参数。 - * **sinfo_args** (*Union*[***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)***,******List****[*[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)*]]):返回值结构信息的参数列表。 + * **sinfo_args** (*Union*[***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)***,******List****[*[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)*]]):返回值结构信息的参数列表。 * **返回:result**:一个 Relax 调用,对应于 call_pure_packed(ExternFunc(func), args, DictAttrs(kwargs), sinfo_args)。 * **返回类型:** Expr。 -## tvm.relax.op.call_tir(*gvar:*[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar), *args:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *out_sinfo:*[TensorStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TensorStructInfo)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[TensorStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TensorStructInfo)*]*, *tir_vars:*[ShapeExpr](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ShapeExpr)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*] |*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call) +## tvm.relax.op.call_tir(*gvar:*[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none), *args:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *out_sinfo:*[TensorStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtensorstructinfoshaperelaxexprnonelistprimexprnonedtypestrfloat32vdevicevdevicenonestrnonendimint-1spanspannonenone)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[TensorStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtensorstructinfoshaperelaxexprnonelistprimexprnonedtypestrfloat32vdevicevdevicenonestrnonendimint-1spanspannonenone)*]*, *tir_vars:*[ShapeExpr](/docs/api-reference/python-api/tvm-relax#classtvmrelaxshapeexprvalueslistprimexprtupleprimexprarrayspanspannonenone)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*] |*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone) relax.Call 一个 tir.prim_func 并返回输出。 * **参数:** - * **gvar** ([GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar)):指向 tir PrimFunc 的 GlobalVar。 + * **gvar** ([GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none)):指向 tir PrimFunc 的 GlobalVar。 * **args** (*Expr*):输入参数。 - * **out_sinfo** (*Union*[***[TensorStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TensorStructInfo)***,***List***[*[TensorStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TensorStructInfo)*]]):调用_tir 的输出结构信息。它应该是一个 TensorStructInfo 或 TensorStructInfo 的列表。每个元素表示一个返回张量的结构信息。 - * **tir_vars** (*Optional*[****Union**[***[ShapeExpr](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ShapeExpr)***,** [Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)***]***,List[***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)***]*]]*):表示调用 func 时解包的整数元组的 ShapeExpr。如果未使用则为 null。 + * **out_sinfo** (*Union*[***[TensorStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtensorstructinfoshaperelaxexprnonelistprimexprnonedtypestrfloat32vdevicevdevicenonestrnonendimint-1spanspannonenone)***,***List***[*[TensorStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtensorstructinfoshaperelaxexprnonelistprimexprnonedtypestrfloat32vdevicevdevicenonestrnonendimint-1spanspannonenone)*]]):调用_tir 的输出结构信息。它应该是一个 TensorStructInfo 或 TensorStructInfo 的列表。每个元素表示一个返回张量的结构信息。 + * **tir_vars** (*Optional*[****Union**[***[ShapeExpr](/docs/api-reference/python-api/tvm-relax#classtvmrelaxshapeexprvalueslistprimexprtupleprimexprarrayspanspannonenone)***,** [Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)***]***,List[***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)***]*]]*):表示调用 func 时解包的整数元组的 ShapeExpr。如果未使用则为 null。 * **返回:ret**:call_tir 运算符的调用节点。 -* **返回类型:**[relax.Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call)。 +* **返回类型:**[relax.Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone)。 -## tvm.relax.op.call_tir_inplace(*gvar:*[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar), *args:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *inplace_indices:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*, *out_sinfo:*[TensorStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TensorStructInfo)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[TensorStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TensorStructInfo)*]*, *tir_vars:*[ShapeExpr](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ShapeExpr)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*] |*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call) +## tvm.relax.op.call_tir_inplace(*gvar:*[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none), *args:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *inplace_indices:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*, *out_sinfo:*[TensorStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtensorstructinfoshaperelaxexprnonelistprimexprnonedtypestrfloat32vdevicevdevicenonestrnonendimint-1spanspannonenone)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[TensorStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtensorstructinfoshaperelaxexprnonelistprimexprnonedtypestrfloat32vdevicevdevicenonestrnonendimint-1spanspannonenone)*]*, *tir_vars:*[ShapeExpr](/docs/api-reference/python-api/tvm-relax#classtvmrelaxshapeexprvalueslistprimexprtupleprimexprarrayspanspannonenone)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*] |*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone) relax 调用 TIR PrimFunc 并返回结果,在指定位置执行计算(基于 inplace_indices 参数;输出将与通过 in-place 索引选择的输入别名)。 @@ -103,48 +103,48 @@ relax 调用 TIR PrimFunc 并返回结果,在指定位置执行计算(基于 仅应出于测试目的对此运算符进行直接调用。 * **参数:** - * **gvar** ( [GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar) ):GlobalVar 引用 TIR PrimFunc。 + * **gvar** ( [GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none) ):GlobalVar 引用 TIR PrimFunc。 * **args** ( *Expr* )**:** 输入参数。 * **inplace_indices** ( *Union [*[int](https://docs.python.org/3/library/functions.html#int)*, List [*[int](https://docs.python.org/3/library/functions.html#int)*] ]* ):指定哪些参数应用于就地计算。如果inplace_indices是单个整数,它将被转换为单例列表。假设inplace_indices[i] = j,其中j >= 0。则第 i 个输出将是 `args[j] 的别名。如果inplace_indices[i] = -1,则第 i 个输出将是新分配的张量。`inplace_indices 中至少有一个成员不能为 -1。 - * **out_sinfo** ( *Union [*[TensorStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TensorStructInfo)*, List [*[TensorStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TensorStructInfo)*] ]* ):call_tir_inplace 输出的结构信息。它应该是一个TensorStructInfo或一个TensorStructInfo列表。每个列表表示返回张量的结构信息。如果给出一个TensorStructInfo列表,则结果将是一个TensorStructInfo元组。 - * **tir_vars** ( *Optional [ Union [*[ShapeExpr](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ShapeExpr)*,*[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)*[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*] , List [*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*] ] ]* ):ShapeExpr 表示调用 func 时需要解包的整数元组。若未使用则为 null。 + * **out_sinfo** ( *Union [*[TensorStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtensorstructinfoshaperelaxexprnonelistprimexprnonedtypestrfloat32vdevicevdevicenonestrnonendimint-1spanspannonenone)*, List [*[TensorStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtensorstructinfoshaperelaxexprnonelistprimexprnonedtypestrfloat32vdevicevdevicenonestrnonendimint-1spanspannonenone)*] ]* ):call_tir_inplace 输出的结构信息。它应该是一个TensorStructInfo或一个TensorStructInfo列表。每个列表表示返回张量的结构信息。如果给出一个TensorStructInfo列表,则结果将是一个TensorStructInfo元组。 + * **tir_vars** ( *Optional [ Union [*[ShapeExpr](/docs/api-reference/python-api/tvm-relax#classtvmrelaxshapeexprvalueslistprimexprtupleprimexprarrayspanspannonenone)*,*[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)*[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*] , List [*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*] ] ]* ):ShapeExpr 表示调用 func 时需要解包的整数元组。若未使用则为 null。 * **返回:ret**:call_tir 运算符的调用节点。 -* **返回类型:**[relax.Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call)。 +* **返回类型:**[relax.Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone)。 -## tvm.relax.op.call_tir_with_grad(*gvar:*[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar), *args:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *out_sinfo:*[TensorStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TensorStructInfo)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[TensorStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TensorStructInfo)*]*, *te_grad_name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *te_grad_kwargs:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*, Object] = None*, *tir_vars:*[ShapeExpr](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ShapeExpr)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*] |*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call) +## tvm.relax.op.call_tir_with_grad(*gvar:*[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none), *args:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *out_sinfo:*[TensorStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtensorstructinfoshaperelaxexprnonelistprimexprnonedtypestrfloat32vdevicevdevicenonestrnonendimint-1spanspannonenone)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[TensorStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtensorstructinfoshaperelaxexprnonelistprimexprnonedtypestrfloat32vdevicevdevicenonestrnonendimint-1spanspannonenone)*]*, *te_grad_name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *te_grad_kwargs:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*, Object] = None*, *tir_vars:*[ShapeExpr](/docs/api-reference/python-api/tvm-relax#classtvmrelaxshapeexprvalueslistprimexprtupleprimexprarrayspanspannonenone)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*] |*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone) relax 调用 tir.prim_func 并返回输出。这个内建函数会将 te 梯度函数(通过 te_grad_name 指向)绑定到 call_tir_with_grad 节点。梯度传递过程会调用这个 te 梯度函数。 * **参数:** - * **gvar** ([GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar))**:** 指向 tir PrimFunc 的 GlobalVar。 + * **gvar** ([GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none))**:** 指向 tir PrimFunc 的 GlobalVar。 * **args** (*Expr*):输入参数。 - * **out_sinfo** (*Union*[***[TensorStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TensorStructInfo)***,******List****[*[TensorStructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.TensorStructInfo)*]]):call_tir_with_grad 输出的结构信息。它应该是一个 TensorStructInfo 或 TensorStructInfo 列表。每个元素表示一个返回张量的结构信息。 + * **out_sinfo** (*Union*[***[TensorStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtensorstructinfoshaperelaxexprnonelistprimexprnonedtypestrfloat32vdevicevdevicenonestrnonendimint-1spanspannonenone)***,******List****[*[TensorStructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtensorstructinfoshaperelaxexprnonelistprimexprnonedtypestrfloat32vdevicevdevicenonestrnonendimint-1spanspannonenone)*]]):call_tir_with_grad 输出的结构信息。它应该是一个 TensorStructInfo 或 TensorStructInfo 列表。每个元素表示一个返回张量的结构信息。 * **te_grad_name** ([str](https://docs.python.org/3/library/stdtypes.html#str)):与 call_tir_with_grad 节点相关联的 te 梯度函数的注册名称。必须作为关键字参数提供。 * **te_grad_kwargs** (*Dict*[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,******Object****],optional*)*: 传递给 te 梯度函数的关键字参数。可选作为关键字参数提供。默认:{}。 - * **tir_vars** (*Optional**[****Union**[***[ShapeExpr](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ShapeExpr)***,** [Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)***]****,List[***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)***]*]]):表示调用 func 时要解包的整数元组的 ShapeExpr。如果未使用则为 null + * **tir_vars** (*Optional**[****Union**[***[ShapeExpr](/docs/api-reference/python-api/tvm-relax#classtvmrelaxshapeexprvalueslistprimexprtupleprimexprarrayspanspannonenone)***,** [Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)***]****,List[***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)***]*]]):表示调用 func 时要解包的整数元组的 ShapeExpr。如果未使用则为 null * **返回:ret**:调用 call_tir_with_grad 运算符的调用节点。 -* **返回类型:**[relax.Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call) +* **返回类型:**[relax.Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone) -## tvm.relax.op.hint_on_device(*data*, *dst_vdevice*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.hint_on_device(*data*, *dst_vdevice*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 它提供了一个提示,指定输入数据应该在哪个设备上执行。这个提示被 RealizeVDevice 用来传播虚拟设备。 * **参数:** * **data** (*Expr*):要复制的张量。 - * **dst_device** ([VDevice](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.VDevice)):数据预期执行的目標设备。 + * **dst_device** ([VDevice](/docs/api-reference/python-api/tvm-ir#class-tvmirvdevicetargetnone-vdevice_idint-0-memory_scopestr-global)):数据预期执行的目標设备。 * **返回:result**:结果。 * **返回类型:** Expr。 -## tvm.relax.op.invoke_closure(*closure:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *args:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *sinfo_args:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)*] |*[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)) → [Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call) +## tvm.relax.op.invoke_closure(*closure:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *args:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *sinfo_args:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)*] |*[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)) → [Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone) 调用闭包。 * **参数:** * **closure** (*Expr*):VMClosure 对象。 * **args** (*Expr*):输入参数。 - * **type_args** (*Union*[****List**[***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)***]****,*[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)*]*):CallNode 的结构信息参数。 -* **返回:ret**[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)调用 invoke_closure 的调用。 -* **返回类型:**[relax.Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call)。 + * **type_args** (*Union*[****List**[***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)***]****,*[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)*]*):CallNode 的结构信息参数。 +* **返回:ret**-invoke_closure 的调用。 +* **返回类型:**[relax.Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone)。 -## tvm.relax.op.invoke_pure_closure(*closure:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *args:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *sinfo_args:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)*] |*[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)) → [Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call) +## tvm.relax.op.invoke_pure_closure(*closure:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *args:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *sinfo_args:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)*] |*[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)) → [Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone) 调用闭包并指示编译器该闭包是纯函数。 @@ -154,27 +154,27 @@ relax 调用 tir.prim_func 并返回输出。这个内建函数会将 te 梯度 * **参数:** * **closure** (*Expr*):VMClosure 对象。 * **args** (*Expr*):输入参数。 - * **type_args** (*Union*[****List**[***[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)***]****,*[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)*]):CallNode 的结构信息参数。 + * **type_args** (*Union*[****List**[***[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)***]****,*[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)*]):CallNode 的结构信息参数。 * **返回:ret**:调用 invoke_pure_closure。 -* **返回类型:**[relax.Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call)。 +* **返回类型:**[relax.Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone)。 -## tvm.relax.op.make_closure(*func:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *args:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → Object +## tvm.relax.op.make_closure(*func:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *args:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → Object 创建一个带有自由变量的闭包并返回该闭包。 * **参数:** * **func** (*Expr*):该闭包,可以是 ExternFunc 或 PrimFunc。 - * **args** (*Expr*)[:](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call)输入参数。 + * **args** (*Expr*)-输入参数。 * **返回:ret**:VMClosure。 * **返回类型:** Object。 -## tvm.relax.op.null_value() → [Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call) +## tvm.relax.op.null_value() → [Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone) 创建一个表示空值对象的调用节点。 * **返回:ret:** 创建的调用节点。 -* **返回类型:**[relax.Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call)。 +* **返回类型:**[relax.Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone)。 -## tvm.relax.op.print(values:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*]*, *format:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*= '') → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.print(values:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*]*, *format:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*= '') → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 打印操作以打印值。 * **参数:** @@ -183,7 +183,7 @@ relax 调用 tir.prim_func 并返回输出。这个内建函数会将 te 梯度 * **返回:result**:一个 relax Call,在运行时将打印值。 * **返回类型:** Expr。 -## tvm.relax.op.register_gradient(*op_name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *fgradient:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*[[*[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)*,*[Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call)*,*[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)*,*[BlockBuilder](https://tvm.apache.org/docs/reference/api/python/relax/block_builder.html#tvm.relax.block_builder.BlockBuilder)*],*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*]] = None*, *level:*[int](https://docs.python.org/3/library/functions.html#int)*= 10*) +## tvm.relax.op.register_gradient(*op_name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *fgradient:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*[[*[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenon)*,*[Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone)*,*[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenon)*,*[BlockBuilder](/docs/api-reference/python-api/tvm-relax_block_builder#class-tvmrelaxblock_builderblockbuildermodirmodulenone-none)*],*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*]] = None*, *level:*[int](https://docs.python.org/3/library/functions.html#int)*= 10*) 为 relax 运算符注册运算符梯度函数。 * **参数:** @@ -191,7 +191,7 @@ relax 调用 tir.prim_func 并返回输出。这个内建函数会将 te 梯度 * **fgradient** (*function(**orig_var: relax.Var****,orig_call: relax.Call,***output_grad: relax.Var****,ctx: BlockBuilder)):> partials: List[Expr] 使用的梯度函数。 * **level** ([int](https://docs.python.org/3/library/functions.html#int)):优先级级别 -## tvm.relax.op.shape_of(*expr:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.shape_of(*expr:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 获取张量的形状。 @@ -200,29 +200,29 @@ relax 调用 tir.prim_func 并返回输出。这个内建函数会将 te 梯度 * **返回:result**:一个 relax.Call,它获取输入的形状。 * **返回类型:** Expr。 -## tvm.relax.op.shape_to_tensor(*expr:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.shape_to_tensor(*expr:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 将形状转换为张量 expr。 :param expr: 输入的 Expr :type expr: Expr。 * **返回:result**:一个 relax relax.Call,将形状值转换为张量。 * **返回类型:** Expr。 -## tvm.relax.op.tensor_to_shape(*expr:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.tensor_to_shape(*expr:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 将张量转换为形状表达式。 :param expr: 输入的 Expr :type expr: Expr。 * **返回:result**:一个 relax relax.Call,将张量值转换为形状。 * **返回类型:** Expr。 -## tvm.relax.op.to_vdevice(*data*, *dst_vdevice*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.to_vdevice(*data*, *dst_vdevice*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 将数据复制到目标设备。此运算符有助于在不同设备之间进行数据传输,以支持异构执行。 * **参数:** * **data** (*Expr*):要复制的张量。 - * **dst_device** ([VDevice](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.VDevice)):数据被复制到的目标设备。 + * **dst_device** ([VDevice](/docs/api-reference/python-api/tvm-ir#class-tvmirvdevicetargetnone-vdevice_idint-0-memory_scopestr-global)):数据被复制到的目标设备。 * **返回:result**:复制的结果。 * **返回类型:** Expr。 -## tvm.relax.op.add(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.add(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 使用 numpy 风格的广播进行加法。 @@ -241,28 +241,28 @@ a = relax.Var("a", relax.TensorStructInfo(shape=(2, 3), dtype="float32")) b = relax.Var("b", relax.TensorStructInfo(shape=(2, 1), dtype="float32")) c = bb.normalize(relax.op.add(a, b)) # c has TensorStructInfo(shape=(2, 3), dtype="float32") ``` -## tvm.relax.op.bitwise_and(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.bitwise_and(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 按位 AND :param x1: 第一个输入张量。 :type x1: relax.Expr :param x2: 第二个输入张量。 :type x2: relax.Expr。 * **返回:result**:计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.bitwise_or(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.bitwise_or(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 按位 OR :param x1: 第一个输入张量。 :type x1: relax.Expr :param x2: 第二个输入张量。 :type x2: relax.Expr。 * **返回:result**:计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.bitwise_xor(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.bitwise_xor(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 按位异或 :param x1: 第一个输入张量。 :type x1: relax.Expr :param x2: 第二个输入张量。 :type x2: relax.Expr * **返回:result:** 计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.divide(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.divide(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 使用 numpy 风格的广播进行除法。 @@ -272,7 +272,7 @@ c = bb.normalize(relax.op.add(a, b)) # c has TensorStructInfo(shape=(2, 3), dty * **返回:result**:计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.equal(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.equal(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 逐元素广播测试(lhs == rhs)。 * **参数:** @@ -281,7 +281,7 @@ c = bb.normalize(relax.op.add(a, b)) # c has TensorStructInfo(shape=(2, 3), dty * **返回:result**:计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.floor_divide(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.floor_divide(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 使用 numpy 风格的广播进行地板除。 @@ -291,7 +291,7 @@ c = bb.normalize(relax.op.add(a, b)) # c has TensorStructInfo(shape=(2, 3), dty * **返回:result**:计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.log_add_exp(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.log_add_exp(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算输入的指数和的对数,逐元素进行。 @@ -301,14 +301,14 @@ c = bb.normalize(relax.op.add(a, b)) # c has TensorStructInfo(shape=(2, 3), dty * **返回:** The element-wise log-sum-exp of x1 and x2。 * **返回类型:** Expr。 -## tvm.relax.op.floor_mod(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.floor_mod(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 使用 numpy 风格的广播进行地板取模。 * **参数:** * **x1** (*Expr*):第一个输入张量。 * **x2** (*Expr*):第二个输入张量。 -## tvm.relax.op.greater(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.greater(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 广播的逐元素测试 (lhs > rhs)。 @@ -318,32 +318,32 @@ c = bb.normalize(relax.op.add(a, b)) # c has TensorStructInfo(shape=(2, 3), dty * **返回:result**:计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.greater_equal(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.greater_equal(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 广播的逐元素测试 (lhs >= rhs)。 * **参数:** * **x1** (*relax.Expr*)**:** 第一个输入张量。 * **x2** (*relax.Expr*):第二个输入张量。 -* **返回:result**[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)计算结果。 +* **返回:result**-计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.left_shift(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.left_shift(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 位左移 :param x1: 要移位的输入张量。 :type x1: relax.Expr :param x2: 移位的位数。 :type x2: relax.Expr。 * **返回:result**:计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.less(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.less(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 广播的逐元素测试 (lhs < rhs)。 * **参数:** * **x1** (*relax.Expr*):第一个输入张量。 * **x2** (*relax.Expr*):第二个输入张量。 -* **返回:result**[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)计算结果。 +* **返回:result**-计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.less_equal(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.less_equal(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 广播的逐元素测试 (lhs <= rhs)。 @@ -353,37 +353,37 @@ c = bb.normalize(relax.op.add(a, b)) # c has TensorStructInfo(shape=(2, 3), dty * **返回:result***:*计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.logical_and(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.logical_and(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 逻辑与 :param x1: 第一个输入张量。 :type x1: relax.Expr :param x2: 第二个输入张量。 :type x2: relax.Expr -* **返回:result**[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)计算结果。 +* **返回:result**-计算结果。 * **返回类型:** relax.Expr, -## tvm.relax.op.logical_or(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.logical_or(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 逻辑或 :param x1: 第一个输入张量。 :type x1: relax.Expr :param x2: 第二个输入张量。 :type x2: relax.Expr。 * **返回:result**:计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.logical_xor(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.logical_xor(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 逻辑异或 :param x1: 第一个输入张量。 :type x1: relax.Expr :param x2: 第二个输入张量。 :type x2: relax.Expr。 * **返回:result**:计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.maximum(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.maximum(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 逐元素最大值。 * **参数:** * **x1** (*relax.Expr*):第一个输入张量。 - * **x2** (*relax.Expr*)[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)第二个输入张量。 + * **x2** (*relax.Expr*)-第二个输入张量。 * **返回:result**:计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.minimum(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.minimum(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 逐元素最小值。 * **参数:** * **x1** (*relax.Expr*):第一个输入张量。 @@ -391,7 +391,7 @@ c = bb.normalize(relax.op.add(a, b)) # c has TensorStructInfo(shape=(2, 3), dty * **返回:result**:计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.mod(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.mod(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 使用 numpy 风格的广播进行取模运算。 @@ -399,41 +399,41 @@ c = bb.normalize(relax.op.add(a, b)) # c has TensorStructInfo(shape=(2, 3), dty * **x1** (*Expr*):第一个输入张量。 * **x2** (*Expr*):第二个输入张量。 -## tvm.relax.op.multiply(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.multiply(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 使用 numpy 风格的广播进行乘法。 * **参数:** - * **x1** (*Expr*)[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)第一个输入张量。 + * **x1** (*Expr*)-第一个输入张量。 * **x2** (*Expr*):第二个输入张量。 * **返回:result**:计算结果。 * **返回类型:** Expr。 -## tvm.relax.op.not_equal(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.not_equal(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 对广播后的元素进行不等性测试 (lhs != rhs)。 * **参数:** - * **x1** (*relax.Expr*)[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)第一个输入张量。 + * **x1** (*relax.Expr*)-第一个输入张量。 * **x2** (*relax.Expr*):第二个输入张量。 * **返回:result**:计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.power(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) +## tvm.relax.op.power(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) 使用 numpy 风格的广播进行幂运算。 * **参数:** - * **x1** (*relax.Expr*)[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)第一个输入张量。 + * **x1** (*relax.Expr*)-第一个输入张量。 * **x2** (*relax.Expr*):第二个输入张量。 * **返回:result**:计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.right_shift(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.right_shift(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 位右移 :param x1: 要移位的输入张量。 :type x1: relax.Expr :param x2: 移位的位数。 :type x2: relax.Expr。 * **返回:result**:计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.subtract(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.subtract(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) numpy 风格的广播减法。 @@ -443,29 +443,29 @@ numpy 风格的广播减法。 * **返回:result**:计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.arange(*start:*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*|*[PrimValue](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.PrimValue), *end:*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*|*[PrimValue](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.PrimValue)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *step:*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*|*[PrimValue](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.PrimValue)*= 1*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.arange(*start:*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*|*[PrimValue](/docs/api-reference/python-api/tvm-relax#classtvmrelaxprimvaluevalueprimexprintspanspannonenone), *end:*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*|*[PrimValue](/docs/api-reference/python-api/tvm-relax#classtvmrelaxprimvaluevalueprimexprintspanspannonenone)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *step:*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*|*[PrimValue](/docs/api-reference/python-api/tvm-relax#classtvmrelaxprimvaluevalueprimexprintspanspannonenone)*= 1*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 构造一个元素均匀分布的张量。 * **参数:** - * **start** (*Union*[****PrimExprLike,*[PrimValue](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.PrimValue)*]*)*:*区间的起始值。 - * **end** (*Optional*[****Union**[****PrimExprLike**,***[PrimValue](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.PrimValue)*]]):区间的结束。如果未提供,它将被设置为 start,而 start 将被设置为 0。 - * **step** (*Union*[***PrimExprLike,*[PrimValue](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.PrimValue)*]*):步长。 + * **start** (*Union*[****PrimExprLike,*[PrimValue](/docs/api-reference/python-api/tvm-relax#classtvmrelaxprimvaluevalueprimexprintspanspannonenone)*]*)*:*区间的起始值。 + * **end** (*Optional*[****Union**[****PrimExprLike**,***[PrimValue](/docs/api-reference/python-api/tvm-relax#classtvmrelaxprimvaluevalueprimexprintspanspannonenone)*]]):区间的结束。如果未提供,它将被设置为 start,而 start 将被设置为 0。 + * **step** (*Union*[***PrimExprLike,*[PrimValue](/docs/api-reference/python-api/tvm-relax#classtvmrelaxprimvaluevalueprimexprintspanspannonenone)*]*):步长。 * **dtype** (*Optional*[****Union**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,***DataType****]]*):创建的张量的数据类型。 * **返回:result**:结果张量。 * **返回类型:** relax.Expr。 -## tvm.relax.op.full(*shape:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*] |*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *fill_value:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.full(*shape:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*] |*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *fill_value:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 用标量值填充数组。 * **参数:** - * **shape** (*Union*[***[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[****PrimExprLike**]***,Expr]*):创建的张量的形状。 + * **shape** (*Union*[***[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[****PrimExprLike**]***,Expr]*):创建的张量的形状。 * **fill_value** (*relax.Expr*):填充的值。必须是一个标量张量。 * **dtype** (*Optional*[****Union**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,** ***DataType***]]):创建的张量的数据类型。如果未给出 dtype,默认将使用 fill_value 的数据类型。 * **返回:result**:结果张量。 * **返回类型:** relax.Expr。 -## tvm.relax.op.full_like(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *fill_value:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.full_like(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *fill_value:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 构造一个张量,其特征为:- 形状与输入数据张量的形状相同,- 其值被输入标量 fill_value 填充。 @@ -480,56 +480,56 @@ numpy 风格的广播减法。 Hamming 窗函数。 * **参数:** - * **window_size** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):返回窗口的大小。 - * **periodic** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))**:** 如果为 True,返回一个周期函数使用的窗口。如果为 False,返回一个对称窗口。 - * **alpha** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):系数 alpha。 - * **beta** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):系数 beta。 + * **window_size** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):返回窗口的大小。 + * **periodic** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))**:** 如果为 True,返回一个周期函数使用的窗口。如果为 False,返回一个对称窗口。 + * **alpha** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):系数 alpha。 + * **beta** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):系数 beta。 * **返回:ret**:结果张量。 * **返回类型:** relax.Expr。 -## tvm.relax.op.ones(*shape:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*] |*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.ones(*shape:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*] |*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 构建一个所有元素都为 1 的张量,具有输入的形状和数据类型。 * **参数:** - * **shape** (*Union*[***[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[****PrimExprLike**]***,Expr]*):创建的张量的形状。 + * **shape** (*Union*[***[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[****PrimExprLike**]***,Expr]*):创建的张量的形状。 * **dtype** (*Union*[***[str](https://docs.python.org/3/library/stdtypes.html#str)***, ***DataType***]):创建的张量的数据类型。 -* **返回:result**[:](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.PrimValue)结果张量。 +* **返回:result**-结果张量。 * **返回类型:** relax.Expr。 -## tvm.relax.op.ones_like(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.ones_like(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 构造一个全为 1 的张量,其形状与输入张量的形状相同。 * **参数:** - * **x** (*relax.Expr*)[:](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.PrimValue)输入张量,当 dtype 字段未指定时,提供形状和 dtype。 + * **x** (*relax.Expr*)-输入张量,当 dtype 字段未指定时,提供形状和 dtype。 * **dtype** (*Optional**[****Union**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,** ***DataType***]]):创建的张量的数据类型。如果 dtype 未给出,将默认使用输入张量的 dtype。 * **返回:result**:结果张量。 * **返回类型:** relax.Expr。 -## tvm.relax.op.eye(*n:*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*|*[PrimValue](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.PrimValue), *m:*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*|*[PrimValue](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.PrimValue)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *k:*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*|*[PrimValue](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.PrimValue)*= 0*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype = 'float32'*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.eye(*n:*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*|*[PrimValue](/docs/api-reference/python-api/tvm-relax#classtvmrelaxprimvaluevalueprimexprintspanspannonenone), *m:*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*|*[PrimValue](/docs/api-reference/python-api/tvm-relax#classtvmrelaxprimvaluevalueprimexprintspanspannonenone)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *k:*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*|*[PrimValue](/docs/api-reference/python-api/tvm-relax#classtvmrelaxprimvaluevalueprimexprintspanspannonenone)*= 0*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype = 'float32'*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 构造一个对角线上为 1,其余位置为 0 的 2-D 张量。 * **参数:** - * **n** (*Union*[***PrimExprLike,*[PrimValue](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.PrimValue)*]*)**:** 输出张量的行数。 - * **m** (*Optional*[****Union**[****PrimExprLike**,*** [PrimValue](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.PrimValue)***]***]*):输出中的列数。如果为 None,则默认为 n。 - * **k** (*Union*[***PrimExprLike,*[PrimValue](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.PrimValue)*]*):对角线的索引:0(默认值)表示主对角线,正值表示上对角线,负值表示下对角线。 + * **n** (*Union*[***PrimExprLike,*[PrimValue](/docs/api-reference/python-api/tvm-relax#classtvmrelaxprimvaluevalueprimexprintspanspannonenone)*]*)**:** 输出张量的行数。 + * **m** (*Optional*[****Union**[****PrimExprLike**,*** [PrimValue](/docs/api-reference/python-api/tvm-relax#classtvmrelaxprimvaluevalueprimexprintspanspannonenone)***]***]*):输出中的列数。如果为 None,则默认为 n。 + * **k** (*Union*[***PrimExprLike,*[PrimValue](/docs/api-reference/python-api/tvm-relax#classtvmrelaxprimvaluevalueprimexprintspanspannonenone)*]*):对角线的索引:0(默认值)表示主对角线,正值表示上对角线,负值表示下对角线。 * **dtype** (*Union* *[***[str](https://docs.python.org/3/library/stdtypes.html#str)**, ***DataType***]):创建的张量的数据类型。 * **返回:result**:结果张量。 * **返回类型:** relax.Expr。 -## tvm.relax.op.eye_like(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *k:*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*|*[PrimValue](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.PrimValue)*= 0*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.eye_like(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *k:*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*|*[PrimValue](/docs/api-reference/python-api/tvm-relax#classtvmrelaxprimvaluevalueprimexprintspanspannonenone)*= 0*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 返回一个二维张量,其对角线元素为 1,其余元素为 0,形状与输入张量相同。 * **参数:** * **x** (*relax.Expr*):输入张量,当 dtype 字段未指定时,提供形状和 dtype。 - * **k** (*Union*[***PrimExprLike,*[PrimValue](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.PrimValue)*]*):对角线的索引:0(默认值)表示主对角线,正数表示上对角线,负数表示下对角线。 + * **k** (*Union*[***PrimExprLike,*[PrimValue](/docs/api-reference/python-api/tvm-relax#classtvmrelaxprimvaluevalueprimexprintspanspannonenone)*]*):对角线的索引:0(默认值)表示主对角线,正数表示上对角线,负数表示下对角线。 * **dtype** (*Optional*[****Union**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,** ***DataType***]]):创建的张量的数据类型。如果未给出 dtype,默认将使用输入张量的数据类型。 * **返回:result** :结果张量。 * **返回类型:** relax.Expr。 -## tvm.relax.op.tril(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *k:*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*|*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*= 0*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.tril(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *k:*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*|*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*= 0*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 返回矩阵或矩阵批次的下三角部分。 @@ -539,7 +539,7 @@ Hamming 窗函数。 * **返回:ret** :结果张量。 * **返回类型:** relax.Expr。 -## tvm.relax.op.triu(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *k:*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*|*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*= 0*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.triu(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *k:*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*|*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*= 0*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 返回矩阵或矩阵批次的上三角部分。 * **参数:** @@ -548,17 +548,17 @@ Hamming 窗函数。 * **返回:ret** :结果张量。 * **返回类型:** relax.Expr。 -## tvm.relax.op.zeros(*shape:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*] |*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.zeros(*shape:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*] |*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 构建一个全为零的张量,其输入形状和 dtype。 * **参数:** - * **shape** (*Union*[***[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[****PrimExprLike**]***,Expr]*) ***:*** 创建的张量的形状。 + * **shape** (*Union*[***[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[****PrimExprLike**]***,Expr]*) ***:*** 创建的张量的形状。 * **dtype** (*Union*[***[str](https://docs.python.org/3/library/stdtypes.html#str)** *,** ***DataType***]) **:** 创建的张量的数据类型。 * **返回:result** :结果张量。 * **返回类型:** relax.Expr -## tvm.relax.op.zeros_like(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.zeros_like(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 构造一个全为零的张量,其形状与输入张量的形状相同。 @@ -568,7 +568,7 @@ Hamming 窗函数。 * **返回:result** :结果张量。 * **返回类型:** relax.Expr。 -## tvm.relax.op.astype(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.astype(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 将输入张量转换为指定的数据类型。 @@ -578,14 +578,14 @@ Hamming 窗函数。 * **返回:result** :转换结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.wrap_param(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype = 'float32'*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.wrap_param(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype = 'float32'*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 如果输入数据的类型与给定的类型不同,则将模型参数输入张量转换为数据类型。 :param data: 运算符的输入数据。 :type data: relax.Expr :param dtype: 目标数据类型 :type dtype: Union[str, DataType]。 * **返回:result** :转换后的结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.dynamic_strided_slice(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *begin:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *end:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *strides:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.dynamic_strided_slice(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *begin:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *end:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *strides:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 动态步长切片张量。begin、end、strides 可以在运行时计算。 * **参数:** @@ -602,7 +602,7 @@ dyn_strided_slice 要求输入的 begin、end 和 strides 的长度与数据张 ::: -## tvm.relax.op.strided_slice(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axes:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *begin:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *end:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *strides:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *assume_inbound:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.strided_slice(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axes:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *begin:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *end:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *strides:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *assume_inbound:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 对张量进行带步长的切片。 @@ -621,7 +621,7 @@ strided_slice 要求输入的 begin、end 和 strides 的长度与 axes 相同 ::: -## tvm.relax.op.take(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *indices:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.take(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *indices:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 从一个张量沿轴取出元素。它的语义与 numpy.take([https://numpy.org/doc/stable/reference/generated/numpy.take.html)基本相同,可以涵盖](https://numpy.org/doc/stable/reference/generated/numpy.take.html)基本相同,可以涵盖) torch.take([https://pytorch.org/docs/stable/generated/torch.take.html)和](https://pytorch.org/docs/stable/generated/torch.take.html)和) onnx.gather([https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Gather-13)。](https://github.com/onnx/onnx/blob/main/docs/Changelog.md#Gather-13)。) * **参数:** @@ -635,12 +635,12 @@ strided_slice 要求输入的 begin、end 和 strides 的长度与 axes 相同 对数据进行爱因斯坦求和约定求值。 * **参数:** - * **operands** (*Union*(****List**[****relax.Expr**]****,*[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)*[**relax.Expr**])) :表达式列表。 - * **subscripts** ([str](https://docs.python.org/3/library/stdtypes.html#str)) [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)爱因斯坦求和表达式字符串。 + * **operands** (*Union*(****List**[****relax.Expr**]****,*[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)*[**relax.Expr**])) :表达式列表。 + * **subscripts** ([str](https://docs.python.org/3/library/stdtypes.html#str)) -爱因斯坦求和表达式字符串。 * **返回:result** :einsum op 的输出。 * **返回类型:** relax.Expr。 -## tvm.relax.op.linear(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *weight:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *bias:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *out_dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.linear(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *weight:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *bias:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *out_dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 对输入数据应用线性变换:y = xA^T + b。 @@ -658,7 +658,7 @@ Relax 不将线性运算符视为原始运算符,而是通过组合转置、 * **返回:result** *:* 计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.matmul(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *out_dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.matmul(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *out_dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 对两个张量进行一般矩阵乘法,并在批处理维度上进行广播。 @@ -672,7 +672,7 @@ Relax 不将线性运算符视为原始运算符,而是通过组合转置、 * **返回:result** **:** 计算结果。 * **返回类型:** relax.Expr -## tvm.relax.op.outer(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.outer(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算两个输入表达式的外积。 * **参数:** @@ -687,16 +687,16 @@ Relax 不将线性运算符视为原始运算符,而是通过组合转置、 * **返回:result** :表示外积的结果表达式。 * **返回类型:** relax.Expr。 -## tvm.relax.op.broadcast_to(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *shape:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*] |*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.broadcast_to(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *shape:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*] |*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 将张量广播到指定形状。 * **参数:** * **x** (*relax.Expr*) :运算符的输入数据。 - * **shape** (*Union*[***[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[****PrimExprLike**]***,Expr]*) [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)目标形状。 + * **shape** (*Union*[***[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[****PrimExprLike**]***,Expr]*) -目标形状。 * **返回:result** :广播后的张量。 * **返回类型:** relax.Expr。 -## tvm.relax.op.collapse_sum_like(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *collapse_target:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.collapse_sum_like(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *collapse_target:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 返回数据到 collapse_target 的形状的求和。 @@ -705,11 +705,11 @@ Relax 不将线性运算符视为原始运算符,而是通过组合转置、 详情请参阅 relax.op.collapse_sum_to。 * **参数:** * **data** (*relax.Expr*) :输入张量。 - * **collapse_target** (*relax.Expr*) [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)要折叠到的张量的形状。 -* **返回:result** [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)求和后的结果张量。 + * **collapse_target** (*relax.Expr*) -要折叠到的张量的形状。 +* **返回:result** -求和后的结果张量。 * **返回类型:** relax.Expr。 -## tvm.relax.op.collapse_sum_to(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *shape:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*] |*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.collapse_sum_to(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *shape:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*] |*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 返回数据折叠到给定形状的求和结果。 @@ -723,34 +723,34 @@ collapse_sum_to 是 tvm.relax.op.broadcast_to 和其他广播运算符在自动 在计算过程中,会从右到左检查 data.shape 和 shape 的所有轴。对于一个轴,如果它满足以下规则之一,data 将在该轴上求和:- 该轴存在于 data.shape 中但不存在于 shape 中,或- 该轴存在于 data.shape 中,并且在 shape 中等于 1。 * **参数:** * **data** (*relax.Expr*) :输入张量。 - * **shape** (*Union*[***[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[****PrimExprLike**]****,relax.Expr]*) *:* 要折叠成的形状。 + * **shape** (*Union*[***[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[****PrimExprLike**]****,relax.Expr]*) *:* 要折叠成的形状。 * **返回:result** :按给定形状求和后的结果张量。 * **返回类型:** relax.Expr。 -## tvm.relax.op.concat(*tensors:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*]*, *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= 0*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.concat(*tensors:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*]*, *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= 0*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 沿给定轴连接输入张量。 * **参数:** * **tensors** (*Union*[****relax.Expr**,** ***List***[**relax.Expr**]]) :一个元组类型的 Expr,包含要连接的张量,或一个张量列表。 - * **axis** (*Optional[*[int](https://docs.python.org/3/library/functions.html#int)*]*) [:](https://docs.python.org/3/library/typing.html#typing.List)沿此轴将张量连接起来。如果 axis 为 None,则在连接之前需要将输入张量展平。 + * **axis** (*Optional[*[int](https://docs.python.org/3/library/functions.html#int)*]*) - 沿此轴将张量连接起来。如果 axis 为 None,则在连接之前需要将输入张量展平。 * **返回:result** *:* 连接的张量。 * **返回类型:** relax.Expr。 -## tvm.relax.op.expand_dims(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.expand_dims(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 在 axis 指定的位置插入新的轴。 * **参数:** - * **x** (*relax.Expr*) [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)运算符的输入数据。 + * **x** (*relax.Expr*) -运算符的输入数据。 * **axis** (*Union*[***[int](https://docs.python.org/3/library/functions.html#int)***,***List***[*[int](https://docs.python.org/3/library/functions.html#int)*]]) :1, data.ndim] 内,遵循负索引的约定。 * **返回:result** **:** 转换后的结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.flatten(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.flatten(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 将所有张量维度展平为一个。 -* **参数:x** (*relax.Expr*) [:](https://docs.python.org/3/library/functions.html#int)运算符的输入数据。 +* **参数:x** (*relax.Expr*) - 运算符的输入数据。 * **返回:result** :展平的结果。 * **返回类型:** relax.Expr @@ -773,7 +773,7 @@ relax.flip(x, axis=0) = [[3., 4.], [1., 2.]] relax.flip(x, axis=1) = [[2., 1.], [4., 3.]] ``` -## tvm.relax.op.gather_elements(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *indices:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= 0*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.gather_elements(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *indices:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= 0*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 根据指定轴上的索引从数据中收集元素。 @@ -798,7 +798,7 @@ indices = [[1, 1, 1]] axis = 0 output = [[4, 5, 6]] ``` -## tvm.relax.op.gather_nd(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *indices:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *batch_dims:*[int](https://docs.python.org/3/library/functions.html#int)*= 0*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.gather_nd(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *indices:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *batch_dims:*[int](https://docs.python.org/3/library/functions.html#int)*= 0*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 使用 updates 中的值更新由 indices 定义的位置处的数据。 @@ -823,7 +823,7 @@ data = [[[0,1],[2,3]],[[4,5],[6,7]]] # data_shape = [2, 2, 2] indices = [[1],[0]] # indices_shape = [2, 1] output = [[2,3],[4,5]] # output_shape = [2, 2] ``` -## tvm.relax.op.index_put(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *indices:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*]*, *values:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *accumulate:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.index_put(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *indices:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*]*, *values:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *accumulate:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 此操作使用来自 values 的对应值更新 data 中由 indices 指定的位置。indices 是一个张量元组,其中每个张量对应 data 中的一个维度。当 accumulate 为 True 时,操作执行累积(加法)而不是替换。reduction 参数允许指定不同的缩减操作。 :param data: 要修改的输入张量 :type data: relax.Expr :param indices: 指定更新位置的索引张量元组(每个维度一个) :type indices: Union[Expr, Tuple[Expr]] :param values: 要放置在指定索引处的值 :type values: relax.Expr :param accumulate: 是否累积(加)值而不是替换(默认:False) :type accumulate: bool @@ -852,7 +852,7 @@ output = [ ] ``` -## tvm.relax.op.index_tensor(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *indices:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*]*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.index_tensor(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *indices:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*]*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 高级张量索引(NumPy/PyTorch 风格)。 @@ -896,7 +896,7 @@ col = R.const(np.array([[0,1,2]])) z = R.index_tensor(x, [row, col]) # z.shape == (2,3) ``` -## tvm.relax.op.meshgrid(*tensors:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*]*, *indexing:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= 'ij'*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.meshgrid(*tensors:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*]*, *indexing:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= 'ij'*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 从输入张量生成坐标网格。 * **参数:** @@ -905,26 +905,26 @@ z = R.index_tensor(x, [row, col]) * **返回:result** *:* 一个表示坐标网格的张量元组。 * **返回类型:** relax.Expr。 -## tvm.relax.op.layout_transform(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *index_map:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*|*[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap), *pad_value:*[int](https://docs.python.org/3/library/functions.html#int)*|*[float](https://docs.python.org/3/library/functions.html#float)*|*[PrimValue](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.PrimValue)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *axis_separators:*[int](https://docs.python.org/3/library/functions.html#int)*| axis_separator |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *input_axis_separators:*[int](https://docs.python.org/3/library/functions.html#int)*| axis_separator |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## tvm.relax.op.layout_transform(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *index_map:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*|*[IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map), *pad_value:*[int](https://docs.python.org/3/library/functions.html#int)*|*[float](https://docs.python.org/3/library/functions.html#float)*|*[PrimValue](/docs/api-reference/python-api/tvm-relax#classtvmrelaxprimvaluevalueprimexprintspanspannonenone)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *axis_separators:*[int](https://docs.python.org/3/library/functions.html#int)*| axis_separator |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *input_axis_separators:*[int](https://docs.python.org/3/library/functions.html#int)*| axis_separator |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) 修改张量的布局。 * **参数:** * **x** (*relax.Expr*) ***:*** 运算符的输入张量。 - * **index_map** (*Union**[****Callable,*[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap)*]*) :应用转换。 - * **pad_value** (*Optional*[****Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,** [float](https://docs.python.org/3/library/functions.html#float)***,*** [PrimValue](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.PrimValue)***]****]*) :如果转换结果导致隐式填充,则用于填充的值。如果未指定,可以使用任何值。 + * **index_map** (*Union**[****Callable,*[IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map)*]*) :应用转换。 + * **pad_value** (*Optional*[****Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,** [float](https://docs.python.org/3/library/functions.html#float)***,*** [PrimValue](/docs/api-reference/python-api/tvm-relax#classtvmrelaxprimvaluevalueprimexprintspanspannonenone)***]****]*) :如果转换结果导致隐式填充,则用于填充的值。如果未指定,可以使用任何值。 * **axis_separators** (*Optional**[****Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,** ***IndexMap.AXIS_SEPARATOR****]]*) :用于 index_map 创建非扁平化缓冲区的 axis_separators。 * **返回:result** *:* 转换后的张量。 * **返回类型:** relax.Expr。 -## tvm.relax.op.one_hot(*indices:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *on_value:*[PrimValue](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.PrimValue), *off_value:*[PrimValue](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.PrimValue), *depth:*[int](https://docs.python.org/3/library/functions.html#int), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= -1*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.one_hot(*indices:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *on_value:*[PrimValue](/docs/api-reference/python-api/tvm-relax#classtvmrelaxprimvaluevalueprimexprintspanspannonenone), *off_value:*[PrimValue](/docs/api-reference/python-api/tvm-relax#classtvmrelaxprimvaluevalueprimexprintspanspannonenone), *depth:*[int](https://docs.python.org/3/library/functions.html#int), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= -1*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 返回一个 one-hot 张量。 * **参数:** * **indices** (*relax.Expr*) **:** 要设置为 on_value 的索引。 - * **on_value** ([relax.PrimValue](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.PrimValue)) :要在 indices 处填充的值。 - * **off_value** ([relax.PrimValue](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.PrimValue)) :要在其他位置填充的值。 + * **on_value** ([relax.PrimValue](/docs/api-reference/python-api/tvm-relax#classtvmrelaxprimvaluevalueprimexprintspanspannonenone)) :要在 indices 处填充的值。 + * **off_value** ([relax.PrimValue](/docs/api-reference/python-api/tvm-relax#classtvmrelaxprimvaluevalueprimexprintspanspannonenone)) :要在其他位置填充的值。 * **depth** ([int](https://docs.python.org/3/library/functions.html#int)) :hot 维度的深度。 * **axis** ([int](https://docs.python.org/3/library/functions.html#int)*,optional*) -1,即在末尾添加一个新维度。 * **返回:result** :计算结果。 @@ -944,7 +944,7 @@ one_hot(indices, on_value, off_value, depth) = [0, 1, 0], [0, 0, 1]] ``` ->tvm.relax.op.permute_dims(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axes:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +>tvm.relax.op.permute_dims(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axes:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 对数组的维度进行重排。 * **参数:** @@ -953,7 +953,7 @@ one_hot(indices, on_value, off_value, depth) = * **返回:result** :转置结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.repeat(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *repeats:*[int](https://docs.python.org/3/library/functions.html#int), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.repeat(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *repeats:*[int](https://docs.python.org/3/library/functions.html#int), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 重复数组中的元素。 @@ -973,7 +973,7 @@ lv1 = R.repeat(x, repeats=2) # lv1 == [1, 1, 2, 2, 3, 3, 4, 4] lv2 = R.repeat(x, repeats=2, axis=1) # lv2 == [[1., 1., 2., 2.], # [3., 3., 4., 4.]] ``` -## tvm.relax.op.reshape(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *shape:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*] |*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.reshape(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *shape:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*] |*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 重塑输入数组。 @@ -988,18 +988,18 @@ x.shape = (2, 3, 4), shape = (-1,), result.shape = (24,) ``` * **参数:** * **x** (*relax.Expr*) :运算符的输入数据。 - * **shape** (*Union*[***[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[****PrimExprLike**]***,Expr]*) :新的形状。应与原始形状兼容。 -* **返回:result** [:](https://tvm.apache.org/docs/reference/api/python/relax/op.html#tvm.relax.op.scatter_elements)重塑后的结果。 + * **shape** (*Union*[***[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[****PrimExprLike**]***,Expr]*) :新的形状。应与原始形状兼容。 +* **返回:result** :重塑后的结果。 * **返回类型:** relax.Expr。 - :::Note + :::note `-1` 推理仅在编译时执行。也就是说,在任何情况下,如果 `-1` 的维度长度不能在编译时推断,将会抛出错误。 ::: -## tvm.relax.op.scatter_elements(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *indices:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *updates:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= 0*, *reduction:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'update'*) +## tvm.relax.op.scatter_elements(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *indices:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *updates:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= 0*, *reduction:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'update'*) ONNX 风格的散布元素。此操作根据 indices 指定的特定索引位置,将 data 中的值更新为 updates 中指定的值。例如,在 2D 张量中,对应于[i][j]条目的更新操作如下: @@ -1055,7 +1055,7 @@ data = [ [0.0, 2.1, 1.2] ] ``` -## tvm.relax.op.scatter_nd(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *indices:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *updates:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *reduction:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'update'*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.scatter_nd(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *indices:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *updates:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *reduction:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'update'*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 将更新分散到数组中,根据索引。 * **参数:** @@ -1063,7 +1063,7 @@ data = [ * **indices** (*relax.Expr*) :data 中要更新的索引位置。 * **updates** (*relax.Expr*) :要替换的值。 * **reduction** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :应用约简的类型:update、add、mul、max、min。默认为「update」。 -* **返回:result** [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)结果与 data 具有相同的形状。 +* **返回:result** -结果与 data 具有相同的形状。 * **返回类型:** relax.Expr。 @@ -1078,11 +1078,11 @@ updates = [9, 10, 11, 12] # output output = [1, 11, 3, 10, 9, 6, 7, 12] ``` -## tvm.relax.op.slice_scatter(*input_tensor:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *src:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *start*, *end*, *step*, *axis=0*) +## tvm.relax.op.slice_scatter(*input_tensor:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *src:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *start*, *end*, *step*, *axis=0*) 将 src 张量的值嵌入到 input 的指定维度中。 * **参数:** - * **input_tensor** (*relax.Expr*) [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)要更新的输入张量。 + * **input_tensor** (*relax.Expr*) -要更新的输入张量。 * **src** (*relax.Expr*) :要嵌入到输入中的张量。 * **axis** ([int](https://docs.python.org/3/library/functions.html#int)) :插入切片的维度。 * **start** :插入切片的起始索引。 @@ -1091,7 +1091,7 @@ output = [1, 11, 3, 10, 9, 6, 7, 12] * **返回:result** :与 data 相同形状的计算结果张量。 * **返回类型:** relax.Expr。 -## tvm.relax.op.split(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *indices_or_sections:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*, *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= 0*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.split(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *indices_or_sections:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*, *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= 0*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 沿轴通过分段或索引分割输入张量。 @@ -1108,7 +1108,7 @@ output = [1, 11, 3, 10, 9, 6, 7, 12] * **返回:ret** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.squeeze(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.squeeze(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 在数组中压缩轴。 @@ -1118,7 +1118,7 @@ output = [1, 11, 3, 10, 9, 6, 7, 12] * **返回:result** :压缩后的结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.stack(*tensors:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*]*, *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= 0*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.stack(*tensors:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*]*, *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= 0*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 沿着新轴堆叠输入张量。 * **参数:** @@ -1127,7 +1127,7 @@ output = [1, 11, 3, 10, 9, 6, 7, 12] * **返回:result** :与输入张量相比,堆叠的张量多了一个维度。 * **返回类型:** relax.Expr。 -## tvm.relax.op.tile(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *repeats:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.tile(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *repeats:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 通过 repeats 指定的次数重复 data 来构造一个数组。 @@ -1142,7 +1142,7 @@ output = [1, 11, 3, 10, 9, 6, 7, 12] 如果 d > l,reps 将通过在其前面添加 1 来提升为长度 d。因此,对于形状为 (2, 3, 4, 5) 的数据,一个 reps 为 (2, 2) 将被视为 (1, 1, 2, 2)。 * **参数:** * **data** (*relax.Expr*) **:** 运算符的输入数据。 - * **repeats** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***]****,List[***[int](https://docs.python.org/3/library/functions.html#int)*]*]) **:** 沿每个轴的数据重复次数。 + * **repeats** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***]****,List[***[int](https://docs.python.org/3/library/functions.html#int)*]*]) **:** 沿每个轴的数据重复次数。 * **返回:ret** :计算结果。 * **返回类型:** relax.Expr。 @@ -1158,14 +1158,14 @@ lv1 = R.tile(x, reps=(2, 3)) # lv1 = [[1., 2., 1., 2., 1., 2.], lv2 = R.tile(x, reps=2) # lv2 = [[1., 2., 1., 2.], # [3., 4., 3., 4.]] ``` -## tvm.relax.op.masked_fill(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *mask:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *value:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) +## tvm.relax.op.masked_fill(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *mask:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *value:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) 用指定的值填充由掩码定义位置的张量。 :param x: 运算符的输入数据。 :type x: relax.Expr :param mask: 掩码。 :type mask: relax.Expr :param value: 要在输入张量中设置的值。 :type value: relax.Expr * **返回:result** :填充的张量。 * **返回类型:** relax.Expr。 -## tvm.relax.op.dequantize(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *scale:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *zero_point:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= -1*, *out_dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'float32'*) +## tvm.relax.op.dequantize(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *scale:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *zero_point:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= -1*, *out_dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'float32'*) 去量化运算符 该运算符接收输入并产生去量化输出。输入张量可以是任何形状。输出形状与输入形状相同。 @@ -1181,7 +1181,7 @@ output = clamp(scale 运算符* (input_tensor - zero_point), out_dtype::min, out * **返回:result** :计算结果。 * **返回类型:** tvm.relax.Expr。 -## tvm.relax.op.quantize(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *scale:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *zero_point:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= -1*, *out_dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'int8'*) +## tvm.relax.op.quantize(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *scale:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *zero_point:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= -1*, *out_dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'int8'*) 量化操作 该操作接收输入并产生量化输出。输入张量可以是任意形状。输出形状与输入形状相同。 @@ -1191,13 +1191,13 @@ Q_output = clamp((round(input_tensor/scale) + zero_point), out_dtype::min, out_d * **参数:** * **data** (*tvm.relax.Expr*) **:** 待量化的输入张量。 * **scale** (*tvm.relax.Expr*) :输出缩放比例。 - * **zero_point** (*tvm.relax.Expr*) [:](https://docs.python.org/3/library/stdtypes.html#str)输出 zero_point。 + * **zero_point** (*tvm.relax.Expr*) - 输出 zero_point。 * **axis** ([int](https://docs.python.org/3/library/functions.html#int)) **:** 1,对应最后一个轴。 * **out_dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)*,optional*) :输出张量的数据类型。 * **返回:result** :计算结果。 * **返回类型:** tvm.relax.Expr。 -## tvm.relax.op.multinomial_from_uniform(*prob:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *uniform_sample:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *sample_indices:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'int64'*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.multinomial_from_uniform(*prob:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *uniform_sample:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *sample_indices:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'int64'*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 返回一个张量,其中每一行包含从位于张量 prob 相应行的多项式概率分布中采样的索引。 @@ -1228,7 +1228,7 @@ multinomial_from_uniform(prob, usample) multinomial_from_uniform(prob, usample, sample_indices) -> [[1], [2]] ``` -## tvm.relax.op.argmax(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *keepdims:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.argmax(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *keepdims:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算给定轴上张量元素的 argmax。 @@ -1239,7 +1239,7 @@ multinomial_from_uniform(prob, usample, sample_indices) * **返回:result** *:* 计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.argmin(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *keepdims:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.argmin(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *keepdims:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算给定轴上张量元素的最小值。 @@ -1250,7 +1250,7 @@ multinomial_from_uniform(prob, usample, sample_indices) * **返回:result** *:* 计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.where(*condition:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.where(*condition:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 根据条件值从输入张量中选择元素。 @@ -1263,7 +1263,7 @@ multinomial_from_uniform(prob, usample, sample_indices) * **返回:result** **:** 结果张量。 * **返回类型:** relax.Expr。 -## tvm.relax.op.nonzero(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nonzero(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 找到张量中非零元素的索引。 @@ -1272,7 +1272,7 @@ multinomial_from_uniform(prob, usample, sample_indices) * **返回:result** :一个包含非零元素索引的二维张量。 * **返回类型:** relax.Expr。 -:::Note +:::note 该函数等价于 onnx.nonzero。 @@ -1287,7 +1287,7 @@ x = [[0, 1], nonzero(x) = [[0, 1], [1, 0]] ``` -## tvm.relax.op.unique(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *sorted:*[bool](https://docs.python.org/3/library/functions.html#bool)*|*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*= True*, *return_index:*[bool](https://docs.python.org/3/library/functions.html#bool)*|*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*= False*, *return_inverse:*[bool](https://docs.python.org/3/library/functions.html#bool)*|*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*= False*, *return_counts:*[bool](https://docs.python.org/3/library/functions.html#bool)*|*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*= False*, *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.unique(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *sorted:*[bool](https://docs.python.org/3/library/functions.html#bool)*|*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*= True*, *return_index:*[bool](https://docs.python.org/3/library/functions.html#bool)*|*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*= False*, *return_inverse:*[bool](https://docs.python.org/3/library/functions.html#bool)*|*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*= False*, *return_counts:*[bool](https://docs.python.org/3/library/functions.html#bool)*|*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*= False*, *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 查找给定张量中的唯一元素。此外,它还可以选择性地返回 - 输入张量中给出唯一值的索引; - 重建输入张量的唯一张量的索引; - 每个唯一值在输入张量中出现的次数。 @@ -1301,18 +1301,18 @@ nonzero(x) = [[0, 1], * **返回:ret** :创建的 relax 调用, * **返回类型:** relax.Expr -## tvm.relax.op.argsort(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= -1*, *descending:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'int32'*) +## tvm.relax.op.argsort(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= -1*, *descending:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'int32'*) 沿给定轴进行排序,并返回一个与输入数组形状相同的索引数组,该数组按排序顺序索引数据。 * **参数:** * **data** (*relax.Expr*) :输入数据张量。 * **axis** ([int](https://docs.python.org/3/library/functions.html#int)) :沿此轴对输入张量进行排序。 - * **descending** ([bool](https://docs.python.org/3/library/functions.html#bool)) [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)是否按降序排序,默认为 False, + * **descending** ([bool](https://docs.python.org/3/library/functions.html#bool)) -是否按降序排序,默认为 False, * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)) *:* 输出索引的数据类型。 * **返回:out** :与 data 形状相同的张量。 * **返回类型:** relax.Expr, -## tvm.relax.op.sort(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= -1*, *descending:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) +## tvm.relax.op.sort(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= -1*, *descending:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) 沿给定轴进行排序,并返回排序后的数组。 @@ -1323,7 +1323,7 @@ nonzero(x) = [[0, 1], * **返回:out** *:* 排序后的张量。 * **返回类型:** relax.Expr。 -## tvm.relax.op.topk(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *k:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= -1*, *ret_type:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'both'*, *largest:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'int32'*) +## tvm.relax.op.topk(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *k:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= -1*, *ret_type:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'both'*, *largest:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'int32'*) 获取输入张量沿给定轴的 top k 元素。 @@ -1340,7 +1340,7 @@ ret_type 指定返回类型,可以是("both","values","indices")之一 * **返回:out** *:* 计算结果。 * **返回类型:** relax.Expr or List[relax.Expr]。 -## tvm.relax.op.cumprod(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *exclusive:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) +## tvm.relax.op.cumprod(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *exclusive:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) Numpy 风格的累积乘积操作。返回沿给定轴的元素累积乘积。 * **参数:** @@ -1375,7 +1375,7 @@ a = [1, 1, 1, 0, 1, 1, 0] # a is a boolean array cumprod(a, dtype=int32) # dtype should be provided to get the expected results -> [1, 1, 1, 0, 0, 0, 0] ``` -## tvm.relax.op.cumsum(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *exclusive:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) +## tvm.relax.op.cumsum(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *exclusive:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) Numpy 风格的累积和操作。返回沿给定轴的元素的累积包含和。 * **参数:** @@ -1410,7 +1410,7 @@ a = [1, 0, 1, 0, 1, 1, 0] # a is a boolean array cumsum(a, dtype=int32) # dtype should be provided to get the expected results -> [1, 1, 2, 2, 3, 4, 4] ``` -## tvm.relax.op.max(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *keepdims:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.max(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *keepdims:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算给定轴上张量元素的最大值。 * **参数:** @@ -1420,7 +1420,7 @@ cumsum(a, dtype=int32) # dtype should be provided to get the expected results * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.mean(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *keepdims:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.mean(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *keepdims:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算给定轴上张量元素的平均值。 @@ -1431,7 +1431,7 @@ cumsum(a, dtype=int32) # dtype should be provided to get the expected results * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.min(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *keepdims:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.min(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *keepdims:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算在给定轴上张量元素的最小值。 @@ -1442,18 +1442,18 @@ cumsum(a, dtype=int32) # dtype should be provided to get the expected results * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.prod(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *keepdims:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.prod(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *keepdims:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 对指定轴上的张量元素进行乘积计算。 * **参数:** * **x** (*relax.Expr*) :输入数据张量。 * **axis** (*Optional**[****Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***List****[*[int](https://docs.python.org/3/library/functions.html#int)*]**]**]) :执行乘积计算的轴或轴列表。默认值 axis=None 将计算输入张量所有元素的乘积。支持负索引。 - * **keepdims** ([bool](https://docs.python.org/3/library/functions.html#bool)) [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)如果设置为 True,则被缩减的轴将保留为结果中的维度,其大小为 1。使用此选项,结果将正确地广播到输入张量。 + * **keepdims** ([bool](https://docs.python.org/3/library/functions.html#bool)) -如果设置为 True,则被缩减的轴将保留为结果中的维度,其大小为 1。使用此选项,结果将正确地广播到输入张量。 * **返回:result** *:* 计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.std(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *keepdims:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.std(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *keepdims:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算张量元素在给定轴上的标准差。 @@ -1464,18 +1464,18 @@ cumsum(a, dtype=int32) # dtype should be provided to get the expected results * **返回:result** **:** 计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.sum(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *keepdims:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.sum(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *keepdims:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 对指定轴上的张量元素求和。 * **参数:** * **x** (*relax.Expr*) :输入数据张量。 - * **axis** (*Optional*[****Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,***List****[*[int](https://docs.python.org/3/library/functions.html#int)]**]**]) [:](https://docs.python.org/3/library/functions.html#int)求和的轴或轴列表。默认值 axis=None 将求和输入张量的所有元素。支持负索引。 + * **axis** (*Optional*[****Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,***List****[*[int](https://docs.python.org/3/library/functions.html#int)]**]**]) - 求和的轴或轴列表。默认值 axis=None 将求和输入张量的所有元素。支持负索引。 * **keepdims** ([bool](https://docs.python.org/3/library/functions.html#bool)) :如果设置为 True,则被缩减的轴将保留为结果中的尺寸为一的维度。使用此选项,结果将正确广播与输入张量。 * **返回:result** ***:*** 计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.variance(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *keepdims:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.variance(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *keepdims:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算张量元素在给定轴上的方差。 @@ -1486,27 +1486,27 @@ cumsum(a, dtype=int32) # dtype should be provided to get the expected results * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.ewise_fma(*x1:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x2:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x3:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.ewise_fma(*x1:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x2:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x3:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 元素级融合乘加运算符 返回 x1∗x2+x3 的元素级结果。 * **参数:** * **x1** (*relax.Expr*) :乘法的左操作数。 - * **x2** (*relax.Expr*) [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)乘法的右操作数。 + * **x2** (*relax.Expr*) -乘法的右操作数。 * **x3** (*relax.Expr*) :加法的操作数。 * **返回:result** *:* 计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.abs(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.abs(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算输入数据的逐元素绝对值。 * **参数:** - * **x** (*relax.Expr*) [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)输入数据。 + * **x** (*relax.Expr*) -输入数据。 * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.acos(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.acos(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算输入数据的逐元素反余弦。 * **参数:** @@ -1514,13 +1514,13 @@ cumsum(a, dtype=int32) # dtype should be provided to get the expected results * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -:::Note +:::note 输入张量必须具有 float dtype。 ::: -## tvm.relax.op.acosh(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.acosh(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算输入数据的逐元素反双曲余弦。 * **参数:** @@ -1528,13 +1528,13 @@ cumsum(a, dtype=int32) # dtype should be provided to get the expected results * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -:::Note +:::note 输入张量必须具有 float dtype。 ::: -## tvm.relax.op.asin(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.asin(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算输入数据的逐元素反正弦值。 @@ -1543,27 +1543,27 @@ cumsum(a, dtype=int32) # dtype should be provided to get the expected results * **返回:result** *:* 计算结果。 * **返回类型:** relax.Expr。 -:::Note +:::note 输入张量必须具有 float dtype。 ::: -## tvm.relax.op.asinh(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.asinh(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算输入数据的逐元素反双曲正弦。 * **参数:** * **x** (*relax.Expr*) :输入数据。 -* **返回:result** [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)计算结果。 +* **返回:result** -计算结果。 * **返回类型:** relax.Expr。 -:::Note +:::note 输入张量必须具有 float dtype。 ::: -## tvm.relax.op.atan(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.atan(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算输入数据的逐元素反正切。 @@ -1572,13 +1572,13 @@ cumsum(a, dtype=int32) # dtype should be provided to get the expected results * **返回:result** *:* 计算结果。 * **返回类型:** relax.Expr。 -:::Note +:::note 输入张量必须具有 float dtype。 ::: -## tvm.relax.op.atanh(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.atanh(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算输入数据的逐元素反双曲正切。 @@ -1587,13 +1587,13 @@ cumsum(a, dtype=int32) # dtype should be provided to get the expected results * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -:::Note +:::note 输入张量必须具有 float dtype。 ::: -## tvm.relax.op.bitwise_not(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.bitwise_not(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算输入数据的逐位取反。 @@ -1602,7 +1602,7 @@ cumsum(a, dtype=int32) # dtype should be provided to get the expected results * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.ceil(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.ceil(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 对输入数据取上整。 @@ -1611,7 +1611,7 @@ cumsum(a, dtype=int32) # dtype should be provided to get the expected results * **返回:result** **:** 计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.clip(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *min:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *max:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.clip(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *min:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *max:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 将张量值裁剪到指定的最小值和最大值。 @@ -1622,7 +1622,7 @@ cumsum(a, dtype=int32) # dtype should be provided to get the expected results * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.cos(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.cos(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算输入数据的逐元素余弦值。 @@ -1631,13 +1631,13 @@ cumsum(a, dtype=int32) # dtype should be provided to get the expected results * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -:::Note +:::note 输入张量必须具有 float dtype。 ::: -## tvm.relax.op.cosh(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.cosh(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算输入数据的逐元素双曲余弦。 @@ -1646,13 +1646,13 @@ cumsum(a, dtype=int32) # dtype should be provided to get the expected results * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -:::Note +:::note 输入张量必须具有 float dtype。 ::: -## tvm.relax.op.erf(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.erf(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算输入的错误函数。 @@ -1661,7 +1661,7 @@ cumsum(a, dtype=int32) # dtype should be provided to get the expected results * **返回:result** :计算每个元素的错误函数。 * **返回类型:** relax.Expr。 -## tvm.relax.op.exp(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.exp(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算数据的逐元素指数。 @@ -1670,13 +1670,13 @@ cumsum(a, dtype=int32) # dtype should be provided to get the expected results * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -:::Note +:::note 输入张量必须具有 float dtype。 ::: -## tvm.relax.op.floor(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.floor(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 取输入数据的下界。 @@ -1685,7 +1685,7 @@ cumsum(a, dtype=int32) # dtype should be provided to get the expected results * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.isfinite(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.isfinite(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 检查输入值是否有限。 @@ -1694,7 +1694,7 @@ cumsum(a, dtype=int32) # dtype should be provided to get the expected results * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.isinf(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.isinf(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 检查输入值是否为无穷大。 @@ -1703,16 +1703,16 @@ cumsum(a, dtype=int32) # dtype should be provided to get the expected results * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.isnan(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.isnan(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 检查输入值是否为 NaN。 * **参数:** * **x** (*relax.Expr*) :输入数据。 -* **返回:result** [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)计算结果。 +* **返回:result** -计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.log(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)[](https://tvm.apache.org/docs/reference/api/python/relax/op.html#tvm.relax.op.log) +## tvm.relax.op.log(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算输入数据的逐元素自然对数。 @@ -1721,22 +1721,22 @@ cumsum(a, dtype=int32) # dtype should be provided to get the expected results * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -:::Note +:::note 输入张量必须具有 float dtype。 ::: -## tvm.relax.op.logical_not(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.logical_not(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算输入数据的逻辑非。 * **参数:** * **x** (*relax.Expr*) :输入数据。 -* **返回:result** [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)计算结果。 +* **返回:result** -计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.negative(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.negative(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算输入数据的逐元素负值。 @@ -1745,16 +1745,16 @@ cumsum(a, dtype=int32) # dtype should be provided to get the expected results * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.round(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.round(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 将输入数据的每个元素四舍五入到最近的整数。 * **参数:** * **x** (*relax.Expr*) :输入数据。 -* **返回:result** [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)计算结果。 +* **返回:result** -计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.rsqrt(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.rsqrt(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算输入数据的逐元素倒数平方根。 @@ -1764,13 +1764,13 @@ $$1/sqrt(x)$$ * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -:::Note +:::note 输入张量必须具有 float dtype。 ::: -## tvm.relax.op.sigmoid(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.sigmoid(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算输入数据的逐元素 Sigmoid 函数。 @@ -1779,13 +1779,13 @@ $$1/sqrt(x)$$ * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -:::Note +:::note 输入张量必须具有 float dtype。 ::: -## tvm.relax.op.sign(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.sign(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 为输入数据的每个元素返回一个指示该数字符号的标志。 @@ -1794,7 +1794,7 @@ $$1/sqrt(x)$$ * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.sin(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.sin(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算输入数据的逐元素正弦值。 @@ -1803,42 +1803,42 @@ $$1/sqrt(x)$$ * **返回:result** *:* 计算结果。 * **返回类型:** relax.Expr。 -:::Note +:::note 输入张量必须具有 float dtype。 ::: -## tvm.relax.op.sinh(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.sinh(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算输入数据的逐元素双曲正弦值。 * **参数:** * **x** (*relax.Expr*) :输入数据 -* **返回:result** [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)计算结果。 +* **返回:result** -计算结果。 * **返回类型:** relax.Expr。 -:::Note +:::note 输入张量必须具有 float dtype。 ::: -## tvm.relax.op.sqrt(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.sqrt(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算输入数据的逐元素平方根。 * **参数:** * **x** (*relax.Expr*) :输入数据 -* **返回:result** [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)计算结果。 +* **返回:result** -计算结果。 * **返回类型:** relax.Expr。 -:::Note +:::note 输入张量必须具有 float dtype。 ::: -## tvm.relax.op.square(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.square(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 对输入数据的每个元素进行平方。 @@ -1847,36 +1847,36 @@ $$1/sqrt(x)$$ * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.tan(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.tan(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算输入数据的逐元素正切值。 * **参数:** * **x** (*relax.Expr*) *:* 输入数据 -* **返回:result** [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)计算结果。 +* **返回:result** -计算结果。 * **返回类型:** relax.Expr。 -:::Note +:::note 输入张量必须具有 float dtype。 ::: -## tvm.relax.op.tanh(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.tanh(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算输入数据的逐元素 tanh。 * **参数:** - * **x** (*relax.Expr*) [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)输入数据 + * **x** (*relax.Expr*) -输入数据 * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -:::Note +:::note 输入张量必须具有 float dtype。 ::: -## tvm.relax.op.trunc(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.trunc(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 取输入数据的截断值。:param x: 输入数据 :type x: relax.Expr。 @@ -1887,7 +1887,7 @@ $$1/sqrt(x)$$ 与神经网络相关的运算符。 -## tvm.relax.op.nn.adaptive_avg_pool1d(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *output_size:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.adaptive_avg_pool1d(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *output_size:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 1D 自适应平均池化运算符。该运算符是实验性的。 @@ -1911,13 +1911,13 @@ $$1/sqrt(x)$$ 如果为 output_size 提供一个整数,则对于任何输入(NCW),输出大小为(N x C x output_size)。 * **参数:** * **data** (*relax.Expr*) :运算符的输入数据。 - * **output_size** (*Optional**[****Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]]*) :输出高度和宽度。如果未指定,则与输入的高度和宽度相同。如果指定,则长度必须为 1 或 2。 + * **output_size** (*Optional**[****Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]]*) :输出高度和宽度。如果未指定,则与输入的高度和宽度相同。如果指定,则长度必须为 1 或 2。 * **layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :输入的布局。 * **out_layout** (*Optional[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :输出的布局。如果未指定,则与 data_layout 相同 * **返回:result** **:** 计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.nn.adaptive_avg_pool2d(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *output_size:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCHW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.adaptive_avg_pool2d(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *output_size:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCHW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 2D 自适应平均池化运算符。此运算符为实验性功能。 @@ -1943,13 +1943,13 @@ $$1/sqrt(x)$$ 如果为 output_size 提供了一个整数的元组(高度,宽度),则对于任何输入(NCHW),输出大小为 (N x C x 高度 x 宽度)。 * **参数:** * **data** (*relax.Expr*) **:**运算符的输入数据。 - * **output_size** (*Optional**[****Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]]*) :输出高度和宽度。如果未指定,则与输入高度和宽度相同。如果指定,其长度必须是 1 或 2。 + * **output_size** (*Optional**[****Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]]*) :输出高度和宽度。如果未指定,则与输入高度和宽度相同。如果指定,其长度必须是 1 或 2。 * **layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)) **:** 输入的布局。 * **out_layout** (*Optional[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :输出的布局。如果未指定,则与 data_layout 相同 * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.nn.adaptive_avg_pool3d(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *output_size:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCDHW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.adaptive_avg_pool3d(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *output_size:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCDHW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 3D 自适应平均池化运算符。此运算符为实验性功能。 @@ -1975,13 +1975,13 @@ $$1/sqrt(x)$$ 如果为 output_size 提供一个整数元组(depth, height, width),则输出大小为(N x C x depth x height x width),适用于任何输入(NCDHW)。 * **参数:** * **data** (*relax.Expr*) :运算符的输入数据。 - * **output_size** (*Optional**[****Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]]*) :输出高度和宽度。如果未指定,则与输入高度和宽度相同。如果指定,则长度必须是 1 或 3。 + * **output_size** (*Optional**[****Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]]*) :输出高度和宽度。如果未指定,则与输入高度和宽度相同。如果指定,则长度必须是 1 或 3。 * **layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)) *:* 输入的布局。 * **out_layout** (*Optional[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :输出的布局。如果未指定,则与 data_layout 相同 * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.nn.attention(*query:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *key:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *value:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *bias:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *scale:*[FloatImm](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.FloatImm)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *causal_mask:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *window_size:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.attention(*query:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *key:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *value:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *bias:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *scale:*[FloatImm](/docs/api-reference/python-api/tvm-tir#class-tvmtirfloatimmdtypestr-valuefloat-spanspannone-none)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *causal_mask:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *window_size:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算融合多头注意力。 @@ -1990,7 +1990,7 @@ $$1/sqrt(x)$$ 所有输入张量都是 BSNH 布局的 4 维张量。 $$FMA(Q, K, V) = \text{Softmax}(Q @ K^T) @ V$$ -:::Note +:::note 输入张量必须具有 float16 数据类型。 @@ -2031,7 +2031,7 @@ $$FMA(Q, K, V) = \text{Softmax}(Q @ K^T) @ V$$ * **返回:result** :计算结果。输出布局应为(batch_size, seq_len, num_head, head_dim_v)。 * **返回类型:** relax.Expr -## tvm.relax.op.nn.attention_bias(*query:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *key:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *value:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *bias:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *scale:*[FloatImm](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.FloatImm)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *causal_mask:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *window_size:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.attention_bias(*query:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *key:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *value:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *bias:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *scale:*[FloatImm](/docs/api-reference/python-api/tvm-tir#class-tvmtirfloatimmdtypestr-valuefloat-spanspannone-none)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *causal_mask:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *window_size:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算融合多头注意力。 @@ -2044,7 +2044,7 @@ IRModule.script() 将注意力操作转换为注意力偏置,这与 TVMScript $$FMA(Q, K, V) = \text{Softmax}(Q @ K^T) @ V$$ -:::Note +:::note 输入张量必须具有 float16 数据类型。 @@ -2085,7 +2085,7 @@ with seq_len = 2, seq_len_kv = 4, mask for ‘TopLeft’: * **返回:result** :计算结果。输出布局应为(batch_size, seq_len, num_head, head_dim_v)。 * **返回类型:** relax.Expr -## tvm.relax.op.nn.attention_var_len(*queries:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *keys:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *values:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *seqstart_q:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *max_seqlen_q:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *seqstart_k:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *max_seqlen_k:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *scale:*[FloatImm](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.FloatImm)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *causal_mask:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *window_size:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.attention_var_len(*queries:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *keys:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *values:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *seqstart_q:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *max_seqlen_q:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *seqstart_k:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *max_seqlen_k:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *scale:*[FloatImm](/docs/api-reference/python-api/tvm-tir#class-tvmtirfloatimmdtypestr-valuefloat-spanspannone-none)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *causal_mask:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *window_size:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算变长批量序列的融合多头注意力。 @@ -2130,7 +2130,7 @@ with seq_len = 2, seq_len_kv = 4, mask for ‘TopLeft’: * **返回:result** :计算结果,形状为 (1, total_seq_len, num_head, head_dim_v)。 * **返回类型:** relax.Expr。 -## tvm.relax.op.nn.avg_pool1d(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *pool_size:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1,)*, *strides:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1,)*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*, …] = (0, 0)*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1,)*, *ceil_mode:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *count_include_pad:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.avg_pool1d(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *pool_size:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1,)*, *strides:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1,)*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*, …] = (0, 0)*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1,)*, *ceil_mode:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *count_include_pad:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 1D 平均池化运算符。 @@ -2145,18 +2145,18 @@ with seq_len = 2, seq_len_kv = 4, mask for ‘TopLeft’: ceil_mode 用于在计算输出形状时取上整或下整。count_include_pad 指示是否在计算中包含或排除填充的输入值。该运算符接受数据布局规范。 * **参数:** * **data** (*relax.Expr*) ***:*** 运算符的输入数据。 - * **pool_size** (*Union*[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***]****]*) *:* 池化窗口的大小。必须具有长度为 1。 - * **strides** (*Union*[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***]****]*) :池化的步长。必须具有长度为 1。 - * **padding** (*Union*[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) :池化的填充。必须具有长度为 1 或 2。 - * **dilation** (*Union*[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***]****]*) :池化的膨胀。必须具有长度为 1。 + * **pool_size** (*Union*[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***]****]*) *:* 池化窗口的大小。必须具有长度为 1。 + * **strides** (*Union*[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***]****]*) :池化的步长。必须具有长度为 1。 + * **padding** (*Union*[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) :池化的填充。必须具有长度为 1 或 2。 + * **dilation** (*Union*[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***]****]*) :池化的膨胀。必须具有长度为 1。 * **ceil_mode** ([bool](https://docs.python.org/3/library/functions.html#bool)) *:* 一个布尔值,指示是否使用 ceil 或 floor 来计算输出形状。使用 ceil 时,输入张量的每个元素都将被滑动窗口覆盖。 * **count_include_pad** ([bool](https://docs.python.org/3/library/functions.html#bool)*,optional*) :是否将填充包括在内以计算平均值。 * **layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :输入的布局。 - * **out_layout** (*Optional[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)输出的布局。如果未指定,则与 data_layout 相同 + * **out_layout** (*Optional[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) -输出的布局。如果未指定,则与 data_layout 相同 * **返回:result** :计算结果。 * **返回类型:** Expr。 -## tvm.relax.op.nn.avg_pool2d(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *pool_size:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *strides:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*, …] = (0, 0)*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *ceil_mode:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *count_include_pad:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCHW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.avg_pool2d(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *pool_size:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *strides:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*, …] = (0, 0)*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *ceil_mode:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *count_include_pad:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCHW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 2D 平均池化运算符。 @@ -2179,10 +2179,10 @@ $$ 在计算之前对数据进行填充。ceil_mode 用于在计算输出形状时取上整或下整。该运算符接受数据布局规范。 * **参数:** * **data** (*relax.Expr*) ***:*** 运算符的输入数据。 - * **pool_size** (*Union*[[int](https://docs.python.org/3/library/functions.html#int)**,** [Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) [:](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)池化窗口的大小。必须具有长度为 1 或 2。 - * **strides** (*Union*[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) [:](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)池化的步长。必须具有长度为 1 或 2。 - * **padding** (*Union*[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***…****]]*) :池化操作的填充。必须具有长度为 1、2 或 4。 - * **dilation** (*Union*[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) **:** 池化操作的膨胀率。必须具有长度为 1 或 2。 + * **pool_size** (*Union*[[int](https://docs.python.org/3/library/functions.html#int)**,** [Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) - 池化窗口的大小。必须具有长度为 1 或 2。 + * **strides** (*Union*[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) - 池化的步长。必须具有长度为 1 或 2。 + * **padding** (*Union*[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***…****]]*) :池化操作的填充。必须具有长度为 1、2 或 4。 + * **dilation** (*Union*[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) **:** 池化操作的膨胀率。必须具有长度为 1 或 2。 * **ceil_mode** ([bool](https://docs.python.org/3/library/functions.html#bool)) :一个布尔值,指示是否使用 ceil 或 floor 来计算输出形状。使用 ceil 时,输入张量的每个元素都将被滑动窗口覆盖。 * **count_include_pad** ([bool](https://docs.python.org/3/library/functions.html#bool)*,optional*) :是否将填充包括在内以计算平均值。 * **layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :输入的布局。 @@ -2190,7 +2190,7 @@ $$ * **返回:result** *:* 计算结果。 * **返回类型:** Expr。 -## tvm.relax.op.nn.avg_pool3d(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *pool_size:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1, 1)*, *strides:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1, 1)*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*, …] = (0, 0, 0)*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1, 1)*, *ceil_mode:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *count_include_pad:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCDHW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.avg_pool3d(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *pool_size:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1, 1)*, *strides:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1, 1)*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*, …] = (0, 0, 0)*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1, 1)*, *ceil_mode:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *count_include_pad:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCDHW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 2D 平均池化运算符。 @@ -2205,18 +2205,18 @@ $$ ceil_mode 用于在计算输出形状时取上整或下整。count_include_pad 指示是否在计算中包含或排除填充的输入值。该运算符接受数据布局规范。 * **参数:** * **data** (*relax.Expr*) :运算符的输入数据。 - * **pool_size** (*Union*[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) :池化窗口的大小。它必须具有 1 或 3 的长度。 - * **strides** (*Union*[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) :池化的步长。必须具有长度为 1 或 3。 - * **padding** (*Union*[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***…****]]*) :池化操作的填充。长度必须是 1、3 或 6。 - * **dilation** (*Union*[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) *:* 池化操作的膨胀率。必须具有长度为 1 或 3。 + * **pool_size** (*Union*[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) :池化窗口的大小。它必须具有 1 或 3 的长度。 + * **strides** (*Union*[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) :池化的步长。必须具有长度为 1 或 3。 + * **padding** (*Union*[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***…****]]*) :池化操作的填充。长度必须是 1、3 或 6。 + * **dilation** (*Union*[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) *:* 池化操作的膨胀率。必须具有长度为 1 或 3。 * **ceil_mode** ([bool](https://docs.python.org/3/library/functions.html#bool)) :一个布尔值,指示是否使用 ceil 或 floor 来计算输出形状。使用 ceil 时,输入张量的每个元素都将被滑动窗口覆盖。 * **count_include_pad** ([bool](https://docs.python.org/3/library/functions.html#bool)*,optional*) :是否将填充包括在内以计算平均值。 - * **layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)) [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)输入的布局。 + * **layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)) -输入的布局。 * **out_layout** (*Optional[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :输出的布局。如果未指定,则与 data_layout 相同。 * **返回:result** :计算结果。 * **返回类型:** Expr。 -## tvm.relax.op.nn.batch_norm(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *gamma:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *beta:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *moving_mean:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *moving_var:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int), *epsilon:*[float](https://docs.python.org/3/library/functions.html#float)*= 1e-05*, *center:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *scale:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *momentum:*[float](https://docs.python.org/3/library/functions.html#float)*= 0.1*, *training:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.batch_norm(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *gamma:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *beta:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *moving_mean:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *moving_var:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int), *epsilon:*[float](https://docs.python.org/3/library/functions.html#float)*= 1e-05*, *center:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *scale:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *momentum:*[float](https://docs.python.org/3/library/functions.html#float)*= 0.1*, *training:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) Batch normalization 层(Ioffe 和 Szegedy,2014)。 @@ -2255,7 +2255,7 @@ moving_var = moving_var * momentum + data_var * (1 - momentum) 参数 `axis` 指定输入形状中哪个轴表示“通道”(单独归一化的组)。默认值为 1。指定 -1 将通道轴设置为输入形状中的最后一项。 -:::Note +:::note 这个运算符有两种模式: * 训练模式。 @@ -2277,15 +2277,15 @@ moving_var = moving_var * momentum + data_var * (1 - momentum) * **moving_mean** (*relax.Expr*) **:** 输入的运行均值。 * **moving_var** (*relax.Expr*) :输入的运行方差。 * **axis** ([int](https://docs.python.org/3/library/functions.html#int)) :沿此轴应用归一化。 - * **epsilon** ([float](https://docs.python.org/3/library/functions.html#float)) [:](https://docs.python.org/3/library/functions.html#bool)添加到方差中的小浮点数,以避免除以零。 + * **epsilon** ([float](https://docs.python.org/3/library/functions.html#float)) - 添加到方差中的小浮点数,以避免除以零。 * **center** ([bool](https://docs.python.org/3/library/functions.html#bool)) :指示是否将 beta 偏移添加到归一化张量中。 * **scale** ([bool](https://docs.python.org/3/library/functions.html#bool)) :指示是否将伽马缩放相乘。 * **momentum** ([float](https://docs.python.org/3/library/functions.html#float)) :用于 moving_mean 和 moving_var 更新的值。 * **training** ([bool](https://docs.python.org/3/library/functions.html#bool)) *:* relax batch_norm 处于训练模式。要将其转换为推理模式,可以使用 DecomposeOpsForInference。 -* **返回:result** [:](https://docs.python.org/3/library/typing.html#typing.Tuple)计算结果。 +* **返回:result** - 计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.nn.conv1d(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *weight:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *strides:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*] = 1*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*, …] = 0*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*] = 1*, *groups:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *data_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCW'*, *kernel_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'OIW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *out_dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.conv1d(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *weight:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *strides:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*] = 1*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*, …] = 0*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*] = 1*, *groups:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *data_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCW'*, *kernel_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'OIW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *out_dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 1D 卷积。 @@ -2305,9 +2305,9 @@ $$ * **参数:** * **data** (*relax.Expr*) *:* 运算符的输入数据。 * **weight** (*relax.Expr*) :权重表达式。 - * **strides** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***]****]*) :卷积的步长。必须具有长度 1。 - * **padding** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***…****]]*) **:** 卷积前输入两侧的填充。必须具有长度为 1 或 2。 - * **dilation** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) :指定用于扩张卷积的扩张率。必须具有长度 1。 + * **strides** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***]****]*) :卷积的步长。必须具有长度 1。 + * **padding** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***…****]]*) **:** 卷积前输入两侧的填充。必须具有长度为 1 或 2。 + * **dilation** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) :指定用于扩张卷积的扩张率。必须具有长度 1。 * **groups** ([int](https://docs.python.org/3/library/functions.html#int)) **:** 分组卷积将输入分成多少组。输入和输出通道数应该能被组数整除。 * **data_layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :输入的布局。 * **kernel_layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :权重的布局。 @@ -2316,7 +2316,7 @@ $$ * **返回:result** *:* 计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.nn.conv1d_transpose(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *weight:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *strides:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*] = 1*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*, …] = 0*, *output_padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*] = 0*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*] = 1*, *groups:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *data_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCW'*, *kernel_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'IOW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *out_dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.conv1d_transpose(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *weight:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *strides:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*] = 1*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*, …] = 0*, *output_padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*] = 0*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*] = 1*, *groups:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *data_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCW'*, *kernel_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'IOW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *out_dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 1D 转置卷积运算符。 @@ -2330,19 +2330,19 @@ $$ * **参数:** * **data** (*relax.Expr*) ***:*** 运算符的输入数据。 * **weight** (*relax.Expr*) **:** 权重表达式。 - * **strides** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***]****]*) :卷积的步长。必须具有长度 1。 - * **padding** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***…****]]*) :卷积前输入两侧的填充。必须具有长度为 1 或 2。 - * **output_padding** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***…***]**]**,optional) [:](https://docs.python.org/3/library/stdtypes.html#str)用于区分输出形状。 - * **dilation** (*Union*[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***]****]*) :指定用于扩张卷积的扩张率。必须具有长度为 1。 + * **strides** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***]****]*) :卷积的步长。必须具有长度 1。 + * **padding** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***…****]]*) :卷积前输入两侧的填充。必须具有长度为 1 或 2。 + * **output_padding** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***…***]**]**,optional) - 用于区分输出形状。 + * **dilation** (*Union*[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***]****]*) :指定用于扩张卷积的扩张率。必须具有长度为 1。 * **groups** ([int](https://docs.python.org/3/library/functions.html#int)) :分组卷积将输入分成多少组。输入和输出通道数应该能被组数整除。 * **data_layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :输入的布局。 - * **kernel_layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)) [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)权重的布局。 + * **kernel_layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)) -权重的布局。 * **out_layout** (*Optional[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) *:* 输出的布局。如果未指定,则与 data_layout 相同 - * **out_dtype** (*Optional**[****Union**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,*** ***DataType****]]*) [:](https://docs.python.org/3/library/functions.html#int)指定混合精度 conv2d 的输出数据类型。 + * **out_dtype** (*Optional**[****Union**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,*** ***DataType****]]*) - 指定混合精度 conv2d 的输出数据类型。 * **返回:result** *:* 计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.nn.conv2d(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *weight:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *strides:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*, …] = (0, 0)*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *groups:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *data_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCHW'*, *kernel_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'OIHW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *out_dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.conv2d(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *weight:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *strides:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*, …] = (0, 0)*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *groups:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *data_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCHW'*, *kernel_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'OIHW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *out_dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 二维卷积。 @@ -2364,18 +2364,18 @@ $$ * **参数:** * **data** (*relax.Expr*) :运算符的输入数据。 * **weight** (*relax.Expr*) :权重表达式。 - * **strides** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) :卷积的步长。必须具有长度为 1 或 2。 - * **padding** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***…****]]*) *:* 卷积前输入两侧的填充。必须具有长度为 1、2 或 4。 - * **dilation** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]***]) **:** 指定用于扩张卷积的扩张率。必须具有长度为 1 或 2。 + * **strides** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) :卷积的步长。必须具有长度为 1 或 2。 + * **padding** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***…****]]*) *:* 卷积前输入两侧的填充。必须具有长度为 1、2 或 4。 + * **dilation** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]***]) **:** 指定用于扩张卷积的扩张率。必须具有长度为 1 或 2。 * **groups** ([int](https://docs.python.org/3/library/functions.html#int)) **:** 分组卷积将输入分成多少组。输入和输出通道数应该能被组数整除。 * **data_layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :输入的布局。 * **kernel_layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)) *:* 权重的布局。 * **out_layout** (*Optional[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) *:* 输出的布局。如果未指定,则与 data_layout 相同 - * **out_dtype** (*Optional**[****Union**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,*** ***DataType****]]*) [:](https://docs.python.org/3/library/typing.html#typing.Tuple)指定混合精度 conv2d 的输出数据类型。 + * **out_dtype** (*Optional**[****Union**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,*** ***DataType****]]*) - 指定混合精度 conv2d 的输出数据类型。 * **返回:result** *:* 计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.nn.conv2d_transpose(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *weight:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *strides:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*, …] = (0, 0)*, *output_padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (0, 0)*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *groups:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *data_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCHW'*, *kernel_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'IOHW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *out_dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.conv2d_transpose(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *weight:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *strides:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*, …] = (0, 0)*, *output_padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (0, 0)*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *groups:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *data_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCHW'*, *kernel_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'IOHW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *out_dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 二维转置卷积运算符。 @@ -2399,10 +2399,10 @@ data_grad = conv2d_transpose(out_grad, weight, strides, padding, output_padding, * **参数:** * **data** (*relax.Expr*) **:** 运算符的输入数据。 * **weight** (*relax.Expr*) :权重表达式。 - * **strides** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) :卷积的步长。必须具有长度为 1 或 2。 - * **padding** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***…****]]*) **:** 卷积前输入两边的填充。必须具有长度为 1、2 或 4。 - * **output_padding** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***…****]**]****,optional*) :用于区分输出形状。 - * **dilation** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) :指定用于扩张卷积的扩张率。必须具有长度为 1 或 2。 + * **strides** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) :卷积的步长。必须具有长度为 1 或 2。 + * **padding** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***…****]]*) **:** 卷积前输入两边的填充。必须具有长度为 1、2 或 4。 + * **output_padding** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***…****]**]****,optional*) :用于区分输出形状。 + * **dilation** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) :指定用于扩张卷积的扩张率。必须具有长度为 1 或 2。 * **groups** ([int](https://docs.python.org/3/library/functions.html#int)) :分组卷积将输入分成多少组。输入和输出通道数应该能被组数整除。 * **data_layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)) *:* 输入的布局。 * **kernel_layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)) *:* 权重的布局。 @@ -2411,7 +2411,7 @@ data_grad = conv2d_transpose(out_grad, weight, strides, padding, output_padding, * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.nn.conv3d(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *weight:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *strides:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1, 1)*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*, …] = (0, 0, 0)*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1, 1)*, *groups:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *data_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCDHW'*, *kernel_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'OIDHW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *out_dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.conv3d(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *weight:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *strides:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1, 1)*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*, …] = (0, 0, 0)*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1, 1)*, *groups:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *data_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCDHW'*, *kernel_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'OIDHW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *out_dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 3D 卷积。 @@ -2437,9 +2437,9 @@ $$ * **参数:** * **data** (*relax.Expr*) :运算符的输入数据。 * **weight** (*relax.Expr*) :权重表达式。 - * **strides** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) :卷积的步长。必须具有长度为 1 或 3。 - * **padding** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***…****]]*) :卷积前输入两边的填充。必须具有长度为 1、3 或 6。 - * **dilation** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) **:** 指定用于扩张卷积的扩张率。必须具有长度为 1 或 3。 + * **strides** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) :卷积的步长。必须具有长度为 1 或 3。 + * **padding** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***…****]]*) :卷积前输入两边的填充。必须具有长度为 1、3 或 6。 + * **dilation** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) **:** 指定用于扩张卷积的扩张率。必须具有长度为 1 或 3。 * **groups** ([int](https://docs.python.org/3/library/functions.html#int)) :分组卷积将输入分成多少组。输入和输出通道数应该能被组数整除。 * **data_layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)) *:* 输入的布局。 * **kernel_layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :权重的布局。 @@ -2448,7 +2448,7 @@ $$ * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.nn.cross_entropy_with_logits(*predictions:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *labels:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.cross_entropy_with_logits(*predictions:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *labels:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) predictions 和 labels 之间的 logits 交叉熵。 @@ -2463,7 +2463,7 @@ $$\text{cross\_entropy\_with\_logits}(x_i, y_i) = \frac{\sum_i -x_i \cdot y_i}{N * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.nn.dropout(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *rate:*[float](https://docs.python.org/3/library/functions.html#float)*= 0.5*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.dropout(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *rate:*[float](https://docs.python.org/3/library/functions.html#float)*= 0.5*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 对输入张量应用 dropout 操作。 @@ -2476,7 +2476,7 @@ $$\text{cross\_entropy\_with\_logits}(x_i, y_i) = \frac{\sum_i -x_i \cdot y_i}{N * **返回:result** :dropout 的结果,是一个包含两个张量的元组。第一个是原始张量,第二个是掩码张量(未丢弃元素处为 1.0,丢弃处为 0.0)。 * **返回类型:** relax.Expr。 -## tvm.relax.op.nn.gelu(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.gelu(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 高斯误差线性单元函数 @@ -2486,16 +2486,16 @@ $$\text{GeLU}(x) = 0.5 * x * (1 + \text{erf}(x * 0.5**0.5))$$ 其中 erf 是高斯误差函数。 * **参数:** * **data** (*relax.Expr*) *:*输入数据。 -* **返回:result** [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)计算结果。 +* **返回:result** -计算结果。 * **返回类型:** relax.Expr。 -:::Note +:::note 输入张量必须具有 float dtype。 ::: -## tvm.relax.op.nn.gelu_tanh(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.gelu_tanh(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 高斯误差线性单元函数,使用 tanh 近似 @@ -2505,13 +2505,13 @@ $$\text{GELU}(x) = 0.5 * x * (1 + \text{Tanh}(\sqrt(2 / \pi) * (x + 0.044715 * x * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -:::Note +:::note 输入张量必须具有 float dtype。 ::: -## tvm.relax.op.nn.group_norm(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *gamma:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *beta:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *num_groups:*[int](https://docs.python.org/3/library/functions.html#int), *channel_axis:*[int](https://docs.python.org/3/library/functions.html#int), *axes:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*, *epsilon:*[float](https://docs.python.org/3/library/functions.html#float)*= 1e-05*, *center:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *scale:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.group_norm(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *gamma:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *beta:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *num_groups:*[int](https://docs.python.org/3/library/functions.html#int), *channel_axis:*[int](https://docs.python.org/3/library/functions.html#int), *axes:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*, *epsilon:*[float](https://docs.python.org/3/library/functions.html#float)*= 1e-05*, *center:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *scale:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 分组归一化(Yuxin Wu 等人,2016 年)。将分组归一化应用于 n 维输入数组。该运算符接收一个 n 维输入数组。首先沿通道轴将输入数组分成多个组。然后对每个组应用层归一化。 @@ -2522,27 +2522,27 @@ $$\text{GELU}(x) = 0.5 * x * (1 + \text{Tanh}(\sqrt(2 / \pi) * (x + 0.044715 * x * **num_groups** ([int](https://docs.python.org/3/library/functions.html#int)) *:* 将通道分离成的组数。 * **channel_axis** ([int](https://docs.python.org/3/library/functions.html#int)) *:* 输入数据中通道轴的索引。 * **axes** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,***List***[*[int](https://docs.python.org/3/library/functions.html#int)*]]) *:* 正规化应用的轴(不包括组轴)。 - * **epsilon** ([float](https://docs.python.org/3/library/functions.html#float)) [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)添加到方差中的小浮点数,以避免除以零。 + * **epsilon** ([float](https://docs.python.org/3/library/functions.html#float)) -添加到方差中的小浮点数,以避免除以零。 * **center** ([bool](https://docs.python.org/3/library/functions.html#bool)) :指示是否将 beta 偏移添加到归一化张量中。 * **scale** ([bool](https://docs.python.org/3/library/functions.html#bool)) :指示是否将伽马缩放相乘。 * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.nn.instance_norm(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *gamma:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *beta:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *channel_axis:*[int](https://docs.python.org/3/library/functions.html#int), *axes:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*, *epsilon:*[float](https://docs.python.org/3/library/functions.html#float)*= 1e-05*, *center:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *scale:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.instance_norm(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *gamma:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *beta:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *channel_axis:*[int](https://docs.python.org/3/library/functions.html#int), *axes:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*, *epsilon:*[float](https://docs.python.org/3/library/functions.html#float)*= 1e-05*, *center:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *scale:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) **参数:** * **data** (*relax.Expr*) *:* 应用 instance_norm 的输入。 * **gamma** (*relax.Expr*) *:* gamma 缩放因子。 * **beta** (*relax.Expr*) :beta 偏移因子。 - * **axes** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***List****[*[int](https://docs.python.org/3/library/functions.html#int)*]]*) [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)正在应用归一化的轴。 + * **axes** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***List****[*[int](https://docs.python.org/3/library/functions.html#int)*]]*) -正在应用归一化的轴。 * **epsilon** ([float](https://docs.python.org/3/library/functions.html#float)) :添加到方差中的小浮点数,以避免除以零。 * **center** ([bool](https://docs.python.org/3/library/functions.html#bool)) :指示是否将 beta 偏移添加到归一化张量中。 * **scale** ([bool](https://docs.python.org/3/library/functions.html#bool)) :指示是否将伽马缩放相乘。 * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.nn.layer_norm(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *gamma:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *beta:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axes:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*, *epsilon:*[float](https://docs.python.org/3/library/functions.html#float)*= 1e-05*, *center:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *scale:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.layer_norm(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *gamma:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *beta:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axes:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*, *epsilon:*[float](https://docs.python.org/3/library/functions.html#float)*= 1e-05*, *center:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *scale:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 层归一化(Lei Ba 等人,2016 年)。将层归一化应用于 n 维输入数组。该运算符接收一个 n 维输入数组,并使用指定的轴对输入进行归一化: @@ -2553,7 +2553,7 @@ $$out = \frac{data - mean(data, axis)}{\sqrt{var(data, axis)+\epsilon}} * gamma 假设输入在轴 1 上的大小为 k,那么 gamma 和 beta 的形状都是(k,)。 -:::Note +:::note 这个运算符可以在推理时被优化掉。 @@ -2569,7 +2569,7 @@ $$out = \frac{data - mean(data, axis)}{\sqrt{var(data, axis)+\epsilon}} * gamma * **返回:result** *:* 计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.nn.leakyrelu(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *alpha:*[float](https://docs.python.org/3/library/functions.html#float)*= 0.01*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.leakyrelu(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *alpha:*[float](https://docs.python.org/3/library/functions.html#float)*= 0.01*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 修正线性单元。 @@ -2581,7 +2581,7 @@ $$text{LeakyReLU, negative_slope}(x) = max(x, 0) + negative_slope * min(x, 0)$$ * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.nn.log_softmax(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= -1*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.log_softmax(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= -1*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算 log softmax。 @@ -2595,7 +2595,7 @@ $$\text{log\_softmax}(x_i) = \log\left( \frac{\exp(x_i)}{\sum_j \exp(x_j)}\right * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.nn.max_pool1d(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *pool_size:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1,)*, *strides:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1,)*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*, …] = (0, 0)*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1,)*, *ceil_mode:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *count_include_pad:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.max_pool1d(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *pool_size:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1,)*, *strides:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1,)*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*, …] = (0, 0)*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1,)*, *ceil_mode:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *count_include_pad:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 1D 最大池化运算符。 @@ -2609,18 +2609,18 @@ $$\text{log\_softmax}(x_i) = \log\left( \frac{\exp(x_i)}{\sum_j \exp(x_j)}\right ceil_mode 用于在计算输出形状时取上整或下整。count_include_pad 指示是否在计算中包含或排除填充的输入值。该运算符接受数据布局规范。 * **参数:** * **data** (*relax.Expr*) *:* 运算符的输入数据。 - * **pool_size** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) **:** 池化窗口的大小。它必须具有长度为 1。 - * **strides** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) :池化的步长。它必须具有长度为 1。 - * **padding** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***…****]]*) [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)池化的填充。它必须具有长度为 1 或 2。 - * **dilation** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) [:](https://docs.python.org/3/library/typing.html#typing.Tuple)池化的膨胀率。必须为长度为 1。 - * **ceil_mode** ([bool](https://docs.python.org/3/library/functions.html#bool)) [:](https://docs.python.org/3/library/typing.html#typing.Tuple)一个布尔值,指示是否使用 ceil 或 floor 来计算输出形状。使用 ceil 时,输入张量的每个元素都将被滑动窗口覆盖。 + * **pool_size** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) **:** 池化窗口的大小。它必须具有长度为 1。 + * **strides** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) :池化的步长。它必须具有长度为 1。 + * **padding** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***…****]]*) -池化的填充。它必须具有长度为 1 或 2。 + * **dilation** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) - 池化的膨胀率。必须为长度为 1。 + * **ceil_mode** ([bool](https://docs.python.org/3/library/functions.html#bool)) - 一个布尔值,指示是否使用 ceil 或 floor 来计算输出形状。使用 ceil 时,输入张量的每个元素都将被滑动窗口覆盖。 * **count_include_pad** ([bool](https://docs.python.org/3/library/functions.html#bool)*,optional*) *:* 是否将填充包括在内以计算平均值。 * **layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)) *:*输入的布局。 * **out_layout** (*Optional[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :输出的布局。如果未指定,则与 data_layout 相同 * **返回:result** :计算结果。 * **返回类型:** Expr。 -## tvm.relax.op.nn.max_pool2d(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *pool_size:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *strides:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*, …] = (0, 0)*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *ceil_mode:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *count_include_pad:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCHW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.max_pool2d(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *pool_size:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *strides:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*, …] = (0, 0)*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *ceil_mode:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *count_include_pad:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCHW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 2D 最大池化运算符。 @@ -2643,18 +2643,18 @@ $$ 在计算之前对数据进行填充。ceil_mode 用于在计算输出形状时取上整或下整。该运算符接受数据布局规范。 * **参数:** * **data** (*relax.Expr*) :运算符的输入数据。 - * **pool_size** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) :池化窗口的大小。必须具有长度为 1 或 2。 - * **strides** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) :池化的步长。必须具有长度为 1 或 2。 - * **padding** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***…****]]*) *:* 池化操作的填充。必须具有长度为 1、2 或 4。 - * **dilation** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) *:* 池化操作的膨胀率。必须具有长度为 1 或 2。 + * **pool_size** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) :池化窗口的大小。必须具有长度为 1 或 2。 + * **strides** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) :池化的步长。必须具有长度为 1 或 2。 + * **padding** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***…****]]*) *:* 池化操作的填充。必须具有长度为 1、2 或 4。 + * **dilation** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) *:* 池化操作的膨胀率。必须具有长度为 1 或 2。 * **ceil_mode** ([bool](https://docs.python.org/3/library/functions.html#bool)) *:* 一个布尔值,指示是否使用 ceil 或 floor 来计算输出形状。使用 ceil 时,输入张量的每个元素都将被滑动窗口覆盖。 - * **count_include_pad** ([bool](https://docs.python.org/3/library/functions.html#bool)*,optional*) [:](https://docs.python.org/3/library/functions.html#bool)是否将填充包括在内以计算平均值。 + * **count_include_pad** ([bool](https://docs.python.org/3/library/functions.html#bool)*,optional*) - 是否将填充包括在内以计算平均值。 * **layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :输入的布局。 - * **out_layout** (*Optional[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)输出的布局。如果未指定,则与 data_layout 相同。 + * **out_layout** (*Optional[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) -输出的布局。如果未指定,则与 data_layout 相同。 * **返回:result** :计算结果。 * **返回类型:** Expr。 -## tvm.relax.op.nn.max_pool3d(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *pool_size:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1, 1)*, *strides:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1, 1)*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*, …] = (0, 0, 0)*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1, 1)*, *ceil_mode:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *count_include_pad:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCDHW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.max_pool3d(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *pool_size:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1, 1)*, *strides:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1, 1)*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*, …] = (0, 0, 0)*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1, 1)*, *ceil_mode:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *count_include_pad:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCDHW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 3D 最大池化运算符。 @@ -2669,10 +2669,10 @@ $$ ceil_mode 用于在计算输出形状时取上整或下整。count_include_pad 指示是否在计算中包含或排除填充的输入值。该运算符接受数据布局规范。 * **参数:** * **data** (*relax.Expr*) :运算符的输入数据。 - * **pool_size** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) :池化窗口的大小。必须具有 1 或 3 的长度。 - * **strides** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) :池化的步长。必须具有长度为 1 或 3。 - * **padding** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***…****]]*) :池化操作的填充。长度必须是 1、3 或 6。 - * **dilation** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) *:* 池化操作的膨胀率。必须为长度为 1 或 3 的值。 + * **pool_size** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) :池化窗口的大小。必须具有 1 或 3 的长度。 + * **strides** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) :池化的步长。必须具有长度为 1 或 3。 + * **padding** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***…****]]*) :池化操作的填充。长度必须是 1、3 或 6。 + * **dilation** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[int](https://docs.python.org/3/library/functions.html#int)***,*** [int](https://docs.python.org/3/library/functions.html#int)***]****]*) *:* 池化操作的膨胀率。必须为长度为 1 或 3 的值。 * **ceil_mode** ([bool](https://docs.python.org/3/library/functions.html#bool)) :一个布尔值,指示是否使用 ceil 或 floor 来计算输出形状。使用 ceil 时,输入张量的每个元素都将被滑动窗口覆盖。 * **count_include_pad** ([bool](https://docs.python.org/3/library/functions.html#bool)*,optional*) :是否将填充包括在内以计算平均值。 * **layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :输入的布局。 @@ -2680,7 +2680,7 @@ ceil_mode 用于在计算输出形状时取上整或下整。count_include_pad * **返回:result** :计算结果。 * **返回类型:** Expr。 -## tvm.relax.op.nn.nll_loss(*predictions:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *targets:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *weights:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *reduction:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'mean'*, *ignore_index:*[int](https://docs.python.org/3/library/functions.html#int)*= -100*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.nll_loss(*predictions:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *targets:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *weights:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *reduction:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'mean'*, *ignore_index:*[int](https://docs.python.org/3/library/functions.html#int)*= -100*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 负对数似然损失。 @@ -2698,19 +2698,19 @@ result = reduction(output)。 * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.nn.pad(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *pad_width:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*, …]*, *pad_mode:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= 'constant'*, *pad_value:*[float](https://docs.python.org/3/library/functions.html#float)*|*[None](https://docs.python.org/3/library/constants.html#None)*= 0.0*) +## tvm.relax.op.nn.pad(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *pad_width:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*, …]*, *pad_mode:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= 'constant'*, *pad_value:*[float](https://docs.python.org/3/library/functions.html#float)*|*[None](https://docs.python.org/3/library/constants.html#None)*= 0.0*) 这个运算符接收一个张量,并使用指定的值按照指定的宽度对每个轴进行填充。 * **参数:** * **data** (*relax.Expr*) :运算符的输入数据 - * **pad_width** (*Union**[****List**[***[int](https://docs.python.org/3/library/functions.html#int)***]****,*[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,…**]****],required*) :每个轴边缘填充的值数量,格式为 ((before_1, after_1), …, (before_N, after_N)) + * **pad_width** (*Union**[****List**[***[int](https://docs.python.org/3/library/functions.html#int)***]****,*[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)*[*[int](https://docs.python.org/3/library/functions.html#int)*,…**]****],required*) :每个轴边缘填充的值数量,格式为 ((before_1, after_1), …, (before_N, after_N)) * **pad_mode** (*Optional[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :‘constant’, ‘reflect’, ‘replicate’, ‘circular’ ‘constant’ 使用常数值填充 pad_value ‘reflect’ 通过镜像值(不包括边缘)进行填充 ‘replicate’ 通过重复边缘值进行填充。 ‘circular’ 通过从另一侧循环值进行填充。默认为 ‘constant’ * **pad_value** (*Optional**[****Union**[***[float](https://docs.python.org/3/library/functions.html#float)***,*** ***Expr****]]*) :用于填充的值。默认为 0。 * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.nn.pixel_shuffle(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *upscale_factor:*[int](https://docs.python.org/3/library/functions.html#int)) +## tvm.relax.op.nn.pixel_shuffle(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *upscale_factor:*[int](https://docs.python.org/3/library/functions.html#int)) 像素重排运算符。 @@ -2729,7 +2729,7 @@ result = reduction(output)。 如果输入张量的形状为 (1, 8, 10, 15) 且上采样因子为 2,则结果张量的形状将为 (1, 2, 20, 30)。 -## tvm.relax.op.nn.prelu(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *alpha:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.prelu(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *alpha:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 参数化整流线性单元(PReLU)。 @@ -2738,11 +2738,11 @@ $$PReLU(x) = x \text{ if } x > 0 \text{ else } \alpha * x$$ * **参数:** * **data** (*relax.Expr*) :输入张量。 * **alpha** (*relax.Expr*) :可学习的斜率张量,按通道应用。 - * **axis** ([int](https://docs.python.org/3/library/functions.html#int)) [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)alpha 值应用的轴。默认为 1(假设为 NCHW 格式)。 + * **axis** ([int](https://docs.python.org/3/library/functions.html#int)) -alpha 值应用的轴。默认为 1(假设为 NCHW 格式)。 * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.nn.relu(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.relu(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 修正线性单元。 @@ -2753,7 +2753,7 @@ $$\text{ReLU}(x) = \max(x, 0)$$ * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.nn.relu6(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.relu6(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) ReLU6 激活函数。 @@ -2764,7 +2764,7 @@ $$\text{ReLU6}(x) = \min(\max(x, 0), 6)$$ * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.nn.rms_norm(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *weight:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axes:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] = -1*, *epsilon:*[float](https://docs.python.org/3/library/functions.html#float)*= 1e-05*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.rms_norm(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *weight:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axes:*[int](https://docs.python.org/3/library/functions.html#int)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] = -1*, *epsilon:*[float](https://docs.python.org/3/library/functions.html#float)*= 1e-05*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 均方根归一化(Biao Zhang 等,2019)。对 n 维输入数组应用均方根归一化。该运算符接收一个 n 维输入数组,并使用指定轴对输入进行归一化: @@ -2774,12 +2774,12 @@ $$out = \frac{data}{\sqrt{mean(data, axis)+\epsilon}} * weight + bias$$ * **data** (*relax.Expr*) **:** rms_norm 将要应用到的输入。 * **weight** (*relax.Expr*) :缩放因子。 * **bias** (*relax.Expr*) :偏移因子。 - * **axes** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***List****[*[int](https://docs.python.org/3/library/functions.html#int)*]]*) [:](https://docs.python.org/3/library/functions.html#int)沿着这些轴应用归一化。 + * **axes** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***List****[*[int](https://docs.python.org/3/library/functions.html#int)*]]*) - 沿着这些轴应用归一化。 * **epsilon** ([float](https://docs.python.org/3/library/functions.html#float)) :添加到平方均值的小浮点数,以避免除以零。 * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.nn.selu(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.selu(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 缩放指数线性单元(SELU)。 @@ -2792,7 +2792,7 @@ $$\begin{split}\text{SELU}(x) = \lambda \begin{cases} x & \text{if } x > 0 \ * **返回:result** *:* 计算结果。 * **返回类型:** relax.Expr -## tvm.relax.op.nn.silu(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.silu(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) Sigmoid 线性单元函数。 @@ -2803,13 +2803,13 @@ $$\text{SiLU}(x) = x * \text{sigmoid}(x)$$ * **返回:result** :计算结果。 * **返回类型:** relax.Expr。 -:::Note +:::note 输入张量必须具有 float dtype。 ::: -## tvm.relax.op.nn.softmax(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= -1*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.softmax(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= -1*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 计算 softmax。 @@ -2824,7 +2824,7 @@ $$\text{softmax}(x)_i = \frac{\exp(x_i)}{\sum_j \exp(x_j)}$$ 输入张量必须具有 float dtype。 -## tvm.relax.op.nn.softplus(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *beta:*[float](https://docs.python.org/3/library/functions.html#float)*= 1.0*, *threshold:*[float](https://docs.python.org/3/library/functions.html#float)*= 20.0*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.nn.softplus(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *beta:*[float](https://docs.python.org/3/library/functions.html#float)*= 1.0*, *threshold:*[float](https://docs.python.org/3/library/functions.html#float)*= 20.0*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) Softplus 激活函数。 @@ -2843,7 +2843,7 @@ $$\text{Softplus}(x) = \frac{1}{\beta} \log(1 + e^{\beta x})$$ Relax 内置运算符。 -## tvm.relax.op.builtin.alloc_tensor(*shape:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *runtime_device_index:*[int](https://docs.python.org/3/library/functions.html#int)*|*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *storage_scope:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*= 'global'*) → [Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call) +## tvm.relax.op.builtin.alloc_tensor(*shape:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *runtime_device_index:*[int](https://docs.python.org/3/library/functions.html#int)*|*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *storage_scope:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*= 'global'*) → [Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone) 构建一个 relax.Call 来分配具有特定形状、dtype 和 runtime_device_index 的张量。 @@ -2853,9 +2853,9 @@ Relax 内置运算符。 * **runtime_device_index** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***Expr****]*) :1 保留用于主机设备。 * **storage_scope** (*Union**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,*** ***Expr****]*) :指示分配存储的范围。 * **返回:result** :一个 relax relax.Call,它获取已分配的张量。 -* **返回类型:**[relax.Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call)。 +* **返回类型:**[relax.Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone)。 -## tvm.relax.op.builtin.stop_lift_params(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.builtin.stop_lift_params(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 一个指示输入张量的消费者不应被提升到 transform_params 函数的标志。 @@ -2888,7 +2888,7 @@ Allreduce 运算符。 * **返回:result** :allreduce 的所有结果。 * **返回类型:** relax.Expr。 -## tvm.relax.op.ccl.broadcast_from_worker0(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.ccl.broadcast_from_worker0(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 从 worker-0 广播数据到所有其他 worker。 @@ -2896,7 +2896,7 @@ Allreduce 运算符。 * **返回:result** *:* 已广播到所有其他 worker 的相同张量。 * **返回类型:** relax.Expr。 -## tvm.relax.op.ccl.scatter_from_worker0(*x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *num_workers:*[int](https://docs.python.org/3/library/functions.html#int), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= 0*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.ccl.scatter_from_worker0(*x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *num_workers:*[int](https://docs.python.org/3/library/functions.html#int), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*= 0*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 执行从 worker-0 开始的 scatter 操作,将给定的 buffer 分成相等的部分。 @@ -2914,18 +2914,18 @@ Allreduce 运算符。 用于分布式 Relax 的运算符。 -## tvm.relax.op.distributed.annotate_sharding(*input:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *device_mesh: DeviceMesh*, *placement: Placement*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.distributed.annotate_sharding(*input:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *device_mesh: DeviceMesh*, *placement: Placement*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 为张量标注分片计划。 * **参数:** * **input** (*relax.Expr*) *:* 输入张量。 - * **device_mesh** (*DeviceMesh*) [:](https://docs.python.org/3/library/constants.html#None)分片计划的设备网格。 + * **device_mesh** (*DeviceMesh*) - 分片计划的设备网格。 * **placement** (*Placement*) :分片计划的放置。 * **返回:result** :未修改的张量。 * **返回类型:** relax.Expr。 -## tvm.relax.op.distributed.redistribute(*input:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *device_mesh: DeviceMesh*, *placement: Placement*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.distributed.redistribute(*input:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *device_mesh: DeviceMesh*, *placement: Placement*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 重分布张量。 @@ -2936,18 +2936,18 @@ Allreduce 运算符。 * **返回:result** :重分布后的张量。 * **返回类型:** relax.Expr。 -## tvm.relax.op.distributed.call_tir_local_view(*gvar:*[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar), *args:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *out_sinfo: DTensorStructInfo |*[List](https://docs.python.org/3/library/typing.html#typing.List)*[DTensorStructInfo]*, *tir_vars:*[ShapeExpr](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ShapeExpr)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*] |*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call) +## tvm.relax.op.distributed.call_tir_local_view(*gvar:*[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none), *args:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *out_sinfo: DTensorStructInfo |*[List](https://docs.python.org/3/library/typing.html#typing.List)*[DTensorStructInfo]*, *tir_vars:*[ShapeExpr](/docs/api-reference/python-api/tvm-relax#classtvmrelaxshapeexprvalueslistprimexprtupleprimexprarrayspanspannonenone)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*] |*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone) relax.Call 一个 tir.prim_func 并返回输出。该 prim_func 应该是一个工作本地函数,实际上在每个工作节点上执行,而不是未分割的函数。这个运算符的输出是 DTensor 或 DTensor 的元组。 * **参数:** - * **gvar** ([GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar)) :指向 tir PrimFunc 的 GlobalVar。 + * **gvar** ([GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none)) :指向 tir PrimFunc 的 GlobalVar。 * **args** (*Expr*) :输入参数。 * **out_sinfo** (*Union**[****DTensorStructInfo**,*** ***List****[**DTensorStructInfo****]]*) :调用_tir 的输出结构信息。它应该是一个 DTensorStructInfo 或一个 DTensorStructInfo 的列表。每一个表示一个返回张量的结构信息。 - * **tir_vars** (*Optional**[****Union**[***[ShapeExpr](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.ShapeExpr)***,*** [Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)***]****,List**[***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)***]****]]*) :表示调用 func 时需要解包的整数元组的 ShapeExpr。如果未使用则为 null。 + * **tir_vars** (*Optional**[****Union**[***[ShapeExpr](/docs/api-reference/python-api/tvm-relax#classtvmrelaxshapeexprvalueslistprimexprtupleprimexprarrayspanspannonenone)***,*** [Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)***]****,List**[***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)***]****]]*) :表示调用 func 时需要解包的整数元组的 ShapeExpr。如果未使用则为 null。 * **返回:ret** *:* call_tir_local_view 运算符的调用节点。 -* **返回类型:**[relax.Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call)。 +* **返回类型:**[relax.Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone)。 -## tvm.relax.op.distributed.redistribute_replica_to_shard(*input:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *num_workers:*[int](https://docs.python.org/3/library/functions.html#int), *axis:*[int](https://docs.python.org/3/library/functions.html#int)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.distributed.redistribute_replica_to_shard(*input:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *num_workers:*[int](https://docs.python.org/3/library/functions.html#int), *axis:*[int](https://docs.python.org/3/library/functions.html#int)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 沿一个轴将张量切片成多个部分, @@ -2969,14 +2969,14 @@ relax.Call 一个 tir.prim_func 并返回输出。该 prim_func 应该是一个 `RelaxExpr` 的别名。 -## tvm.relax.op.grad.avg_pool2d_backward(*output_grad:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *pool_size:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *strides:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *padding:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (0, 0, 0, 0)*, *dilation:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *ceil_mode:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *count_include_pad:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCHW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.grad.avg_pool2d_backward(*output_grad:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *pool_size:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *strides:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *padding:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (0, 0, 0, 0)*, *dilation:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *ceil_mode:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *count_include_pad:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCHW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) relax.nn.avg_pool2d 的反向运算符。除了 output_grad 之外的所有参数与relax.nn.avg_pool2d 相同。返回关于 data 的梯度。 * **参数:output_grad** (*relax.Expr*) *:* 对 avg_pool2d 结果的梯度。 * **返回:result** :对数据的梯度。 * **返回类型:** relax.Expr。 -## tvm.relax.op.grad.end_checkpoint(*input:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.grad.end_checkpoint(*input:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 标记检查点阶段的结束。参见 tvm.relax.op.grad.start_checkpoint。 @@ -2984,7 +2984,7 @@ relax.nn.avg_pool2d 的反向运算符。除了 output_grad 之外的所有参 * **返回:result** :与输入相同的张量。 * **返回类型:** relax.Expr。 -## tvm.relax.op.grad.max_pool2d_backward(*output_grad:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *pool_size:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *strides:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *padding:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (0, 0, 0, 0)*, *dilation:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *ceil_mode:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *count_include_pad:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCHW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.grad.max_pool2d_backward(*output_grad:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *pool_size:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *strides:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *padding:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (0, 0, 0, 0)*, *dilation:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*,*[int](https://docs.python.org/3/library/functions.html#int)*] = (1, 1)*, *ceil_mode:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *count_include_pad:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCHW'*, *out_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) relax.nn.max_pool2d 的反向运算符。除了 output_grad 之外的所有参数与 。relax.nn.max_pool2d 相同。返回相对于数据的梯度。 @@ -2992,21 +2992,21 @@ relax.nn.max_pool2d 的反向运算符。除了 output_grad 之外的所有参 * **返回:result** *:* 对数据的梯度。 * **返回类型:** relax.Expr。 -## tvm.relax.op.grad.nll_loss_backward(*output_grad:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *predictions:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *targets:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *weights:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *reduction:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'mean'*, *ignore_index:*[int](https://docs.python.org/3/library/functions.html#int)*= -100*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.grad.nll_loss_backward(*output_grad:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *predictions:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *targets:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *weights:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *reduction:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'mean'*, *ignore_index:*[int](https://docs.python.org/3/library/functions.html#int)*= -100*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) relax.nn.nll_loss 的反向运算符。除了 output_grad 外,所有参数与 relax.nn.nll_loss 相同。返回对预测的梯度。 * **参数:output_grad** (*relax.Expr*) :对 nll_loss 结果的梯度。 * **返回:result**:对预测的梯度。 * **返回类型:** relax.Expr。 -## tvm.relax.op.grad.no_grad(*input:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.grad.no_grad(*input:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 对输入无梯度的虚拟运算符。 * **参数:input** (*relax.Expr*) :对应的输入张量。 * **返回:result** :相对于输入的无梯度表示。 * **返回类型:** relax.Expr。 -## tvm.relax.op.grad.start_checkpoint(*input:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.grad.start_checkpoint(*input:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 标记检查点阶段的开始。start_checkpoint 和 end_checkpoint 之间的计算将被标记为检查点阶段。 @@ -3022,7 +3022,7 @@ relax.nn.nll_loss 的反向运算符。除了 output_grad 外,所有参数与 * **返回:result** *:* 与输入相同的张量。 * **返回类型:** relax.Expr。 -## tvm.relax.op.grad.take_backward(*output_grad:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *x:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *indices:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.grad.take_backward(*output_grad:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *x:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *indices:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) relax.take 的反向运算符。除了 output_grad 之外的所有参数与 relax.take 相同。返回关于 x 的梯度。 @@ -3038,7 +3038,7 @@ relax.take 的反向运算符。除了 output_grad 之外的所有参数与 rela 图像运算符。 -## tvm.relax.op.image.resize2d(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *size:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*|*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*, *roi:*[float](https://docs.python.org/3/library/functions.html#float)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[float](https://docs.python.org/3/library/functions.html#float)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCHW'*, *method:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'linear'*, *coordinate_transformation_mode:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'half_pixel'*, *rounding_method:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'round'*, *cubic_alpha:*[float](https://docs.python.org/3/library/functions.html#float)*= -0.75*, *cubic_exclude:*[int](https://docs.python.org/3/library/functions.html#int)*= 0*, *extrapolation_value:*[float](https://docs.python.org/3/library/functions.html#float)*= 0.0*, *out_dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.image.resize2d(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *size:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*|*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*, *roi:*[float](https://docs.python.org/3/library/functions.html#float)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[float](https://docs.python.org/3/library/functions.html#float)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'NCHW'*, *method:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'linear'*, *coordinate_transformation_mode:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'half_pixel'*, *rounding_method:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'round'*, *cubic_alpha:*[float](https://docs.python.org/3/library/functions.html#float)*= -0.75*, *cubic_exclude:*[int](https://docs.python.org/3/library/functions.html#int)*= 0*, *extrapolation_value:*[float](https://docs.python.org/3/library/functions.html#float)*= 0.0*, *out_dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 图像 resize2d 运算符。 @@ -3050,8 +3050,8 @@ relax.take 的反向运算符。除了 output_grad 之外的所有参数与 rela method 指示计算输出值时使用的算法,method 可以是("linear", "nearest_neighbor", "cubic")之一。 * **参数:** * **data** (*relax.Expr*) :运算符的输入数据。 - * **size** (*Union**[****Expr**,*** ***PrimExprLike****,*[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)*[**PrimExprLike****]]*) :图像将被调整到的输出尺寸。如果指定为列表,其长度必须是 1 或 2。如果指定为 Expr,其必须具有维度 2。 - * **roi** (*Optional**[****Union**[***[float](https://docs.python.org/3/library/functions.html#float)***,*** [Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***[***[float](https://docs.python.org/3/library/functions.html#float)***]****]]*) :用于裁剪输入图像的区域。预期大小为 4,格式为[start_h, start_w, end_h, end_w]。仅在使用 coordinate_transformation_mode 为 tf_crop_and_resize 时使用。 + * **size** (*Union**[****Expr**,*** ***PrimExprLike****,*[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)*[**PrimExprLike****]]*) :图像将被调整到的输出尺寸。如果指定为列表,其长度必须是 1 或 2。如果指定为 Expr,其必须具有维度 2。 + * **roi** (*Optional**[****Union**[***[float](https://docs.python.org/3/library/functions.html#float)***,*** [Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***[***[float](https://docs.python.org/3/library/functions.html#float)***]****]]*) :用于裁剪输入图像的区域。预期大小为 4,格式为[start_h, start_w, end_h, end_w]。仅在使用 coordinate_transformation_mode 为 tf_crop_and_resize 时使用。 * **layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :输入的布局。 * **method** ([str](https://docs.python.org/3/library/stdtypes.html#str)) *:* 使用的缩放方法 [最近邻, 线性, 三次插值]。 * **coordinate_transformation_mode** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :描述如何将调整大小后的张量中的坐标转换为原始张量中的坐标。定义可以在 topi/image/resize.py 中找到。[半像素, 对齐角点, 非对称, pytorch_half_pixel, tf_half_pixel_for_nn, 和 tf_crop_and_resize]。 @@ -3059,7 +3059,7 @@ method 指示计算输出值时使用的算法,method 可以是("linear", "nea * **cubic_alpha** ([float](https://docs.python.org/3/library/functions.html#float)) ***:*** 双三次插值的样条系数。 * **cubic_exclude** ([int](https://docs.python.org/3/library/functions.html#int)) :标志位,用于在双三次插值时排除图像外部区域。 * **extrapolation_value** ([float](https://docs.python.org/3/library/functions.html#float)) :当 roi 位于图像外部时使用的填充值。 - * **out_dtype** (*Optional**[****Union**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,*** ***DataType****]]*) [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)输出张量的数据类型。如果未指定,输出将具有与输入相同的数据类型(如果未指定)。 + * **out_dtype** (*Optional**[****Union**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,*** ***DataType****]]*) -输出张量的数据类型。如果未指定,输出将具有与输入相同的数据类型(如果未指定)。 * **返回:result** :调整大小后的结果。 * **返回类型:** relax.Expr。 @@ -3069,47 +3069,47 @@ method 指示计算输出值时使用的算法,method 可以是("linear", "nea Relax 内存原语。 -## tvm.relax.op.memory.alloc_storage(*size:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *virtual_device_index:*[int](https://docs.python.org/3/library/functions.html#int)*|*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *storage_scope:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call) +## tvm.relax.op.memory.alloc_storage(*size:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *virtual_device_index:*[int](https://docs.python.org/3/library/functions.html#int)*|*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *storage_scope:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone) 构造一个 relax.Call 来分配具有特定大小、虚拟设备索引、存储范围和 dtype 的存储。 * **参数:** - * **size** (*Expr*) [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)要分配的存储的大小。 + * **size** (*Expr*) :要分配的存储的大小。 * **virtual_device_index** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***Expr****]*) :1 保留用于主机设备。 * **storage_scope** (*Union**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,*** ***Expr****]*) :指示分配存储的范围。 * **dtype** (*Union**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,*** ***Expr****]*) :要分配的存储的数据类型。 -* **返回:result** [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)一个 relax relax.Call,它获取已分配的存储。 -* **返回类型:**[relax.Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call)。 +* **返回:result** :一个 relax relax.Call,它获取已分配的存储。 +* **返回类型:**[relax.Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone)。 -## tvm.relax.op.memory.alloc_tensor(*storage:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *offset:*[int](https://docs.python.org/3/library/functions.html#int)*|*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *shape:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call)[](https://tvm.apache.org/docs/reference/api/python/relax/op.html#tvm.relax.op.memory.alloc_tensor) +## tvm.relax.op.memory.alloc_tensor(*storage:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *offset:*[int](https://docs.python.org/3/library/functions.html#int)*|*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *shape:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone) 构建一个 relax.Call 来在指定的存储上从给定偏移量开始分配一个张量。 * **参数:** - * **storage** (*Expr*) [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)分配张量的存储。 + * **storage** (*Expr*) -分配张量的存储。 * **offset** (*Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,*** ***Expr****]*) *:* 分配张量的存储偏移量。 - * **shape** (*Expr*) [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)要分配的张量的形状。 + * **shape** (*Expr*) -要分配的张量的形状。 * **dtype** (*Union**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,*** ***Expr****]*) :要分配的张量的数据类型。 * **返回:result** :一个 relax relax.Call,它获取已分配的张量。 -* **返回类型:**[relax.Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call)。 +* **返回类型:**[relax.Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone)。 -## tvm.relax.op.memory.kill_storage(*storage:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call) +## tvm.relax.op.memory.kill_storage(*storage:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone) 构建一个 relax.Call 来销毁一个存储。 * **参数:storage** (*Expr*) :要杀死的存储。 * **返回:result** :一个用于杀死存储的 relax relax.Call。 -* **返回类型:**[relax.Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call)。 +* **返回类型:**[relax.Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone)。 -## tvm.relax.op.memory.kill_tensor(*tensor:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call) +## tvm.relax.op.memory.kill_tensor(*tensor:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone) 构建一个 relax.Call 来销毁一个张量。 * **参数:tensor** (*Expr*) :要销毁的张量。 * **返回:result** :一个用于销毁张量的 relax relax.Call。 -* **返回类型:**[relax.Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call)。 +* **返回类型:**[relax.Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone)。 -## tvm.relax.op.memory.view(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr), *shape:*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*] |*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *dtype:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *relative_byte_offset:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.memory.view(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr), *shape:*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*] |*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *dtype:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *relative_byte_offset:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 提供一个现有张量的视图。 @@ -3127,7 +3127,7 @@ Relax 内存原语。 * **返回:result** :张量视图。 * **返回类型:** relax.Expr。 -## tvm.relax.op.memory.ensure_zero_offset(*data:*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)) → [RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr) +## tvm.relax.op.memory.ensure_zero_offset(*data:*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)) → [RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr) 确保张量具有 elem_offset == 0。如有必要,将进行复制。 diff --git a/docs/04-api-reference/01-python-api/16-tvm-relax-transform.md b/docs/04-api-reference/01-python-api/16-tvm-relax-transform.md index b4a0cde..e93c3ee 100644 --- a/docs/04-api-reference/01-python-api/16-tvm-relax-transform.md +++ b/docs/04-api-reference/01-python-api/16-tvm-relax-transform.md @@ -1,12 +1,12 @@ --- -title: Relax 变换 +title: tvm.relax.transform --- -Relax 变换。 +TVM Relax 中用于图优化和程序变换的模块 ## tvm.relax.transform.AdjustMatmulOrder() @@ -16,9 +16,9 @@ Relax 变换。 有助于优化 LoRA 计算,其中 matmul(x, LoraA*LoraB)可以计算为 matmul(matmul(x, LoraA), LoraB),从而减少总内存使用量。 * **返回:ret**:相应的 pass。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.AllocateWorkspace() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.AllocateWorkspace() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 分配一个工作区,用一个足够大的张量来表示,用于所有需要临时存储的外部函数,并将其附加到外部函数的参数中。 @@ -26,27 +26,27 @@ Relax 变换。 外部函数可以通过 kWorkspaceSize 属性指定其工作空间要求。 * **返回:ret**:用于分配工作空间的注册通道。 -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.AlterOpImpl(*op_impl_map:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)*]*, *op_buffer_transforms:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap)*|*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*]]*, *op_buffer_axis_separators:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[List](https://docs.python.org/3/library/typing.html#typing.List)*[axis_separator |*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*]]*, *op_buffer_input_axis_separators:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[List](https://docs.python.org/3/library/typing.html#typing.List)*[axis_separator |*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*]]*) +## tvm.relax.transform.AlterOpImpl(*op_impl_map:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)*]*, *op_buffer_transforms:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[IndexMap](/docs/api-reference/python-api/tvm-tir/#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map)*|*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*]]*, *op_buffer_axis_separators:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[List](https://docs.python.org/3/library/typing.html#typing.List)*[axis_separator |*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*]]*, *op_buffer_input_axis_separators:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[List](https://docs.python.org/3/library/typing.html#typing.List)*[axis_separator |*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*]]*) 将所有具有匹配“operator_name”属性的 PrimFunc 替换为可能在 I/O 缓冲区上具有不同布局的替代 PrimFunc。I/O 缓冲区的布局转换存在于 op_buffer_transforms 映射中。将布局转换插入到被替换的 PrimFunc 的调用点中,以便新的 PrimFunc 将 I/O 张量转换为预期的布局。 * **参数:** - * **op_impl_map** (*Dict[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)*]*):op_kind 到 PrimFunc 的映射。 - * **op_buffer_transforms** (*Dict**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,***List****[**Union****[*[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap)*,Callable]]):op_kind 用于为每个缓冲区布局转换图。 + * **op_impl_map** (*Dict[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)*]*):op_kind 到 PrimFunc 的映射。 + * **op_buffer_transforms** (*Dict**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,***List****[**Union****[*[IndexMap](/docs/api-reference/python-api/tvm-tir/#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map)*,Callable]]):op_kind 用于为每个缓冲区布局转换图。 * **op_buffer_axis_separators** (*Dict**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,*** ***List****[**Union****[**IndexMap.AXIS_SEPARATOR****,Callable**]****]]*):每个 index_map 的 op_kind 到 axis_separator。 * **op_buffer_input_axis_separators** (*Dict**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,*** ***List****[**Union****[**IndexMap.AXIS_SEPARATOR****,Callable**]****]]*):输入 index_map 的 op_kind 到 axis_separator。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.AnnotateTIROpPattern() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.AnnotateTIROpPattern() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 注释 TIR 函数的操作模式类型。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.AttachAttrLayoutFreeBuffers() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.AttachAttrLayoutFreeBuffers() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 将布局空闲缓冲区附加到 tir::PrimFunc。 @@ -57,36 +57,36 @@ Relax 变换。 请注意,我们建议在此过程之前应用 CanonicalizeBindings。 * **返回:ret**:用于附加布局空闲缓冲区的注册过程。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.AttachGlobalSymbol() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.AttachGlobalSymbol() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 将 global_symbol 附加到 Relax 函数和 TIR Primfuncs 以进行代码生成。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.BindParams(*func_name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *params:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)*,*[NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray)*| ndarray]*) → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.BindParams(*func_name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *params:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)*,*Tensor*| ndarray]*) → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 将模块函数的参数绑定到常量张量。 * **参数:** * **func_name** ([str](https://docs.python.org/3/library/stdtypes.html#str)):要绑定的函数名称。 - * **params** (*Dict**[****Union**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,***[relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)***]****,Union**[****tvm.runtime.NDArray**,*** ***np.ndarray****]]*)**:** 从参数或参数名称到常量张量的映射。 + * **params** (*Dict**[****Union**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,***[relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)***]****,Union**[****tvm.runtime.NDArray**,*** ***np.ndarray****]]*)**:** 从参数或参数名称到常量张量的映射。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.BindSymbolicVars(*binding_map:*[Mapping](https://docs.python.org/3/library/typing.html#typing.Mapping)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)*,*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*, *func_name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.BindSymbolicVars(*binding_map:*[Mapping](https://docs.python.org/3/library/typing.html#typing.Mapping)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)*,*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*, *func_name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 将模块函数的参数绑定到常量张量。 * **参数:** - * **binding_map** (*Mapping**[****Union**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,*** [tvm.tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)***]****,tvm.tir.PrimExpr]*):从符号 varname 到整数的映射。 + * **binding_map** (*Mapping**[****Union**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,*** [tvm.tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)***]****,tvm.tir.PrimExpr]*):从符号 varname 到整数的映射。 * **func_name** (*Optional[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):要绑定的函数名称。如果为 None (默认),则模块内的所有函数都将更新。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.BundleModelParams(*param_tuple_name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.BundleModelParams(*param_tuple_name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 将多个模型参数捆绑成一个元组参数 @@ -94,17 +94,17 @@ Relax 变换。 对于每个函数,如果该函数具有属性“num_input”,则将其运行时参数和编译时权重分开。运行时参数(例如激活函数)是第一个 num_input 参数,其余参数是编译时权重。 * **参数:param_tuple_name** (*Optional[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):元组参数的名称。如果未指定,则默认为“model_params”。 -* **返回:ret**[:](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)用于捆绑模型参数的注册过程。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回:ret**- 用于捆绑模型参数的注册过程。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.CallTIRRewrite() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.CallTIRRewrite() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 为 call_tir 和 call_dps_packed 执行显式张量分配。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.CanonicalizeBindings() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.CanonicalizeBindings() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 规范化变量定义(例如,如果 y = x 且 z = y,则将 y 和 z 替换为 x)。同时简化匹配强制类型转换节点(消除冗余检查)和元组索引。 @@ -115,7 +115,7 @@ Relax 变换。 注意:如果数据流变量仅用于与数据流块输出变量(即非数据流变量)的绑定,则此过程还将删除数据流变量并用数据流变量的直接定义替换输出变量的绑定。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.relax.transform.CombineParallelMatmul(*check=None*) @@ -125,11 +125,12 @@ Relax 变换。 目前仅支持有限的融合操作,包括 bias add、relu、gelu、gelu_tanh 和 silu 激活。 * **参数:** - * **check** (*Callable**[****[*[relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)*,List**[***[relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)***]****,List**[***[relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)***]****,Dict**[***[relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)***,*** ***Expr****]**]****,*[bool](https://docs.python.org/3/library/functions.html#bool)*]*)[:](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)> bool。 + * **check** (*Callable**[****[*[relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)*,List**[***[relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)***]****,List**[***[relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)***]****,Dict**[***[relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)***,*** ***Expr**]**]****,*[bool](https://docs.python.org/3/library/functions.html#bool)*]*)– 用于筛选不需要分支的函数,其函数签名为 (input, [rhs], [bias], binding)-> bool。 + * **返回:ret**:相应的 pass。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.ComputePrimValue() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.ComputePrimValue() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 计算所有 R.prim_value 实例。 @@ -137,31 +138,31 @@ Relax 变换。 虽然高级的 Relax 函数可以包含符号变量形式的表达式,但这些表达式无法在 Relax 函数中原生计算。为了给符号表达式提供值(例如 R.prim_value(N*N),其中 N 是符号变量),此过程会生成一个 PrimFunc 函数,用于计算该表达式。之后,Relax 函数图会更新,包含对该 PrimFunc 函数的调用,以替代原始的 R.prim_value(expr)。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.ConvertLayout(*desired_layouts:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]]*) → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.ConvertLayout(*desired_layouts:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]]*) → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 自动布局转换过程。 * **参数:desired_layouts** (*Dict**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,*** ***List****[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]]*):conv2d 操作所需的布局是从操作名称到所需特征图、权重和输出的所需布局的映射。例如,如果我们想将 conv2d 的布局从 NCHW 转换为 NHWC,我们可以将 conv2d 的所需布局设置为 。`{"relax.nn.conv2d": ["NHWC", "OHWI"]}` * **返回:ret**:布局转换的注册过程。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 - -## tvm.relax.transform.ConvertToDataflow(*min_size:*[int](https://docs.python.org/3/library/functions.html#int)*= 2*) → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)[](https://tvm.apache.org/docs/reference/api/python/relax/transform.html#tvm.relax.transform.ConvertToDataflow) +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 +将绑定块内的连续数据流操作转换为数据流块的过程。 +## tvm.relax.transform.ConvertToDataflow(*min_size:*[int](https://docs.python.org/3/library/functions.html#int)*= 2*) → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 将绑定块内的连续数据流操作转换为数据流块的过程。 注意:可能需要先调用 ConvertToDataflow。 -* **参数:min_size** ([int](https://docs.python.org/3/library/functions.html#int))[:](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)pass 提取新块所需的连续数据流绑定的最小数量。 +* **参数:min_size** ([int](https://docs.python.org/3/library/functions.html#int)):提取新块所需的连续数据流绑定的最小数量。 * **返回:ret**:传递。 -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## *class* tvm.relax.transform.DataflowBlockPass 对模块中每个 tvm.relax.DataflowBlock 进行操作的通道。 -## tvm.relax.transform.DataflowUseInplaceCalls() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.DataflowUseInplaceCalls() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 将对可就地执行的操作符(通常是逐元素运算)的调用更改为就地实现。支持的操作符将被替换为对 call_tir_inplace 的调用,该调用会调用这些操作符的就地 PrimFunc 实现(这些实现基于这些操作符的合法化)。 @@ -169,9 +170,9 @@ Relax 变换。 注意:可能需要先调用 ConvertToDataflow 来提供数据流块。 * **返回:ret**:该传递。 -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.DeadCodeElimination(*entry_functions:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.DeadCodeElimination(*entry_functions:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 删除 IRModule 中的死代码。目前,它会删除: @@ -191,26 +192,26 @@ Relax 变换。 对于功能性的 DCE,使用 py:func: tvm.relax.analysis.remove_all_unused。 * **参数:entry_functions** (*Optional**[****List**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***]****]*):开始的入口函数集。 * **返回:ret**:已注册的通行证。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.DecomposeOpsForInference(*func_name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.DecomposeOpsForInference(*func_name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 在推理过程中,分解由其他算子组成的复合算子。例如,批量归一化的结果(一个三元组)将被简化。注意力机制、tensor_to_shape 等也可以分解成多个简化的算子。 -* **参数:func_name** (*Optional[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*)[:](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)指定函数的名称。如果未指定,则该过程将在所有函数中运行。 +* **参数:func_name** (*Optional[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):指定函数的名称。如果未指定,则该过程将在所有函数中运行。 * **返回:ret**:注册通行证。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.DecomposeOpsForTraining(*func_name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.DecomposeOpsForTraining(*func_name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 在训练过程中,分解由其他算子组合而成的复合算子。例如,批量归一化的结果(一个三元组)将被简化。注意力机制、tensor_to_shape 等也可以分解成多个简化的算子。 * **参数:** * **func_name** (*Optional[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):指定函数的名称。如果未指定,则该过程将在所有函数中运行。 * **返回:ret**:注册通行证 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) -## tvm.relax.transform.EliminateCommonSubexpr(*call_only=False*) → [FunctionPass](https://tvm.apache.org/docs/reference/api/python/relax/transform.html#tvm.relax.transform.FunctionPass) +## tvm.relax.transform.EliminateCommonSubexpr(*call_only=False*) → [FunctionPass](/docs/api-reference/python-api/tvm-relax-transform#class-tvmrelaxtransformfunctionpass) 消除函数内的公共子表达式。 @@ -219,7 +220,7 @@ Relax 变换。 注意:对于嵌套函数,此过程在这些函数*内执行 CSE。* * **参数:call_only** ([bool](https://docs.python.org/3/library/functions.html#bool)):如果为 True,则启用仅消除呼叫节点。 * **返回:ret**:消除公共子表达式的注册过程。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.relax.transform.ExpandMatmulOfSum() @@ -231,27 +232,27 @@ Relax 变换。 对于优化 LoRA 计算很有用,其中 matmul(x, Base + LoraA*LoraB)可以扩展为 matmul(x, Base) + matmul(x, LoraA*LoraB),从而允许使用 CombineParallelMatmul 进行优化。 -* **返回:ret**[:](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)相应的 pass。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回:ret**:相应的 pass。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.ExpandTupleArguments() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.ExpandTupleArguments() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 将元组参数扩展为内部函数。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.FewShotTuning(*valid_count:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *benchmark:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.FewShotTuning(*valid_count:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *benchmark:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 该通道专为静态形状 PrimFuncs 的少量调优而设计。它会检查 PrimFunc 中的所有块,并根据 MetaSchedule 调度规则进行循环融合、拆分和其他转换,但会直接从搜索空间采样,而不是使用调优算法。用户可以指定要尝试的有效计数数量,以及是否使用运行器进行基准测试。 * **参数:** - * **valid_count** ([int](https://docs.python.org/3/library/functions.html#int))[:](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)要尝试的有效计数的数量。 + * **valid_count** ([int](https://docs.python.org/3/library/functions.html#int)):要尝试的有效计数的数量。 * **benchmark** ([bool](https://docs.python.org/3/library/functions.html#bool)):是否使用 runner 进行基准测试。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.FoldConstant() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.FoldConstant() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 折叠数据流块内的常量表达式。 @@ -259,14 +260,14 @@ Relax 变换。 注意:可能需要先调用 ConvertToDataflow 来提供数据流块。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## *class* tvm.relax.transform.FunctionPass 一个作用于模块中每个 tvm.relax.Function 的 Pass。一个函数 Pass 类应通过 function_pass 创建。 -## tvm.relax.transform.FuseOps(*fuse_opt_level=-1*) → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.FuseOps(*fuse_opt_level=-1*) → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 此过程将绑定分组到 Relax 函数的数据流块中,并根据过程实现中描述的融合算法为每个组生成一个新的 Relax 函数分组。通过将绑定分组到新的 Relax 函数中,我们将被操作函数中的绑定替换为对新分组函数的函数调用。 @@ -277,10 +278,10 @@ Relax 变换。 注意:可能需要先调用 ConvertToDataflow 来提供数据流块。 * **参数:fuse_opt_level** ([int](https://docs.python.org/3/library/functions.html#int)):1 表示将从 pass 上下文中推断级别。 -* **返回:ret**[:](https://tvm.apache.org/docs/reference/api/python/relax/transform.html#tvm.relax.transform.FusionPattern)操作符融合的注册通道。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回:ret**:操作符融合的注册通道。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.FuseOpsByPattern(*patterns:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[FusionPattern](https://tvm.apache.org/docs/reference/api/python/relax/transform.html#tvm.relax.transform.FusionPattern)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*]*, *bind_constants:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *annotate_codegen:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *entry_functions:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.FuseOpsByPattern(*patterns:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[FusionPattern](/docs/api-reference/python-api/tvm-relax-transform#class-tvmrelaxtransformfusionpatternnamestr-pattern-dfpattern-annotation_patternsmappingstr-dfpattern-none-none-checkcallablepatterncheckcontextbool-none-none-attrs_gettercallabledictstrrelaxexprdictstrstr-none-none)*|*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*]*, *bind_constants:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *annotate_codegen:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *entry_functions:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 将模式匹配应用于给定模块中的每个函数,并将匹配的表达式分组为一个新函数。 @@ -291,21 +292,21 @@ Relax 变换。 注意:仅在数据流块内操作。可能需要先调用 ConvertToDataflow 。 * **参数:** - * **patterns** (*List**[****Union**[***[FusionPattern](https://tvm.apache.org/docs/reference/api/python/relax/transform.html#tvm.relax.transform.FusionPattern)***,*** [Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)***]****]*):要匹配的模式列表。模式的顺序决定了匹配的优先级顺序。高优先级模式应出现在列表的前面。除了 FusionPattern 之外,还可以将元组作为此列表的元素传递。模式将通过 `FusionPattern(*item)` 构建。 + * **patterns** (*List**[****Union**[***[FusionPattern](/docs/api-reference/python-api/tvm-relax-transform#class-tvmrelaxtransformfusionpatternnamestr-pattern-dfpattern-annotation_patternsmappingstr-dfpattern-none-none-checkcallablepatterncheckcontextbool-none-none-attrs_gettercallabledictstrrelaxexprdictstrstr-none-none)***,*** [Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)***]****]*):要匹配的模式列表。模式的顺序决定了匹配的优先级顺序。高优先级模式应出现在列表的前面。除了 FusionPattern 之外,还可以将元组作为此列表的元素传递。模式将通过 `FusionPattern(*item)` 构建。 * **bind_constants** ([bool](https://docs.python.org/3/library/functions.html#bool)):是否在分组函数中保留绑定常量。 * **annotate_codegen** ([bool](https://docs.python.org/3/library/functions.html#bool)):如果为 True,将每个创建的复合函数用另一个函数包装,该函数的体仅包含对复合函数的调用,并给外层函数添加“Codegen”和“global_symbol”属性。 “Codegen”属性设置为对应模式名称的前缀。例如,如果模式名称为“dnnl.conv2d_relu”,则设置为“dnnl”。如果创建的复合函数打算在不使用 MergeCompositeFunctions 遍历的情况下卸载到外部后端,则此值必须为 True。 * **entry_functions** (*Optional**[****List**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***]****]*):开始的入口函数集。 * **返回:ret**:基于模式的融合的注册过程。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.FuseTIR() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.FuseTIR() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 如果可能的话,将原始 Relax 函数融合到更大的 TIR 函数中。 * **返回:ret***:*tir 融合的注册通道。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## *class* tvm.relax.transform.FusionPattern(*name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *pattern: DFPattern*, *annotation_patterns:*[Mapping](https://docs.python.org/3/library/typing.html#typing.Mapping)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*, DFPattern] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *check:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*[[*[PatternCheckContext](https://tvm.apache.org/docs/reference/api/python/relax/transform.html#tvm.relax.transform.PatternCheckContext)*],*[bool](https://docs.python.org/3/library/functions.html#bool)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *attrs_getter:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*[[*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*]],*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.relax.transform.FusionPattern(*name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *pattern: DFPattern*, *annotation_patterns:*[Mapping](https://docs.python.org/3/library/typing.html#typing.Mapping)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*, DFPattern] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *check:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*[[*[PatternCheckContext](/docs/api-reference/python-api/tvm-relax-transform#class-tvmrelaxtransformpatterncheckcontext)*],*[bool](https://docs.python.org/3/library/functions.html#bool)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *attrs_getter:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*[[*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*]],*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) FuseOpsByPattern 使用的模式。它主要是 DFPattern,但也包含其他信息以帮助进行融合过程。 @@ -313,9 +314,9 @@ FuseOpsByPattern 使用的模式。它主要是 DFPattern,但也包含其他 * **name** ([str](https://docs.python.org/3/library/stdtypes.html#str))*:*模式名称。通常以后端名称开头,例如“cutlass.matmul”。 * **pattern** (*DFPattern*):用于匹配可由外部后端处理的表达式的数据流模式。 * **annotation_patterns** (*Mapping**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,*** ***DFPattern****]*):用于从模式匹配结果中提取重要表达式的映射。此映射中的所有 DFPattern 都应为模式的一部分。 - * **check** (*Callable**[****[*[PatternCheckContext](https://tvm.apache.org/docs/reference/api/python/relax/transform.html#tvm.relax.transform.PatternCheckContext)*],*[bool](https://docs.python.org/3/library/functions.html#bool)*]*)*:*检查匹配结果是否被接受的函数。 + * **check** (*Callable**[****[*[PatternCheckContext](/docs/api-reference/python-api/tvm-relax-transform#class-tvmrelaxtransformpatterncheckcontext)*],*[bool](https://docs.python.org/3/library/functions.html#bool)*]*)*:*检查匹配结果是否被接受的函数。 -## tvm.relax.transform.Gradient(*func_name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *require_grads:*[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *target_index:*[int](https://docs.python.org/3/library/functions.html#int)*= 0*) → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.Gradient(*func_name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *require_grads:*[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *target_index:*[int](https://docs.python.org/3/library/functions.html#int)*= 0*) → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 逆向模式自动微分。 @@ -348,10 +349,10 @@ def main_adjoint(original_parameters): 此 AD 通道还支持检查点,具体功能请参阅“以亚线性内存成本训练深度网络” - Chen, Tianqi, et al. (2016)。更多详情,请参阅 tvm.relax.testing.nn.checkpoint。 * **参数:** * **func_name** ([str](https://docs.python.org/3/library/stdtypes.html#str)):特定函数的名称。 - * **require_grads** (*Optional**[****Union**[***[relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)***,*** ***List****[*[relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)*]**]****]*):需要伴随函数的松弛变量。必须是给定函数的参数,且不能重复。如果未指定,则计算所有参数的伴随函数。 + * **require_grads** (*Optional**[****Union**[***[relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)***,*** ***List****[*[relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)*]**]****]*):需要伴随函数的松弛变量。必须是给定函数的参数,且不能重复。如果未指定,则计算所有参数的伴随函数。 * **target_index** ([int](https://docs.python.org/3/library/functions.html#int)):如果指定的函数有多个返回值,则指定返回值的索引作为目标。如果未指定,则第一个返回值将作为目标。 * **返回:ret**:通行证。 -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 **示例** @@ -474,27 +475,27 @@ class Module: # 返回值: (orig_return_values, tuple(adjoints)) return ((lv1, lv2), (x_adjoint, y_adjoint)) ``` -## tvm.relax.transform.InlinePrivateFunctions() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.InlinePrivateFunctions() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 内联所有私有放松函数。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.KillAfterLastUse() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.KillAfterLastUse() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 最后一次使用后删除所有张量/存储对象。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.LambdaLift() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.LambdaLift() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 将本地函数提升到全局。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.LazyGetInput() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.LazyGetInput() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 延迟请求输入的通道。 @@ -517,9 +518,9 @@ def after(fget_param: R.Callable([R.Prim('int64'), R.Object], R.Object)): ... ``` * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.LazySetOutput() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.LazySetOutput() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 设置可用函数输出的通道。 @@ -546,9 +547,9 @@ def after(args, fset_param: R.Callable([R.Prim('int64'), R.Object])): return () ``` * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.LegalizeOps(*customize_legalize_map:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*[[*[BlockBuilder](https://tvm.apache.org/docs/reference/api/python/relax/block_builder.html#tvm.relax.block_builder.BlockBuilder)*,*[Call](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Call)*],*[RelaxExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.RelaxExpr)*]] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *enable_warning:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) +## tvm.relax.transform.LegalizeOps(*customize_legalize_map:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*[[*[BlockBuilder](/docs/api-reference/python-api/tvm-relax_block_builder#class-tvmrelaxblock_builderblockbuildermodirmodulenone-none)*,*[Call](/docs/api-reference/python-api/tvm-relax#classtvmrelaxcalloprelaxexpropargslistrelaxexprtuplerelaxexprattrsattrsnonenonesinfo_argsliststructinfotuplestructinfononenonespanspannonenone)*],*[RelaxExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirrelaxexpr)*]] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *enable_warning:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) 将 Relax 函数中的高级操作符调用合法化为 call_tir 和相应的低级 TIR PrimFuncs。 @@ -562,10 +563,10 @@ def after(args, fset_param: R.Callable([R.Prim('int64'), R.Object])): 此 pass 为用户提供可定制性,以便用户为操作符使用自己的合法化函数。该 pass 接受一个可选的自定义 map,其键为操作符名称 ( str ),值是函数 ( LegalizeFunc )。默认的合法化函数将被自定义函数覆盖。 * **参数:** - * **customize_legalize_map** (*Optional**[****Dict**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,*** ***LegalizeFunc****]]*)[:](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)自定义操作符合法化函数映射。自定义函数将覆盖默认函数。 + * **customize_legalize_map** (*Optional**[****Dict**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,*** ***LegalizeFunc****]]*):自定义操作符合法化函数映射。自定义函数将覆盖默认函数。 * **enable_warning** ([bool](https://docs.python.org/3/library/functions.html#bool)):一个布尔值,指示是否针对未注册操作合法化函数的 CallNode 打印警告。默认情况下,我们不打印警告。 * **返回:ret**:注册通行证。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 **示例** @@ -636,7 +637,7 @@ class Module: T.writes(T_multiply[v_ax0, v_ax1]) T_multiply[v_ax0, v_ax1] = A[v_ax0, v_ax1] * B[v_ax0, v_ax1] ``` -## tvm.relax.transform.LiftTransformParams(*shared_transform:*[bool](https://docs.python.org/3/library/functions.html#bool)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*] = False*) → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.LiftTransformParams(*shared_transform:*[bool](https://docs.python.org/3/library/functions.html#bool)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*] = False*) → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 函数参数的提升变换。 @@ -652,9 +653,9 @@ class Module: * True:生成单个参数转换函数,包含所有具有“num_input”属性的函数中共同的预处理步骤。 * List[str]: 将生成一个单一参数转换函数,其中包含每个函数名称在列表中的预处理步骤。传递具有“num_input”属性的所有函数的列表或空列表等同于传递 True。 * **返回:ret**:用于提升参数变换的注册过程。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.LowerAllocTensor() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.LowerAllocTensor() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 降低 R.builtin.alloc_tensor 的剩余实例。 @@ -665,60 +666,60 @@ class Module: 此转换会将所有剩余的 R.builtin.alloc_tensor 实例替换为 R.memory.alloc_storage 和 R.memory.alloc_tensor。如果不存在 R.builtin.alloc_tensor,则此过程无效。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.LowerRuntimeBuiltin() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.LowerRuntimeBuiltin() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 将通用内在函数降低为 VM 内在函数。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.MergeCompositeFunctions() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.MergeCompositeFunctions() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 将 FuseOpsByPattern 创建的一个或多个复合函数组合成一个新函数。新函数将使用“Codegen”和“global_symbol”属性进行注释,并计划将其卸载到外部后端。 * **返回:ret**:合并复合函数的注册过程。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.MetaScheduleApplyDatabase(*work_dir:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *enable_warning:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.MetaScheduleApplyDatabase(*work_dir:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *enable_warning:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 从调整数据库中应用最佳计划。 * **参数:** - * **work_dir** (*Optional[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*)[:](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)如果未提供数据库,则推断默认数据库的工作目录(当用户 pass 数据库时它将被忽略)。 + * **work_dir** (*Optional[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):如果未提供数据库,则推断默认数据库的工作目录(当用户 pass 数据库时它将被忽略)。 * **enable_warning** ([bool](https://docs.python.org/3/library/functions.html#bool))*:* 一个布尔值,指示是否打印数据库中未显示的 TIR 函数的警告。默认情况下,我们不打印警告。 * **返回:ret**:注册通行证。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.MetaScheduleTuneIRMod(*params:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray)*]*, *work_dir:*[str](https://docs.python.org/3/library/stdtypes.html#str), *max_trials_global:*[int](https://docs.python.org/3/library/functions.html#int), *max_trials_per_task:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *op_names:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.MetaScheduleTuneIRMod(*params:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[Tensor]*]*, *work_dir:*[str](https://docs.python.org/3/library/stdtypes.html#str), *max_trials_global:*[int](https://docs.python.org/3/library/functions.html#int), *max_trials_per_task:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *op_names:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Pass](tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 使用 MetaSchedule 调整 Relax IRModule。 * **参数:** - * **params** (*Dict[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray)*]*):模型参数。 + * **params** (*Dict[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*]*):模型参数。 * **work_dir** ([str](https://docs.python.org/3/library/stdtypes.html#str)):工作目录。 - * **max_trials_gloabl** ([int](https://docs.python.org/3/library/functions.html#int))[:](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)允许调整的最大试验次数。 + * **max_trials_gloabl** ([int](https://docs.python.org/3/library/functions.html#int)):允许调整的最大试验次数。 * **max_trials_per_task** ([int](https://docs.python.org/3/library/functions.html#int))*:*每个任务的最大试验次数。 * **op_names** (*Optional**[****List**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***]****]*):用于指定需要调整的操作符的操作符名称列表。当值为 None 时,表示所有操作符均已调整。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.MetaScheduleTuneTIR(*work_dir:*[str](https://docs.python.org/3/library/stdtypes.html#str), *max_trials_global:*[int](https://docs.python.org/3/library/functions.html#int)) → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.MetaScheduleTuneTIR(*work_dir:*[str](https://docs.python.org/3/library/stdtypes.html#str), *max_trials_global:*[int](https://docs.python.org/3/library/functions.html#int)) → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 使用 MetaSchedule 调整 TIR。:param work_dir:工作目录:type work_dir:str:param max_trials_gloabl:允许调整的最大试验次数:type max_trials_gloabl:int。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.Normalize() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.Normalize() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 将 Relax IR 转换为范式,即表达式被规范化(没有嵌套,因此 AST 在 ANF 中),并且表达式的所有 struct_info_都可用。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.NormalizeGlobalVar() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.NormalizeGlobalVar() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 可能重命名 IRModule 中的 GlobalVar 以确保这些属性: @@ -726,7 +727,7 @@ class Module: 1.(不变)首先确保每个公共函数与其“global_symbol”属性同名;2.为确保1.,我们可能需要重命名名称冲突的私有函数;3.最后,每个 GlobalVar 的名称在 IRModule 中都是唯一的。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## *class* tvm.relax.transform.PatternCheckContext @@ -735,18 +736,18 @@ class Module: * **参数:** * **matched_expr** (*Expr*):与 FusionPattern.pattern 匹配的表达式。 * **annotated_expr** (*Mapping**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,*** ***Expr****]*)***:** 包含 FusionPattern.annotation_patterns 中的子模式匹配的所有表达式的映射。 - * **matched_bindings** (*Mapping**[***[relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)***,*** ***Expr****]*):从变量映射到其值。它包含由 FuseOpsByPattern 融合的绑定变量。 - * **var_usages** (*Mapping**[***[relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)***,*** ***Sequence****[*[relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)*]]*)[:](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)将变量定义映射到一组用途的映射。它包含函数中使用的所有变量。 - * **value_to_bound_var** (*Mapping**[****Expr,*[relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)*]*):将值映射到其绑定变量。匹配的表达式后没有变量。 + * **matched_bindings** (*Mapping**[***[relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)***,*** ***Expr****]*):从变量映射到其值。它包含由 FuseOpsByPattern 融合的绑定变量。 + * **var_usages** (*Mapping**[***[relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)***,*** ***Sequence****[*[relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)*]]*):将变量定义映射到一组用途的映射。它包含函数中使用的所有变量。 + * **value_to_bound_var** (*Mapping**[****Expr,*[relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)*]*):将值映射到其绑定变量。匹配的表达式后没有变量。 -## tvm.relax.transform.RealizeVDevice() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.RealizeVDevice() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 传播虚拟设备信息。 -* **返回:ret**[:](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)注册通行证。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回:ret**:注册通行证。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.RemovePurityChecking() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.RemovePurityChecking() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 在模块中的所有纯函数上激活 relax.force_pure,并将所有纯覆盖操作解包为正常版本。 @@ -754,27 +755,27 @@ class Module: 这实际上意味着将不再有纯度跟踪,这对于低级代码生成有用。 * **返回:ret**:通行证。 -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -:::Note +:::note 应在 ToNonDataflow() 之后使用。 ::: -## tvm.relax.transform.RemoveUnusedOutputs() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.RemoveUnusedOutputs() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 从内部函数中删除未使用的输出。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.RemoveUnusedParameters() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.RemoveUnusedParameters() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 删除内部函数未使用的参数。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.relax.transform.ReorderPermuteDimsAfterConcat() @@ -784,7 +785,7 @@ class Module: 用于优化 CombineParallelMatmul 之后的计算。优化后的 nn.Linear 实现的模式会查找 matmul(activations, permute_dims(weights)) 。 CombineParallelMatmul 之后 ,matmul(activations, concat(permute_dims(A), permute_dims(B)))不再符合该模式。将其重新排列为 matmul(activations, permute_dims(concat(A,B)))即可恢复模式匹配。 * **返回:ret**:相应的 pass。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpasss)。 ## tvm.relax.transform.ReorderTakeAfterMatmul() @@ -793,17 +794,17 @@ class Module: 对于优化 LoRA 计算很有用,其中可以将多个 LoRA 批处理在一起。 -* **返回:ret**[:](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)相应的 pass。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +* **返回:ret**:相应的 pass。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) -## tvm.relax.transform.RewriteCUDAGraph() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.RewriteCUDAGraph() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 重写一个 Relax 模块,用于使用 CUDA 计算图执行。此过程识别出可以使用 CUDA 计算图执行的区域,并将其提升到新函数中,以便在运行时捕获计算图。 * **返回:ret**:重写 cuda graph 的注册通道。 -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.RewriteDataflowReshape() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.RewriteDataflowReshape() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 将所有类似 reshape 的 call_tir 转换为虚拟机 reshape 操作符调用。虚拟机 reshape 操作符调用将在运行时进一步简化为 CreateView 操作,而不是执行真正的数据复制。这里的“类似 reshape”包括 reshape、expand_dims、flatten 等。 @@ -811,9 +812,9 @@ class Module: 注意:仅在数据流块中操作。可能需要先调用 ConvertToDataflow 。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.RunCodegen(*target_options:*[dict](https://docs.python.org/3/library/stdtypes.html#dict)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *entry_functions:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.RunCodegen(*target_options:*[dict](https://docs.python.org/3/library/stdtypes.html#dict)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *entry_functions:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 使用带注释的代码生成和全局符号生成运行时::模块。 @@ -821,26 +822,26 @@ class Module: * **target_options** (*Optional[*[dict](https://docs.python.org/3/library/stdtypes.html#dict)*]*):目标名称和编译选项对。 * **entry_functions** (*Optional**[****List**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***]****]*):开始的入口函数集。 * **返回:ret**:用于删除未使用函数的注册过程。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.SplitCallTIRByPattern(*patterns:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)*]*, *fcodegen:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)) → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.SplitCallTIRByPattern(*patterns:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)*]*, *fcodegen:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)) → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 将 PrimFunc 拆分为两部分:第一部分是 TIR PrimFunc,它是与某个模式匹配,第二部分是原始 PrimFunc 的其余部分。它将调用 fcodegen 生成匹配模式的代码,并将其替换为 ExternFunc 调用。 * **参数:** - * **patterns** (*List[*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)*]*):要匹配的模式列表。 + * **patterns** (*List[*[PrimFunc](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)*]*):要匹配的模式列表。 * **fcodegen** (*Callable*[****[**List****[**MatchResult****]**],List**[****Object**]****]*):用于生成匹配模式的代码的函数。 * **返回:ret**:用于拆分 call_tir 的注册通道。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.SplitLayoutRewritePreproc() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.SplitLayoutRewritePreproc() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 将 TIR 布局重写拆分为多个 TIR 函数。此过程用于 meta_schedule 调整后的预打包权重。 * **返回:ret**:用于分割 TIR 布局重写的注册过程。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) -## tvm.relax.transform.StaticPlanBlockMemory() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.StaticPlanBlockMemory() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 静态内存规划在 BindingBlock 级别进行。该过程将尽力重用已分配的内存,以减少已分配内存的总量。 @@ -851,9 +852,9 @@ class Module: 例如,我们可以用 来注释一个 Relax 函数 。这意味着函数签名中名为“n”的变量的最大值将有上界 1024。在内存规划时,我们将使用 1024 作为它的值。`R.func_attr({"tir_var_upper_bound": {"n": 1024}})` * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.ToMixedPrecision(*out_dtype='float32'*, *fp16*input_names: [List](https://docs.python.org/3/library/typing.html#typing.List)[[str](https://docs.python.org/3/library/stdtypes.html#str)] | [None](https://docs.python.org/3/library/constants.html#None) = None*) → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.ToMixedPrecision(*out_dtype='float32'*, *fp16*input_names: [List](https://docs.python.org/3/library/typing.html#typing.List)[[str](https://docs.python.org/3/library/stdtypes.html#str)] | [None](https://docs.python.org/3/library/constants.html#None) = None*) → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 自动混合精度通道。目前,该通道假设输入模块仅为 fp32,并会自动将某些操作的 fp32 转换为 fp16。 @@ -863,63 +864,63 @@ class Module: * **参数:** * **out_dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):gemm/conv 的输出数据类型,即累加器的数据类型。 * **fp16*input_names****(*List[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):函数参数的名称,其数据类型应为 fp16。函数签名将相应更改。 -* **返回:ret**[:](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)混合精度的注册通道。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回:ret**:混合精度的注册通道。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.ToNonDataflow() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.ToNonDataflow() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 将所有数据流结构转换为非数据流版本。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.TopologicalSort(*order='depth-first'*, *direction='from-inputs'*) → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.TopologicalSort(*order='depth-first'*, *direction='from-inputs'*) → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 按指定顺序对 Relax.Dataflow 块中的绑定进行排序。 * **参数:** * **order** ([str](https://docs.python.org/3/library/stdtypes.html#str)):绑定的发出顺序。允许的值为“深度优先”和“广度优先”。 - * **direciton** ([str](https://docs.python.org/3/library/stdtypes.html#str))[:](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)outputs”。 + * **direciton** ([str](https://docs.python.org/3/library/stdtypes.html#str)):排序应该执行的方向。允许的值是“from-input”和“from-outputs”。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.UpdateParamStructInfo(*sinfo_func:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*[[*[Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)*],*[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)*|*[None](https://docs.python.org/3/library/constants.html#None)*]*) +## tvm.relax.transform.UpdateParamStructInfo(*sinfo_func:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*[[*[Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)*],*[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)*|*[None](https://docs.python.org/3/library/constants.html#None)*]*) 更新参数的结构信息。 更新参数的结构体信息。内部绑定和函数返回类型将使用 Relax 的结构体推断规则进行更新。结构体推断产生的错误将传递给用户。 -* **参数:sinfo_func** (*Callable**[****[*[relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)*]**,*** ***Optional****[*[StructInfo](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.StructInfo)*]]*):一个函数,它会为每个函数参数调用一次,并返回更新后的结构体信息。如果函数返回 None,则表示参数未被修改。 +* **参数:sinfo_func** (*Callable**[****[*[relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)*]**,*** ***Optional****[*[StructInfo](/docs/api-reference/python-api/tvm-relax#classtvmrelaxstructinfo)*]]*):一个函数,它会为每个函数参数调用一次,并返回更新后的结构体信息。如果函数返回 None,则表示参数未被修改。 * **返回:ret**:相应的 pass。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.UpdateVDevice(*new_vdevice:*[VDevice](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.VDevice), *index:*[int](https://docs.python.org/3/library/functions.html#int)) → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.UpdateVDevice(*new_vdevice:*[VDevice](/docs/api-reference/python-api/tvm-ir#class-tvmirvdevicetargetnone-vdevice_idint-0-memory_scopestr-global), *index:*[int](https://docs.python.org/3/library/functions.html#int)) → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 更新虚拟设备。 * **参数:** - * **new_vdevice** ([tvm.ir.VDevice](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.VDevice)):新的虚拟设备。 + * **new_vdevice** ([tvm.ir.VDevice](/docs/api-reference/python-api/tvm-ir#class-tvmirvdevicetargetnone-vdevice_idint-0-memory_scopestr-global)):新的虚拟设备。 * **index** ([int](https://docs.python.org/3/library/functions.html#int)):设备索引指示将执行更新的设备。 * **返回:ret**:修改虚拟设备的注册通行证。 -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.VMBuiltinLower() → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.VMBuiltinLower() → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpasss) 将通用内在函数降低为 VM 内在函数。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.VMShapeLower(***, *emit_err_ctx: [bool](https://docs.python.org/3/library/functions.html#bool) = True*) → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.relax.transform.VMShapeLower(***, *emit_err_ctx: [bool](https://docs.python.org/3/library/functions.html#bool) = True*) → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 降低符号形状和参数并匹配结构信息匹配。 -* **参数:emit_err_ctx** (*Optional[*[bool](https://docs.python.org/3/library/functions.html#bool)*]*)[:](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)是否发出错误上下文字符串,可出于测试目的关闭。 +* **参数:emit_err_ctx** (*Optional[*[bool](https://docs.python.org/3/library/functions.html#bool)*]*):是否发出错误上下文字符串,可出于测试目的关闭。 * **返回:ret。** -* **返回类型:**[tvm.ir.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.ir.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.relax.transform.dataflowblock_pass(*pass_func=None*, *opt_level=None*, *name=None*, *required=None*, *traceable=False*) → [Callable](https://docs.python.org/3/library/typing.html#typing.Callable) | [DataflowBlockPass](https://tvm.apache.org/docs/reference/api/python/relax/transform.html#tvm.relax.transform.DataflowBlockPass) +## tvm.relax.transform.dataflowblock_pass(*pass_func=None*, *opt_level=None*, *name=None*, *required=None*, *traceable=False*) → [Callable](https://docs.python.org/3/library/typing.html#typing.Callable) | [DataflowBlockPass](/docs/api-reference/python-api/tvm-relax-transform#class-tvmrelaxtransformdataflowblockpass) 装饰数据流块传递。 @@ -927,13 +928,13 @@ class Module: 当提供 pass_func 时,此函数返回回调。否则,它返回使用给定优化函数创建的数据流块 pass。 * **参数:** - * **pass_func** (*Optional**[****Callable**[****(*[DataflowBlock](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.DataflowBlock)*,Module,*[PassContext](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.PassContext)***)*** ***-> DataflowBlock****]]*):转换函数或类。 + * **pass_func** (*Optional**[****Callable**[****(*[DataflowBlock](/docs/api-reference/python-api/tvm-relax#classtvmrelaxdataflowblockbindingslistbindingspanspannonenone)*,Module,*[PassContext](/docs/api-reference/python-api/tvm-transform#classtvmtransformpasscontextopt_level2required_passnonedisabled_passnoneinstrumentsnoneconfignone)***)*** ***-> DataflowBlock****]]*):转换函数或类。 * **opt_level** ([int](https://docs.python.org/3/library/functions.html#int)):此数据流块 pass 的优化级别。 * **name** (*Optional[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*)**:** 数据流块 pass 的名称。名称可以为空。在这种情况下,优化函数的名称将用作 pass 名称。 * **required** (*Optional**[****List**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***]****]*):数据流块 pass 所依赖的 pass 列表。 * **traceable** (*Boolean*):布尔变量,表示数据流块 pass 是否可追踪。 * **返回:create_dataflowblock_pass**:如果未提供 pass_func,则返回一个装饰器;否则返回装饰后的结果。返回的装饰器根据输入有两种行为:装饰 pass 函数时,将返回一个新的 DataflowBlockPass。装饰类类型时,将返回一个新的 DataflowBlockPass 类。 -* **返回类型:** Union[Callable, [DataflowBlockPass](https://tvm.apache.org/docs/reference/api/python/relax/transform.html#tvm.relax.transform.DataflowBlockPass)]。 +* **返回类型:** Union[Callable, [DataflowBlockPass](/docs/api-reference/python-api/tvm-relax-transform#class-tvmrelaxtransformdataflowblockpass)]。 **示例** @@ -995,20 +996,20 @@ updated_mod = block_pass(m) # 现在 transform 应该已经应用到提供的模块 m 中的每个 DataflowBlock # 并且更新后的模块将被返回 ``` -## tvm.relax.transform.function_pass(*pass_func=None*, *opt_level=None*, *name=None*, *required=None*, *traceable=False*) → [Callable](https://docs.python.org/3/library/typing.html#typing.Callable) | [FunctionPass](https://tvm.apache.org/docs/reference/api/python/relax/transform.html#tvm.relax.transform.FunctionPass) +## tvm.relax.transform.function_pass(*pass_func=None*, *opt_level=None*, *name=None*, *required=None*, *traceable=False*) → [Callable](https://docs.python.org/3/library/typing.html#typing.Callable) | [FunctionPass](/docs/api-reference/python-api/tvm-relax-transform#class-tvmrelaxtransformfunctionpass) 装饰一个函数 pass。 当提供 pass_func 时,此函数返回一个回调。否则,它返回使用给定优化函数创建的函数传递。 * **参数:** - * **pass_func** (*Optional**[****Callable**[****(*[Function](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Function)*,Module**,*** [PassContext](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.PassContext)***)*** ***-> Function****]]*):转换函数或类。 + * **pass_func** (*Optional**[****Callable**[****(*[Function](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfunctionparamslistvarbodyrelaxexprret_struct_infostructinfononenoneis_pureboolnonetrueattrsdictattrsnonenonespanspannonenone)*,Module**,*** [PassContext](h/docs/api-reference/python-api/tvm-transform#classtvmtransformpasscontextopt_level2required_passnonedisabled_passnoneinstrumentsnoneconfignone)***)*** ***-> Function****]]*):转换函数或类。 * **opt_level** ([int](https://docs.python.org/3/library/functions.html#int)):此函数 pass 的优化级别。 * **name** (*Optional[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*)*:* 函数 pass 的名称。名称可以为空。在这种情况下,优化函数的名称将用作 pass 名称。 * **required** (*Optional**[****List**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***]****]*)**:** 函数 pass 所依赖的 pass 列表。 * **traceable** (*Boolean*):布尔变量,表示函数 pass 是否可追踪。 * **返回:create_function_pass**:如果未提供 pass_func,则返回一个装饰器;否则返回装饰后的结果。返回的装饰器根据输入有两种行为:装饰一个 pass 函数时,将返回一个新的 FunctionPass。装饰一个类类型时,将返回一个新的 FunctionPass 类。 -* **返回类型:** Union[Callable, [FunctionPass](https://tvm.apache.org/docs/reference/api/python/relax/transform.html#tvm.relax.transform.FunctionPass)]。 +* **返回类型:** Union[Callable, [FunctionPass](/docs/api-reference/python-api/tvm-relax-transform#class-tvmrelaxtransformfunctionpass)]。 **示例** @@ -1091,8 +1092,8 @@ updated_mod = function_pass(m) * **参数:** * **fget_item** ([str](https://docs.python.org/3/library/stdtypes.html#str))*:* get_item 函数的名称。 * **fset_item** ([str](https://docs.python.org/3/library/stdtypes.html#str)):set_item 函数的名称。 - * **extra_get_item_params** ([list](https://docs.python.org/3/library/stdtypes.html#list)*of*[relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var))*:*get_item 函数除 index 之外的参数。[给定](https://docs.python.org/3/library/stdtypes.html#list)*(在 Python v3.13 中)的参数将放在 index 之前。例如,如果 extra_get_item_params 为 [param1, param2],则 pass 将生成 call_packed(fget_item, [param1, param2, index])。 - * **extra_set_item_params** ([list](https://docs.python.org/3/library/stdtypes.html#list)*of*[relax.Var](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Var)):set_item 函数除 index 和 value 之外的参数。给定的参数将放置在 index 和 value 之前。例如,如果 extra_set_item_params 为 [param1, param2],则 pass 将生成 call_packed(fset_item, [param1, param2, index, value])。 + * **extra_get_item_params** ([list](https://docs.python.org/3/library/stdtypes.html#list)*of*[relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone))*:*get_item 函数除 index 之外的参数。[给定](https://docs.python.org/3/library/stdtypes.html#list)*(在 Python v3.13 中)的参数将放在 index 之前。例如,如果 extra_get_item_params 为 [param1, param2],则 pass 将生成 call_packed(fget_item, [param1, param2, index])。 + * **extra_set_item_params** ([list](https://docs.python.org/3/library/stdtypes.html#list)*of*[relax.Var](/docs/api-reference/python-api/tvm-relax#classtvmrelaxvarname_hintstridstruct_infostructinfononenonespanspannonenone)):set_item 函数除 index 和 value 之外的参数。给定的参数将放置在 index 和 value 之前。例如,如果 extra_set_item_params 为 [param1, param2],则 pass 将生成 call_packed(fset_item, [param1, param2, index, value])。 ## *class* tvm.relax.transform.LowerGPUIPCAllocStorage(args*, ***kwargs*) diff --git a/docs/04-api-reference/01-python-api/17-tvm-tir.md b/docs/04-api-reference/01-python-api/17-tvm-tir.md index b3445b2..5ce14a1 100644 --- a/docs/04-api-reference/01-python-api/17-tvm-tir.md +++ b/docs/04-api-reference/01-python-api/17-tvm-tir.md @@ -63,9 +63,9 @@ buffer.access_ptr("r", extent = 100) 生成一个从开始索引加载 dtype 的 Expr。 * **参数:** - * **begin** ([Array](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Array)*ofExpr*):Buffer.dtype 单位的起始索引。 + * **begin** ([Array](/docs/api-reference/python-api/tvm-ir#class-tvmirarrayinput_listsequenceany)*ofExpr*):Buffer.dtype 单位的起始索引。 * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):要加载的数据类型,可以是具有多个 Buffer.dtype 的通道的矢量类型。 - * **predicate** (*Optional[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*):一个布尔值向量掩码,指示要加载向量的哪些通道。掩码中的通道数必须等于正在加载的通道数。 + * **predicate** (*Optional[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*):一个布尔值向量掩码,指示要加载向量的哪些通道。掩码中的通道数必须等于正在加载的通道数。 * **返回:load**:相应的负载表达式。 * **返回类型:** Expr。 @@ -74,11 +74,11 @@ buffer.access_ptr("r", extent = 100) 生成一个将值存储到开始索引的 Stmt。 * **参数:** - * **begin** ([Array](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Array)*ofExpr*):Buffer.dtype 单位的起始索引。 + * **begin** ([Array](/docs/api-reference/python-api/tvm-ir#class-tvmirarrayinput_listsequenceany)*ofExpr*):Buffer.dtype 单位的起始索引。 * **value** (*Expr*)**:** 要存储的值。 - * **predicate** (*Optional[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*):一个布尔值的矢量掩码,指示要存储矢量的哪些通道。掩码中的通道数必须等于值中的通道数。 + * **predicate** (*Optional[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*):一个布尔值的矢量掩码,指示要存储矢量的哪些通道。掩码中的通道数必须等于值中的通道数。 * **返回:store**:相应的存储语句。 -* **返回类型:**[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)。 +* **返回类型:**[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)。 ### @@ -94,15 +94,15 @@ buffer.access_ptr("r", extent = 100) 生成一个该缓冲区的扁平化版本的 Buffer。 * **返回:flattened**:相应的平面缓冲区。 -* **返回类型:**[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)。 +* **返回类型:**[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)。 ### offset_of(*indices*) 确定扁平缓冲区中提供的索引的偏移量。 -* **参数:indices** (*Union**[***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)***,*** ***List****[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]]*)**:** 原始缓冲区中元素的索引。 -* **返回:flattened_indices**[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)扁平缓冲区中元素的偏移索引。 -* **返回类型:** List[[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)]。 +* **参数:indices** (*Union**[***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)***,*** ***List****[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]]*)**:** 原始缓冲区中元素的索引。 +* **返回:flattened_indices** - 扁平缓冲区中元素的偏移索引。 +* **返回类型:** List[[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)]。 ## tvm.tir.decl_buffer(*shape*, *dtype=None*, *name='buffer'*, *data=None*, *strides=None*, *elem_offset=None*, *scope=''*, *data_alignment=-1*, *offset_factor=0*, *buffer_type=''*, *axis_separators=None*, *span=None*) @@ -118,17 +118,17 @@ buffer.access_ptr("r", extent = 100) * **shape** ([tuple](https://docs.python.org/3/library/stdtypes.html#tuple)*ofExpr*):缓冲区的形状。 * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)*,optional*):缓冲区的数据类型。 * **name** ([str](https://docs.python.org/3/library/stdtypes.html#str)*,optional*):缓冲区的名称。 - * **data** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)*,optional*):缓冲区中的数据指针。 + * **data** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)*,optional*):缓冲区中的数据指针。 * **strides** (*arrayofExpr*):缓冲区*的步幅。 * **elem_offset** (*Expr,optional*)*:* 数组到数据的起始偏移量。以 dtype 元素的数量表示。 * **scope** ([str](https://docs.python.org/3/library/stdtypes.html#str)*,optional*)**:** 缓冲区的存储范围(如果不是全局的)。如果 scope 等于空字符串,则表示它是全局内存。 * **data_alignment** ([int](https://docs.python.org/3/library/functions.html#int)*,optional*):1,则对齐方式将设置为 TVM 的内部默认值。 * **offset_factor** ([int](https://docs.python.org/3/library/functions.html#int)*,optional*):elem_offset 字段的因子。设置后,elem_offset 必须是 offset_factor 的倍数。如果传入 0,则对齐方式将设置为 1。如果传入非零值,且 elem_offset 不为 None,我们将为 elem_offset 创建一个 tir.Var。 * **buffer_type** ([str](https://docs.python.org/3/library/stdtypes.html#str)*,optional**,*** ***{""****,"auto_broadcast"}*):> buffer[i][0][k]。 - * **axis_separators** ([list](https://docs.python.org/3/library/stdtypes.html#list)*of*[int](https://docs.python.org/3/library/functions.html#int)*,optional*):如果传递,[则为](https://docs.python.org/3/library/functions.html#int)轴组之间的分隔符列表,每个轴都会展平为一个输出轴。对于平坦的内存空间,应为 None 或空列表。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):decl_buffer 在源中创建的位置。 + * **axis_separators** ([list](https://docs.python.org/3/library/stdtypes.html#list)*of*[int](https://docs.python.org/3/library/functions.html#int)*,optional*):如果传递,则为轴组之间的分隔符列表,每个轴都会展平为一个输出轴。对于平坦的内存空间,应为 None 或空列表。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):decl_buffer 在源中创建的位置。 * **返回:buffer**:创建的缓冲区。 -* **返回类型:**[tvm.tir.Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)。 +* **返回类型:**[tvm.tir.Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)。 :::note @@ -176,10 +176,10 @@ buffer.access_ptr("r", extent = 100) 两种布局(源布局和目标布局)的双射映射。它提供彼此之间的形状和索引转换。 -不要直接构造,而是使用 [bijective_layout](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.bijective_layout)。有关更多详细信息,请参阅文档 [bijective_layout](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.bijective_layout)。 +不要直接构造,而是使用 [bijective_layout](/docs/api-reference/python-api/tvm-tir#tvmtirbijective_layoutsrc_layoutstrlayout-dst_layoutstrlayout--bijectivelayout)。有关更多详细信息,请参阅文档 [bijective_layout](/docs/api-reference/python-api/tvm-tir#tvmtirbijective_layoutsrc_layoutstrlayout-dst_layoutstrlayout--bijectivelayout)。 * **参数:** - * **src_layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)*or*[Layout](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Layout)):源布局。 - * **dst_layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)*or*[Layout](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Layout)):目标布局。 + * **src_layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)*or*[Layout](/docs/api-reference/python-api/tvm-tir#tvmtirlayoutlayout_strstr-dtypestr-int32--layout)):源布局。 + * **dst_layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)*or*[Layout](/docs/api-reference/python-api/tvm-tir#tvmtirlayoutlayout_strstr-dtypestr-int32--layout)):目标布局。 :::info 另见 @@ -195,45 +195,45 @@ buffer.access_ptr("r", extent = 100) 给定 src-layout 的索引,推断 dst 索引。 -* **参数:index** ([Array](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Array)*ofExpr*):src 布局中的索引。 +* **参数:index** ([Array](/docs/api-reference/python-api/tvm-ir#class-tvmirarrayinput_listsequenceany)*ofExpr*):src 布局中的索引。 * **返回:dst_index**:layout 中推断的索引。 -* **返回类型:**[Array](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Array) of Expr。 +* **返回类型:**[Array](/docs/api-reference/python-api/tvm-ir#class-tvmirarrayinput_listsequenceany) of Expr。 ### backward_index(*index*) 给定 dst-layout 的索引,推断 src 索引。 -* **参数:index** ([Array](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Array)*ofExpr*):layout 中的索引。 +* **参数:index** ([Array](/docs/api-reference/python-api/tvm-ir#class-tvmirarrayinput_listsequenceany)*ofExpr*):layout 中的索引。 * **返回:src_index:** layout 中推断的索引。 -* **返回类型:**[Array](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Array) of Expr。 +* **返回类型:**[Array](/docs/api-reference/python-api/tvm-ir#class-tvmirarrayinput_listsequenceany) of Expr。 ### forward_shape(*shape*) 给定 src-layout 的形状,推断 dst 的形状。 -* **参数:shape** ([Array](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Array)*ofExpr*):layout 中的形状。 +* **参数:shape** ([Array](/docs/api-reference/python-api/tvm-ir#class-tvmirarrayinput_listsequenceany)*ofExpr*):layout 中的形状。 * **返回:dst_shape**:layout 中推断的形状。 -* **返回类型:**[Array](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Array) of Expr。 +* **返回类型:**[Array](/docs/api-reference/python-api/tvm-ir#class-tvmirarrayinput_listsequenceany) of Expr。 ### backward_shape(*shape*) 给定 dst-layout 的形状,推断 src 的形状。 -* **参数:shape** ([Array](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Array)*ofExpr*)*:*layout 中的形状。 -* **返回:src_shape**[:](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Layout)layout 中推断的形状。 -* **返回类型:**[Array](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Array) of Expr。 +* **参数:shape** ([Array](/docs/api-reference/python-api/tvm-ir#class-tvmirarrayinput_listsequenceany)*ofExpr*)*:*layout 中的形状。 +* **返回:src_shape**:中推断的形状。 +* **返回类型:**[Array](/docs/api-reference/python-api/tvm-ir#class-tvmirarrayinput_listsequenceany) of Expr。 -## tvm.tir.bijective_layout(*src_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Layout](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Layout), *dst_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Layout](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Layout)) → [BijectiveLayout](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BijectiveLayout) +## tvm.tir.bijective_layout(*src_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Layout](/docs/api-reference/python-api/tvm-tir#tvmtirlayoutlayout_strstr-dtypestr-int32--layout), *dst_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Layout](/docs/api-reference/python-api/tvm-tir#tvmtirlayoutlayout_strstr-dtypestr-int32--layout)) → [BijectiveLayout](/docs/api-reference/python-api/tvm-tir#class-tvmtirbijectivelayout) 创建双射布局映射。 * **参数:** - * **src_layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)*or*[Layout](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Layout)):源布局。 - * **dst_layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)*or*[Layout](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Layout)):目标布局。 + * **src_layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)*or*[Layout](/docs/api-reference/python-api/tvm-tir#tvmtirlayoutlayout_strstr-dtypestr-int32--layout)):源布局。 + * **dst_layout** ([str](https://docs.python.org/3/library/stdtypes.html#str)*or*[Layout](/docs/api-reference/python-api/tvm-tir#tvmtirlayoutlayout_strstr-dtypestr-int32--layout)):目标布局。 * **返回:bijective_layout:** 创建的双射布局。 -* **返回类型:**[BijectiveLayout](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BijectiveLayout)。 +* **返回类型:**[BijectiveLayout](/docs/api-reference/python-api/tvm-tir#class-tvmtirbijectivelayout)。 -## tvm.tir.layout(*layout_str:*[str](https://docs.python.org/3/library/stdtypes.html#str), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'int32'*) → [Layout](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Layout) +## tvm.tir.layout(*layout_str:*[str](https://docs.python.org/3/library/stdtypes.html#str), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'int32'*) → [Layout](/docs/api-reference/python-api/tvm-tir#tvmtirlayoutlayout_strstr-dtypestr-int32--layout) 从字符串创建布局节点。 @@ -241,18 +241,18 @@ buffer.access_ptr("r", extent = 100) * **layout_str** ([str](https://docs.python.org/3/library/stdtypes.html#str)):布局表示由大写字母、小写字母和数字组成,其中大写字母表示主轴,对应的小写字母及其因子大小表示从轴。例如,NCHW16c 可以描述一个 5 维张量,其参数为 [batch_size, channel, height, width, channel_block]。其中,从轴 channel_block=16 表示主轴 C(通道)的因子大小。 * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str))*:* 返回布局中生成的轴变量的数据类型。必须为整数类型。 * **返回:layout**:创建的布局。 -* **返回类型:**[Layout](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Layout)。 +* **返回类型:**[Layout](/docs/api-reference/python-api/tvm-tir#tvmtirlayoutlayout_strstr-dtypestr-int32--layout)。 -## *class* tvm.tir.Var(*name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Type](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Type), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*)】 +## *class* tvm.tir.Var(*name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Type](/docs/api-reference/python-api/tvm-ir#class-tvmirtype), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*)】 符号变量。 * **参数:** - * **name** ([str](https://docs.python.org/3/library/stdtypes.html#str))[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Type)名称。 - * **dtype** (*Union[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[ir.Type](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Type)*]*):数据类型。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此表达式在源代码中的位置。 + * **name** ([str](https://docs.python.org/3/library/stdtypes.html#str)) - 名称。 + * **dtype** (*Union[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[ir.Type](/docs/api-reference/python-api/tvm-ir#class-tvmirtype)*]*):数据类型。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 -## *class* tvm.tir.SizeVar(*name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Type](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Type), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.SizeVar(*name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Type](/docs/api-reference/python-api/tvm-ir#class-tvmirtype), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) 表示张量索引大小的符号变量。 @@ -260,304 +260,304 @@ buffer.access_ptr("r", extent = 100) 大于或等于零。 * **参数:** - * **name** ([str](https://docs.python.org/3/library/stdtypes.html#str))[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)名称。 - * **dtype** (*Union[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[ir.Type](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Type)*]*)*:* 数据类型。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)*:* 此表达式在源代码中的位置。 + * **name** ([str](https://docs.python.org/3/library/stdtypes.html#str)):名称。 + * **dtype** (*Union[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[ir.Type](/docs/api-reference/python-api/tvm-ir#class-tvmirtype)*]*)*:* 数据类型。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)*:* 此表达式在源代码中的位置。 -## *class* tvm.tir.Reduce(*combiner:*[CommReducer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.CommReducer), *src:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*, *rdom:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[IterVar](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IterVar)*]*, *condition:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *value_index:*[int](https://docs.python.org/3/library/functions.html#int), *init:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.Reduce(*combiner:*[CommReducer](/docs/api-reference/python-api/tvm-tir#class-tvmtircommreducerlhslistvar-rhslistvar-resultlistprimexpr-identity_elementlistprimexpr-spanspannone-none), *src:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*, *rdom:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[IterVar](range-varvarstr-iter_typeint-thread_tagstr--spanspannone-none)*]*, *condition:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *value_index:*[int](https://docs.python.org/3/library/functions.html#int), *init:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) 归约节点。 * **参数:** - * **combiner** ([CommReducer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.CommReducer)):合并器。 + * **combiner** ([CommReducer](/docs/api-reference/python-api/tvm-tir#class-tvmtircommreducerlhslistvar-rhslistvar-resultlistprimexpr-identity_elementlistprimexpr-spanspannone-none)):合并器。 * **src** ([list](https://docs.python.org/3/library/stdtypes.html#list)*ofExpr*)**:** 源表达式。 - * **rdom** ([list](https://docs.python.org/3/library/stdtypes.html#list)*of*[IterVar](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IterVar))*:](*[https://docs.python.org/3/library/stdtypes.html#list](https://docs.python.org/3/library/stdtypes.html#list)*"(在 Python v3.13 中)")-*[迭代](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IterVar)域。 - * **condition** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):归约条件。 + * **rdom** ([list](https://docs.python.org/3/library/stdtypes.html#list)*of*[IterVar](range-varvarstr-iter_typeint-thread_tagstr--spanspannone-none))*:](*[https://docs.python.org/3/library/stdtypes.html#list](https://docs.python.org/3/library/stdtypes.html#list)*"(在 Python v3.13 中)")-*[迭代](range-varvarstr-iter_typeint-thread_tagstr--spanspannone-none)域。 + * **condition** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):归约条件。 * **value_index** ([int](https://docs.python.org/3/library/functions.html#int))*:* 值索引。 * **init** ([list](https://docs.python.org/3/library/stdtypes.html#list)*ofExpr*):输出的初始值。可以是 int、float 或 ProducerLoad 。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)此表达式在源代码中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 -## *class* tvm.tir.FloatImm(*dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str), *value:*[float](https://docs.python.org/3/library/functions.html#float), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.FloatImm(*dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str), *value:*[float](https://docs.python.org/3/library/functions.html#float), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) 浮点常数。 * **参数:** * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):数据类型。 * **value** ([float](https://docs.python.org/3/library/functions.html#float)):常量值。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此表达式在源代码中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 -## *class* tvm.tir.IntImm(*dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str), *value:*[int](https://docs.python.org/3/library/functions.html#int), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.IntImm(*dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str), *value:*[int](https://docs.python.org/3/library/functions.html#int), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) 整数常量。 * **参数:** * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str))*:* 数据类型。 * **value** ([int](https://docs.python.org/3/library/functions.html#int)):常量值。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此表达式在源代码中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 -## *class* tvm.tir.StringImm(*value:*[str](https://docs.python.org/3/library/stdtypes.html#str), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.StringImm(*value:*[str](https://docs.python.org/3/library/stdtypes.html#str), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) 字符串常量。 * **参数:** * **value** ([str](https://docs.python.org/3/library/stdtypes.html#str))*:* 函数的值。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此表达式在源代码中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 -## *class* tvm.tir.Cast(*dtype*, *value*, *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.Cast(*dtype*, *value*, *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) 转换表达式。 * **参数:** * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):数据类型。 - * **value** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)函数的值。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此表达式在源代码中的位置。 + * **value** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):函数的值。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 -## *class* tvm.tir.Add(*a:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *b:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.Add(*a:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *b:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) Add 节点。 * **参数:** - * **a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):左边的操作数。 - * **b** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):右侧操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)*:* 此表达式在源代码中的位置。 + * **a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):左边的操作数。 + * **b** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):右侧操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)*:* 此表达式在源代码中的位置。 -## *class* tvm.tir.Sub(*a:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *b:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.Sub(*a:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *b:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) Sub 节点。 * **参数:** - * **a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):左边的操作数。 - * **b** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):右侧操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此表达式在源代码中的位置。 + * **a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):左边的操作数。 + * **b** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):右侧操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 -## *class* tvm.tir.Mul(*a:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *b:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.Mul(*a:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *b:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) Mul 节点。 * **参数:** - * **a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))*:* 左边的操作数。 - * **b** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))*:* 右侧操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)此表达式在源代码中的位置。 + * **a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))*:* 左边的操作数。 + * **b** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))*:* 右侧操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 -## *class* tvm.tir.Div(*a:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *b:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.Div(*a:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *b:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) Div 节点。 * **参数:** - * **a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):左边的操作数。 - * **b** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):右侧操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此表达式在源代码中的位置。 + * **a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):左边的操作数。 + * **b** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):右侧操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 -## *class* tvm.tir.Mod(*a:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *b:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.Mod(*a:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *b:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) Mod 节点。 * **参数:** - * **a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):左边的操作数。 - * **b** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):右侧操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)此表达式在源代码中的位置。 + * **a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):左边的操作数。 + * **b** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):右侧操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 -## *class* tvm.tir.FloorDiv(*a:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *b:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.FloorDiv(*a:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *b:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) FloorDiv 节点。 * **参数:** - * **a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):左边的操作数。 - * **b** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):右侧操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)*:* 此表达式在源代码中的位置。 + * **a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):左边的操作数。 + * **b** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):右侧操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)*:* 此表达式在源代码中的位置。 -## *class* tvm.tir.FloorMod(*a:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *b:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.FloorMod(*a:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *b:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) FloorMod 节点。 * **参数:** - * **a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):左边的操作数。 - * **b** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):右侧操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此表达式在源代码中的位置。 + * **a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):左边的操作数。 + * **b** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):右侧操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 -## *class* tvm.tir.Min(*a:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *b:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.Min(*a:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *b:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) Min 节点。 * **参数:** - * **a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)左边的操作数。 - * **b** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))*:*右侧操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此表达式在源代码中的位置。 + * **a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):左边的操作数。 + * **b** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))*:*右侧操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 -## *class* tvm.tir.Max(*a:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *b:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.Max(*a:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *b:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) Max 节点。 * **参数:** - * **a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):左边的操作数。 - * **b** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))[:](https://docs.python.org/3/library/constants.html#None)右侧操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)此表达式在源代码中的位置。 + * **a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):左边的操作数。 + * **b** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):右侧操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 -## *class* tvm.tir.EQ(*a:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *b:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.EQ(*a:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *b:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) EQ 节点。 * **参数:** - * **a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):左边的操作数。 - * **b** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):右侧操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此表达式在源代码中的位置。 + * **a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):左边的操作数。 + * **b** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):右侧操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 -## *class* tvm.tir.NE(*a:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *b:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.NE(*a:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *b:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) NE 节点。 * **参数:** - * **a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))*:* 左边的操作数。 - * **b** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):右侧操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此表达式在源代码中的位置。 + * **a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))*:* 左边的操作数。 + * **b** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):右侧操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 -## *class* tvm.tir.LT(*a:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *b:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.LT(*a:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *b:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) LT 节点。 * **参数:** - * **a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))[:](https://docs.python.org/3/library/constants.html#None)左边的操作数。 - * **b** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):右侧操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此表达式在源代码中的位置。 + * **a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):左边的操作数。 + * **b** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):右侧操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 -## *class* tvm.tir.LE(*a:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *b:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.LE(*a:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *b:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) LE 节点。 * **参数:** - * **a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):左边的操作数。 - * **b** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):右侧操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此表达式在源代码中的位置。 + * **a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):左边的操作数。 + * **b** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):右侧操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 -## *class* tvm.tir.GT(*a:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *b:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.GT(*a:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *b:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) GT 节点。 * **参数:** - * **a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):左边的操作数。 - * **b** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):右侧操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)*:* 此表达式在源代码中的位置。 + * **a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):左边的操作数。 + * **b** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):右侧操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)*:* 此表达式在源代码中的位置。 -## *class* tvm.tir.GE(*a:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *b:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.GE(*a:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *b:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) GE 节点。 * **参数:** - * **a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):左边的操作数。 - * **b** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)右侧操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此表达式在源代码中的位置。 + * **a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):左边的操作数。 + * **b** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):右侧操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 -## *class* tvm.tir.And(*a:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *b:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.And(*a:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *b:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) And 节点。 * **参数:** - * **a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):左边的操作数。 - * **b** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):右侧操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)*:* 此表达式在源代码中的位置。 + * **a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):左边的操作数。 + * **b** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):右侧操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)*:* 此表达式在源代码中的位置。 -## *class* tvm.tir.Or(*a:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *b:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.Or(*a:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *b:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) Or 节点。 * **参数:** - * **a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):左边的操作数。 - * **b** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):右侧操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此表达式在源代码中的位置。 + * **a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):左边的操作数。 + * **b** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):右侧操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 -## *class* tvm.tir.Not(*a:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.Not(*a:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) Not 节点。 * **参数:** - * **a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)输入值。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)*:*此表达式在源代码中的位置。 + * **a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入值。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)*:*此表达式在源代码中的位置。 -## *class* tvm.tir.Select(*condition:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *true_value:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *false_value:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.Select(*condition:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *true_value:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *false_value:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) Select 节点。 -:::Note +:::note Select 可能会同时计算 true_value 和 false_value。如果您只想获取仅评估正确分支的条件表达式,请使用 `tvm.tir.if_then_else`。 ::: * **参数:** - * **condition** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):条件表达式。 - * **true_value** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)条件为真时要取的值。 - * **false_value** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):条件为假时取的值。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此表达式在源代码中的位置。 + * **condition** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):条件表达式。 + * **true_value** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):条件为真时要取的值。 + * **false_value** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):条件为假时取的值。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 -## *class* tvm.tir.BufferLoad(*buffer:*[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer), *indices:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*, *predicate:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.BufferLoad(*buffer:*[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer), *indices:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*, *predicate:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) BufferLoad 节点。 * **参数:** - * **buffer** ([Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer))*:* 要加载的缓冲区。 - * **indices** (*List[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*):从中加载值的缓冲区索引。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)*:* 此表达式在源代码中的位置。 - * **predicate** (*Optional[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*)**:** 一个布尔值向量掩码,指示要加载向量的哪些通道。掩码中的通道数必须等于正在加载的通道数。 + * **buffer** ([Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer))*:* 要加载的缓冲区。 + * **indices** (*List[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*):从中加载值的缓冲区索引。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)*:* 此表达式在源代码中的位置。 + * **predicate** (*Optional[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*)**:** 一个布尔值向量掩码,指示要加载向量的哪些通道。掩码中的通道数必须等于正在加载的通道数。 -## *class* tvm.tir.ProducerLoad(*producer:*[DataProducer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.DataProducer), *indices:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*, *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.ProducerLoad(*producer:*[DataProducer](/docs/api-reference/python-api/tvm-tir#class-tvmtirdataproducer), *indices:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*, *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) ProducerLoad 节点。 * **参数:** - * **producer** ([DataProducer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.DataProducer))*:* 要加载的缓冲区。 - * **indices** (*List[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*)[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)缓冲区索引。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此表达式在源代码中的位置。 + * **producer** ([DataProducer](/docs/api-reference/python-api/tvm-tir#class-tvmtirdataproducer))*:* 要加载的缓冲区。 + * **indices** (*List[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*):缓冲区索引。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 -## *class* tvm.tir.Ramp(*base:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *stride:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *lanes:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.Ramp(*base:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *stride:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *lanes:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) Ramp 节点。 * **参数:** - * **base** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):基本表达式。 - * **stride** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))*:* 斜坡的步幅。 - * **lanes** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))*:* 表达式的车道。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)*:* 此表达式在源代码中的位置。 + * **base** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):基本表达式。 + * **stride** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))*:* 斜坡的步幅。 + * **lanes** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))*:* 表达式的车道。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)*:* 此表达式在源代码中的位置。 -## *class* tvm.tir.Broadcast(*value:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *lanes:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.Broadcast(*value:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *lanes:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) Broadcast 节点。 * **参数:** - * **value** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))**:** 表达式的值。 - * **lanes** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):表达式的车道。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此表达式在源代码中的位置。 + * **value** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))**:** 表达式的值。 + * **lanes** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):表达式的车道。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 -## *class* tvm.tir.Shuffle(*vectors:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*, *indices:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*, *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.Shuffle(*vectors:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*, *indices:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*, *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) Shuffle 节点。 * **参数:** - * **vectors** (*List[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*)*:* 向量。 - * **indices** (*List[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*)*:* 索引。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此表达式在源代码中的位置。 + * **vectors** (*List[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*)*:* 向量。 + * **indices** (*List[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*)*:* 索引。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 -## *class* tvm.tir.Call(*dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str), *op:*[Op](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Op)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *args:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*, *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.Call(*dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str), *op:*[Op](/docs/api-reference/python-api/tvm-ir#class-tvmirop)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *args:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*, *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) tir.Call 节点。 * **参数:** * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):返回数据类型。 - * **op** (*Union[*[Op](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Op)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):要调用的函数,或全局 tvm.Op 的名称。 + * **op** (*Union[*[Op](/docs/api-reference/python-api/tvm-ir#class-tvmirop)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):要调用的函数,或全局 tvm.Op 的名称。 * **args** ([list](https://docs.python.org/3/library/stdtypes.html#list)*ofExpr*):调用的输入*参数。* - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)**:** 此表达式在源代码中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)**:** 此表达式在源代码中的位置。 ## *class* tvm.tir.CallEffectKind 可能的 tir.Call 效果种类。 -## *class* tvm.tir.Let(*var:*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var), *value:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *body:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.Let(*var:*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none), *value:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *body:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) Let 节点。 * **参数:** - * **var** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)):绑定中的变量。 - * **value** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):要绑定的值。 - * **body** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):主体表达式。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此表达式在源代码中的位置。 + * **var** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)):绑定中的变量。 + * **value** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):要绑定的值。 + * **body** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):主体表达式。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 -## *class* tvm.tir.IterVar(*dom:*[Range](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Range), *var:*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *iter_type:*[int](https://docs.python.org/3/library/functions.html#int), *thread_tag:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= ''*, *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.IterVar(*dom:*[Range](/docs/api-reference/python-api/tvm-ir#class-tvmirrangebeginprimexpr-endprimexprnone-none-spanspannone-none), *var:*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *iter_type:*[int](https://docs.python.org/3/library/functions.html#int), *thread_tag:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= ''*, *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) 表示迭代变量。 @@ -565,11 +565,11 @@ Let 节点。 IterVar 表示计算中的轴迭代。 * **参数:** - * **dom** ([Range](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Range))[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)迭代的范围。 - * **var** (*Union[*[tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*)*:* 用于迭代的内部变量。 + * **dom** ([Range](/docs/api-reference/python-api/tvm-ir#class-tvmirrangebeginprimexpr-endprimexprnone-none-spanspannone-none))- 迭代的范围。 + * **var** (*Union[*[tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*)*:* 用于迭代的内部变量。 * **iter_type** ([int](https://docs.python.org/3/library/functions.html#int))*:*迭代类型。 * **thread_tag** ([str](https://docs.python.org/3/library/stdtypes.html#str))*:*线程类型标签。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此表达式在源代码中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 :::info 另见 @@ -586,41 +586,41 @@ IterVar 表示计算中的轴迭代。 ::: -## *class* tvm.tir.CommReducer(*lhs:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)*]*, *rhs:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)*]*, *result:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*, *identity_element:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*, *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.CommReducer(*lhs:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)*]*, *rhs:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)*]*, *result:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*, *identity_element:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*, *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) 交换约简运算符。 * **参数:** - * **lhs** (*List[*[tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)*]*)*:* 减速器的左参数。 - * **rhs** (*List[*[tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)*]*)*:* 减速器的正确参数。 - * **result** (*List[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*)**:** 约简结果。 - * **identity_element** (*List[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*):身份元素。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此表达式在源代码中的位置。 + * **lhs** (*List[*[tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)*]*)*:* 减速器的左参数。 + * **rhs** (*List[*[tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)*]*)*:* 减速器的正确参数。 + * **result** (*List[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*)**:** 约简结果。 + * **identity_element** (*List[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*):身份元素。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 ## *class* tvm.tir.Stmt 所有语句的基类。 -## *class* tvm.tir.LetStmt(*var:*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var), *value:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *body:*[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.LetStmt(*var:*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none), *value:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *body:*[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) LetStmt 节点。 * **参数:** - * **var** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)):绑定中的变量。 - * **value** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)要绑定的值。 - * **body** ([Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt))*:* 正文语句。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)[:](https://docs.python.org/3/library/constants.html#None)源代码中 stmt 的位置。 + * **var** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)):绑定中的变量。 + * **value** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):要绑定的值。 + * **body** ([Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt))*:* 正文语句。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):源代码中 stmt 的位置。 -## *class* tvm.tir.AssertStmt(*condition:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *message:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *body:*[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.AssertStmt(*condition:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *message:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *body:*[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) AssertStmt 节点。 * **参数:** - * **condition** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):断言条件。 - * **message** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):错误消息。 - * **body** ([tvm.tir.Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt))**:** 主体语句。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):源代码中 stmt 的位置。 + * **condition** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):断言条件。 + * **message** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):错误消息。 + * **body** ([tvm.tir.Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt))**:** 主体语句。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):源代码中 stmt 的位置。 ## *class* tvm.tir.ForKind(*value*) @@ -628,196 +628,196 @@ AssertStmt 节点。 for 循环的种类。 -:::Note +:::note ForKind 可以改变循环的控制流语义,需要在所有 TIR 传递中考虑它。 ::: -## *class* tvm.tir.For(*loop_var:*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var), *min:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *extent:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *kind:*[ForKind](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.ForKind), *body:*[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt), *thread_binding:*[IterVar](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IterVar)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *annotations:*[Mapping](https://docs.python.org/3/library/typing.html#typing.Mapping)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*, Object] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.For(*loop_var:*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none), *min:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *extent:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *kind:*[ForKind](/docs/api-reference/python-api/tvm-tir#class-tvmtirforkindvalue), *body:*[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt), *thread_binding:*[IterVar](range-varvarstr-iter_typeint-thread_tagstr--spanspannone-none)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *annotations:*[Mapping](https://docs.python.org/3/library/typing.html#typing.Mapping)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*, Object] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) For 节点。 * **参数:** - * **loop_var** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var))*:* 循环变量。 - * **min** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):起始值。 - * **extent** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))*:* 循环的长度。 - * **kind** ([ForKind](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.ForKind)):for 的类型。 - * **body** ([Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)):正文语句。 - * **thread_binding** (*Optional[*[tir.IterVar](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IterVar)*]*)[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)此循环绑定到的线程。仅当 kind 为 ThreadBinding 时有效/ + * **loop_var** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none))*:* 循环变量。 + * **min** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):起始值。 + * **extent** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))*:* 循环的长度。 + * **kind** ([ForKind](/docs/api-reference/python-api/tvm-tir#class-tvmtirforkindvalue)):for 的类型。 + * **body** ([Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)):正文语句。 + * **thread_binding** (*Optional[*[tir.IterVar](range-varvarstr-iter_typeint-thread_tagstr--spanspannone-none)*]*):此循环绑定到的线程。仅当 kind 为 ThreadBinding 时有效/ * **annotations** (*Optional**[****Mapping**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,*** ***Object****]]*):额外的注解提示。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):源代码中 stmt 的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):源代码中 stmt 的位置。 -## *class* tvm.tir.While(*condition:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *body:*[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.While(*condition:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *body:*[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) While 节点。 * **参数:** - * **condition** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):终止条件。 - * **body** ([Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt))*:* 正文语句。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)**:** 源代码中 stmt 的位置。 + * **condition** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):终止条件。 + * **body** ([Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt))*:* 正文语句。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)**:** 源代码中 stmt 的位置。 -## *class* tvm.tir.BufferStore(*buffer:*[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer), *value:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *indices:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*, *predicate:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.BufferStore(*buffer:*[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer), *value:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *indices:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*, *predicate:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) 缓冲存储节点。 * **参数:** - * **buffer** ([Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)):缓冲区。 - * **value** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))*:* 我们要存储的值。 - * **indices** (*List[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*)*:* 要存储的索引位置。 - * **predicate** (*Optional[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*)*:* 一个布尔值的矢量掩码,指示要存储矢量的哪些通道。掩码中的通道数必须等于值中的通道数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):源代码中 stmt 的位置。 + * **buffer** ([Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)):缓冲区。 + * **value** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))*:* 我们要存储的值。 + * **indices** (*List[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*)*:* 要存储的索引位置。 + * **predicate** (*Optional[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*)*:* 一个布尔值的矢量掩码,指示要存储矢量的哪些通道。掩码中的通道数必须等于值中的通道数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):源代码中 stmt 的位置。 -## *class* tvm.tir.BufferRealize(*buffer:*[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer), *bounds:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Range](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Range)*]*, *condition:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *body:*[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.BufferRealize(*buffer:*[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer), *bounds:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Range](/docs/api-reference/python-api/tvm-ir#class-tvmirrangebeginprimexpr-endprimexprnone-none-spanspannone-none)*]*, *condition:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *body:*[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) BufferRealize 节点。 * **参数:** - * **buffer** ([Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)):缓冲区。 - * **bounds** (*List[*[Range](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Range)*]*):我们要存储的值。 - * **condition** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):实现条件。 - * **body** ([Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)):语句的主体。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)*:* 源代码中 stmt 的位置。 + * **buffer** ([Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)):缓冲区。 + * **bounds** (*List[*[Range](/docs/api-reference/python-api/tvm-ir#class-tvmirrangebeginprimexpr-endprimexprnone-none-spanspannone-none)*]*):我们要存储的值。 + * **condition** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):实现条件。 + * **body** ([Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)):语句的主体。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)*:* 源代码中 stmt 的位置。 -## *class* tvm.tir.Allocate(*buffer_var:*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str), *extents:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*, *condition:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *body:*[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt), *annotations:*[Mapping](https://docs.python.org/3/library/typing.html#typing.Mapping)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*, Object] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.Allocate(*buffer_var:*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str), *extents:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*, *condition:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *body:*[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt), *annotations:*[Mapping](https://docs.python.org/3/library/typing.html#typing.Mapping)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*, Object] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) Allocate 节点。 * **参数:** - * **buffer_var** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)):缓冲区变量。 + * **buffer_var** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)):缓冲区变量。 * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):缓冲区的数据类型。 * **extents** ([list](https://docs.python.org/3/library/stdtypes.html#list)*ofExpr*):分配的范围。 - * **condition** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))**:** 条件。 - * **body** ([Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt))*:* 正文语句。 + * **condition** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))**:** 条件。 + * **body** ([Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt))*:* 正文语句。 * **annotations** (*Optional**[****Mapping**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,*** ***Object****]]*):附加注解提。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):源代码中 stmt 的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):源代码中 stmt 的位置。 -## *class* tvm.tir.AllocateConst(*buffer_var:*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str), *extents:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*, *data_or_idx:*[NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray)*|*[int](https://docs.python.org/3/library/functions.html#int), *body:*[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt), *annotations:*[Mapping](https://docs.python.org/3/library/typing.html#typing.Mapping)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*, Object] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.AllocateConst(*buffer_var:*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str), *extents:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*, *data_or_idx:*NDArray*|*[int](https://docs.python.org/3/library/functions.html#int), *body:*[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt), *annotations:*[Mapping](https://docs.python.org/3/library/typing.html#typing.Mapping)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*, Object] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) AllocateConst 节点。 * **参数:** - * **buffer_var** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)):缓冲区变量。 - * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str))[:](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)缓冲区的数据类型。 + * **buffer_var** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)):缓冲区变量。 + * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):缓冲区的数据类型。 * **extents** ([list](https://docs.python.org/3/library/stdtypes.html#list)*ofExpr*)*:* 分配的范围。 - * **data_or_idx** (*Union[*[NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray)*,*[int](https://docs.python.org/3/library/functions.html#int)*]*):如果是 NDArray,则这是与常量关联的 const 数据。如果是整数,则这是包含 AllocateConst 的 IRModule 的“constants”属性的索引。 - * **body** ([Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)):正文语句。 + * **data_or_idx** (*Union[*NDArray*,*[int](https://docs.python.org/3/library/functions.html#int)*]*):如果是 NDArray,则这是与常量关联的 const 数据。如果是整数,则这是包含 AllocateConst 的 IRModule 的“constants”属性的索引。 + * **body** ([Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)):正文语句。 * **annotations** (*Optional**[****Mapping**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,*** ***Object****]]*)**:** 关于分配的附加注解。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)*:* 源代码中 stmt 的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)*:* 源代码中 stmt 的位置。 -## *class* tvm.tir.AttrStmt(*node: Object*, *attr_key:*[str](https://docs.python.org/3/library/stdtypes.html#str), *value:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *body:*[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.AttrStmt(*node: Object*, *attr_key:*[str](https://docs.python.org/3/library/stdtypes.html#str), *value:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *body:*[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) AttrStmt 节点。 * **参数:** * **node** (*Object*)**:** 注解属性的节点。 * **attr_key** ([str](https://docs.python.org/3/library/stdtypes.html#str))**:** 属性类型键。 - * **value** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):属性的值。 - * **body** ([Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt))*:* 正文语句。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)*:* 源代码中 stmt 的位置。 + * **value** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):属性的值。 + * **body** ([Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt))*:* 正文语句。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)*:* 源代码中 stmt 的位置。 -## *class* tvm.tir.DeclBuffer(*buffer:*[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer), *body:*[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.DeclBuffer(*buffer:*[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer), *body:*[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) DeclBuffer 节点。 * **参数:** - * **buffer** ([Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer))**:**正在声明的缓冲区。 - * **body** ([Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)):要执行的主体语句。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)此 DeclBuffer 在源代码中的位置。 + * **buffer** ([Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer))**:**正在声明的缓冲区。 + * **body** ([Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)):要执行的主体语句。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此 DeclBuffer 在源代码中的位置。 -## *class* tvm.tir.SeqStmt(*seq:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)*]*, *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.SeqStmt(*seq:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)*]*, *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) 语句序列。 * **参数:** - * **seq** (*List[*[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)*]*):语句。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):源代码中 stmt 的位置。 + * **seq** (*List[*[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)*]*):语句。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):源代码中 stmt 的位置。 -## *class* tvm.tir.IfThenElse(*condition:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *then_case:*[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt), *else_case:*[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)*|*[None](https://docs.python.org/3/library/constants.html#None), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.IfThenElse(*condition:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *then_case:*[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt), *else_case:*[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)*|*[None](https://docs.python.org/3/library/constants.html#None), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) IfThenElse 节点。 * **参数:** - * **condition** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):表达式。 - * **then_case** ([Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)):如果条件为真则执行的语句。 - * **else_case** (*Optional[*[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)*]*):如果条件为假则执行的语句。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)[:](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BufferRegion)源代码中 stmt 的位置。 + * **condition** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):表达式。 + * **then_case** ([Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)):如果条件为真则执行的语句。 + * **else_case** (*Optional[*[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)*]*):如果条件为假则执行的语句。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):源代码中 stmt 的位置。 -## *class* tvm.tir.Evaluate(*value:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.Evaluate(*value:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) Evaluate 节点。 * **参数:** - * **value** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):要评估的表达式。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)[:](https://docs.python.org/3/library/typing.html#typing.List)源代码中 stmt 的位置。 + * **value** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):要评估的表达式。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):源代码中 stmt 的位置。 -## tvm.tir.stmt_seq(args:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*|*[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)) → [SeqStmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.SeqStmt) +## tvm.tir.stmt_seq(args:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*|*[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)) → [SeqStmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirseqstmtseqliststmt-spanspannone-none) 制定语句序列。 -* **参数:*args***(*Union[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*,*[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)*]*)*:* 要组合为序列的语句列表。 +* **参数:*args***(*Union[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*,*[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)*]*)*:* 要组合为序列的语句列表。 * **返回:stmt**:组合语句。 -* **返回类型:**[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)。 +* **返回类型:**[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)。 -## tvm.tir.stmt_list(*stmt:*[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)] +## tvm.tir.stmt_list(*stmt:*[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)] 从块中创建 stmt 列表。 -* **参数:stmt** ([Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt))*:* 输入语句。 +* **参数:stmt** ([Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt))*:* 输入语句。 * **返回:stmt_list**:解压后的语句列表。 -* **返回类型:** List[[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)]。 +* **返回类型:** List[[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)]。 -## *class* tvm.tir.BufferRegion(*buffer:*[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer), *region:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Range](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Range)*]*) +## *class* tvm.tir.BufferRegion(*buffer:*[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer), *region:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Range](/docs/api-reference/python-api/tvm-ir#class-tvmirrangebeginprimexpr-endprimexprnone-none-spanspannone-none)*]*) BufferRegion 节点。 * **参数:** - * **buffer** ([Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer))**:** 缓冲区的缓冲区。 - * **region** (*List[*[Range](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Range)*]*):缓冲区的区域数组。 + * **buffer** ([Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer))**:** 缓冲区的缓冲区。 + * **region** (*List[*[Range](/docs/api-reference/python-api/tvm-ir#class-tvmirrangebeginprimexpr-endprimexprnone-none-spanspannone-none)*]*):缓冲区的区域数组。 -## *class* tvm.tir.MatchBufferRegion(*buffer:*[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer), *source:*[BufferRegion](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BufferRegion)) +## *class* tvm.tir.MatchBufferRegion(*buffer:*[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer), *source:*[BufferRegion](/docs/api-reference/python-api/tvm-tir#class-tvmtirbufferRegion)) MatchBufferRegion 节点。 * **参数:** - * **buffer** ([Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer))***:*** 目标缓冲区。 - * **source** ([BufferRegion](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BufferRegion))**:** 源缓冲区的区域。 + * **buffer** ([Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer))***:*** 目标缓冲区。 + * **source** ([BufferRegion](/docs/api-reference/python-api/tvm-tir#class-tvmtirbufferRegion))**:** 源缓冲区的区域。 -## *class* tvm.tir.Block(*iter_vars:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[IterVar](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IterVar)*]*, *reads:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[BufferRegion](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BufferRegion)*]*, *writes:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[BufferRegion](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BufferRegion)*]*, *name_hint:*[str](https://docs.python.org/3/library/stdtypes.html#str), *body:*[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt), *init:*[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *alloc_buffers:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *match_buffers:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[MatchBufferRegion](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.MatchBufferRegion)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *annotations:*[Mapping](https://docs.python.org/3/library/typing.html#typing.Mapping)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*, Object] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.Block(*iter_vars:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[IterVar](range-varvarstr-iter_typeint-thread_tagstr--spanspannone-none)*]*, *reads:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[BufferRegion](/docs/api-reference/python-api/tvm-tir#class-tvmtirbufferRegion)*]*, *writes:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[BufferRegion](/docs/api-reference/python-api/tvm-tir#class-tvmtirbufferRegion)*]*, *name_hint:*[str](https://docs.python.org/3/library/stdtypes.html#str), *body:*[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt), *init:*[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *alloc_buffers:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *match_buffers:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[MatchBufferRegion](/docs/api-reference/python-api/tvm-tir#class-tvmtirmatchbufferregionbufferbuffer-sourcebufferregion)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *annotations:*[Mapping](https://docs.python.org/3/library/typing.html#typing.Mapping)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*, Object] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) Block 节点。 * **参数:** - * **iter_vars** (*List[*[IterVar](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IterVar)*]*):块变量。 - * **reads** (*List[*[BufferRegion](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BufferRegion)*]*):块的读取缓冲区区域。 - * **writes** (*List[*[BufferRegion](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BufferRegion)*]*):块的写入缓冲区区域。 + * **iter_vars** (*List[*[IterVar](range-varvarstr-iter_typeint-thread_tagstr--spanspannone-none)*]*):块变量。 + * **reads** (*List[*[BufferRegion](/docs/api-reference/python-api/tvm-tir#class-tvmtirbufferRegion)*]*):块的读取缓冲区区域。 + * **writes** (*List[*[BufferRegion](/docs/api-reference/python-api/tvm-tir#class-tvmtirbufferRegion)*]*):块的写入缓冲区区域。 * **name_hint** ([str](https://docs.python.org/3/library/stdtypes.html#str)):块的 name_hint。 - * **body** ([Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt))[:](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)块的主体。 - * **init** (*Optional[*[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)*]*):缩减块的 init 块。 - * **alloc_buffers** (*Optional**[***[list](https://docs.python.org/3/library/stdtypes.html#list)***[***[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)***]*]*):缓冲区分配。 - * **match_buffers** (*Optional**[****List**[***[MatchBufferRegion](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.MatchBufferRegion)***]****]*):子区域缓冲区匹配。 + * **body** ([Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)):块的主体。 + * **init** (*Optional[*[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)*]*):缩减块的 init 块。 + * **alloc_buffers** (*Optional**[***[list](https://docs.python.org/3/library/stdtypes.html#list)***[***[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)***]*]*):缓冲区分配。 + * **match_buffers** (*Optional**[****List**[***[MatchBufferRegion](/docs/api-reference/python-api/tvm-tir#class-tvmtirmatchbufferregionbufferbuffer-sourcebufferregion)***]****]*):子区域缓冲区匹配。 * **annotations** (*Optional**[****Mapping**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,*** ***Object****]]*):额外的注解提示。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此块在源代码中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此块在源代码中的位置。 -## *class* tvm.tir.BlockRealize(*iter_values:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*, *predicate:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*|*[bool](https://docs.python.org/3/library/functions.html#bool), *block:*[Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.tir.BlockRealize(*iter_values:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*, *predicate:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*|*[bool](https://docs.python.org/3/library/functions.html#bool), *block:*[Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) BlockRealize 节点。 * **参数:** - * **iter_values** (*List[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*)*:* 块变量的绑定值。 - * **predicate** (*Union[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*,*[bool](https://docs.python.org/3/library/functions.html#bool)*]*):块的谓词。 - * **block** ([Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block))*:* 要实现的块。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)*:* 此 block_realize 在源代码中的位置。 + * **iter_values** (*List[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*)*:* 块变量的绑定值。 + * **predicate** (*Union[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*,*[bool](https://docs.python.org/3/library/functions.html#bool)*]*):块的谓词。 + * **block** ([Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none))*:* 要实现的块。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)*:* 此 block_realize 在源代码中的位置。 ## *class* tvm.tir.PrimFunc(*params*, *body*, *ret_type=None*, *buffer_map=None*, *attrs=None*, *span=None*) 函数声明表达式。 * **参数:** - * **params** (*List*[****Union**[***[tvm.tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)***,** [tvm.tir.Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)***]****]*):函数的输入参数列表。 - * **body** ([tvm.tir.Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)):函数主体。 - * **ret_type** ([tvm.ir.Type](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Type)):函数的返回类型注解。 - * **buffer_map** ([Map](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Map)*[*[tvm.tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)*,*[tvm.tir.Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)*]*):缓冲区绑定图。 + * **params** (*List*[****Union**[***[tvm.tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)***,** [tvm.tir.Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)***]****]*):函数的输入参数列表。 + * **body** ([tvm.tir.Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)):函数主体。 + * **ret_type** ([tvm.ir.Type](/docs/api-reference/python-api/tvm-ir#class-tvmirtype)):函数的返回类型注解。 + * **buffer_map** ([Map](/docs/api-reference/python-api/tvm-ir#class-tvmirmapinput_dictmappinganyany)*[*[tvm.tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)*,*[tvm.tir.Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)*]*):缓冲区绑定图。 * **attrs** (*Optional*[*tvm.Attrs]*):函数的属性,可以为 None。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此 itervar 在源代码中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此 itervar 在源代码中的位置。 ### @@ -825,16 +825,16 @@ BlockRealize 节点。 创建具有相同集合签名但具有新主体的新 PrimFunc。 * **参数:** - * **new_body** ([Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)):新主体。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此 itervar 在源代码中的位置。 + * **new_body** ([Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)):新主体。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此 itervar 在源代码中的位置。 * **返回:new_func**:创建的新函数。 -* **返回类型:**[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)。 +* **返回类型:**[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)。 -### specialize(*param_map:*[Mapping](https://docs.python.org/3/library/typing.html#typing.Mapping)*[*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)*,*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*|*[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)*]*) +### specialize(*param_map:*[Mapping](https://docs.python.org/3/library/typing.html#typing.Mapping)*[*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)*,*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*|*[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)*]*) PrimFunc 的专门参数。 -* **参数:param_map** (*Mapping*[***[tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)***,***Union***[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*,*[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)*]]):从函数参数到实例的映射。 +* **参数:param_map** (*Mapping*[***[tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)***,***Union***[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*,*[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)*]]):从函数参数到实例的映射。 **示例** @@ -878,29 +878,29 @@ def mem_copy_16_16(a: T.handle, b: T.handle) -> None: B[vi, vj] = A[vi, vj] ``` * **返回:func:** 带有特殊参数的新函数。 -* **返回类型:**[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)。 +* **返回类型:**[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)。 ## *class* tvm.tir.TensorIntrin(*desc*, *impl*) 张量的内在函数。 * **参数:** - * **desc** ([PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc))**:** 描述计算的函数。 - * **impl** ([PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc))**:** 执行的实现函数。 + * **desc** ([PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone))**:** 描述计算的函数。 + * **impl** ([PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone))**:** 执行的实现函数。 -### *static* register(*name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *desc:*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc), *impl:*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc), *override:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) +### *static* register(*name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *desc:*[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone), *impl:*[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone), *override:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) 使用其名称注册张量内在函数。 * **参数:** * **name** ([str](https://docs.python.org/3/library/stdtypes.html#str))*:* 要注册的 TensorIntrin 的名称。 - * **desc** ([PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc))*:* 描述计算的函数。 - * **impl** ([PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc))[:](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap)执行的实现函数。 + * **desc** ([PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone))*:* 描述计算的函数。 + * **impl** ([PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)) - 执行的实现函数。 * **override** ([bool](https://docs.python.org/3/library/functions.html#bool)):是否覆盖现有的内在函数。 -### *static* get(*name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *allow_missing:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [TensorIntrin](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.TensorIntrin) | [None](https://docs.python.org/3/library/constants.html#None) +### *static* get(*name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *allow_missing:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [TensorIntrin](/docs/api-reference/python-api/tvm-tir#class-tvmtirtensorintrindesc-impl) | [None](https://docs.python.org/3/library/constants.html#None) 通过名称查找张量内在函数。 @@ -909,65 +909,65 @@ def mem_copy_16_16(a: T.handle, b: T.handle) -> None: * **allow_missing** ([bool](https://docs.python.org/3/library/functions.html#bool)):是否允许缺失张量内部参数。若为 False,则在张量内部参数。 * **exist.** 不存在。 * **返回:result**:具有指定名称的 TensorIntrin,如果未找到则为 None。 -* **返回类型:** Optional[[TensorIntrin](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.TensorIntrin)]。 +* **返回类型:** Optional[[TensorIntrin](/docs/api-reference/python-api/tvm-tir#class-tvmtirtensorintrindesc-impl)]。 ## *class* tvm.tir.IndexMap(*initial_indices*, *final_indices*, *inverse_index_map*) 从多维索引到另一组多维索引的映射。 * **参数:** - * **initial_indices** (*List[*[tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)*]*):表示重新映射之前的索引的变量。 - * **final_indices** (*List[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*):定义重新映射后的索引的表达式。 - * **inverse_index_map** (*Union*[****Callable**,** ***Optional***[*[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap)*]]*)*:可选的预定义逆索引图。定义此方法后,IndexMap::Inverse 将返回预定义的逆索引图。否则,逆索引图将即时计算。用户有责任确保预定义逆索引图的正确性。 + * **initial_indices** (*List[*[tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)*]*):表示重新映射之前的索引的变量。 + * **final_indices** (*List[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*):定义重新映射后的索引的表达式。 + * **inverse_index_map** (*Union*[****Callable**,** ***Optional***[*[IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map)*]]*)*:可选的预定义逆索引图。定义此方法后,IndexMap::Inverse 将返回预定义的逆索引图。否则,逆索引图将即时计算。用户有责任确保预定义逆索引图的正确性。 -### *static* from_func(*mapping_function:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable), *ndim:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *inverse_index_map:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*|*[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*,*, *index_dtype: [str](https://docs.python.org/3/library/stdtypes.html#str) = 'int64'*) +### *static* from_func(*mapping_function:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable), *ndim:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *inverse_index_map:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*|*[IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*,*, *index_dtype: [str](https://docs.python.org/3/library/stdtypes.html#str) = 'int64'*) 从函数创建索引图。 * **参数:** * **mapping_function** (*Callable*):从源索引映射到目标索引的函数。该函数应接受 tir.Var 参数并返回 tir.PrimExpr 或 tir.PrimExpr 列表。返回 tir.PrimExpr 相当于返回包含该 tir.PrimExpr 的长度为 1 的列表。 * **ndim** (*Optional[*[int](https://docs.python.org/3/library/functions.html#int)*]*):此转换应应用到的缓冲区的维数。如果 mapping_function 使用可变参数*args,则必须指定 ndim。如果 mapping_function 不使用可变参数,则 ndim 为可选。 - * **inverse_index_map** (*Union**[****Callable**,*** ***Optional****[*[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap)*]]*):可选的预定义逆索引图。定义此方法后,IndexMap::Inverse 将返回预定义的逆索引图。否则,逆索引图将即时计算。用户有责任确保预定义逆索引图的正确性。 + * **inverse_index_map** (*Union**[****Callable**,*** ***Optional****[*[IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map)*]]*):可选的预定义逆索引图。定义此方法后,IndexMap::Inverse 将返回预定义的逆索引图。否则,逆索引图将即时计算。用户有责任确保预定义逆索引图的正确性。 * **返回:index_map**:返回表示 mapping_function 的 IndexMap 。 -* **返回类型:**[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap)。 +* **返回类型:**[IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map)。 -### *static* from_func_with_separators(*mapping_function:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable), *ndim:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *inverse_index_map:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*|*[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, ***, *index_dtype: [str](https://docs.python.org/3/library/stdtypes.html#str) = 'int64'*) +### *static* from_func_with_separators(*mapping_function:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable), *ndim:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *inverse_index_map:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*|*[IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, ***, *index_dtype: [str](https://docs.python.org/3/library/stdtypes.html#str) = 'int64'*) 从函数创建索引图。 * **参数:** - * **mapping_function** (*Callable*)[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)用于从源索引映射到目标索引的函数。该函数应接受 tir.Var 参数并返回 tir.PrimExpr 或列表。返回列表的每个元素应为 tir.PrimExpr 或 IndexMap.AXIS_SEPARATOR 对象。返回 tir.PrimExpr 相当于返回包含该 tir.PrimExpr 的长度为 1 的列表。 + * **mapping_function** (*Callable*):用于从源索引映射到目标索引的函数。该函数应接受 tir.Var 参数并返回 tir.PrimExpr 或列表。返回列表的每个元素应为 tir.PrimExpr 或 IndexMap.AXIS_SEPARATOR 对象。返回 tir.PrimExpr 相当于返回包含该 tir.PrimExpr 的长度为 1 的列表。 * **ndim** (*Optional[*[int](https://docs.python.org/3/library/functions.html#int)*]*):此转换应应用到的缓冲区的维数。如果 mapping_function 使用可变参数*args,则必须指定 ndim 。如果 mapping_function 不使用可变参数,则 ndim 为可选。 - * **inverse_index_map** (*Union**[****Callable**,*** ***Optional****[*[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap)*]]*)**:** 可选的预定义逆索引图。定义此方法后,IndexMap::Inverse 将返回预定义的逆索引图。否则,逆索引图将即时计算。用户有责任确保预定义逆索引图的正确性。 + * **inverse_index_map** (*Union**[****Callable**,*** ***Optional****[*[IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map)*]]*)**:** 可选的预定义逆索引图。定义此方法后,IndexMap::Inverse 将返回预定义的逆索引图。否则,逆索引图将即时计算。用户有责任确保预定义逆索引图的正确性。 * **index_dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str))*:* 映射函数中输入迭代器使用的默认索引 dtype。 * **返回:ret**:返回一个元组,其第一个元素是表示**mapping_function 的 IndexMap ,其第二个索引是 IndexMap.AXIS_SEPARATOR 发生的索引列表 。 -* **返回类型:**[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)[[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap), List[[int](https://docs.python.org/3/library/functions.html#int)]]。 +* **返回类型:**[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)[[IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map), List[[int](https://docs.python.org/3/library/functions.html#int)]]。 -### is_equivalent_to(*other_map:*[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap)) → [bool](https://docs.python.org/3/library/functions.html#bool) +### is_equivalent_to(*other_map:*[IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map)) → [bool](https://docs.python.org/3/library/functions.html#bool) 如果索引图等效,则返回。 -* **参数:other_map** ([IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap)):应该进行比较的 IndexMap。 +* **参数:other_map** ([IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map)):应该进行比较的 IndexMap。 * **返回:is_equivalent**:如果两个映射表示相同的转换,则为 True,否则为 False。 * **返回类型:**[bool](https://docs.python.org/3/library/functions.html#bool)。 -### map_indices(*indices:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)] +### map_indices(*indices:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)] 将索引图应用于一组索引。 -* **参数:indices** (*List[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*):要映射的索引。 +* **参数:indices** (*List[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*):要映射的索引。 * **返回:result**:映射的索引。 -* **返回类型:** List[[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)]。 +* **返回类型:** List[[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)]。 -### map_shape(*shape:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)] +### map_shape(*shape:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)] 将索引图应用于缓冲区形状。 -* **参数:shape** (*List[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*):要映射的缓冲区形状。 +* **参数:shape** (*List[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*):要映射的缓冲区形状。 * **返回:result**:映射的形状。 -* **返回类型:** List[[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)]。 +* **返回类型:** List[[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)]。 -### map_ndarray(*arr_src:*[NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray)) → [NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray) +### map_ndarray(*arr_src:*NDArray) → NDArray 将此索引映射应用于输入 NDArray,以转换其布局。 @@ -975,27 +975,27 @@ def mem_copy_16_16(a: T.handle, b: T.handle) -> None: * **返回:arr_dst**:转换后的 NDArray。 * **返回类型:** runtime.NDArray。 -### inverse(*shape:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Range](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Range)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*) → [IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap) +### inverse(*shape:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Range](/docs/api-reference/python-api/tvm-ir#class-tvmirrangebeginprimexpr-endprimexprnone-none-spanspannone-none)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*) → [IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map) 返回该映射的逆映射。   如果该函数不是双射(bijective),则会抛出错误。 -* **参数:shape** (*List**[****Union**[***[Range](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Range)***,***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)***]****]*):需要确定逆的区域。用于验证映射在此范围内是否为双射。 -* **返回:inverse**[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)逆。 -* **返回类型:**[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap)。 +* **参数:shape** (*List**[****Union**[***[Range](/docs/api-reference/python-api/tvm-ir#class-tvmirrangebeginprimexpr-endprimexprnone-none-spanspannone-none)***,***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)***]****]*):需要确定逆的区域。用于验证映射在此范围内是否为双射。 +* **返回:inverse**:逆。 +* **返回类型:**[IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map)。 -### non_surjective_inverse(*shape:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Range](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Range)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*) → [Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)[[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap), [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)] +### non_surjective_inverse(*shape:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Range](/docs/api-reference/python-api/tvm-ir#class-tvmirrangebeginprimexpr-endprimexprnone-none-spanspannone-none)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*) → [Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)[[IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map), [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)] 返回该映射的逆映射。   可用于引入填充(padding)的变换。 -* **参数:shape** (*List**[****Union**[***[Range](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Range)***,***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)***]****]*):需要确定逆的区域。用于确定谓词。 +* **参数:shape** (*List**[****Union**[***[Range](/docs/api-reference/python-api/tvm-ir#class-tvmirrangebeginprimexpr-endprimexprnone-none-spanspannone-none)***,***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)***]****]*):需要确定逆的区域。用于确定谓词。 * **返回:result**:逆,以及逆映射到输入范围中的有效索引的谓词。 -* **返回类型:**[Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)[[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap), [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)]。 +* **返回类型:**[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)[[IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map), [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)]。 **示例** @@ -1011,9 +1011,9 @@ print(predicate) # 打印 "(axis0==3) && (axis2 >= 2)" 调用 packed 的低版本。packed 函数的参数可以是 Expr 或 Buffer。当传入 Expr 时,参数为对应的 POD 类型。当参数为 Buffer 时,对应的 PackedFunc 将收到一个 TVMArrayHandle,其内容在回调期间有效。如果 PackedFunc 是 Python 回调,则对应的参数为 NDArray。 * **参数:** * **args** ([list](https://docs.python.org/3/library/stdtypes.html#list)*ofExprorBuffer.*):位置参数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 :::info 另见 @@ -1029,9 +1029,9 @@ print(predicate) # 打印 "(axis0==3) && (axis2 >= 2)" call c-packed 的低版本。与 call_packed 相同,但第一个参数是函数名(与 call_extern 类似),最后一个参数是资源句柄。 * **参数:** * **args** ([list](https://docs.python.org/3/library/stdtypes.html#list)*ofExprorBuffer.*):位置参数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)*:* 此运算符在源代码中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)*:* 此运算符在源代码中的位置。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 :::info 另见 @@ -1043,12 +1043,12 @@ call c-packed 的低版本。与 call_packed 相同,但第一个参数是函 ::: -## tvm.tir.call_tir(*global_var:*[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar), args*) +## tvm.tir.call_tir(*global_var:*[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none), args*) 调用同一 IRModule 中的另一个 PrimFunc。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.call_packed(args*, *span=None*) @@ -1061,9 +1061,9 @@ call c-packed 的低版本。与 call_packed 相同,但第一个参数是函 当参数为 Buffer 时,对应的 PackedFunc 会收到一个 TVMArrayHandle,其内容在回调期间有效。如果 PackedFunc 是 python 回调,则对应的参数为 NDArray。 * **参数:** * **args** ([list](https://docs.python.org/3/library/stdtypes.html#list)*ofExprorBuffer.*):位置参数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)*:* 此运算符在源代码中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)*:* 此运算符在源代码中的位置。 * **返回:call:** 调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 :::info 另见 @@ -1084,9 +1084,9 @@ call c-packed 的低版本。与 call_packed 相同,但第一个参数是函 与 call_packed 相同,但第一个参数是函数名(如 call_extern 中一样),最后一个参数是资源句柄。 * **参数:** * **args** ([list](https://docs.python.org/3/library/stdtypes.html#list)*ofExprorBuffer.*):位置参数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 :::info 另见 @@ -1109,9 +1109,9 @@ call c-packed 的低版本。与 call_packed 相同,但第一个参数是函 * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):结果的数据类型。 * **func_name** ([str](https://docs.python.org/3/library/stdtypes.html#str)):内部函数名称。 * **args** ([list](https://docs.python.org/3/library/stdtypes.html#list)):位置参数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.call_pure_extern(*dtype*, *func_name*, args*, *span=None*) @@ -1120,9 +1120,9 @@ call c-packed 的低版本。与 call_packed 相同,但第一个参数是函 * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):结果的数据类型。 * **func_name** ([str](https://docs.python.org/3/library/stdtypes.html#str))*:* 外部函数名称。 * **args** ([list](https://docs.python.org/3/library/stdtypes.html#list))**:** 位置参数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.call_extern(*dtype*, *func_name*, args*, *span=None*) @@ -1132,9 +1132,9 @@ call c-packed 的低版本。与 call_packed 相同,但第一个参数是函 * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):结果的数据类型。 * **func_name** ([str](https://docs.python.org/3/library/stdtypes.html#str)):外部函数名称。 * **args** ([list](https://docs.python.org/3/library/stdtypes.html#list))**:** 位置参数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)*:* 此运算符在源代码中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)*:* 此运算符在源代码中的位置。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.call_llvm_intrin(*dtype*, *name*, args*, *span=None*) @@ -1144,9 +1144,9 @@ call c-packed 的低版本。与 call_packed 相同,但第一个参数是函 * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str))*:* 结果的数据类型。 * **name** ([str](https://docs.python.org/3/library/stdtypes.html#str))**:** llvm 内部函数的名称。 * **args** ([list](https://docs.python.org/3/library/stdtypes.html#list)):位置参数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.call_llvm_pure_intrin(*dtype*, *name*, args*, *span=None*) @@ -1156,9 +1156,9 @@ call c-packed 的低版本。与 call_packed 相同,但第一个参数是函 * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):结果的数据类型。 * **name** ([str](https://docs.python.org/3/library/stdtypes.html#str))*:* llvm 内部函数的名称。 * **args** ([list](https://docs.python.org/3/library/stdtypes.html#list)):位置参数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ## tvm.tir.ret(*val*, *span=None*) @@ -1166,9 +1166,9 @@ call c-packed 的低版本。与 call_packed 相同,但第一个参数是函 创建 tir 返回表达式 * **参数:** * **val** (*Expr*):返回的 tir 表达式,其数据类型为 int、float 或 void 指针。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:ret**:返回表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.all(args*, *span=None*) @@ -1176,7 +1176,7 @@ call c-packed 的低版本。与 call_packed 相同,但第一个参数是函 创建一个新的表达式,该表达式表示所有参数条件的交集。 * **参数:** * **args** ([list](https://docs.python.org/3/library/stdtypes.html#list)):符号布尔表达式列表。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:expr**:表达式。 * **返回类型:** Expr。 @@ -1186,7 +1186,7 @@ call c-packed 的低版本。与 call_packed 相同,但第一个参数是函 创建一个新的表达式,表示所有参数条件的并集。 * **参数:** * **args** ([list](https://docs.python.org/3/library/stdtypes.html#list)):符号布尔表达式列表。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:expr** *:* 表达式。 * **返回类型:** Expr。 @@ -1196,17 +1196,17 @@ call c-packed 的低版本。与 call_packed 相同,但第一个参数是函 dtype 的最小值。 * **参数:** * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str))**:** 数据类型。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:value**:dtype 的最小值。 * **返回类型:** tvm.Expr。 -## tvm.tir.max_value(*dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Any](https://docs.python.org/3/library/typing.html#typing.Any) +## tvm.tir.max_value(*dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Any](https://docs.python.org/3/library/typing.html#typing.Any) dtype 的最大值 * **参数:** * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):数据类型。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)**:** 此运算符在源代码中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)**:** 此运算符在源代码中的位置。 * **返回:value**:dtype 的最大值。 * **返回类型:** tvm.Expr @@ -1220,7 +1220,7 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 * **args** ([list](https://docs.python.org/3/library/stdtypes.html#list)*ofExprorBuffers.*):位置参数。 * **trace_action** (*str.*):跟踪操作的名称。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 :::info 另见 @@ -1240,15 +1240,15 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 * **dtype_str** ([str](https://docs.python.org/3/library/stdtypes.html#str))*:* 数组的数据类型。 * **num** ([int](https://docs.python.org/3/library/functions.html#int)):数组的大小。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.tvm_stack_make_shape(args*) 在堆栈上分配一个形状元组,返回句柄。 -* **参数:args** ([int](https://docs.python.org/3/library/functions.html#int))[:](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)元组形状。 +* **参数:args** ([int](https://docs.python.org/3/library/functions.html#int)):元组形状。 * **返回:call** *:* 调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.tvm_stack_make_array(*data*, *shape*, *strides*, *ndim*, *arr_dtype*, *elem_offset*) @@ -1261,15 +1261,15 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 * **ndim** (*Expr*)**:** 数组的维度。 * **arr_dtype** (*Expr*)*:* 数组的数据类型。 * **elem_offse** (*Expr*)**:** 数组的元素偏移量。 -* **返回:call**[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回:call**:调用表达式。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.tvm_tuple(value*) 在 AttrStmt 的值字段中创建一个元组结构。 -* **参数:value** (*Expr*)[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)元组中的值。 +* **参数:value** (*Expr*):元组中的值。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.handle_add_byte_offset(*handle*, *offset*) @@ -1279,7 +1279,7 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 * **handle** (*Expr*):句柄。 * **offset** ([int](https://docs.python.org/3/library/functions.html#int))**:** 偏移量。 * **返回:call:** 调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.tvm_struct_get(*arr*, *index*, *field*, *dtype*) @@ -1291,7 +1291,7 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 * **index** ([int](https://docs.python.org/3/library/functions.html#int)):结构的索引。 * **field** ([int](https://docs.python.org/3/library/functions.html#int)):结构体的字段。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.tvm_struct_set(*arr*, *index*, *field*, *value*) @@ -1303,17 +1303,17 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 * **field** ([int](https://docs.python.org/3/library/functions.html#int)):结构体的字段。 * **value** (*Expr*):要在字段中设置的值。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -## tvm.tir.address_of(*obj:*[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)*|*[BufferLoad](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BufferLoad), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +## tvm.tir.address_of(*obj:*[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)*|*[BufferLoad](/docs/api-reference/python-api/tvm-tir#class-tvmtirbufferLoad), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 返回缓冲区中元素的地址。 * **参数:** - * **obj** (*Union[*[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)*,*[BufferLoad](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BufferLoad)*]*):缓冲区或缓冲区负载。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **obj** (*Union[*[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)*,*[BufferLoad](/docs/api-reference/python-api/tvm-tir#class-tvmtirbufferLoad)*]*):缓冲区或缓冲区负载。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.lookup_param(*param_name*, *span=None*) @@ -1321,9 +1321,9 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 按名称返回参数。 * **参数:** * **param_name** ([str](https://docs.python.org/3/library/stdtypes.html#str))**:** 参数的名称。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)***:*** 此运算符在源代码中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)***:*** 此运算符在源代码中的位置。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.assume(*cond=None*) @@ -1331,13 +1331,13 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 提供可用于简化的真实陈述。 * **参数:cond** (*Expr*):约束条件。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ## tvm.tir.undef() 返回已初始化的任意值。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.tvm_thread_allreduce(freduce_args*) @@ -1345,7 +1345,7 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 在线程块内执行 allreduce。 * **参数:freduce_args** (*Expr*):参数。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ## tvm.tir.type_annotation(*dtype*) @@ -1353,7 +1353,7 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 创建类型注解表达式。 * **参数:dtype** (*Expr*):数据类型。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.tvm_access_ptr(*ptype*, *data*, *offset*, *extent*, *rw_mask*) @@ -1365,21 +1365,21 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 * **extent** ([int](https://docs.python.org/3/library/functions.html#int))**:** 指针的范围。 * **rw_mask** ([int](https://docs.python.org/3/library/functions.html#int)):读写掩码。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.tvm_throw_last_error() 抛出 TVMGetLastError()。 * **返回:ret**:返回表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.tvm_load_matrix_sync(*fragment*, *m*, *n*, *k*, *index*, *buffer_ptr*, *stride*, *layout*) TVM 张量核心负载运算符的内在函数。 * **参数:** - * **fragment** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var))*:* wmma 片段。 + * **fragment** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none))*:* wmma 片段。 * **m** (*UIntImm*):wmma 片段的形状。 * **n** (*UIntImm*):wmma 片段的形状。 * **k** (*UIntImm*):wmma 片段的形状。 @@ -1388,13 +1388,13 @@ TVM 张量核心负载运算符的内在函数。 * **stride** (*Expr*):片段步幅。 * **layout** (*Literal**[****"row_major"**,*** ***"column_major"****]*):片段布局。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.tvm_store_matrix_sync(*fragment*, *m*, *n*, *k*, *index*, *buffer_ptr*, *stride*, *layout*) TVM 张量核心存储运算符的内在函数。 * **参数:** - * **fragment** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var))*:* wmma 片段。 + * **fragment** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none))*:* wmma 片段。 * **m** (*UIntImm*):wmma 片段的形状。 * **n** (*UIntImm*):wmma 片段的形状。 * **k** (*UIntImm*):wmma 片段的形状。 @@ -1402,24 +1402,24 @@ TVM 张量核心存储运算符的内在函数。 * **buffer_ptr** (*Expr*):片段缓冲区指针。 * **stride** (*Expr*):片段步幅。 * **layout** (*Literal**[****"row_major"**,*** ***"column_major"****]*):片段布局。 -* **返回:call**[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回:call**:调用表达式。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.tvm_mma_sync(*fragment_d*, *index_d*, *fragment_a*, *index_a*, *fragment_b*, *index_b*, *fragment_c*, *index_c*) TVM 张量核心 mma_sync 运算符的内在函数。 * **参数:** - * **fragment_d** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)):wmma fragment_d。 - * **index_d** (*Expr*)[:](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-matrix-instructions-for-mma)fragment_d 索引。 - * **fragment_a** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var))[:](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-matrix-instructions-for-mma)wmma fragment_a。 - * **index_a** (*Expr*)[:](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-matrix-instructions-for-mma)fragment_a 索引。 - * **fragment_b** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)):wmma fragment_b。 + * **fragment_d** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)):wmma fragment_d。 + * **index_d** (*Expr*):fragment_d 索引。 + * **fragment_a** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)):wmma fragment_a。 + * **index_a** (*Expr*):fragment_a 索引。 + * **fragment_b** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)):wmma fragment_b。 * **index_b** (*Expr*)*:* fragment_b 索引。 - * **fragment_c** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var))*:* wmma fragment_c。 + * **fragment_c** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none))*:* wmma fragment_c。 * **index_c** (*Expr*)**:** fragment_c 索引。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.tvm_bmma_sync(*fragment_d*, *index_d*, *fragment_a*, *index_a*, *fragment_b*, *index_b*, *fragment_c*, *index_c*) @@ -1434,21 +1434,21 @@ TVM 张量核心 mma_sync 运算符的内在函数。 * fragment_c (tir.Var) – bwmma 片段_c。 * index_c (Expr) – 片段_c 的索引。 * **返回:call** *:* 调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.tvm_fill_fragment(*fragment*, *m*, *n*, *k*, *index*, *value*) TVM 张量核心 fill_fragment 运算符的内在函数。 * **参数:** - * **fragment** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)):wmma 片段。 - * **m** (*UIntImm*):wmma 片段的形状。 - * **n** (*UIntImm*)[:](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-matrix-instructions-for-sparse-mma)wmma 片段的形状。 - * **k** (*UIntImm*)[:](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-matrix-instructions-for-sparse-mma)wmma 片段的形状。 - * **index** (*Expr*)[:](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-matrix-instructions-for-sparse-mma)片段索引。 - * **value** (*Expr*)[:](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-matrix-instructions-for-sparse-mma)片段中要填充的值。 + * **fragment** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)):wmma 片段。 + * **m** (*UIntImm*) - wmma 片段的形状。 + * **n** (*UIntImm*) - wmma 片段的形状。 + * **k** (*UIntImm*) - wmma 片段的形状。 + * **index** (*Expr*) - 片段索引。 + * **value** (*Expr*) - 片段中要填充的值。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.ptx_mma(*dtype*, *shape*, *A_layout*, *B_layout*, *A_dtype*, *B_dtype*, *C_dtype*, *multiplicand_a*, *a_index*, *multiplicand_b*, *b_index*, *accumulator*, *c_index*, *saturate*, *operator=None*) @@ -1461,55 +1461,55 @@ TVM 内在的 ptx 张量核心 mma 指令 [https://docs.nvidia.com/cuda/parallel * **A_dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):被乘数片段 A 的数据类型。 * **B_dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str))**:** 被乘数片段 B 的数据类型。 * **C_dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):累加器片段 C 的数据类型。 - * **multiplicand_a** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)):被乘数片段 A 变量。 + * **multiplicand_a** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)):被乘数片段 A 变量。 * **a_index** (*Expr*)*:* 被乘数片段 A 的索引。 - * **multiplicand_b** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)):被乘数片段 B 变量。 + * **multiplicand_b** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)):被乘数片段 B 变量。 * **b_index** (*Expr*):被乘数片段 A 的索引。 - * **accumulator** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)):累加器片段 C 变量。 + * **accumulator** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)):累加器片段 C 变量。 * **c_index** (*Expr*):累加器片段 C 的索引。 * **saturate** ([bool](https://docs.python.org/3/library/functions.html#bool)):输出处的可选饱和度。 * **operator** (*Optional**[****Literal**[****"xor"**,*** ***"and"****]]*):1 位运算符。 * **返回:call:** 调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.ptx_mma_sp(*dtype*, *shape*, *A_layout*, *B_layout*, *A_dtype*, *B_dtype*, *C_dtype*, *multiplicand_a*, *a_index*, *multiplicand_b*, *b_index*, *accumulator*, *c_index*, *metadata*, *meta_index*, *sparse_selector*, *saturate*) TVM 稀疏张量核心 ptx 指令的内在函数 [https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-matrix-instructions-for-sparse-mma](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-matrix-instructions-for-sparse-mma)。 * **参数:** - * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str))[:](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-matrix-instructions-ldmatrix)结果的数据类型。 - * **shape** ([str](https://docs.python.org/3/library/stdtypes.html#str))[:](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-matrix-instructions-ldmatrix)mma 片段的形状。 - * **A_layout** (*Literal**[****"row"**,*** ***"col"****]*)[:](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-matrix-instructions-ldmatrix)被乘数片段 A 的布局。 + * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):结果的数据类型。 + * **shape** ([str](https://docs.python.org/3/library/stdtypes.html#str)):mma 片段的形状。 + * **A_layout** (*Literal**[****"row"**,*** ***"col"****]*):被乘数片段 A 的布局。 * **B_layout** (*Literal**[****"row"**,*** ***"col"****]*):被乘数片段 B 的布局。 * **A_dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):被乘数片段 A 的数据类型。 * **B_dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):被乘数片段 B 的数据类型。 * **C_dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):被乘数片段 C 的数据类型。 - * **multiplicand_a** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)):被乘数片段 A 变量。 + * **multiplicand_a** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)):被乘数片段 A 变量。 * **a_index** (*Expr*)**:** 被乘数片段 A 的索引。 - * **multiplicand_b** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)):被乘数片段 B 变量。 + * **multiplicand_b** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)):被乘数片段 B 变量。 * **b_index** (*Expr*):被乘数片段 B 的索引。 - * **accumulator** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var))*:* 累加器片段 C 变量。 + * **accumulator** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none))*:* 累加器片段 C 变量。 * **c_index** (*Expr*):累加器片段 C 的索引。 * **metadata** (*Expr*):操作数的元数据。 - * **meta_index** (*Expr*)[:](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async)操作数的元数据索引。 - * **sparse_selector** (*Expr*)[:](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async)指示存储元数据的线程的稀疏选择器。 - * **saturate** ([bool](https://docs.python.org/3/library/functions.html#bool))[:](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async)输出处的可选饱和度。 + * **meta_index** (*Expr*):操作数的元数据索引。 + * **sparse_selector** (*Expr*):指示存储元数据的线程的稀疏选择器。 + * **saturate** ([bool](https://docs.python.org/3/library/functions.html#bool)):输出处的可选饱和度。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.mma_store(*dtype*, *m*, *n*, *dst_ptr*, *src_ptr*, *src_offset*, *dst_stride*) TVM 内部函数,用于将 PTX MMA 的结果存储到目标指针中。 * **参数:** * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str))**:** 结果的数据类型。 - * **m** ([IntImm](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IntImm))**:** mma 片段的形状。 - * **n** ([IntImm](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IntImm)):mma 片段的形状。 - * **dst_ptr** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var))*:* 目标指针变量。 - * **src_ptr** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var))*:* 源指针变量。 + * **m** ([IntImm](/docs/api-reference/python-api/tvm-tir#class-tvmtirintimmdtypestr-valueint-spanspannone-none))**:** mma 片段的形状。 + * **n** ([IntImm](/docs/api-reference/python-api/tvm-tir#class-tvmtirintimmdtypestr-valueint-spanspannone-none)):mma 片段的形状。 + * **dst_ptr** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none))*:* 目标指针变量。 + * **src_ptr** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none))*:* 源指针变量。 * **src_offset** (*Expr*)*:* 源偏移量。 - * **dst_stride** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)):目标步幅。 + * **dst_stride** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)):目标步幅。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.mma_fill(*dtype*, *local_size*, *local_ptr*, *offset*) @@ -1517,69 +1517,69 @@ TVM 内部函数,用于将 PTX MMA 的结果存储到目标指针中。 TVM 内在函数,用于对 MMA 累积寄存器进行零初始化。 * **参数:** * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str))**:** 结果的数据类型。 - * **local_size** ([IntImm](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IntImm)):元素的数量。 - * **local_ptr** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var))**:** 目标指针变量。 + * **local_size** ([IntImm](/docs/api-reference/python-api/tvm-tir#class-tvmtirintimmdtypestr-valueint-spanspannone-none)):元素的数量。 + * **local_ptr** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none))**:** 目标指针变量。 * **offset** (*Expr*)**:** 目标偏移量。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.ptx_ldmatrix(*dtype*, *trans*, *num*, *type*, *local_ptr*, *local_offset*, *smem_ptr*, *smem_offset*) TVM 内部函数,用于从共享内存中加载 ptx 矩阵 [https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-matrix-instructions-ldmatrix](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-matrix-instructions-ldmatrix)。 * **参数:** - * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str))[:](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async-commit-group)结果的数据类型。 - * **trans** ([bool](https://docs.python.org/3/library/functions.html#bool))[:](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async-commit-group)矩阵以列主格式加载。 - * **num** ([IntImm](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IntImm)):矩阵的数量。 + * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):结果的数据类型。 + * **trans** ([bool](https://docs.python.org/3/library/functions.html#bool)):矩阵以列主格式加载。 + * **num** ([IntImm](/docs/api-reference/python-api/tvm-tir#class-tvmtirintimmdtypestr-valueint-spanspannone-none)):矩阵的数量。 * **type** (*Literal**[****".b16"]*):矩阵的数据类型。 - * **local_ptr** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)):本地指针变量。 - * **local_offset** (*Expr*)[:](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async-wait-group)本地指针的偏移量。 - * **smem_ptr** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var))[:](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async-wait-group)共享内存指针变量。 - * **smem_offset** (*Expr*)[:](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async-wait-group)共享内存指针的偏移量。 + * **local_ptr** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)):本地指针变量。 + * **local_offset** (*Expr*):本地指针的偏移量。 + * **smem_ptr** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)):共享内存指针变量。 + * **smem_offset** (*Expr*):共享内存指针的偏移量。 * **返回:call:** 调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.ptx_cp_async(*dtype*, *shared_ptr*, *shared_offset*, *global_ptr*, *global_offset*, *bytes*) TVM 内部使用 cp.async 将 ptx 异步复制到从全局到共享内存 [https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async)。 * **参数:** - * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str))[:](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-cp-async-mbarrier-arrive)结果的数据类型。 - * **shared_ptr** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var))**:** 共享内存指针变量。 + * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):结果的数据类型。 + * **shared_ptr** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none))**:** 共享内存指针变量。 * **shared_offset** (*Expr*):共享内存指针的偏移量。 - * **global_ptr** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)):全局内存指针变量。 + * **global_ptr** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)):全局内存指针变量。 * **global_offset** (*Expr*):全局内存指针的偏移量。 * **bytes** ([int](https://docs.python.org/3/library/functions.html#int)):要复制的数据大小。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ## tvm.tir.ptx_cp_async_bulk(*dtype*, *shared_ptr*, *shared_offset*, *global_ptr*, *global_offset*, *bytes*, *barrier_id*) TVM 使用 cp.async.bulk 将 ptx 异步复制到从全局到共享内存的内在 [函数 https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async-bulk](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async-bulk)。 * **参数:** * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):结果的数据类型。 - * **shared_ptr** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var))[:](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-mbarrier-arrive)共享内存指针变量。 - * **shared_offset** (*Expr*)[:](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-mbarrier-arrive)共享内存指针的偏移量。 - * **global_ptr** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var))[:](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-mbarrier-arrive)全局内存指针变量。 + * **shared_ptr** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)):共享内存指针变量。 + * **shared_offset** (*Expr*):共享内存指针的偏移量。 + * **global_ptr** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)):全局内存指针变量。 * **global_offset** (*Expr*)**:** 全局内存指针的偏移量。 * **bytes** ([int](https://docs.python.org/3/library/functions.html#int))**:** 要复制的数据大小。 * **barrier_id** ([int](https://docs.python.org/3/library/functions.html#int)):屏障共享内存指针的 ID。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.ptx_commit_group() TVM ptx 异步复制提交内在函数 [https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async-commit-group](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async-commit-group)。 -* **返回:call**[:](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-mbarrier-arrive)调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回:call**:调用表达式。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.ptx_wait_group(*num*) TVM 内部用于 ptx 异步复制等待 [https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async-wait-group](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async-wait-group)。 * **参数:num** ([int](https://docs.python.org/3/library/functions.html#int)):要等待的最近未提交的待处理 cp.async 组的数量。 * **返回:call:** 调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.ptx_cp_async_barrier(*barrier_id*) @@ -1587,7 +1587,7 @@ TVM 内部用于 ptx 异步复制等待 [https://docs.nvidia.com/cuda/parallel-t TVM 使用 cp.async.mbarrier.arrive 实现 ptx 异步复制屏障的内在机制 [https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-cp-async-mbarrier-arrive](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-cp-async-mbarrier-arrive)。 * **参数:barrier_id** ([int](https://docs.python.org/3/library/functions.html#int)):屏障共享内存指针的 ID。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.ptx_init_barrier_thread_count(*barrier_id*, *thread_count*) @@ -1597,7 +1597,7 @@ TVM 使用 mbarrier.init 来初始化线程数的 ptx 屏障 [https://docs.nvidi * **barrier_id** ([int](https://docs.python.org/3/library/functions.html#int)):屏障共享内存指针的 ID。 * **thread_count** ([int](https://docs.python.org/3/library/functions.html#int)):预计到达屏障的线程数。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.ptx_arrive_barrier(*barrier_id*) @@ -1605,7 +1605,7 @@ TVM 使用 mbarrier.init 来初始化线程数的 ptx 屏障 [https://docs.nvidi TVM 使用 mbarrier.arrive 实现 ptx 屏障到达的内在机制 [https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-mbarrier-arrive](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-mbarrier-arrive)。 * **参数:barrier_id** ([int](https://docs.python.org/3/library/functions.html#int)):屏障共享内存指针的 ID。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.ptx_arrive_barrier_expect_tx(*barrier_id*, *byte_count*) @@ -1615,7 +1615,7 @@ TVM 内在函数,用于使用 mbarrier.arrive.expect_tx 实现 ptx 屏障到 * **barrier_id** ([int](https://docs.python.org/3/library/functions.html#int)):屏障共享内存指针的 ID。 * **byte_count** ([int](https://docs.python.org/3/library/functions.html#int)):增加 mbarrier 对象的 tx 计数以跟踪附加异步事务的完成情况。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.ptx_wait_barrier(*barrier_id*) @@ -1623,72 +1623,72 @@ TVM 内在函数,用于使用 mbarrier.arrive.expect_tx 实现 ptx 屏障到 TVM 使用 mbarrier.try_wait 等待 ptx 屏障的内在机制 [https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-mbarrier-test-wait-mbarrier-try-wait](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-mbarrier-test-wait-mbarrier-try-wait)。 * **参数:barrier_id** ([int](https://docs.python.org/3/library/functions.html#int)):屏障共享内存指针的 ID。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.create_barriers(*barrier_count*) TVM 固有创建 N 个屏障。 -* **参数:barrier_count** ([int](https://docs.python.org/3/library/functions.html#int))[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)要创建的障碍数量。 +* **参数:barrier_count** ([int](https://docs.python.org/3/library/functions.html#int)):要创建的障碍数量。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -## tvm.tir.make_filled_simdgroup_matrix(*d:*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var), *index:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *value:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *col:*[int](https://docs.python.org/3/library/functions.html#int)*= 8*, *row:*[int](https://docs.python.org/3/library/functions.html#int)*= 8*) +## tvm.tir.make_filled_simdgroup_matrix(*d:*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none), *index:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *value:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *col:*[int](https://docs.python.org/3/library/functions.html#int)*= 8*, *row:*[int](https://docs.python.org/3/library/functions.html#int)*= 8*) 创建填充的 SIMDGroup 矩阵。 * **参数:** * **d** (*var*):simdgroup var。 - * **index** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))**:** 矩阵的索引。 - * **value** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):要填充的值。 + * **index** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))**:** 矩阵的索引。 + * **value** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):要填充的值。 * **col** ([int](https://docs.python.org/3/library/functions.html#int))*:* 列数。 * **row** ([int](https://docs.python.org/3/library/functions.html#int)):行数。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -## tvm.tir.simdgroup_load(*d:*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var), *index:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *ptr:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *stride:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *col:*[int](https://docs.python.org/3/library/functions.html#int)*= 8*, *row:*[int](https://docs.python.org/3/library/functions.html#int)*= 8*, *transpose_matrix:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) +## tvm.tir.simdgroup_load(*d:*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none), *index:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *ptr:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *stride:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *col:*[int](https://docs.python.org/3/library/functions.html#int)*= 8*, *row:*[int](https://docs.python.org/3/library/functions.html#int)*= 8*, *transpose_matrix:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) 将数据从设备内存或线程组内存加载到 simdgroup。 * **参数:** * **d** (*var*)**:** simdgroup var。 - * **index** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):矩阵的索引。 - * **ptr** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))*:* 指针。 - * **stride** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):步幅。 + * **index** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):矩阵的索引。 + * **ptr** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))*:* 指针。 + * **stride** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):步幅。 * **col** ([int](https://docs.python.org/3/library/functions.html#int)):列数。 * **row** ([int](https://docs.python.org/3/library/functions.html#int)):行数。 * **transpose_matrix** ([bool](https://docs.python.org/3/library/functions.html#bool)):是否转置矩阵。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -## tvm.tir.simdgroup_multiply_accumulate(*d:*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var), *index_d:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *a:*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var), *index_a:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *b:*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var), *index_b:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *c:*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var), *index_c:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)) +## tvm.tir.simdgroup_multiply_accumulate(*d:*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none), *index_d:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *a:*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none), *index_a:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *b:*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none), *index_b:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *c:*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none), *index_c:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)) 在 simdgroup 中对两个矩阵进行乘法和累加,即 d = a * b + c。 * **参数:** - * **d** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)):目标矩阵。 - * **index_d** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):目标矩阵的索引。 - * **a** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var))**:** 第一个矩阵。 - * **index_a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):第一个矩阵的索引。 - * **b** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)):第二个矩阵。 - * **index_b** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):第二个矩阵的索引。 - * **c** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)):第三个矩阵。 - * **index_c** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):第三个矩阵的索引。 + * **d** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)):目标矩阵。 + * **index_d** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):目标矩阵的索引。 + * **a** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none))**:** 第一个矩阵。 + * **index_a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):第一个矩阵的索引。 + * **b** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)):第二个矩阵。 + * **index_b** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):第二个矩阵的索引。 + * **c** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)):第三个矩阵。 + * **index_c** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):第三个矩阵的索引。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -## tvm.tir.simdgroup_store(*d:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *index:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *ptr:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *stride:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *col:*[int](https://docs.python.org/3/library/functions.html#int)*= 8*, *row:*[int](https://docs.python.org/3/library/functions.html#int)*= 8*, *transpose_matrix:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) +## tvm.tir.simdgroup_store(*d:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *index:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *ptr:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *stride:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *col:*[int](https://docs.python.org/3/library/functions.html#int)*= 8*, *row:*[int](https://docs.python.org/3/library/functions.html#int)*= 8*, *transpose_matrix:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) 将数据从 simdgroup 存储到设备内存或线程组内存。 * **参数:** - * **d** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):SIMDGroup。 - * **index** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):矩阵的索引。 - * **ptr** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):指针。 - * **stride** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):步幅。 + * **d** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):SIMDGroup。 + * **index** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):矩阵的索引。 + * **ptr** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):指针。 + * **stride** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):步幅。 * **col** ([int](https://docs.python.org/3/library/functions.html#int)):列数。 * **row** ([int](https://docs.python.org/3/library/functions.html#int)):行数。 * **transpose_matrix:bool** 是否转置矩阵。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.vectorlow(*dtype*, *vec*) @@ -1697,8 +1697,8 @@ TVM 固有创建 N 个屏障。 * **参数:** * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):结果的数据类型。 * **vec** ([list](https://docs.python.org/3/library/stdtypes.html#list)):输入向量。 -* **返回:call**[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回:call**:调用表达式。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.vectorhigh(*dtype*, *vec*) @@ -1708,7 +1708,7 @@ TVM 固有创建 N 个屏障。 * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):结果的数据类型。 * **vec** ([list](https://docs.python.org/3/library/stdtypes.html#list)):输入向量。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.vectorcombine(*dtype*, *vec1*, *vec2*) 连接两个向量。 @@ -1716,25 +1716,25 @@ TVM 固有创建 N 个屏障。 * **vec1** ([list](https://docs.python.org/3/library/stdtypes.html#list)):输入向量。 * **vec2** ([list](https://docs.python.org/3/library/stdtypes.html#list)):输入向量。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -## tvm.tir.infinity(*dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Any](https://docs.python.org/3/library/typing.html#typing.Any) +## tvm.tir.infinity(*dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Any](https://docs.python.org/3/library/typing.html#typing.Any) 数据类型的无穷大值。 * **参数:** * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):数据类型。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:value**:dtype 的无穷大值。 * **返回类型:** tvm.Expr。 -## tvm.tir.reinterpret(*dtype*, *value*, *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Any](https://docs.python.org/3/library/typing.html#typing.Any) +## tvm.tir.reinterpret(*dtype*, *value*, *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Any](https://docs.python.org/3/library/typing.html#typing.Any) 数据类型的无穷大值。 * **参数:** * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):数据类型。 - * **value** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入值。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **value** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入值。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:value**:重新解释 dtype 的转换值。 * **返回类型:** tvm.Expr。 @@ -1742,278 +1742,278 @@ TVM 固有创建 N 个屏障。 取输入 x 的指数。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.exp2(*x*) 计算 2**x。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ## tvm.tir.exp10(*x*) 计算 10**x。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.log(*x*) 对输入 x 取对数。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y** *:* 结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ## tvm.tir.log2(*x*) 对输入 x 取 log2。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))**:** 输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))**:** 输入参数。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.log10(*x*) 对输入 x 取 log10。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))*:* 输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))*:* 输入参数。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.log1p(*x*) 对输入 x 取 log(x + 1)。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.ldexp(*x1*, *x2*) 返回 x1 * (2 ** x2)。 * **参数:** - * **x1** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)输入参数。 - * **x2** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))*:* 输入参数。 + * **x1** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 + * **x2** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))*:* 输入参数。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.clz(*x*) 计算整数 x 的前导零位。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入 32 位或 64 位整数。如果输入为 0,则结果未定义。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入 32 位或 64 位整数。如果输入为 0,则结果未定义。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.sin(*x*) 对输入 x 取正弦值。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.sinh(*x*) 对输入 x 取 sinh。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))**:** 输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))**:** 输入参数。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ## tvm.tir.asin(*x*) 取输入 x 的 asin。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.asinh(*x*) 取输入 x 的正弦值。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.cos(*x*) 取输入 x 的 cos。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y** *:* 结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.cosh(*x*) 对输入 x 取余弦值。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))**:** 输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))**:** 输入参数。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.acos(*x*) 对输入 x 取余数。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.acosh(*x*) 对输入 x 取余数。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 -* **返回:y**[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 +* **返回:y**:结果。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.tan(*x*) 对输入 x 取 tan。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 -* **返回:y**[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 +* **返回:y**:结果。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.tanh(*x*) 对输入 x 取双曲 tanh。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.atan(*x*) 对输入 x 取正切值。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.atan2(*x1*, *x2*) 取 arctan2(x1, x2)。 * **参数:** - * **x1** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 - * **x2** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 + * **x1** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 + * **x2** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.atanh(*x*) 对输入 x 进行 atanh 处理。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))**:** 输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))**:** 输入参数。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.bitwise_and(*x*, *y*, *span=None*) 对两个值进行按位与运算。 * **参数:** - * **x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):左操作数。 - * **y** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):右操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):左操作数。 + * **y** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):右操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:res**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.bitwise_not(*x*, *span=None*) 对输入值进行按位非。 * **参数:** - * **x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:res**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.bitwise_or(*x*, *y*, *span=None*) 对两个值进行按位或操作。 * **参数:** - * **x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))[:](https://en.cppreference.com/w/cpp/numeric/math/round)左操作数。 - * **y** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))[:](https://en.cppreference.com/w/cpp/numeric/math/round)右操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)[:](https://en.cppreference.com/w/cpp/numeric/math/nearbyint)此运算符在源代码中的位置。 + * **x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):左操作数。 + * **y** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):右操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:res**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.bitwise_xor(*x*, *y*, *span=None*) 对两个值进行按位异或。 * **参数:** - * **x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):左操作数。 - * **y** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))*:* 右操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):左操作数。 + * **y** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))*:* 右操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:res**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.erf(*x*) 取输入 x 的高斯误差函数。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y** *:* 结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.sigmoid(*x*) 快速获取 S 形函数。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))*:* 输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))*:* 输入参数。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.sqrt(*x*) 对输入 x 取平方根。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.rsqrt(*x*) 取输入 x 的平方根的倒数。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.floor(*x: PrimExprWithOp*, *span=None*) 取浮点输入 x 的下限。 * **参数:** - * **x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))*:* 输入参数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)此运算符在源代码中的位置。 + * **x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))*:* 输入参数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.ceil(*x*, *span=None*) 对浮点输入 x 取上限。 * **参数:** - * **x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)**:** 此运算符在源代码中的位置。 + * **x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)**:** 此运算符在源代码中的位置。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.hypot(*x1*, *x2*) 相当于 sqrt(x1**2 + x2**2),逐个元素。 * **参数:** - * **x1** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 - * **x2** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 + * **x1** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 + * **x2** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y:** 结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.trunc(*x*, *span=None*) @@ -2023,101 +2023,101 @@ TVM 固有创建 N 个屏障。 标量 x 的截断值是最接近的整数 i,它比 x 更接近零。 * **参数:** - * **x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.abs(*x*, *span=None*) 逐个获取输入元素的绝对值。 * **参数:** - * **x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))*:* 输入参数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)**:** 此运算符在源代码中的位置。 + * **x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))*:* 输入参数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)**:** 此运算符在源代码中的位置。 * **返回:y:** 结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.round(*x*, *span=None*) 将数组元素四舍五入为最接近的整数。 * **参数:** - * **x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:y** *:* 结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.nextafter(*x1*, *x2*) 返回在 x1 和 x2 之间,比 x1 更接近 x2 的下一个浮点数。 * **参数:** - * **x1** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 - * **x2** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))*:*输入参数。 + * **x1** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 + * **x2** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))*:*输入参数。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.nearbyint(*x*, *span=None*) 将数组元素四舍五入为最接近的整数。此内在函数使用 llvm.nearbyint 而不是 llvm.round,后者速度更快,但结果与 te.round 不同。值得注意的是,nearbyint 根据舍入模式进行舍入,而 te.round (llvm.round) 则忽略该模式。有关两者之间的差异,请参阅: https: [//en.cppreference.com/w/cpp/numeric/math/round](https://en.cppreference.com/w/cpp/numeric/math/round) [https://en.cppreference.com/w/cpp/numeric/math/nearbyint](https://en.cppreference.com/w/cpp/numeric/math/nearbyint)。 * **参数:** - * **x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)输入参数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.power(*x*, *y*, *span=None*) x 次方 y。 * **参数:** - * **x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 - * **y** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):指数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 + * **y** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):指数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:z**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.pow(*x*, *y*, *span=None*) x 次方 y。 * **参数:** - * **x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))*:* 输入参数。 - * **y** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):指数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))*:* 输入参数。 + * **y** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):指数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:z**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.popcount(*x*) 计算输入 x 中设置位的数量。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.fmod(*x*, *y*) 返回 x 除以 y 后的余数,其符号与 x 相同。 * **参数:** - * **x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)输入参数。 - * **y** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)输入参数。 + * **x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 + * **y** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:z:** 结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.if_then_else(*cond*, *t*, *f*, *span=None*) 条件选择表达式。 * **参数:** - * **cond** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):条件。 - * **t** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))*:* 如果 cond 为真,则结果表达式。 - * **f** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)如果 cond 为假,则结果表达式。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源中的位置。 + * **cond** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):条件。 + * **t** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))*:* 如果 cond 为真,则结果表达式。 + * **f** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):如果 cond 为假,则结果表达式。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源中的位置。 * **返回:result**:条件表达式的结果。 -* **返回类型:**[Node](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Node) +* **返回类型:**[Node](/docs/api-reference/python-api/tvm-ir#class-tvmirnode) -:::Note +:::note 与 Select 不同,if_then_else 不会执行不满足条件的分支。您可以使用它来防止越界访问。与 Select 不同,如果向量中某些通道的条件不同,则 if_then_else 无法进行向量化。 @@ -2128,73 +2128,73 @@ x 次方 y。 将情况标记为可能。 * **参数:** - * **cond** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **cond** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:y** *:* 标记的表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.isnan(*x*, *span=None*) 检查输入值是否为 Nan。 * **参数:** - * **x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))*:* 输入参数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))*:* 输入参数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.isnullptr(*x*, *span=None*) 检查输入值是否为 nullptr。 * **参数:** - * **x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.isfinite(*x*, *span=None*) 检查输入值是否有限。 * **参数:** - * **x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.isinf(*x*, *span=None*) 检查输入值是否无限。 * **参数:** - * **x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:y:** 结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.copysign(*x1*, *x2*) 逐个元素地将 x1 的符号更改为 x2 的符号。 * **参数:** - * **x1** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))*:*输入参数。 - * **x2** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 + * **x1** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))*:*输入参数。 + * **x2** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.div(*a*, *b*, *span=None*) 按照 C/C++ 语义计算 a / b。 * **参数:** - * **a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):左侧操作数,已知为非负数。 - * **b** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):右侧操作数,已知为非负。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源中的位置。 + * **a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):左侧操作数,已知为非负数。 + * **b** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):右侧操作数,已知为非负。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源中的位置。 * **返回:res**:结果表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -:::Note +:::note 当操作数为整数时,返回 truncdiv(a, b, span)。 @@ -2204,13 +2204,13 @@ x 次方 y。 计算 floor(a / b),其中 a 和 b 为非负数。 * **参数:** - * **a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):左侧操作数,已知为非负数。 - * **b** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):右侧操作数,已知为非负。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)*:* 此运算符在源中的位置。 + * **a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):左侧操作数,已知为非负数。 + * **b** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):右侧操作数,已知为非负。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)*:* 此运算符在源中的位置。 * **返回:res** *:* 结果表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -:::Note +:::note 使用此函数拆分非负索引。此函数可以利用操作数的非负性。 @@ -2221,30 +2221,30 @@ x 次方 y。 计算 indexdiv 的余数。a 和 b 非负。 * **参数:** - * **a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))**:** 左侧操作数,已知为非负数。 - * **b** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):右侧操作数,已知为非负。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源中的位置。 + * **a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))**:** 左侧操作数,已知为非负数。 + * **b** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):右侧操作数,已知为非负。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源中的位置。 * **返回:res**:结果表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -:::Note +:::note 使用此函数拆分非负索引。此函数可以利用操作数的非负性。 ::: -## tvm.tir.truncdiv(*a*, *b*, *span=None*)[](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.truncdiv) +## tvm.tir.truncdiv(*a*, *b*, *span=None*) 计算两个表达式的 truncdiv。 * **参数:** - * **a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):左侧操作数。 - * **b** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):右侧操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源中的位置。 + * **a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):左侧操作数。 + * **b** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):右侧操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源中的位置。 * **返回:res**:结果表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -:::Note +:::note 这是 C 语言中的默认整数除法行为。 @@ -2254,13 +2254,13 @@ x 次方 y。 计算两个表达式的 truncmod。 * **参数:** - * **a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))*:* 左侧操作数。 - * **b** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):右侧操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源中的位置。 + * **a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))*:* 左侧操作数。 + * **b** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):右侧操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源中的位置。 * **返回:res**:结果表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -:::Note +:::note 这是 C 语言中的默认整数除法行为。 @@ -2271,22 +2271,22 @@ x 次方 y。 计算两个表达式的 floordiv。 * **参数:** - * **a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):左侧操作数。 - * **b** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):右侧操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源中的位置。 + * **a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):左侧操作数。 + * **b** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):右侧操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源中的位置。 * **返回:res**:结果表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.floormod(*a*, *b*, *span=None*) 计算两个表达式的 floormod。 * **参数:** - * **a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):左侧操作数。 - * **b** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):右侧操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源中的位置。 + * **a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):左侧操作数。 + * **b** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):右侧操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源中的位置。 * **返回:res**:结果表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.ceildiv(*lhs*, *rhs*, *span=None*) @@ -2295,7 +2295,7 @@ x 次方 y。 * **参数:** * **lhs** ([object](https://docs.python.org/3/library/functions.html#object)):左操作数。 * **rhs** ([object](https://docs.python.org/3/library/functions.html#object))*:* 右操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)此运算符在源中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源中的位置。 * **返回:op**:ceildiv 运算的结果 Expr。 * **返回类型:** tvm.Expr。 @@ -2304,11 +2304,11 @@ x 次方 y。 计算两个表达式的 logaddexp。 * **参数:** - * **a** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):左侧操作数。 - * **b** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):右侧操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源中的位置。 + * **a** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):左侧操作数。 + * **b** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):右侧操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源中的位置。 * **返回:res**:结果表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.comm_reducer(*fcombine*, *fidentity*, *name='reduce'*) @@ -2340,11 +2340,11 @@ B = te.compute((n,), lambda i: mysum(A[i, k], axis=k), name="B") 在轴上创建最小表达式。 * **参数:** - * **expr** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)源表达式。 - * **axis** ([IterVar](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IterVar))*:* 缩减 IterVar 轴。 + * **expr** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):源表达式。 + * **axis** ([IterVar](range-varvarstr-iter_typeint-thread_tagstr--spanspannone-none))*:* 缩减 IterVar 轴。 * **where** (*optional,Expr*):归约操作的过滤条件。 * **返回:value**:结果值。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **示例** @@ -2369,11 +2369,11 @@ min_res = tvm.min(m, n) 在轴上创建最大表达式。 * **参数:** - * **expr** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):源表达式。 - * **axis** ([IterVar](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IterVar)):缩减 IterVar 轴。 + * **expr** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):源表达式。 + * **axis** ([IterVar](range-varvarstr-iter_typeint-thread_tagstr--spanspannone-none)):缩减 IterVar 轴。 * **where** (*optional,Expr*)*:*归约操作的过滤谓词。 * **返回:value**:结果值。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **示例** @@ -2398,11 +2398,11 @@ max_res = tvm.max(m, n) 在轴上创建一个求和表达式。 * **参数:** - * **expr** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):源表达式。 - * **axis** ([IterVar](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IterVar)):缩减 IterVar 轴。 + * **expr** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):源表达式。 + * **axis** ([IterVar](range-varvarstr-iter_typeint-thread_tagstr--spanspannone-none)):缩减 IterVar 轴。 * **where** (*optional,Expr*):归约操作的过滤条件。 * **返回:value**:结果值。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **示例** @@ -2432,47 +2432,47 @@ out = round(x*y*2^-s) 输出 = 舍入(x*y*2^-s) 。 有关 Q 数的更多信息,请参见:[https://en.wikipedia.org/wiki/Q_(number_format](https://en.wikipedia.org/wiki/Q*(number_format)) 舍入规则是舍入到最接近的值,将一半向上舍入(即,round(x.1) = x 和 round (x.5) = x+1)。 * **参数:** - * **x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))**:** 第一个 Q 数。 - * **y** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):第二个 Q 数。 - * **q** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):x 和 y 中的小数位数。必须大于 0。 - * **s** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))**:** 数移位。 + * **x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))**:** 第一个 Q 数。 + * **y** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):第二个 Q 数。 + * **q** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):x 和 y 中的小数位数。必须大于 0。 + * **s** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))**:** 数移位。 * **返回:y**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -## tvm.tir.q_multiply_shift_per_axis(*x:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *y:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *ls:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *rs:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *q:*[IntImm](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IntImm), *is_lshift_required:*[IntImm](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IntImm), *is_rshift_required:*[IntImm](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IntImm)) +## tvm.tir.q_multiply_shift_per_axis(*x:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *y:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *ls:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *rs:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *q:*[IntImm](/docs/api-reference/python-api/tvm-tir#class-tvmtirintimmdtypestr-valueint-spanspannone-none), *is_lshift_required:*[IntImm](/docs/api-reference/python-api/tvm-tir#class-tvmtirintimmdtypestr-valueint-spanspannone-none), *is_rshift_required:*[IntImm](/docs/api-reference/python-api/tvm-tir#class-tvmtirintimmdtypestr-valueint-spanspannone-none)) 执行两个 Q 数字 x 和 y 之间的乘法。 * **参数:** - * **x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))*:* 第一个 Q 数。 - * **y** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):第二个 Q 号。 - * **ls** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):整数左移。 - * **rs** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))*:* 整数右移。 - * **q** ([IntImm](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IntImm))**:** x 和 y 的小数位数。必须大于 0。 - * **is_lshift_required** ([IntImm](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IntImm)):我们是否需要进行左移。 - * **is_rshift_required** ([IntImm](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IntImm))[:](https://docs.python.org/3/library/functions.html#object)我们是否需要进行右移。 -* **返回:z**[:](https://docs.python.org/3/library/functions.html#object)结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 + * **x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))*:* 第一个 Q 数。 + * **y** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):第二个 Q 号。 + * **ls** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):整数左移。 + * **rs** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))*:* 整数右移。 + * **q** ([IntImm](/docs/api-reference/python-api/tvm-tir#class-tvmtirintimmdtypestr-valueint-spanspannone-none))**:** x 和 y 的小数位数。必须大于 0。 + * **is_lshift_required** ([IntImm](/docs/api-reference/python-api/tvm-tir#class-tvmtirintimmdtypestr-valueint-spanspannone-none)):我们是否需要进行左移。 + * **is_rshift_required** ([IntImm](/docs/api-reference/python-api/tvm-tir#class-tvmtirintimmdtypestr-valueint-spanspannone-none)):我们是否需要进行右移。 +* **返回:z**:结果。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.shift_left(*x*, *y*, *span=None*) 返回 x 左移 y 位的结果。 * **参数:** - * **x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 - * **y** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))*:* 输入参数。 + * **x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 + * **y** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))*:* 输入参数。 * **返回:z:** 结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.shift_right(*x*, *y*, *span=None*) 返回 x 右移 y 位的结果。 * **参数:** - * **x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 - * **y** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 + * **x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 + * **y** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:z**:结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.TVMBackendAllocWorkspace(*device_type*, *device_id*, *nbytes*, *dtype_code_hint*, *dtype_bits_hint*) @@ -2485,7 +2485,7 @@ out = round(x*y*2^-s) 输出 = 舍入(x*y*2^-s) 。 * **dtype_code_hint** ([int](https://docs.python.org/3/library/functions.html#int)):数组元素的类型代码。仅在某些后端(例如 OpenGL)中使用。 * **dtype_bits_hint** ([int](https://docs.python.org/3/library/functions.html#int))**:** 数组元素的类型位。仅在某些后端(例如 OpenGL)中使用。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.TVMBackendFreeWorkspace(*device_type*, *device_id*, *ptr*) @@ -2494,23 +2494,23 @@ out = round(x*y*2^-s) 输出 = 舍入(x*y*2^-s) 。 * **参数:** * **device_type** ([int](https://docs.python.org/3/library/functions.html#int)):将分配空间的设备类型。 * **device_id** ([int](https://docs.python.org/3/library/functions.html#int)):将分配空间的设备 ID。 - * **ptr** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)):结果分配的空间指针。 + * **ptr** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)):结果分配的空间指针。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.start_profile_intrinsic(*id*) 启动配置文件内在。:param id:内在 id。:type id:int。 * **返回:call:** 调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.end_profile_intrinsic(*id*) 结束配置文件内在:param id:内在 id:type id:int。 * **返回:call***:*调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.tir.vscale() @@ -2526,10 +2526,10 @@ out = round(x*y*2^-s) 输出 = 舍入(x*y*2^-s) 。 它将被降低到 llvm.get.active.lane.mask 内在函数。([https://llvm.org/docs/LangRef.html#llvm-get-active-lane-mask-intrinsics](https://llvm.org/docs/LangRef.html#llvm-get-active-lane-mask-intrinsics))。 * **参数:** * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):结果的数据类型。 - * **base** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):表示基数的表达式。 - * **limit** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):表示限制的表达式。 + * **base** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):表示基数的表达式。 + * **limit** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):表示限制的表达式。 -## tvm.tir.get_vscale_expr(*dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype*, *min_size:*[int](https://docs.python.org/3/library/functions.html#int)*= 128*) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +## tvm.tir.get_vscale_expr(*dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*| dtype*, *min_size:*[int](https://docs.python.org/3/library/functions.html#int)*= 128*) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 创建依赖于数据类型的可扩展表达式。 @@ -2544,15 +2544,15 @@ out = round(x*y*2^-s) 输出 = 舍入(x*y*2^-s) 。 * **参数:** * **vec1** (*int8x4*):输入向量。 * **vec2** (*int8x4*):输入向量。 - * **acc** (*int32*)[:](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IfThenElse)累加器。 + * **acc** (*int32*):累加器。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -## tvm.tir.ignore_loop_partition(*predicate*) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +## tvm.tir.ignore_loop_partition(*predicate*) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 注解谓词不被视为循环分区的目标条件。 -* **参数:predicate** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))[:](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.LetStmt)带注解的谓词表达式。 +* **参数:predicate** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):带注解的谓词表达式。 ## tvm.tir.add(*lhs*, *rhs*, *span=None*) @@ -2561,7 +2561,7 @@ out = round(x*y*2^-s) 输出 = 舍入(x*y*2^-s) 。 * **参数:** * **lhs** ([object](https://docs.python.org/3/library/functions.html#object)):左操作数。 * **rhs** ([object](https://docs.python.org/3/library/functions.html#object)):右操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源中的位置。 * **返回:op**:加法运算的结果 Expr。 * **返回类型:** tvm.Expr。 @@ -2571,8 +2571,8 @@ out = round(x*y*2^-s) 输出 = 舍入(x*y*2^-s) 。 通用减法运算符。 * **参数:** * **lhs** ([object](https://docs.python.org/3/library/functions.html#object)):左操作数。 - * **rhs** ([object](https://docs.python.org/3/library/functions.html#object))[:](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Allocate)右操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源中的位置。 + * **rhs** ([object](https://docs.python.org/3/library/functions.html#object)):右操作数。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源中的位置。 * **返回:op**:减法运算的结果 Expr。 * **返回类型:** tvm.Expr。 @@ -2581,13 +2581,13 @@ out = round(x*y*2^-s) 输出 = 舍入(x*y*2^-s) 。 通用乘法运算符。 * **参数:** - * **lhs** ([object](https://docs.python.org/3/library/functions.html#object))[:](https://docs.python.org/3/library/constants.html#None)左操作数。 + * **lhs** ([object](https://docs.python.org/3/library/functions.html#object)):左操作数。 * **rhs** ([object](https://docs.python.org/3/library/functions.html#object)):右操作数。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源中的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源中的位置。 * **返回:op**:乘法运算的结果 Expr。 * **返回类型:** tvm.Expr。 -## *class* tvm.tir.BlockDependenceInfo(*mod:*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)*|*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)) +## *class* tvm.tir.BlockDependenceInfo(*mod:*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)*|*[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)) 使用两个核心对象 BlockScope 和 StmtSRef 帮助构建和查询块级依赖关系的对象。 @@ -2597,40 +2597,40 @@ out = round(x*y*2^-s) 输出 = 舍入(x*y*2^-s) 。 请注意,此对象不存储循环的 SRef,因为其目的仅用于公开块级依赖关系。这带来了一个优势:给定块 sref 的作用域块(父块)可以直接通过 sref->parent 进行访问。 -### get_sref(*block:*[Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block)) → [StmtSRef](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.StmtSRef) | [None](https://docs.python.org/3/library/constants.html#None) +### get_sref(*block:*[Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none)) → [StmtSRef](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulestmtsref) | [None](https://docs.python.org/3/library/constants.html#None) 返回指向该块的相应 sref -* **参数:stmt** ([Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block))[:](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BufferRealize)要检索 sref 的块。 +* **参数:stmt** ([Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none)):要检索 sref 的块。 * **返回:sref**:对应的 sref/ -* **返回类型:**[StmtSRef](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.StmtSRef)/ +* **返回类型:**[StmtSRef](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulestmtsref)/ -### get_block_scope(*block_sref:*[StmtSRef](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.StmtSRef)) → [BlockScope](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockScope) +### get_block_scope(*block_sref:*[StmtSRef](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulestmtsref)) → [BlockScope](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockscope) 获取与块 sref 对应的 BlockScope/。 -* **参数:block_sref** ([StmtSRef](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.StmtSRef)):要检索的块 sref。 +* **参数:block_sref** ([StmtSRef](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulestmtsref)):要检索的块 sref。 * **返回:scope**:对应的 BlockScope。 -* **返回类型:**[StmtSRef](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.StmtSRef)。 +* **返回类型:**[StmtSRef](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulestmtsref)。 -## tvm.tir.build(*mod:*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)*|*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule), *target:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *pipeline:*[None](https://docs.python.org/3/library/constants.html#None)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)*= 'default'*) +## tvm.tir.build(*mod:*[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)*|*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone), *target:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *pipeline:*[None](https://docs.python.org/3/library/constants.html#None)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)*= 'default'*) 构建一个带有签名的函数,为结合目标信息的设备生成代码。 * **参数:** - * **mod** (*Union[*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)*,*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)*]*)**:** 要构建的输入。 - * **target** (*Optional**[****Union**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,*** [Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target)***]****]*)[:](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Evaluate)编译的目标。 - * **pipeline** (*Union**[****None,*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)*]*):用于编译的管道。 + * **mod** (*Union[*[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)*,*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)*]*)**:** 要构建的输入。 + * **target** (*Optional**[****Union**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***,*** [Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone)***]****]*):编译的目标。 + * **pipeline** (*Union**[****None,*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)*]*):用于编译的管道。 * **返回:** 结合主机和设备代码的模块。 * **返回类型:** tvm.runtime.Module。 -## tvm.tir.get_tir_pipeline(*name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'default'*, ***kwargs*) → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.tir.get_tir_pipeline(*name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'default'*, ***kwargs*) → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 按名称获取预构建管道。 * **参数:name** (*Optional[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):管道的名称。 -## tvm.tir.get_default_tir_pipeline(*target:*[Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target)) → [Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +## tvm.tir.get_default_tir_pipeline(*target:*[Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone)) → [Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) 获取给定目标的默认 TIR 管道。 @@ -2643,396 +2643,396 @@ Python StmtExprVisitor 用于为 Stmt 和 PrimExpr 定义自定义访问者。 用户可以自定义任意的访问函数。 -### visit_stmt(*stmt:*[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_stmt(*stmt:*[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)) → [None](https://docs.python.org/3/library/constants.html#None) 访问AttrStmt。 -* **参数:stmt** ([Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)):要访问的 Stmt。 +* **参数:stmt** ([Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)):要访问的 Stmt。 -### visit_expr(*expr:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_expr(*expr:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 PrimExpr。 -* **参数:expr** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):要访问的 PrimExpr。 +* **参数:expr** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):要访问的 PrimExpr。 -### visit_attr_stmt_(*op:*[AttrStmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.AttrStmt)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_attr_stmt_(*op:*[AttrStmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirattrstmtnode-object-attr_keystr-valueprimexpr-bodystmt-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 AttrStmt,用户可以自定义该函数,在 C++ 端覆盖 VisitStmt_(const AttrStmtNode* op)。 -* **参数:op** ([AttrStmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.AttrStmt)):要访问的 AttrStmt。 +* **参数:op** ([AttrStmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirattrstmtnode-object-attr_keystr-valueprimexpr-bodystmt-spanspannone-none)):要访问的 AttrStmt。 -### visit_if_then_else_(*op:*[IfThenElse](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IfThenElse)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_if_then_else_(*op:*[IfThenElse](/docs/api-reference/python-api/tvm-tir#class-tvmtirifthenelseconditionprimexpr-then_casestmt-else_casestmtnone-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 IfThenElse,用户可以自定义该函数,在 C++端覆盖 VisitStmt_(const IfThenElseNode* op)。 -* **参数:op** ([IfThenElse](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IfThenElse)):要访问的 IfThenElse。 +* **参数:op** ([IfThenElse](/docs/api-reference/python-api/tvm-tir#class-tvmtirifthenelseconditionprimexpr-then_casestmt-else_casestmtnone-spanspannone-none)):要访问的 IfThenElse。 -### visit_let_stmt_(*op:*[LetStmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.LetStmt)) → [None](https://docs.python.org/3/library/constants.html#None)[](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PyStmtExprVisitor.visit_let_stmt*) +### visit_let_stmt_(*op:*[LetStmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirletstmtvarvar-valueprimexpr-bodystmt-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 LetStmt。用户可以自定义此函数,在 C++ 端覆盖 VisitStmt_(const LetStmtNode* op)。 -* **参数:op** ([LetStmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.LetStmt)):要访问的 LetStmt。 +* **参数:op** ([LetStmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirletstmtvarvar-valueprimexpr-bodystmt-spanspannone-none)):要访问的 LetStmt。 -### visit_for_(*op:*[For](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.For)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_for_(*op:*[For](/docs/api-reference/python-api/tvm-tir#class-tvmtirforloop_varvar-minprimexpr-extentprimexpr-kindforkind-bodystmt-thread_bindingitervarnone-none-annotationsmappingstr-object-none-none-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 For,用户可以自定义该函数,在 C++ 端覆盖 VisitStmt_(const ForNode* op)。 -* **参数:op** ([For](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.For)):要访问的 For。 +* **参数:op** ([For](/docs/api-reference/python-api/tvm-tir#class-tvmtirforloop_varvar-minprimexpr-extentprimexpr-kindforkind-bodystmt-thread_bindingitervarnone-none-annotationsmappingstr-object-none-none-spanspannone-none)):要访问的 For。 -### visit_while_(*op:*[While](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.While)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_while_(*op:*[While](/docs/api-reference/python-api/tvm-tir#class-tvmtirwhileconditionprimexpr-bodystmt-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 While。用户可以自定义此函数,在 C++ 端覆盖 VisitStmt_(const WhileNode* op)。 -* **参数:op** ([While](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.While)):需要访问的 While 部分。 +* **参数:op** ([While](/docs/api-reference/python-api/tvm-tir#class-tvmtirwhileconditionprimexpr-bodystmt-spanspannone-none)):需要访问的 While 部分。 -### visit_allocate_(*op:*[Allocate](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Allocate)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_allocate_(*op:*[Allocate](/docs/api-reference/python-api/tvm-tir#class-tvmtirallocatebuffer_varvar-dtypestr-extentslistprimexpr-conditionprimexpr-bodystmt-annotationsmappingstr-object-none-none-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) Visit Allocate,用户可以自定义该函数,在 C++端覆盖 VisitStmt_(const AllocateNode* op)。 -* **参数:op** ([Allocate](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Allocate)):要访问的分配。 +* **参数:op** ([Allocate](/docs/api-reference/python-api/tvm-tir#class-tvmtirallocatebuffer_varvar-dtypestr-extentslistprimexpr-conditionprimexpr-bodystmt-annotationsmappingstr-object-none-none-spanspannone-none)):要访问的分配。 -### visit_allocate_const_(*op:*[AllocateConst](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.AllocateConst)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_allocate_const_(*op:*[AllocateConst](/docs/api-reference/python-api/tvm-tir#class-tvmtirallocateconstbuffer_varvar-dtypestr-extentslistprimexpr-data_or_idxndarrayint-bodystmt-annotationsmappingstr-object-none-none-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 AllocateConst,用户可以自定义该函数,在 C++端覆盖 VisitStmt_(const AllocateConstNode* op)。 -* **参数:op** ([AllocateConst](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.AllocateConst)):要访问的 AllocateConst。 +* **参数:op** ([AllocateConst](/docs/api-reference/python-api/tvm-tir#class-tvmtirallocateconstbuffer_varvar-dtypestr-extentslistprimexpr-data_or_idxndarrayint-bodystmt-annotationsmappingstr-object-none-none-spanspannone-none)):要访问的 AllocateConst。 -### visit_decl_buffer_(*op:*[DeclBuffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.DeclBuffer)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_decl_buffer_(*op:*[DeclBuffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirdeclbufferbufferbuffer-bodystmt-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 DeclBuffer,用户可以自定义该函数,在 C++端覆盖 VisitStmt_(const DeclBufferNode* op)。 -* **参数:op** ([DeclBuffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.DeclBuffer)):要访问的 DeclBuffer。 +* **参数:op** ([DeclBuffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirdeclbufferbufferbuffer-bodystmt-spanspannone-none)):要访问的 DeclBuffer。 -### visit_buffer_store_(*op:*[BufferStore](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BufferStore)) → [None](https://docs.python.org/3/library/constants.html#None)[](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PyStmtExprVisitor.visit_buffer_store*) +### visit_buffer_store_(*op:*[BufferStore](/docs/api-reference/python-api/tvm-tir#class-tvmtirbufferStore)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 BufferStore,用户可以自定义该函数,在 C++端覆盖 VisitStmt_(const BufferStoreNode* op)。 -* **参数:op** ([BufferStore](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BufferStore)):要访问的 BufferStore。 +* **参数:op** ([BufferStore](/docs/api-reference/python-api/tvm-tir#class-tvmtirbufferStore)):要访问的 BufferStore。 -### visit_buffer_realize_(*op:*[BufferRealize](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BufferRealize)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_buffer_realize_(*op:*[BufferRealize](/docs/api-reference/python-api/tvm-tir#class-tvmtirbufferRealize)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 BufferRealize,用户可以自定义该函数,在 C++端覆盖 VisitStmt_(const BufferRealizeNode* op)。 -* **参数:op** ([BufferRealize](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BufferRealize)):要访问的 BufferRealize。 +* **参数:op** ([BufferRealize](/docs/api-reference/python-api/tvm-tir#class-tvmtirbufferRealize)):要访问的 BufferRealize。 -### visit_assert_stmt_(*op:*[AssertStmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.AssertStmt)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_assert_stmt_(*op:*[AssertStmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirattrstmtnode-object-attr_keystr-valueprimexpr-bodystmt-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 AssertStmt,用户可以自定义该函数,在 C++端覆盖 VisitStmt_(const AssertStmtNode* op)。 -* **参数:op** ([AssertStmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.AssertStmt)):要访问的 AssertStmt。 +* **参数:op** ([AssertStmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirattrstmtnode-object-attr_keystr-valueprimexpr-bodystmt-spanspannone-none)):要访问的 AssertStmt。 -### visit_seq_stmt_(*op:*[SeqStmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.SeqStmt)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_seq_stmt_(*op:*[SeqStmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirseqstmtseqliststmt-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 SeqStmt,用户可以自定义该函数,在 C++端覆盖 VisitStmt_(const SeqStmtNode* op)。 -* **参数:op** ([SeqStmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.SeqStmt)):要访问的 SeqStmt。 +* **参数:op** ([SeqStmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirseqstmtseqliststmt-spanspannone-none)):要访问的 SeqStmt。 -### visit_evaluate_(*op:*[Evaluate](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Evaluate)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_evaluate_(*op:*[Evaluate](/docs/api-reference/python-api/tvm-tir#class-tvmtirevaluatevalueprimexpr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) Visit Evaluate,用户可以自定义该函数,在 C++端覆盖 VisitStmt_(const EvaluateNode* op)。 -* **参数:op** ([Evaluate](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Evaluate)):要访问的评估。 +* **参数:op** ([Evaluate](/docs/api-reference/python-api/tvm-tir#class-tvmtirevaluatevalueprimexpr-spanspannone-none)):要访问的评估。 -### visit_block_(*op:*[Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_block_(*op:*[Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问区块。用户可以自定义该函数,在 C++端覆盖 VisitStmt_(const BlockNode* op)。 -* **参数:op** ([Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block))[:](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BlockRealize)要访问的区块。 +* **参数:op** ([Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none)):要访问的区块。 -### visit_block_realize_(*op:*[BlockRealize](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BlockRealize)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_block_realize_(*op:*[BlockRealize](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-noneRealize)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 BlockRealize。用户可以自定义此函数,在 C++ 端覆盖 VisitStmt_(const BlockRealizeNode* op)。 -* **参数:op** ([BlockRealize](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BlockRealize)):要访问的 BlockRealize。 +* **参数:op** ([BlockRealize](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-noneRealize)):要访问的 BlockRealize。 -### visit_var_(*op:*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_var_(*op:*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 参观 Var。 用户可以自定义该函数,在 C++端覆盖 VisitVar_(const VarNode* op)。 -* **参数:op** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)):要访问的 tir.Var。 +* **参数:op** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)):要访问的 tir.Var。 -### visit_size_var_(*op:*[SizeVar](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.SizeVar)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_size_var_(*op:*[SizeVar](/docs/api-reference/python-api/tvm-tir#class-tvmtirsizevarnamestr-dtypestrtype-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 SizeVar。 用户可以自定义该函数,在 C++端覆盖 VisitSizeVar_(const SizeVarNode* op)。 -* **参数:op** ([SizeVar](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.SizeVar)):要访问的 SizeVar。 +* **参数:op** ([SizeVar](/docs/api-reference/python-api/tvm-tir#class-tvmtirsizevarnamestr-dtypestrtype-spanspannone-none)):要访问的 SizeVar。 -### visit_buffer_load_(*op:*[BufferLoad](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BufferLoad)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_buffer_load_(*op:*[BufferLoad](/docs/api-reference/python-api/tvm-tir#class-tvmtirbufferLoad)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 BufferLoad。 用户可以自定义该函数,在 C++端覆盖 VisitBufferLoad_(const BufferLoadNode* op)。 -* **参数:op** ([BufferLoad](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BufferLoad))[:](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.ProducerLoad)要访问的 BufferLoad。 +* **参数:op** ([BufferLoad](/docs/api-reference/python-api/tvm-tir#class-tvmtirbufferLoad)):要访问的 BufferLoad。 -### visit_producer_load_(*op:*[ProducerLoad](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.ProducerLoad)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_producer_load_(*op:*[ProducerLoad](/docs/api-reference/python-api/tvm-tir#class-tvmtirproducerloadproducerdataproducer-indiceslistprimexpr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 ProducerLoad。 用户可以自定义该函数,在 C++端覆盖 VisitProducerLoad_(const ProducerLoadNode* op)。 -* **参数:op** ([ProducerLoad](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.ProducerLoad)):要访问的 ProducerLoad。 +* **参数:op** ([ProducerLoad](/docs/api-reference/python-api/tvm-tir#class-tvmtirproducerloadproducerdataproducer-indiceslistprimexpr-spanspannone-none)):要访问的 ProducerLoad。 -### visit_let_(*op:*[Let](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Let)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_let_(*op:*[Let](/docs/api-reference/python-api/tvm-tir#class-tvmtirletvarvar-valueprimexpr-bodyprimexpr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 Let。 用户可以自定义该函数,在 C++端覆盖 VisitLet_(const LetNode* op)。 -* **参数:op** ([Let](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Let)):要访问的 Let。 +* **参数:op** ([Let](/docs/api-reference/python-api/tvm-tir#class-tvmtirletvarvar-valueprimexpr-bodyprimexpr-spanspannone-none)):要访问的 Let。 -### visit_call_(*op:*[Call](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Call)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_call_(*op:*[Call](/docs/api-reference/python-api/tvm-tir#class-tvmtircalldtypestr-opopstr-argslistprimexpr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问调用。 用户可以自定义该函数,在 C++端覆盖 VisitCall_(const CallNode* op)。 -* **参数:op** ([tir.Call](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Call)):要访问的 tir.Call。 +* **参数:op** ([tir.Call](/docs/api-reference/python-api/tvm-tir#class-tvmtircalldtypestr-opopstr-argslistprimexpr-spanspannone-none)):要访问的 tir.Call。 -### visit_add_(*op:*[Add](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Add)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_add_(*op:*[Add](/docs/api-reference/python-api/tvm-tir#class-tvmtiraddaprimexpr-bprimexpr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问添加。 用户可以自定义该函数,在 C++端覆盖 VisitAdd_(const AddNode* op)。 -* **参数:op** ([Add](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Add)):要访问的 Add。 +* **参数:op** ([Add](/docs/api-reference/python-api/tvm-tir#class-tvmtiraddaprimexpr-bprimexpr-spanspannone-none)):要访问的 Add。 -### visit_sub_(*op:*[Sub](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Sub)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_sub_(*op:*[Sub](/docs/api-reference/python-api/tvm-tir#class-tvmtirsubaprimexpr-bprimexpr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 Sub。 用户可以自定义该函数,在 C++端覆盖 VisitSub_(const SubNode* op)。 -* **参数:op** ([Sub](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Sub)):要访问的 Sub。 +* **参数:op** ([Sub](/docs/api-reference/python-api/tvm-tir#class-tvmtirsubaprimexpr-bprimexpr-spanspannone-none)):要访问的 Sub。 -### visit_mul_(*op:*[Mul](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Mul)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_mul_(*op:*[Mul](/docs/api-reference/python-api/tvm-tir#class-tvmtirmulaprimexpr-bprimexpr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 参观 Mul。 用户可以自定义该函数,在 C++端覆盖 VisitMul_(const MulNode* op)。 -* **参数:op** ([Mul](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Mul)):要访问的 Mul。 +* **参数:op** ([Mul](/docs/api-reference/python-api/tvm-tir#class-tvmtirmulaprimexpr-bprimexpr-spanspannone-none)):要访问的 Mul。 -### visit_div_(*op:*[Div](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Div)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_div_(*op:*[Div](/docs/api-reference/python-api/tvm-tir#class-tvmtirdivaprimexpr-bprimexpr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 Div。 用户可以自定义该函数,在 C++端覆盖 VisitDiv_(const DivNode* op)。 -* **参数:op** ([Div](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Div)):要访问的 Div。 +* **参数:op** ([Div](/docs/api-reference/python-api/tvm-tir#class-tvmtirdivaprimexpr-bprimexpr-spanspannone-none)):要访问的 Div。 -### visit_mod_(*op:*[Mod](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Mod)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_mod_(*op:*[Mod](/docs/api-reference/python-api/tvm-tir#class-tvmtirmodaprimexpr-bprimexpr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 Mod。 用户可以自定义该函数,在 C++端覆盖 VisitMod_(const ModNode* op)。 -* **参数:op** ([Mod](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Mod)):要访问的 Mod。 +* **参数:op** ([Mod](/docs/api-reference/python-api/tvm-tir#class-tvmtirmodaprimexpr-bprimexpr-spanspannone-none)):要访问的 Mod。 -### visit_floor_div_(*op:*[FloorDiv](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.FloorDiv)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_floor_div_(*op:*[FloorDiv](/docs/api-reference/python-api/tvm-tir#class-tvmtirfloordivaprimexpr-bprimexpr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 FloorDiv。 用户可以自定义该函数,在 C++端覆盖 VisitFloorDiv_(const FloorDivNode* op)。 -* **参数:op** ([FloorDiv](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.FloorDiv)):要访问的 FloorDiv。 +* **参数:op** ([FloorDiv](/docs/api-reference/python-api/tvm-tir#class-tvmtirfloordivaprimexpr-bprimexpr-spanspannone-none)):要访问的 FloorDiv。 -### visit_floor_mod_(*op:*[FloorMod](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.FloorMod)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_floor_mod_(*op:*[FloorMod](/docs/api-reference/python-api/tvm-tir#class-tvmtirfloormodaprimexpr-bprimexpr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 FloorMod。 用户可以自定义该函数,在 C++端覆盖 VisitFloorMod_(const FloorModNode* op)。 -* **参数:op** ([FloorMod](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.FloorMod)):要访问的 FloorMod。 +* **参数:op** ([FloorMod](/docs/api-reference/python-api/tvm-tir#class-tvmtirfloormodaprimexpr-bprimexpr-spanspannone-none)):要访问的 FloorMod。 -### visit_min_(*op:*[Min](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Min)) → [None](https://docs.python.org/3/library/constants.html#None)[](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PyStmtExprVisitor.visit_min*) +### visit_min_(*op:*[Min](/docs/api-reference/python-api/tvm-tir#class-tvmtirminaprimexpr-bprimexpr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 Min。 用户可以自定义该函数,在 C++端覆盖 VisitMin_(const MinNode* op)。 -* **参数:op** ([Min](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Min)):要访问的 Min。 +* **参数:op** ([Min](/docs/api-reference/python-api/tvm-tir#class-tvmtirminaprimexpr-bprimexpr-spanspannone-none)):要访问的 Min。 -### visit_max_(*op:*[Max](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Max)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_max_(*op:*[Max](/docs/api-reference/python-api/tvm-tir#class-tvmtirmaxaprimexpr-bprimexpr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 Max。 用户可以自定义该函数,在 C++端覆盖 VisitMax_(const MaxNode* op)。 -* **参数:op** ([Max](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Max)):要访问的最大值。 +* **参数:op** ([Max](/docs/api-reference/python-api/tvm-tir#class-tvmtirmaxaprimexpr-bprimexpr-spanspannone-none)):要访问的最大值。 -### visit_eq_(*op:*[EQ](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.EQ)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_eq_(*op:*[EQ](/docs/api-reference/python-api/tvm-tir#class-tvmtireqaprimexpr-bprimexpr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 EQ。 用户可以自定义该函数,在 C++端覆盖 VisitEQ_(const EQNode* op)。 -* **参数:op** ([EQ](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.EQ)):要访问的 EQ。 +* **参数:op** ([EQ](/docs/api-reference/python-api/tvm-tir#class-tvmtireqaprimexpr-bprimexpr-spanspannone-none)):要访问的 EQ。 -### visit_ne_(*op:*[NE](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.NE)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_ne_(*op:*[NE](/docs/api-reference/python-api/tvm-tir#class-tvmtirneaprimexpr-bprimexpr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 NE。 用户可以自定义该函数,在 C++端覆盖 VisitNE_(const NENode* op)。 -* **参数:op** ([NE](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.NE)):要访问的 NE。 +* **参数:op** ([NE](/docs/api-reference/python-api/tvm-tir#class-tvmtirneaprimexpr-bprimexpr-spanspannone-none)):要访问的 NE。 -### visit_lt_(*op:*[LT](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.LT)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_lt_(*op:*[LT](/docs/api-reference/python-api/tvm-tir#class-tvmtirltaprimexpr-bprimexpr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 LT。 用户可以自定义该函数,在 C++端覆盖 VisitLT_(const LTNode* op)。 -* **参数:op** ([LT](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.LT))**:** 要访问的 LT。 +* **参数:op** ([LT](/docs/api-reference/python-api/tvm-tir#class-tvmtirltaprimexpr-bprimexpr-spanspannone-none))**:** 要访问的 LT。 -### visit_le_(*op:*[LE](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.LE)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_le_(*op:*[LE](/docs/api-reference/python-api/tvm-tir#class-tvmtirleaprimexpr-bprimexpr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 LE。 用户可以自定义该函数,在 C++端覆盖 VisitLE_(const LENode* op)。 -* **参数:op** ([LE](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.LE))**:** 要访问的 LE。 +* **参数:op** ([LE](/docs/api-reference/python-api/tvm-tir#class-tvmtirleaprimexpr-bprimexpr-spanspannone-none))**:** 要访问的 LE。 -### visit_gt_(*op:*[GT](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.GT)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_gt_(*op:*[GT](/docs/api-reference/python-api/tvm-tir#class-tvmtirgtaprimexpr-bprimexpr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 GT。 用户可以自定义该函数,在 C++端覆盖 VisitGT_(const GTNode* op)。 -* **参数:op** ([GT](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.GT)):要访问的 GT。 +* **参数:op** ([GT](/docs/api-reference/python-api/tvm-tir#class-tvmtirgtaprimexpr-bprimexpr-spanspannone-none)):要访问的 GT。 -### visit_ge_(*op:*[GE](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.GE)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_ge_(*op:*[GE](/docs/api-reference/python-api/tvm-tir#class-tvmtirgeaprimexpr-bprimexpr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 GE。 用户可以自定义该函数,在 C++端覆盖 VisitGE_(const GENode* op)。 -* **参数:op** ([GE](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.GE)):要访问的 GE。 +* **参数:op** ([GE](/docs/api-reference/python-api/tvm-tir#class-tvmtirgeaprimexpr-bprimexpr-spanspannone-none)):要访问的 GE。 -### visit_and_(*op:*[And](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.And)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_and_(*op:*[And](/docs/api-reference/python-api/tvm-tir#class-tvmtirandaprimexpr-bprimexpr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 And。 用户可以自定义该函数,在 C++端覆盖 VisitAnd_(const AndNode* op)。 -* **参数:op** ([And](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.And)):要访问的 And。 +* **参数:op** ([And](/docs/api-reference/python-api/tvm-tir#class-tvmtirandaprimexpr-bprimexpr-spanspannone-none)):要访问的 And。 -### visit_or_(*op:*[Or](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Or)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_or_(*op:*[Or](/docs/api-reference/python-api/tvm-tir#class-tvmtiroraprimexpr-bprimexpr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 Or。 用户可以自定义该函数,在 C++端覆盖 VisitOr_(const OrNode* op)。 -* **参数:op** ([Or](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Or)):要访问的 Or。 +* **参数:op** ([Or](/docs/api-reference/python-api/tvm-tir#class-tvmtiroraprimexpr-bprimexpr-spanspannone-none)):要访问的 Or。 -### visit_reduce_(*op:*[Reduce](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Reduce)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_reduce_(*op:*[Reduce](/docs/api-reference/python-api/tvm-tir#class-tvmtirreducecombinercommreducer-srclistprimexpr-rdomlistitervar-conditionprimexpr-value_indexint-initlistprimexpr-none-none-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 Reduce。 用户可以自定义该函数,在 C++端覆盖 VisitReduce_(const ReduceNode* op)。 -* **参数:op** ([Reduce](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Reduce)):要访问的 Reduce。 +* **参数:op** ([Reduce](/docs/api-reference/python-api/tvm-tir#class-tvmtirreducecombinercommreducer-srclistprimexpr-rdomlistitervar-conditionprimexpr-value_indexint-initlistprimexpr-none-none-spanspannone-none)):要访问的 Reduce。 -### visit_cast_(*op:*[Cast](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Cast)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_cast_(*op:*[Cast](/docs/api-reference/python-api/tvm-tir#class-tvmtircastdtype-value-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 Cast。 用户可以自定义该函数,在 C++端覆盖 VisitCast_(const CastNode* op)。 -* **参数:op** ([Cast](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Cast)):要访问的 Cast。 +* **参数:op** ([Cast](/docs/api-reference/python-api/tvm-tir#class-tvmtircastdtype-value-spanspannone-none)):要访问的 Cast。 -### visit_not_(*op:*[Not](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Not)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_not_(*op:*[Not](/docs/api-reference/python-api/tvm-tir#class-tvmtirnotaprimexpr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 不访问。 用户可以自定义该函数,在 C++端覆盖 VisitNot_(const NotNode* op)。 -* **参数:op** ([Not](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Not)):不可访问。 +* **参数:op** ([Not](/docs/api-reference/python-api/tvm-tir#class-tvmtirnotaprimexpr-spanspannone-none)):不可访问。 -### visit_select_(*op:*[Select](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Select)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_select_(*op:*[Select](/docs/api-reference/python-api/tvm-tir#class-tvmtirselectconditionprimexpr-true_valueprimexpr-false_valueprimexpr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问选择。 用户可以自定义该函数,在 C++端覆盖 VisitSelect_(const SelectNode* op)。 -* **参数:op** ([Select](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Select)):要访问的选择。 +* **参数:op** ([Select](/docs/api-reference/python-api/tvm-tir#class-tvmtirselectconditionprimexpr-true_valueprimexpr-false_valueprimexpr-spanspannone-none)):要访问的选择。 -### visit_ramp_(*op:*[Ramp](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Ramp)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_ramp_(*op:*[Ramp](/docs/api-reference/python-api/tvm-tir#class-tvmtirrampbaseprimexpr-strideprimexpr-lanesprimexpr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 参观 Ramp。 用户可以自定义该函数,在 C++端覆盖 VisitRamp_(const RampNode* op)。 -* **参数:op** ([Ramp](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Ramp)):要访问的坡道。 +* **参数:op** ([Ramp](/docs/api-reference/python-api/tvm-tir#class-tvmtirrampbaseprimexpr-strideprimexpr-lanesprimexpr-spanspannone-none)):要访问的坡道。 -### visit_broadcast_(*op:*[Broadcast](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Broadcast)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_broadcast_(*op:*[Broadcast](/docs/api-reference/python-api/tvm-tir#class-tvmtirbroadcastvalueprimexpr-lanesprimexpr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问广播。 用户可以自定义该函数,在 C++端覆盖 VisitBroadcast_(const BroadcastNode* op)。 -* **参数:op** ([Broadcast](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Broadcast))[:](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Shuffle)要访问的广播。 +* **参数:op** ([Broadcast](/docs/api-reference/python-api/tvm-tir#class-tvmtirbroadcastvalueprimexpr-lanesprimexpr-spanspannone-none)):要访问的广播。 -### visit_shuffle_(*op:*[Shuffle](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Shuffle)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_shuffle_(*op:*[Shuffle](/docs/api-reference/python-api/tvm-tir#class-tvmtirshufflevectorslistprimexpr-indiceslistprimexpr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 Shuffle。 用户可以自定义该函数,在 C++端覆盖 VisitShuffle_(const ShuffleNode* op)。 -* **参数:op** ([Shuffle](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Shuffle))[:](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IntImm)要访问的 Shuffle。 +* **参数:op** ([Shuffle](/docs/api-reference/python-api/tvm-tir#class-tvmtirshufflevectorslistprimexpr-indiceslistprimexpr-spanspannone-none)):要访问的 Shuffle。 -### visit_int_imm_(*op:*[IntImm](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IntImm)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_int_imm_(*op:*[IntImm](/docs/api-reference/python-api/tvm-tir#class-tvmtirintimmdtypestr-valueint-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 IntImm。 用户可以自定义该函数,在 C++端覆盖 VisitIntImm_(const IntImmNode* op)。 -* **参数:op** ([IntImm](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IntImm)):要访问的 IntImm。 +* **参数:op** ([IntImm](/docs/api-reference/python-api/tvm-tir#class-tvmtirintimmdtypestr-valueint-spanspannone-none)):要访问的 IntImm。 -### visit_float_imm_(*op:*[FloatImm](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.FloatImm)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_float_imm_(*op:*[FloatImm](/docs/api-reference/python-api/tvm-tir#class-tvmtirfloatimmdtypestr-valuefloat-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 FloatImm。 用户可以自定义该函数,在 C++端覆盖 VisitFloatImm_(const FloatImmNode* op)。 -* **参数:op** ([FloatImm](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.FloatImm))**:** 要访问的 FloatImm。 +* **参数:op** ([FloatImm](/docs/api-reference/python-api/tvm-tir#class-tvmtirfloatimmdtypestr-valuefloat-spanspannone-none))**:** 要访问的 FloatImm。 -### visit_string_imm_(*op:*[StringImm](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.StringImm)) → [None](https://docs.python.org/3/library/constants.html#None) +### visit_string_imm_(*op:*[StringImm](/docs/api-reference/python-api/tvm-tir#class-tvmtirstringimmvaluestr-spanspannone-none)) → [None](https://docs.python.org/3/library/constants.html#None) 访问 StringImm。 用户可以自定义该函数,在 C++端覆盖 VisitStringImm_(const StringImmNode* op)。 -* **参数:op** ([StringImm](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.StringImm))[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)要访问的 StringImm。 +* **参数:op** ([StringImm](/docs/api-reference/python-api/tvm-tir#class-tvmtirstringimmvaluestr-spanspannone-none)):要访问的 StringImm。 ## *class* tvm.tir.PyStmtExprMutator @@ -3041,495 +3041,495 @@ Python StmtExprMutator 用于为 Stmt 和 PrimExpr 定义自定义变量。 用户可以自定义任意的访问函数。 -### visit_expr(*expr:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_expr(*expr:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问 PrimExpr。用户可以自定义此函数,在 C++ 端覆盖 VisitExpr(const PrimExpr& expr)。 -* **参数:expr** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):要访问的 PrimExpr。 +* **参数:expr** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):要访问的 PrimExpr。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_stmt(*stmt:*[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)) → [Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt) +### visit_stmt(*stmt:*[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)) → [Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt) Visit Stmt,用户可以自定义该函数,在 C++端覆盖 VisitStmt(const Stmt& stmt)。 -* **参数:stmt** ([Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)):要访问的 Stmt。 +* **参数:stmt** ([Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)):要访问的 Stmt。 * **返回:result**:变异的 Stmt。 -* **返回类型:**[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)。 +* **返回类型:**[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)。 -### visit_attr_stmt_(*op:*[AttrStmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.AttrStmt)) → [Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt) +### visit_attr_stmt_(*op:*[AttrStmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirattrstmtnode-object-attr_keystr-valueprimexpr-bodystmt-spanspannone-none)) → [Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt) 访问 AttrStmt,用户可以自定义该函数,在 C++ 端覆盖 VisitStmt_(const AttrStmtNode* op)。 -* **参数:op** ([AttrStmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.AttrStmt)):要访问的 AttrStmt。 +* **参数:op** ([AttrStmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirattrstmtnode-object-attr_keystr-valueprimexpr-bodystmt-spanspannone-none)):要访问的 AttrStmt。 * **返回:result**:变异的 Stmt。 -* **返回类型:**[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)。 +* **返回类型:**[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)。 -### visit_if_then_else_(*op:*[IfThenElse](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IfThenElse)) → [Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt) +### visit_if_then_else_(*op:*[IfThenElse](/docs/api-reference/python-api/tvm-tir#class-tvmtirifthenelseconditionprimexpr-then_casestmt-else_casestmtnone-spanspannone-none)) → [Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt) 访问 IfThenElse,用户可以自定义该函数,在 C++端覆盖 VisitStmt_(const IfThenElseNode* op)。 -* **参数:op** ([IfThenElse](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IfThenElse))**:** 要访问的 IfThenElse。 +* **参数:op** ([IfThenElse](/docs/api-reference/python-api/tvm-tir#class-tvmtirifthenelseconditionprimexpr-then_casestmt-else_casestmtnone-spanspannone-none))**:** 要访问的 IfThenElse。 * **返回:result:** 变异的 Stmt。 -* **返回类型:**[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)。 +* **返回类型:**[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)。 -### visit_let_stmt_(*op:*[LetStmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.LetStmt)) → [Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt) +### visit_let_stmt_(*op:*[LetStmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirletstmtvarvar-valueprimexpr-bodystmt-spanspannone-none)) → [Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt) 访问 LetStmt。用户可以自定义此函数,在 C++ 端覆盖 VisitStmt_(const LetStmtNode* op)。 -* **参数:op** ([LetStmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.LetStmt))**:** 要访问的 LetStmt。 +* **参数:op** ([LetStmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirletstmtvarvar-valueprimexpr-bodystmt-spanspannone-none))**:** 要访问的 LetStmt。 * **返回:result**:变异的 Stmt。 -* **返回类型:**[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)。 +* **返回类型:**[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)。 -### visit_for_(*op:*[For](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.For)) → [Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt) +### visit_for_(*op:*[For](/docs/api-reference/python-api/tvm-tir#class-tvmtirforloop_varvar-minprimexpr-extentprimexpr-kindforkind-bodystmt-thread_bindingitervarnone-none-annotationsmappingstr-object-none-none-spanspannone-none)) → [Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt) 访问 For。用户可以自定义该函数,在 C++ 端覆盖 VisitStmt_(const ForNode* op)。 -* **参数:op** ([For](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.For)):要访问的 For。 +* **参数:op** ([For](/docs/api-reference/python-api/tvm-tir#class-tvmtirforloop_varvar-minprimexpr-extentprimexpr-kindforkind-bodystmt-thread_bindingitervarnone-none-annotationsmappingstr-object-none-none-spanspannone-none)):要访问的 For。 * **返回:result**:变异的 Stmt。 -* **返回类型:**[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)。 +* **返回类型:**[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)。 -### visit_while_(*op:*[While](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.While)) → [Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt) +### visit_while_(*op:*[While](/docs/api-reference/python-api/tvm-tir#class-tvmtirwhileconditionprimexpr-bodystmt-spanspannone-none)) → [Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt) 访问 While。用户可以自定义此函数,在 C++ 端覆盖 VisitStmt_(const WhileNode* op)。 -* **参数:op** ([While](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.While)):需要访问的 While 部分。 +* **参数:op** ([While](/docs/api-reference/python-api/tvm-tir#class-tvmtirwhileconditionprimexpr-bodystmt-spanspannone-none)):需要访问的 While 部分。 * **返回:result**:变异的 Stmt。 -* **返回类型:**[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)。 +* **返回类型:**[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)。 -### visit_allocate_(*op:*[Allocate](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Allocate)) → [Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt) +### visit_allocate_(*op:*[Allocate](/docs/api-reference/python-api/tvm-tir#class-tvmtirallocatebuffer_varvar-dtypestr-extentslistprimexpr-conditionprimexpr-bodystmt-annotationsmappingstr-object-none-none-spanspannone-none)) → [Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt) Visit Allocate,用户可以自定义该函数,在 C++端覆盖 VisitStmt_(const AllocateNode* op)。 -* **参数:op** ([Allocate](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Allocate))[:](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.AllocateConst)要访问的分配。 +* **参数:op** ([Allocate](/docs/api-reference/python-api/tvm-tir#class-tvmtirallocatebuffer_varvar-dtypestr-extentslistprimexpr-conditionprimexpr-bodystmt-annotationsmappingstr-object-none-none-spanspannone-none)):要访问的分配。 * **返回:result**:变异的 Stmt。 -* **返回类型:**[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt) +* **返回类型:**[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt) -### visit_allocate_const_(*op:*[AllocateConst](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.AllocateConst)) → [Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt) +### visit_allocate_const_(*op:*[AllocateConst](/docs/api-reference/python-api/tvm-tir#class-tvmtirallocateconstbuffer_varvar-dtypestr-extentslistprimexpr-data_or_idxndarrayint-bodystmt-annotationsmappingstr-object-none-none-spanspannone-none)) → [Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt) 访问 AllocateConst,用户可以自定义该函数,在 C++端覆盖 VisitStmt_(const AllocateConstNode* op)。 -* **参数:op** ([AllocateConst](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.AllocateConst)):要访问的 AllocateConst。 +* **参数:op** ([AllocateConst](/docs/api-reference/python-api/tvm-tir#class-tvmtirallocateconstbuffer_varvar-dtypestr-extentslistprimexpr-data_or_idxndarrayint-bodystmt-annotationsmappingstr-object-none-none-spanspannone-none)):要访问的 AllocateConst。 * **返回:result**:变异的 Stmt。 -* **返回类型:**[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)。 +* **返回类型:**[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)。 -### visit_decl_buffer_(*op:*[DeclBuffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.DeclBuffer)) → [Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt) +### visit_decl_buffer_(*op:*[DeclBuffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirdeclbufferbufferbuffer-bodystmt-spanspannone-none)) → [Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt) 访问 DeclBuffer,用户可以自定义该函数,在 C++端覆盖 VisitStmt_(const DeclBufferNode* op)。 -* **参数:op** ([DeclBuffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.DeclBuffer)):要访问的 DeclBuffer。 +* **参数:op** ([DeclBuffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirdeclbufferbufferbuffer-bodystmt-spanspannone-none)):要访问的 DeclBuffer。 * **返回:result**:变异的 Stmt。 -* **返回类型:**[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)。 +* **返回类型:**[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)。 -### visit_buffer_store_(*op:*[BufferStore](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BufferStore)) → [Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt) +### visit_buffer_store_(*op:*[BufferStore](/docs/api-reference/python-api/tvm-tir#class-tvmtirbufferStore)) → [Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt) 访问 BufferStore,用户可以自定义该函数,在 C++端覆盖 VisitStmt_(const BufferStoreNode* op)。 -* **参数:op** ([BufferStore](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BufferStore)):要访问的 BufferStore。 +* **参数:op** ([BufferStore](/docs/api-reference/python-api/tvm-tir#class-tvmtirbufferStore)):要访问的 BufferStore。 * **返回:result**:变异的 Stmt。 -* **返回类型:**[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)。 +* **返回类型:**[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)。 -### visit_buffer_realize_(*op:*[BufferRealize](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BufferRealize)) → [Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt) +### visit_buffer_realize_(*op:*[BufferRealize](/docs/api-reference/python-api/tvm-tir#class-tvmtirbufferRealize)) → [Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt) 访问 BufferRealize,用户可以自定义该函数,在 C++端覆盖 VisitStmt_(const BufferRealizeNode* op)。 -* **参数:op** ([BufferRealize](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BufferRealize)):要访问的 BufferRealize。 +* **参数:op** ([BufferRealize](/docs/api-reference/python-api/tvm-tir#class-tvmtirbufferRealize)):要访问的 BufferRealize。 * **返回:result**:变异的 Stmt。 -* **返回类型:**[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)。 +* **返回类型:**[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)。 -### visit_assert_stmt_(*op:*[AssertStmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.AssertStmt)) → [Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt) +### visit_assert_stmt_(*op:*[AssertStmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirattrstmtnode-object-attr_keystr-valueprimexpr-bodystmt-spanspannone-none)) → [Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt) 访问 AssertStmt,用户可以自定义该函数,在 C++ 端覆盖 VisitStmt_(const AssertStmtNode* op)。 -* **参数:op** ([AssertStmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.AssertStmt))**:** 要访问的 AssertStmt。 -* **返回:result**[:](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Evaluate)变异的 Stmt。 -* **返回类型:**[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)。 +* **参数:op** ([AssertStmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirattrstmtnode-object-attr_keystr-valueprimexpr-bodystmt-spanspannone-none))**:** 要访问的 AssertStmt。 +* **返回:result**:变异的 Stmt。 +* **返回类型:**[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)。 -### visit_seq_stmt_(*op:*[SeqStmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.SeqStmt)) → [Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt) +### visit_seq_stmt_(*op:*[SeqStmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirseqstmtseqliststmt-spanspannone-none)) → [Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt) 访问 SeqStmt,用户可以自定义该函数,在 C++端覆盖 VisitStmt_(const SeqStmtNode* op)。 -* **参数:op** ([SeqStmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.SeqStmt)):要访问的 SeqStmt。 +* **参数:op** ([SeqStmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirseqstmtseqliststmt-spanspannone-none)):要访问的 SeqStmt。 * **返回:result**:变异的 Stmt。 -* **返回类型:**[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)。 +* **返回类型:**[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)。 -### visit_evaluate_(*op:*[Evaluate](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Evaluate)) → [Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt) +### visit_evaluate_(*op:*[Evaluate](/docs/api-reference/python-api/tvm-tir#class-tvmtirevaluatevalueprimexpr-spanspannone-none)) → [Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt) Visit Evaluate,用户可以自定义该函数,在 C++端覆盖 VisitStmt_(const EvaluateNode* op)。 -* **参数:op** ([Evaluate](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Evaluate)):要访问的评估。 +* **参数:op** ([Evaluate](/docs/api-reference/python-api/tvm-tir#class-tvmtirevaluatevalueprimexpr-spanspannone-none)):要访问的评估。 * **返回:result**:变异的 Stmt。 -* **返回类型:**[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)。 +* **返回类型:**[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)。 -### visit_block_(*op:*[Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block)) → [Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt) +### visit_block_(*op:*[Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none)) → [Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt) 访问区块。用户可以自定义该函数,在 C++端覆盖 VisitStmt_(const BlockNode* op)。 -* **参数:op** ([Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block)):要访问的区块。 +* **参数:op** ([Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none)):要访问的区块。 * **返回:result**:变异的 Stmt。 -* **返回类型:**[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)。 +* **返回类型:**[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)。 -### visit_block_realize_(*op:*[BlockRealize](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BlockRealize)) → [Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt) +### visit_block_realize_(*op:*[BlockRealize](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-noneRealize)) → [Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt) 访问 BlockRealize。用户可以自定义此函数,在 C++ 端覆盖 VisitStmt_(const BlockRealizeNode* op)。 -* **参数:op** ([BlockRealize](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BlockRealize)):要访问的 BlockRealize。 +* **参数:op** ([BlockRealize](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-noneRealize)):要访问的 BlockRealize。 * **返回:result:** 变异的 Stmt。 -* **返回类型:**[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)。 +* **返回类型:**[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)。 -### visit_var_(*op:*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_var_(*op:*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 参观 Var。 用户可以自定义该函数,在 C++端覆盖 VisitVar_(const VarNode* op)。 -* **参数:op** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var))**:** 要访问的 tir.Var。 +* **参数:op** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none))**:** 要访问的 tir.Var。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_size_var_(*op:*[SizeVar](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.SizeVar)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_size_var_(*op:*[SizeVar](/docs/api-reference/python-api/tvm-tir#class-tvmtirsizevarnamestr-dtypestrtype-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问 SizeVar。 用户可以自定义该函数,在 C++端覆盖 VisitSizeVar_(const SizeVarNode* op)。 -* **参数:op** ([SizeVar](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.SizeVar)):要访问的 SizeVar。 -* **返回:result**[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **参数:op** ([SizeVar](/docs/api-reference/python-api/tvm-tir#class-tvmtirsizevarnamestr-dtypestrtype-spanspannone-none)):要访问的 SizeVar。 +* **返回:result**:变异的 PrimExpr。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_buffer_load_(*op:*[BufferLoad](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BufferLoad)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_buffer_load_(*op:*[BufferLoad](/docs/api-reference/python-api/tvm-tir#class-tvmtirbufferLoad)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问 BufferLoad。 用户可以自定义该函数,在 C++端覆盖 VisitBufferLoad_(const BufferLoadNode* op)。 -* **参数:op** ([BufferLoad](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BufferLoad)):要访问的 BufferLoad。 +* **参数:op** ([BufferLoad](/docs/api-reference/python-api/tvm-tir#class-tvmtirbufferLoad)):要访问的 BufferLoad。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_producer_load_(*op:*[ProducerLoad](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.ProducerLoad)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_producer_load_(*op:*[ProducerLoad](/docs/api-reference/python-api/tvm-tir#class-tvmtirproducerloadproducerdataproducer-indiceslistprimexpr-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问 ProducerLoad。 用户可以自定义该函数,在 C++端覆盖 VisitProducerLoad_(const ProducerLoadNode* op)。 -* **参数:op** ([ProducerLoad](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.ProducerLoad)):要访问的 ProducerLoad。 +* **参数:op** ([ProducerLoad](/docs/api-reference/python-api/tvm-tir#class-tvmtirproducerloadproducerdataproducer-indiceslistprimexpr-spanspannone-none)):要访问的 ProducerLoad。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_let_(*op:*[Let](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Let)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_let_(*op:*[Let](/docs/api-reference/python-api/tvm-tir#class-tvmtirletvarvar-valueprimexpr-bodyprimexpr-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问 Let. 用户可以自定义该函数,在 C++端覆盖 VisitLet_(const LetNode* op)。 -* **参数:op** ([Let](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Let))**:** 要访问的 Let。 +* **参数:op** ([Let](/docs/api-reference/python-api/tvm-tir#class-tvmtirletvarvar-valueprimexpr-bodyprimexpr-spanspannone-none))**:** 要访问的 Let。 * **返回:result** *:* 变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_call_(*op:*[Call](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Call)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_call_(*op:*[Call](/docs/api-reference/python-api/tvm-tir#class-tvmtircalldtypestr-opopstr-argslistprimexpr-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问调用。 用户可以自定义该函数,在 C++端覆盖 VisitCall_(const CallNode* op)。 -* **参数:op** ([tir.Call](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Call)):要访问的 tir.Call。 +* **参数:op** ([tir.Call](/docs/api-reference/python-api/tvm-tir#class-tvmtircalldtypestr-opopstr-argslistprimexpr-spanspannone-none)):要访问的 tir.Call。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_add_(*op:*[Add](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Add)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_add_(*op:*[Add](/docs/api-reference/python-api/tvm-tir#class-tvmtiraddaprimexpr-bprimexpr-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问添加。 用户可以自定义该函数,在 C++端覆盖 VisitAdd_(const AddNode* op)。 -* **参数:op** ([Add](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Add)):要访问的 Add。 -* **返回:result**[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **参数:op** ([Add](/docs/api-reference/python-api/tvm-tir#class-tvmtiraddaprimexpr-bprimexpr-spanspannone-none)):要访问的 Add。 +* **返回:result**:变异的 PrimExpr。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_sub_(*op:*[Sub](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Sub)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_sub_(*op:*[Sub](/docs/api-reference/python-api/tvm-tir#class-tvmtirsubaprimexpr-bprimexpr-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问 Sub。 用户可以自定义该函数,在 C++端覆盖 VisitSub_(const SubNode* op)。 -* **参数:op** ([Sub](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Sub)):要访问的 Sub。 +* **参数:op** ([Sub](/docs/api-reference/python-api/tvm-tir#class-tvmtirsubaprimexpr-bprimexpr-spanspannone-none)):要访问的 Sub。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_mul_(*op:*[Mul](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Mul)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_mul_(*op:*[Mul](/docs/api-reference/python-api/tvm-tir#class-tvmtirmulaprimexpr-bprimexpr-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 参观 Mul。 用户可以自定义该函数,在 C++端覆盖 VisitMul_(const MulNode* op)。 -* **参数:op** ([Mul](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Mul)):要访问的 Mul。 +* **参数:op** ([Mul](/docs/api-reference/python-api/tvm-tir#class-tvmtirmulaprimexpr-bprimexpr-spanspannone-none)):要访问的 Mul。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_div_(*op:*[Div](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Div)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_div_(*op:*[Div](/docs/api-reference/python-api/tvm-tir#class-tvmtirdivaprimexpr-bprimexpr-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问 Div。 用户可以自定义该函数,在 C++端覆盖 VisitDiv_(const DivNode* op)。 -* **参数:op** ([Div](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Div)):要访问的 Div。 +* **参数:op** ([Div](/docs/api-reference/python-api/tvm-tir#class-tvmtirdivaprimexpr-bprimexpr-spanspannone-none)):要访问的 Div。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_mod_(*op:*[Mod](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Mod)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_mod_(*op:*[Mod](/docs/api-reference/python-api/tvm-tir#class-tvmtirmodaprimexpr-bprimexpr-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问 Mod。 用户可以自定义该函数,在 C++端覆盖 VisitMod_(const ModNode* op)。 -* **参数:op** ([Mod](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Mod))[:](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.FloorDiv)要访问的 Mod。 +* **参数:op** ([Mod](/docs/api-reference/python-api/tvm-tir#class-tvmtirmodaprimexpr-bprimexpr-spanspannone-none)):要访问的 Mod。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_floor_div_(*op:*[FloorDiv](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.FloorDiv)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_floor_div_(*op:*[FloorDiv](/docs/api-reference/python-api/tvm-tir#class-tvmtirfloordivaprimexpr-bprimexpr-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问 FloorDiv。 用户可以自定义该函数,在 C++端覆盖 VisitFloorDiv_(const FloorDivNode* op)。 -* **参数:op** ([FloorDiv](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.FloorDiv))[:](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.FloorMod)要访问的 FloorDiv。 +* **参数:op** ([FloorDiv](/docs/api-reference/python-api/tvm-tir#class-tvmtirfloordivaprimexpr-bprimexpr-spanspannone-none)):要访问的 FloorDiv。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_floor_mod_(*op:*[FloorMod](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.FloorMod)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_floor_mod_(*op:*[FloorMod](/docs/api-reference/python-api/tvm-tir#class-tvmtirfloormodaprimexpr-bprimexpr-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问 FloorMod。 用户可以自定义该函数,在 C++端覆盖 VisitFloorMod_(const FloorModNode* op)。 -* **参数:op** ([FloorMod](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.FloorMod)):要访问的 FloorMod。 +* **参数:op** ([FloorMod](/docs/api-reference/python-api/tvm-tir#class-tvmtirfloormodaprimexpr-bprimexpr-spanspannone-none)):要访问的 FloorMod。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_min_(*op:*[Min](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Min)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_min_(*op:*[Min](/docs/api-reference/python-api/tvm-tir#class-tvmtirminaprimexpr-bprimexpr-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问 Min。 用户可以自定义该函数,在 C++端覆盖 VisitMin_(const MinNode* op)。 -* **参数:op** ([Min](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Min)):要访问的 Min。 +* **参数:op** ([Min](/docs/api-reference/python-api/tvm-tir#class-tvmtirminaprimexpr-bprimexpr-spanspannone-none)):要访问的 Min。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_max_(*op:*[Max](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Max)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_max_(*op:*[Max](/docs/api-reference/python-api/tvm-tir#class-tvmtirminaprimexpr-bprimexpr-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 拜访 Max。 用户可以自定义该函数,在 C++端覆盖 VisitMax_(const MaxNode* op)。 -* **参数:op** ([Max](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Max)):要访问的最大值。 +* **参数:op** ([Max](/docs/api-reference/python-api/tvm-tir#class-tvmtirminaprimexpr-bprimexpr-spanspannone-none)):要访问的最大值。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_eq_(*op:*[EQ](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.EQ)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_eq_(*op:*[EQ](/docs/api-reference/python-api/tvm-tir#class-tvmtireqaprimexpr-bprimexpr-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问 EQ。 用户可以自定义该函数,在 C++端覆盖 VisitEQ_(const EQNode* op)。 -* **参数:op** ([EQ](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.EQ)):要访问的 EQ。 +* **参数:op** ([EQ](/docs/api-reference/python-api/tvm-tir#class-tvmtireqaprimexpr-bprimexpr-spanspannone-none)):要访问的 EQ。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_ne_(*op:*[NE](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.NE)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_ne_(*op:*[NE](/docs/api-reference/python-api/tvm-tir#class-tvmtirneaprimexpr-bprimexpr-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问NE。 用户可以自定义该函数,在 C++端覆盖 VisitNE_(const NENode* op)。 -* **参数:op** ([NE](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.NE)):要访问的 NE。 +* **参数:op** ([NE](/docs/api-reference/python-api/tvm-tir#class-tvmtirneaprimexpr-bprimexpr-spanspannone-none)):要访问的 NE。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_lt_(*op:*[LT](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.LT)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_lt_(*op:*[LT](/docs/api-reference/python-api/tvm-tir#class-tvmtirltaprimexpr-bprimexpr-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问 LT。 用户可以自定义该函数,在 C++端覆盖 VisitLT_(const LTNode* op)。 -* **参数:op** ([LT](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.LT)):要访问的 LT。 +* **参数:op** ([LT](/docs/api-reference/python-api/tvm-tir#class-tvmtirltaprimexpr-bprimexpr-spanspannone-none)):要访问的 LT。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) -### visit_le_(*op:*[LE](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.LE)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_le_(*op:*[LE](/docs/api-reference/python-api/tvm-tir#class-tvmtirleaprimexpr-bprimexpr-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问 LE。 用户可以自定义该函数,在 C++端覆盖 VisitLE_(const LENode* op)。 -* **参数:op** ([LE](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.LE)):要访问的 LE。 +* **参数:op** ([LE](/docs/api-reference/python-api/tvm-tir#class-tvmtirleaprimexpr-bprimexpr-spanspannone-none)):要访问的 LE。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_gt_(*op:*[GT](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.GT)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_gt_(*op:*[GT](/docs/api-reference/python-api/tvm-tir#class-tvmtirgtaprimexpr-bprimexpr-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问 GT。 用户可以自定义该函数,在 C++端覆盖 VisitGT_(const GTNode* op)。 -* **参数:op** ([GT](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.GT)):要访问的 GT。 +* **参数:op** ([GT](/docs/api-reference/python-api/tvm-tir#class-tvmtirgtaprimexpr-bprimexpr-spanspannone-none)):要访问的 GT。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_ge_(*op:*[GE](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.GE)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_ge_(*op:*[GE](/docs/api-reference/python-api/tvm-tir#class-tvmtirgeaprimexpr-bprimexpr-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 参观 GE。 用户可以自定义该函数,在 C++端覆盖 VisitGE_(const GENode* op)。 -* **参数:op** ([GE](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.GE)):要访问的 GE。 +* **参数:op** ([GE](/docs/api-reference/python-api/tvm-tir#class-tvmtirgeaprimexpr-bprimexpr-spanspannone-none)):要访问的 GE。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_and_(*op:*[And](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.And)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_and_(*op:*[And](/docs/api-reference/python-api/tvm-tir#class-tvmtirandaprimexpr-bprimexpr-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问 And。 用户可以自定义该函数,在 C++端覆盖 VisitAnd_(const AndNode* op)。 -* **参数:op** ([And](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.And))**:** 要访问的 And。 +* **参数:op** ([And](/docs/api-reference/python-api/tvm-tir#class-tvmtirandaprimexpr-bprimexpr-spanspannone-none))**:** 要访问的 And。 * **返回:result:** 变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_or_(*op:*[Or](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Or)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_or_(*op:*[Or](/docs/api-reference/python-api/tvm-tir#class-tvmtiroraprimexpr-bprimexpr-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问 Or。 用户可以自定义该函数,在 C++端覆盖 VisitOr_(const OrNode* op)。 -* **参数:op** ([Or](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Or)):要访问的 Or。 +* **参数:op** ([Or](/docs/api-reference/python-api/tvm-tir#class-tvmtiroraprimexpr-bprimexpr-spanspannone-none)):要访问的 Or。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_reduce_(*op:*[Reduce](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Reduce)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_reduce_(*op:*[Reduce](/docs/api-reference/python-api/tvm-tir#class-tvmtirreducecombinercommreducer-srclistprimexpr-rdomlistitervar-conditionprimexpr-value_indexint-initlistprimexpr-none-none-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问 Reduce。 用户可以自定义该函数,在 C++端覆盖 VisitReduce_(const ReduceNode* op)。 -* **参数:op** ([Reduce](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Reduce))**:** 要访问的 Reduce。 +* **参数:op** ([Reduce](/docs/api-reference/python-api/tvm-tir#class-tvmtirreducecombinercommreducer-srclistprimexpr-rdomlistitervar-conditionprimexpr-value_indexint-initlistprimexpr-none-none-spanspannone-none))**:** 要访问的 Reduce。 * **返回:result:** 变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_cast_(*op:*[Cast](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Cast)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_cast_(*op:*[Cast](/docs/api-reference/python-api/tvm-tir#class-tvmtircastdtype-value-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问 Cast。 用户可以自定义该函数,在 C++端覆盖 VisitCast_(const CastNode* op)。 -* **参数:op** ([Cast](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Cast)):要访问的演员表。 +* **参数:op** ([Cast](/docs/api-reference/python-api/tvm-tir#class-tvmtircastdtype-value-spanspannone-none)):要访问的演员表。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_not_(*op:*[Not](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Not)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_not_(*op:*[Not](/docs/api-reference/python-api/tvm-tir#class-tvmtirnotaprimexpr-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 不访问。 用户可以自定义该函数,在 C++端覆盖 VisitNot_(const NotNode* op)。 -* **参数:op** ([Not](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Not)):不可访问。 +* **参数:op** ([Not](/docs/api-reference/python-api/tvm-tir#class-tvmtirnotaprimexpr-spanspannone-none)):不可访问。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_select_(*op:*[Select](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Select)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_select_(*op:*[Select](/docs/api-reference/python-api/tvm-tir#class-tvmtirselectconditionprimexpr-true_valueprimexpr-false_valueprimexpr-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问选择。 用户可以自定义该函数,在 C++端覆盖 VisitSelect_(const SelectNode* op)。 -* **参数:op** ([Select](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Select)):要访问的选择。 +* **参数:op** ([Select](/docs/api-reference/python-api/tvm-tir#class-tvmtirselectconditionprimexpr-true_valueprimexpr-false_valueprimexpr-spanspannone-none)):要访问的选择。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_ramp_(*op:*[Ramp](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Ramp)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_ramp_(*op:*[Ramp](/docs/api-reference/python-api/tvm-tir#class-tvmtirrampbaseprimexpr-strideprimexpr-lanesprimexpr-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 参观 Ramp。 用户可以自定义该函数,在 C++端覆盖 VisitRamp_(const RampNode* op)。 -* **参数:op** ([Ramp](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Ramp))[:](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Broadcast)要访问的坡道。 +* **参数:op** ([Ramp](/docs/api-reference/python-api/tvm-tir#class-tvmtirrampbaseprimexpr-strideprimexpr-lanesprimexpr-spanspannone-none)):要访问的坡道。 * **返回:result:** 变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_broadcast_(*op:*[Broadcast](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Broadcast)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_broadcast_(*op:*[Broadcast](/docs/api-reference/python-api/tvm-tir#class-tvmtirbroadcastvalueprimexpr-lanesprimexpr-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问广播。 用户可以自定义该函数,在 C++端覆盖 VisitBroadcast_(const BroadcastNode* op)。 -* **参数:op** ([Broadcast](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Broadcast)):要访问的广播。 +* **参数:op** ([Broadcast](/docs/api-reference/python-api/tvm-tir#class-tvmtirbroadcastvalueprimexpr-lanesprimexpr-spanspannone-none)):要访问的广播。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_shuffle_(*op:*[Shuffle](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Shuffle)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_shuffle_(*op:*[Shuffle](/docs/api-reference/python-api/tvm-tir#class-tvmtirshufflevectorslistprimexpr-indiceslistprimexpr-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问 Shuffle。 用户可以自定义该函数,在 C++端覆盖 VisitShuffle_(const ShuffleNode* op)。 -* **参数:op** ([Shuffle](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Shuffle)):要访问的 Shuffle。 +* **参数:op** ([Shuffle](/docs/api-reference/python-api/tvm-tir#class-tvmtirshufflevectorslistprimexpr-indiceslistprimexpr-spanspannone-none)):要访问的 Shuffle。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_int_imm_(*op:*[IntImm](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IntImm)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_int_imm_(*op:*[IntImm](/docs/api-reference/python-api/tvm-tir#class-tvmtirintimmdtypestr-valueint-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问 IntImm。 用户可以自定义该函数,在 C++端覆盖 VisitIntImm_(const IntImmNode* op)。 -* **参数:op** ([IntImm](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IntImm)):要访问的 IntImm。 +* **参数:op** ([IntImm](/docs/api-reference/python-api/tvm-tir#class-tvmtirintimmdtypestr-valueint-spanspannone-none)):要访问的 IntImm。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_float_imm_(*op:*[FloatImm](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.FloatImm)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_float_imm_(*op:*[FloatImm](/docs/api-reference/python-api/tvm-tir#class-tvmtirfloatimmdtypestr-valuefloat-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问 FloatImm。 用户可以自定义该函数,在 C++端覆盖 VisitFloatImm_(const FloatImmNode* op)。 -* **参数:op** ([FloatImm](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.FloatImm)):要访问的 FloatImm。 +* **参数:op** ([FloatImm](/docs/api-reference/python-api/tvm-tir#class-tvmtirfloatimmdtypestr-valuefloat-spanspannone-none)):要访问的 FloatImm。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -### visit_string_imm_(*op:*[StringImm](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.StringImm)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### visit_string_imm_(*op:*[StringImm](/docs/api-reference/python-api/tvm-tir#class-tvmtirstringimmvaluestr-spanspannone-none)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 访问 StringImm。 用户可以自定义该函数,在 C++端覆盖 VisitStringImm_(const StringImmNode* op)。 -* **参数:op** ([StringImm](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.StringImm)):要访问的 StringImm。 +* **参数:op** ([StringImm](/docs/api-reference/python-api/tvm-tir#class-tvmtirstringimmvaluestr-spanspannone-none)):要访问的 StringImm。 * **返回:result**:变异的 PrimExpr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 diff --git a/docs/04-api-reference/01-python-api/18-tvm-tir-analysis.md b/docs/04-api-reference/01-python-api/18-tvm-tir-analysis.md index fbfc2b5..de4a501 100644 --- a/docs/04-api-reference/01-python-api/18-tvm-tir-analysis.md +++ b/docs/04-api-reference/01-python-api/18-tvm-tir-analysis.md @@ -1,23 +1,23 @@ --- -title: tvm.tir 分析 +title: tvm.tir.analysis --- 包装现有的分析工具。 -## tvm.tir.analysis.analysis.expr_deep_equal(*lhs:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *rhs:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)) → [bool](https://docs.python.org/3/library/functions.html#bool) +## tvm.tir.analysis.analysis.expr_deep_equal(*lhs:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *rhs:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)) → [bool](https://docs.python.org/3/library/functions.html#bool) 深度比较两个嵌套表达式。 * **参数:** - * **lhs** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)) :左操作数。 - * **rhs** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)) :右操作数。 + * **lhs** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)) :左操作数。 + * **rhs** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)) :右操作数。 * **返回:result**:比较结果。 * **返回类型:**[bool](https://docs.python.org/3/library/functions.html#bool)。 -:::Note +:::note 此函数不会重新映射变量绑定,除非 x.same_as(y),否则它不会对 (let x = 1 in x + 1) 和 (let y = 1 in y + 1) 返回 true。使用 py:func: tvm.ir.structural_equal 来处理结构变量重新映射。 @@ -37,33 +37,33 @@ title: tvm.tir 分析 ## -## tvm.tir.analysis.analysis.verify_ssa(*func:*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)) → [bool](https://docs.python.org/3/library/functions.html#bool) +## tvm.tir.analysis.analysis.verify_ssa(*func:*[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)) → [bool](https://docs.python.org/3/library/functions.html#bool) 验证函数是否为 SSA 形式。 -* **参数:func** ([tvm.tir.PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)):要验证的模块。 +* **参数:func** ([tvm.tir.PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)):要验证的模块。 * **返回:result**:验证的结果。 * **返回类型:**[bool](https://docs.python.org/3/library/functions.html#bool)。 -## tvm.tir.analysis.analysis.verify_memory(*func:*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)) → [bool](https://docs.python.org/3/library/functions.html#bool) +## tvm.tir.analysis.analysis.verify_memory(*func:*[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)) → [bool](https://docs.python.org/3/library/functions.html#bool) 验证 func 是否包含非法主机端直接内存访问。 -* **参数:func** ([tvm.tir.PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)):要验证的模块。 +* **参数:func** ([tvm.tir.PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)):要验证的模块。 * **返回:result**:验证的结果。 * **返回类型:**[bool](https://docs.python.org/3/library/functions.html#bool)。 -## tvm.tir.analysis.analysis.verify_gpu_code(*func:*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc), *constraints:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[int](https://docs.python.org/3/library/functions.html#int)*]*) → [None](https://docs.python.org/3/library/constants.html#None) +## tvm.tir.analysis.analysis.verify_gpu_code(*func:*[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone), *constraints:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[int](https://docs.python.org/3/library/functions.html#int)*]*) → [None](https://docs.python.org/3/library/constants.html#None) 验证模块是否包含非法主机端直接内存访问。 * **参数:** - * **func** ([tvm.tir.PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)):要验证的模块。 + * **func** ([tvm.tir.PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)):要验证的模块。 * **constraints** (*Dict[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[int](https://docs.python.org/3/library/functions.html#int)*]*):属性约束。 * **返回:result**:验证的结果。 * **返回类型:**[bool](https://docs.python.org/3/library/functions.html#bool)。 -## tvm.tir.analysis.analysis.get_block_access_region(*block:*[Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block), *buffer_var_map:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)*,*[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)*]*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[List](https://docs.python.org/3/library/typing.html#typing.List)[[BufferRegion](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BufferRegion)]] +## tvm.tir.analysis.analysis.get_block_access_region(*block:*[Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none), *buffer_var_map:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)*,*[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)*]*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[List](https://docs.python.org/3/library/typing.html#typing.List)[[BufferRegion](/docs/api-reference/python-api/tvm-tir#class-tvmtirbufferregionbufferbuffer-regionlistrange)]] 检测此块中的张量区域被读取或写入。 @@ -71,15 +71,15 @@ title: tvm.tir 分析 区域按照 AST 中出现的顺序排序。 * **参数:** - * **block** ([tvm.tir.Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block)):我们正在检测读/写区域的块。 - * **buffer_var_map** (*Dict[*[tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)*,*[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)*]*):可以访问该块的外部缓冲区。从缓冲区 var 映射到缓冲区。 + * **block** ([tvm.tir.Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none)):我们正在检测读/写区域的块。 + * **buffer_var_map** (*Dict[*[tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)*,*[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)*]*):可以访问该块的外部缓冲区。从缓冲区 var 映射到缓冲区。 * **返回:result**:访问区域的数组。包括三种类型的 `BufferRegion` 数组: * 第一: 读区域。 * 第二: 写区域。 * 第三: 不透明区域。 -* **返回类型:** List[List[[BufferRegion](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BufferRegion)]]。 +* **返回类型:** List[List[[BufferRegion](/docs/api-reference/python-api/tvm-tir#class-tvmtirbufferregionbufferbuffer-regionlistrange)]]。 -## tvm.tir.analysis.analysis.get_block_read_write_region(*block:*[Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block), *buffer_var_map:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)*,*[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)*]*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[List](https://docs.python.org/3/library/typing.html#typing.List)[[BufferRegion](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BufferRegion)]] +## tvm.tir.analysis.analysis.get_block_read_write_region(*block:*[Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none), *buffer_var_map:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)*,*[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)*]*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[List](https://docs.python.org/3/library/typing.html#typing.List)[[BufferRegion](/docs/api-reference/python-api/tvm-tir#class-tvmtirbufferregionbufferbuffer-regionlistrange)]] 根据块主体语句自动检测块读/写区域。 @@ -87,52 +87,52 @@ title: tvm.tir 分析 不透明访问将被视为读访问和写访问。 * **参数:** - * **block** ([tvm.tir.Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block)):我们正在检测读/写区域的块。 - * **buffer_var_map** (*Dict[*[tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)*,*[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)*]*):可以访问该块的外部缓冲区。从缓冲区 var 映射到缓冲区。 + * **block** ([tvm.tir.Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none)):我们正在检测读/写区域的块。 + * **buffer_var_map** (*Dict[*[tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)*,*[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)*]*):可以访问该块的外部缓冲区。从缓冲区 var 映射到缓冲区。 * **返回:result**:仅由输入块的读取区域和写入区域组成的数组。 -* **返回类型:** List[List[[BufferRegion](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BufferRegion)]]。 +* **返回类型:** List[List[[BufferRegion](/docs/api-reference/python-api/tvm-tir#class-tvmtirbufferregionbufferbuffer-regionlistrange)]]。 -## tvm.tir.analysis.analysis.calculate_allocated_bytes(*func_or_mod:*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)*|*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)) → [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)[[str](https://docs.python.org/3/library/stdtypes.html#str), [int](https://docs.python.org/3/library/functions.html#int)] | [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)[[str](https://docs.python.org/3/library/stdtypes.html#str), [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)[[str](https://docs.python.org/3/library/stdtypes.html#str), [int](https://docs.python.org/3/library/functions.html#int)]] +## tvm.tir.analysis.analysis.calculate_allocated_bytes(*func_or_mod:*[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)*|*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)) → [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)[[str](https://docs.python.org/3/library/stdtypes.html#str), [int](https://docs.python.org/3/library/functions.html#int)] | [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)[[str](https://docs.python.org/3/library/stdtypes.html#str), [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)[[str](https://docs.python.org/3/library/stdtypes.html#str), [int](https://docs.python.org/3/library/functions.html#int)]] 计算 TIR PrimFuncs 所需的每个内存范围分配的内存。 -* **参数:func_or_mod** (*Union[*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)*,*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)*]*):待检测的函数或模块。如果传入的是模块,则会计算模块内所有 PrimFunc 的分配内存。 +* **参数:func_or_mod** (*Union[*[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)*,*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)*]*):待检测的函数或模块。如果传入的是模块,则会计算模块内所有 PrimFunc 的分配内存。 * **返回:result**:IRModule 中每个函数在每个作用域内分配的内存大小(以字节为单位),以字典形式返回,字典的键为函数名,值是分配的大小。如果传入单个 PrimFunc,则返回函数名称“main”。 * **返回类型:** Union[Dict[[str](https://docs.python.org/3/library/stdtypes.html#str), [int](https://docs.python.org/3/library/functions.html#int)], Dict[[str](https://docs.python.org/3/library/stdtypes.html#str), Dict[[str](https://docs.python.org/3/library/stdtypes.html#str), [int](https://docs.python.org/3/library/functions.html#int)]]]。 -## tvm.tir.analysis.analysis.detect_buffer_access_lca(*func:*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)) → [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)[[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer), [Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)] +## tvm.tir.analysis.analysis.detect_buffer_access_lca(*func:*[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)) → [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)[[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer), [Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)] 检测缓冲区访问的最低公共祖先 (LCA),包括高级访问(BufferLoad、BufferStore)和低级访问(BufferLoad、BufferStore 和不透明访问)。LCA 可以是 For 循环,也可以是 Block。 -* **参数:func** ([tvm.tir.PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)):要检测的函数。 +* **参数:func** ([tvm.tir.PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)):要检测的函数。 * **返回:result**:从缓冲区映射到对其的所有访问的 LCA。 -* **返回类型:** Dict[[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer), [Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)]。 +* **返回类型:** Dict[[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer), [Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)]。 -## tvm.tir.analysis.analysis.estimate_tir_flops(*stmt_or_mod:*[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)*|*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)) → [float](https://docs.python.org/3/library/functions.html#float) +## tvm.tir.analysis.analysis.estimate_tir_flops(*stmt_or_mod:*[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)*|*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)) → [float](https://docs.python.org/3/library/functions.html#float) 估计 TIR 片段的 FLOP。 -* **参数:stmt_or_mod** (*Union[*[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)*,*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)*]*):需要估计的 TIR 片段或 IRModule。 +* **参数:stmt_or_mod** (*Union[*[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)*,*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)*]*):需要估计的 TIR 片段或 IRModule。 * **返回:flops**:估计的 FLOP。 * **返回类型:**[float](https://docs.python.org/3/library/functions.html#float)。 -## tvm.tir.analysis.analysis.undefined_vars(*node:*[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *defs:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)] +## tvm.tir.analysis.analysis.undefined_vars(*node:*[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *defs:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)] 在 TIR 语句或表达式中查找未定义的变量。 * **参数:** - * **node** (*Union[*[Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)*,*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*):要检查的 TIR 语句或表达式。 - * **defs** (*Optional**[****List**[***[tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)***]****]*):定义的变量。 + * **node** (*Union[*[Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)*,*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*):要检查的 TIR 语句或表达式。 + * **defs** (*Optional**[****List**[***[tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)***]****]*):定义的变量。 * **返回:result**:未定义的变量。 -* **返回类型:** List[[tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)]。 +* **返回类型:** List[[tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)]。 -## tvm.tir.analysis.analysis.verify_well_formed(*obj:*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)*|*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule), *assert_mode:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [bool](https://docs.python.org/3/library/functions.html#bool) +## tvm.tir.analysis.analysis.verify_well_formed(*obj:*[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)*|*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone), *assert_mode:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [bool](https://docs.python.org/3/library/functions.html#bool) 验证给定的 TIR 是否格式正确。验证包括: * 检查表达式是否不包含在块外定义的变量。 * **参数:** - * **obj** (*Union[*[tvm.tir.PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)*,*[tvm.ir.IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)*]*)**:** 要验证的功能或模块。 + * **obj** (*Union[*[tvm.tir.PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)*,*[tvm.ir.IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)*]*)**:** 要验证的功能或模块。 * **assert_mode** ([bool](https://docs.python.org/3/library/functions.html#bool))**:** 当函数格式不正确时,指示是否会引发错误。 * **返回:result**:它是否是一个格式良好的 TIR 函数。 * **返回类型:**[bool](https://docs.python.org/3/library/functions.html#bool)。 @@ -141,9 +141,9 @@ title: tvm.tir 分析 检测数组中的越界内存访问。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -## tvm.tir.analysis.analysis.find_anchor_block(*mod:*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)) → [Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block) +## tvm.tir.analysis.analysis.find_anchor_block(*mod:*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)) → [Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none) 找到给定模块的「锚块」。 @@ -163,23 +163,23 @@ title: tvm.tir 分析 然而,由 Winograd 卷积创建的模块包含多个带有 init 语句的块(输入变换、分批 GEMM 和输出变换)。我们使用第二个条件(即 flops count)来确定分批 GEMM 块是锚块。 -* **参数:mod** ([tvm.ir.IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)):输入 TIR 模块。 +* **参数:mod** ([tvm.ir.IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)):输入 TIR 模块。 * **返回:anchor_block**:如果找到则为锚块,否则为无。 -* **返回类型:**[Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block)。 +* **返回类型:**[Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none)。 -## tvm.tir.analysis.analysis.get_vtcm_compaction_passes() → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)] +## tvm.tir.analysis.analysis.get_vtcm_compaction_passes() → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)] 用于获取降低通道列表的实用函数,用于计算压缩的 VTCM 分配大小。 * **返回:result**:返回通行证列表。 -* **返回类型:** List[[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)]。 +* **返回类型:** List[[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)]。 -## tvm.tir.analysis.analysis.is_pure_function(*func:*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)) → [bool](https://docs.python.org/3/library/functions.html#bool) +## tvm.tir.analysis.analysis.is_pure_function(*func:*[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)) → [bool](https://docs.python.org/3/library/functions.html#bool) 检查函数是否为纯函数。 -## tvm.tir.analysis.analysis.assert_pure_function(*func:*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)) → [bool](https://docs.python.org/3/library/functions.html#bool) +## tvm.tir.analysis.analysis.assert_pure_function(*func:*[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)) → [bool](https://docs.python.org/3/library/functions.html#bool) 断言该函数是纯函数。 diff --git a/docs/04-api-reference/01-python-api/19-tvm-tir-schedule.md b/docs/04-api-reference/01-python-api/19-tvm-tir-schedule.md index 152fca2..dc99fa6 100644 --- a/docs/04-api-reference/01-python-api/19-tvm-tir-schedule.md +++ b/docs/04-api-reference/01-python-api/19-tvm-tir-schedule.md @@ -20,30 +20,30 @@ TensorIR 调度 API 的命名空间。 * **作用域叶子(scope leaves)**:块 sref。 * 子块:作用域根或特定内部 sref 下的作用域叶块。 -### get_deps_by_src(*block:*[StmtSRef](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.StmtSRef)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Dependency](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Dependency)] +### get_deps_by_src(*block:*[StmtSRef](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulestmtsref)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Dependency](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduledependency)] 获取所有 src 为目标“block”的依赖项。 -* **参数:block** ([StmtSRef](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.StmtSRef)) :查询的区块。 +* **参数:block** ([StmtSRef](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulestmtsref)) :查询的区块。 * **返回:blocks**:依赖项。 -* **返回类型:** List[[Dependency](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Dependency)]。 +* **返回类型:** List[[Dependency](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduledependency)]。 -### get_deps_by_dst(*block:*[StmtSRef](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.StmtSRef)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Dependency](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Dependency)] +### get_deps_by_dst(*block:*[StmtSRef](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulestmtsref)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Dependency](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduledependency)] 获取所有 dst 为目标块的依赖项。 -* **参数:block** ([StmtSRef](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.StmtSRef)):查询的区块。 +* **参数:block** ([StmtSRef](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulestmtsref)):查询的区块。 * **返回:blocks**:依赖项。 -* **返回类型:** List[[Dependency](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Dependency)]。 +* **返回类型:** List[[Dependency](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduledependency)]。 ## *class* tvm.tir.schedule.Dependency 一个元组 (src, dst, kind),表示特定类型的依赖关系。例如,(A, B, kRAW) 表示区块 B 依赖于区块 A,依赖关系类型为「写后读」,即区块 B 读取区块 A 写入的结果。 * **参数:** - * **src** ([StmtSRef](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.StmtSRef)):依赖关系的来源。 - * **dst** ([StmtSRef](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.StmtSRef)):依赖关系的目标。 - * **kind** ([DepKind](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.DepKind)):依赖类型。 + * **src** ([StmtSRef](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulestmtsref)):依赖关系的来源。 + * **dst** ([StmtSRef](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulestmtsref)):依赖关系的目标。 + * **kind** ([DepKind](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduledepkindvalue)):依赖类型。 ## *class* tvm.tir.schedule.DepKind(*value*) @@ -87,27 +87,27 @@ TensorIR 调度 API 的命名空间。 -### *property* stmt*:*[Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block)*|*[For](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.For)*|*[None](https://docs.python.org/3/library/constants.html#None) +### *property* stmt*:*[Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none)*|*[For](/docs/api-reference/python-api/tvm-tir#class-tvmtirforloop_varvar-minprimexpr-extentprimexpr-kindforkind-bodystmt-thread_bindingitervarnone-none-annotationsmappingstr-object-none-none-spanspannone-none)*|*[None](https://docs.python.org/3/library/constants.html#None) 对象引用的块/语句。 -### *property* parent*:*[StmtSRef](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.StmtSRef)*|*[None](https://docs.python.org/3/library/constants.html#None) +### *property* parent*:*[StmtSRef](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulestmtsref)*|*[None](https://docs.python.org/3/library/constants.html#None) 父 sref。 -### *static* inline_mark() → [StmtSRef](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.StmtSRef) +### *static* inline_mark() → [StmtSRef](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulestmtsref) 一个特殊的 StmtSRef,它不指向 AST 中的任何 stmt,仅作为「标记」来提示 compute-at 执行 compute-inline 的工作。 -### *static* root_mark() → [StmtSRef](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.StmtSRef) +### *static* root_mark() → [StmtSRef](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulestmtsref) 一个特殊的 StmtSRef,它不指向 AST 中的任何 stmt,仅作为「标记」来提示 compute-at 不执行任何操作。 -## *class* tvm.tir.schedule.Instruction(*kind:*[InstructionKind](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.InstructionKind), *inputs:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Any](https://docs.python.org/3/library/typing.html#typing.Any)*]*, *attrs:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Any](https://docs.python.org/3/library/typing.html#typing.Any)*]*, *outputs:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Any](https://docs.python.org/3/library/typing.html#typing.Any)*]*) +## *class* tvm.tir.schedule.Instruction(*kind:*[InstructionKind](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleinstructionkind), *inputs:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Any](https://docs.python.org/3/library/typing.html#typing.Any)*]*, *attrs:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Any](https://docs.python.org/3/library/typing.html#typing.Any)*]*, *outputs:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Any](https://docs.python.org/3/library/typing.html#typing.Any)*]*) 每个调度指令对应一个调度原语。 @@ -115,7 +115,7 @@ TensorIR 调度 API 的命名空间。 ### kind 指令类型。 -* **类型:**[InstructionKind](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.InstructionKind) +* **类型:**[InstructionKind](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleinstructionkind) ### inputs @@ -158,7 +158,7 @@ TensorIR 调度 API 的命名空间。 指令种类名称。 * **类型:**[str](https://docs.python.org/3/library/stdtypes.html#str)。 -:::Note +:::note 目前函子属性尚未在 Python 端公开。 @@ -171,13 +171,13 @@ TensorIR 调度 API 的命名空间。 * **返回:pure**:布尔标志,指示指令是否为纯指令。 * **返回类型:**[bool](https://docs.python.org/3/library/functions.html#bool)。 -### *static* get(*name:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [InstructionKind](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.InstructionKind) +### *static* get(*name:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [InstructionKind](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleinstructionkind) 使用其名称检索 InstructionKind。 * **参数:name** ([str](https://docs.python.org/3/library/stdtypes.html#str)):InstructionKind 的注册名称。 * **返回:kind**:检索到的 InstructionKind。 -* **返回类型:**[InstructionKind](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.InstructionKind)。 +* **返回类型:**[InstructionKind](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleinstructionkind)。 ## *class* tvm.tir.schedule.BlockRV @@ -193,7 +193,7 @@ TensorIR 调度 API 的命名空间。 引用循环的随机变量。 -## *class* tvm.tir.schedule.Schedule(*mod:*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)*|*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule), *, *seed: [int](https://docs.python.org/3/library/functions.html#int) | [None](https://docs.python.org/3/library/constants.html#None) = None*, *debug_mask: [str](https://docs.python.org/3/library/stdtypes.html#str) | [int](https://docs.python.org/3/library/functions.html#int) = 'none'*, *error_render_level: [str](https://docs.python.org/3/library/stdtypes.html#str) = 'detail'*, *enable_check: [bool](https://docs.python.org/3/library/functions.html#bool) = True*) +## *class* tvm.tir.schedule.Schedule(*mod:*[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)*|*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone), *, *seed: [int](https://docs.python.org/3/library/functions.html#int) | [None](https://docs.python.org/3/library/constants.html#None) = None*, *debug_mask: [str](https://docs.python.org/3/library/stdtypes.html#str) | [int](https://docs.python.org/3/library/functions.html#int) = 'none'*, *error_render_level: [str](https://docs.python.org/3/library/stdtypes.html#str) = 'detail'*, *enable_check: [bool](https://docs.python.org/3/library/functions.html#bool) = True*) 面向用户的调度类。 @@ -205,23 +205,21 @@ TensorIR 调度 API 的命名空间。 调度类存储了辅助信息,以便正确、有效地进行调度。 -教程链接:[https://tvm.apache.org/docs/tutorials/language/schedule_primitives.html](https://tvm.apache.org/docs/tutorials/language/schedule_primitives.html)。 - -### *property* mod*:*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule) +### *property* mod*:*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone) 返回正在调度的模块的 AST。 -### *property* state:[ScheduleState](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.ScheduleState)[](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule.state) +### *property* state:[ScheduleState](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulestatemodprimfuncirmodule--debug_mask-str--int--none-enable_check-bool--true) 返回当前调度类中的 ScheduleState。 -### *property* trace:[Trace](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Trace)*|*[None](https://docs.python.org/3/library/constants.html#None) +### *property* trace:[Trace](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduletraceinstslistinstruction-decisionsdictinstructionany)*|*[None](https://docs.python.org/3/library/constants.html#None) 返回内部维护的调度程序执行跟踪。 -### *property* func_working_on*:*[GlobalVar](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.GlobalVar)*|*[None](https://docs.python.org/3/library/constants.html#None) +### *property* func_working_on*:*[GlobalVar](/docs/api-reference/python-api/tvm-ir#class-tvmirglobalvarname_hintstr-type_annottypenone-none)*|*[None](https://docs.python.org/3/library/constants.html#None) 返回当前正在执行的调度函数的 GlobalVar。 @@ -238,12 +236,12 @@ TensorIR 调度 API 的命名空间。 如果未指定其 func_name,此糖函数将指导 GetBlock 方法。 * **参数:func_name** ([str](https://docs.python.org/3/library/stdtypes.html#str)):要处理的函数的名称。 -### copy() → [Schedule](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule) +### copy() → [Schedule](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulemodprimfuncirmodule--seed-int--none--none-debug_mask-str--int--none-error_render_level-str--detail-enable_check-bool--true) 返回调度的副本,包括状态和符号表,* 保证 * 1) SRef 树完全重建;* 2) 正在调度的 IRModule 未受影响;* 3) 所有随机变量在副本中有效,指向相应的 sref * 重建。 * **返回:copy**:调度的新副本。 -* **返回类型:**[Schedule](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule)。 +* **返回类型:**[Schedule](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulemodprimfuncirmodule--seed-int--none--none-debug_mask-str--int--none-error_render_level-str--detail-enable_check-bool--true)。 ### seed(*seed:*[int](https://docs.python.org/3/library/functions.html#int)) → [None](https://docs.python.org/3/library/constants.html#None) @@ -265,29 +263,29 @@ TensorIR 调度 API 的命名空间。 所有参数都转发给底层的 Module.show 和 Trace.show 方法。 -### get(*rand_var_or_sref:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*|*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)*|*[StmtSRef](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.StmtSRef)) → [int](https://docs.python.org/3/library/functions.html#int) | [Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block) | [For](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.For) | [None](https://docs.python.org/3/library/constants.html#None) +### get(*rand_var_or_sref:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*|*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)*|*[StmtSRef](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulestmtsref) → [int](https://docs.python.org/3/library/functions.html#int) | [Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none) | [For](/docs/api-reference/python-api/tvm-tir#class-tvmtirforloop_varvar-minprimexpr-extentprimexpr-kindforkind-bodystmt-thread_bindingitervarnone-none-annotationsmappingstr-object-none-none-spanspannone-none) | [None](https://docs.python.org/3/library/constants.html#None) 返回: - BlockRV 计算结果对应的 Block; - LoopRV 计算结果对应的 For; - ExprRV 计算结果对应的整数; - 块 sref 指向的对应 Block; - 循环 sref 指向的对应 For; -* **参数:rand_var_or_sref** (*Union**[****ExprRV,*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)*,*[StmtSRef](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.StmtSRef)*]*):需要评估的随机变量 / sref。 +* **参数:rand_var_or_sref** (*Union**[****ExprRV,*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)*,*[StmtSRef](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulestmtsref)*]*):需要评估的随机变量 / sref。 * **返回:result**:相应的结果。 -* **返回类型:** Optional[Union[[int](https://docs.python.org/3/library/functions.html#int), [Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block), [For](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.For)]]。 +* **返回类型:** Optional[Union[[int](https://docs.python.org/3/library/functions.html#int), [Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none), [For](/docs/api-reference/python-api/tvm-tir#class-tvmtirforloop_varvar-minprimexpr-extentprimexpr-kindforkind-bodystmt-thread_bindingitervarnone-none-annotationsmappingstr-object-none-none-spanspannone-none)]]。 -### get_sref(*rand_var_or_stmt:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)*|*[Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block)*|*[For](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.For)) → [StmtSRef](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.StmtSRef) | [None](https://docs.python.org/3/library/constants.html#None) +### get_sref(*rand_var_or_stmt:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)*|*[Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none)*|*[For](/docs/api-reference/python-api/tvm-tir#class-tvmtirforloop_varvar-minprimexpr-extentprimexpr-kindforkind-bodystmt-thread_bindingitervarnone-none-annotationsmappingstr-object-none-none-spanspannone-none)) → [StmtSRef](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulestmtsref) | [None](https://docs.python.org/3/library/constants.html#None) 返回与给定对象对应的 sref,支持对象类型:1) LoopRV 2) BlockRV 3) Block 4) For。 -* **参数:rand_var_or_stmt** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)*,*[Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block)*,*[For](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.For)*]*):需要评估的随机变量 / sref。 +* **参数:rand_var_or_stmt** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)*,*[Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none)*,*[For](/docs/api-reference/python-api/tvm-tir#class-tvmtirforloop_varvar-minprimexpr-extentprimexpr-kindforkind-bodystmt-thread_bindingitervarnone-none-annotationsmappingstr-object-none-none-spanspannone-none)*]*):需要评估的随机变量 / sref。 * **返回:result**:相应的结果。 -* **返回类型:** Optional[[StmtSRef](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.StmtSRef)]。 +* **返回类型:** Optional[[StmtSRef](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulestmtsref)]。 -### remove_rv(*rand_var:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*|*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)) → [None](https://docs.python.org/3/library/constants.html#None) +### remove_rv(*rand_var:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*|*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)) → [None](https://docs.python.org/3/library/constants.html#None) 从符号表中删除一个随机变量。 -* **参数:rand_var** (*Union**[***[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)***,[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)***,*** ***ExprRV***]):要删除的随机变量。 +* **参数:rand_var** (*Union**[***[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)***,[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)***,*** ***ExprRV***]):要删除的随机变量。 -### sample_categorical(*candidates:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*, *probs:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[float](https://docs.python.org/3/library/functions.html#float)*]*, *decision:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### sample_categorical(*candidates:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*, *probs:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[float](https://docs.python.org/3/library/functions.html#float)*]*, *decision:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 给定概率分布,对整数进行采样。 @@ -298,24 +296,24 @@ TensorIR 调度 API 的命名空间。 * **返回:result**:从候选人中抽取的随机变量。 * **返回类型:** ExprRV。 -### sample_perfect_tile(*loop:*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV), *n:*[int](https://docs.python.org/3/library/functions.html#int), *max_innermost_factor:*[int](https://docs.python.org/3/library/functions.html#int)*= 16*, *decision:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)] +### sample_perfect_tile(*loop:*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv), *n:*[int](https://docs.python.org/3/library/functions.html#int), *max_innermost_factor:*[int](https://docs.python.org/3/library/functions.html#int)*= 16*, *decision:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)] 对因素进行采样以完美平铺特定循环。 * **参数:** - * **loop** ([LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)): 要平铺的循环。 + * **loop** ([LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)): 要平铺的循环。 * **n** ([int](https://docs.python.org/3/library/functions.html#int)) :要采样的图块数量。 * **max_innermost_factor** ([int](https://docs.python.org/3/library/functions.html#int)):最内层循环中允许采样的最大图块大小。 * **decision**(*可选[List[*[int](https://docs.python.org/3/library/functions.html#int)*]]*):抽样决策(如果有)。 * **返回:result**:长度为n 的列表,即随机采样的完美图块尺寸。 * **返回类型:** List[ExprRV]。 -### sample_partitioned_tile(*loop:*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV), *n:*[int](https://docs.python.org/3/library/functions.html#int), *partition_pos:*[int](https://docs.python.org/3/library/functions.html#int)*= 0*, *innerpart_factor:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *decision:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)] +### sample_partitioned_tile(*loop:*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv), *n:*[int](https://docs.python.org/3/library/functions.html#int), *partition_pos:*[int](https://docs.python.org/3/library/functions.html#int)*= 0*, *innerpart_factor:*[int](https://docs.python.org/3/library/functions.html#int)*= 1*, *decision:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)] 将因子采样到特定循环的分区块中。 * **参数:** - * **loop** ([LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)) :要平铺的循环。 + * **loop** ([LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)) :要平铺的循环。 * **n** ([int](https://docs.python.org/3/library/functions.html#int)) :要采样的图块数量。 * **partition_pos** ([int](https://docs.python.org/3/library/functions.html#int)) :将 tile 分成两部分的位置。 * **innerpart_factor** ([int](https://docs.python.org/3/library/functions.html#int)) :第二部分的因子。 @@ -323,17 +321,17 @@ TensorIR 调度 API 的命名空间。 * **返回:result**:长度为n 的列表,即采样的随机分区图块大小。 * **返回类型:** List[ExprRV]。 -### sample_compute_location(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *decision:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV) +### sample_compute_location(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *decision:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv) 对给定块的计算位置进行采样。 * **参数:** - * **block** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :需要采样计算位置的块。 + * **block** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :需要采样计算位置的块。 * *decision**(*可选**[ [int](https://docs.python.org/3/library/functions.html#int)*]*):采样决策。 * **返回:result**:计算输入块的采样循环。 -* **返回类型:**[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)。 +* **返回类型:**[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)。 -### get_block(*name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *func_name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV) +### get_block(*name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *func_name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv) 通过名称检索特定函数中的块。 @@ -344,55 +342,55 @@ TensorIR 调度 API 的命名空间。 * **name** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :块的名称。 * func_name (可选[[str](https://docs.python.org/3/library/stdtypes.html#str)]= None ) :函数的名称。 * **返回:block**:如果存在 0 个或多个具有特定名称的块,则会引发检索到的块 IndexError。 -* **返回类型:**[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)。 +* **返回类型:**[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)。 -### get_loops(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)] +### get_loops(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)] 获取块在其范围内的父循环,从外到内。 -* **参数:block** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):查询块。 +* **参数:block** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):查询块。 * **返回:loops**:给定块范围内的循环列表,从外到内。 -* **返回类型:** List[[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)]。 +* **返回类型:** List[[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)]。 -### get_child_blocks(*block_or_loop:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)] +### get_child_blocks(*block_or_loop:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)] 获取特定块/循环的叶块。 -* **参数:block_or_loop** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)*]*):查询块/循环。 +* **参数:block_or_loop** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)*]*):查询块/循环。 * **返回:blocks**:特定块/循环内的叶块列表。 -* **返回类型:** List[[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)]。 +* **返回类型:** List[[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)]。 -### get_producers(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)] +### get_producers(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)] 获取特定区块的生产者。 -* **参数:block** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):查询中的块。 +* **参数:block** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):查询中的块。 * **返回:producers**:给定区块的生产者列表。 -* **返回类型:** List[[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)]。 +* **返回类型:** List[[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)]。 -### get_consumers(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)] +### get_consumers(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)] 获取特定区块的消费者。 -* **参数:block** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):查询中的块。 +* **参数:block** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):查询中的块。 * **返回:consumers**:给定区块的消费者列表。 -* **返回类型:** List[[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)]。 +* **返回类型:** List[[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)]。 -### get_output_blocks(*scope_block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)] +### get_output_blocks(*scope_block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)] 获取给定范围内的输出块列表输出块是至少有一个缓冲区被写入但未在 PrimFunc 内分配的块 -* **参数:scope_block** (*Union**[***[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)***,[str](https://docs.python.org/3/library/stdtypes.html#str)***]****,*):收集输出块的范围块。 +* **参数:scope_block** (*Union**[***[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)***,[str](https://docs.python.org/3/library/stdtypes.html#str)***]****,*):收集输出块的范围块。 * **返回:output_blocks**:写入某个输出缓冲区的所有块的列表。 -* **返回类型:** List[[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)]。 +* **返回类型:** List[[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)]。 -### merge(loops:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)*]*) → [LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV) +### merge(loops:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)*]*) → [LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv) 将循环列表合并为一个。其 LCA 下的循环要求:1) 作用域相同。2) 不能包含注释或线程绑定。3) 从 0 开始,且具有相同的范围和相同的嵌套深度。4) 从目标循环到其 LCA,内层循环必须是外层循环的唯一子循环。 -* **参数:*loops****(*List[*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)*]*):要合并的循环。 +* **参数:*loops****(*List[*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)*]*):要合并的循环。 * **返回:fused_loop**:合并后的新循环。 -* **返回类型:**[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)。 +* **返回类型:**[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)。 **示例** @@ -451,13 +449,13 @@ def after_fuse(a: T.handle, b: T.handle, c: T.handle) -> None: T.writes(C[vi, vj]) C[vi, vj] = A[vi, vj] * T.float32(2) ``` -### fuse(loops:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)*]*, *preserve_unit_iters:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)[](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule.fuse) +### fuse(loops:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)*]*, *preserve_unit_iters:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)[](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulemodprimfuncirmodule--seed-int--none--none-debug_mask-str--int--none-error_render_level-str--detail-enable_check-bool--true.fuse) 将一系列连续的循环融合为一个。它要求:1) 循环不能包含注释或线程绑定。2) 第 (i+1) 个循环必须是第 i 个循环的唯一子循环。3) 所有循环必须以 0 开头。4) 待融合循环的域不能依赖于另一个待融合循环。 -* **参数:*loops****(*List*[*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)*]*):要融合的循环。 +* **参数:*loops****(*List*[*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)*]*):要融合的循环。 * **返回:fused_loop**:融合后的新循环。 -* **返回类型:**[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)。 +* **返回类型:**[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)。 **示例** @@ -501,11 +499,11 @@ def after_fuse(a: T.handle, b: T.handle) -> None: vj = T.axis.S(128, T.floormod(i_j_fused, 128)) B[vi, vj] = A[vi, vj] * 2.0 ``` -### split(*loop:*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV), *factors:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*]*, *preserve_unit_iters:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *disable_predication:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)] +### split(*loop:*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv), *factors:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*]*, *preserve_unit_iters:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *disable_predication:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)] 将循环拆分为一系列连续的循环。它要求:1)循环不能包含注解或线程绑定。2)循环必须从 0 开始。可以添加谓词以确保循环总数保持不变。在因子中,最多只有一个因子可以为 None,这将被自动推断出来。 - * **参数:loop** ([LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)) :要拆分的循环。 + * **参数:loop** ([LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)) :要拆分的循环。 * **factors** (*List**[****Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,******ExprRV****,None**]***]*):分裂因子潜在输入为: – None – ExprRV – 正常整数。 * **preserve_unit_iters** ([bool](https://docs.python.org/3/library/functions.html#bool)): 是否在块绑定中保留单元迭代器。 * **disable_predication** ([bool](https://docs.python.org/3/library/functions.html#bool)):如果启用,则不创建用于保护循环的谓词。当使用可扩展因子进行拆分时,如果调度编写器知道这些因子可以被循环界限整除,则此功能非常有用。 @@ -513,7 +511,7 @@ def after_fuse(a: T.handle, b: T.handle) -> None: 警告:如果不小心使用,启用此功能可能会导致错误的代码生成。 * **返回:split_loops**:分割后的新循环。 -* **返回类型:** List[[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)]。 +* **返回类型:** List[[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)]。 **示例** @@ -554,15 +552,15 @@ def after_split(a: T.handle, b: T.handle) -> None: vj = T.axis.S(128, j) B[vi, vj] = A[vi, vj] * 2.0 ``` -### loop_partition(*loop:*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV), *factors:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*]*, *preserve_unit_iters:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)] +### loop_partition(*loop:*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv), *factors:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*|*[None](https://docs.python.org/3/library/constants.html#None)*]*, *preserve_unit_iters:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)] 将循环划分为一系列连续的循环。它要求:1)循环不能包含注解或线程绑定。可以添加谓词以确保循环总数保持不变。在因子中,最多只有一个因子可以为 None,这将被自动推断出来。 * **参数:** - * **loop** ([LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)) :要分割的循环。 + * **loop** ([LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)) :要分割的循环。 * **factors** (*List**[****Union**[***[int](https://docs.python.org/3/library/functions.html#int)***,***ExprRV****,None*]*]*) :分区因子潜在输入包括: – None – ExprRV – 正常整数。 * **preserve_unit_iters** ([bool](https://docs.python.org/3/library/functions.html#bool)) :是否在块绑定中保留单元迭代器。 * **返回:partition_loops**:分区后的新循环。 -* **返回类型:** List[[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)]。 +* **返回类型:** List[[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)]。 **示例** @@ -635,11 +633,11 @@ def after_partition(a: T.handle, b: T.handle) -> None: T.writes(B[66:128, 0:128]) B[vi, vj] = A[vi, vj] * T.float32(2) ``` -### reorder(ordered_loops:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)*]*) → [None](https://docs.python.org/3/library/constants.html#None) +### reorder(ordered_loops:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)*]*) → [None](https://docs.python.org/3/library/constants.html#None) 重新排序循环列表。它不要求循环是连续的。它要求:1)循环位于同一链中。这意味着:循环可以排序为 [l_1, l_2, … , l_n],其中 l_i 是 l_{i+1} 的祖先,并且 l_1 和 l_n 之间只有单分支循环(这也表明它们在同一范围内)。2)重新排序后,外层循环的定义域不能依赖于任何内层循环。3)对于循环嵌套下的每个块,其块绑定必须是仿射的,并且块变量必须是数据并行的或缩减的。4)参数中不允许有重复的循环。 -* **参数:*ordered_loops****(*List[*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)*]*):新顺序的循环。 +* **参数:*ordered_loops****(*List[*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)*]*):新顺序的循环。 **示例** @@ -682,12 +680,12 @@ def after_reorder(a: T.handle, b: T.handle) -> None: vi, vj = T.axis.remap("SS", [i, j]) B[vi, vj] = A[vi, vj] * 2.0 ``` -### reorder_block_iter_var(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV), *new_order:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*) → [None](https://docs.python.org/3/library/constants.html#None) +### reorder_block_iter_var(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv), *new_order:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*) → [None](https://docs.python.org/3/library/constants.html#None) 对给定块内的 itervars 进行重新排序。 * **参数:** - * **block** ([BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)):要转换的块。 + * **block** ([BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)):要转换的块。 * **new_order** (*List[*[int](https://docs.python.org/3/library/functions.html#int)*]*) :新的块 itervar 顺序。 @@ -748,12 +746,12 @@ def matmul_after_reorder_block_iter_var( ::: -### add_unit_loop(*block_or_loop:*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)*|*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)) → [LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV) +### add_unit_loop(*block_or_loop:*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)*|*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)) → [LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv) 在特定块或循环之上创建一个新的单元循环。 -* **参数:block_or_loop** (*Union[*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)*,*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*]*):在其上创建新循环的区块。 +* **参数:block_or_loop** (*Union[*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)*,*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*]*):在其上创建新循环的区块。 * **返回:new_loop**:新的单元循环。 -* **返回类型:**[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)。 +* **返回类型:**[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)。 **示例** @@ -797,11 +795,11 @@ def after_add_unit_loop( vi = T.axis.spatial(1, 0) C[()] = A[()] + B[()] ``` -### parallel(*loop:*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)) → [None](https://docs.python.org/3/library/constants.html#None) +### parallel(*loop:*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)) → [None](https://docs.python.org/3/library/constants.html#None) 并行化输入循环。它要求:1)循环所在的作用域块应具有阶段流水线属性;2)循环下的所有块都是完整块或归约块,并且具有仿射绑定;3)对于循环下的每个块,循环只能包含在数据并行块迭代器的绑定中。 -* **参数:loop** ([LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)):要并行化的循环。 +* **参数:loop** ([LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)):要并行化的循环。 **示例** @@ -843,11 +841,11 @@ def after_parallel(a: T.handle, b: T.handle) -> None: vi, vj = T.axis.remap("SS", [i, j]) B[vi, vj] = A[vi, vj] * 2.0 ``` -### vectorize(*loop:*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)) → [None](https://docs.python.org/3/library/constants.html#None) +### vectorize(*loop:*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)) → [None](https://docs.python.org/3/library/constants.html#None) 对输入循环进行矢量化。它要求:1)循环所在的作用域块应具有阶段流水线属性;2)循环下的所有块均为完整块或归约块,且具有仿射绑定;3)对于循环下的每个块,该循环只能包含在数据并行块迭代器的绑定中。 -* **参数:loop** ([LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)):要矢量化的循环。 +* **参数:loop** ([LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)):要矢量化的循环。 **示例** @@ -889,12 +887,12 @@ def after_vectorize(a: T.handle, b: T.handle) -> None: vi, vj = T.axis.remap("SS", [i, j]) B[vi, vj] = A[vi, vj] * 2.0 ``` -### bind(*loop:*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV), *thread_axis:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [None](https://docs.python.org/3/library/constants.html#None) +### bind(*loop:*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv), *thread_axis:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [None](https://docs.python.org/3/library/constants.html#None) 将输入循环绑定到给定的线程轴。它要求:1) 循环所在的作用域块应具有 stage-pipeline 属性;2) 循环下的所有块均为完整块或归约块,且具有仿射绑定;3) 对于循环下的每个块,如果线程轴以“threadIdx”开头,则该循环只能包含在数据并行块迭代器和归约块迭代器的绑定中。否则,该循环只能包含在数据并行块迭代器的绑定中。 * **参数:** - * **loop** ([LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)) :要绑定到线程轴的循环。 + * **loop** ([LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)) :要绑定到线程轴的循环。 * **thread_axis** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :要绑定到循环的线程轴。可能的候选:– blockIdx.x/y/z – threadIdx.x/y/z – vthread.x/y/z – vthread(这是一个将被弃用的遗留行为。请改用 vthread.x/y/z 。)。 @@ -938,11 +936,11 @@ def after_bind(a: T.handle, b: T.handle) -> None: vi, vj = T.axis.remap("SS", [i, j]) B[vi, vj] = A[vi, vj] * 2.0 ``` -### unroll(*loop:*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)) → [None](https://docs.python.org/3/library/constants.html#None) +### unroll(*loop:*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)) → [None](https://docs.python.org/3/library/constants.html#None) 展开输入循环。它不需要。 -* **参数:loop** ([LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)):要展开的循环。 +* **参数:loop** ([LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)):要展开的循环。 **示例** @@ -984,7 +982,7 @@ def after_unroll(a: T.handle, b: T.handle) -> None: vi, vj = T.axis.remap("SS", [i, j]) B[vi, vj] = A[vi, vj] * 2.0 ``` -### cache_read(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *read_buffer_index:*[int](https://docs.python.org/3/library/functions.html#int)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer), *storage_scope:*[str](https://docs.python.org/3/library/stdtypes.html#str), *consumer_blocks:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV) +### cache_read(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *read_buffer_index:*[int](https://docs.python.org/3/library/functions.html#int)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer), *storage_scope:*[str](https://docs.python.org/3/library/stdtypes.html#str), *consumer_blocks:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv) 创建一个块,用于将缓冲区读入读缓存。它需要: @@ -995,12 +993,12 @@ def after_unroll(a: T.handle, b: T.handle) -> None: 2. 范围块具有阶段管道属性。 * **参数:** - * **block** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :目标缓冲区的消费者块。 - * **buffer** (*Union[*[int](https://docs.python.org/3/library/functions.html#int)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)*]*) :块读取区域中缓冲区的索引、块中读取缓冲区的唯一名称或块读取区域内的 Buffer 对象。 + * **block** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :目标缓冲区的消费者块。 + * **buffer** (*Union[*[int](https://docs.python.org/3/library/functions.html#int)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)*]*) :块读取区域中缓冲区的索引、块中读取缓冲区的唯一名称或块读取区域内的 Buffer 对象。 * **storage_scope** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :目标存储范围。 - * **consumer_blocks** (*Optional**[****List**[****Union**[***[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)***,*** [str](https://docs.python.org/3/library/stdtypes.html#str)***]****]]*) :可选,包含需要从缓存读取数据的消费者列表。若未指定,则所有消费者都将使用缓存。 + * **consumer_blocks** (*Optional**[****List**[****Union**[***[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)***,*** [str](https://docs.python.org/3/library/stdtypes.html#str)***]****]]*) :可选,包含需要从缓存读取数据的消费者列表。若未指定,则所有消费者都将使用缓存。 * **返回:cached_block**:缓存阶段的块。 -* **返回类型:**[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)。 +* **返回类型:**[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)。 **示例** @@ -1047,7 +1045,7 @@ def after_cache_read(a: T.handle, b: T.handle) -> None: vi, vj = T.axis.remap("SS", [i, j]) B[vi, vj] = A_local[vi, vj] * 2.0 ``` -### cache_write(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *write_buffer_index:*[int](https://docs.python.org/3/library/functions.html#int)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer), *storage_scope:*[str](https://docs.python.org/3/library/stdtypes.html#str), *consumer_blocks:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV) +### cache_write(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *write_buffer_index:*[int](https://docs.python.org/3/library/functions.html#int)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer), *storage_scope:*[str](https://docs.python.org/3/library/stdtypes.html#str), *consumer_blocks:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv) 创建一个块,用于将缓冲区读入写缓存。它需要: @@ -1058,12 +1056,12 @@ def after_cache_read(a: T.handle, b: T.handle) -> None: 2. 范围块具有阶段管道属性。 * **参数:** - * **block** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :目标缓冲区的生产者块。 + * **block** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :目标缓冲区的生产者块。 * **write_buffer_index** ([int](https://docs.python.org/3/library/functions.html#int)) :块的写入区域中缓冲区的索引、块中写入缓冲区的唯一名称或块写入区域内的缓冲区对象。 * **storage_scope** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :目标存储范围。 - * **consumer_blocks** (*Optional**[****List**[****Union**[***[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)***,*** [str](https://docs.python.org/3/library/stdtypes.html#str)***]****]]*) :可选列表,列出应直接从缓存读取数据的消费者。如果未指定,则所有消费者都将从原始缓冲区读取数据。 + * **consumer_blocks** (*Optional**[****List**[****Union**[***[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)***,*** [str](https://docs.python.org/3/library/stdtypes.html#str)***]****]]*) :可选列表,列出应直接从缓存读取数据的消费者。如果未指定,则所有消费者都将从原始缓冲区读取数据。 * **返回:cached_block**:缓存阶段的块。 -* **返回类型:**[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)。 +* **返回类型:**[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)。 **示例** @@ -1110,7 +1108,7 @@ def after_cache_write(a: T.handle, b: T.handle) -> None: vi, vj = T.axis.remap("SS", [i, j]) B[vi, vj] = B_local[vi, vj] ``` -### reindex_cache_read(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *read_buffer_index:*[int](https://docs.python.org/3/library/functions.html#int), *storage_scope:*[str](https://docs.python.org/3/library/stdtypes.html#str), *index_map:*[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap)*|*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)) → [BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV) +### reindex_cache_read(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *read_buffer_index:*[int](https://docs.python.org/3/library/functions.html#int), *storage_scope:*[str](https://docs.python.org/3/library/stdtypes.html#str), *index_map:*[IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map)*|*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)) → [BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv) 创建一个块,使用索引图指定的自定义索引将缓冲区读取到读取缓存中。缓冲区的读取区域必须是单个点。 @@ -1121,12 +1119,12 @@ def after_cache_write(a: T.handle, b: T.handle) -> None: 与 cache_read 不同,reindex_cache_read 仅支持单个消费者, 当有多个消费者时请使用 cache_read 。 * **参数:** - * **block** ([BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)):目标缓冲区的消费者块。 + * **block** ([BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)):目标缓冲区的消费者块。 * **read_buffer_index** ([int](https://docs.python.org/3/library/functions.html#int)) :块读取区域中缓冲区的索引。 * **storage_scope** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :目标存储范围。 - * **index_map** (*Union*[***[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap)***,****Callable****]) :用户定义索引来访问分配的缓存缓冲区,从块迭代变量映射。 + * **index_map** (*Union*[***[IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map)***,****Callable****]) :用户定义索引来访问分配的缓存缓冲区,从块迭代变量映射。 * **返回:cached_block**:缓存阶段的块。 -* **返回类型:**[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)。 +* **返回类型:**[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)。 **示例** @@ -1182,7 +1180,7 @@ def after_reindex_cache_read(a: T.handle, b: T.handle) -> None: ::: -### reindex_cache_write(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *write_buffer_index:*[int](https://docs.python.org/3/library/functions.html#int), *storage_scope:*[str](https://docs.python.org/3/library/stdtypes.html#str), *index_map:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*|*[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap)) → [BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV) +### reindex_cache_write(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *write_buffer_index:*[int](https://docs.python.org/3/library/functions.html#int), *storage_scope:*[str](https://docs.python.org/3/library/stdtypes.html#str), *index_map:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*|*[IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map)) → [BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv) 创建一个块,使用索引图指定的自定义索引将缓冲区读入写缓存。缓冲区的写入区域必须是单个点。 @@ -1193,13 +1191,13 @@ def after_reindex_cache_read(a: T.handle, b: T.handle) -> None: 与 cache_write 不同,reindex_cache_write 仅支持单个消费者, 当有多个消费者时请使用 cache_write 。 * **参数:** - * **block** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :目标缓冲区的消费者块。 + * **block** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :目标缓冲区的消费者块。 * **write_buffer_index** ([int](https://docs.python.org/3/library/functions.html#int)) :块写入区域中缓冲区的索引。 * **storage_scope** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :目标存储范围。 - * **index_map** (*Union**[****Callable,*[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap)*]*) :用户定义索引来访问分配的缓存缓冲区,从块迭代变量映射。 - * **consumer_blocks** (*Optional**[****List**[****Union**[***[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)***,*** [str](https://docs.python.org/3/library/stdtypes.html#str)***]****]]*):可选列表,列出应直接从缓存读取数据的消费者。如果未指定,则所有消费者都将从原始缓冲区读取数据。 + * **index_map** (*Union**[****Callable,*[IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map)*]*) :用户定义索引来访问分配的缓存缓冲区,从块迭代变量映射。 + * **consumer_blocks** (*Optional**[****List**[****Union**[***[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)***,*** [str](https://docs.python.org/3/library/stdtypes.html#str)***]****]]*):可选列表,列出应直接从缓存读取数据的消费者。如果未指定,则所有消费者都将从原始缓冲区读取数据。 * **返回:cached_block**:缓存阶段的块。 -* **返回类型:**[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)。 +* **返回类型:**[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)。 **示例** @@ -1256,16 +1254,16 @@ def after_cache_write(a: T.handle, b: T.handle) -> None: ### -### cache_inplace(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *read_buffer_index:*[int](https://docs.python.org/3/library/functions.html#int)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer), *storage_scope:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)] +### cache_inplace(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *read_buffer_index:*[int](https://docs.python.org/3/library/functions.html#int)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer), *storage_scope:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)] 创建块,将缓冲区读写到缓存块中。它要求目标块同时读写目标缓冲区。主要用于就地操作。 * **参数:** - * **block** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :目标块对目标缓冲区进行操作。 + * **block** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :目标块对目标缓冲区进行操作。 * **read_buffer_index** ([int](https://docs.python.org/3/library/functions.html#int)) :块读取区域中缓冲区的索引、块中读取缓冲区的唯一名称或块读取区域内的缓冲区对象。 * **storage_scope** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :目标存储范围。 * **返回:cached_blocks**:缓存阶段的块,首先读取缓存,然后写入缓存。 -* **返回类型:** List[[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)]。 +* **返回类型:** List[[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)]。 **示例** @@ -1318,16 +1316,16 @@ def cache_inplace(data_io: T.Buffer(64, "int32")) -> None: T.writes(data_io[v0]) data_io[v0] = data_io_local[v0] ``` -### cache_index(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *storage_scope:*[str](https://docs.python.org/3/library/stdtypes.html#str), *cse_thresh:*[int](https://docs.python.org/3/library/functions.html#int)*= 0*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)] +### cache_index(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *storage_scope:*[str](https://docs.python.org/3/library/stdtypes.html#str), *cse_thresh:*[int](https://docs.python.org/3/library/functions.html#int)*= 0*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)] 创建一个块来缓存预先计算的索引以供以后使用。如果没有索引计算,则保持不变。 * **参数:** - * **block** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :目标块对目标缓冲区进行操作。 + * **block** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :目标块对目标缓冲区进行操作。 * **storage_scope** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :缓存块的存储范围。 * **cse_thresh** ([int](https://docs.python.org/3/library/functions.html#int)) :确定公共子表达式的重复阈值,默认值 0 表示缓存所有索引计算。 * **返回:cached_blocks**:写入缓存缓冲区的阶段的块。 -* **返回类型:** List[[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)]。 +* **返回类型:** List[[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)]。 **示例** @@ -1386,15 +1384,15 @@ def resize_cache_index( T.writes(B[n, c, vi, vj]) B[n, c, vi, vj] = A[n, c, index_var_0[vi, vj], index_var_1[vj]] ``` -### reindex(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *buffer:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[int](https://docs.python.org/3/library/functions.html#int)*] |*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)) → [BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV) +### reindex(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *buffer:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[int](https://docs.python.org/3/library/functions.html#int)*] |*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)) → [BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv) 创建一个块,用于将缓冲区读/写到读/写缓存中,并进行重建索引。缓存的布局将与读/写缓冲区的块的迭代器相同。它要求:1) 只有一个块读取/写入目标缓冲区;2) 块中只有一个缓冲区加载/存储该缓冲区; * **参数:** - * **block** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :访问目标缓冲区的块。如果是字符串,则必须唯一地标识一个块。 - * **缓冲区**(*联合[*[元组](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[int](https://docs.python.org/3/library/functions.html#int)*],*[缓冲区](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):需要转换的缓冲区,或者如何识别需要转换的缓冲区的规范。如果缓冲区是的元组`(str,int)`,则第一项应该是“读”或“写”,第二项是块的读或写区域的索引。如果 buffer 是一个字符串,则它是缓冲区的名称,该缓冲区必须存在于块的读/写操作中。此外,块的读/写操作中不能包含多个同名缓冲区。 如果缓冲区是缓冲区对象,它必须存在于块的读/写范围内。 + * **block** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :访问目标缓冲区的块。如果是字符串,则必须唯一地标识一个块。 + * **缓冲区**(*联合[*[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[int](https://docs.python.org/3/library/functions.html#int)*],*[缓冲区](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):需要转换的缓冲区,或者如何识别需要转换的缓冲区的规范。如果缓冲区是的元组`(str,int)`,则第一项应该是“读”或“写”,第二项是块的读或写区域的索引。如果 buffer 是一个字符串,则它是缓冲区的名称,该缓冲区必须存在于块的读/写操作中。此外,块的读/写操作中不能包含多个同名缓冲区。 如果缓冲区是缓冲区对象,它必须存在于块的读/写范围内。 * **返回:reindex_block**:重新索引阶段的块。 -* **返回类型:**[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)。 +* **返回类型:**[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)。 **示例** @@ -1442,7 +1440,7 @@ def after_reindex( vi, vj = T.axis.remap("SS", [i, j]) B[vi, vj] = A_reindex[vi, vj] * 2.0 ``` -### compute_at(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *loop:*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV), *preserve_unit_loops:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *index:*[int](https://docs.python.org/3/library/functions.html#int)*= -1*) → [None](https://docs.python.org/3/library/constants.html#None) +### compute_at(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *loop:*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv), *preserve_unit_loops:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *index:*[int](https://docs.python.org/3/library/functions.html#int)*= -1*) → [None](https://docs.python.org/3/library/constants.html#None) Compute-At。将生产者块移动到特定循环下,并重新生成由该块引发的循环,以使生产者块生成的缓冲区能够覆盖其消费者块在给定循环下消耗的区域。它需要: @@ -1458,8 +1456,8 @@ Compute-At。将生产者块移动到特定循环下,并重新生成由该块 5. 该块的所有消费者都在给定的循环下。 * **参数:** - * **block** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :要移动的块。 - * **loop** ([LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)) :移动方块的循环。 + * **block** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :要移动的块。 + * **loop** ([LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)) :移动方块的循环。 * **preserve_unit_loops** ([bool](https://docs.python.org/3/library/functions.html#bool)) :是否保留范围为 1 的简单循环。 * **index** ([int](https://docs.python.org/3/library/functions.html#int)) :循环体子树块的块索引: – index = –1表示插入到最后一个可能的插入点; – index = –2表示插入到第一个可能的插入点; – 否则,index 是一个非负数,表示插入点。 @@ -1515,7 +1513,7 @@ def after_compute_at(a: T.handle, c: T.handle) -> None: vi, vj = T.axis.remap("SS", [i, j]) C[vi, vj] = B[vi, vj] + 1.0 ``` -### reverse_compute_at(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *loop:*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV), *preserve_unit_loops:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *index:*[int](https://docs.python.org/3/library/functions.html#int)*= -1*) → [None](https://docs.python.org/3/library/constants.html#None) +### reverse_compute_at(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *loop:*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv), *preserve_unit_loops:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*, *index:*[int](https://docs.python.org/3/library/functions.html#int)*= -1*) → [None](https://docs.python.org/3/library/constants.html#None) 反向计算。将消费者块移动到特定循环下,并重新生成由该块引发的循环,以使消费者块消耗的缓冲区能够覆盖其生产者块在给定循环下生成的缓冲区。它需要: @@ -1528,8 +1526,8 @@ def after_compute_at(a: T.handle, c: T.handle) -> None: 4. 该区块的所有生产者都在给定的循环下。 * **参数:** - * **block** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :要移动的块。 - * **loop** ([LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)) :移动方块的循环。 + * **block** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :要移动的块。 + * **loop** ([LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)) :移动方块的循环。 * **preserve_unit_loops** ([bool](https://docs.python.org/3/library/functions.html#bool)) :是否保留范围为 1 的简单循环。 * **index** ([int](https://docs.python.org/3/library/functions.html#int)) :循环体子树块的块索引: – index = –1表示插入到最后一个可能的插入点; – index = –2表示插入到第一个可能的插入点; – 否则,index 是一个非负数,表示插入点。 @@ -1585,7 +1583,7 @@ def after_reverse_compute_at(a: T.handle, c: T.handle) -> None: vi, vj = T.axis.remap("SS", [i, j]) C[vi, vj] = B[vi, vj] + 1.0 ``` -### compute_inline(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [None](https://docs.python.org/3/library/constants.html#None) +### compute_inline(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [None](https://docs.python.org/3/library/constants.html#None) 将块内联到其消费者中。它需要: @@ -1597,7 +1595,7 @@ def after_reverse_compute_at(a: T.handle, c: T.handle) -> None: 3. 块的主体必须是以下形式的 BufferStore 语句,其中 LHS 的索引都是不同的原子变量,并且语句中不允许使用除这些索引变量之外的任何其他变量。`A[i, j, k, ...] = ...`。 -* **参数:block** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):要内联到其消费者的块。 +* **参数:block** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):要内联到其消费者的块。 **示例** @@ -1643,7 +1641,7 @@ def after_inline(a: T.handle, c: T.handle) -> None: vi, vj = T.axis.remap("SS", [i, j]) C[vi, vj] = A[vi, vj] * 2.0 + 1.0 ``` -### reverse_compute_inline(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [None](https://docs.python.org/3/library/constants.html#None) +### reverse_compute_inline(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [None](https://docs.python.org/3/library/constants.html#None) 将块内联到其唯一的生产者中。它需要: @@ -1656,7 +1654,7 @@ def after_inline(a: T.handle, c: T.handle) -> None: 3. 该块的唯一生产者是先读后写生产者,并且是完整的非根块。 4. 块的主体必须是以下形式的 BufferStore 语句, 其中 RHS 上每个 BufferLoad 的索引都是不同的原子变量,并且语句中不允许使用除这些索引变量之外的任何其他变量。`B[f(i, j, k, ...)] = g(i, j, k, A[i, j, k, ...] ...)`。 -* **参数:block** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):要内联到其生产者的块。 +* **参数:block** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):要内联到其生产者的块。 **示例** @@ -1702,7 +1700,7 @@ def after_inline(a: T.handle, c: T.handle) -> None: vi, vj = T.axis.remap("SS", [i, j]) C[vi, vj] = A[vi, vj] * 2.0 + 1.0 ``` -### decompose_reduction(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *loop:*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)) → [BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV) +### decompose_reduction(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *loop:*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)) → [BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv) 将缩减块分解为两个独立的块。 @@ -1727,10 +1725,10 @@ b. 更新块,即没有 init 语句的原始块。 3. 输入循环不低于与 reduce block var 相关的所有循环。 * **参数:** - * **block** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :要分解的缩减块。 - * **loop** ([LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)) :在其上方插入 init 块的循环。 + * **block** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :要分解的缩减块。 + * **loop** ([LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)) :在其上方插入 init 块的循环。 * **返回:init_block**:初始化块。 -* **返回类型:**[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)。 +* **返回类型:**[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)。 **示例** @@ -1779,7 +1777,7 @@ def after_decompose(a: ty.handle, c: ty.handle) -> None: with tir.block([128, 128, tir.reduce_axis(0, 128)], "C") as [vi, vj, vk]: C[vi, vj] = C[vi, vj] + A[vi, vk] * B[vj, vk] ``` -### rfactor(*loop:*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV), *factor_axis:*[int](https://docs.python.org/3/library/functions.html#int)) → [BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV) +### rfactor(*loop:*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv), *factor_axis:*[int](https://docs.python.org/3/library/functions.html#int)) → [BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv) 通过指定的循环对关联约简块进行因式分解。 @@ -1831,10 +1829,10 @@ for i in range(128): # 循环 i 是数据并行循环(保持不变 B[i] = B[i] + B_rf[i, k] ``` * **参数:** - * **loop** ([LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)) :我们要执行 rfactor 的循环外部块。 + * **loop** ([LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)) :我们要执行 rfactor 的循环外部块。 * **factor_axis** ([int](https://docs.python.org/3/library/functions.html#int)) :新维度在新引入的 rfactor 缓冲区中的位置。 * **返回:rf_block**:计算每个切片的部分结果的块(即上图所描述的第一个块)。 -* **返回类型:**[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)。 +* **返回类型:**[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)。 **示例** @@ -1887,19 +1885,19 @@ def after_rfactor(a: T.handle, b: T.handle) -> None: B[vii] = 0.0 B[vii] = B[vii] + B_rf[vi2, vii] ``` -:::Note +:::note Rfactor 要求:1)循环只有一个子块,并且它是一个缩减块;2)循环是一个缩减循环,即循环变量只绑定到块绑定中的缩减变量;3)循环未并行化、矢量化、展开或绑定到任何线程轴;4)循环所在的块范围是分阶段管道;5)缩减块外部的最外层循环应将缩减块作为其第一个子块;6)最外层缩减循环应该只有一个子块;7)未绑定到块绑定中的任何缩减或数据并行变量的一元范围循环不应出现在某些缩减循环下;8)缩减块应该只写入一个缓冲区,并且它的 init 和 body 都是简单的 BufferStore,并且该模式注册为关联缩减器。预定义模式包括:加法、乘法、最小值和最大值;9)块顶部的每个循环不能同时绑定到数据并行和缩减块绑定; 10) `factor_axis 应在[-ndim(B) - 1, ndim(B)]范围内,其中 B 是归约块写入的缓冲区。负索引根据 numpy 约定进行规范化。 ::: -### storage_align(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *buffer_index:*[int](https://docs.python.org/3/library/functions.html#int), *axis:*[int](https://docs.python.org/3/library/functions.html#int), *factor:*[int](https://docs.python.org/3/library/functions.html#int), *offset:*[int](https://docs.python.org/3/library/functions.html#int)) → [None](https://docs.python.org/3/library/constants.html#None) +### storage_align(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *buffer_index:*[int](https://docs.python.org/3/library/functions.html#int), *axis:*[int](https://docs.python.org/3/library/functions.html#int), *factor:*[int](https://docs.python.org/3/library/functions.html#int), *offset:*[int](https://docs.python.org/3/library/functions.html#int)) → [None](https://docs.python.org/3/library/constants.html#None) 设置特定维度的对齐要求,使得 stride[axis] == k * factor + offset(其中 k 为某个值)。这有助于设置内存布局,从而实现更友好的内存访问模式。例如,我们可以将对齐设置为 factor=2,offset=1,以避免在 GPU 共享内存中线程访问更高维度时发生内存库冲突。 * **参数:** - * **block** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :缓冲区的生产者块。 + * **block** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :缓冲区的生产者块。 * **buffer_index** ([int](https://docs.python.org/3/library/functions.html#int)) :块写入区域中缓冲区的索引。 * **轴**([int](https://docs.python.org/3/library/functions.html#int)):指定对齐的尺寸。 * **factor** ([int](https://docs.python.org/3/library/functions.html#int)) :对齐的因子倍数。 @@ -1959,18 +1957,18 @@ def after_storage_align(a: T.handle, c: T.handle) -> None: 降低传递次数后,缓冲区 B 的步幅将为 [129, 1]。 -:::Note +:::note Storage_align 要求缓冲区是通过 alloc_buffer 定义的中间缓冲区。 ::: -### set_scope(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *buffer_index:*[int](https://docs.python.org/3/library/functions.html#int)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer), *storage_scope:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [None](https://docs.python.org/3/library/constants.html#None) +### set_scope(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *buffer_index:*[int](https://docs.python.org/3/library/functions.html#int)*|*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer), *storage_scope:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [None](https://docs.python.org/3/library/constants.html#None) 设置一个缓冲区的存储范围,其中缓冲区由一个块和一个写入索引指定。 * **参数:** - * **block** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :缓冲区的生产者块。 + * **block** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :缓冲区的生产者块。 * **buffer_index** ([int](https://docs.python.org/3/library/functions.html#int)) :块写入区域中缓冲区的索引。 * **storage_scope** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :要设置的存储范围。 @@ -2025,12 +2023,12 @@ def after_set_scope( vi, vj = T.axis.remap("SS", [i, j]) C[vi, vj] = B_shared[vi, vj] + T.float32(1) ``` -:::Note +:::note set_scope 要求缓冲区是通过 alloc_buffer 定义的中间缓冲区。 ::: -### unsafe_set_dtype(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *buffer_index:*[int](https://docs.python.org/3/library/functions.html#int), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [None](https://docs.python.org/3/library/constants.html#None) +### unsafe_set_dtype(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *buffer_index:*[int](https://docs.python.org/3/library/functions.html#int), *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [None](https://docs.python.org/3/library/constants.html#None) 设置缓冲区的数据类型,其中缓冲区由块和写入索引指定。 @@ -2038,7 +2036,7 @@ set_scope 要求缓冲区是通过 alloc_buffer 定义的中间缓冲区。 该调度原语不安全,可能会因为类型转换而改变程序的正确性,请谨慎使用。 * **参数:** - * **block** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :缓冲区的生产者块。 + * **block** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :缓冲区的生产者块。 * **buffer_index** ([int](https://docs.python.org/3/library/functions.html#int)) :块写入区域中缓冲区的索引。 * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :要设置的数据类型。 @@ -2093,21 +2091,21 @@ def after_set_dtype( vi, vj = T.axis.remap("SS", [i, j] C[vi, vj] = T.cast(B[vi, vj], "float32") + 1.0 ``` -:::Note +:::note unsafe_set_dtype 要求缓冲区是通过 alloc_buffer 定义的中间缓冲区。 ::: -### blockize(*target:*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*]*, *preserve_unit_iters:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV) +### blockize(*target:*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*]*, *preserve_unit_iters:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv) 将多个块或以特定循环为根的子树转换为一个块。 * **参数:** - * **target** ([LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)*orList[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*]*):子树的根或指定块。 + * **target** ([LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)*orList[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*]*):子树的根或指定块。 * **preserve_unit_iters** ([bool](https://docs.python.org/3/library/functions.html#bool)) :是否在块绑定中保留单元迭代器。 * **返回:result**:新的区块。 -* **返回类型:**[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)。 +* **返回类型:**[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)。 **示例** @@ -2162,18 +2160,18 @@ def after_blockize( T.writes(B[vio * 16 + vi, vjo * 16 + vj]) B[vio * 16 + vi, vjo * 16 + vj] = A[vio * 16 + vi, vjo * 16 + vj] * T.float32(2) ``` -:::Note +:::note blockize 要求给定循环下恰好有一个块,并且该块的绑定可以被从给定循环开始的循环所表示的子空间整除。 ::: -### tensorize(*block_or_loop:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV), *tensor_intrin:*[str](https://docs.python.org/3/library/stdtypes.html#str), *preserve_unit_iters:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [None](https://docs.python.org/3/library/constants.html#None) +### tensorize(*block_or_loop:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv), *tensor_intrin:*[str](https://docs.python.org/3/library/stdtypes.html#str), *preserve_unit_iters:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) → [None](https://docs.python.org/3/library/constants.html#None) 使用张量内在函数对循环所包含的计算进行张量化。 * **参数:** - * **block_or_loop** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)*]*) :要张量化的循环。 + * **block_or_loop** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)*]*) :要张量化的循环。 * **tensor_intrin** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :张量内部函数或张量内部函数的名称。 * **preserve_unit_iters** ([bool](https://docs.python.org/3/library/functions.html#bool)) :是否在块绑定中保留单元迭代器。 @@ -2307,12 +2305,12 @@ def after_tensorize( ) ) ``` -### annotate(*block_or_loop:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV), *ann_key:*[str](https://docs.python.org/3/library/stdtypes.html#str), *ann_val:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[int](https://docs.python.org/3/library/functions.html#int)*|*[float](https://docs.python.org/3/library/functions.html#float)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[int](https://docs.python.org/3/library/functions.html#int)*|*[float](https://docs.python.org/3/library/functions.html#float)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*] |*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[int](https://docs.python.org/3/library/functions.html#int)*|*[float](https://docs.python.org/3/library/functions.html#float)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[int](https://docs.python.org/3/library/functions.html#int)*|*[float](https://docs.python.org/3/library/functions.html#float)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]]*) → [None](https://docs.python.org/3/library/constants.html#None) +### annotate(*block_or_loop:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv), *ann_key:*[str](https://docs.python.org/3/library/stdtypes.html#str), *ann_val:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[int](https://docs.python.org/3/library/functions.html#int)*|*[float](https://docs.python.org/3/library/functions.html#float)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[int](https://docs.python.org/3/library/functions.html#int)*|*[float](https://docs.python.org/3/library/functions.html#float)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*] |*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[int](https://docs.python.org/3/library/functions.html#int)*|*[float](https://docs.python.org/3/library/functions.html#float)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*|*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[int](https://docs.python.org/3/library/functions.html#int)*|*[float](https://docs.python.org/3/library/functions.html#float)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]]*) → [None](https://docs.python.org/3/library/constants.html#None) 使用键值对注释块/循环。 * **参数:** - * **block_or_loop** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)*]*) :要注释的块/循环。 + * **block_or_loop** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)*]*) :要注释的块/循环。 * **ann_key** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :注释键。 * **ann_val** (*AnnotationValueT*) :注释值。 @@ -2356,12 +2354,12 @@ def after_annotate(a: T.handle, b: T.handle) -> None: T.block_attr({"ann_key", "ann_value"}) B[vi, vj] = A[vi, vj] * 2.0 ``` -### unannotate(*block_or_loop:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV), *ann_key:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [None](https://docs.python.org/3/library/constants.html#None) +### unannotate(*block_or_loop:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv), *ann_key:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [None](https://docs.python.org/3/library/constants.html#None) 使用键 ann_key 取消注释块/循环的注释。 * **参数:** - * **block_or_loop** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)*]*) :要取消注释的块/循环。 + * **block_or_loop** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)*]*) :要取消注释的块/循环。 * **ann_key** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :注释键。 @@ -2404,15 +2402,15 @@ def after_unannotate(a: T.handle, b: T.handle) -> None: vi, vj = T.axis.remap("SS", [i, j]) B[vi, vj] = A[vi, vj] * 2.0 ``` -### transform_layout(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *buffer:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[int](https://docs.python.org/3/library/functions.html#int)*] |*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer), *index_map:*[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap)*|*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable), *pad_value:*[int](https://docs.python.org/3/library/functions.html#int)*|*[float](https://docs.python.org/3/library/functions.html#float)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*|*[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap)*|*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *, *assume_injective_transform: [bool](https://docs.python.org/3/library/functions.html#bool) = False*) → [None](https://docs.python.org/3/library/constants.html#None) +### transform_layout(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *buffer:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[int](https://docs.python.org/3/library/functions.html#int)*] |*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer), *index_map:*[IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map)*|*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable), *pad_value:*[int](https://docs.python.org/3/library/functions.html#int)*|*[float](https://docs.python.org/3/library/functions.html#float)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*|*[IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map)*|*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *, *assume_injective_transform: [bool](https://docs.python.org/3/library/functions.html#bool) = False*) → [None](https://docs.python.org/3/library/constants.html#None) 将 IndexMap 表示的转换应用于缓冲区。 * **参数:** - * **block** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :访问目标缓冲区的块。如果是字符串,则必须唯一地标识一个块。 - * **缓冲区**(*联合[*[元组](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[int](https://docs.python.org/3/library/functions.html#int)*],*[缓冲区](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):需要转换的缓冲区,或者如何识别需要转换的缓冲区的规范。如果缓冲区是的元组`(str,int)`,则第一项应该是「读」或「写」,第二项是块的读或写区域的索引。如果 buffer 是一个字符串,则它是缓冲区的名称,该缓冲区必须存在于块的读/写操作中。此外,块的读/写操作中不能包含多个同名缓冲区。如果缓冲区是缓冲区对象,它必须存在于块的读/写范围内。 - * **index_map**(Union[[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap),Callable]):要应用的转换。如果 index_map 是可调用的,并且返回的列表包含IndexMap.AXIS_SEPARATOR,则除了 TransformLayout 原语之外,还会调用 SetAxisSeparators 原语。 - * pad_value **(可选** [ Union[[int](https://docs.python.org/3/library/functions.html#int),[float](https://docs.python.org/3/library/functions.html#float),[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr),[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap),Callable]]):用于转换引入的任何填充的值。如果调度包含指定缓冲区的生产者块,则填充值将尽可能作为生产者块的一部分写入,否则写入生产者块之后。否则,如果缓冲区是输入,则将插入一个注释块以声明填充值包含已知值。填充值可能不包含 BufferLoad 的实例,除非它从被转换的缓冲区加载一个值(例如,创建一个由重复元素组成的填充循环缓冲区)。 + * **block** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :访问目标缓冲区的块。如果是字符串,则必须唯一地标识一个块。 + * **缓冲区**(*联合[*[元组](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[int](https://docs.python.org/3/library/functions.html#int)*],*[缓冲区](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):需要转换的缓冲区,或者如何识别需要转换的缓冲区的规范。如果缓冲区是的元组`(str,int)`,则第一项应该是「读」或「写」,第二项是块的读或写区域的索引。如果 buffer 是一个字符串,则它是缓冲区的名称,该缓冲区必须存在于块的读/写操作中。此外,块的读/写操作中不能包含多个同名缓冲区。如果缓冲区是缓冲区对象,它必须存在于块的读/写范围内。 + * **index_map**(Union[[IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map),Callable]):要应用的转换。如果 index_map 是可调用的,并且返回的列表包含IndexMap.AXIS_SEPARATOR,则除了 TransformLayout 原语之外,还会调用 SetAxisSeparators 原语。 + * pad_value **(可选** [ Union[[int](https://docs.python.org/3/library/functions.html#int),[float](https://docs.python.org/3/library/functions.html#float),[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr),[IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map),Callable]]):用于转换引入的任何填充的值。如果调度包含指定缓冲区的生产者块,则填充值将尽可能作为生产者块的一部分写入,否则写入生产者块之后。否则,如果缓冲区是输入,则将插入一个注释块以声明填充值包含已知值。填充值可能不包含 BufferLoad 的实例,除非它从被转换的缓冲区加载一个值(例如,创建一个由重复元素组成的填充循环缓冲区)。 @@ -2471,13 +2469,13 @@ def two_elementwise_transformed_intermediate_buffer(a: T.handle, c: T.handle) -> vi, vj = T.axis.remap("SS", [i, j]) C[vi, vj] = B[vi // 16, vj // 16, vi % 16, vj % 16] + 1.0 ``` -### transform_block_layout(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *index_map:*[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap)*|*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)) → [None](https://docs.python.org/3/library/constants.html#None) +### transform_block_layout(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *index_map:*[IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map)*|*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)) → [None](https://docs.python.org/3/library/constants.html#None) 将 IndexMap 表示的转换应用于块。 * **参数:** - * **block** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :要转换的块。 - * **index_map** (*Union**[***[IndexMap](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IndexMap)***,*** ***Callable****]*) :要应用的转换。 + * **block** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :要转换的块。 + * **index_map** (*Union**[***[IndexMap](/docs/api-reference/python-api/tvm-tir#class-tvmtirindexmapinitial_indices-final_indices-inverse_index_map)***,*** ***Callable****]*) :要应用的转换。 **示例** @@ -2520,13 +2518,13 @@ def after_transform_block_layout( vi, = T.axis.remap("S", [i]) B[vi // 16, vi % 16] = A[vi // 16, vi % 16] * 2.0 ``` -### set_axis_separator(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *buffer:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[int](https://docs.python.org/3/library/functions.html#int)*] |*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer), *axis_separators:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)) → [None](https://docs.python.org/3/library/constants.html#None) +### set_axis_separator(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *buffer:*[Tuple](https://docs.python.org/3/library/typing.html#typing.Tuple)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[int](https://docs.python.org/3/library/functions.html#int)*] |*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer), *axis_separators:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*] |*[None](https://docs.python.org/3/library/constants.html#None)) → [None](https://docs.python.org/3/library/constants.html#None) 设置缓冲区的轴分隔符,其中缓冲区由块和读取或写入索引指定。 * **参数:** - * **block** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :访问目标缓冲区的块。如果是字符串,则必须唯一地标识一个块。 - * **缓冲区**(*联合[*[元组](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[int](https://docs.python.org/3/library/functions.html#int)*],*[缓冲区](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):需要转换的缓冲区,或者如何识别需要转换的缓冲区的规范。如果缓冲区是的元组`(str,int)`,则第一项应该是「读」或「写」,第二项是块的读或写区域的索引。如果 buffer 是一个字符串,则它是缓冲区的名称,该缓冲区必须存在于块的读/写操作中。此外,块的读/写操作中不能包含多个同名缓冲区。如果缓冲区是缓冲区对象,它必须存在于块的读/写范围内。 + * **block** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :访问目标缓冲区的块。如果是字符串,则必须唯一地标识一个块。 + * **缓冲区**(*联合[*[元组](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[int](https://docs.python.org/3/library/functions.html#int)*],*[缓冲区](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):需要转换的缓冲区,或者如何识别需要转换的缓冲区的规范。如果缓冲区是的元组`(str,int)`,则第一项应该是「读」或「写」,第二项是块的读或写区域的索引。如果 buffer 是一个字符串,则它是缓冲区的名称,该缓冲区必须存在于块的读/写操作中。此外,块的读/写操作中不能包含多个同名缓冲区。如果缓冲区是缓冲区对象,它必须存在于块的读/写范围内。 * **axis_separators**(*可选*[***列表[*[int](https://docs.python.org/3/library/functions.html#int)*]]*):轴分隔符。 @@ -2581,7 +2579,7 @@ def after_set_axis_separators( vi, vj = T.axis.remap("SS", [i, j]) C[vi, vj] = B[vi, vj] + T.float32(1) ``` -### decompose_padding(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *loop:*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)) → [BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV) +### decompose_padding(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *loop:*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)) → [BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv) 将填充计算模式块分解为两个独立的块。 @@ -2606,10 +2604,10 @@ b. 将边界值填充到填充谓词为真的区域中的块。 3. 输入块是与填充模式匹配的块。 * **参数:** - * **block** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :要分解的填充块。 - * **loop** ([LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)) :在其上方插入 pad 值填充块的循环。 + * **block** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :要分解的填充块。 + * **loop** ([LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)) :在其上方插入 pad 值填充块的循环。 * **返回:pad_value_block**:填充 const pad 值的块。 -* **返回类型:**[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)。 +* **返回类型:**[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)。 **示例** @@ -2651,12 +2649,12 @@ def after_decompose(x: T.Buffer(128, "int32"), y: T.Buffer(140, "int32")): vi = T.axis.spatial(128, i) y[vi + 6] = x[vi] ``` -### can_decompose_padding(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *loop:*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)) → [bool](https://docs.python.org/3/library/functions.html#bool) +### can_decompose_padding(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *loop:*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)) → [bool](https://docs.python.org/3/library/functions.html#bool) 检查块是否匹配填充模式并且可以分解。 -### pad_einsum(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *padding:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*) → [None](https://docs.python.org/3/library/constants.html#None) +### pad_einsum(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *padding:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*) → [None](https://docs.python.org/3/library/constants.html#None) 填充 Einsum 的计算。 @@ -2667,7 +2665,7 @@ def after_decompose(x: T.Buffer(128, "int32"), y: T.Buffer(140, "int32")): Einsum 模式意味着缓冲区访问上的所有索引要么是常量(例如 B[0]),要么是变量(例如 B[i]),但不是由复合表达式(例如 B[i + 1])组成。 * **参数:** - * **block** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :与 Einsum 模式匹配的块。 + * **block** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :与 Einsum 模式匹配的块。 * **padding** (*List[*[int](https://docs.python.org/3/library/functions.html#int)*]*) :每个块迭代器的填充。 @@ -2742,7 +2740,7 @@ def main( v0, v1 = T.axis.remap("SS", [i0, i1]) C[v0, v1] = C_pad[v0, v1] ``` -### rolling_buffer(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *write_buffer_index:*[int](https://docs.python.org/3/library/functions.html#int)) → [None](https://docs.python.org/3/library/constants.html#None) +### rolling_buffer(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*|*[str](https://docs.python.org/3/library/stdtypes.html#str), *write_buffer_index:*[int](https://docs.python.org/3/library/functions.html#int)) → [None](https://docs.python.org/3/library/constants.html#None) 通过滚动缓冲计算目标缓冲区,选择块祖先循环中出现的具有正边界重叠的最外层可滚动轴作为滚动轴,沿滚动维度折叠并循环缓冲区,并附加块谓词以避免重新计算重叠元素。它需要: @@ -2759,7 +2757,7 @@ def main( 1. 缓冲区的访问区域至少有一个维度包含正边界重叠。 * **参数:** - * **block** (*Union[*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :缓冲区的生产者块。 + * **block** (*Union[*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)*,*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*) :缓冲区的生产者块。 * **write_buffer_index** ([int](https://docs.python.org/3/library/functions.html#int)) :块写入区域中缓冲区的索引。 @@ -2834,7 +2832,7 @@ def after_rolling_buffer( C[ax0_1, ax1_1], B[ax0_1 % 6 + rv0, ax1_1 + rv1] ) ``` -:::Note +:::note 目标缓冲区的消费者块的 region_cover 属性将变为 false。 @@ -2845,27 +2843,27 @@ def after_rolling_buffer( 标志着调度后处理阶段开始的无操作。 -### unsafe_hide_buffer_access(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV), *buf_type:*[str](https://docs.python.org/3/library/stdtypes.html#str), *buf_index_array:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*) → [None](https://docs.python.org/3/library/constants.html#None) +### unsafe_hide_buffer_access(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv), *buf_type:*[str](https://docs.python.org/3/library/stdtypes.html#str), *buf_index_array:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*) → [None](https://docs.python.org/3/library/constants.html#None) 隐藏给定块中的某些缓冲区访问。这是一个不安全的调度原语。 * **参数:** - * **块**([BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)):我们隐藏读取访问权限的块。 + * **块**([BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)):我们隐藏读取访问权限的块。 * **buf_type** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :缓冲区类型:「读」/「写」。 * **buf_index_array** (*List[*[int](https://docs.python.org/3/library/functions.html#int)*]*) :我们隐藏访问的缓冲区索引数组。 -:::Note +:::note 此调度原语不安全,并且可能无法通过依赖性分析。unsafe_hide_buffer_access 的一个用例是隐藏对索引缓冲区的访问(例如在稀疏计算中),以便我们可以进一步对块进行张量化(出现在读/写区域中的索引缓冲区可能无法通过张量化原语中的模式匹配,而隐藏对这些缓冲区的访问可以解决这个问题)。 ::: -### annotate_buffer_access(*block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV), *buffer_index:*[int](https://docs.python.org/3/library/functions.html#int), *buf_type:*[str](https://docs.python.org/3/library/stdtypes.html#str), *gen_new_ranges:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)) → [None](https://docs.python.org/3/library/constants.html#None) +### annotate_buffer_access(*block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv), *buffer_index:*[int](https://docs.python.org/3/library/functions.html#int), *buf_type:*[str](https://docs.python.org/3/library/stdtypes.html#str), *gen_new_ranges:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)) → [None](https://docs.python.org/3/library/constants.html#None) 注释块的读取或写入区域。 * **参数:** - * **block** ([BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)) :需要注释的块。 + * **block** ([BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)) :需要注释的块。 * **buffer_index** ([int](https://docs.python.org/3/library/functions.html#int)) :块的读取或写入区域中缓冲区的索引。 * **buf_type** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :缓冲区类型:「读」或「写」。 * **gen_new_ranges** (*Callable*) :一个函数,它接受块的 iter_vars 并返回一个 Tuple[Union[PrimExpr, Tuple[PrimExpr, PrimExpr]], …] 类型的值,该值定义了缓冲区新的读写区域。该 Tuple 中的每个元素可以是:一个表示 iter_var 本身的 PrimExpr;一个包含两个 PrimExpr 的 Tuple,表示范围 (begin, end)。 @@ -2930,7 +2928,7 @@ def after_annotate_buffer_access( 这将块“B”中缓冲区 A(索引 0)的读取区域注释为块迭代域中每个 (vi, vj) 的 [vi-1:vi+1, vj-1:vj+1]。 -:::Note +:::note 此函数允许手动指定读取或写入区域,这在编译器无法准确推断访问模式(例如复杂的数据依赖型访问)的情况下非常有用。它会覆盖指定缓冲区的自动推断区域。该函数会向块添加一个注释,指示已为给定索引处的缓冲区提供了显式区域。此注释在 CompactBufferAllocation 过程中用于遵循手动指定的区域,而不是依赖自动推断。 @@ -2963,34 +2961,34 @@ ScheduleState 类中 debug_mask 标志的位掩码。 验证 affine_binding、region_cover 和 stage_pipeline 的正确性 * **类型:** int = 2 -### *class* tvm.tir.schedule.ScheduleState(*mod:*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)*|*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule), ***, *debug_mask: [str](https://docs.python.org/3/library/stdtypes.html#str) | [int](https://docs.python.org/3/library/functions.html#int) = 'none'*, *enable_check: [bool](https://docs.python.org/3/library/functions.html#bool) = True*) +### *class* tvm.tir.schedule.ScheduleState(*mod:*[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)*|*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone), ***, *debug_mask: [str](https://docs.python.org/3/library/stdtypes.html#str) | [int](https://docs.python.org/3/library/functions.html#int) = 'none'*, *enable_check: [bool](https://docs.python.org/3/library/functions.html#bool) = True*) 调度状态,它公开了一个 Replace 方法作为所有调度原语操作 TensorIR 的主要手段。 数据结构包含以下信息 1)正在调度的 AST(mod)2)可调度语句的 sref 树(由 srefs 指示)3)每个块范围的依赖信息(block_info)4)从 AST 节点到 sref 树中的反向映射(get_sref)5)调试标志,如果设置,则启用额外检查(debug_mask)6)启用检查标志,如果为 False,则禁用某些先决条件检查。 * **参数:** - * **mod** ([IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)) :正在调度的模块的 AST。 + * **mod** ([IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)) :正在调度的模块的 AST。 * **debug_mask** ([int](https://docs.python.org/3/library/functions.html#int)) :在对象构造之后以及每次调用 Replace 方法后进行额外的正确性检查。 * **enable_check** ([bool](https://docs.python.org/3/library/functions.html#bool)) :指示是否为某些调度原语启用先决条件检查,默认为 True。 -### get_sref(*stmt:*[Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block)*|*[For](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.For)) → [StmtSRef](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.StmtSRef) | [None](https://docs.python.org/3/library/constants.html#None) +### get_sref(*stmt:*[Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none)*|*[For](/docs/api-reference/python-api/tvm-tir#class-tvmtirforloop_varvar-minprimexpr-extentprimexpr-kindforkind-bodystmt-thread_bindingitervarnone-none-annotationsmappingstr-object-none-none-spanspannone-none)) → [StmtSRef](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulestmtsref) | [None](https://docs.python.org/3/library/constants.html#None) 返回指向 stmt 的相应 sref。 -* **参数:stmt** (*Union[*[Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block)*,*[For](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.For)*]*):TensorIR 中可调度的语句,用于检索其 sref。 +* **参数:stmt** (*Union[*[Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none)*,*[For](/docs/api-reference/python-api/tvm-tir#class-tvmtirforloop_varvar-minprimexpr-extentprimexpr-kindforkind-bodystmt-thread_bindingitervarnone-none-annotationsmappingstr-object-none-none-spanspannone-none)*]*):TensorIR 中可调度的语句,用于检索其 sref。 * **返回:sref**:对应的 sref。 -* **返回类型:**[StmtSRef](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.StmtSRef)。 +* **返回类型:**[StmtSRef](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulestmtsref)。 -### get_block_scope(*block_sref:*[StmtSRef](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.StmtSRef)) → [BlockScope](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockScope) +### get_block_scope(*block_sref:*[StmtSRef](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulestmtsref)) → [BlockScope](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockscope) 获取与块 sref 对应的 BlockScope。 -* **参数:block_sref** ([StmtSRef](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.StmtSRef)):要检索的块 sref。 +* **参数:block_sref** ([StmtSRef](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulestmtsref)):要检索的块 sref。 * **返回:sref**:对应的 sref。 -* **返回类型:**[StmtSRef](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.StmtSRef)。 +* **返回类型:**[StmtSRef](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulestmtsref)。 -### replace(*src_sref:*[StmtSRef](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.StmtSRef), *tgt_stmt:*[Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block)*|*[For](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.For)*|*[BlockRealize](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BlockRealize), *block_sref_reuse:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block)*,*[Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [None](https://docs.python.org/3/library/constants.html#None) +### replace(*src_sref:*[StmtSRef](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulestmtsref)), *tgt_stmt:*[Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none)*|*[For](/docs/api-reference/python-api/tvm-tir#class-tvmtirforloop_varvar-minprimexpr-extentprimexpr-kindforkind-bodystmt-thread_bindingitervarnone-none-annotationsmappingstr-object-none-none-spanspannone-none)*|*[BlockRealize](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockrealizeiter_valueslistprimexpr-predicateprimexprbool-blockblock-spanspannone-none), *block_sref_reuse:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none)*,*[Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [None](https://docs.python.org/3/library/constants.html#None) 将 src_sref 指向的 AST 部分替换为具体的语句 tgt_stmt,并相应地维护 sref 树。当 ScheduleState 持有 IRModule 和 IR 节点的唯一副本时,Replace 将尽可能执行写时复制。 @@ -2999,17 +2997,17 @@ Only 3 types of replacements are allowed: from src_sref->stmt to tgt_stmt. 1) Bl 只允许 3 种类型的替换:从 src_sref->stmt 到 tgt_stmt。1) Block -> Block 2) Loop -> Loop 3) Loop -> BlockRealize。 * **参数:** - * **src_sref** ([StmtSRef](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.StmtSRef)) :TensorIR AST 中要替换的语句的 sref。 - * **tgt_stmt** (*Union[*[Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block)*,*[For](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.For)*,*[BlockRealize](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.BlockRealize)*]*) :要替换为的语句。 - * **block_sref_reuse** (*Optional**[****Dict**[***[Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block)***,*** [Block](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Block)***]****]= None*) :将旧块(在 src_sref–>stmt 下的子树中被替换)映射到新块(在 tgt_stmt 下的子树中被替换),并强制在它们之间重用 sref(而不是创建新的 sref),即在被替换之后,指向旧块的 sref 将指向新块。 + * **src_sref** ([StmtSRef](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulestmtsref)) :TensorIR AST 中要替换的语句的 sref。 + * **tgt_stmt** (*Union[*[Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none)*,*[For](/docs/api-reference/python-api/tvm-tir#class-tvmtirforloop_varvar-minprimexpr-extentprimexpr-kindforkind-bodystmt-thread_bindingitervarnone-none-annotationsmappingstr-object-none-none-spanspannone-none)*,*[BlockRealize](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockrealizeiter_valueslistprimexpr-predicateprimexprbool-blockblock-spanspannone-none)*]*) :要替换为的语句。 + * **block_sref_reuse** (*Optional**[****Dict**[***[Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none)***,*** [Block](/docs/api-reference/python-api/tvm-tir#class-tvmtirblockiter_varslistitervar-readslistbufferregion-writeslistbufferregion-name_hintstr-bodystmt-initstmtnone-none-alloc_bufferslistbuffer-none-none-match_bufferslistmatchbufferregion-none-none-annotationsmappingstr-object-none-none-spanspannone-none)***]****]= None*) :将旧块(在 src_sref–>stmt 下的子树中被替换)映射到新块(在 tgt_stmt 下的子树中被替换),并强制在它们之间重用 sref(而不是创建新的 sref),即在被替换之后,指向旧块的 sref 将指向新块。 -:::Note +:::note 根据循环变量的重用自动检测循环引用的重用。 ::: -### *class* tvm.tir.schedule.Trace(*insts:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Instruction](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Instruction)*]*, *decisions:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[Instruction](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Instruction)*,*[Any](https://docs.python.org/3/library/typing.html#typing.Any)*]*) +### *class* tvm.tir.schedule.Trace(*insts:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Instruction](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleinstructionkindinstructionkind-inputslistany-attrslistany-outputslistany)*]*, *decisions:*[Dict](https://docs.python.org/3/library/typing.html#typing.Dict)*[*[Instruction](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleinstructionkindinstructionkind-inputslistany-attrslistany-outputslistany)*,*[Any](https://docs.python.org/3/library/typing.html#typing.Any)*]*) 调度程序的执行轨迹。 @@ -3027,47 +3025,47 @@ Only 3 types of replacements are allowed: from src_sref->stmt to tgt_stmt. 1) Bl 程序执行过程中调用的指令。 -* **类型:** List[[Instruction](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Instruction)] +* **类型:** List[[Instruction](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleinstructionkindinstructionkind-inputslistany-attrslistany-outputslistany)] ### decisions 根据这些指示做出的随机决定。 -* **类型:** Dict[[Instruction](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Instruction), DECISION_TYPE]。 +* **类型:** Dict[[Instruction](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleinstructionkindinstructionkind-inputslistany-attrslistany-outputslistany), DECISION_TYPE]。 -### get_decision(*inst:*[Instruction](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Instruction)) → [Any](https://docs.python.org/3/library/typing.html#typing.Any) | [None](https://docs.python.org/3/library/constants.html#None) +### get_decision(*inst:*[Instruction](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleinstructionkindinstructionkind-inputslistany-attrslistany-outputslistany)) → [Any](https://docs.python.org/3/library/typing.html#typing.Any) | [None](https://docs.python.org/3/library/constants.html#None) 检索针对特定指令做出的决定。 -* **参数:insts** ([Instruction](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Instruction)):要检索其决策的指令。 +* **参数:insts** ([Instruction](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleinstructionkindinstructionkind-inputslistany-attrslistany-outputslistany)):要检索其决策的指令。 * **返回:decision**:相应的决定;如果没有对指令做出决定,则为无。 * **返回类型:** Optional[DECISION_TYPE]。 -### append(*inst:*[Instruction](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Instruction), *decision:*[Any](https://docs.python.org/3/library/typing.html#typing.Any)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [None](https://docs.python.org/3/library/constants.html#None) +### append(*inst:*[Instruction](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleinstructionkindinstructionkind-inputslistany-attrslistany-outputslistany), *decision:*[Any](https://docs.python.org/3/library/typing.html#typing.Any)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [None](https://docs.python.org/3/library/constants.html#None) 将新指令附加到跟踪中。 * **参数:** - * **insts**([指令](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Instruction)):要附加的新指令。 + * **insts**([指令](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleinstructionkindinstructionkind-inputslistany-attrslistany-outputslistany)):要附加的新指令。 * *decision*(*可选*[ *DECISION_TYPE]= None*):对此指令做出的随机决定。 -### pop() → [Instruction](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Instruction) | [None](https://docs.python.org/3/library/constants.html#None) +### pop() → [Instruction](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleinstructionkindinstructionkind-inputslistany-attrslistany-outputslistany) | [None](https://docs.python.org/3/library/constants.html#None) 删除最后一条指令,以及根据该指令做出的决定(如果有)。 * **返回:popped_inst**:返回被移除的指令;如果跟踪为空,则返回 std::nullopt。 -* **返回类型:**[Instruction](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Instruction)。 +* **返回类型:**[Instruction](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleinstructionkindinstructionkind-inputslistany-attrslistany-outputslistany)。 -### apply_to_schedule(*sch:*[Schedule](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule), *remove_postproc:*[bool](https://docs.python.org/3/library/functions.html#bool), *decision_provider:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*[[*[Instruction](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Instruction)*,*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Any](https://docs.python.org/3/library/typing.html#typing.Any)*],*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Any](https://docs.python.org/3/library/typing.html#typing.Any)*],*[Any](https://docs.python.org/3/library/typing.html#typing.Any)*],*[Any](https://docs.python.org/3/library/typing.html#typing.Any)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [None](https://docs.python.org/3/library/constants.html#None) +### apply_to_schedule(*sch:*[Schedule](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulemodprimfuncirmodule--seed-int--none--none-debug_mask-str--int--none-error_render_level-str--detail-enable_check-bool--true), *remove_postproc:*[bool](https://docs.python.org/3/library/functions.html#bool), *decision_provider:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*[[*[Instruction](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleinstructionkindinstructionkind-inputslistany-attrslistany-outputslistany)*,*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Any](https://docs.python.org/3/library/typing.html#typing.Any)*],*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Any](https://docs.python.org/3/library/typing.html#typing.Any)*],*[Any](https://docs.python.org/3/library/typing.html#typing.Any)*],*[Any](https://docs.python.org/3/library/typing.html#typing.Any)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [None](https://docs.python.org/3/library/constants.html#None) 将跟踪应用于 TensorIR 调度。 * **参数:** - * **sch**([调度](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule)):要应用的调度。 + * **sch**([调度](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulemodprimfuncirmodule--seed-int--none--none-debug_mask-str--int--none-error_render_level-str--detail-enable_check-bool--true)):要应用的调度。 * **remove_postproc** ( [bool](https://docs.python.org/3/library/functions.html#bool) ) :如果删除后处理指令。 * *decision_provider*(*可选*[ *Callable]= None*):一个回调函数,允许用户在应用指令时动态修改决策。回调函数的签名如下:第一个参数:指令;第二个参数:输入随机变量;第三个参数:属性;第四个参数:决策。返回:新的决策。 -### as_json(*remove_postproc:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [Any](https://docs.python.org/3/library/typing.html#typing.Any)[](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Trace.as_json) +### as_json(*remove_postproc:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [Any](https://docs.python.org/3/library/typing.html#typing.Any) 将跟踪序列化为 JSON 样式的对象。 @@ -3083,30 +3081,30 @@ Only 3 types of replacements are allowed: from src_sref->stmt to tgt_stmt. 1) Bl * **返回:py_stmts**:python 语句序列。 * **返回类型:** List[[str](https://docs.python.org/3/library/stdtypes.html#str)]。 -### with_decision(*inst:*[Instruction](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Instruction), *decision:*[Any](https://docs.python.org/3/library/typing.html#typing.Any), *remove_postproc:*[bool](https://docs.python.org/3/library/functions.html#bool)) → [Trace](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Trace) +### with_decision(*inst:*[Instruction](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleinstructionkindinstructionkind-inputslistany-attrslistany-outputslistany), *decision:*[Any](https://docs.python.org/3/library/typing.html#typing.Any), *remove_postproc:*[bool](https://docs.python.org/3/library/functions.html#bool)) → [Trace](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduletraceinstslistinstruction-decisionsdictinstructionany) 创建一条带有已更改决策的指令的新轨迹,假设该指令存在于结果轨迹中。 * **参数:** - * **inst**([指令](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Instruction)):需要更改其决策的指令。 + * **inst**([指令](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleinstructionkindinstructionkind-inputslistany-attrslistany-outputslistany)):需要更改其决策的指令。 * **决策**(*DECISION_TYPE*):需要更改为的决策。 * **remove_postproc** ( [bool](https://docs.python.org/3/library/functions.html#bool) ) :如果删除后处理指令。 * **返回:trace**:决策发生改变的新跟踪。 -* **返回类型:**[Trace](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Trace)。 +* **返回类型:**[Trace](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduletraceinstslistinstruction-decisionsdictinstructionany)。 -### simplified(*remove_postproc:*[bool](https://docs.python.org/3/library/functions.html#bool)) → [Trace](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Trace) +### simplified(*remove_postproc:*[bool](https://docs.python.org/3/library/functions.html#bool)) → [Trace](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduletraceinstslistinstruction-decisionsdictinstructionany) 通过消除死代码来简化跟踪。 * **参数:remove_postproc** ([bool](https://docs.python.org/3/library/functions.html#bool)):如果删除后处理指令。 * **返回:trace**:简化的跟踪。 -* **返回类型:**[Trace](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Trace)。 +* **返回类型:**[Trace](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduletraceinstslistinstruction-decisionsdictinstructionany)。 -### *static* apply_json_to_schedule(*json_obj:*[Any](https://docs.python.org/3/library/typing.html#typing.Any), *sch:*[Schedule](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule)) → [None](https://docs.python.org/3/library/constants.html#None) +### *static* apply_json_to_schedule(*json_obj:*[Any](https://docs.python.org/3/library/typing.html#typing.Any), *sch:*[Schedule](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulemodprimfuncirmodule--seed-int--none--none-debug_mask-str--int--none-error_render_level-str--detail-enable_check-bool--true)) → [None](https://docs.python.org/3/library/constants.html#None) 将 JSON 序列化的跟踪应用于 TensorIR 调度。 * **参数:** * **json_obj** ( *JSON_TYPE* ) :JSON 序列化的跟踪。 - * **sch**([调度](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule)):TensorIR 调度。 + * **sch**([调度](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulemodprimfuncirmodule--seed-int--none--none-debug_mask-str--int--none-error_render_level-str--detail-enable_check-bool--true)):TensorIR 调度。 ### show(*style:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *black_format:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) → [None](https://docs.python.org/3/library/constants.html#None) diff --git a/docs/04-api-reference/01-python-api/20-tvm-tir-stmt_functor.md b/docs/04-api-reference/01-python-api/20-tvm-tir-stmt_functor.md index 99f85a3..c145bb0 100644 --- a/docs/04-api-reference/01-python-api/20-tvm-tir-stmt_functor.md +++ b/docs/04-api-reference/01-python-api/20-tvm-tir-stmt_functor.md @@ -12,12 +12,12 @@ title: tvm.tir.stmt_functor 按照 DFS 后顺序递归访问和转换 ir 节点。 * **参数:** - * **stmt** ([tvm.tir.Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)):要转换的输入。 + * **stmt** ([tvm.tir.Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)):要转换的输入。 * **preorder** (*function*):递归变异之前调用的函数。如果 preorder 返回 None,则变换将继续进行递归调用。如果 preorder 返回非 None 的 tvm.tir.Stmt/Expr,则变换器将直接返回该值,而不会进行进一步的递归。 * **postorder** (*function*):递归变异后调用的函数。 * **only_enable** (*Optional**[****List**[***[str](https://docs.python.org/3/library/stdtypes.html#str)***]***]*):我们仅启用的类型列表。 * **返回:result**:结果。 -* **返回类型:**[tvm.tir.Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)。 +* **返回类型:**[tvm.tir.Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)。 ## tvm.tir.stmt_functor.post_order_visit(*stmt*, *fvisit*) @@ -43,16 +43,16 @@ title: tvm.tir.stmt_functor 替换 vmap 指定的 var。 * **参数:** * **node** (*ObjectRef*):输入。 - * **vmap** (*Dict[*[tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)*,*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]*):变量映射。 + * **vmap** (*Dict[*[tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)*,*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]*):变量映射。 * **返回:result**:结果。 -* **返回类型:**[tvm.tir.Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)。 +* **返回类型:**[tvm.tir.Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)。 -## tvm.tir.stmt_functor.renew_defs(*func:*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)) +## tvm.tir.stmt_functor.renew_defs(*func:*[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)) 重新生成 TIR 的定义节点,包括 VarDef 和 BufferDef。此过程相当于一个简单的 DeepCopy,用于复制具有不同 Var 和 Buffer 但行为相同的函数。 -* **参数:func** ([PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)):输入函数。 +* **参数:func** ([PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)):输入函数。 * **返回:result**:新生成的函数。 -* **返回类型:**[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)。 +* **返回类型:**[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)。 diff --git a/docs/04-api-reference/01-python-api/21-tvm-tir-transform.md b/docs/04-api-reference/01-python-api/21-tvm-tir-transform.md index c468f9b..4c84c41 100644 --- a/docs/04-api-reference/01-python-api/21-tvm-tir-transform.md +++ b/docs/04-api-reference/01-python-api/21-tvm-tir-transform.md @@ -7,7 +7,7 @@ title: tvm.tir.transform 所有 TIR 变换的命名空间 -### tvm.tir.transform.prim_func_pass(*pass_func=None*, *opt_level:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *required:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *traceable=False*) → [Callable](https://docs.python.org/3/library/typing.html#typing.Callable) | [PrimFuncPass](https://tvm.apache.org/docs/reference/api/python/tir/transform.html#tvm.tir.transform.PrimFuncPass) +### tvm.tir.transform.prim_func_pass(*pass_func=None*, *opt_level:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *name:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *required:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[str](https://docs.python.org/3/library/stdtypes.html#str)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *traceable=False*) → [Callable](https://docs.python.org/3/library/typing.html#typing.Callable) | [PrimFuncPass](/docs/api-reference/python-api/tvm-tir-transform#class-tvmtirtransformprimfuncpass) 装饰一个函数传递。 @@ -15,12 +15,12 @@ title: tvm.tir.transform 当提供 pass_func 时,此函数返回一个回调。否则,它返回使用给定优化函数创建的函数传递。 * **参数:** - * **pass_func** (*可选**[****可调用[(*[tvm.tir.PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)*,*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)*,*[PassContext](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.PassContext)*)–> tvm.tir.PrimFunc]]* ):转换函数或类。 + * **pass_func** (*可选**[****可调用[(*[tvm.tir.PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)*,*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)*,*[PassContext](/docs/api-reference/python-api/tvm-transform#classtvmtransformpasscontextopt_level2required_passnonedisabled_passnoneinstrumentsnoneconfignone)*)–> tvm.tir.PrimFunc]]* ):转换函数或类。 * **opt_level**([int](https://docs.python.org/3/library/functions.html#int)):此模块传递的优化级别。 * *name**(*可选**[ [str](https://docs.python.org/3/library/stdtypes.html#str)*]*):函数传递的名称。名称可以为空。在这种情况下,优化函数的名称将用作传递名称。 * **required**(可选[List[[str](https://docs.python.org/3/library/stdtypes.html#str)]]):函数传递所依赖的传递列表。 * **返回:create_function_pass**:如果未提供 pass_func,则返回一个装饰器;否则返回装饰后的结果。返回的装饰器根据输入有两种行为:装饰一个 pass 函数时,将返回一个新的 FunctionPass。装饰一个类类型时,将返回一个新的 FunctionPass 类。 -* **返回类型:** Union[Callable, [FunctionPass](https://tvm.apache.org/docs/reference/api/python/relax/transform.html#tvm.relax.transform.FunctionPass)]。 +* **返回类型:** Union[Callable, [FunctionPass](/docs/api-reference/python-api/tvm-relax-transform#class-tvmrelaxtransformfunctionpass)]。 **示例** @@ -71,12 +71,12 @@ updated_mod = function_pass(m) 插入 AttrStmt 节点,指定 PrimFunc 中应执行区域的目标。仅修改具有 tvm::attr::kTarget 属性且该目标定义了主机的函数。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.AnnotateEntryFunc() 如果它是 IRModule 中唯一的函数,则将 PrimFunc 设置为入口点。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.Apply(*ftransform*) @@ -87,42 +87,42 @@ updated_mod = function_pass(m) 此函数是 tvm.tir.transform.prim_func_pass 的薄包装器。 * **参数:ftransform** (*tvm.tir.PrimFunc -> tvm.tir.PrimFunc*):转换过程。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.BF16ComputeLegalize() 使 bf16 计算操作合法化。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.BF16StorageLegalize() 将 bf16 存储类型合法化为 u16。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.BindTarget(*target*) 使用给定的目标注释 PrimFunc:param target: target:type target: tvm.target.Target。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.CombineContextCall() 在宿主函数中组合上下文调用。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.CommonSubexprElimTIR(*enable_cse_tir:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*, *identify_equiv_terms:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) 用新变量代替冗余计算。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.CompactBufferAllocation(*is_strict:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) @@ -156,20 +156,20 @@ for i in range(0, 16): ``` * **参数:is_strict** ([bool](https://docs.python.org/3/library/functions.html#bool)):确保压缩后的形状始终小于原始形状。否则,允许增大形状以匹配实际访问的缓冲区。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.ConvertBlocksToOpaque() 将所有块变量替换为它们绑定的 PrimExprs,由 BlockRealize 中的相应 iter_values 指示,然后通过删除 BlockRealize 中的所有 iter_values 和 Block 中的 iter_vars 将块转换为不透明的块。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.ConvertForLoopsToSerial() 将并行 For 循环转换为串行 For 循环。 * **返回:fpass**:结果通过 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass) +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass) ## tvm.tir.transform.ConvertSSA() @@ -178,14 +178,14 @@ for i in range(0, 16): 此过程处理同一 tir.Var 出现在同一模块内多个函数中的情况。例如,将一个函数中的片段提取到另一个函数后,同一个 tir.Var 可能既在原始函数的主函数中定义,又在提升函数中作为参数定义。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.DecorateDeviceScope() 将所有函数体装饰为设备函数。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.DefaultGPUSchedule() @@ -195,14 +195,14 @@ for i in range(0, 16): 此过程的主要目标并非优化性能,而是为非调度或符号形状的 PrimFuncs 生成有效的 GPU 内核。此过程目前仅适用于 CUDA 目标平台。 * **返回:ret。** -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.ExtractPrimFuncConstants() 收集并统一非标量常量到模块的属性「常量」数组。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.FP8ComputeLegalize(*promote_dtype_str:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'float32'*) @@ -210,34 +210,34 @@ for i in range(0, 16): 使 fp8 计算操作合法化。 * **参数:promote_dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)):我们将 fp8 提升到的数据类型,选项:float16/float32。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.FP8StorageLegalize() 将 fp8 存储类型合法化为 u8。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.Filter(*fcond:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)) 过滤掉不满足给定条件的 PrimFuncs。fcond 应该是一个接受 primfunc 并返回布尔值的函数。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.FlattenBuffer() 对于不包含不透明块的 TIR,将多维 BufferLoad 和 BufferStore 展平为单维 BufferLoad/BufferStore。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.ForceNarrowIndexToInt32() 强制将索引表达式和整数缓冲区缩小为 int32 dtype。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 在默认情况下不应使用此通行证。 @@ -254,7 +254,7 @@ HoistIfThenElse 的通用版本。 * IfThenElse 条件。 * 布尔运算符。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## ***class*tvm.tir.transform.HoistExpressionConfig** @@ -276,7 +276,7 @@ HoistIfThenElse 的通用版本。 config={“tir.HoistIfThenElse”: {“support_block_scope_hoisting”: True}}。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## ***class*tvm.tir.transform.HoistIfThenElseConfig** @@ -359,14 +359,14 @@ Let 表达式中发生的绑定。 使用张量内在函数推断 TensorCore 片段信息。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.InjectDoubleBuffer() 注入双缓冲区语句。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## ***class*tvm.tir.transform.InjectDoubleBufferConfig** @@ -382,7 +382,7 @@ Split loop factors  分割环系数。 使用异步复制将全局到 CUDA 上的共享内存复制重写。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.InjectPTXLDG32(*enable_inject_ptx_intrin:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) @@ -395,62 +395,62 @@ Split loop factors  分割环系数。 在 mma 中注入排列布局。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.InjectRollingBuffer() 注入滚动缓冲区语句。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.InjectSoftwarePipeline() 将带注释的循环转换为并行生产者和消费者的流水线循环。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.InjectVirtualThread() 注入虚拟线程循环。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.InlinePrivateFunctions() 内联调用私有函数。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.InstrumentBoundCheckers() instrument 绑定检查器。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.InstrumentProfileIntrinsics() 插入对 instrument 函数和循环级分析的内部调用。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.LiftThreadBinding() 将相同的线程绑定提升到其 LCA 环。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.LoopPartition() 注入虚拟线程循环。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## ***class*tvm.tir.transform.LoopPartitionConfig** @@ -475,21 +475,21 @@ Split constant loop  拆分常量循环。 降低异步 DMA 至 DMA。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.LowerAutoCopy() 自动对自动复制块进行内存优化。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.LowerCrossThreadReduction() 降低从线程绑定到内部函数调用的跨线程减少。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ### tvm.tir.transform.LowerCustomDatatypes() @@ -499,7 +499,7 @@ Split constant loop  拆分常量循环。 有关添加自定义数据类型的更多信息,请参阅 tvm::datatypes::Registry。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.LowerDeviceKernelLaunch() @@ -512,16 +512,16 @@ Split constant loop  拆分常量循环。 经过此过程后,主机到设备的调用将表示为内置的 tvm_call_packed 函数。设备函数是一个对外暴露的函数,具有非空的 tvm::attr::kGlobalSymbol 属性。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ### tvm.tir.transform.LowerDeviceStorageAccessInfo() 降低设备上附加存储的访问信息。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -:::Note +:::note 所有存储访问分析完成后运行此过程。 @@ -532,56 +532,56 @@ Split constant loop  拆分常量循环。 将块初始化语句转换为 IfThenElse 语句 。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.LowerIntrin() 降低目标特定的内在调用。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.LowerMatchBuffer() 删除块内的匹配缓冲区。此外,它将验证绑定。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.LowerOpaqueBlock() 解除封锁以确保 TIR 不会再次被安排。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.LowerTVMBuiltin() 降低 TVM 内置内在函数。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.LowerThreadAllreduce() 降低跨线程 alleduce。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.LowerVtcmAlloc() 降低 vtcm 分配。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.LowerWarpMemory() 降低 warp 内存访问到低级设备相关的函数调用。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.MakePackedAPI() @@ -597,7 +597,7 @@ Split constant loop  拆分常量循环。 对于动态缓冲区,其中一个或多个 BufferNode 成员变量使用未由其他 PrimFunc 参数定义的 tir.Var ,这些变量将用于根据相应的 DLTensor 成员定义变量。(例如,接受形状为[tir.Var(“n”), tir.Var(“m”)]的缓冲区的 PrimFunc ,在传递 形状为[16,32]的 DLTensor 时,将根据参数的形状定义n = 16和 n=32 。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.MakeUnpackedAPI() @@ -610,21 +610,21 @@ Split constant loop  拆分常量循环。 对于静态形状,无需执行运行时验证来确认参数缓冲区的形状是否与预期形状匹配。对于动态形状,MakeUnpackedAPI 要求将动态参数作为单独的 tir.Var 参数传递。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.ManifestSharedMemoryLocalStage() 为 GPU 上的共享内存访问添加显式本地阶段。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.MergeSharedMemoryAllocations() 此过程将多个 TIR 级共享内存分配合并为一个分配。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.NarrowDataType(*target_bits:*[int](https://docs.python.org/3/library/functions.html#int)) @@ -633,9 +633,9 @@ Split constant loop  拆分常量循环。 * **参数:** * **target_bits** ([int](https://docs.python.org/3/library/functions.html#int)):目标位配置。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -:::Note +:::note 在 FlattenBuffer 之后运行此过程。 @@ -646,21 +646,21 @@ Split constant loop  拆分常量循环。 将缓冲区分配定位到精确位置(通常是缓冲区访问的 lca)。此过程将在分配位置注入带有 alloc_buffers 的不透明块。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.PointerValueTypeRewrite() 重写参数的指针内容类型,以及函数内部的 Alloc,以使用最常访问的类型进行加载/存储,从而尽可能避免在后端进行指针转换。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.ReduceBranchingThroughOvercompute() 通过引入过度计算来减少分支。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## ***class*tvm.tir.transform.ReduceBranchingThroughOvercomputeConfig** @@ -676,13 +676,13 @@ Split constant loop  拆分常量循环。 删除所有 builtin::assume 实例。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.RemoveNoOp() 从 Stmt 中删除 No Op。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## ***class*tvm.tir.transform.RemoveNoOpConfig** @@ -702,7 +702,7 @@ Split constant loop  拆分常量循环。 从 Stmt 中删除未定义值的存储。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.RemoveWeightLayoutRewriteBlock(*skip_ndarray_rewrite=False*) @@ -713,27 +713,27 @@ Split constant loop  拆分常量循环。 如果为 True,则将跳过根据给定索引图精确重写 NDArray 的操作。仅正确转换 NDArray 的形状,并用随机值填充目标数组的内容。在 MetaSchedule 调优过程中,如果多次调用此过程,则重写前后 NDArray 的原始数据无关紧要。由于使用 IndexMap 的 MapNDArray 进行 NDArray 布局重写目前速度较慢,因此有时需要跳过精确的重写。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.RenormalizeSplitPattern() 将分割模式从 floordiv(floormod()) 重新规范化为 floormod(floordiv())。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.RewriteUnsafeSelect() 检测并重写包含内存访问的不安全选择。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.Simplify() 对语句和表达式进行算术简化。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## ***class*tvm.tir.transform.SimplifyConfig** @@ -768,14 +768,14 @@ Split constant loop  拆分常量循环。 跳过断言语句。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.SplitHostDevice() 将函数分为主机函数和设备函数。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.StorageRewrite() @@ -785,7 +785,7 @@ Split constant loop  拆分常量循环。 将分配移至尽可能最外层的作用域。尝试在分配之间共享空间,以便在可能的情况下制定静态分配计划。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.ThreadSync(*storage_scope:*[str](https://docs.python.org/3/library/stdtypes.html#str)) @@ -793,23 +793,23 @@ Split constant loop  拆分常量循环。 在共享缓冲区的并行读/写之间插入同步。 * **参数:storage_scope** ([str](https://docs.python.org/3/library/stdtypes.html#str)):目标存储范围。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.TransformMmaBufferLayout() 变换 mma 缓冲区布局。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.UnifyThreadBinding() 统一所有“blockIdx.x/y/z”、“threadIdx.x/y/z”和“vthread.x/y/z”的线程绑定。统一之前,绑定到同一线程轴的两个变量(例如“threadIdx.x”)在其 AttrStmts 中使用不同的 IterVar 和变量。统一之后,我们将为它们使用合并后的 IterVar 和变量。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 -:::Note +:::note vthread 是一种将被弃用的遗留行为,但 vthread 的线程绑定在本阶段仍然统一。请使用 vthread.x、vthread.y 和 vthread.z 代替。 @@ -823,7 +823,7 @@ vthread 是一种将被弃用的遗留行为,但 vthread 的线程绑定在本 此过程还自动将 pragma unroll 标签附加到符合标准的循环。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## ***class*tvm.tir.transform.UnrollLoopConfig** @@ -857,7 +857,7 @@ vthread 是一种将被弃用的遗留行为,但 vthread 的线程绑定在本 此过程尝试通过过度计算填充区域的值来消除布局特定的填充分支。消除分支将有助于矢量化代码,并提升元素级操作的性能。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.VectorizeLoop(*enable_vectorize:*[bool](https://docs.python.org/3/library/functions.html#bool)*= True*) @@ -865,14 +865,14 @@ vthread 是一种将被弃用的遗留行为,但 vthread 的线程绑定在本 降低矢量化循环。 * **参数:enable_vectorize** ([bool](https://docs.python.org/3/library/functions.html#bool)):是否启用矢量化。关闭时将降低到标量循环。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.VerifyMemory() 验证 func 是否包含非法主机端直接内存访问。 * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 ## tvm.tir.transform.VerifyVTCMLimit(*limit=None*) @@ -880,7 +880,7 @@ vthread 是一种将被弃用的遗留行为,但 vthread 的线程绑定在本 验证分配的 vtcm 内存的大小是否满足限制。 * * **返回:fpass**:结果通过。 -* **返回类型:**[tvm.transform.Pass](https://tvm.apache.org/docs/reference/api/python/transform.html#tvm.transform.Pass)。 +* **返回类型:**[tvm.transform.Pass](/docs/api-reference/python-api/tvm-transform#class-tvmtransformpass)。 diff --git a/docs/04-api-reference/01-python-api/22-tvm-te.md b/docs/04-api-reference/01-python-api/22-tvm-te.md index 608f217..839b611 100644 --- a/docs/04-api-reference/01-python-api/22-tvm-te.md +++ b/docs/04-api-reference/01-python-api/22-tvm-te.md @@ -11,82 +11,82 @@ title: tvm.te **函数:** -|[any](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.any)(*args[,span])|创建参数中所有条件的并集的新表达式。| +|[any](/docs/api-reference/python-api/tvm-te#tvmteanyargs-spannone)(*args[,span])|创建参数中所有条件的并集的新表达式。| |:----|:----| -|[all](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.all)(*args[,span])|创建所有条件交集的新表达式。| -|[min_value](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.min_value)(dtype[,span])|dtype 的最小值。| -|[max_value](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.max_value)(dtype[,span])|dtype 的最大值。| -|[trace](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.trace)(args[,trace_action])|在运行时跟踪张量数据。| -|[exp](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.exp)(x)|取输入 x 的指数。| -|[erf](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.erf)(x)|取输入 x 的高斯误差函数。| -|[tanh](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.tanh)(x)|对输入 x 取双曲 tanh。| -|[sigmoid](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.sigmoid)(x)|快速获取 S 形函数。| -|[log](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.log)(x)|对输入 x 取对数。| -|[tan](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.tan)(x)|对输入 x 取 tan。| -|[cos](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.cos)(x)|取输入 x 的 cos。| -|[sin](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.sin)(x)|对输入 x 取正弦值。| -|[sqrt](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.sqrt)(x)|对输入 x 取平方根。| -|[rsqrt](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.rsqrt)(x)|取输入 x 的平方根的倒数。| -|[floor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.floor)(x[,span])|取浮点输入 x 的下限。| -|[ceil](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.ceil)(x[,span])|对浮点输入 x 取上限。| -|[sinh](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.sinh)(x)|对输入 x 取 sinh。| -|[cosh](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.cosh)(x)|对输入 x 取余弦值。| -|[log2](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.log2)(x)|对输入 x 取 log2。| -|[log10](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.log10)(x)|对输入 x 取 log10。| -|[asin](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.asin)(x)|取输入 x 的 asin。| -|[asinh](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.asinh)(x)|取输入 x 的正弦值。| -|[acos](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.acos)(x)|对输入 x 取余数。| -|[acosh](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.acosh)(x)|对输入 x 取余数。| -|[atan](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.atan)(x)|对输入 x 取正切值。| -|[atanh](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.atanh)(x)|对输入 x 进行 atanh 处理。| -|[trunc](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.trunc)(x[,span])|获取输入的截断值。| -|[abs](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.abs)(x[,span])|逐个获取输入元素的绝对值。| -|[round](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.round)(x[,span])|将数组元素四舍五入为最接近的整数。| -|[nearbyint](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.nearbyint)(x[,span])|将数组元素四舍五入为最接近的整数。| -|[power](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.power)(x,y[,span])|x 次方 y。| -|[popcount](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.popcount)(x)|计算输入 x 中设置位的数量。| -|[fmod](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.fmod)(x,y)|返回 x 除以 y 后的余数,其符号与 x 相同。| -|[if_then_else](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.if_then_else)(cond,t,f[,span])|条件选择表达式。| -|[isnan](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.isnan)(x[,span])|检查输入值是否为 Nan。| -|[isfinite](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.isfinite)(x[,span])|检查输入值是否有限。| -|[isinf](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.isinf)(x[,span])|检查输入值是否无限。| -|[div](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.div)(a,b[,span])|按照 C/C++ 语义计算 a / b。| -|[indexdiv](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.indexdiv)(a,b[,span])|计算 floor(a / b),其中 a 和 b 为非负数。| -|[indexmod](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.indexmod)(a,b[,span])|计算 indexdiv 的余数。a 和 b 非负。| -|[truncdiv](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.truncdiv)(a,b[,span])|计算两个表达式的 truncdiv。| -|[truncmod](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.truncmod)(a,b[,span])|计算两个表达式的 truncmod。| -|[floordiv](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.floordiv)(a,b[,span])|计算两个表达式的 floordiv。| -|[floormod](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.floormod)(a,b[,span])|计算两个表达式的 floormod。| -|[logaddexp](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.logaddexp)(a,b[,span])|计算两个表达式的 logaddexp。| -|[comm_reducer](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.comm_reducer)(fcombine,fidentity[,name])|创建一个交换减速器用于减速。| -|[min](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.min)(expr,axis[,where,init])|在轴上创建最小表达式。| -|[max](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.max)(expr,axis[,where,init])|在轴上创建最大表达式。| -|[sum](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.sum)(expr,axis[,where,init])|在轴上创建一个求和表达式。| -|[add](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.add)(lhs,rhs[,span])|通用加法运算符。| -|[subtract](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.subtract)(lhs,rhs[,span])|通用减法运算符。| -|[multiply](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.multiply)(lhs,rhs[,span])|通用乘法运算符。| -|[tag_scope](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.tag_scope)(tag)|运算符标签范围。| -|[placeholder](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.placeholder)(shape[,dtype,name])|构造一个空的张量对象。| -|[compute](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.compute)(shape,fcompute[,name,tag,attrs,…])|通过计算形状域来构建一个新的张量。| -|[scan](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.scan)(init,update,state_placeholder[,…])|通过扫描轴来构建新的张量。| -|[extern](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.extern)(shape,inputs,fcompute[,name,…])|通过外部函数计算多个张量。| -|[var](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.var)([name,dtype,span])|创建具有指定名称和数据类型的新变量。| -|[size_var](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.size_var)([name,dtype,span])|创建一个新变量表示张量形状的大小,它是非负的。| -|[const](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.const)(value[,dtype,span])|创建具有指定值和数据类型的新常量。| -|[thread_axis](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.thread_axis)([dom,tag,name,span])|创建一个新的 IterVar 来表示线程索引。| -|[reduce_axis](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.reduce_axis)(dom[,name,thread_tag,span])|创建一个新的 IterVar 进行缩减。| -|[create_prim_func](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.create_prim_func)(ops[,index_dtype_override])|从张量表达式创建 TensorIR PrimFunc。| -|[extern_primfunc](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.extern_primfunc)(input_tensors,primfunc,…)|通过可调度的 TIR PrimFunc 计算张量。| +|[all](/docs/api-reference/python-api/tvm-te#tvmteallargs-spannone)(*args[,span])|创建所有条件交集的新表达式。| +|[min_value](/docs/api-reference/python-api/tvm-te#tvmtemin_valuedtype-spannone)(dtype[,span])|dtype 的最小值。| +|[max_value](/docs/api-reference/python-api/tvm-te#tvmtemax_valuedtypestr-spanspannone-none--any)(dtype[,span])|dtype 的最大值。| +|[trace](/docs/api-reference/python-api/tvm-te#tvmtetraceargs-trace_actiontvmdefault_trace_action)(args[,trace_action])|在运行时跟踪张量数据。| +|[exp](/docs/api-reference/python-api/tvm-te#tvmteexpx)(x)|取输入 x 的指数。| +|[erf](/docs/api-reference/python-api/tvm-te#tvmteerfx)(x)|取输入 x 的高斯误差函数。| +|[tanh](/docs/api-reference/python-api/tvm-te#tvmtetanhx)(x)|对输入 x 取双曲 tanh。| +|[sigmoid](/docs/api-reference/python-api/tvm-te#tvmtesigmoidx)(x)|快速获取 S 形函数。| +|[log](/docs/api-reference/python-api/tvm-te#tvmtelogx)(x)|对输入 x 取对数。| +|[tan](/docs/api-reference/python-api/tvm-te#tvmtetanx)(x)|对输入 x 取 tan。| +|[cos](/docs/api-reference/python-api/tvm-te#tvmtecosx)(x)|取输入 x 的 cos。| +|[sin](/docs/api-reference/python-api/tvm-te#tvmtesinx)(x)|对输入 x 取正弦值。| +|[sqrt](/docs/api-reference/python-api/tvm-te#tvmtesqrtx)(x)|对输入 x 取平方根。| +|[rsqrt](/docs/api-reference/python-api/tvm-te#tvmtersqrtx)(x)|取输入 x 的平方根的倒数。| +|[floor](/docs/api-reference/python-api/tvm-te#tvmtefloorx-primexprwithop-spannone)(x[,span])|取浮点输入 x 的下限。| +|[ceil](/docs/api-reference/python-api/tvm-te#tvmteceilx-spannone)(x[,span])|对浮点输入 x 取上限。| +|[sinh](/docs/api-reference/python-api/tvm-te#tvmtesinhx)(x)|对输入 x 取 sinh。| +|[cosh](/docs/api-reference/python-api/tvm-te#tvmtecoshx)(x)|对输入 x 取余弦值。| +|[log2](/docs/api-reference/python-api/tvm-te#tvmtelog2x)(x)|对输入 x 取 log2。| +|[log10](/docs/api-reference/python-api/tvm-te#tvmtelog10x)(x)|对输入 x 取 log10。| +|[asin](/docs/api-reference/python-api/tvm-te#tvmteasinx)(x)|取输入 x 的 asin。| +|[asinh](/docs/api-reference/python-api/tvm-te#tvmteasinhx)(x)|取输入 x 的正弦值。| +|[acos](/docs/api-reference/python-api/tvm-te#tvmteacosx)(x)|对输入 x 取余数。| +|[acosh](/docs/api-reference/python-api/tvm-te#tvmteacoshx)(x)|对输入 x 取余数。| +|[atan](/docs/api-reference/python-api/tvm-te#tvmteatanx)(x)|对输入 x 取正切值。| +|[atanh](/docs/api-reference/python-api/tvm-te#tvmteatanhx)(x)|对输入 x 进行 atanh 处理。| +|[trunc](/docs/api-reference/python-api/tvm-te#tvmtetruncx-spannone)(x[,span])|获取输入的截断值。| +|[abs](/docs/api-reference/python-api/tvm-te#tvmteabsx-spannone)(x[,span])|逐个获取输入元素的绝对值。| +|[round](/docs/api-reference/python-api/tvm-te#tvmteroundx-spannone)(x[,span])|将数组元素四舍五入为最接近的整数。| +|[nearbyint](/docs/api-reference/python-api/tvm-te#tvmtenearbyintx-spannone)(x[,span])|将数组元素四舍五入为最接近的整数。| +|[power](/docs/api-reference/python-api/tvm-te#tvmtepowerx-y-spannone)(x,y[,span])|x 次方 y。| +|[popcount](/docs/api-reference/python-api/tvm-te#tvmtepopcountx)(x)|计算输入 x 中设置位的数量。| +|[fmod](/docs/api-reference/python-api/tvm-te#tvmtefmodx-y)(x,y)|返回 x 除以 y 后的余数,其符号与 x 相同。| +|[if_then_else](/docs/api-reference/python-api/tvm-te#tvmteif_then_elsecond-t-f-spannone)(cond,t,f[,span])|条件选择表达式。| +|[isnan](/docs/api-reference/python-api/tvm-te#tvmteisnanx-spannone)(x[,span])|检查输入值是否为 Nan。| +|[isfinite](/docs/api-reference/python-api/tvm-te#tvmteisfinitex-spannone)(x[,span])|检查输入值是否有限。| +|[isinf](/docs/api-reference/python-api/tvm-te#tvmteisinfx-spannone)(x[,span])|检查输入值是否无限。| +|[div](/docs/api-reference/python-api/tvm-te#tvmtediva-b-spannone)(a,b[,span])|按照 C/C++ 语义计算 a / b。| +|[indexdiv](/docs/api-reference/python-api/tvm-te#tvmteindexdiva-b-spannone)(a,b[,span])|计算 floor(a / b),其中 a 和 b 为非负数。| +|[indexmod](/docs/api-reference/python-api/tvm-te#tvmteindexmoda-b-spannone)(a,b[,span])|计算 indexdiv 的余数。a 和 b 非负。| +|[truncdiv](/docs/api-reference/python-api/tvm-te#tvmtetruncdiva-b-spannone)(a,b[,span])|计算两个表达式的 truncdiv。| +|[truncmod](/docs/api-reference/python-api/tvm-te#tvmtetruncmoda-b-spannone)(a,b[,span])|计算两个表达式的 truncmod。| +|[floordiv](/docs/api-reference/python-api/tvm-te#tvmtefloordiva-b-spannone)(a,b[,span])|计算两个表达式的 floordiv。| +|[floormod](/docs/api-reference/python-api/tvm-te#tvmtefloormoda-b-spannone)(a,b[,span])|计算两个表达式的 floormod。| +|[logaddexp](/docs/api-reference/python-api/tvm-te#tvmtelogaddexpa-b-spannone)(a,b[,span])|计算两个表达式的 logaddexp。| +|[comm_reducer](/docs/api-reference/python-api/tvm-te#tvmtecomm_reducerfcombine-fidentity-namereduce)(fcombine,fidentity[,name])|创建一个交换减速器用于减速。| +|[min](/docs/api-reference/python-api/tvm-te#tvmteminexpr-axis-wherenone-initnone-args)(expr,axis[,where,init])|在轴上创建最小表达式。| +|[max](/docs/api-reference/python-api/tvm-te#tvmtemaxexpr-axis-wherenone-initnone-args)(expr,axis[,where,init])|在轴上创建最大表达式。| +|[sum](/docs/api-reference/python-api/tvm-te#tvmtesumexpr-axis-wherenone-initnone-args)(expr,axis[,where,init])|在轴上创建一个求和表达式。| +|[add](/docs/api-reference/python-api/tvm-te#tvmteaddlhs-rhs-spannone)(lhs,rhs[,span])|通用加法运算符。| +|[subtract](/docs/api-reference/python-api/tvm-te#tvmtesubtractlhs-rhs-spannone)(lhs,rhs[,span])|通用减法运算符。| +|[multiply](/docs/api-reference/python-api/tvm-te#tvmtemultiplylhs-rhs-spannone)(lhs,rhs[,span])|通用乘法运算符。| +|[tag_scope](/docs/api-reference/python-api/tvm-te#tvmtetag_scopetag)(tag)|运算符标签范围。| +|[placeholder](/docs/api-reference/python-api/tvm-te#tvmteplaceholdershape-dtypenone-nameplaceholder)(shape[,dtype,name])|构造一个空的张量对象。| +|[compute](/docs/api-reference/python-api/tvm-te#tvmtecomputeshape-fcompute-namecompute-tag-attrsnone-varargs_namesnone)(shape,fcompute[,name,tag,attrs,…])|通过计算形状域来构建一个新的张量。| +|[scan](/docs/api-reference/python-api/tvm-te#tvmtescaninit-update-state_placeholder-inputsnone-namescan-tag-attrsnone)(init,update,state_placeholder[,…])|通过扫描轴来构建新的张量。| +|[extern](/docs/api-reference/python-api/tvm-te#tvmteexternshape-inputs-fcompute-nameextern-dtypenone-in_buffersnone-out_buffersnone-tag-attrsnone)(shape,inputs,fcompute[,name,…])|通过外部函数计算多个张量。| +|[var](/docs/api-reference/python-api/tvm-te#tvmtevarnametindex-dtypeint32-spannone)([name,dtype,span])|创建具有指定名称和数据类型的新变量。| +|[size_var](/docs/api-reference/python-api/tvm-te#tvmtesize_varnamesize-dtypeint32-spannone)([name,dtype,span])|创建一个新变量表示张量形状的大小,它是非负的。| +|[const](/docs/api-reference/python-api/tvm-te#tvmteconstvalue-dtypeint32-spannone)(value[,dtype,span])|创建具有指定值和数据类型的新常量。| +|[thread_axis](/docs/api-reference/python-api/tvm-te#tvmtethread_axisdomnone-tag-name-spannone)([dom,tag,name,span])|创建一个新的 IterVar 来表示线程索引。| +|[reduce_axis](/docs/api-reference/python-api/tvm-te#tvmtereduce_axisdom-namerv-thread_tag-spannone)(dom[,name,thread_tag,span])|创建一个新的 IterVar 进行缩减。| +|[create_prim_func](/docs/api-reference/python-api/tvm-te#tvmtecreate_prim_funcopslisttensorvar-index_dtype_overridestrnone-none--primfunc)(ops[,index_dtype_override])|从张量表达式创建 TensorIR PrimFunc。| +|[extern_primfunc](/docs/api-reference/python-api/tvm-te#tvmteextern_primfuncinput_tensorslisttensor-primfuncprimfunc-kwargs)(input_tensors,primfunc,…)|通过可调度的 TIR PrimFunc 计算张量。| **类:** -|[TensorSlice](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.TensorSlice)(tensor,indices)|用于从张量启用切片语法的辅助数据结构。| +|[TensorSlice](/docs/api-reference/python-api/tvm-te#class-tvmtetensorslicetensor-indices)(tensor,indices)|用于从张量启用切片语法的辅助数据结构。| |:----|:----| -|[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)|Tensor 对象,构造方法参见 function.Tensor| -|[PlaceholderOp](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.PlaceholderOp)|占位符操作。| -|[ComputeOp](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.ComputeOp)|标量运算。| -|[ScanOp](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.ScanOp)|扫描操作。| -|[ExternOp](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.ExternOp)|外部操作。| +|[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)|Tensor 对象,构造方法参见 function.Tensor| +|[PlaceholderOp](/docs/api-reference/python-api/tvm-te#class-tvmteplaceholderop)|占位符操作。| +|[ComputeOp](/docs/api-reference/python-api/tvm-te#class-tvmtecomputeop)|标量运算。| +|[ScanOp](/docs/api-reference/python-api/tvm-te#class-tvmtescanop)|扫描操作。| +|[ExternOp](/docs/api-reference/python-api/tvm-te#class-tvmteexternop)|外部操作。| ## tvm.te.any(args*, *span=None*) @@ -94,7 +94,7 @@ title: tvm.te 创建参数中所有条件的并集的新表达式。 * **参数:** * **args**([列表](https://docs.python.org/3/library/stdtypes.html#list)):符号布尔表达式列表。 - * *span*(*可选*[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * *span*(*可选*[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:expr**:表达式。 * **返回类型:** Expr。 @@ -107,7 +107,7 @@ title: tvm.te 创建一个新的表达式,该表达式表示所有参数条件的交集。 * **参数:** * **args**([列表](https://docs.python.org/3/library/stdtypes.html#list)):符号布尔表达式列表。 - * *span**(*可选**[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * *span**(*可选**[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:expr**:表达式 * **返回类型:** Expr。 @@ -119,20 +119,20 @@ title: tvm.te dtype 的最小值。 * **参数:** * **dtype**([str](https://docs.python.org/3/library/stdtypes.html#str)):数据类型。 - * *span**(*可选**[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * *span**(*可选**[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:value**:dtype 的最小值。 * **返回类型:** tvm.Expr。 **别名**`tvm.tir.min_value()` -## tvm.te.max_value(*dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str), *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Any](https://docs.python.org/3/library/typing.html#typing.Any) +## tvm.te.max_value(*dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str), *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Any](https://docs.python.org/3/library/typing.html#typing.Any) dtype 的最大值。 * **参数:** * **dtype**([str](https://docs.python.org/3/library/stdtypes.html#str))*:*数据类型。 - * *span**(*可选**[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * *span**(*可选**[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:value**:dtype 的最大值。 * **返回类型:** tvm.Expr。 @@ -150,7 +150,7 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 * **args**(*Expr**或*** *Buffers*[列表](https://docs.python.org/3/library/stdtypes.html#list)*。*)**:** 位置参数。 * **trace_action**(*str.*):跟踪操作的名称。 * **返回:call**:调用表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 :::info 另见 @@ -167,9 +167,9 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 取输入 x 的指数。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 -* **返回:y** [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 +* **返回:y** [:](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)结果。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.exp()` @@ -178,9 +178,9 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 取输入 x 的高斯误差函数。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 -* **返回:y** [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 +* **返回:y** [:](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)结果。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.erf()` @@ -188,9 +188,9 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 ## tvm.te.tanh(*x*) 对输入 x 取双曲 tanh。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 -* **返回:y** [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 +* **返回:y** [:](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)结果。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.tanh()` @@ -199,9 +199,9 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 快速获取 S 形函数。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y** :结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.sigmoid()` @@ -210,9 +210,9 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 对输入 x 取对数。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y** :结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.log()` @@ -221,9 +221,9 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 对输入 x 取 tan。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y** **:** 结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.tan()` @@ -231,9 +231,9 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 ## tvm.te.cos(*x*) 取输入 x 的 cos。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y** :结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.cos()` @@ -242,9 +242,9 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 对输入 x 取正弦值。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y** :结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.sin()` @@ -253,9 +253,9 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 对输入 x 取平方根。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y** :结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.sqrt()` @@ -264,9 +264,9 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 取输入 x 的平方根的倒数。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y** :结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.rsqrt()` @@ -276,10 +276,10 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 取浮点输入 x 的下限。 * **参数:** - * **x** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):输入参数。 - * *span**(*可选**[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)此运算符在源代码中的位置。 + * **x** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):输入参数。 + * *span**(*可选**[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)[:](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)此运算符在源代码中的位置。 * **返回:y** :结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.floor()` @@ -289,10 +289,10 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 对浮点输入 x 取上限。 * **参数:** - * **x** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) )**:** 输入参数。 - * *span**(*可选**[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **x** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) )**:** 输入参数。 + * *span**(*可选**[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:y** :结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.ceil()` @@ -301,9 +301,9 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 对输入 x 取 sinh。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y** :结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.sinh()` @@ -312,9 +312,9 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 对输入 x 取余弦值。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y** :结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.cosh()` @@ -323,9 +323,9 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 对输入 x 取 log2。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y** :结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.log2()` @@ -334,9 +334,9 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 对输入 x 取 log10。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y** :结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.log10()` @@ -345,9 +345,9 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 取输入 x 的 asin。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y** :结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.asin()` @@ -356,9 +356,9 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 取输入 x 的正弦值。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y** :结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.asinh()` @@ -367,9 +367,9 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 对输入 x 取余数。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y** :结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.acos()` @@ -378,9 +378,9 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 对输入 x 取余数。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y** :结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.acosh()` @@ -389,9 +389,9 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 对输入 x 取正切值。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y** :结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.atan()` @@ -400,9 +400,9 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 对输入 x 进行 atanh 处理。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y** *:* 结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.atanh()` @@ -415,10 +415,10 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 标量 x 的截断值是最接近的整数 i,它比 x 更接近零。 * **参数:** - * **x** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):输入参数。 - * *span**(*可选**[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **x** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):输入参数。 + * *span**(*可选**[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:y** :结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.trunc()` @@ -428,10 +428,10 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 逐个获取输入元素的绝对值。 * **参数:** - * **x** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):输入参数。 - * *span**(*可选**[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **x** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):输入参数。 + * *span**(*可选**[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:y** :结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.abs()` @@ -441,10 +441,10 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 将数组元素四舍五入为最接近的整数。 * **参数:** - * **x** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):输入参数。 - * span(*可选**[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **x** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):输入参数。 + * span(*可选**[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:y** :结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.round()` @@ -454,10 +454,10 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 将数组元素四舍五入为最接近的整数。此内在函数使用 llvm.nearbyint 而不是 llvm.round,后者速度更快,但结果与 te.round 不同。值得注意的是,nearbyint 根据舍入模式进行舍入,而 te.round (llvm.round) 则忽略该模式。有关两者之间的差异,请参阅: https: [//en.cppreference.com/w/cpp/numeric/math/round](https://en.cppreference.com/w/cpp/numeric/math/round) [https://en.cppreference.com/w/cpp/numeric/math/nearbyint](https://en.cppreference.com/w/cpp/numeric/math/nearbyint)。 * **参数:** - * **x** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):输入参数。 - * *span**(*可选**[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **x** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):输入参数。 + * *span**(*可选**[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:y** **:** 结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.nearbyint()` @@ -467,22 +467,21 @@ trace 函数允许在运行时跟踪特定的张量。跟踪值应作为最后 x 次方 y。 * **参数:** - * **x** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):输入参数。 - * **y** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):指数。 - * *span**(*可选**[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **x** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):输入参数。 + * **y** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):指数。 + * *span**(*可选**[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:z** :结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.power()` -## tvm.te.popcount(*x*)[](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.popcount) - +## tvm.te.popcount(*x*) 计算输入 x 中设置位的数量。 -* **参数:x** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):输入参数。 +* **参数:x** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):输入参数。 * **返回:y** :结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.popcount()` @@ -492,10 +491,10 @@ x 次方 y。 返回 x 除以 y 后的余数,其符号与 x 相同。 * **参数:** - * **x** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):输入参数。 - * **y** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):输入参数。 + * **x** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):输入参数。 + * **y** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):输入参数。 * **返回:z** :结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.fmod()` @@ -505,14 +504,14 @@ x 次方 y。 条件选择表达式。 * **参数:** - * **cond** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):条件。 - * **t** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) )**:** 如果 cond 为真,则结果表达式。 - * **f** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):如果 cond 为假,则结果表达式。 - * *span**(*可选**[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源中的位置。 + * **cond** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):条件。 + * **t** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) )**:** 如果 cond 为真,则结果表达式。 + * **f** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):如果 cond 为假,则结果表达式。 + * *span**(*可选**[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源中的位置。 * **返回:result**:条件表达式的结果。 -* **返回类型:**[Node](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Node)。 +* **返回类型:**[Node](/docs/api-reference/python-api/tvm-ir#class-tvmirnode)。 -:::Note +:::note 与 Select 不同,if_then_else 不会执行不满足条件的分支。您可以使用它来防止越界访问。与 Select 不同,如果向量中某些通道的条件不同,则 if_then_else 无法进行向量化。 @@ -526,10 +525,10 @@ x 次方 y。 检查输入值是否为 Nan。 * **参数:** - * **x** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) )*:* 输入参数。 - * *span**(*可选**[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **x** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) )*:* 输入参数。 + * *span**(*可选**[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:y** :结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.isnan()` @@ -539,10 +538,10 @@ x 次方 y。 检查输入值是否有限。 * **参数:** - * **x** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):输入参数。 - * *span**(*可选**[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源代码中的位置。 + * **x** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):输入参数。 + * *span**(*可选**[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源代码中的位置。 * **返回:y** *:* 结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.isfinite()` @@ -552,10 +551,10 @@ x 次方 y。 检查输入值是否无限。 * **参数:** - * **x** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):输入参数。 - * *span*(*可选*[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)此运算符在源代码中的位置。 + * **x** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):输入参数。 + * *span*(*可选*[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)[:](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)此运算符在源代码中的位置。 * **返回:y** :结果。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.isinf()` @@ -565,13 +564,13 @@ x 次方 y。 按照 C/C++ 语义计算 a / b。 * **参数:** - * **a** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):左侧操作数,已知为非负数。 - * **b** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):右侧操作数,已知为非负。 - * span(*可选*[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源中的位置。 + * **a** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):左侧操作数,已知为非负数。 + * **b** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):右侧操作数,已知为非负。 + * span(*可选*[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源中的位置。 * **返回:res**:结果表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -:::Note +:::note 当操作数为整数时,返回 truncdiv(a, b, span)。 @@ -585,13 +584,13 @@ x 次方 y。 计算 floor(a / b),其中 a 和 b 为非负数。 * **参数:** - * **a** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):左侧操作数,已知为非负数。 - * **b** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):右侧操作数,已知为非负。 - * *span**(*可选**[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源中的位置。 + * **a** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):左侧操作数,已知为非负数。 + * **b** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):右侧操作数,已知为非负。 + * *span**(*可选**[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源中的位置。 * **返回:res**:结果表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -:::Note +:::note 使用此函数拆分非负索引。此函数可以利用操作数的非负性。 @@ -605,13 +604,13 @@ x 次方 y。 计算 indexdiv 的余数。a 和 b 非负。 * **参数:** - * **a** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) )`:`左侧操作数,已知为非负数。 - * **b** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):右侧操作数,已知为非负。 - * *span**(*可选**[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源中的位置。 + * **a** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) )`:`左侧操作数,已知为非负数。 + * **b** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):右侧操作数,已知为非负。 + * *span**(*可选**[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源中的位置。 * **返回:res**:结果表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -:::Note +:::note 使用此函数拆分非负索引。此函数可以利用操作数的非负性。 @@ -625,13 +624,13 @@ x 次方 y。 计算两个表达式的 truncdiv。 * **参数:** - * **a** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):左侧操作数。 - * **b** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):右侧操作数。 - * *span**(*可选**[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源中的位置。 + * **a** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):左侧操作数。 + * **b** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):右侧操作数。 + * *span**(*可选**[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源中的位置。 * **返回:res**:结果表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -:::Note +:::note 这是 C 中的默认整数除法行为。 @@ -645,13 +644,13 @@ x 次方 y。 计算两个表达式的 truncmod。 * **参数:** - * **a** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):左侧操作数。 - * **b** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):右侧操作数。 - * *span*(*可选*[[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)此运算符在源中的位置。 + * **a** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):左侧操作数。 + * **b** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):右侧操作数。 + * *span*(*可选*[[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)[:](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)此运算符在源中的位置。 * **返回:res**:结果表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -:::Note +:::note 这是 C 中的默认整数除法行为。 @@ -665,11 +664,11 @@ x 次方 y。 计算两个表达式的 floordiv。 * **参数:** - * **a** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):左侧操作数。 - * **b** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):右侧操作数。 - * *span**(*可选**[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源中的位置。 + * **a** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):左侧操作数。 + * **b** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):右侧操作数。 + * *span**(*可选**[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源中的位置。 * **返回:res**:结果表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.floordiv()` @@ -679,11 +678,11 @@ x 次方 y。 计算两个表达式的 floormod。 * **参数:** - * **a** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):左侧操作数。 - * **b** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):右侧操作数。 - * *span*(*可选*[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源中的位置。 + * **a** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):左侧操作数。 + * **b** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):右侧操作数。 + * *span*(*可选*[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源中的位置。 * **返回:res**:结果表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.floormod()` @@ -693,11 +692,11 @@ x 次方 y。 计算两个表达式的 logaddexp。 * **参数:** - * **a** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):左侧操作数。 - * **b** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) )**:** 右侧操作数。 - * span(*可选*[[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源中的位置。 + * **a** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):左侧操作数。 + * **b** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) )**:** 右侧操作数。 + * span(*可选*[[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源中的位置。 * **返回:res**:结果表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **别名**`tvm.tir.logaddexp()` @@ -735,11 +734,11 @@ B = te.compute((n,), lambda i: mysum(A[i, k], axis=k), name="B") 在轴上创建最小表达式。 * **参数:** - * **expr**([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):源表达式。 - * **轴**([IterVar](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IterVar)):缩减 IterVar 轴 + * **expr**([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):源表达式。 + * **轴**([IterVar](/docs/api-reference/python-api/tvm-tir#class-tvmtiritervardomrange-varvarstr-iter_typeint-thread_tagstr--spanspannone-none)):缩减 IterVar 轴 * *where*(*可选*,*Expr*):减少的过滤谓词。 * **返回:value**:结果值。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **示例** @@ -768,11 +767,11 @@ min_res = tvm.min(m, n) 在轴上创建最大表达式。 * **参数:** - * **expr**([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):源表达式。 - * **轴**([IterVar](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IterVar)):缩减 IterVar 轴。 + * **expr**([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):源表达式。 + * **轴**([IterVar](/docs/api-reference/python-api/tvm-tir#class-tvmtiritervardomrange-varvarstr-iter_typeint-thread_tagstr--spanspannone-none)):缩减 IterVar 轴。 * *where**(*可选**,*Expr*):减少的过滤谓词。 * **返回:value**:结果值。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **示例** @@ -801,11 +800,11 @@ max_res = tvm.max(m, n) 在轴上创建一个求和表达式。 * **参数:** - * **expr**([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):源表达式。 - * **轴**([IterVar](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IterVar)):缩减 IterVar 轴。 + * **expr**([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):源表达式。 + * **轴**([IterVar](/docs/api-reference/python-api/tvm-tir#class-tvmtiritervardomrange-varvarstr-iter_typeint-thread_tagstr--spanspannone-none)):缩减 IterVar 轴。 * *where**(*可选**,*Expr*):减少的过滤谓词。 * **返回:value**:结果值。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 **示例** @@ -836,7 +835,7 @@ sum_res = tvm.sum(m, n) * **参数:** * **lhs**([对象](https://docs.python.org/3/library/functions.html#object)):左操作数。 * **rhs**([对象](https://docs.python.org/3/library/functions.html#object)):右操作数。 - * *span**(*可选**[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源中的位置。 + * *span**(*可选**[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源中的位置。 * **返回:op**:加法运算的结果 Expr。 * **返回类型:** tvm.Expr。 @@ -849,8 +848,8 @@ sum_res = tvm.sum(m, n) 通用减法运算符。 * **参数:** * **lhs**([对象](https://docs.python.org/3/library/functions.html#object)):左操作数。 - * **rhs**([对象](https://docs.python.org/3/library/functions.html#object))[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)右操作数。 - * *span**(*可选**[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源中的位置。 + * **rhs**([对象](https://docs.python.org/3/library/functions.html#object))[:](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)右操作数。 + * *span**(*可选**[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源中的位置。 * **返回:op**:减法运算的结果 Expr。 * **返回类型:** tvm.Expr。 @@ -864,7 +863,7 @@ sum_res = tvm.sum(m, n) * **参数:** * **lhs**([对象](https://docs.python.org/3/library/functions.html#object)):左操作数。 * **rhs**([对象](https://docs.python.org/3/library/functions.html#object))*:* 右操作数。 - * *span**(*可选**[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)*:* 此运算符在源中的位置。 + * *span**(*可选**[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)*:* 此运算符在源中的位置。 * **返回:op**:乘法运算的结果 Expr。 * **返回类型:** tvm.Expr。 @@ -879,12 +878,12 @@ sum_res = tvm.sum(m, n) **方法:** -|[asobject](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.TensorSlice.asobject)()|将切片转换为对象。| +|[asobject](/docs/api-reference/python-api/tvm-te#asobject)()|将切片转换为对象。| |:----|:----| **属性:** -|[dtype](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.TensorSlice.dtype)|张量的数据内容。| +|[dtype](/docs/api-reference/python-api/tvm-te#property-dtype)|张量的数据内容。| |:----|:----| ### asobject() @@ -903,7 +902,7 @@ Tensor 对象,构造方法参见 function.Tensor **属性:** -|[ndim](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor.ndim)|张量的维度。| +|[ndim](/docs/api-reference/python-api/tvm-te#property-ndim)|张量的维度。| |:----|:----| ## *property* ndim @@ -943,11 +942,11 @@ def compute_relu(data): 构造一个空的张量对象。 * **参数:** - * **shape**(*Expr的*[元组](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)):张量的形状。 + * **shape**(*Expr的*[Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)):张量的形状。 * **dtype**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*):张量的数据类型。 * **name**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*):张量的名称提示。 * **返回:tensor**:创建的张量。 -* **返回类型:**[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.te.compute(*shape*, *fcompute*, *name='compute'*, *tag=''*, *attrs=None*, *varargs_names=None*) @@ -957,28 +956,28 @@ def compute_relu(data): 计算规则是 result[axis] = fcompute(axis) * **参数:** - * **shape**(*Expr的*[元组](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)):张量的形状。 + * **shape**(*Expr的*[元组](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)):张量的形状。 * **fcompute**(*indices–>value 的lambda 函数*):指定输入源表达式。 * **name**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*)*:* 张量的名称提示。 * **tag**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*):有关计算的附加标签信息。 * **attrs**([dict](https://docs.python.org/3/library/stdtypes.html#dict)*,可选*)**:** 有关计算的附加辅助属性。 * **varargs_names**([list](https://docs.python.org/3/library/stdtypes.html#list)*,可选*)[:](https://docs.python.org/3/library/stdtypes.html#list)每个可变参数使用的名称。如果未提供,可变参数将被称为 i1、i2…… * **返回:tensor**:创建的张量。 -* **返回类型:**[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.te.scan(*init*, *update*, *state_placeholder*, *inputs=None*, *name='scan'*, *tag=''*, *attrs=None*) 通过扫描轴来构建新的张量。 * **参数:** - * **init** ( [Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Tensor*[列表)](https://docs.python.org/3/library/stdtypes.html#list)[:](https://docs.python.org/3/library/stdtypes.html#list)[第一个 init.shape[0] 时间戳](https://docs.python.org/3/library/stdtypes.html#list)[的](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)初始条件。 - * **更新**([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或*[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)[列表](https://docs.python.org/3/library/stdtypes.html#list)*):由符号*张量给出的扫描更新规则。 - * **state_placeholder**([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Tensor*[列表](https://docs.python.org/3/library/stdtypes.html#list)):更新使用的占位符变量[。](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) - * **输入**( [Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) 或 *Tensor* [列表](https://docs.python.org/3/library/stdtypes.html#list)*,可选*):扫描的输入列表。这不是必需的,但有助于编译器更快地检测扫描主体[。](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) + * **init** ( [Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Tensor*[列表)](https://docs.python.org/3/library/stdtypes.html#list)[:](https://docs.python.org/3/library/stdtypes.html#list)[第一个 init.shape[0] 时间戳](https://docs.python.org/3/library/stdtypes.html#list)[的](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)初始条件。 + * **更新**([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或*[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)[列表](https://docs.python.org/3/library/stdtypes.html#list)*):由符号*张量给出的扫描更新规则。 + * **state_placeholder**([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Tensor*[列表](https://docs.python.org/3/library/stdtypes.html#list)):更新使用的占位符变量[。](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) + * **输入**( [Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) 或 *Tensor* [列表](https://docs.python.org/3/library/stdtypes.html#list)*,可选*):扫描的输入列表。这不是必需的,但有助于编译器更快地检测扫描主体[。](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) * **name**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*):张量的名称提示。 * **tag**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*):有关计算的附加标签信息。 * **attrs**([dict](https://docs.python.org/3/library/stdtypes.html#dict)*,可选*):有关计算的附加辅助属性。 * **返回:tensor**:创建的张量或张量元组包含多个输出。 -* **返回类型:**[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) or [list](https://docs.python.org/3/library/stdtypes.html#list) of Tensors。 +* **返回类型:**[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) or [list](https://docs.python.org/3/library/stdtypes.html#list) of Tensors。 **示例** @@ -999,20 +998,20 @@ res = tvm.te.scan(s_init, s_update, s_state, X) 通过外部函数计算多个张量。 * **参数:** * **shape**([元组](https://docs.python.org/3/library/stdtypes.html#tuple)*或元组*[列表](https://docs.python.org/3/library/stdtypes.html#list)*。*):输出的形状。 - * **输入**(*Tensor*[列表)](https://docs.python.org/3/library/stdtypes.html#list)[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)输入 + * **输入**(*Tensor*[列表)](https://docs.python.org/3/library/stdtypes.html#list)[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)输入 * *fcompute**(*输入**的**lambda 函数*,*输出–> stmt*)***:*** 指定用于执行计算的 IR 语句。请参阅以下注释以了解 fcompute 的函数签名。 -:::Note +:::note * **参数** - * *ins* (list of [tvm.tir.Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)) :每个输入的占位符。 - * *outs* (list of [tvm.tir.Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)) :每个输出的占位符。 - * *返回:stmt(*[tvm.tir.Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)*)* :执行数组计算的语句。 + * *ins* (list of [tvm.tir.Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)) :每个输入的占位符。 + * *outs* (list of [tvm.tir.Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)) :每个输出的占位符。 + * *返回:stmt(*[tvm.tir.Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)*)* :执行数组计算的语句。 ::: * **name**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*)**:** 张量的名称提示。 * **dtype**([str](https://docs.python.org/3/library/stdtypes.html#str)*或*[str](https://docs.python.org/3/library/stdtypes.html#str)[列表](https://docs.python.org/3/library/stdtypes.html#list)*,可选):输出的数据类型,默认情况*下 dtype 与输入相同。 - * **in_buffers**([tvm.tir.Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)*或**tvm.tir.Buffer***[列表](https://docs.python.org/3/library/stdtypes.html#list)*,可选*):输入缓冲区[。](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer) - * **out_buffers**([tvm.tir.Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)*或**tvm.tir.Buffer***[列表](https://docs.python.org/3/library/stdtypes.html#list),*可选*):输出缓冲区[。](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer) + * **in_buffers**([tvm.tir.Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)*或**tvm.tir.Buffer***[列表](https://docs.python.org/3/library/stdtypes.html#list)*,可选*):输入缓冲区[。](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer) + * **out_buffers**([tvm.tir.Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)*或**tvm.tir.Buffer***[列表](https://docs.python.org/3/library/stdtypes.html#list),*可选*):输出缓冲区[。](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer) **tag: str, optional** @@ -1022,7 +1021,7 @@ res = tvm.te.scan(s_init, s_update, s_state, X) 有关计算的附加辅助属性。 * **返回:tensor**:创建的张量或张量元组包含多个输出。 -* **返回类型:**[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) or [list](https://docs.python.org/3/library/stdtypes.html#list) of Tensors。 +* **返回类型:**[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) or [list](https://docs.python.org/3/library/stdtypes.html#list) of Tensors。 **示例** @@ -1044,9 +1043,9 @@ C = te.extern((n, m), [A, B], * **参数:** * **name**([str](https://docs.python.org/3/library/stdtypes.html#str)):名称。 * **dtype** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ):数据类型。 - * *span**(*可选**[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此变量在源中的位置。 + * *span**(*可选**[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此变量在源中的位置。 * **返回:var**:结果符号变量。 -* **返回类型:**[tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)。 +* **返回类型:**[tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)。 ## tvm.te.size_var(*name='size'*, *dtype='int32'*, *span=None*) @@ -1055,9 +1054,9 @@ C = te.extern((n, m), [A, B], * **参数:** * **name**([str](https://docs.python.org/3/library/stdtypes.html#str)):名称。 * **dtype** ( [str](https://docs.python.org/3/library/stdtypes.html#str) )*:* 数据类型。 - * *span**(*可选**[[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此变量在源中的位置。 + * *span**(*可选**[[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此变量在源中的位置。 * **返回:var**:结果符号形状变量。 -* **返回类型:**[SizeVar](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.SizeVar)。 +* **返回类型:**[SizeVar](/docs/api-reference/python-api/tvm-tir#class-tvmtirsizevarnamestr-dtypestrtype-spanspannone-none)。 ## tvm.te.const(*value*, *dtype='int32'*, *span=None*) @@ -1066,39 +1065,39 @@ C = te.extern((n, m), [A, B], * **参数:** * *value* ( *Union[*[bool](https://docs.python.org/3/library/functions.html#bool)*,*[int](https://docs.python.org/3/library/functions.html#int)*,*[float](https://docs.python.org/3/library/functions.html#float)*,numpy.ndarray,tvm.nd.NDArray]* )*:* 常量值。 * **dtype** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ):数据类型。 - * *span**(*可选**[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)*:* 此变量在源中的位置。 + * *span**(*可选**[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)*:* 此变量在源中的位置。 * **返回:const**:结果常量 expr。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.te.thread_axis(*dom=None*, *tag=''*, *name=''*, *span=None*) 创建一个新的 IterVar 来表示线程索引。 * **参数:** - * **dom** ( [Range](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Range)*或*[str](https://docs.python.org/3/library/stdtypes.html#str) )**:** 迭代的范围,当传入 str 时,dom 设置为 None,str 作为标签。 + * **dom** ( [Range](/docs/api-reference/python-api/tvm-ir#class-tvmirrangebeginprimexpr-endprimexprnone-none-spanspannone-none)*或*[str](https://docs.python.org/3/library/stdtypes.html#str) )**:** 迭代的范围,当传入 str 时,dom 设置为 None,str 作为标签。 * **tag**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*):线程标签。 * **name**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*):变量的名称。 - * span(*可选*[[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*)**:** 此变量在源中的位置。 + * span(*可选*[[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*)**:** 此变量在源中的位置。 * **返回:axis**:线程迭代变量。 -* **返回类型:**[IterVar](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IterVar)。 +* **返回类型:**[IterVar](/docs/api-reference/python-api/tvm-tir#class-tvmtiritervardomrange-varvarstr-iter_typeint-thread_tagstr--spanspannone-none)。 ## tvm.te.reduce_axis(*dom*, *name='rv'*, *thread_tag=''*, *span=None*) 创建一个新的 IterVar 进行缩减。 * **参数:** - * **dom** ([范围](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Range))**:** 迭代的范围。 + * **dom** ([范围](/docs/api-reference/python-api/tvm-ir#class-tvmirrangebeginprimexpr-endprimexprnone-none-spanspannone-none))**:** 迭代的范围。 * **name** ( [str](https://docs.python.org/3/library/stdtypes.html#str) )*:* 变量的名称。 * *thread_tag**(*可选**[ [str](https://docs.python.org/3/library/stdtypes.html#str)*]*):thread_tag 的名称。 - * *span**(*可选**[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此变量在源中的位置。 + * *span**(*可选**[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此变量在源中的位置。 * **返回:axis**:表示值的迭代变量。 -* **返回类型:**[IterVar](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IterVar)。 +* **返回类型:**[IterVar](/docs/api-reference/python-api/tvm-tir#class-tvmtiritervardomrange-varvarstr-iter_typeint-thread_tagstr--spanspannone-none)。 -## tvm.te.create_prim_func(*ops:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*|*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)*]*, *index_dtype_override:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc) +## tvm.te.create_prim_func(*ops:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*|*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)*]*, *index_dtype_override:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone) 从张量表达式创建 TensorIR PrimFunc。 -* **参数:ops** (*List**[****Union**[****_tensor.Tensor**,*** [tvm.tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)***]****]*):源表达式。 +* **参数:ops** (*List**[****Union**[****_tensor.Tensor**,*** [tvm.tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)***]****]*):源表达式。 **示例** @@ -1137,17 +1136,17 @@ def tir_matmul(a: T.handle, b: T.handle, c: T.handle) -> None: C[vi, vj] += A[vi, vk] * B[vj, vk] ``` * **返回:func**:创建的函数。 -* **返回类型:**[tir.PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc) +* **返回类型:**[tir.PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone) -## tvm.te.extern_primfunc(*input_tensors:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*]*, *primfunc:*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc), ***kwargs*) +## tvm.te.extern_primfunc(*input_tensors:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*]*, *primfunc:*[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone), ***kwargs*) 通过可调度的 TIR PrimFunc 计算张量。 * **参数:** - * **input_tensors**([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)[列表](https://docs.python.org/3/library/stdtypes.html#list)):映射到相应 primfunc 输入参数的输入张量。 - * **primfunc** ( [PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc) ):TIR PrimFunc。 + * **input_tensors**([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)[列表](https://docs.python.org/3/library/stdtypes.html#list)):映射到相应 primfunc 输入参数的输入张量。 + * **primfunc** ( [PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone) ):TIR PrimFunc。 * **返回:tensor**:如果包含多个输出,则创建的张量或张量元组。 -* **返回类型:**[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) or [list](https://docs.python.org/3/library/stdtypes.html#list) of Tensors。 +* **返回类型:**[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) or [list](https://docs.python.org/3/library/stdtypes.html#list) of Tensors。 **示例** @@ -1185,7 +1184,7 @@ C = te.extern_primfunc([A, B], func) **属性:** -|[scan_axis](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.ScanOp.scan_axis)|表示扫描轴,仅当它是 ScanOp 时定义。| +|[scan_axis](/docs/api-reference/python-api/tvm-te#property-scan_axis)|表示扫描轴,仅当它是 ScanOp 时定义。| |:----|:----| ### *property* scan_axis diff --git a/docs/04-api-reference/01-python-api/23-tvm-topi.md b/docs/04-api-reference/01-python-api/23-tvm-topi.md index 0bfc1d6..f79fc92 100644 --- a/docs/04-api-reference/01-python-api/23-tvm-topi.md +++ b/docs/04-api-reference/01-python-api/23-tvm-topi.md @@ -206,97 +206,97 @@ TOPI 是 TVM 的操作符集合库,提供构建计算声明以及优化调度 |:----|:----| -### const_int_bound(*expr :*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ) → ConstIntBound +### const_int_bound(*expr :*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ) → ConstIntBound 查找 expr 的常数整数界限。 -* **参数:expr** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):表达式。 +* **参数:expr** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):表达式。 * **返回:bound**:结果边界。 * **返回类型:** ConstIntBound。 -### const_int_bound_is_bound(*var:*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)) → [bool](https://docs.python.org/3/library/functions.html#bool) +### const_int_bound_is_bound(*var:*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)) → [bool](https://docs.python.org/3/library/functions.html#bool) 检查变量是否绑定到某个范围。 -* **参数:var** ([tvm.tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var))**:** 变量。 +* **参数:var** ([tvm.tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none))**:** 变量。 * **返回:result**:变量是否绑定到某个范围。 * **返回类型:**[bool](https://docs.python.org/3/library/functions.html#bool)。 -### **modular_set(*expr:***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)**)→ ModularSet** +### **modular_set(*expr:***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)**)→ ModularSet** 找到 expr 所属的模集。 -* **参数:expr** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):表达式。 +* **参数:expr** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):表达式。 * **返回:result**:结果。 * **返回类型:** ModularSet。 -### **simplify(*expr:***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)**,*steps:***[int](https://docs.python.org/3/library/functions.html#int)***= 2*)→**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### **simplify(*expr:***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)**,*steps:***[int](https://docs.python.org/3/library/functions.html#int)***= 2*)→**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 通过重写和规范化来简化表达。 * **参数:** - * **expr** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):表达式。 + * **expr** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):表达式。 * **步骤**(*简化按以下顺序运行*):rewrite_simplify(步骤 1)–> canonical_simplify(步骤 2)–> rewrite_simplify(步骤 3)–> canonical_simplify(步骤 4)–> … 参数 steps 控制运行步骤数。默认值为 2,即 rewrite_simplify + canonical_simplify。 * **返回:result**:结果。 * **返回类型:** Expr。 -### rewrite_simplify(*expr :*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### rewrite_simplify(*expr :*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 通过重写规则来简化表达。 -* **参数:expr** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr))**:** 表达式。 +* **参数:expr** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr))**:** 表达式。 * **返回:result**:结果。 * **返回类型:** Expr。 -### canonical_simplify(*expr:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)) → [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### canonical_simplify(*expr:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)) → [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 通过规范化来简化表达。 -* **参数:expr** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):表达式。 +* **参数:expr** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):表达式。 * **返回:result** *:* 结果。 * **返回类型:** Expr。 -### int_set(*expr :*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) , *dom_map :*[dict](https://docs.python.org/3/library/stdtypes.html#dict)*[*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)*, IntSet ]* ) → IntSet +### int_set(*expr :*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) , *dom_map :*[dict](https://docs.python.org/3/library/stdtypes.html#dict)*[*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)*, IntSet ]* ) → IntSet 计算一个符号 IntSet,覆盖 dom_map 中所有值的 expr。 * **参数:** - * **expr** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):表达式。 - * **dom_map** ( *Dict[*[tvm.tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)*,tvm.arith.IntSet]* ):要放宽的变量的域。 + * **expr** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):表达式。 + * **dom_map** ( *Dict[*[tvm.tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)*,tvm.arith.IntSet]* ):要放宽的变量的域。 * **返回:result** :结果。 * **返回类型:** IntSet。 -### can_prove(*expr :*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) *,strength :ProofStrength = ProofStrength.DEFAULT* ) → [bool](https://docs.python.org/3/library/functions.html#bool) +### can_prove(*expr :*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) *,strength :ProofStrength = ProofStrength.DEFAULT* ) → [bool](https://docs.python.org/3/library/functions.html#bool) 检查我们是否可以证明 expr 为真。 * **参数:** - * **expr** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):表达式。 + * **expr** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):表达式。 * **强度**(*ProofStrength*)**:** 证明强度。 * **返回:result** :结果。 * **返回类型:** Expr。 -### **bind(*var:***[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)**,*expr:***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)***|***[Range](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Range)**)→**[None](https://docs.python.org/3/library/constants.html#None) +### **bind(*var:***[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)**,*expr:***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)***|***[Range](/docs/api-reference/python-api/tvm-ir#class-tvmirrangebeginprimexpr-endprimexprnone-none-spanspannone-none)**)→**[None](https://docs.python.org/3/library/constants.html#None) 将变量绑定到表达式。 * **参数:** - * **var** ( [tvm.tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var) ):变量。 - * expr(Union [tir.PrimExpr,[ir.Range](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Range)])**:** 要绑定到的表达式或范围。 + * **var** ( [tvm.tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none) ):变量。 + * expr(Union [tir.PrimExpr,[ir.Range](/docs/api-reference/python-api/tvm-ir#class-tvmirrangebeginprimexpr-endprimexprnone-none-spanspannone-none)])**:** 要绑定到的表达式或范围。 -### **constraint_scope(*constraint:***[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)**)→ ConstraintScope** +### **constraint_scope(*constraint:***[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)**)→ ConstraintScope** 创建约束范围。 * **参数:** - * **constraint** ([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):约束表达式。 + * **constraint** ([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):约束表达式。 * **返回:scope**:约束范围。 * **返回类型:** ConstraintScope。 @@ -312,26 +312,26 @@ with analzyer.constraint_scope(x % 3 == 0): # 约束不再生效 assert analyzer.modular_set(x).coeff != 3 -update(*var: [Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var "tvm.tir.expr.Var")*, *info: ConstIntBound*, *override: [bool](https://docs.python.org/3/library/functions.html#bool "(in Python v3.13)") = False*) → [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.13)") +update(*var: [Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var"tvm.tir.expr.Var""tvm.tir.expr.Var")*, *info: ConstIntBound*, *override: [bool](https://docs.python.org/3/library/functions.html#bool "(in Python v3.13)") = False*) → [None](https://docs.python.org/3/library/constants.html#None "(in Python v3.13)") Update infomation about var ``` -### **update(*var:***[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)**,*info: ConstIntBound*,*override:***[bool](https://docs.python.org/3/library/functions.html#bool)***= False*)→**[None](https://docs.python.org/3/library/constants.html#None) +### **update(*var:***[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)**,*info: ConstIntBound*,*override:***[bool](https://docs.python.org/3/library/functions.html#bool)***= False*)→**[None](https://docs.python.org/3/library/constants.html#None) 更新有关 var 的信息。 * **参数:** - * **var** ( [tvm.tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var) ):变量。 + * **var** ( [tvm.tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none) ):变量。 * **info**(*tvm.Object*):相关信息。 * **override** ( [bool](https://docs.python.org/3/library/functions.html#bool) ):是否允许覆盖。 -### can_prove_equal(*lhs:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *rhs:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)) → [bool](https://docs.python.org/3/library/functions.html#bool) +### can_prove_equal(*lhs:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *rhs:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)) → [bool](https://docs.python.org/3/library/functions.html#bool) 我们是否可以证明 lhs == rhs * **参数:** - * **lhs** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):比较的左侧。 - * **rhs** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):比较的右侧。 + * **lhs** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):比较的左侧。 + * **rhs** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):比较的右侧。 * **返回:result**:我们是否可以证明 lhs == rhs。 * **返回类型:**[bool](https://docs.python.org/3/library/functions.html#bool)。 @@ -340,14 +340,14 @@ Update infomation about var 返回当前启用的扩展。 -## *class* tvm.topi.Cast(*dtype*, *value*, *span:*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) +## *class* tvm.topi.Cast(*dtype*, *value*, *span:*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) 转换表达式。 * **参数:** * **dtype** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ):数据类型。 - * **值**([PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)):函数的值。 - * *span*(*可选*[[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此表达式在源代码中的位置。 + * **值**([PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)):函数的值。 + * *span*(*可选*[[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此表达式在源代码中的位置。 ## *class* tvm.topi.PrimExpr @@ -361,67 +361,67 @@ PrimExpr 用于低级代码优化和整数分析。 逐个元素地取 x 输入的绝对值。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) [:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入参数。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ## tvm.topi.acos(*x*) 取输入 x 的反余弦值。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) [:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入参数。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.acosh(*x*) 取输入 x 的反余弦值。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) :输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) :输入参数。 * **返回:y** *:* 结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.add(*lhs*, *rhs*) 自动广播加法 * **参数:** - * **lhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*):左操作数。 - * **rhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*):右操作数。 + * **lhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*):左操作数。 + * **rhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*):右操作数。 * **返回:ret**:如果两个操作数都是 Expr,则返回 Expr。否则返回 Tensor。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) or Expr。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) or Expr。 ## tvm.topi.adv_index(*data*, *indices*) 使用张量进行 Numpy 样式索引。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入数据。 - * **indices**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*列表):张量*索引。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入数据。 + * **indices**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*列表):张量*索引。 * **返回:result**:输出张量。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.all(*data*, *axis=None*, *keepdims=False*) 对给定轴或轴列表上的数组元素进行逻辑与。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入 tvm 布尔张量。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入 tvm 布尔张量。 * **axis**(*None、*[int](https://docs.python.org/3/library/functions.html#int)*或*[int 元](https://docs.python.org/3/library/functions.html#int)*组*[)](https://docs.python.org/3/library/stdtypes.html#tuple):执行逻辑与运算的轴。默认值 axis=None,表示对输入数组的所有元素执行逻辑与运算。如果 axis 为负数,则从最后一个轴计数到第一个轴。 * **keepdims** ( [bool](https://docs.python.org/3/library/functions.html#bool) ):如果设置为 True,则缩小的轴将保留在结果中,作为大小为 1 的维度。使用此选项,结果将根据输入数组正确广播。 * **返回:ret。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.any(*data*, *axis=None*, *keepdims=False*) 对给定轴或轴列表上的数组元素进行逻辑或 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入 tvm 布尔张量。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入 tvm 布尔张量。 * **axis**(*None、*[int](https://docs.python.org/3/library/functions.html#int)*或*[int 元](https://docs.python.org/3/library/functions.html#int)*组*[)](https://docs.python.org/3/library/stdtypes.html#tuple):执行逻辑或运算的轴。默认值 axis=None,将对输入数组的所有元素执行逻辑或运算。如果 axis 为负数,则从最后一个轴计数到第一个轴。 * **keepdims** ( [bool](https://docs.python.org/3/library/functions.html#bool) ):如果设置为 True,则缩小的轴将保留在结果中,作为大小为 1 的维度。使用此选项,结果将根据输入数组正确广播。 * **返回:ret。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.arange(*start*, *stop=None*, *step=1*, *dtype='float32'*) @@ -433,44 +433,44 @@ PrimExpr 用于低级代码优化和整数分析。 * *step*(*tvm.Expr*,*可选*):值之间的间距。默认步长为 1。 * **dtype**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*):目标数据类型。 * **返回:result** **:** 结果张量。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.argmax(*data*, *axis=None*, *keepdims=False*, *select_last_index=False*) 返回沿轴的最大值的索引。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入 tvm 张量。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入 tvm 张量。 * **axis**(*None、*[int](https://docs.python.org/3/library/functions.html#int)*或*[int 元](https://docs.python.org/3/library/functions.html#int)*组*[)](https://docs.python.org/3/library/stdtypes.html#tuple):执行 argmax 运算的一个或多个轴。默认值 axis=None 将查找输入数组元素中最大元素的索引。如果 axis 为负数,则从最后一个轴计数到第一个轴。 * **keepdims** ( [bool](https://docs.python.org/3/library/functions.html#bool) ):如果设置为 True,则缩小的轴将保留在结果中,作为大小为 1 的维度。使用此选项,结果将根据输入数组正确广播。 * **select_last_index** ( [bool](https://docs.python.org/3/library/functions.html#bool) ):如果最大元素出现多次,是否选择最后一个索引,否则选择第一个索引。 * **返回:ret。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.argmin(*data*, *axis=None*, *keepdims=False*, *select_last_index=False*) 返回沿轴的最小值的索引。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 输入 tvm 张量。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 输入 tvm 张量。 * **axis**(*None、*[int](https://docs.python.org/3/library/functions.html#int)*或*[int 元](https://docs.python.org/3/library/functions.html#int)*组*[)](https://docs.python.org/3/library/stdtypes.html#tuple):执行 argmin 操作的轴。默认值 axis=None,将查找输入数组所有元素中最小元素的索引。如果 axis 为负数,则从最后一个轴计数到第一个轴。 * **keepdims** ( [bool](https://docs.python.org/3/library/functions.html#bool) ):如果设置为 True,则缩小的轴将保留在结果中,作为大小为 1 的维度。使用此选项,结果将根据输入数组正确广播。 * **select_last_index** ( [bool](https://docs.python.org/3/library/functions.html#bool) ):如果最小元素出现多次,是否选择最后一个索引,否则选择第一个索引。 * **返回:ret。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.argsort(*data*, *valid_count=None*, *axis=-1*, *is_ascend=1*, *dtype='float32'*) 沿给定轴执行排序,并返回与按排序顺序索引数据的输入数组具有相同形状的索引数组。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 输入张量。 - * **valid_count**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*,可选*)**:** 有效框数量的一维张量。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 输入张量。 + * **valid_count**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*,可选*)**:** 有效框数量的一维张量。 * **axis**([int](https://docs.python.org/3/library/functions.html#int)*,可选*):对输入张量进行排序的轴。默认情况下使用扁平数组。 * *is_ascend**(*布尔值**,*可选*):按升序还是降序排序。 * *dtype**(*字符串**,*可选*)**:** 输出索引的 DType。 * **返回:out** :排序索引张量。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 **示例** @@ -494,33 +494,33 @@ f(tvm_data, tvm_out) 对输入 x 取反正弦值。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) :输入参数。 -* **返回:y** [:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) :输入参数。 +* **返回:y** [:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)结果。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.asinh(*x*) 对输入 x 取反正弦值。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) **:** 输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) **:** 输入参数。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.atan(*x*) 对输入 x 取正切值。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) :输入参数。 -* **返回:y** [:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) :输入参数。 +* **返回:y** [:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)结果。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.atanh(*x*) 对输入 x 进行 atanh 处理。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) :输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) :输入参数。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.binary_search(*ib*, *sequence_offset*, *search_range*, *sorted_sequence*, *value*, *right*, *out_dtype*) @@ -538,38 +538,38 @@ sorted_sequence 是一个 ND 缓冲区,我们要在其最内层维度中搜索 逐元素按位计算数据的「与」。 * **参数:** - * **lhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*)[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)左操作数。 - * **rhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*):右操作数。 + * **lhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*)[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)左操作数。 + * **rhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*):右操作数。 * **返回:ret** :如果两个操作数都是 Expr,则返回 Expr。否则返回 Tensor。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) or Expr。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) or Expr。 ## tvm.topi.bitwise_not(*data*) 逐元素按位计算数据的「非」。 -* **参数:数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*orExpr*)。 +* **参数:数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*orExpr*)。 * **返回:ret** :如果操作数是 Expr,则返回 Expr。否则返回 Tensor。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) or Expr。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) or Expr。 ## tvm.topi.bitwise_or(*lhs*, *rhs*) 逐元素按位或计算数据。 * **参数:** - * **lhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*)[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)左操作数。 - * **rhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*):右操作数。 + * **lhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*)[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)左操作数。 + * **rhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*):右操作数。 * **返回:ret** :如果两个操作数都是 Expr,则返回 Expr。否则返回 Tensor。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) or Expr。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) or Expr。 ## tvm.topi.bitwise_xor(*lhs*, *rhs*) 计算数据的逐元素按位异或。 * **参数:** - * **lhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*)*:* 左操作数。 - * **rhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*):右操作数。 + * **lhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*)*:* 左操作数。 + * **rhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*):右操作数。 * **返回:ret** :如果两个操作数都是 Expr,则返回 Expr。否则返回 Tensor。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) or Expr。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) or Expr。 ## tvm.topi.broadcast_to(*data*, *shape*) @@ -579,48 +579,48 @@ sorted_sequence 是一个 ND 缓冲区,我们要在其最内层维度中搜索 我们遵循 numpy 广播规则。另请参阅[https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html](https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html)。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入数据。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入数据。 * **shape**([列表](https://docs.python.org/3/library/stdtypes.html#list)*或*[元组](https://docs.python.org/3/library/stdtypes.html#tuple))**:** 要广播的目标形状。 * **返回:ret。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.cast(*x*, *dtype*, *span=None*) 将输入转换为指定的数据类型。 * **参数:** - * **x**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*):输入参数。 - * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str))[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)数据类型。 - * *span**(*可选**[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):源中演员的位置。 + * **x**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*):输入参数。 + * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str))[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)数据类型。 + * *span**(*可选**[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):源中演员的位置。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.ceil(*x*) 取输入 x 的上限。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) :输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) :输入参数。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.ceil_log2(*x*) 使用 Vulkan 的特殊代码路径计算整数 ceil log2。SPIR-V 不支持 fp64 上的 log2。因此,当目标平台为 Vulkan 时,我们通过 clz 内在函数计算整数 ceil_log2。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) :输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) :输入参数。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.clip(*x*, *a_min*, *a_max*) 裁剪(限制)数组中的值。给定一个区间,区间之外的值将被裁剪到区间边缘。 * **参数:** - * **x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) [:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)输入参数。 + * **x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) [:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)输入参数。 * **a_min** (*tvm.tir.PrimExpr*) *:* 最小值。 * **a_max** (*tvm.tir.PrimExpr*):最大值。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.collapse_sum(*data*, *target_shape*) @@ -636,20 +636,20 @@ crash_sum 旨在作为自动微分过程中 topi 广播操作符的后向操作 计算过程中,data.shape 和 target_shape 的轴会从右到左进行检查。对于每个轴,如果满足以下任一条件:- 存在于数据中但不存在于 target_shape 中;或 - 在数据中大于 1 且在 target_shape 中等于 1,则数据将在该轴上进行求和。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入张量。 - * **shape** ([Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*):要折叠的形状。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入张量。 + * **shape** ([Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*):要折叠的形状。 * **返回:ret**:求和后的结果张量。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.concatenate(*a_tuple*, *axis=0*) 沿现有轴连接一系列数组。 * **参数:** - * **a_tuple**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*的*[元组](https://docs.python.org/3/library/stdtypes.html#tuple)):要连接的数组。 + * **a_tuple**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*的*[元组](https://docs.python.org/3/library/stdtypes.html#tuple)):要连接的数组。 * **axis** ([int](https://docs.python.org/3/library/functions.html#int)*, 可选*):数组将沿其连接的轴。默认值为 0。 * **返回:ret。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.const_vector(*vector*, *name='const_vector'*) @@ -658,43 +658,43 @@ crash_sum 旨在作为自动微分过程中 topi 广播操作符的后向操作 * **vector** (*numpy.ndarray*):常量输入数组。 * **name** (str, 可选)**:** 输出操作的名称。 * **返回:tensor** :创建的 tensor。 -* **返回类型:**[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.cos(*x*) 对输入 x 取余弦。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)输入参数。 * **返回:y**:结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.cosh(*x*) 对输入 x 取双曲余弦。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))*:* 输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))*:* 输入参数。 * **返回:y** *:* 结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 -## tvm.topi.cumprod(*data:*[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *dtype:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *exclusive:*[bool](https://docs.python.org/3/library/functions.html#bool)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) +## tvm.topi.cumprod(*data:*[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *dtype:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *exclusive:*[bool](https://docs.python.org/3/library/functions.html#bool)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) Numpy 风格的累积乘积操作。返回沿给定轴的元素的累积乘积。 * **参数:** - * **data** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):操作的输入数据。 + * **data** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):操作的输入数据。 * **axis** ([int](https://docs.python.org/3/library/functions.html#int)*,optional*):计算累积乘积的轴。默认(None)是计算展平数组的累积乘积。 * **dtype** (*string,optional*):返回数组的类型以及元素相乘的累加器的类型。如果未指定 dtype,则默认为 data 的 dtype。 * **exclusive** ([bool](https://docs.python.org/3/library/functions.html#bool)*,optional*) :如果为 True,将返回一个排他性乘积,其中第一个元素不包含在内。换句话说,如果为 True,第 j 个输出元素将是前 (j-1) 个元素的乘积。否则,将是前 j 个元素的乘积。 * **返回:result** :结果与 data 具有相同的大小,如果 axis 不是 None,则形状也相同。如果 axis 是 None,结果是一个一维数组。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 -## tvm.topi.cumsum(*data:*[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *exclusive:*[bool](https://docs.python.org/3/library/functions.html#bool)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) +## tvm.topi.cumsum(*data:*[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *exclusive:*[bool](https://docs.python.org/3/library/functions.html#bool)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) Numpy 风格的 cumsum 操作。返回沿给定轴的元素累积和。 * **参数:** - * **data** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) :运算符的输入数据。 + * **data** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) :运算符的输入数据。 * **axis** ([int](https://docs.python.org/3/library/functions.html#int)*,optional*):沿着哪个轴计算累积和。默认值(None)是计算扁平化数组的 cumsum。 * **dtype** (*string,optional*) :返回数组的类型以及用于累加元素的累加器的类型。如果未指定 dtype,则默认为 data 的 dtype。 * **exclusive** ([bool](https://docs.python.org/3/library/functions.html#bool)*,optional*) :如果为 True,将返回排他性求和,其中第一个元素不包含在内。换句话说,如果为 True,第 j 个输出元素将是前 (j-1) 个元素的和。否则,它将是前 j 个元素的和。 * **返回:result**:结果与 data 的大小相同,如果 axis 不是 None,则形状也与 data 相同。如果 axis 是 None,结果是一个 1 维数组。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ## tvm.topi.decl_buffer(*shape*, *dtype=None*, *name='buffer'*, *data=None*, *strides=None*, *elem_offset=None*, *scope=''*, *data_alignment=-1*, *offset_factor=0*, *buffer_type=''*, *axis_separators=None*, *span=None*) @@ -707,7 +707,7 @@ Numpy 风格的 cumsum 操作。返回沿给定轴的元素累积和。 * **shape** ([tuple](https://docs.python.org/3/library/stdtypes.html#tuple)*ofExpr*) :缓冲区的形状。 * **dtype** ([str](https://docs.python.org/3/library/stdtypes.html#str)*,optional*):缓冲区的数据类型。 * **name** ([str](https://docs.python.org/3/library/stdtypes.html#str)*,optional*):缓冲区的名称。 - * **data** ([tir.Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var)*,optional*) *:* 缓冲区中的数据指针。 + * **data** ([tir.Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none)*,optional*) *:* 缓冲区中的数据指针。 * **strides** (*arrayofExpr*):缓冲区的步长。 * **elem_offset** (*Expr,optional*) :数组到数据的起始偏移量。以 dtype 元素数量为单位。 * **scope** ([str](https://docs.python.org/3/library/stdtypes.html#str)*,optional*):缓冲区的存储范围,如果不是全局的。如果 scope 等于空字符串,表示它是全局内存。 @@ -715,11 +715,11 @@ Numpy 风格的 cumsum 操作。返回沿给定轴的元素累积和。 * **offset_factor** ([int](https://docs.python.org/3/library/functions.html#int)*,optional*):elem_offset 字段的因子,当设置时,elem_offset 必须是 offset_factor 的倍数。如果传入 0,对齐将被设置为 1。如果传入非零值,当 elem_offset 不为 None 时,我们将为 elem_offset 创建一个 Var。 * **buffer_type** ([str](https://docs.python.org/3/library/stdtypes.html#str)*,optional,* ***{""****,"auto_broadcast"}*)*:* auto_broadcast buffer 允许在不考虑维度大小是否等于一的情况下实现广播计算。TVM 将 buffer[i][j][k] 映射到 buffer[i][0][k],如果维度 j 的形状等于 1。 * **axis_separators** ([list](https://docs.python.org/3/library/stdtypes.html#list)*of*[int](https://docs.python.org/3/library/functions.html#int)*,optional*) :如果传入,则是一个分隔轴组的列表,每个组将被展平为一个输出轴。对于扁平内存空间,应该是 None 或一个空列表。 - * **span** (*Optional[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*) :在源代码中创建 decl_buffer 的位置。 + * **span** (*Optional[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*) :在源代码中创建 decl_buffer 的位置。 * **返回:buffer** :创建的缓冲区。 -* **返回类型:**[tvm.tir.Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)。 +* **返回类型:**[tvm.tir.Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)。 -:::Note +:::note Buffer 数据结构反映了 dlpack 中的 DLTensor 结构。虽然 DLTensor 数据结构非常通用,但通常创建只处理特定数据结构情况的函数是有帮助的,这样编译后的函数可以从中受益。 @@ -727,13 +727,13 @@ Buffer 数据结构反映了 dlpack 中的 DLTensor 结构。虽然 DLTensor 数 ::: -## tvm.topi.dft(*re_data:*[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor), *im_data:*[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor), *inverse:*[IntImm](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.IntImm)) +## tvm.topi.dft(*re_data:*[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor), *im_data:*[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor), *inverse:*[IntImm](/docs/api-reference/python-api/tvm-tir#class-tvmtirintimmdtypestr-valueint-spanspannone-none)) 计算输入的离散傅里叶变换(沿最后一个轴计算)。这将给出信号随时间变化的频率分量。 * **参数:** - * **re_data**([te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)ND 张量,输入信号的实部。 - * **im_data** ( [te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) ):ND 张量,输入信号的虚部。如果信号为实数,则该张量的值为零。 + * **re_data**([te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)ND 张量,输入信号的实部。 + * **im_data** ( [te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ):ND 张量,输入信号的虚部。如果信号为实数,则该张量的值为零。 * **inverse**([bool](https://docs.python.org/3/library/functions.html#bool)):是否执行逆离散傅里叶变换。 * **返回:** * **re_output** (*te.Tensor*):输入的傅里叶变换(实部)。 @@ -746,13 +746,13 @@ Buffer 数据结构反映了 dlpack 中的 DLTensor 结构。虽然 DLTensor 数 按照 C/C++ 语义计算 a / b。 * **参数:** - * **a** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):左侧操作数,已知为非负数。 - * **b** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):右侧操作数,已知为非负。 - * *span**(*可选**[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源中的位置。 + * **a** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):左侧操作数,已知为非负数。 + * **b** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):右侧操作数,已知为非负。 + * *span**(*可选**[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源中的位置。 * **返回:res** :结果表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 -:::Note +:::note 当操作数为整数时,返回 truncdiv(a, b, span)。 @@ -763,23 +763,23 @@ Buffer 数据结构反映了 dlpack 中的 DLTensor 结构。虽然 DLTensor 数 自动广播分工。 * **参数:** - * **lhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*):左操作数。 - * **rhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*):右操作数。 + * **lhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*):左操作数。 + * **rhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*):右操作数。 * **返回:ret** :如果两个操作数都是 Expr,则返回 Expr。否则返回 Tensor。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) or Expr。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) or Expr。 ## tvm.topi.dynamic_strided_slice(*a*, *begin*, *end*, *strides*, *output_shape*) 数组的切片。 * **参数:** - * **a** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):要切片的张量。 - * **begin** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) [:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)切片中开始的索引。 - * **end** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) *:* 指示切片结束的索引。 - * **strides** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):指定步幅值,在这种情况下它可以为负,输入张量将在该特定轴上反转。 - * **output_shape**(*PrimExpr*[列表)](https://docs.python.org/3/library/stdtypes.html#list)[–](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)指定输出形状。 + * **a** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):要切片的张量。 + * **begin** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) [:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)切片中开始的索引。 + * **end** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) *:* 指示切片结束的索引。 + * **strides** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):指定步幅值,在这种情况下它可以为负,输入张量将在该特定轴上反转。 + * **output_shape**(*PrimExpr*[列表)](https://docs.python.org/3/library/stdtypes.html#list)[–](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)指定输出形状。 * **返回:ret。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.einsum(*subscripts*, operand*) @@ -787,53 +787,53 @@ Buffer 数据结构反映了 dlpack 中的 DLTensor 结构。虽然 DLTensor 数 评估操作数的爱因斯坦求和约定。 * **参数:** * **subscripts**(*字符串*):将求和的下标指定为以逗号分隔的下标标签列表。除非包含显式指示符“–>”以及精确输出形式的下标标签,否则将执行隐式(经典爱因斯坦求和)计算。 - * **a_tuple**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*的*[元组](https://docs.python.org/3/library/stdtypes.html#tuple)):这些是用于运算的张量。tvm 和 numpy 中 einsum 的唯一区别在于,einsum 需要额外的括号来表示张量。例如,topi.einsum(“ij, jk –> ik”, (A, B))。 -* **返回:out**[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)基于爱因斯坦求和约定的计算。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 + * **a_tuple**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*的*[元组](https://docs.python.org/3/library/stdtypes.html#tuple)):这些是用于运算的张量。tvm 和 numpy 中 einsum 的唯一区别在于,einsum 需要额外的括号来表示张量。例如,topi.einsum(“ij, jk –> ik”, (A, B))。 +* **返回:out**[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)基于爱因斯坦求和约定的计算。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.elemwise_sum(*xs*) 对输入执行元素求和。 -* **参数:xs** ([list](https://docs.python.org/3/library/stdtypes.html#list)*of*[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) *:*–] "tvm.te.张量")输入参数。 +* **参数:xs** ([list](https://docs.python.org/3/library/stdtypes.html#list)*of*[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) *:*–] "tvm.te.张量")输入参数。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.equal(*lhs*, *rhs*) 使用自动广播计算 (lhs==rhs) * **参数:** - * **lhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*)**:** 左操作数。 - * **rhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*):右操作数。 -* **返回:ret**[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)如果两个操作数都是 Expr,则返回 Expr。否则返回 Tensor。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) or Expr。 + * **lhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*)**:** 左操作数。 + * **rhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*):右操作数。 +* **返回:ret**[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)如果两个操作数都是 Expr,则返回 Expr。否则返回 Tensor。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) or Expr。 ## tvm.topi.erf(*x*) 取输入 x 的高斯误差函数。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) :输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) :输入参数。 * **返回:y** **:** 结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.exp(*x*) 取输入 x 的指数。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) **:** 输入参数。 -* **返回:y** [:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) **:** 输入参数。 +* **返回:y** [:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)结果。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.expand_dims(*a*, *axis*, *num_newaxis=1*) 扩展数组的形状。 * **参数:** - * **a**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 要扩展的张量。 + * **a**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 要扩展的张量。 * **num_newaxis** ( [int](https://docs.python.org/3/library/functions.html#int)*,可选*):要在轴上插入的新轴的数量。 * **返回:ret。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.expand_like(*a*, *shape_like*, *axis*) @@ -858,11 +858,11 @@ expand_like(input, [1,2], new_shape_array) = [[27,27],[27,27],[27,27]]] ``` * **参数:** - * **a**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 要扩展的张量。 - * **shape_like**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)具有目标形状的张量。 + * **a**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 要扩展的张量。 + * **shape_like**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)具有目标形状的张量。 * **axis**(*int*[列表](https://docs.python.org/3/library/stdtypes.html#list)):要扩展的[轴](https://docs.python.org/3/library/functions.html#int)。 * **返回:ret。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.extern(*shape*, *inputs*, *fcompute*, *name='extern'*, *dtype=None*, *in_buffers=None*, *out_buffers=None*, *tag=''*, *attrs=None*) @@ -870,20 +870,20 @@ expand_like(input, [1,2], new_shape_array) = 通过外部函数计算多个张量。 * **参数:** * **shape**([元组](https://docs.python.org/3/library/stdtypes.html#tuple)*或元组*[列表](https://docs.python.org/3/library/stdtypes.html#list)*。*):输出的形状。 - * **输入**(*Tensor*[列表)](https://docs.python.org/3/library/stdtypes.html#list)[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)输入。 + * **输入**(*Tensor*[列表)](https://docs.python.org/3/library/stdtypes.html#list)[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)输入。 * *fcompute**(*输入**的**lambda 函数**,*输出–> stmt*):指定用于执行计算的 IR 语句。请参阅以下注释以了解 fcompute 的函数签名。 -:::Note +:::note * **参数:** - * **ins** (list of [tvm.tir.Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)) :每个输入的占位符 - * **outs** (list of [tvm.tir.Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)) :每个输出的占位符 -* **返回:stmt** ([tvm.tir.Stmt](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Stmt)) :执行数组计算的语句。 + * **ins** (list of [tvm.tir.Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)) :每个输入的占位符 + * **outs** (list of [tvm.tir.Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)) :每个输出的占位符 +* **返回:stmt** ([tvm.tir.Stmt](/docs/api-reference/python-api/tvm-tir#class-tvmtirstmt)) :执行数组计算的语句。 ::: * **name**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*)**:** 张量的名称提示 - * **dtype**([str](https://docs.python.org/3/library/stdtypes.html#str)*或*[str](https://docs.python.org/3/library/stdtypes.html#str)[列表](https://docs.python.org/3/library/stdtypes.html#list)*,**可选)***[:](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)***输出的数据类型,默认****情况*下 dtype 与输入相同。 - * **in_buffers**([tvm.tir.Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)*或**tvm.tir.Buffer***[列表](https://docs.python.org/3/library/stdtypes.html#list)***,****可选*)***:*** 输入缓冲区[。](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer) - * **out_buffers**([tvm.tir.Buffer](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer)*或**tvm.tir.Buffer***[列表](https://docs.python.org/3/library/stdtypes.html#list)***,*** *可选*):输出缓冲区[。](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Buffer) + * **dtype**([str](https://docs.python.org/3/library/stdtypes.html#str)*或*[str](https://docs.python.org/3/library/stdtypes.html#str)[列表](https://docs.python.org/3/library/stdtypes.html#list)*,**可选)***[:](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)***输出的数据类型,默认****情况*下 dtype 与输入相同。 + * **in_buffers**([tvm.tir.Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)*或**tvm.tir.Buffer***[列表](https://docs.python.org/3/library/stdtypes.html#list)***,****可选*)***:*** 输入缓冲区[。](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer) + * **out_buffers**([tvm.tir.Buffer](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer)*或**tvm.tir.Buffer***[列表](https://docs.python.org/3/library/stdtypes.html#list)***,*** *可选*):输出缓冲区[。](/docs/api-reference/python-api/tvm-tir#class-tvmtirbuffer) **tag: str, optional** @@ -896,7 +896,7 @@ expand_like(input, [1,2], new_shape_array) = 有关计算的其他辅助属性。 * **返回:tensor**:创建的张量或张量元组包含多个输出。 -* **返回类型:**[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) or [list](https://docs.python.org/3/library/stdtypes.html#list) of Tensors +* **返回类型:**[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) or [list](https://docs.python.org/3/library/stdtypes.html#list) of Tensors **示例** @@ -912,7 +912,7 @@ C = te.extern((n, m), [A, B], "tvm.contrib.cblas.matmul", ins[0], ins[1], outs[0], 0, 0), name="C") ``` -## tvm.topi.eye(*n:*[int](https://docs.python.org/3/library/functions.html#int), *m:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *k:*[int](https://docs.python.org/3/library/functions.html#int)*= 0*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'float32'*) → [Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) +## tvm.topi.eye(*n:*[int](https://docs.python.org/3/library/functions.html#int), *m:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *k:*[int](https://docs.python.org/3/library/functions.html#int)*= 0*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= 'float32'*) → [Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) 生成一个单位矩阵或第 k 个对角线为 1 的矩阵。 @@ -922,116 +922,116 @@ C = te.extern((n, m), [A, B], * **k**([int](https://docs.python.org/3/library/functions.html#int)*,可选*):对角线的索引。0(默认值)表示主对角线。正值表示上对角线,负值表示下对角线。 * **dtype**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*):返回数组的数据类型。 * **返回:y** **:** 结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.fast_erf(*x*) 使用 fast_erf 实现获取输入 x 的高斯误差函数。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) :输入参数。 -* **返回:y** [:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) :输入参数。 +* **返回:y** [:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)结果。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.fast_exp(*x*) 使用 fast_exp 实现对输入 x 进行指数运算。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) *:* 输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) *:* 输入参数。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.fast_tanh(*x*) 使用 fast_tanh 实现对输入 x 进行双曲正切 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) :输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) :输入参数。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.fixed_point_multiply(*x*, *multiplier*, *shift*) 数据与定点常数之间的定点乘法表示为乘数 * 2^(-shift),其中乘数是一个具有 31 个小数位的 Q 数 * **参数:** - * **x**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*):输入参数。 + * **x**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*):输入参数。 * **乘数**([int](https://docs.python.org/3/library/functions.html#int))*:* 固定浮点数的乘数,表示为乘数*2^(–shift)。 * **shift**([int](https://docs.python.org/3/library/functions.html#int)):固定浮点数的移位,描述为乘数*2^(–shift)。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 -## tvm.topi.fixed_point_multiply_per_axis(*x:*[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor), *y:*[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor), *lshift:*[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor), *rshift:*[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor), *is_lshift_required:*[int](https://docs.python.org/3/library/functions.html#int), *is_rshift_required:*[int](https://docs.python.org/3/library/functions.html#int), *axes*) +## tvm.topi.fixed_point_multiply_per_axis(*x:*[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor), *y:*[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor), *lshift:*[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor), *rshift:*[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor), *is_lshift_required:*[int](https://docs.python.org/3/library/functions.html#int), *is_rshift_required:*[int](https://docs.python.org/3/library/functions.html#int), *axes*) 数据与定点常数之间的定点乘法表示为乘数 * 2^(-shift),其中乘数是一个具有 31 个小数位的 Q 数。 * **参数:** - * **x**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入参数。 - * **y**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):固定浮点数的乘数,描述为乘数*2^(–shift)。 - * **lshift**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):固定浮点数的左移,描述为乘数*2^(–shift)。 - * **rshift**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):固定浮点数的右移,描述为乘数*2^(–shift)。 - * **is_lshift_required** ( [int](https://docs.python.org/3/library/functions.html#int) )[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)我们是否需要进行左移。 + * **x**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入参数。 + * **y**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):固定浮点数的乘数,描述为乘数*2^(–shift)。 + * **lshift**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):固定浮点数的左移,描述为乘数*2^(–shift)。 + * **rshift**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):固定浮点数的右移,描述为乘数*2^(–shift)。 + * **is_lshift_required** ( [int](https://docs.python.org/3/library/functions.html#int) )[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)我们是否需要进行左移。 * **is_rshift_required** ( [int](https://docs.python.org/3/library/functions.html#int) ):我们是否需要进行右移。 * **返回:z** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.flip(*a*, *axis=0*) 在特定轴上翻转/反转数组的元素。 * **参数:** - * **a**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)要扩展的张量。 + * **a**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)要扩展的张量。 * **axis**([int](https://docs.python.org/3/library/functions.html#int)*,可选*):张量将沿其反转的轴。 * **返回:ret。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.floor(*x*) 取输入 x 的底数。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) [:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) [:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)输入参数。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.floor_divide(*lhs*, *rhs*) 使用自动广播的整数除法。 * **参数:** - * **lhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*):左操作数。 - * **rhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*)[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)右操作数。 + * **lhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*):左操作数。 + * **rhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*)[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)右操作数。 * **返回:ret**:如果两个操作数都是 Expr,则返回 Expr。否则返回 Tensor。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) or Expr。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) or Expr。 ## tvm.topi.floor_mod(*lhs*, *rhs*) 使用自动广播的向下取模。 * **参数:** - * **lhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*):左操作数。 - * **rhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*)[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)右操作数。 -* **返回:ret**[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)如果两个操作数都是 Expr,则返回 Expr。否则返回 Tensor。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) or Expr。 + * **lhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*):左操作数。 + * **rhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*)[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)右操作数。 +* **返回:ret**[:](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)如果两个操作数都是 Expr,则返回 Expr。否则返回 Tensor。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) or Expr。 ## tvm.topi.floordiv(*a*, *b*, *span=None*) 计算两个表达式的 floordiv。 * **参数:** - * **a** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):左侧操作数。 - * **b** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):右侧操作数。 - * span**(*可选*[*[Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]):此运算符在源中的位置。 + * **a** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):左侧操作数。 + * **b** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):右侧操作数。 + * span**(*可选*[*[Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]):此运算符在源中的位置。 * **返回:res**:结果表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.topi.floormod(*a*, *b*, *span=None*) 计算两个表达式的 floormod。 * **参数:** - * **a** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):左侧操作数。 - * **b** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) )**:** 右侧操作数。 - * *span**(*可选**[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源中的位置。 + * **a** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):左侧操作数。 + * **b** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) )**:** 右侧操作数。 + * *span**(*可选**[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源中的位置。 * **返回:res:** 结果表达式。 -* **返回类型:**[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)。 +* **返回类型:**[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)。 ## tvm.topi.full(*shape*, *dtype*, *fill_value*) @@ -1042,7 +1042,7 @@ C = te.extern((n, m), [A, B], * **dtype**([str](https://docs.python.org/3/library/stdtypes.html#str)):数据类型。 * **fill_value** ( [float](https://docs.python.org/3/library/functions.html#float) ):要填充的值。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.full_like(*x*, *fill_value*) @@ -1052,10 +1052,10 @@ C = te.extern((n, m), [A, B], 然后用 fill_value 填充张量。 * **参数:** - * **x**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入参数。 + * **x**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入参数。 * **fill_value** ( [float](https://docs.python.org/3/library/functions.html#float) ):要填充的值。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.gather(*data*, *axis*, *indices*) @@ -1075,21 +1075,21 @@ out[i][j][k] = data[i][j][indices[i][j][k]] # if axis == 2 `indices`必须具有与 相同的形状`data`,但维度`axis` 必须不为空。输出将具有与 相同的形状`indices`。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 运算符的输入数据。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 运算符的输入数据。 * **axis**([int](https://docs.python.org/3/library/functions.html#int)):沿其进行索引的轴。 - * **indices**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):要提取的值的索引。 + * **indices**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):要提取的值的索引。 * **返回:ret。** -* **返回类型:**[tvm.te.Tenso](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tenso](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.gather_nd(*a*, *indices*, *batch_dims=0*) 从 n 维数组中收集元素.. * **参数:** - * **a**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):源数组。 - * **indices**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))*:* 要提取的值的索引。 + * **a**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):源数组。 + * **indices**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))*:* 要提取的值的索引。 * **返回:ret。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.get_const_tuple(*in_tuple*) @@ -1104,20 +1104,20 @@ out[i][j][k] = data[i][j][indices[i][j][k]] # if axis == 2 使用自动广播计算 (lhs>rhs)。 * **参数:** - * **lhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*):左操作数。 - * **rhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*):右操作数。 -* **返回:ret**[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)如果两个操作数都是 Expr,则返回 Expr。否则返回 Tensor。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) or Expr。 + * **lhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*):左操作数。 + * **rhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*):右操作数。 +* **返回:ret**[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)如果两个操作数都是 Expr,则返回 Expr。否则返回 Tensor。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) or Expr。 ## tvm.topi.greater_equal(*lhs*, *rhs*) 使用自动广播计算 (lhs>=rhs)。 * **参数:** - * **lhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*):左操作数。 - * **rhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*):右操作数。 + * **lhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*):左操作数。 + * **rhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*):右操作数。 * **返回:ret**:如果两个操作数都是 Expr,则返回 Expr。否则返回 Tensor。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) or Expr。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) or Expr。 ## tvm.topi.hamming_window(*window_size*, *periodic*, *alpha*, *beta*, *dtype*) @@ -1129,27 +1129,27 @@ out[i][j][k] = data[i][j][indices[i][j][k]] # if axis == 2 * **alpha** ( *tvm.Expr* )**:** 系数 alpha。 * **beta**(*tvm.Expr*):系数 beta。 * **返回:ret**:结果张量。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.identity(*x*) 取输入 x 的恒等式。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) :输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) :输入参数。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.index_put(*data*, *indices*, *values*, *accumulate=False*) 根据索引将值放入数组中。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)要修改的源数组。 - * **indices** ( [Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)*[*[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*]* ):指定位置的 1D 索引张量的元组(每个维度一个)。 - * **值**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):放置在指定索引处的值。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)要修改的源数组。 + * **indices** ( [Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)*[*[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*]* ):指定位置的 1D 索引张量的元组(每个维度一个)。 + * **值**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):放置在指定索引处的值。 * **累积**([bool](https://docs.python.org/3/library/functions.html#bool)*,可选*):是否累积(添加)值而不是替换。如果为 True,则执行 tensor[indices] += values;如果为 False,则执行 tensor[indices] = values。默认值为 False。 * **返回:ret。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.index_tensor(*data*, *indices*) @@ -1163,10 +1163,10 @@ out[i][j][k] = data[i][j][indices[i][j][k]] # if axis == 2 * 结果形状是(即广播形状后跟未索引的其余轴*)* 。`B + data.shape[k:]``data` * `k`不能超过`data.ndim`;否则会引发编译时错误。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):要索引的张量。 - * *indices*( *Sequence[*[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*]* ):一个包含 k 个索引的 Python`list`张**量**`tuple`,或一个 tvm.te.Tensor 元组表达式。每个张量必须具有整数数据类型。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):要索引的张量。 + * *indices*( *Sequence[*[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*]* ):一个包含 k 个索引的 Python`list`张**量**`tuple`,或一个 tvm.te.Tensor 元组表达式。每个张量必须具有整数数据类型。 * **返回:result**:高级索引后得到的张量。其 dtype 等于 `data.dtype`。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 **示例** @@ -1188,136 +1188,136 @@ z = topi.index_tensor(x, [row, col]) # 形状 (2, 3) 检查 x 的值是否是有限的、元素有限的。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) :输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) :输入参数。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.isinf(*x*) 检查 x 的值是否为无限的(按元素)。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) :输入参数。 -* **返回:y** [:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) :输入参数。 +* **返回:y** [:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)结果。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.isnan(*x*) 逐个元素检查 x 的值是否为 NaN。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) **:** 输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) **:** 输入参数。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.layout_transform(*array*, *src_layout*, *dst_layout*, *schedule_rule='None'*) 根据 src_layout 和 dst_layout 转换布局。 * **参数:** - * **array**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):源数组。 + * **array**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):源数组。 * **src_layout** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ):源布局。 * **dst_layout** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ):目标布局。 - * **Schedule_rule** ( [str](https://docs.python.org/3/library/stdtypes.html#str) )[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)适用的调度规则(如果有)。 + * **Schedule_rule** ( [str](https://docs.python.org/3/library/stdtypes.html#str) )[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)适用的调度规则(如果有)。 ## tvm.topi.left_shift(*lhs*, *rhs*) 左移并自动广播。 * **参数:** - * **lhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*)**:** 左操作数。 - * **rhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*):右操作数。 + * **lhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*)**:** 左操作数。 + * **rhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*):右操作数。 * **返回:ret**:如果两个操作数都是 Expr,则返回 Expr。否则返回 Tensor。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) or Expr。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) or Expr。 ## tvm.topi.less(*lhs*, *rhs*) 使用自动广播计算 (lhs x 深度 x <索引内维度>。 * **参数:** - * **indices**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 设置为 on_value 的位置。 - * **on_value**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):填充索引的值。 - * **off_value**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):除了索引之外的所有其他位置填充的值。 + * **indices**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 设置为 on_value 的位置。 + * **on_value**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):填充索引的值。 + * **off_value**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):除了索引之外的所有其他位置填充的值。 * **深度**([int](https://docs.python.org/3/library/functions.html#int)):独热维度的深度。 * **axis**([int](https://docs.python.org/3/library/functions.html#int)):要填充的轴。 * **dtype**([str](https://docs.python.org/3/library/stdtypes.html#str)):输出张量的数据类型。 * **返回:ret**:独热张量。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 **示例** @@ -1512,92 +1512,92 @@ topi.one_hot(indices, 3) = 自动广播幂方。 * **参数:** - * **lhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*):左操作数。 - * **rhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*):右操作数。 + * **lhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*):左操作数。 + * **rhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*):右操作数。 * **返回:ret**:如果两个操作数都是 Expr,则返回 Expr。否则返回 Tensor。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) or Expr。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) or Expr。 ## tvm.topi.prod(*data*, *axis=None*, *keepdims=False*) 给定轴或轴列表上的数组元素的乘积。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入 tvm 张量。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入 tvm 张量。 * **axis**(*None、*[int](https://docs.python.org/3/library/functions.html#int)*或*[int 元](https://docs.python.org/3/library/functions.html#int)*组*[)](https://docs.python.org/3/library/stdtypes.html#tuple)**:** 执行 prod 操作的轴。默认值 axis=None 表示将获取输入数组所有元素上的 prod 元素。如果 axis 为负数,则从最后一个轴计数到第一个轴。 * **keepdims** ( [bool](https://docs.python.org/3/library/functions.html#bool) ):如果设置为 True,则缩小的轴将保留在结果中,作为大小为 1 的维度。使用此选项,结果将根据输入数组正确广播。 * **返回:ret。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.reinterpret(*x*, *dtype*) 将输入重新解释为指定的数据类型。 * **参数:** - * **x**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入参数。 + * **x**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入参数。 * **dtype**([str](https://docs.python.org/3/library/stdtypes.html#str)):数据类型。 -* **返回:y** [:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回:y** [:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)结果。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.repeat(*a*, *repeats*, *axis*) 重复数组的元素。 * **参数:** - * **a**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 要重复的张量。 + * **a**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 要重复的张量。 * **repeats**([int](https://docs.python.org/3/library/functions.html#int)*,必需*):每个元素的重复次数。 * **axis**([int](https://docs.python.org/3/library/functions.html#int)*,可选*):重复值的轴。 * **返回:ret。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.reshape(*a*, *newshape*) 重塑数组。 * **参数:** - * **a** ( [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) ):需要重塑的张量。 + * **a** ( [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ):需要重塑的张量。 * **newshape**(*整数元组*[)](https://docs.python.org/3/library/stdtypes.html#tuple):新形状。 * **返回:ret。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.reverse_sequence(*a*, *seq_lengths*, *seq_axis=1*, *batch_axis=0*) 将张量反转为可变长度切片。输入首先沿批处理轴进行切片,然后沿序列轴反转元素。 * **参数:** - * **a**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):要反转的张量。 - * **seq_lengths** ( [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) )[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)长度为 a.dims[batch_axis] 的一维张量,必须是以下类型之一:int32、int64,如果 seq_lengths[i] > a.dims[seq_axis],则四舍五入为 a.dims[seq_axis],如果 seq_lengths[i] < 1,则四舍五入为 1。 + * **a**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):要反转的张量。 + * **seq_lengths** ( [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) )[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)长度为 a.dims[batch_axis] 的一维张量,必须是以下类型之一:int32、int64,如果 seq_lengths[i] > a.dims[seq_axis],则四舍五入为 a.dims[seq_axis],如果 seq_lengths[i] < 1,则四舍五入为 1。 * **seq_axis**([int](https://docs.python.org/3/library/functions.html#int)*,可选*):元素反转的轴。默认值为 1。 * **batch_axis**([int](https://docs.python.org/3/library/functions.html#int)*,可选*)*:* 张量切片的轴。默认值为 0。 * **返回:ret**:与输入具有相同形状和类型的计算结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.right_shift(*lhs*, *rhs*) 右移并自动广播。 * **参数:** - * **lhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*):左操作数。 - * **rhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*)[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)右操作数。 + * **lhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*):左操作数。 + * **rhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*)[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)右操作数。 * **返回:ret**:如果两个操作数都是 Expr,则返回 Expr。否则返回 Tensor。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) or Expr。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) or Expr。 ## tvm.topi.round(*x*) 将 x 的元素四舍五入为最接近的整数。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) :输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) :输入参数。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.rsqrt(*x*) 取输入 x 的平方根的倒数。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) :输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) :输入参数。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 -## tvm.topi.scanop(*data:*[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor), *binop:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*[[tvm.Expr, tvm.Expr], tvm.Expr]*, *identity_value: tvm.Expr*, *op_name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *exclusive:*[bool](https://docs.python.org/3/library/functions.html#bool)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) +## tvm.topi.scanop(*data:*[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor), *binop:*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*[[tvm.Expr, tvm.Expr], tvm.Expr]*, *identity_value: tvm.Expr*, *op_name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *exclusive:*[bool](https://docs.python.org/3/library/functions.html#bool)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) 累积二元运算符(扫描),其轴行为与 np.cumsum 和 np.cumprod 类似。 @@ -1608,14 +1608,14 @@ topi.one_hot(indices, 3) = 例如,如果 * 是二元运算符,输入张量为 [1, 2, 3, 4],则输出可能是 [1, 1 * 2, 1 * 2 * 3, 1 * 2 * 3 * 4] * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):运算符的输入数据。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):运算符的输入数据。 * *binop* ( *Callable(tvm.Expr,tvm.Expr)–> tvm.Expr* ):一个二元运算符,它必须满足结合律和交换律。例如,如果你的运算符是 * ,那么 a * (b * c) = (a * b) * c ,并且 a * b = b * a * **身份值**( *tvm.Expr* ):提供身份属性的二元运算值。例如,如果 * 是运算符,i 是身份值,那么对于运算域中的所有 a,a * i = a。 * **axis**([int](https://docs.python.org/3/library/functions.html#int)*,可选*):计算操作所沿的轴。默认值(无)是计算展平数组上的累积运算。 * *dtype**(*string*,*可选*):返回数组的类型,以及用于计算元素的累加器的类型。如果未指定 dtype,则默认为 data 的 dtype。 * **exclusive** ([bool](https://docs.python.org/3/library/functions.html#bool)*,可选*):如果为 True,则返回独占累积运算,其中不包含第一个元素。换句话说,如果为 True,则第 j 个输出元素将是前 (j–1) 个元素的累积运算。否则,它将是前 j 个元素的累积运算。零个元素的累积运算被假定为身份值。 * **返回:result**:如果 axis 不为 None,则结果的大小与数据相同,形状也与数据相同。如果 axis 为 None,则结果为一维数组。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.scatter_elements(*data*, *indices*, *updates*, *axis=0*, *reduction='update'*) @@ -1633,13 +1633,13 @@ output[i][indices[i][j]] = f(output[i][indices[i][j]], updates[i][j]) if axis = 其中更新函数 f 由约简确定。该函数支持五种类型:“update”、“add”、“mul”、“min”和“max”(见下文) * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):源数组。 - * **indices**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):要提取的值的索引。 - * **更新**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):应用于索引的更新。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):源数组。 + * **indices**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):要提取的值的索引。 + * **更新**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):应用于索引的更新。 * *axis**(*可选**,[int](https://docs.python.org/3/library/functions.html#int)):散点图的轴。默认值为零。 * r*eduction**(*可选**,*字符串*):算法的更新模式,可以是“update”,“add”,“mul”,“min”或“max”。如果是更新,更新值将替换输入数据。如果是添加,更新值将添加到输入数据中。如果是 mul,输入数据将乘以更新值。如果是平均值,输入数据将是更新值和输入数据之间的平均值。如果是最小值,则可以在更新值和输入数据之间选择最小值。如果是最大值,则可以在更新值和输入数据之间选择最大值。默认情况下为「更新」。 * **返回:ret。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.scatter_nd(*data*, *indices*, *updates*, *mode*) @@ -1662,12 +1662,12 @@ output[indices[0, y_0, ..., y_{K-1}], 其中更新函数 f 由模式决定。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 源数组。 - * **indices**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):要提取的值的索引。 - * **更新**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))*:* 应用于索引的更新。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 源数组。 + * **indices**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):要提取的值的索引。 + * **更新**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))*:* 应用于索引的更新。 * **mode**(*字符串*)*:* 算法的更新模式,可以是“更新”或“添加”。如果是更新,则更新值将替换输入数据。如果是添加,则更新值将添加到输入数据中。 * **返回:ret。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.searchsorted(*sorted_sequence*, *values*, *right=False*, *out_dtype='int64'*) @@ -1677,12 +1677,12 @@ output[indices[0, y_0, ..., y_{K-1}], 如果 sorted_sequence 是 N 维的,则 在 sorted_sequence 的相应维度中搜索值的最内层维度。 * **参数:** - * **sorted_sequence**([te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):ND 或 1–D 张量,包含最内层维度上的单调递增序列。 - * **values** ( [te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) ):包含搜索值的 ND 张量。当 sorted_sequence 为一维时, values 的形状可以是任意的。否则,sorted_sequence 和 values 的秩必须相同,且外 N–1 个轴的大小必须相同。 + * **sorted_sequence**([te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):ND 或 1–D 张量,包含最内层维度上的单调递增序列。 + * **values** ( [te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ):包含搜索值的 ND 张量。当 sorted_sequence 为一维时, values 的形状可以是任意的。否则,sorted_sequence 和 values 的秩必须相同,且外 N–1 个轴的大小必须相同。 * **right**([bool](https://docs.python.org/3/library/functions.html#bool)*,可选*)**:** 控制当值恰好位于已排序值之一时返回哪个索引。如果为 False,则返回找到的第一个合适位置的索引。如果为 True,则返回最后一个合适的索引。如果没有合适的索引,则返回 0 或 N(其中 N 是最内层维度的大小)。 * dtype(*字符串*,可选)*:* 输出索引的数据类型。 * **返回:indices**:与值具有相同形状的张量,表示如果值元素插入 sorted_sequence 中则它们的索引。 -* **返回类型:**[te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.sequence_mask(*data*, *valid_length*, *mask_value=0*, *axis=0*) @@ -1698,92 +1698,92 @@ axis 表示长度维度的轴,只能为 0 或 1。如果 axis 为 0,则数 valid_length 给出每个序列的长度。valid_length 应该是一个包含正整数的一维 int 数组,维度为 [batch_size,] 。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):根据轴的值,具有形状[MAX_LENGTH,batch_size,…]或[batch_size,MAX_LENGTH,…]的 ND 。 - * **valid_length**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):一维,形状为[batch_size,]。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):根据轴的值,具有形状[MAX_LENGTH,batch_size,…]或[batch_size,MAX_LENGTH,…]的 ND 。 + * **valid_length**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):一维,形状为[batch_size,]。 * **mask_value**([float](https://docs.python.org/3/library/functions.html#float)*,可选*):掩蔽值,默认为 0。 * **axis**([int](https://docs.python.org/3/library/functions.html#int)*,可选*):长度维度的轴,必须为 0 或 1,默认为 0。 * **返回:output**:ND,形状为 [MAX_LENGTH, batch_size, …] 或 [batch_size, MAX_LENGTH, …],具体取决于轴的值。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.shape(*array*, *dtype='int32'*) 获取输入数组的形状 * **参数:** - * **数组**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 源张量。 + * **数组**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 源张量。 * **dtype**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*):目标数据类型。 * **返回:result**:结果张量。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.sigmoid(*x*) 对输入 x 进行 S 型 tanh 运算。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) *:* 输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) *:* 输入参数。 * **返回:y** *:* 结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.sign(*x*) 根据 x 的符号返回 -1、0、1。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) :输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) :输入参数。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.sin(*x*) 对输入 x 取正弦值。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) :输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) :输入参数。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.sinh(*x*) 对输入 x 取 sinh。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) :输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) :输入参数。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.slice_scatter(*input_tensor*, *src*, *start*, *end*, *step*, *axis*) 将 src 的切片沿给定轴(SSA 形式)分散到输入中。 * **参数:** - * **input_tensor**([te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):要散射的输入张量。 - * **src**([te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):要散射的源张量。 + * **input_tensor**([te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):要散射的输入张量。 + * **src**([te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):要散射的源张量。 * **start**([int](https://docs.python.org/3/library/functions.html#int))*:* 切片的起始索引。 * **end**([int](https://docs.python.org/3/library/functions.html#int)):切片的结束索引。 * **step**([int](https://docs.python.org/3/library/functions.html#int)):切片的步长。 * **axis**([int](https://docs.python.org/3/library/functions.html#int)):散布的轴。 * **返回:** 包含切片分散的输出张量的列表。 -* **返回类型:**[list](https://docs.python.org/3/library/stdtypes.html#list)[[te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)]。 +* **返回类型:**[list](https://docs.python.org/3/library/stdtypes.html#list)[[te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)]。 ## tvm.topi.sliding_window(*data*, *axis*, *window_shape*, *strides*) 在数据张量上滑动一个窗口。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):运算符的输入数据。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):运算符的输入数据。 * **axis** ( [int](https://docs.python.org/3/library/functions.html#int) )*:* 窗口开始滑动的轴。窗口将在此轴及其所有后续轴上滑动。axis 值决定了窗口的形状(从而决定了步长):窗口形状和步长的长度都必须为 data.ndim–axis。 * *window_shape* ( *List[*[int](https://docs.python.org/3/library/functions.html#int)*]* )**:** 在输入上形成的窗口形状。窗口形状的长度必须为 data.ndim–axis。 * *strides* ( *List[*[int](https://docs.python.org/3/library/functions.html#int)*]* )*:* 如何沿每个维度移动窗口。步幅必须为 data.ndim–axis 的长度。 * **返回:result**:结果张量。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.sort(*data*, *axis=-1*, *is_ascend=1*) 沿给定轴执行排序并按排序顺序返回数组。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入张量。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入张量。 * **axis**([int](https://docs.python.org/3/library/functions.html#int)*,可选*)*:* 对输入张量进行排序的轴。默认情况下使用扁平数组。 * *is_ascend*(*布尔值*,*可选*)*:* 按升序还是降序排序。 * *dtype*(*字符串*,*可选*):输出索引的 DType。 * **返回:out**:排序索引张量。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.sparse_reshape(*sparse_indices*, *prev_shape*, *new_shape*, *new_sparse_indices_shape*, *new_shape_shape*) @@ -1824,58 +1824,58 @@ new_shape = [9, 4] 示例:: - sparse_to_dense([[0, 0], [1, 1]], [2, 2], [3, 3], 0) = [[3, 0], [0, 3]]。 * **参数:** - * **sparse_indices**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):包含稀疏值位置的 0–D、1–D 或 2–D 整数张量。 + * **sparse_indices**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):包含稀疏值位置的 0–D、1–D 或 2–D 整数张量。 * **output_shape**(*整数列表*):密集输出张量的形状 *。* - * **sparse_values**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):包含稀疏索引的稀疏值的 0–D 或 1–D 张量。 - * **default_value**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):一个 0 维张量,包含剩余位置的默认值。默认为 0。 + * **sparse_values**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):包含稀疏索引的稀疏值的 0–D 或 1–D 张量。 + * **default_value**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):一个 0 维张量,包含剩余位置的默认值。默认为 0。 * **返回:result** :形状为 output_shape 的稠密张量。类型与 sparse_values 相同。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.split(*ary*, *indices_or_sections*, *axis=0*) 将数组拆分为多个子数组。 * **参数:** - * **ary** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))。 + * **ary** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))。 * **indices_or_sections** ([int](https://docs.python.org/3/library/functions.html#int)*or1-D array*)。 * **axis** ([int](https://docs.python.org/3/library/functions.html#int))。 * **返回:ret。** -* **返回类型:**[tuple](https://docs.python.org/3/library/stdtypes.html#tuple) of [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tuple](https://docs.python.org/3/library/stdtypes.html#tuple) of [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.sqrt(*x*) 对输入 x 取平方根。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) :输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) :输入参数。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.squeeze(*a*, *axis=None*) 从数组形状中删除一维条目。 * **参数:** - * **a** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))。 - * **axis** (*Noneor*[int](https://docs.python.org/3/library/functions.html#int)*or*[tuple](https://docs.python.org/3/library/stdtypes.html#tuple)*ofints,optional*)[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) axis(*None*、***[int](https://docs.python.org/3/library/functions.html#int)***或***int 元**组*[,](https://docs.python.org/3/library/stdtypes.html#tuple)***可选*** *)*:选择形状中单维条目的子集。如果所选轴的形状条目数大于 1,则会引发错误。 + * **a** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))。 + * **axis** (*Noneor*[int](https://docs.python.org/3/library/functions.html#int)*or*[tuple](https://docs.python.org/3/library/stdtypes.html#tuple)*ofints,optional*)[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) axis(*None*、***[int](https://docs.python.org/3/library/functions.html#int)***或***int 元**组*[,](https://docs.python.org/3/library/stdtypes.html#tuple)***可选*** *)*:选择形状中单维条目的子集。如果所选轴的形状条目数大于 1,则会引发错误。 * **返回:squeezed。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.stack(*tensors*, *axis=0*) 沿新轴连接一系列张量。 * **参数:** - * **张量**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*的*[元组](https://docs.python.org/3/library/stdtypes.html#tuple)*或*[列表](https://docs.python.org/3/library/stdtypes.html#list))*:* 需要堆叠的张量。所有张量必须具有相同的形状。 + * **张量**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*的*[元组](https://docs.python.org/3/library/stdtypes.html#tuple)*或*[列表](https://docs.python.org/3/library/stdtypes.html#list))*:* 需要堆叠的张量。所有张量必须具有相同的形状。 * **axis**([int](https://docs.python.org/3/library/functions.html#int)*,可选*)*:* 输入张量将沿着结果张量的轴进行堆叠。负值表示环绕。默认值为 0。 * **返回:ret**:与输入张量相比具有额外维度的堆叠张量。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.stft(*data*, *n_fft*, *hop_length*, *win_length*, *window*, *normalized*, *onesided*, *output_shape*) STFT 计算输入短重叠窗口的傅里叶变换。这给出了信号随时间变化的频率分量。:param data: 一维张量或二维批量张量。:type data: te.Tensor :param n_fft: 傅里叶变换的大小 :type n_fft: int :param hop_length: 相邻滑动窗口帧之间的距离 :type hop_length: int :param win_length: 窗口帧和 STFT 滤波器的大小 :type win_length: int :param window: 一维张量窗口帧 :type window: te.Tensor :param normalized: 是否返回归一化的 STFT 结果 :type normalized: bool :param onesided: 是否返回单侧结果或使用共轭对称性填充 :type onesided: bool。 * **返回:output**:包含 STFT 结果的张量。 -* **返回类型:**[te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 **示例** @@ -1892,20 +1892,20 @@ topi.stft(data, n_fft, hop_length, win_length, window, normalized, onesided) 设置数组的切片。 * **参数:** - * **a**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 要切片的张量。 - * **v**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):要设置的值。 - * **begin**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):切片中开始的索引。 - * **end**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))*:* 指示切片结束的索引。 - * **strides**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*,可选*):指定步幅值,在这种情况下可以为负数,输入张量将在该特定轴上反转。 + * **a**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 要切片的张量。 + * **v**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):要设置的值。 + * **begin**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):切片中开始的索引。 + * **end**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))*:* 指示切片结束的索引。 + * **strides**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*,可选*):指定步幅值,在这种情况下可以为负数,输入张量将在该特定轴上反转。 * **返回:ret。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.strided_slice(*a*, *begin*, *end*, *strides=None*, *axes=None*, *slice_mode='end'*, *assume_inbound=True*) 数组的切片。 * **参数:** - * **a**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):要切片的张量。 + * **a**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):要切片的张量。 * **begin**(*int*[列表](https://docs.python.org/3/library/stdtypes.html#list)):切片中开始的索引[。](https://docs.python.org/3/library/functions.html#int) * **end**(*int*[列表](https://docs.python.org/3/library/stdtypes.html#list)):指示切片结束的索引[。](https://docs.python.org/3/library/functions.html#int) * **strides**(*整数*[列表](https://docs.python.org/3/library/stdtypes.html#list)*,可选):指定*[步幅](https://docs.python.org/3/library/functions.html#int)值,在这种情况下可以为负数,输入张量将在该特定轴上反转。 @@ -1913,57 +1913,57 @@ topi.stft(data, n_fft, hop_length, win_length, window, normalized, onesided) * **slice_mode**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*)**:** 切片模式 [end, size]。end*:*切片的结束索引 [默认]。size:输入的步幅将被忽略,此模式下的输入 end 表示从 begin 指定位置开始的切片大小。如果 end[i] 为 –1,则该维度上的所有剩余元素都将包含在切片中。 * **假设_inbound** ( [bool](https://docs.python.org/3/library/functions.html#bool)*,可选*):一个标志,指示是否假定所有索引都是入站的。 * **返回:ret。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.subtract(*lhs*, *rhs*) 自动广播减法。 * **参数:** - * **lhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*):左操作数。 - * **rhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*):右操作数。 + * **lhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*):左操作数。 + * **rhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*):右操作数。 * **返回:ret**:如果两个操作数都是 Expr,则返回 Expr。否则返回 Tensor。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) or Expr。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) or Expr。 ## tvm.topi.sum(*data*, *axis=None*, *keepdims=False*) 给定轴或轴列表上的数组元素的总和。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 输入 tvm 张量。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 输入 tvm 张量。 * **axis**(*None、*[int](https://docs.python.org/3/library/functions.html#int)*或*[int 元](https://docs.python.org/3/library/functions.html#int)*组*[)](https://docs.python.org/3/library/stdtypes.html#tuple):执行求和的轴。默认值 axis=None,将对输入数组的所有元素求和。如果 axis 为负数,则从最后一个轴开始计数到第一个轴。 * **keepdims** ( [bool](https://docs.python.org/3/library/functions.html#bool) ):如果设置为 True,则缩小的轴将保留在结果中,作为大小为 1 的维度。使用此选项,结果将根据输入数组正确广播。 * **返回:ret。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.take(*a*, *indices*, *axis=None*, *batch_dims=0*, *mode='fast'*) 沿轴从数组中获取元素。 * **参数:** - * **a**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):源数组。 - * **indices**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):要提取的值的索引。 + * **a**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):源数组。 + * **indices**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):要提取的值的索引。 * **axis**([int](https://docs.python.org/3/library/functions.html#int)*,可选*)**:** 用于选择值的轴。默认情况下,使用扁平化的输入数组。 * **batch_dims**([int](https://docs.python.org/3/library/functions.html#int)):批次维度的数量。默认情况下为 0。 * **mode**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*):指定超出范围的索引将如何表现。*:* fast(默认):额外的索引会导致段错误(用户必须确保索引在范围内):nan:为超出范围的索引生成 NaN:wrap:环绕索引:clip:剪辑到范围内。 * **返回:ret。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.tan(*x*) 对输入 x 取 tan。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) [:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) [:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)输入参数。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.tanh(*x*) 对输入 x 取双曲 tanh。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) :输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) :输入参数。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.tensordot(*a*, *b*, *axes*) @@ -1981,45 +1981,45 @@ topi.stft(data, n_fft, hop_length, win_length, window, normalized, onesided) 重复整个数组多次。 * **参数:** - * **a**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)要平铺的张量。 + * **a**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)要平铺的张量。 * *reps([整数](https://docs.python.org/3/library/stdtypes.html#tuple)元组,* 必需):重复张量的次数。 * **返回:ret。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.topk(*data*, *k=1*, *axis=-1*, *ret_type='both'*, *is_ascend=False*, *dtype='int64'*) 获取输入张量中沿给定轴的前 k 个元素。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入张量。 - * **k**([int](https://docs.python.org/3/library/functions.html#int)*或*[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*,可选*):待选元素的数量。如果 k < 1,则返回所有元素。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入张量。 + * **k**([int](https://docs.python.org/3/library/functions.html#int)*或*[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*,可选*):待选元素的数量。如果 k < 1,则返回所有元素。 * **axis**([int](https://docs.python.org/3/library/functions.html#int)*,可选*):用于对输入张量进行排序的轴长。 * **ret_type**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*):返回类型 [both,values,indices]。“both”:返回前 k 个数据和索引。“values”:仅返回前 k 个数据。“indices”:仅返回前 k 个索引。 * *is_ascend*(*布尔值*,*可选*):按升序还是降序排序。 - * *dtype*(*字符串**,*可选*)[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)索引输出的数据类型。 + * *dtype*(*字符串**,*可选*)[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)索引输出的数据类型。 * **返回:out** **:** 计算结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) or List[[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)]。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) or List[[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)]。 ## tvm.topi.transpose(*a*, *axes=None*) 排列数组的维度。 * **参数:** - * **a**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):要扩展的张量。 + * **a**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):要扩展的张量。 * *轴*(*整数*元[组](https://docs.python.org/3/library/stdtypes.html#tuple),可选):默认情况下,反转尺寸。 * **返回:ret。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.trilu(*data*, *k*, *upper*) 给定一个二维矩阵或一批二维矩阵,返回张量的上三角或下三角部分。 * **参数:** - * **data** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) [:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) **data** ( [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) ):trilu 将应用到的张量。必须是二维矩阵或由二维矩阵批次组成的张量。 - * **k** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) [:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) **k**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):要排除或包含的主对角线上方或下方的对角线数量。 + * **data** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) [:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) **data** ( [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ):trilu 将应用到的张量。必须是二维矩阵或由二维矩阵批次组成的张量。 + * **k** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) [:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) **k**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):要排除或包含的主对角线上方或下方的对角线数量。 * **upper** ([bool](https://docs.python.org/3/library/functions.html#bool)) [:](https://docs.python.org/3/library/functions.html#bool) **upper** ( [bool](https://docs.python.org/3/library/functions.html#bool) ):如果为 True,则仅保留输入的上三角值;如果为 False,则保留下三角值。 * **返回:ret** :将适当的对角线设置为零的新张量。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 **示例** @@ -2038,9 +2038,9 @@ topi.trilu(x, True, 0) = 逐个元素地取 x 输入的截断值。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) :输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) :输入参数。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.unravel_index(*indices*, *shape*) @@ -2050,21 +2050,21 @@ topi.trilu(x, True, 0) = 示例:: - unravel_index([22, 41, 37], [7, 6]) = [[3, 6, 6], [4, 5, 1]]。 * **参数:** - * **indices**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):包含索引的整数数组。 - * **shape**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 数组的形状。 + * **indices**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):包含索引的整数数组。 + * **shape**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 数组的形状。 * **返回:result** :坐标数组的元组。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.where(*condition*, *x*, *y*) 根据条件从 x 或 y 获取元素。 * **参数:** - * **条件**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):条件数组。 - * **x**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))*:* 要选择的第一个数组。 - * **y**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 要选择的第二个数组。 + * **条件**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):条件数组。 + * **x**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))*:* 要选择的第一个数组。 + * **y**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 要选择的第二个数组。 * **返回:result** :根据条件从 x 或 y 中选择的张量。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.within_index(*b*, *e*, *s*, *i*) @@ -2095,144 +2095,144 @@ topi.trilu(x, True, 0) = **类:** -|[Workload](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.Workload)(in_dtype,out_dtype,height,width,…)|| +|[Workload](/docs/api-reference/python-api/tvm-topi#class-tvmtopinnworkloadin_dtype-out_dtype-height-width-in_filter-out_filter-kernel_h-kernel_w-padt-padl-padb-padr-dilation_h-dilation_w-stride_h-stride_w)(in_dtype,out_dtype,height,width,…)|| |:----|:----| **函数:** -|[adaptive_pool](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.adaptive_pool)(data,output_size,pool_type)|对数据的高度和宽度维度进行池化。| +|[adaptive_pool](/docs/api-reference/python-api/tvm-topi#tvmtopinnadaptive_pooldata-output_size-pool_type-layoutnchw)(data,output_size,pool_type)|对数据的高度和宽度维度进行池化。| |:----|:----| -|[adaptive_pool1d](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.adaptive_pool1d)(data,output_size,pool_type)|对三维数据进行池化。详情请参阅上面的二维版本。| -|[adaptive_pool3d](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.adaptive_pool3d)(data,output_size,pool_type)|对三维数据进行池化。详情请参阅上面的二维版本。| -|[add](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.add)(lhs,rhs)|自动广播附加功能。| -|[batch_matmul](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.batch_matmul)(tensor_a,tensor_b[,oshape,…])|计算 tensor_a 和 tensor_b 的批量矩阵乘法。| -|[batch_norm](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.batch_norm)(data,gamma,beta,moving_mean,…)|批量标准化层(Ioffe 和 Szegedy,2014)。| -|[batch_to_space_nd](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.batch_to_space_nd)(data,block_shape,…)|对数据执行空间到批量的转换。| -|[binarize_pack](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.binarize_pack)(data[,axis,name])|沿某个轴进行二值化和位打包。| -|[binary_dense](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.binary_dense)(data,weight)|使用异或和位计数进行二进制矩阵乘法。| -|[bitpack](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.bitpack)(data,bits,pack_axis,bit_axis,…)|将数据打包成位串行计算所需的格式。| -|[bitserial_conv2d_nchw](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.bitserial_conv2d_nchw)(data,kernel,stride,…)|Bitserial Conv2D 运算符。| -|[bitserial_conv2d_nhwc](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.bitserial_conv2d_nhwc)(data,kernel,stride,…)|Bitserial Conv2D 运算符。| -|[bitserial_dense](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.bitserial_dense)(data,weight,data_bits,…)|topi 中位串行密集的默认实现。| -|[circular_pad](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.circular_pad)(data,pad_before[,pad_after,name])|对输入张量应用圆形填充(环绕)。| -|[concatenate](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.concatenate)(a_tuple[,axis])|沿现有轴连接一系列数组。| -|[conv](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv)(inp,filt,stride,padding,dilation,…)|NCHW 或 NHWC 布局中的卷积操作符。| -|[conv1d](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv1d)(data,kernel[,strides,padding,…])|1D 卷积前向操作符。| -|[conv1d_ncw](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv1d_ncw)(data,kernel[,strides,padding,…])|NCW 布局中的一维卷积。[conv()](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv)有关参数的详细信息,请参阅。| -|[conv1d_nwc](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv1d_nwc)(data,kernel[,strides,padding,…])|NWC 布局中的一维卷积。[conv()](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv)有关参数的详细信息,请参阅。| -|[conv1d_transpose_ncw](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv1d_transpose_ncw)(data,kernel,stride,…)|转置的一维卷积 ncw 前向操作符。| -|[conv2d](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv2d)(input,filter,strides,padding,dilation)|Conv2D 运算符。| -|[conv2d_NCHWc](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv2d_NCHWc)(data,kernel,stride,padding,…)|nChw[x]c 布局的 Conv2D 运算符。| -|[conv2d_NCHWc_int8](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv2d_NCHWc_int8)(data,kernel,stride,…)|nChw[x]c 布局的 Conv2D 运算符。| -|[conv2d_hwcn](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv2d_hwcn)(Input,Filter,stride,padding,…)|HWCN 布局中的卷积操作符。| -|[conv2d_nchw](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv2d_nchw)(Input,Filter,stride,padding,…)|NCHW 布局中的卷积操作符。| -|[conv2d_nhwc](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv2d_nhwc)(Input,Filter,stride,padding,…)|NHWC 布局中的卷积操作符。| -|[conv2d_transpose_nchw](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv2d_transpose_nchw)(Input,Filter,…)|转置的二维卷积 nchw 前向操作符。| -|[conv2d_transpose_nchw_preprocess](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv2d_transpose_nchw_preprocess)(data,…)|预处理数据和内核,使 conv2d_transpose 的计算模式与 conv2d 相同。| -|[conv2d_winograd_nchw](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv2d_winograd_nchw)(data,weight,strides,…)|NCHW 布局中的 Conv2D Winograd。这是一个干净的版本,可供 CPU 和 GPU 的自动调度程序使用。| -|[conv2d_winograd_nchw_without_weight_transform](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv2d_winograd_nchw_without_weight_transform)(…)|在 NCHW 布局中,Conv2D Winograd 无需布局变换。这是一个可供 CPU 和 GPU 元调度使用的干净版本。| -|[conv2d_winograd_nhwc](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv2d_winograd_nhwc)(data,weight,strides,…)|NHWC 布局中的 Conv2D Winograd。这是一个干净的版本,可供 CPU 和 GPU 的自动调度程序使用。| -|[conv2d_winograd_nhwc_without_weight_transform](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv2d_winograd_nhwc_without_weight_transform)(…)|Conv2D Winograd 在 NHWC 布局中无需布局变换。这是一个干净的版本,可供 CPU 和 GPU 自动调度程序使用。| -|[conv2d_winograd_weight_transform](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv2d_winograd_weight_transform)(kernel,…)|winograd 的权重转换。| -|[conv3d_ncdhw](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv3d_ncdhw)(Input,Filter,stride,padding,…)|NCDHW 布局中的 Conv3D 运算符。| -|[conv3d_ndhwc](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv3d_ndhwc)(Input,Filter,stride,padding,…)|NDHWC 布局中的卷积操作符。| -|[conv3d_transpose_ncdhw](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv3d_transpose_ncdhw)(Input,Filter,…)|转置的3D 卷积 ncdhw 前向操作符。| -|[conv3d_transpose_ncdhw_preprocess](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv3d_transpose_ncdhw_preprocess)(data,…)|预处理数据和内核,使 conv3d_transpose 的计算模式与 conv3d 相同。| -|[conv3d_winograd_weight_transform](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv3d_winograd_weight_transform)(kernel,…)|3D winograd 的权重变换。| -|[correlation_nchw](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.correlation_nchw)(data1,data2,kernel_size,…)|NCHW 布局中的相关运算符。| -|[declaration_conv2d_transpose_impl](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.declaration_conv2d_transpose_impl)(data,…)|conv2d 转置的实现。| -|[declaration_conv3d_transpose_impl](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.declaration_conv3d_transpose_impl)(data,…)|conv3d 转置的实现。| -|[deformable_conv2d_nchw](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.deformable_conv2d_nchw)(data,offset,kernel,…)|NCHW 布局中的可变形 conv2D 运算符。| -|[deformable_conv2d_nhwc](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.deformable_conv2d_nhwc)(data,offset,kernel,…)|NHWC 布局中的可变形 conv2D 运算符。| -|[dense](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.dense)(data,weight[,bias,out_dtype,…])|topi 中致密的默认实现。这是 matmul_nt 运算符的别名,用于非转置格式的数据张量和转置格式的权重张量。| -|[dense_pack](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.dense_pack)(data,weight[,bias,out_dtype])|topi 中 dense_pack 的默认实现。| -|[depth_to_space](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.depth_to_space)(data,block_size[,layout,mode])|对数据进行深度到空间的变换。| -|[depthwise_conv2d_NCHWc](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.depthwise_conv2d_NCHWc)(Input,Filter,…[,…])|深度卷积 NCHW[x]c 前向操作符。| -|[depthwise_conv2d_backward_input_nhwc](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.depthwise_conv2d_backward_input_nhwc)(Filter,…)|深度卷积 nhwc 后向 wrt 输入运算符。| -|[depthwise_conv2d_backward_weight_nhwc](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.depthwise_conv2d_backward_weight_nhwc)(Input,…)|深度卷积 nhwc 后向 wrt 权重运算符。| -|[depthwise_conv2d_nchw](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.depthwise_conv2d_nchw)(Input,Filter,stride,…)|深度卷积 nchw 前向操作符。| -|[depthwise_conv2d_nhwc](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.depthwise_conv2d_nhwc)(Input,Filter,stride,…)|深度卷积 nhwc 前向操作符。| -|[dilate](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.dilate)(data,strides[,dilation_value,name])|使用给定的扩张值(默认为 0)扩张数据。| -|[equal_const_int](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.equal_const_int)(expr,value)|如果 expr 等于 value,则返回。| -|[fast_softmax](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.fast_softmax)(x[,axis])|对数据执行 softmax 激活。使用近似值计算指数可以提高速度。| -|[fifo_buffer](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.fifo_buffer)(data,buffer,axis)|FIFO 缓冲区可在具有滑动窗口输入的 CNN 中实现计算重用。| -|[flatten](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.flatten)(data)|通过折叠较高维度将输入数组展平为二维数组。| -|[get_const_int](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.get_const_int)(expr)|验证 expr 是否为整数并获取常数值。| -|[get_const_tuple](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.get_const_tuple)(in_tuple)|验证输入元组是 IntImm 还是 Var,返回 int 或 Var 的元组。| -|[get_pad_tuple](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.get_pad_tuple)(padding,kernel)|获取 pad 选项的通用代码。| -|[get_pad_tuple1d](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.get_pad_tuple1d)(padding,kernel)|获取 pad 选项的通用代码。| -|[get_pad_tuple3d](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.get_pad_tuple3d)(padding,kernel)|获取 pad 选项的通用代码。| -|[get_pad_tuple_generic](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.get_pad_tuple_generic)(padding,kernel)|获取 pad 选项的通用代码。| -|[get_padded_shape](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.get_padded_shape)(data,pad_before[,pad_after])|应用填充后计算张量的输出形状。| -|[global_pool](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.global_pool)(data,pool_type[,layout])|对数据的高度和宽度维度进行全局池化。| -|[group_conv1d_ncw](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.group_conv1d_ncw)(data,kernel[,strides,…])|用于 NCW 布局的一维卷积前向操作符。| -|[group_conv1d_nwc](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.group_conv1d_nwc)(data,kernel[,strides,…])|用于 NWC 布局的一维卷积前向操作符。| -|[group_conv1d_transpose_ncw](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.group_conv1d_transpose_ncw)(data,kernel,…)|转置的一维组卷积 ncw 前向操作符。| -|[group_conv2d_nchw](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.group_conv2d_nchw)(Input,Filter,stride,…)|NCHW 布局中的组卷积操作符。| -|[group_conv2d_nhwc](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.group_conv2d_nhwc)(Input,Filter,stride,…)|NHWC 布局中的组卷积操作符。| -|[group_conv2d_transpose_nchw](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.group_conv2d_transpose_nchw)(data,kernel,…)|NCHW 布局中的组卷积操作符。| -|[group_conv3d_transpose_ncdhw](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.group_conv3d_transpose_ncdhw)(data,kernel,…)|转置组3D 卷积 ncdhw 前向操作符。| -|[if_then_else](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.if_then_else)(cond,t,f[,span])|条件选择表达式。| -|[leaky_relu](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.leaky_relu)(x,alpha)|取输入 x 的 leaky relu。| -|[log_softmax](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.log_softmax)(x[,axis])|对数据执行对数 softmax 激活| -|[lrn](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.lrn)(data,size[,axis,alpha,beta,bias])|对输入数据执行跨通道局部响应标准化。| -|[lstm](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.lstm)(Xs,Wi,Wh[,Bi,Bh,h_init,c_init,…])|使用 TE 扫描实现的通用 LSTM。| -|[matmul](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.matmul)(tensor_a,tensor_b[,bias,…])|topi 中 matmul 的默认实现。| -|[mirror_pad](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.mirror_pad)(data,pad_before[,pad_after,…])|具有对称或反射功能的镜像平板输入。| -|[namedtuple](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.namedtuple)(typename,field_names,*[,…])|返回具有命名字段的元组的新子类。| -|[nll_loss](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.nll_loss)(predictions,targets,weights,…)|输入数据的负对数似然损失。| -|[pad](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.pad)(data,pad_before[,pad_after,…])|使用 pad 值的 Pad 输入。| -|[pool1d](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.pool1d)(data,kernel,stride,dilation,…)|对数据的宽度维度进行池化。| -|[pool2d](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.pool2d)(data,kernel,stride,dilation,…)|对数据的高度和宽度维度进行池化。| -|[pool3d](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.pool3d)(data,kernel,stride,dilation,…)|对数据的深度、高度和宽度维度进行池化。| -|[pool_grad](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.pool_grad)(grads,data,kernel,stride,…)|池化在数据高度和宽度维度上的梯度。| -|[prelu](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.prelu)(x,slope[,axis])|PReLU。它接受两个参数:一个输入x和一个权重数组W ,并计算输出为 PReLU(x)y=x>0?x:W∗x, 在哪里∗是批次中每个样本的元素乘法。| -|[reduce](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.reduce)(function,sequence[,initial])|将一个包含两个参数的函数从左到右累加地应用于序列的项,从而将序列简化为单个值。例如,reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) 计算结果为 ((((1+2)+3)+4)+5)。如果指定了 initial,则在计算过程中将其放置在序列的项之前,并在序列为空时用作默认值。| -|[reflect_pad](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.reflect_pad)(data,pad_before[,pad_after,name])|将反射填充应用于输入张量。| -|[relu](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.relu)(x)|取输入 x 的 relu。| -|[replicate_pad](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.replicate_pad)(data,pad_before[,pad_after,…])|对输入张量应用重复填充(边缘填充)。| -|[scale_shift_nchw](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.scale_shift_nchw)(Input,Scale,Shift)|推理中的批量标准化运算符。| -|[scale_shift_nchwc](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.scale_shift_nchwc)(Input,Scale,Shift)|推理中的批量标准化运算符。| -|[scale_shift_nhwc](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.scale_shift_nhwc)(Input,Scale,Shift)|推理中的批量标准化运算符。| -|[simplify](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.simplify)(expr)|如果是 Expr 则化简表达式,如果是 int 则直接返回。| -|[simulated_dequantize](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.simulated_dequantize)(data,in_dtype[,…])|模拟 QNN 反量化运算符,可模拟 QNN 输出,而无需更改数据类型。与真正的 QNN 反量化相比,此运算符的优势在于,它允许动态选择数据类型,并且可以对每个通道、标量尺度和零点进行操作,而 QNN 反量化则需要在编译时修复这两者。| -|[simulated_quantize](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.simulated_quantize)(data,out_dtype[,…])|模拟 QNN 量化运算符,可模拟 QNN 输出,无需更改数据类型。与真正的 QNN 量化相比,此运算符的优势在于,它允许动态选择数据类型,并且可以对每个通道、标量尺度和零点进行操作,而 QNN 量化则要求在编译时固定这两个参数。| -|[softmax](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.softmax)(x[,axis])|对数据执行 softmax 激活。| -|[softmax_common](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.softmax_common)(x,axis,use_fast_exp)|softmax 和 fast_softmax 的共同部分。| -|[softplus](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.softplus)(x[,beta,threshold])|计算具有数值稳定性的输入 x 的 Softplus 激活。| -|[space_to_batch_nd](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.space_to_batch_nd)(data,block_shape,…[,…])|对数据执行批量到空间的转换。| -|[space_to_depth](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.space_to_depth)(data,block_size[,layout])|对数据执行空间到深度的转换。| -|[strided_slice](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.strided_slice)(a,begin,end[,strides,…])|数组的切片。| -|[unpack_NCHWc_to_nchw](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.unpack_NCHWc_to_nchw)(packed_out,out_dtype)|将 conv2d_NCHWc 输出从布局 NCHWc 解包为 NCHW。| -|[upsampling](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.upsampling)(data,scale_h,scale_w[,layout,…])|对数据执行上采样。| -|[upsampling3d](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.upsampling3d)(data,scale_d,scale_h,scale_w)|对数据执行上采样。| -|[winograd_transform_matrices](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.winograd_transform_matrices)(tile_size,…)|将 tile_size 的 A、B 和 G 变换矩阵计算为 tvm.Expr。| -|[instance_norm](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.instance_norm)(data,gamma,beta,…[,epsilon])|实例规范化运算符。| -|[layer_norm](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.layer_norm)(data,gamma,beta,axis[,epsilon])|层归一化运算符。它接受 fp16 和 fp32 作为输入数据类型。它会将输入转换为 fp32 来执行计算。输出将具有与输入相同的数据类型。| -|[group_norm](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.group_norm)(data,gamma,beta,num_groups,…)|组规范化运算符。它接受 fp16 和 fp32 作为输入数据类型。它会将输入转换为 fp32 来执行计算。输出将具有与输入相同的数据类型。| -|[rms_norm](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.rms_norm)(data,weight,axis[,epsilon])|均方根归一化运算符。输出将具有与输入相同的数据类型。| +|[adaptive_pool1d](/docs/api-reference/python-api/tvm-topi#tvmtopinnadaptive_pool1ddata-output_size-pool_type-layoutncw)(data,output_size,pool_type)|对三维数据进行池化。详情请参阅上面的二维版本。| +|[adaptive_pool3d](/docs/api-reference/python-api/tvm-topi#tvmtopinnadaptive_pool3ddata-output_size-pool_type-layoutncdhw)(data,output_size,pool_type)|对三维数据进行池化。详情请参阅上面的二维版本。| +|[add](/docs/api-reference/python-api/tvm-topi#tvmtopinnaddlhs-rhs)(lhs,rhs)|自动广播附加功能。| +|[batch_matmul](/docs/api-reference/python-api/tvm-topi#tvmtopinnbatch_matmultensor_a-tensor_b-oshapenone-out_dtypenone-transpose_afalse-transpose_btrue-auto_scheduler_rewritten_layout-meta_schedule_original_shapenone)(tensor_a,tensor_b[,oshape,…])|计算 tensor_a 和 tensor_b 的批量矩阵乘法。| +|[batch_norm](/docs/api-reference/python-api/tvm-topi#tvmtopinnbatch_normdatatensor-gammatensor-betatensor-moving_meantensor-moving_vartensor-axisintnone-none-epsilonfloatnone-none-centerboolnone-none-scaleboolnone-none-trainingboolnone-none-momentumfloatnone-none--listtensor)(data,gamma,beta,moving_mean,…)|批量标准化层(Ioffe 和 Szegedy,2014)。| +|[batch_to_space_nd](/docs/api-reference/python-api/tvm-topi#tvmtopinnbatch_to_space_nddata-block_shape-crop_begin_list-crop_end_list)(data,block_shape,…)|对数据执行空间到批量的转换。| +|[binarize_pack](/docs/api-reference/python-api/tvm-topi#tvmtopinnbinarize_packdata-axisnone-namepackedinput)(data[,axis,name])|沿某个轴进行二值化和位打包。| +|[binary_dense](/docs/api-reference/python-api/tvm-topi#tvmtopinnbinary_densedata-weight)(data,weight)|使用异或和位计数进行二进制矩阵乘法。| +|[bitpack](/docs/api-reference/python-api/tvm-topi#tvmtopinnbitpackdata-bits-pack_axis-bit_axis-pack_type-namequantizeinput)(data,bits,pack_axis,bit_axis,…)|将数据打包成位串行计算所需的格式。| +|[bitserial_conv2d_nchw](/docs/api-reference/python-api/tvm-topi#tvmtopinnbitserial_conv2d_nchwdata-kernel-stride-padding-activation_bits-weight_bits-pack_dtypeuint32-out_dtypeint16-unipolartrue)(data,kernel,stride,…)|Bitserial Conv2D 运算符。| +|[bitserial_conv2d_nhwc](/docs/api-reference/python-api/tvm-topi#tvmtopinnbitserial_conv2d_nhwcdata-kernel-stride-padding-activation_bits-weight_bits-pack_dtypeuint32-out_dtypeint16-unipolartrue)(data,kernel,stride,…)|Bitserial Conv2D 运算符。| +|[bitserial_dense](/docs/api-reference/python-api/tvm-topi#tvmtopinnbitserial_densedata-weight-data_bits-weight_bits-pack_dtypeuint32-out_dtypeint16-unipolartrue)(data,weight,data_bits,…)|topi 中位串行密集的默认实现。| +|[circular_pad](/docs/api-reference/python-api/tvm-topi#tvmtopinncircular_paddata-pad_before-pad_afternone-namecircularpadinput)(data,pad_before[,pad_after,name])|对输入张量应用圆形填充(环绕)。| +|[concatenate](/docs/api-reference/python-api/tvm-topi#tvmtopinnconcatenatea_tuple-axis0)(a_tuple[,axis])|沿现有轴连接一系列数组。| +|[conv](/docs/api-reference/python-api/tvm-topi#tvmtopinnconvinptensor-filttensor-strideintsequenceint-paddingintsequenceint-dilationintsequenceint-groupsint-data_layoutstr-kernel_layoutstr--out_dtypestrnone-none-auto_scheduler_rewritten_layoutstrnone-none-meta_schedule_original_shapenone-auto_scheduler_should_rewrite_layoutbool-false)(inp,filt,stride,padding,dilation,…)|NCHW 或 NHWC 布局中的卷积操作符。| +|[conv1d](/docs/api-reference/python-api/tvm-topi#tvmtopinnconv1ddata-kernel-strides1-paddingvalid-dilation1-groups1-data_layoutncw-kernel_layout-out_dtypenone)(data,kernel[,strides,padding,…])|1D 卷积前向操作符。| +|[conv1d_ncw](/docs/api-reference/python-api/tvm-topi#tvmtopinnconv1d_ncwdata-kernel-strides1-paddingvalid-dilation1-out_dtypenone)(data,kernel[,strides,padding,…])|NCW 布局中的一维卷积。| +|[conv1d_nwc](/docs/api-reference/python-api/tvm-topi#tvmtopinnconv1d_nwcdata-kernel-strides1-paddingvalid-dilation1-out_dtypenone)(data,kernel[,strides,padding,…])|NWC 布局中的一维卷积。| +|[conv1d_transpose_ncw](/docs/api-reference/python-api/tvm-topi#tvmtopinnconv1d_transpose_ncwdata-kernel-stride-padding-out_dtype-output_padding)(data,kernel,stride,…)|转置的一维卷积 ncw 前向操作符。| +|[conv2d](/docs/api-reference/python-api/tvm-topi#tvmtopinnconv2dinput-filter-strides-padding-dilation-data_layoutnchw-kernel_layout-out_dtypenone)(input,filter,strides,padding,dilation)|Conv2D 运算符。| +|[conv2d_NCHWc](/docs/api-reference/python-api/tvm-topi#tvmtopinnconv2d_nchwcdata-kernel-stride-padding-dilation-layout-out_layout-out_dtypefloat32)(data,kernel,stride,padding,…)|nChw[x]c 布局的 Conv2D 运算符。| +|[conv2d_NCHWc_int8](/docs/api-reference/python-api/tvm-topi#tvmtopinnconv2d_nchwc_int8data-kernel-stride-padding-dilation-layout-out_layout-out_dtypeint32-n_elems4)(data,kernel,stride,…)|nChw[x]c 布局的 Conv2D 运算符。| +|[conv2d_hwcn](/docs/api-reference/python-api/tvm-topi#tvmtopinnconv2d_hwcninput-filter-stride-padding-dilation-out_dtypenone)(Input,Filter,stride,padding,…)|HWCN 布局中的卷积操作符。| +|[conv2d_nchw](/docs/api-reference/python-api/tvm-topi#tvmtopinnconv2d_nchwinput-filter-stride-padding-dilation-out_dtypenone)(Input,Filter,stride,padding,…)|NCHW 布局中的卷积操作符。| +|[conv2d_nhwc](/docs/api-reference/python-api/tvm-topi#tvmtopinnconv2d_nhwcinput-filter-stride-padding-dilation-out_dtypefloat32-auto_scheduler_rewritten_layout-meta_schedule_original_shapenone)(Input,Filter,stride,padding,…)|NHWC 布局中的卷积操作符。| +|[conv2d_transpose_nchw](/docs/api-reference/python-api/tvm-topi#tvmtopinnconv2d_transpose_nchwinput-filter-strides-padding-out_dtype-output_padding)(Input,Filter,…)|转置的二维卷积 nchw 前向操作符。| +|[conv2d_transpose_nchw_preprocess](/docs/api-reference/python-api/tvm-topi#tvmtopinnconv2d_transpose_nchw_preprocessdata-kernel-strides-padding-out_dtype-output_padding)(data,…)|预处理数据和内核,使 conv2d_transpose 的计算模式与 conv2d 相同。| +|[conv2d_winograd_nchw](/docs/api-reference/python-api/tvm-topi#tvmtopinnconv2d_winograd_nchwdata-weight-strides-padding-dilation-out_dtype-pre_computedfalse-auto_scheduler_rewritten_layout-meta_schedule_original_shapenone)(data,weight,strides,…)|NCHW 布局中的 Conv2D Winograd。这是一个干净的版本,可供 CPU 和 GPU 的自动调度程序使用。| +|[conv2d_winograd_nchw_without_weight_transform](/docs/api-reference/python-api/tvm-topi#tvmtopinnconv2d_winograd_nchw_without_weight_transformdata-weight-strides-padding-dilation-out_dtype-auto_scheduler_rewritten_layout-meta_schedule_original_shapenone)(…)|在 NCHW 布局中,Conv2D Winograd 无需布局变换。这是一个可供 CPU 和 GPU 元调度使用的干净版本。| +|[conv2d_winograd_nhwc](/docs/api-reference/python-api/tvm-topi#tvmtopinnconv2d_winograd_nhwcdata-weight-strides-padding-dilation-out_dtype-pre_computedfalse-auto_scheduler_rewritten_layout-meta_schedule_original_shapenone)(data,weight,strides,…)|NHWC 布局中的 Conv2D Winograd。这是一个干净的版本,可供 CPU 和 GPU 的自动调度程序使用。| +|[conv2d_winograd_nhwc_without_weight_transform](/docs/api-reference/python-api/tvm-topi#tvmtopinnconv2d_winograd_nhwc_without_weight_transformdata-weight-strides-padding-dilation-out_dtype-auto_scheduler_rewritten_layout-meta_schedule_original_shapenone)(…)|Conv2D Winograd 在 NHWC 布局中无需布局变换。这是一个干净的版本,可供 CPU 和 GPU 自动调度程序使用。| +|[conv2d_winograd_weight_transform](/docs/api-reference/python-api/tvm-topi#tvmtopinnconv2d_winograd_weight_transformkernel-tile_size)(kernel,…)|winograd 的权重转换。| +|[conv3d_ncdhw](/docs/api-reference/python-api/tvm-topi#tvmtopinnconv3d_ncdhwinput-filter-stride-padding-dilation-groups-out_dtypenone)(Input,Filter,stride,padding,…)|NCDHW 布局中的 Conv3D 运算符。| +|[conv3d_ndhwc](/docs/api-reference/python-api/tvm-topi#tvmtopinnconv3d_ndhwcinput-filter-stride-padding-dilation-groups-out_dtypefloat32-auto_scheduler_rewritten_layout-meta_schedule_origin_shapenone)(Input,Filter,stride,padding,…)|NDHWC 布局中的卷积操作符。| +|[conv3d_transpose_ncdhw](/docs/api-reference/python-api/tvm-topi#tvmtopinnconv3d_transpose_ncdhwinput-filter-strides-padding-out_dtype-output_padding)(Input,Filter,…)|转置的3D 卷积 ncdhw 前向操作符。| +|[conv3d_transpose_ncdhw_preprocess](/docs/api-reference/python-api/tvm-topi#tvmtopinnconv3d_transpose_ncdhw_preprocessdata-kernel-strides-padding-out_dtype-output_padding)(data,…)|预处理数据和内核,使 conv3d_transpose 的计算模式与 conv3d 相同。| +|[conv3d_winograd_weight_transform](/docs/api-reference/python-api/tvm-topi#tvmtopinnconv3d_winograd_weight_transformkernel-tile_size)(kernel,…)|3D winograd 的权重变换。| +|[correlation_nchw](/docs/api-reference/python-api/tvm-topi#tvmtopinncorrelation_nchwdata1-data2-kernel_size-max_displacement-stride1-stride2-padding-is_multiply)(data1,data2,kernel_size,…)|NCHW 布局中的相关运算符。| +|[declaration_conv2d_transpose_impl](/docs/api-reference/python-api/tvm-topi#tvmtopinndeclaration_conv2d_transpose_impldata-kernel-strides-padding-out_dtype-output_padding)(data,…)|conv2d 转置的实现。| +|[declaration_conv3d_transpose_impl](/docs/api-reference/python-api/tvm-topi#tvmtopinndeclaration_conv3d_transpose_impldata-kernel-strides-padding-out_dtype-output_padding)(data,…)|conv3d 转置的实现。| +|[deformable_conv2d_nchw](/docs/api-reference/python-api/tvm-topi#tvmtopinndeformable_conv2d_nchwdata-offset-kernel-strides-padding-dilation-deformable_groups-groups-out_dtype)(data,offset,kernel,…)|NCHW 布局中的可变形 conv2D 运算符。| +|[deformable_conv2d_nhwc](/docs/api-reference/python-api/tvm-topi#tvmtopinndeformable_conv2d_nhwcdata-offset-kernel-strides-padding-dilation-deformable_groups-groups-out_dtype)(data,offset,kernel,…)|NHWC 布局中的可变形 conv2D 运算符。| +|[dense](/docs/api-reference/python-api/tvm-topi#tvmtopinndensedata-weight-biasnone-out_dtypenone-auto_scheduler_rewritten_layout-meta_schedule_original_shapenone)(data,weight[,bias,out_dtype,…])|topi 中致密的默认实现。这是 matmul_nt 运算符的别名,用于非转置格式的数据张量和转置格式的权重张量。| +|[dense_pack](/docs/api-reference/python-api/tvm-topi#tvmtopinndense_packdata-weight-biasnone-out_dtypenone)(data,weight[,bias,out_dtype])|topi 中 dense_pack 的默认实现。| +|[depth_to_space](/docs/api-reference/python-api/tvm-topi#tvmtopinndepth_to_spacedata-block_size-layoutnchw-modedcr)(data,block_size[,layout,mode])|对数据进行深度到空间的变换。| +|[depthwise_conv2d_NCHWc](/docs/api-reference/python-api/tvm-topi#tvmtopinndepthwise_conv2d_nchwcinput-filter-stride-padding-dilation-layout-out_layout-out_dtypenone)(Input,Filter,…[,…])|深度卷积 NCHW[x]c 前向操作符。| +|[depthwise_conv2d_backward_input_nhwc](/docs/api-reference/python-api/tvm-topi#tvmtopinndepthwise_conv2d_backward_input_nhwcfilter-out_grad-oshape-ishape-stride-padding)(Filter,…)|深度卷积 nhwc 后向 wrt 输入运算符。| +|[depthwise_conv2d_backward_weight_nhwc](/docs/api-reference/python-api/tvm-topi#tvmtopinndepthwise_conv2d_backward_weight_nhwcinput-out_grad-oshape-fshape-stride-padding)(Input,…)|深度卷积 nhwc 后向 wrt 权重运算符。| +|[depthwise_conv2d_nchw](/docs/api-reference/python-api/tvm-topi#tvmtopinndepthwise_conv2d_nchwinput-filter-stride-padding-dilation-out_dtypenone)(Input,Filter,stride,…)|深度卷积 nchw 前向操作符。| +|[depthwise_conv2d_nhwc](/docs/api-reference/python-api/tvm-topi#tvmtopinndepthwise_conv2d_nhwcinput-filter-stride-padding-dilation-kernel_layouthwoi-out_dtypenone)(Input,Filter,stride,…)|深度卷积 nhwc 前向操作符。| +|[dilate](/docs/api-reference/python-api/tvm-topi#tvmtopinndilatedata-strides-dilation_value00-namedilatedinput)(data,strides[,dilation_value,name])|使用给定的扩张值(默认为 0)扩张数据。| +|[equal_const_int](/docs/api-reference/python-api/tvm-topi#tvmtopinnequal_const_intexpr-value)(expr,value)|如果 expr 等于 value,则返回。| +|[fast_softmax](/docs/api-reference/python-api/tvm-topi#tvmtopinnfast_softmaxx-axis-1)(x[,axis])|对数据执行 softmax 激活。使用近似值计算指数可以提高速度。| +|[fifo_buffer](/docs/api-reference/python-api/tvm-topi#tvmtopinnfifo_bufferdata-buffer-axis)(data,buffer,axis)|FIFO 缓冲区可在具有滑动窗口输入的 CNN 中实现计算重用。| +|[flatten](/docs/api-reference/python-api/tvm-topi#tvmtopinnflattendata)(data)|通过折叠较高维度将输入数组展平为二维数组。| +|[get_const_int](/docs/api-reference/python-api/tvm-topi#tvmtopinnget_const_intexpr)(expr)|验证 expr 是否为整数并获取常数值。| +|[get_const_tuple](/docs/api-reference/python-api/tvm-topi#tvmtopinnget_const_tuplein_tuple)(in_tuple)|验证输入元组是 IntImm 还是 Var,返回 int 或 Var 的元组。| +|[get_pad_tuple](/docs/api-reference/python-api/tvm-topi#tvmtopinnget_pad_tuplepadding-kernel)(padding,kernel)|获取 pad 选项的通用代码。| +|[get_pad_tuple1d](/docs/api-reference/python-api/tvm-topi#tvmtopinnget_pad_tuple1dpadding-kernel)(padding,kernel)|获取 pad 选项的通用代码。| +|[get_pad_tuple3d](/docs/api-reference/python-api/tvm-topi#tvmtopinnget_pad_tuple3dpadding-kernel)(padding,kernel)|获取 pad 选项的通用代码。| +|[get_pad_tuple_generic](/docs/api-reference/python-api/tvm-topi#tvmtopinnget_pad_tuple_genericpadding-kernel)(padding,kernel)|获取 pad 选项的通用代码。| +|[get_padded_shape](/docs/api-reference/python-api/tvm-topi#tvmtopinnget_padded_shapedata-pad_before-pad_afternone)(data,pad_before[,pad_after])|应用填充后计算张量的输出形状。| +|[global_pool](/docs/api-reference/python-api/tvm-topi#tvmtopinnglobal_pooldata-pool_type-layoutnchw)(data,pool_type[,layout])|对数据的高度和宽度维度进行全局池化。| +|[group_conv1d_ncw](/docs/api-reference/python-api/tvm-topi#tvmtopinngroup_conv1d_ncwdata-kernel-strides1-paddingvalid-dilation1-groups1-out_dtypenone)(data,kernel[,strides,…])|用于 NCW 布局的一维卷积前向操作符。| +|[group_conv1d_nwc](/docs/api-reference/python-api/tvm-topi#tvmtopinngroup_conv1d_nwcdata-kernel-strides1-paddingvalid-dilation1-groups1-out_dtypenone)(data,kernel[,strides,…])|用于 NWC 布局的一维卷积前向操作符。| +|[group_conv1d_transpose_ncw](/docs/api-reference/python-api/tvm-topi#tvmtopinngroup_conv1d_transpose_ncwdata-kernel-stride-padding-out_dtype-output_padding-groups)(data,kernel,…)|转置的一维组卷积 ncw 前向操作符。| +|[group_conv2d_nchw](/docs/api-reference/python-api/tvm-topi#tvmtopinngroup_conv2d_nchwinput-filter-stride-padding-dilation-groups-out_dtypenone)(Input,Filter,stride,…)|NCHW 布局中的组卷积操作符。| +|[group_conv2d_nhwc](/docs/api-reference/python-api/tvm-topi#tvmtopinngroup_conv2d_nhwcinput-filter-stride-padding-dilation-groups-out_dtypenone)(Input,Filter,stride,…)|NHWC 布局中的组卷积操作符。| +|[group_conv2d_transpose_nchw](/docs/api-reference/python-api/tvm-topi#tvmtopinngroup_conv2d_transpose_nchwdata-kernel-stride-padding-out_dtype-output_padding-groups)(data,kernel,…)|NCHW 布局中的组卷积操作符。| +|[group_conv3d_transpose_ncdhw](/docs/api-reference/python-api/tvm-topi#tvmtopinngroup_conv3d_transpose_ncdhwdata-kernel-strides-padding-out_dtype-output_padding-groups)(data,kernel,…)|转置组3D 卷积 ncdhw 前向操作符。| +|[if_then_else](/docs/api-reference/python-api/tvm-topi#tvmtopinnif_then_elsecond-t-f-spannone)(cond,t,f[,span])|条件选择表达式。| +|[leaky_relu](/docs/api-reference/python-api/tvm-topi#tvmtopinnleaky_relux-alpha)(x,alpha)|取输入 x 的 leaky relu。| +|[log_softmax](/docs/api-reference/python-api/tvm-topi#tvmtopinnlog_softmaxx-axis-1)(x[,axis])|对数据执行对数 softmax 激活| +|[lrn](/docs/api-reference/python-api/tvm-topi#tvmtopinnlrndata-size-axis1-alpha00001-beta075-bias2)(data,size[,axis,alpha,beta,bias])|对输入数据执行跨通道局部响应标准化。| +|[lstm](/docs/api-reference/python-api/tvm-topi#tvmtopinnlstmxs-wi-wh-binone-bhnone-h_initnone-c_initnone-projnone-p_inone-p_fnone-p_onone-f_act-g_act-h_act-reversefalse-weight_layout-str--ifgo)(Xs,Wi,Wh[,Bi,Bh,h_init,c_init,…])|使用 TE 扫描实现的通用 LSTM。| +|[matmul](/docs/api-reference/python-api/tvm-topi#tvmtopinnmatmultensor_a-tensor_b-biasnone-out_dtypenone-transpose_afalse-transpose_bfalse-auto_scheduler_rewritten_layout-meta_schedule_original_shapenone)(tensor_a,tensor_b[,bias,…])|topi 中 matmul 的默认实现。| +|[mirror_pad](/docs/api-reference/python-api/tvm-topi#tvmtopinnmirror_paddata-pad_before-pad_afternone-modesymmetric-namemirrorpadinput)(data,pad_before[,pad_after,…])|具有对称或反射功能的镜像平板输入。| +|[namedtuple](/docs/api-reference/python-api/tvm-topi#tvmtopinnnamedtupletypename-field_names--renamefalse-defaultsnone-modulenone)(typename,field_names,*[,…])|返回具有命名字段的元组的新子类。| +|[nll_loss](/docs/api-reference/python-api/tvm-topi#tvmtopinnnll_losspredictions-targets-weights-reduction-ignore_index)(predictions,targets,weights,…)|输入数据的负对数似然损失。| +|[pad](/docs/api-reference/python-api/tvm-topi#tvmtopinnpaddata-pad_before-pad_afternone-pad_value00-namepadinput-attrsnone)(data,pad_before[,pad_after,…])|使用 pad 值的 Pad 输入。| +|[pool1d](/docs/api-reference/python-api/tvm-topi#tvmtopinnpool1ddata-kernel-stride-dilation-padding-pool_type-ceil_modefalse-layoutncw-count_include_padtrue)(data,kernel,stride,dilation,…)|对数据的宽度维度进行池化。| +|[pool2d](/docs/api-reference/python-api/tvm-topi#tvmtopinnpool2ddata-kernel-stride-dilation-padding-pool_type-ceil_modefalse-layoutnchw-count_include_padtrue)(data,kernel,stride,dilation,…)|对数据的高度和宽度维度进行池化。| +|[pool3d](/docs/api-reference/python-api/tvm-topi#tvmtopinnpool3ddata-kernel-stride-dilation-padding-pool_type-ceil_modefalse-layoutncdhw-count_include_padtrue)(data,kernel,stride,dilation,…)|对数据的深度、高度和宽度维度进行池化。| +|[pool_grad](/docs/api-reference/python-api/tvm-topi#tvmtopinnpool_gradgrads-data-kernel-stride-padding-pool_type-ceil_modefalse-count_include_padtrue-layoutnchw)(grads,data,kernel,stride,…)|池化在数据高度和宽度维度上的梯度。| +|[prelu](/docs/api-reference/python-api/tvm-topi#tvmtopinnprelux-slope-axis1)(x,slope[,axis])|PReLU。它接受两个参数:一个输入x和一个权重数组W ,并计算输出为 PReLU(x)y=x>0?x:W∗x, 在哪里∗是批次中每个样本的元素乘法。| +|[reduce](/docs/api-reference/python-api/tvm-topi#tvmtopinnreducefunction-sequence-initial--value)(function,sequence[,initial])|将一个包含两个参数的函数从左到右累加地应用于序列的项,从而将序列简化为单个值。例如,reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) 计算结果为 ((((1+2)+3)+4)+5)。如果指定了 initial,则在计算过程中将其放置在序列的项之前,并在序列为空时用作默认值。| +|[reflect_pad](/docs/api-reference/python-api/tvm-topi#tvmtopinnreflect_paddata-pad_before-pad_afternone-namereflectpadinput)(data,pad_before[,pad_after,name])|将反射填充应用于输入张量。| +|[relu](/docs/api-reference/python-api/tvm-topi#tvmtopinnrelux)(x)|取输入 x 的 relu。| +|[replicate_pad](/docs/api-reference/python-api/tvm-topi#tvmtopinnreplicate_paddata-pad_before-pad_afternone-namereplicatepadinput)(data,pad_before[,pad_after,…])|对输入张量应用重复填充(边缘填充)。| +|[scale_shift_nchw](/docs/api-reference/python-api/tvm-topi#tvmtopinnscale_shift_nchwinput-scale-shift)(Input,Scale,Shift)|推理中的批量标准化运算符。| +|[scale_shift_nchwc](/docs/api-reference/python-api/tvm-topi#tvmtopinnscale_shift_nchwcinput-scale-shift)(Input,Scale,Shift)|推理中的批量标准化运算符。| +|[scale_shift_nhwc](/docs/api-reference/python-api/tvm-topi#tvmtopinnscale_shift_nhwcinput-scale-shift)(Input,Scale,Shift)|推理中的批量标准化运算符。| +|[simplify](/docs/api-reference/python-api/tvm-topi#tvmtopinnsimplifyexpr)(expr)|如果是 Expr 则化简表达式,如果是 int 则直接返回。| +|[simulated_dequantize](/docs/api-reference/python-api/tvm-topi#tvmtopinnsimulated_dequantizedata-in_dtype-input_scalenone-input_zero_pointnone-axis-1)(data,in_dtype[,…])|模拟 QNN 反量化运算符,可模拟 QNN 输出,而无需更改数据类型。与真正的 QNN 反量化相比,此运算符的优势在于,它允许动态选择数据类型,并且可以对每个通道、标量尺度和零点进行操作,而 QNN 反量化则需要在编译时修复这两者。| +|[simulated_quantize](/docs/api-reference/python-api/tvm-topi#tvmtopinnsimulated_quantizedata-out_dtype-output_scalenone-output_zero_pointnone-axis-1)(data,out_dtype[,…])|模拟 QNN 量化运算符,可模拟 QNN 输出,无需更改数据类型。与真正的 QNN 量化相比,此运算符的优势在于,它允许动态选择数据类型,并且可以对每个通道、标量尺度和零点进行操作,而 QNN 量化则要求在编译时固定这两个参数。| +|[softmax](/docs/api-reference/python-api/tvm-topi#tvmtopinnsoftmaxx-axis-1)(x[,axis])|对数据执行 softmax 激活。| +|[softmax_common](/docs/api-reference/python-api/tvm-topi#tvmtopinnsoftmax_commonx-axis-use_fast_exp)(x,axis,use_fast_exp)|softmax 和 fast_softmax 的共同部分。| +|[softplus](/docs/api-reference/python-api/tvm-topi#tvmtopinnsoftplusx-beta10-threshold200)(x[,beta,threshold])|计算具有数值稳定性的输入 x 的 Softplus 激活。| +|[space_to_batch_nd](/docs/api-reference/python-api/tvm-topi#tvmtopinnspace_to_batch_nddata-block_shape-pad_before-pad_after-pad_value00)(data,block_shape,…[,…])|对数据执行批量到空间的转换。| +|[space_to_depth](/docs/api-reference/python-api/tvm-topi#tvmtopinnspace_to_depthdata-block_size-layoutnchw)(data,block_size[,layout])|对数据执行空间到深度的转换。| +|[strided_slice](/docs/api-reference/python-api/tvm-topi#tvmtopinnstrided_slicea-begin-end-stridesnone-axesnone-slice_modeend-assume_inboundtrue)(a,begin,end[,strides,…])|数组的切片。| +|[unpack_NCHWc_to_nchw](/docs/api-reference/python-api/tvm-topi#tvmtopinnunpack_nchwc_to_nchwpacked_out-out_dtype)(packed_out,out_dtype)|将 conv2d_NCHWc 输出从布局 NCHWc 解包为 NCHW。| +|[upsampling](/docs/api-reference/python-api/tvm-topi#tvmtopinnupsamplingdata-scale_h-scale_w-layoutnchw-methodnearest_neighbor-align_cornersfalse-output_shapenone)(data,scale_h,scale_w[,layout,…])|对数据执行上采样。| +|[upsampling3d](/docs/api-reference/python-api/tvm-topi#tvmtopinnupsampling3ddata-scale_d-scale_h-scale_w-layoutncdhw-methodnearest_neighbor-coordinate_transformation_modehalf_pixel-output_shapenone)(data,scale_d,scale_h,scale_w)|对数据执行上采样。| +|[winograd_transform_matrices](/docs/api-reference/python-api/tvm-topi#tvmtopinnwinograd_transform_matricestile_size-kernel_size-out_dtype)(tile_size,…)|将 tile_size 的 A、B 和 G 变换矩阵计算为 tvm.Expr。| +|[instance_norm](/docs/api-reference/python-api/tvm-topi#tvmtopinninstance_normdata-gamma-beta-channel_axis-axis-epsilon1e-05)(data,gamma,beta,…[,epsilon])|实例规范化运算符。| +|[layer_norm](/docs/api-reference/python-api/tvm-topi#tvmtopinnlayer_normdata-gamma-beta-axis-epsilon1e-05)(data,gamma,beta,axis[,epsilon])|层归一化运算符。它接受 fp16 和 fp32 作为输入数据类型。它会将输入转换为 fp32 来执行计算。输出将具有与输入相同的数据类型。| +|[group_norm](/docs/api-reference/python-api/tvm-topi#tvmtopinngroup_normdata-gamma-beta-num_groups-channel_axis-axes-epsilon1e-05)(data,gamma,beta,num_groups,…)|组规范化运算符。它接受 fp16 和 fp32 作为输入数据类型。它会将输入转换为 fp32 来执行计算。输出将具有与输入相同的数据类型。| +|[rms_norm](/docs/api-reference/python-api/tvm-topi#tvmtopinnrms_normdata-weight-axis-epsilon1e-05)(data,weight,axis[,epsilon])|均方根归一化运算符。输出将具有与输入相同的数据类型。| ## *class* tvm.topi.nn.Workload(*in_dtype*, *out_dtype*, *height*, *width*, *in_filter*, *out_filter*, *kernel_h*, *kernel_w*, *padt*, *padl*, *padb*, *padr*, *dilation_h*, *dilation_w*, *stride_h*, *stride_w*) **属性:** -|[dilation_h](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.Workload.dilation_h)|字段编号 12 的别名。| +|[dilation_h](/docs/api-reference/python-api/tvm-topi#dilation_h)|字段编号 12 的别名。| |:----|:----| -|[dilation_w](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.Workload.dilation_w)|字段编号 13 的别名。| -|[height](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.Workload.height)|字段号 2 的别名。| -|[in_dtype](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.Workload.in_dtype)|字段编号 0 的别名。| -|[in_filter](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.Workload.in_filter)|字段号 4 的别名。| -|[kernel_h](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.Workload.kernel_h)|字段号 6 的别名。| -|[kernel_w](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.Workload.kernel_w)|字段号 7 的别名。| -|[out_dtype](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.Workload.out_dtype)|字段号 1 的别名。| -|[out_filter](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.Workload.out_filter)|字段编号 5 的别名。| -|[padb](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.Workload.padb)|字段编号 10 的别名。| -|[padl](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.Workload.padl)|字段编号 9 的别名。| -|[padr](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.Workload.padr)|字段编号 11 的别名。| -|[padt](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.Workload.padt)|字段号 8 的别名。| -|[stride_h](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.Workload.stride_h)|字段编号 14 的别名。| -|[stride_w](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.Workload.stride_w)|字段编号 15 的别名。| -|[width](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.Workload.width)|字段号 3 的别名。| +|[dilation_w](/docs/api-reference/python-api/tvm-topi#dilation_w)|字段编号 13 的别名。| +|[height](/docs/api-reference/python-api/tvm-topi#height)|字段号 2 的别名。| +|[in_dtype](/docs/api-reference/python-api/tvm-topi#in_dtype)|字段编号 0 的别名。| +|[in_filter](/docs/api-reference/python-api/tvm-topi#in_filter)|字段号 4 的别名。| +|[kernel_h](/docs/api-reference/python-api/tvm-topi#kernel_h)|字段号 6 的别名。| +|[kernel_w](/docs/api-reference/python-api/tvm-topi#kernel_w)|字段号 7 的别名。| +|[out_dtype](/docs/api-reference/python-api/tvm-topi#out_dtype)|字段号 1 的别名。| +|[out_filter](/docs/api-reference/python-api/tvm-topi#out_filter)|字段编号 5 的别名。| +|[padb](/docs/api-reference/python-api/tvm-topi#padb)|字段编号 10 的别名。| +|[padl](/docs/api-reference/python-api/tvm-topi#padl)|字段编号 9 的别名。| +|[padr](/docs/api-reference/python-api/tvm-topi#padr)|字段编号 11 的别名。| +|[padt](/docs/api-reference/python-api/tvm-topi#padt)|字段号 8 的别名。| +|[stride_h](/docs/api-reference/python-api/tvm-topi#stride_h)|字段编号 14 的别名。| +|[stride_w](/docs/api-reference/python-api/tvm-topi#stride_w)|字段编号 15 的别名。| +|[width](/docs/api-reference/python-api/tvm-topi#width)|字段号 3 的别名。| ### dilation_h @@ -2320,12 +2320,12 @@ topi.trilu(x, True, 0) = 池化核和步长大小会根据所需的输出大小自动选择。它根据布局字符串确定高度和宽度,其中「W」和「H」分别表示宽度和高度。宽度和高度不能拆分。例如,NCHW、NCHW16c 等适用于池化,而 NCHW16w、NCHW16h 则不适用。有关布局字符串约定的更多信息,请参阅参数布局。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):具有布局形状的 nD。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):具有布局形状的 nD。 * **output_size**([int 元](https://docs.python.org/3/library/functions.html#int)*组*[)](https://docs.python.org/3/library/stdtypes.html#tuple)*:* 输出高度和宽度。 * **pool_type** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ):池类型,“max”或“avg”。 * **layout**(*字符串*):输入数据的布局。布局应该由大写字母、小写字母和数字组成,其中大写字母表示维度,对应的小写字母(因子大小)表示分割维度。例如,NCHW16c 可以描述一个 5 维张量,其值为 [batch_size, channel, height, width, channel_block],其中 channel_block=16 表示对 channel 维度的分割。 * **返回:output** :nD 在同一布局中。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.adaptive_pool1d(*data*, *output_size*, *pool_type*, *layout='NCW'*) @@ -2342,10 +2342,10 @@ topi.trilu(x, True, 0) = 自动广播附加功能。 * **参数:** - * **lhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*)*:* 左操作数 - * **rhs**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*或Expr*)*:* 右操作数 + * **lhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*)*:* 左操作数 + * **rhs**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*或Expr*)*:* 右操作数 * **返回:ret**:如果两个操作数都是 Expr,则返回 Expr。否则返回 Tensor。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) or Expr +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) or Expr ### tvm.topi.nn.batch_matmul(*tensor_a*, *tensor_b*, *oshape=None*, *out_dtype=None*, *transpose_a=False*, *transpose_b=True*, *auto_scheduler_rewritten_layout=''*, *meta_schedule_original_shape=None*) @@ -2354,18 +2354,18 @@ topi.trilu(x, True, 0) = tensor_a 和 tensor_b 均可转置。由于历史原因,我们默认使用 NT 格式(transpose_a=False,transpose_b=True)。 * **参数:** - * **tensor_a** ( [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) ):三维,形状为 [batch, M, K] 或 [batch, K, M]。 - * **tensor_b** ( [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) ):三维,形状为 [batch, K, N] 或 [batch, N, K]。 + * **tensor_a** ( [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ):三维,形状为 [batch, M, K] 或 [batch, K, M]。 + * **tensor_b** ( [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ):三维,形状为 [batch, K, N] 或 [batch, N, K]。 * *oshape*(*列表**[**可选**]):计算的明确预期输出形状。在输入形状动态变化的情况下很有用。 * *out_dtype**(*可选**[ [str](https://docs.python.org/3/library/stdtypes.html#str)*]*):指定混合精度批量 matmul 的输出数据类型。 * *transpose_a* (*可选[*[bool](https://docs.python.org/3/library/functions.html#bool)*]= False* )*:* 第一个张量是否为转置格式。 * *transpose_b* (*可选[*[bool](https://docs.python.org/3/library/functions.html#bool)*]= True* )[:](https://docs.python.org/3/library/functions.html#float)第二个张量是否为转置格式。 * *auto_scheduler_rewritten_layout**(*可选**[ [str](https://docs.python.org/3/library/stdtypes.html#str)*]= ""*):自动调度程序布局重写传递后的布局。 - * **meta_schedule_original_shape** ( *Optional[List[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]]= None* )**:** 张量的原始形状 + * **meta_schedule_original_shape** ( *Optional[List[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]]= None* )**:** 张量的原始形状 * **返回:output**:三维,形状为 [batch, M, N] -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) -## tvm.topi.nn.batch_norm(*data:*[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor), *gamma:*[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor), *beta:*[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor), *moving_mean:*[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor), *moving_var:*[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *epsilon:*[float](https://docs.python.org/3/library/functions.html#float)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *center:*[bool](https://docs.python.org/3/library/functions.html#bool)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *scale:*[bool](https://docs.python.org/3/library/functions.html#bool)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *training:*[bool](https://docs.python.org/3/library/functions.html#bool)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *momentum:*[float](https://docs.python.org/3/library/functions.html#float)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)] +## tvm.topi.nn.batch_norm(*data:*[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor), *gamma:*[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor), *beta:*[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor), *moving_mean:*[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor), *moving_var:*[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor), *axis:*[int](https://docs.python.org/3/library/functions.html#int)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *epsilon:*[float](https://docs.python.org/3/library/functions.html#float)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *center:*[bool](https://docs.python.org/3/library/functions.html#bool)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *scale:*[bool](https://docs.python.org/3/library/functions.html#bool)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *training:*[bool](https://docs.python.org/3/library/functions.html#bool)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *momentum:*[float](https://docs.python.org/3/library/functions.html#float)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)] 批量标准化层(Ioffe 和 Szegedy,2014)。 @@ -2373,11 +2373,11 @@ tensor_a 和 tensor_b 均可转置。由于历史原因,我们默认使用 NT 对每个批次的输入进行标准化,即应用保持平均激活接近 0 且激活标准差接近 1 的变换。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):要批量标准化的输入。 - * **gamma**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))*:* 应用于标准化张量的比例因子。 - * **beta**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):应用于标准化张量的偏移量。 - * **moving_mean**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入的运行平均值。 - * **moving_var**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入的运行方差。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):要批量标准化的输入。 + * **gamma**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))*:* 应用于标准化张量的比例因子。 + * **beta**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):应用于标准化张量的偏移量。 + * **moving_mean**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入的运行平均值。 + * **moving_var**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入的运行方差。 * *axis*(**[int](https://docs.python.org/3/library/functions.html#int)**,**可选**,默认值 = 1):指定应沿哪个形状轴进行规范化。 * *epsilon*(**[浮点数](https://docs.python.org/3/library/functions.html#float)**,**可选**,默认值 = 1e–5):添加到方差的小浮点数,以避免除以零。 * *center*(**[bool](https://docs.python.org/3/library/functions.html#bool)**,**可选**,默认 = True):如果为 True,则将 beta 的偏移量添加到标准化张量,如果为 False,则忽略 beta。 @@ -2393,40 +2393,40 @@ tensor_a 和 tensor_b 均可转置。由于历史原因,我们默认使用 NT 对数据执行空间到批量的转换。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 形状为 [batch, spatial_shape, remaining_shapes] 的 ND Tensor,其中 spatial_shape 有 M 维。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 形状为 [batch, spatial_shape, remaining_shapes] 的 ND Tensor,其中 spatial_shape 有 M 维。 * **block_shape**(*整数*[列表](https://docs.python.org/3/library/stdtypes.html#list)):大小为 [M] 的列表,其中 M 是空间维度的数量,指定每个空间维度的块大小。 * **crop_begin_list**(*整数*[列表](https://docs.python.org/3/library/stdtypes.html#list)):形状为 [M] 的列表,其中 M 是空间维度的数量,指定每个空间维度的开始裁剪大小。 * **crop_end_list**(*整数*[列表](https://docs.python.org/3/library/stdtypes.html#list)):形状为 [M] 的列表,其中 M 是空间维度的数量,指定每个空间维度的最终裁剪大小。 * **返回:output。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.binarize_pack(*data*, *axis=None*, *name='PackedInput'*) 沿某个轴进行二值化和位打包。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):nD 输入,可以是任何布局。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):nD 输入,可以是任何布局。 * **axis**(*None或*[int](https://docs.python.org/3/library/functions.html#int)):进行二值化和位打包的轴,默认为最后一个轴。 * **name**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*):运算符生成的名称前缀。 * **返回:output**:nD,与输入相同的布局,dtype 为 uint32。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.binary_dense(*data*, *weight*) 使用异或和位计数进行二进制矩阵乘法。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):二维,形状为 [batch, in_dim],dtype 为 uint32。 - * **权重**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 二维,形状为 [out_dim, in_dim],dtype 为 uint32。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):二维,形状为 [batch, in_dim],dtype 为 uint32。 + * **权重**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 二维,形状为 [out_dim, in_dim],dtype 为 uint32。 * **返回:output**:二维,形状为 [batch, out_dim],dtype 为 float32。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.bitpack(*data*, *bits*, *pack_axis*, *bit_axis*, *pack_type*, *name='QuantizeInput'*) 将数据打包成位串行计算所需的格式。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入 tvm 张量。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入 tvm 张量。 * **位**([int](https://docs.python.org/3/library/functions.html#int)):用于打包的位数。 * **pack_axis** ( [int](https://docs.python.org/3/library/functions.html#int) ):数据打包轴的索引。 * **bit_axis** ( [int](https://docs.python.org/3/library/functions.html#int) ):在结果打包数据中放置位轴的轴索引。 @@ -2438,8 +2438,8 @@ tensor_a 和 tensor_b 均可转置。由于历史原因,我们默认使用 NT Bitserial Conv2D 运算符。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D,形状为[batch, in_channel, in_height, in_width]。 - * **内核**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D,形状为[num_filter,in_channel,filter_height,filter_width]。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D,形状为[batch, in_channel, in_height, in_width]。 + * **内核**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D,形状为[num_filter,in_channel,filter_height,filter_width]。 * **stride**([int](https://docs.python.org/3/library/functions.html#int)*或**两个 int***的列表/元组):步幅大小,或 [stride_height, stride_width]。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或*两个**或**四个 int*的列表/元组*):填充大小,[pad_height, pad_width], [pad_top, pad_left, pad_down, pad_right]。 * **激活位**( [int](https://docs.python.org/3/library/functions.html#int) ):用于激活/输入元素的位数。 @@ -2448,58 +2448,58 @@ Bitserial Conv2D 运算符。 * **pack_dtype** ( [str](https://docs.python.org/3/library/stdtypes.html#str) )*:* 位打包类型。 * **单极**([bool](https://docs.python.org/3/library/functions.html#bool)):如果二值化样式为单极 1/0 格式,而不是双极 –1/+1 格式。 * **返回:output**:4–D,形状为[batch, out_channel, out_height, out_width]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.bitserial_conv2d_nhwc(*data*, *kernel*, *stride*, *padding*, *activation_bits*, *weight_bits*, *pack_dtype='uint32'*, *out_dtype='int16'*, *unipolar=True*) Bitserial Conv2D 运算符。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D,形状为[batch, in_height, in_width, in_channel]。 - * **内核**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D,形状为[filter_height,filter_width,in_channel,num_filter]。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D,形状为[batch, in_height, in_width, in_channel]。 + * **内核**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D,形状为[filter_height,filter_width,in_channel,num_filter]。 * **stride**([int](https://docs.python.org/3/library/functions.html#int)或 **两个 int** *的列表/元组*):步幅大小,或 [stride_height, stride_width]。 - * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或两个****或四个 int****的列表/元组*)[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)填充大小,[pad_height, pad_width], [pad_top, pad_left, pad_down, pad_right]。 + * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或两个****或四个 int****的列表/元组*)[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)填充大小,[pad_height, pad_width], [pad_top, pad_left, pad_down, pad_right]。 * **激活位**( [int](https://docs.python.org/3/library/functions.html#int) ):用于激活/输入元素的位数。 * **weight_bits** ( [int](https://docs.python.org/3/library/functions.html#int) ):用于权重元素的位数。 - * **out_dtype** ( [str](https://docs.python.org/3/library/stdtypes.html#str) )[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)返回卷积类型。 + * **out_dtype** ( [str](https://docs.python.org/3/library/stdtypes.html#str) )[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)返回卷积类型。 * **pack_dtype** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ):位打包类型。 * **单极**([bool](https://docs.python.org/3/library/functions.html#bool)):如果二值化样式为单极 1/0 格式,而不是双极 –1/+1 格式。 * **返回:output**:4–D,形状为[batch, out_height, out_width, out_channel]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.bitserial_dense(*data*, *weight*, *data_bits*, *weight_bits*, *pack_dtype='uint32'*, *out_dtype='int16'*, *unipolar=True*) topi 中位串行密集的默认实现。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))*:* 二维,形状为[batch, in_dim]。 - * **权重**( [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) )[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)形状为 [out_dim, in_dim] 的二维或​​形状为 [out_dim, weight_bits, in_dim] 的三维。 -* **返回:output**[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)二维,形状为 [batch, out_dim]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))*:* 二维,形状为[batch, in_dim]。 + * **权重**( [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) )[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)形状为 [out_dim, in_dim] 的二维或​​形状为 [out_dim, weight_bits, in_dim] 的三维。 +* **返回:output**[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)二维,形状为 [batch, out_dim]。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.circular_pad(*data*, *pad_before*, *pad_after=None*, *name='CircularPadInput'*) 对输入张量应用圆形填充(环绕)。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入张量。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入张量。 * *pad_before* ( *List[*[int](https://docs.python.org/3/library/functions.html#int)*]* )*:* 每个维度前填充的量。 * **pad_after**(*List[*[int](https://docs.python.org/3/library/functions.html#int)*],可选*)**:** 每个维度后的填充量。如果为 None ,则默认为 pad_before 。 * **name**([str](https://docs.python.org/3/library/stdtypes.html#str))*:* 结果张量的名称。 * **返回:out** *:* 圆形填充张量。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.concatenate(*a_tuple*, *axis=0*) 沿现有轴连接一系列数组。 * **参数:** - * **a_tuple**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*的*[元组](https://docs.python.org/3/library/stdtypes.html#tuple))*:* 要连接的数组。 + * **a_tuple**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*的*[元组](https://docs.python.org/3/library/stdtypes.html#tuple))*:* 要连接的数组。 * **axis**([int](https://docs.python.org/3/library/functions.html#int)*,可选*):数组连接的轴。默认值为 0。 * **返回:ret。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 -## tvm.topi.nn.conv(*inp:*[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor), *filt:*[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor), *stride:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*, *groups:*[int](https://docs.python.org/3/library/functions.html#int), *data_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str), *kernel_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= ''*, *out_dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *auto_scheduler_rewritten_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *meta_schedule_original_shape=None*, *auto_scheduler_should_rewrite_layout:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) +## tvm.topi.nn.conv(*inp:*[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor), *filt:*[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor), *stride:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*, *padding:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*, *dilation:*[int](https://docs.python.org/3/library/functions.html#int)*|*[Sequence](https://docs.python.org/3/library/typing.html#typing.Sequence)*[*[int](https://docs.python.org/3/library/functions.html#int)*]*, *groups:*[int](https://docs.python.org/3/library/functions.html#int), *data_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str), *kernel_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*= ''*, *out_dtype:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *auto_scheduler_rewritten_layout:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *meta_schedule_original_shape=None*, *auto_scheduler_should_rewrite_layout:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) NCHW 或 NHWC 布局中的卷积操作符。 @@ -2507,28 +2507,28 @@ NCHW 或 NHWC 布局中的卷积操作符。 支持 1D、2D、3D …… 和分组。 * **参数:** - * **inp**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) ):data_layout 中形状为 [batch, in_channel, in_height, in_width, …] 的 ND。 - * **filt**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) ):kernel_layout 中形状为 [num_filter, in_channel//groups, filter_height, filter_width, …] 的 ND。 + * **inp**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ):data_layout 中形状为 [batch, in_channel, in_height, in_width, …] 的 ND。 + * **filt**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ):kernel_layout 中形状为 [num_filter, in_channel//groups, filter_height, filter_width, …] 的 ND。 * **stride**([int](https://docs.python.org/3/library/functions.html#int)*或dim ints列表/元组)*:(其中 dim=2 表示 NCHW,dim=1 表示 NCH,等等)步幅大小,或 [stride_height, stride_width, …]。 * ***padding***(*[int](https://docs.python.org/3/library/functions.html#int)或**dim**或2*dim ints的列表/元组):(其中 dim=2 表示 NCHW,dim=1 表示 NCH,等等)填充大小,或 dim ints 的 [pad_height, pad_width, …],或 2*dim ints 的 [pad_top, pad_left, pad_bottom, pad_right]。 * **dilation**([int](https://docs.python.org/3/library/functions.html#int)*或两个 int的列表/元组*):扩张大小,或 [dilation_height, dilation_width]。 * **groups**([int](https://docs.python.org/3/library/functions.html#int)):组数。 * **data_layout** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ):输入的布局。N 表示批次维度,C 表示通道数,其他字符表示 HW(对于 1D 和 3D,则表示 H 或 HWD)。 * *kernel_layout*(可选[ [str](https://docs.python.org/3/library/stdtypes.html#str)])**:** 滤波器的布局。I 表示输入通道数,O 表示输出通道数,其他字符表示滤波器的 HW 维度(一维和三维时为 H 或 HWD)。如果 kernel_layout 为空,则使用 data_layout 推断默认的 kernel_layout。默认 kernel_layout 为 OIHW(NCHW 数据布局)或 HWIO(NHWC 数据布局)。 - * **out_dtype** ( [str](https://docs.python.org/3/library/stdtypes.html#str) )[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)在逐元素乘法和求和之前,元素被转换为此类型。 + * **out_dtype** ( [str](https://docs.python.org/3/library/stdtypes.html#str) )[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)在逐元素乘法和求和之前,元素被转换为此类型。 * **auto_scheduler_rewritten_layout** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ):来自自动调度程序布局重写的布局。 - * **meta_schedule_original_shape** (*可选*[***列表[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]]* )[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)输入张量的原始形状。 + * **meta_schedule_original_shape** (*可选*[***列表[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]]* )[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)输入张量的原始形状。 * **auto_scheduler_should_rewrite_layout** ( [bool](https://docs.python.org/3/library/functions.html#bool) ):是否允许自动调度程序重写滤波器张量的布局。默认为 false。如果与分组卷积一起使用,可能会导致错误。 * **返回:Output**:data_layout 中形状为 [batch, out_channel, out_height, out_width, …] 的 ND。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.conv1d(*data*, *kernel*, *strides=1*, *padding='VALID'*, *dilation=1*, *groups=1*, *data_layout='NCW'*, *kernel_layout=''*, *out_dtype=None*) 1D 卷积前向操作符。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):data_layout == 'NCW' 的 3–D 输入形状 [batch, in_width, in_channel] 和 data_layout == 'NWC' 的 [batch, in_width, in_channel]。 - * **kernel**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):3D 内核,其中 kernel_layout == 'OIW' 的形状为 [num_filter, in_channel, filter_size],而 kernel_layout == 'WIO' 的形状为 [filter_size, in_channel, num_filter]。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):data_layout == 'NCW' 的 3–D 输入形状 [batch, in_width, in_channel] 和 data_layout == 'NWC' 的 [batch, in_width, in_channel]。 + * **kernel**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):3D 内核,其中 kernel_layout == 'OIW' 的形状为 [num_filter, in_channel, filter_size],而 kernel_layout == 'WIO' 的形状为 [filter_size, in_channel, num_filter]。 * **strides**([int](https://docs.python.org/3/library/functions.html#int)*或*[tuple](https://docs.python.org/3/library/stdtypes.html#tuple))*:* 沿宽度的空间步幅。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或*[str](https://docs.python.org/3/library/stdtypes.html#str)):填充大小,或 ['VALID', 'SAME']。 * **dilation**([整数](https://docs.python.org/3/library/functions.html#int)*或*[元组](https://docs.python.org/3/library/stdtypes.html#tuple)):如果卷积需要扩张,则扩张率。 @@ -2539,49 +2539,49 @@ NCHW 或 NHWC 布局中的卷积操作符。 ## tvm.topi.nn.conv1d_ncw(*data*, *kernel*, *strides=1*, *padding='VALID'*, *dilation=1*, *out_dtype=None*) -NCW 布局中的一维卷积。有关参数的详细信息,请参阅 [conv()](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv)。 +NCW 布局中的一维卷积。有关参数的详细信息,请参阅 [conv()](/docs/api-reference/python-api/tvm-topi#tvmtopinnconvinptensor-filttensor-strideintsequenceint-paddingintsequenceint-dilationintsequenceint-groupsint-data_layoutstr-kernel_layoutstr--out_dtypestrnone-none-auto_scheduler_rewritten_layoutstrnone-none-meta_schedule_original_shapenone-auto_scheduler_should_rewrite_layoutbool-false)。 ## tvm.topi.nn.conv1d_nwc(*data*, *kernel*, *strides=1*, *padding='VALID'*, *dilation=1*, *out_dtype=None*) -NWC 布局中的一维卷积。有关参数的详细信息,请参阅 [conv()](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.conv)。 +NWC 布局中的一维卷积。有关参数的详细信息,请参阅 [conv()](/docs/api-reference/python-api/tvm-topi#tvmtopinnconvinptensor-filttensor-strideintsequenceint-paddingintsequenceint-dilationintsequenceint-groupsint-data_layoutstr-kernel_layoutstr--out_dtypestrnone-none-auto_scheduler_rewritten_layoutstrnone-none-meta_schedule_original_shapenone-auto_scheduler_should_rewrite_layoutbool-false)。 ## tvm.topi.nn.conv1d_transpose_ncw(*data*, *kernel*, *stride*, *padding*, *out_dtype*, *output_padding*) 转置的一维卷积 ncw 前向操作符。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):三维,形状为[batch, in_channel, in_width]。 - * **内核**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):3–D,形状为[in_channel,num_filter,filter_width]。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):三维,形状为[batch, in_channel, in_width]。 + * **内核**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):3–D,形状为[in_channel,num_filter,filter_width]。 * **步幅**(*ints*)*:* 沿宽度的空间步幅。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或*[str](https://docs.python.org/3/library/stdtypes.html#str))*:* 填充大小,或 ['VALID', 'SAME']。 * **out_dtype** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ):输出数据类型。用于混合精度。 - * **output_padding**(*ints*)[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)用于在存在多个可能形状的情况下恢复实际的输出形状。必须小于步幅。 + * **output_padding**(*ints*)[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)用于在存在多个可能形状的情况下恢复实际的输出形状。必须小于步幅。 * **返回:output**:3–D,形状为[batch, out_channel, out_width]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.conv2d(*input*, *filter*, *strides*, *padding*, *dilation*, *data_layout='NCHW'*, *kernel_layout=''*, *out_dtype=None*) Conv2D 运算符。 * **参数:** - * **输入**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))*:* 4–D,形状为 [batch, in_channel, in_height, in_width],位于 data_layout 中。 - * **过滤器**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D,形状为 [num_filter, in_channel, filter_height, filter_width],位于 kernel_layout 中。 + * **输入**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))*:* 4–D,形状为 [batch, in_channel, in_height, in_width],位于 data_layout 中。 + * **过滤器**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D,形状为 [num_filter, in_channel, filter_height, filter_width],位于 kernel_layout 中。 * **strides**([int](https://docs.python.org/3/library/functions.html#int)*或两个 int*的列表/元组):步幅大小,或 [stride_height, stride_width]。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)或 2 个或 4 个 int的列表/元组):填充大小,或 2 个 int 的 [pad_height, pad_width],或 4 个 int 的 [pad_top, pad_left, pad_bottom, pad_right]。 * **dilation**([int](https://docs.python.org/3/library/functions.html#int)*或两个 int的列表/元组*):扩张大小,或 [dilation_height, dilation_width]。 * **data_layout** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ):数据布局。 * *kernel_layout*(*可选*[ [str](https://docs.python.org/3/library/stdtypes.html#str)*]*)*:* 内核布局。如果未指定,则使用从 data_layout 推断出的默认布局。如果 data_layout == “NCHW”,则为“OIHW”;如果 data_layout == “NHWC”,则为“HWIO”。 * **返回:output**:4–D,形状为[batch, out_channel, out_height, out_width]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.conv2d_NCHWc(*data*, *kernel*, *stride*, *padding*, *dilation*, *layout*, *out_layout*, *out_dtype='float32'*) nChw[x]c 布局的 Conv2D 运算符。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):5–D,形状为[batch,in_channel_chunk,in_height,in_width,in_channel_block]。 - * **内核**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):6D,形状为[num_filter_chunk,in_channel_chunk,filter_height,filter_width,in_channel_block,num_filter_block]。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):5–D,形状为[batch,in_channel_chunk,in_height,in_width,in_channel_block]。 + * **内核**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):6D,形状为[num_filter_chunk,in_channel_chunk,filter_height,filter_width,in_channel_block,num_filter_block]。 * **stride**([int](https://docs.python.org/3/library/functions.html#int)*或两个 int****的列表/元组*)*:* 步幅大小,或 [stride_height, stride_width]。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)或2 个或4 个 int的列表/元组):填充大小,或 2 个 int 的 [pad_height, pad_width],或 4 个 int 的 [pad_top, pad_left, pad_bottom, pad_right]。 * **dilation**([int](https://docs.python.org/3/library/functions.html#int)*或两个 int的列表/元组*)*:* 扩张大小,或 [dilation_height, dilation_width]。 @@ -2589,15 +2589,15 @@ nChw[x]c 布局的 Conv2D 运算符。 * **out_layout** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ):输出数据布局。 * **out_dtype** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ):输出数据类型。 * **返回:output**:5–D,形状为[batch, out_channel_chunk, out_height, out_width, out_channel_block]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.conv2d_NCHWc_int8(*data*, *kernel*, *stride*, *padding*, *dilation*, *layout*, *out_layout*, *out_dtype='int32'*, *n_elems=4*) nChw[x]c 布局的 Conv2D 运算符。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):5–D,形状为[batch,in_channel_chunk,in_height,in_width,in_channel_block]。 - * **内核**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):7–D,形状为[num_filter_chunk,in_channel_chunk,filter_height,filter_width,in_channel_block/4,num_filter_block,4]。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):5–D,形状为[batch,in_channel_chunk,in_height,in_width,in_channel_block]。 + * **内核**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):7–D,形状为[num_filter_chunk,in_channel_chunk,filter_height,filter_width,in_channel_block/4,num_filter_block,4]。 * **stride**([int](https://docs.python.org/3/library/functions.html#int)*或两个 int 的列表/元组*):步幅大小,或 [stride_height, stride_width]。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)或 2 个或 4 个 int 的列表/元组):填充大小,或 2 个 int 的 [pad_height, pad_width],或 4 个 int 的 [pad_top, pad_left, pad_bottom, pad_right]。 * **dilation**([int](https://docs.python.org/3/library/functions.html#int)*或两个 int 的列表/元组*):扩张大小,或 [dilation_height, dilation_width]。 @@ -2606,62 +2606,62 @@ nChw[x]c 布局的 Conv2D 运算符。 * **out_dtype** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ):输出数据类型。 * **n_elems** ( [int](https://docs.python.org/3/library/functions.html#int) ):累计的 int8 元素数量。 * **返回:output** *:* 5–D,形状为[batch, out_channel_chunk, out_height, out_width, out_channel_block]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.conv2d_hwcn(*Input*, *Filter*, *stride*, *padding*, *dilation*, *out_dtype=None*) HWCN 布局中的卷积操作符。 * **参数:** - * **输入**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D,形状为[in_height, in_width, in_channel, batch]。 - * **过滤器**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 4–D,形状为[filter_height,filter_width,in_channel,num_filter]。 + * **输入**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D,形状为[in_height, in_width, in_channel, batch]。 + * **过滤器**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 4–D,形状为[filter_height,filter_width,in_channel,num_filter]。 * **stride**([int](https://docs.python.org/3/library/functions.html#int)*或两个 int 的列表/元组*):步幅大小,或 [stride_height, stride_width]。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或**2 个****或**4 个 int****的列表/元组*):填充大小,或 2 个 int 的 [pad_height, pad_width],或 4 个 int 的 [pad_top, pad_left, pad_bottom, pad_right]。 * **dilation**([int](https://docs.python.org/3/library/functions.html#int)*或两个 int 的列表/元组*):扩张大小,或 [dilation_height, dilation_width]。 * **返回:output**:4–D,形状为[out_height, out_width, out_channel, batch]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.conv2d_nchw(*Input*, *Filter*, *stride*, *padding*, *dilation*, *out_dtype=None*) NCHW 布局中的卷积操作符。 * **参数:** - * **输入**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D,形状为[batch, in_channel, in_height, in_width]。 - * **过滤器**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))[:](https://docs.python.org/3/library/functions.html#int)4–D,形状为[num_filter,in_channel,filter_height,filter_width]。 + * **输入**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D,形状为[batch, in_channel, in_height, in_width]。 + * **过滤器**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))[:](https://docs.python.org/3/library/functions.html#int)4–D,形状为[num_filter,in_channel,filter_height,filter_width]。 * **stride**([int](https://docs.python.org/3/library/functions.html#int)*或两个 int 的列表/元组*):步幅大小,或 [stride_height, stride_width]。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或2 个或 4 个 int 的列表/元组*):填充大小,或 2 个 int 的 [pad_height, pad_width],或 4 个 int 的 [pad_top, pad_left, pad_bottom, pad_right]。 * **dilation**([int](https://docs.python.org/3/library/functions.html#int)*或两个 int 的列表/元组*)*:* 扩张大小,或 [dilation_height, dilation_width]。 * **返回:Output**:4–D,形状为 [batch, out_channel, out_height, out_width]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.conv2d_nhwc(*Input*, *Filter*, *stride*, *padding*, *dilation*, *out_dtype='float32'*, *auto_scheduler_rewritten_layout=''*, *meta_schedule_original_shape=None*) NHWC 布局中的卷积操作符。 * **参数:** - * **输入**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D,形状为[batch, in_height, in_width, in_channel]。 - * **过滤器**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))***:*** 4–D,形状为[filter_height,filter_width,in_channel,num_filter]。 + * **输入**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D,形状为[batch, in_height, in_width, in_channel]。 + * **过滤器**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))***:*** 4–D,形状为[filter_height,filter_width,in_channel,num_filter]。 * **stride**([int](https://docs.python.org/3/library/functions.html#int)*或**两个 int**的列表/元组*):步幅大小,或 [stride_height, stride_width]。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或**2 个**或**4 个 int**的列表/元组*):填充大小,或 2 个 int 的 [pad_height, pad_width],或 4 个 int 的 [pad_top, pad_left, pad_bottom, pad_right]。 * **dilation**([int](https://docs.python.org/3/library/functions.html#int)*或**两个 int**的列表/元组*):扩张大小,或 [dilation_height, dilation_width]。 * *out_dtype* ( *str = "float32",* ):输出张量的类型。 * **auto_scheduler_rewritten_layout** ( *str = ""* ):自动调度程序布局重写传递后的布局。 - * **meta_schedule_original_shape** ( *Optional[List[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]]= None* ):输入张量的原始形状。 + * **meta_schedule_original_shape** ( *Optional[List[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]]= None* ):输入张量的原始形状。 * **返回:output**:4–D,形状为[batch, out_height, out_width, out_channel]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.conv2d_transpose_nchw(*Input*, *Filter*, *strides*, *padding*, *out_dtype*, *output_padding*) 转置的二维卷积 nchw 前向操作符。 * **参数:** - * **输入**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D,形状为[batch, in_channel, in_height, in_width]。 - * **过滤器**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 4–D,形状为[in_channel,num_filter,filter_height,filter_width]。 + * **输入**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D,形状为[batch, in_channel, in_height, in_width]。 + * **过滤器**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 4–D,形状为[in_channel,num_filter,filter_height,filter_width]。 * **strides**(*两个整数的元*[组](https://docs.python.org/3/library/stdtypes.html#tuple)):沿高度和宽度的空间步幅。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或*[str](https://docs.python.org/3/library/stdtypes.html#str)):填充大小,或 ['VALID', 'SAME']。 * **out_dtype** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ):输出数据类型。用于混合精度。 * **output_padding**(*整数元*[组](https://docs.python.org/3/library/stdtypes.html#tuple)):用于获取渐变的正确输出形状。 * **返回:Output** *:* 4–D,形状为 [batch, out_channel, out_height, out_width]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.conv2d_transpose_nchw_preprocess(*data*, *kernel*, *strides*, *padding*, *out_dtype*, *output_padding*) @@ -2672,121 +2672,121 @@ NHWC 布局中的卷积操作符。 NCHW 布局中的 Conv2D Winograd。这是一个干净的版本,可供 CPU 和 GPU 的自动调度程序使用。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))*:* 4–D,形状为[batch, in_channel, in_height, in_width]。 - * **权重**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D,形状为[filter_height,filter_width,in_channel,num_filter]。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))*:* 4–D,形状为[batch, in_channel, in_height, in_width]。 + * **权重**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D,形状为[filter_height,filter_width,in_channel,num_filter]。 * **strides**([int](https://docs.python.org/3/library/functions.html#int)*或两个 int的列表/元组*)*:* 步幅大小,或 [stride_height, stride_width]。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或*两个 int 的列表/元组):填充大小,或 [pad_height, pad_width]。 * **dilation**([int](https://docs.python.org/3/library/functions.html#int)或两个 int 的列表/元组):扩张大小,或 [dilation_height, dilation_width]。 * **out_dtype**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*):指定输出数据类型。 * **pre_computed** ( [bool](https://docs.python.org/3/library/functions.html#bool) ):内核是否预先计算。 * **auto_scheduler_rewritten_layout** ( *str = ""* )**:**自动调度程序布局重写传递后的布局。 - * **meta_schedule_original_shape** ( *Optional[List[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]]= None* ):输入张量的原始形状。 + * **meta_schedule_original_shape** ( *Optional[List[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]]= None* ):输入张量的原始形状。 * **返回:output**:4–D,形状为[batch, out_height, out_width, out_channel]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.conv2d_winograd_nchw_without_weight_transform(*data*, *weight*, *strides*, *padding*, *dilation*, *out_dtype*, *auto_scheduler_rewritten_layout=''*, *meta_schedule_original_shape=None*) 在 NCHW 布局中,Conv2D Winograd 无需布局变换。这是一个可供 CPU 和 GPU 元调度使用的干净版本。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D,形状为[batch, in_height, in_width, in_channel]。 - * **权重**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D,形状为[filter_height,filter_width,in_channel,num_filter]。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D,形状为[batch, in_height, in_width, in_channel]。 + * **权重**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D,形状为[filter_height,filter_width,in_channel,num_filter]。 * **strides**([int](https://docs.python.org/3/library/functions.html#int)*或两个 int***的列表/元组*)*:步幅大小,或 [stride_height, stride_width]。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或两个 int*的列表/元组*):填充大小,或 [pad_height, pad_width]。 - * **dilation**([int](https://docs.python.org/3/library/functions.html#int)*或**两个 int**的列表/元组*)[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)扩张大小,或 [dilation_height, dilation_width]。 + * **dilation**([int](https://docs.python.org/3/library/functions.html#int)*或**两个 int**的列表/元组*)[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)扩张大小,或 [dilation_height, dilation_width]。 * **out_dtype**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*)*:* 指定输出数据类型。 * **auto_scheduler_rewritten_layout** ( *str = ""* )*:*自动调度程序布局重写传递后的布局。 - * **meta_schedule_original_shape** ( *Optional[List[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]]= None* ):输入张量的原始形状。 -* **返回:output**[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)4–D,形状为[batch, out_height, out_width, out_channel]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 + * **meta_schedule_original_shape** ( *Optional[List[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]]= None* ):输入张量的原始形状。 +* **返回:output**[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)4–D,形状为[batch, out_height, out_width, out_channel]。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.conv2d_winograd_nhwc(*data*, *weight*, *strides*, *padding*, *dilation*, *out_dtype*, *pre_computed=False*, *auto_scheduler_rewritten_layout=''*, *meta_schedule_original_shape=None*) NHWC 布局中的 Conv2D Winograd。这是一个干净的版本,可供 CPU 和 GPU 的自动调度程序使用。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D,形状为[batch, in_height, in_width, in_channel]。 - * **权重**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 4–D,形状为[filter_height,filter_width,in_channel,num_filter]。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D,形状为[batch, in_height, in_width, in_channel]。 + * **权重**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 4–D,形状为[filter_height,filter_width,in_channel,num_filter]。 * **strides**([int](https://docs.python.org/3/library/functions.html#int)*或*两个 int*的列表/元组*)*:* 步幅大小,或 [stride_height, stride_width]。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或*两个 int*的列表/元组*):填充大小,或 [pad_height, pad_width]。 * **dilation**([int](https://docs.python.org/3/library/functions.html#int)*或*两个 int*的列表/元组*):扩张大小,或 [dilation_height, dilation_width]。 * **out_dtype**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*):指定输出数据类型。 * **pre_computed** ( [bool](https://docs.python.org/3/library/functions.html#bool) ):内核是否预先计算。 * **auto_scheduler_rewritten_layout** ( *str = ""* )*:* 自动调度程序布局重写传递后的布局。 - * **meta_schedule_original_shape** ( *Optional[List[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]]= None* ):输入张量的原始形状。 + * **meta_schedule_original_shape** ( *Optional[List[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]]= None* ):输入张量的原始形状。 * **返回:output**:4–D,形状为[batch, out_height, out_width, out_channel]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.conv2d_winograd_nhwc_without_weight_transform(*data*, *weight*, *strides*, *padding*, *dilation*, *out_dtype*, *auto_scheduler_rewritten_layout=''*, *meta_schedule_original_shape=None*) Conv2D Winograd 在 NHWC 布局中无需布局变换。这是一个干净的版本,可供 CPU 和 GPU 自动调度程序使用。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D,形状为[batch, in_height, in_width, in_channel]。 - * **权重**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:**4–D,形状为[filter_height,filter_width,in_channel,num_filter]。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D,形状为[batch, in_height, in_width, in_channel]。 + * **权重**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:**4–D,形状为[filter_height,filter_width,in_channel,num_filter]。 * **strides**([int](https://docs.python.org/3/library/functions.html#int)*或*两个 int*的列表/元组*):步幅大小,或 [stride_height, stride_width]。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或*两个 int*的列表/元组*)**:** 填充大小,或 [pad_height, pad_width]。 - * **dilation**([int](https://docs.python.org/3/library/functions.html#int)*或*两个 int*的列表/元组*)[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)扩张大小,或 [dilation_height, dilation_width]。 + * **dilation**([int](https://docs.python.org/3/library/functions.html#int)*或*两个 int*的列表/元组*)[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)扩张大小,或 [dilation_height, dilation_width]。 * **out_dtype**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*)*:* 指定输出数据类型。 * **auto_scheduler_rewritten_layout** ( *str = ""* ):自动调度程序布局重写传递后的布局。 - * **meta_schedule_original_shape** ( *Optional[List[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]]= None* ):输入张量的原始形状。 + * **meta_schedule_original_shape** ( *Optional[List[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]]= None* ):输入张量的原始形状。 * **返回:output**:4–D,形状为[batch, out_height, out_width, out_channel]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.conv2d_winograd_weight_transform(*kernel*, *tile_size*) winograd 的权重转换。 * **参数:** - * **核**([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)布局为「NCHW」的原始核张量。 + * **核**([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)布局为「NCHW」的原始核张量。 * **tile_size** ( [int](https://docs.python.org/3/library/functions.html#int) ):winograd 变换的 Tile 大小。例如,F(2x2, 3x3) 为 2,F(4x4, 3x3) 为 4。 * **返回:output**:4–D,形状为 [alpha, alpha, CO, CI]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.conv3d_ncdhw(*Input*, *Filter*, *stride*, *padding*, *dilation*, *groups*, *out_dtype=None*) NCDHW 布局中的 Conv3D 运算符。 * **参数:** - * **输入**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))***:*** 5–D,形状为[batch, in_channel, in_depth, in_height, in_width]。 - * **过滤器**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):5–D,形状为[num_filter,in_channel,filter_depth,filter_height,filter_width]。 + * **输入**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))***:*** 5–D,形状为[batch, in_channel, in_depth, in_height, in_width]。 + * **过滤器**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):5–D,形状为[num_filter,in_channel,filter_depth,filter_height,filter_width]。 * **stride**([int](https://docs.python.org/3/library/functions.html#int)*或*三个 int*的列表/元组*):步幅大小,或 [strid_depth, stride_height, stride_width]。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或*[str](https://docs.python.org/3/library/stdtypes.html#str)):填充大小,或 ['VALID', 'SAME']。 * **dilation**([int](https://docs.python.org/3/library/functions.html#int)*或*三个 int*的列表/元组*)*:* 扩张大小,或 [dilation_depth, dilation_height, dilation_width]。 - * **groups**([int](https://docs.python.org/3/library/functions.html#int))[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)组数。 + * **groups**([int](https://docs.python.org/3/library/functions.html#int))[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)组数。 * **返回:Output**:5–D,形状为[batch, out_channel, out_depth, out_height, out_width]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.conv3d_ndhwc(*Input*, *Filter*, *stride*, *padding*, *dilation*, *groups*, *out_dtype='float32'*, *auto_scheduler_rewritten_layout=''*, *meta_schedule_origin_shape=None*) NDHWC 布局中的卷积操作符。 * **参数:** - * **输入**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))*:* 5–D,形状为[batch, in_depth, in_height, in_width, in_channel]。 - * **过滤器**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):5–D,形状为[filter_depth,filter_height,filter_width,in_channel,num_filter]。 + * **输入**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))*:* 5–D,形状为[batch, in_depth, in_height, in_width, in_channel]。 + * **过滤器**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):5–D,形状为[filter_depth,filter_height,filter_width,in_channel,num_filter]。 * **stride**([int](https://docs.python.org/3/library/functions.html#int)*或**三个 int**的列表/元组*):步幅大小,或 [stride_depth, stride_height, stride_width]。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或*[str](https://docs.python.org/3/library/stdtypes.html#str)):填充大小,或 ['VALID', 'SAME']。 * **dilation**([int](https://docs.python.org/3/library/functions.html#int)*或**三个 int**的列表/元组*):扩张大小,或 [dilation_depth, dilation_height, dilation_width]。 * **groups**([int](https://docs.python.org/3/library/functions.html#int)):组数。 * out_dtype ( *str = "float32",* ):输出张量的类型。 * **auto_scheduler_rewritten_layout** ( *str = ""* ):自动调度程序布局重写传递后的布局。 - * **meta_schedule_origin_shape** ( *Optional[List[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]]= None* ):输入张量的原始形状。 + * **meta_schedule_origin_shape** ( *Optional[List[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]]= None* ):输入张量的原始形状。 * **返回:Output**:5–D,形状为 [batch, out_depth, out_height, out_width, out_channel]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.conv3d_transpose_ncdhw(*Input*, *Filter*, *strides*, *padding*, *out_dtype*, *output_padding*) 转置的3D 卷积 ncdhw 前向操作符。 * **参数:** - * **输入**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):5–D,形状为[batch, in_channel, in_depth, in_height, in_width]。 - * **过滤器**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):5–D,形状为[in_channel,num_filter,filter_depth,filter_height,filter_width]。 + * **输入**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):5–D,形状为[batch, in_channel, in_depth, in_height, in_width]。 + * **过滤器**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):5–D,形状为[in_channel,num_filter,filter_depth,filter_height,filter_width]。 * **strides**([int](https://docs.python.org/3/library/functions.html#int)*或**三个 int***的列表/元组):沿深度、高度和宽度的空间步幅。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或*[str](https://docs.python.org/3/library/stdtypes.html#str)):填充大小,或 ['VALID', 'SAME']。 * **out_dtype** ( [str](https://docs.python.org/3/library/stdtypes.html#str) )*:* 输出数据类型。用于混合精度。 * **output_padding**(*整数元*[组](https://docs.python.org/3/library/stdtypes.html#tuple)):用于获取渐变的正确输出形状。 * **返回:Output** :5–D,形状为[batch, out_channel, out_depth, out_height, out_width]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.conv3d_transpose_ncdhw_preprocess(*data*, *kernel*, *strides*, *padding*, *out_dtype*, *output_padding*) @@ -2798,17 +2798,17 @@ NDHWC 布局中的卷积操作符。 3D winograd 的权重变换。 * **参数:** - * **核**([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 布局为「NCDHW」的原始核张量。 + * **核**([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 布局为「NCDHW」的原始核张量。 * **tile_size** ( [int](https://docs.python.org/3/library/functions.html#int) ):winograd 变换的 Tile 大小。例如,F(2x2, 3x3) 为 2,F(4x4, 3x3) 为 4。 * **返回:output** :5–D,形状为 [alpha, alpha, alpha, CO, CI]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.correlation_nchw(*data1*, *data2*, *kernel_size*, *max_displacement*, *stride1*, *stride2*, *padding*, *is_multiply*) NCHW 布局中的相关运算符。 * **参数:** - * **data1** ( [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) ):4–D,形状为 [batch, channel, height, width]。 - * **data2** ( [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) )*:* 4–D,形状为 [batch, channel, height, width]。 + * **data1** ( [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ):4–D,形状为 [batch, channel, height, width]。 + * **data2** ( [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) )*:* 4–D,形状为 [batch, channel, height, width]。 * **kernel_size** ( [int](https://docs.python.org/3/library/functions.html#int) ):相关的核大小,必须是奇数。 * **max_displacement**([int](https://docs.python.org/3/library/functions.html#int))*:* 相关性的最大位移。 * **stride1**([int](https://docs.python.org/3/library/functions.html#int)):数据1的步幅。 @@ -2816,7 +2816,7 @@ NCHW 布局中的相关运算符。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或*2 个***或**4 个 int 的列表/元组*):填充大小,或 2 个 int 的 [pad_height, pad_width],或 4 个 int 的 [pad_top, pad_left, pad_bottom, pad_right]。 * **is_multiply** ( [bool](https://docs.python.org/3/library/functions.html#bool) ):运算类型是乘法或减法。 * **返回:Output** :4–D,形状为 [batch, out_channel, out_height, out_width]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.declaration_conv2d_transpose_impl(*data*, *kernel*, *strides*, *padding*, *out_dtype*, *output_padding*) @@ -2835,16 +2835,16 @@ NCHW 布局中的可变形 conv2D 运算符。 可变形卷积运算描述于[https://arxiv.org/abs/1703.06211](https://arxiv.org/abs/1703.06211)。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 4–D,形状为[batch, in_channel, in_height, in_width]。 - * **offset**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))***:*** 4–D,形状为 [batch, formable_groups filter_height filter_width * 2, out_height, out_width]。 - * **内核**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 4–D,形状为[num_filter,in_channel,filter_height,filter_width]。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 4–D,形状为[batch, in_channel, in_height, in_width]。 + * **offset**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))***:*** 4–D,形状为 [batch, formable_groups filter_height filter_width * 2, out_height, out_width]。 + * **内核**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 4–D,形状为[num_filter,in_channel,filter_height,filter_width]。 * **strides**([int](https://docs.python.org/3/library/functions.html#int)*或*两个 int*的列表/元组*):步幅大小,或 [stride_height, stride_width]。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或**两个 int***的列表/元组*):填充大小,或 [pad_height, pad_width]。 * **dilation**([int](https://docs.python.org/3/library/functions.html#int)*或*两个 int*的列表/元组*):扩张大小,或 [dilation_height, dilation_width]。 * **deformable_groups**([int](https://docs.python.org/3/library/functions.html#int)):可变形组的数量。 * **groups**([int](https://docs.python.org/3/library/functions.html#int)):组数。 * **返回:output** *:* 4–D,形状为[batch, out_channel, out_height, out_width]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.deformable_conv2d_nhwc(*data*, *offset*, *kernel*, *strides*, *padding*, *dilation*, *deformable_groups*, *groups*, *out_dtype*) @@ -2854,61 +2854,61 @@ NHWC 布局中的可变形 conv2D 运算符。 可变形卷积运算描述于[https://arxiv.org/abs/1703.06211](https://arxiv.org/abs/1703.06211)。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))*:*4–D,形状为[batch, in_height, in_width, in_channel]。 - * **偏移量**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) –4–D,形状为 [batch, out_height, out_width, 可变形组 * 过滤器高度 * 过滤器宽度 * 2]。 - * **内核**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))[:](https://docs.python.org/3/library/functions.html#int)4–D,形状为[filter_height,filter_width,in_channel,num_filter]。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))*:*4–D,形状为[batch, in_height, in_width, in_channel]。 + * **偏移量**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) –4–D,形状为 [batch, out_height, out_width, 可变形组 * 过滤器高度 * 过滤器宽度 * 2]。 + * **内核**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))[:](https://docs.python.org/3/library/functions.html#int)4–D,形状为[filter_height,filter_width,in_channel,num_filter]。 * **strides**([int](https://docs.python.org/3/library/functions.html#int)*或*两个 int*的列表/元组*):步幅大小,或 [stride_height, stride_width]。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或*两个 int*的列表/元组*):填充大小,或 [pad_height, pad_width]。 * **dilation**([int](https://docs.python.org/3/library/functions.html#int)*或*两个 int*的列表/元组*):扩张大小,或 [dilation_height, dilation_width]。 * **deformable_groups**([int](https://docs.python.org/3/library/functions.html#int)):可变形组的数量。 * **groups**([int](https://docs.python.org/3/library/functions.html#int)):组数。 * **返回:output** :4–D,形状为[batch, out_height, out_width, out_channel]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.dense(*data*, *weight*, *bias=None*, *out_dtype=None*, *auto_scheduler_rewritten_layout=''*, *meta_schedule_original_shape=None*) topi 中致密的默认实现。这是 matmul_nt 运算符的别名,用于非转置格式的数据张量和转置格式的权重张量。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:**二维,形状为[batch, in_dim]。 - * **权重**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))*:*形状为[out_dim,in_dim]的二维。 - * *偏差*(*可选*[ [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*]*):形状为 [out_dim] 的一维。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:**二维,形状为[batch, in_dim]。 + * **权重**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))*:*形状为[out_dim,in_dim]的二维。 + * *偏差*(*可选*[ [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*]*):形状为 [out_dim] 的一维。 * *out_dtype*(*可选*[ [str](https://docs.python.org/3/library/stdtypes.html#str)*]*):输出类型。用于混合精度。 * **auto_scheduler_rewritten_layout** ( *str = ""* ):自动调度程序布局重写传递后的布局。 - * **meta_schedule_original_shape** ( *Optional[List[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]]= None* ):输入张量的原始形状。 + * **meta_schedule_original_shape** ( *Optional[List[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]]= None* ):输入张量的原始形状。 * **返回:output** *:* 二维,形状为 [batch, out_dim]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.dense_pack(*data*, *weight*, *bias=None*, *out_dtype=None*) topi 中 dense_pack 的默认实现。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):二维,形状为[batch, in_dim]。 - * **权重**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):形状为[out_dim,in_dim]的二维。 - * *偏差*(*可选*[ [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*]*):形状为 [out_dim] 的一维。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):二维,形状为[batch, in_dim]。 + * **权重**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):形状为[out_dim,in_dim]的二维。 + * *偏差*(*可选*[ [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*]*):形状为 [out_dim] 的一维。 * *out_dtype*(*可选*[ [str](https://docs.python.org/3/library/stdtypes.html#str)*]*):输出类型。用于混合精度。 * **返回:output** :二维,形状为 [batch, out_dim]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.depth_to_space(*data*, *block_size*, *layout='NCHW'*, *mode='DCR'*) 对数据进行深度到空间的变换。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):NCHW 或 NHWC 布局中的 4–D 张量。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):NCHW 或 NHWC 布局中的 4–D 张量。 * **block_size** ( [int](https://docs.python.org/3/library/functions.html#int) )[:](https://docs.python.org/3/library/stdtypes.html#str)从通道维度组成的块的大小。 * **布局**(*字符串*):NCHW 或 NHWC,表示数据布局。 * **模式**(*字符串*):DCR 或 CDR,指示应如何访问通道。在 DCR 中,通道以 TensorFlow 风格交织,而在 CDR 中,通道以 Pytorch 风格顺序访问。 * **返回:output** :形状输出[N,C / block_size**2,H * block_size,W * block_size]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.depthwise_conv2d_NCHWc(*Input*, *Filter*, *stride*, *padding*, *dilation*, *layout*, *out_layout*, *out_dtype=None*) 深度卷积 NCHW[x]c 前向操作符。 * **参数:** - * **输入**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):5–D,形状为[batch,in_channel_chunk,in_height,in_width,in_channel_block]。 - * **过滤器**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):6维,形状为[out_channel_chunk,1,filter_height,filter_width,1,out_channel_block]。在 NCHWc 深度卷积中,我们将内核的 in_channel 和 channel_multiplier 组合在一起,然后进行平铺。 + * **输入**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):5–D,形状为[batch,in_channel_chunk,in_height,in_width,in_channel_block]。 + * **过滤器**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):6维,形状为[out_channel_chunk,1,filter_height,filter_width,1,out_channel_block]。在 NCHWc 深度卷积中,我们将内核的 in_channel 和 channel_multiplier 组合在一起,然后进行平铺。 * **stride**(*两个整数的元*[组](https://docs.python.org/3/library/stdtypes.html#tuple)):沿高度和宽度的空间步幅。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或*[str](https://docs.python.org/3/library/stdtypes.html#str)):填充大小,或 ['VALID', 'SAME']。 * **dilation**([int](https://docs.python.org/3/library/functions.html#int)*或*两个 int*的列表/元组*):扩张大小,或 [dilation_height, dilation_width]。 @@ -2916,76 +2916,76 @@ topi 中 dense_pack 的默认实现。 * **out_layout** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ):输出数据布局。 * **out_dtype**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*):输出数据类型。 * **返回:Output** **:** 5–D,形状为[batch, out_channel_chunk, out_height, out_width, out_channel_block]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.depthwise_conv2d_backward_input_nhwc(*Filter*, *Out_grad*, *oshape*, *ishape*, *stride*, *padding*) 深度卷积 nhwc 后向 wrt 输入运算符。 * **参数:** - * **过滤器**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D,形状为[filter_height,filter_width,in_channel,channel_multiplier]。 - * **Out_grad** ( [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) ):4–D,形状为 [batch, out_height, out_width, out_channel]。 + * **过滤器**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D,形状为[filter_height,filter_width,in_channel,channel_multiplier]。 + * **Out_grad** ( [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ):4–D,形状为 [batch, out_height, out_width, out_channel]。 * **stride**(*两个整数的元*[组](https://docs.python.org/3/library/stdtypes.html#tuple))*:* 沿高度和宽度的空间步幅。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或*[str](https://docs.python.org/3/library/stdtypes.html#str)):填充大小,或 ['VALID', 'SAME']。 * **返回:Output** :4–D,形状为 [batch, in_height, in_width, in_channel]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.depthwise_conv2d_backward_weight_nhwc(*Input*, *Out_grad*, *oshape*, *fshape*, *stride*, *padding*) 深度卷积 nhwc 后向 wrt 权重运算符。 * **参数:** - * **输入**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D,形状为[batch, in_height, in_width, in_channel]。 - * **Out_grad** ( [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) )***:*** 4–D,形状为 [batch, out_height, out_width, out_channel]。 + * **输入**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D,形状为[batch, in_height, in_width, in_channel]。 + * **Out_grad** ( [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) )***:*** 4–D,形状为 [batch, out_height, out_width, out_channel]。 * **stride**(*两个整数的元*[组](https://docs.python.org/3/library/stdtypes.html#tuple)):沿高度和宽度的空间步幅。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或*[str](https://docs.python.org/3/library/stdtypes.html#str)):填充大小,或 ['VALID', 'SAME']。 -* **返回:Output** [:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)4–D,形状为 [filter_height, filter_width, in_channel, channel_multiplier]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回:Output** [:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)4–D,形状为 [filter_height, filter_width, in_channel, channel_multiplier]。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.depthwise_conv2d_nchw(*Input*, *Filter*, *stride*, *padding*, *dilation*, *out_dtype=None*) 深度卷积 nchw 前向操作符。 * **参数:** - * **输入**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D,形状为[batch, in_channel, in_height, in_width]。 - * **过滤器**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D,形状为[in_channel, channel_multiplier, filter_height, filter_width]。 + * **输入**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D,形状为[batch, in_channel, in_height, in_width]。 + * **过滤器**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D,形状为[in_channel, channel_multiplier, filter_height, filter_width]。 * **stride** ([int](https://docs.python.org/3/library/functions.html#int)*ora list/tupleoftwo ints*) *:* **stride**([int](https://docs.python.org/3/library/functions.html#int)*或*两个 int*的列表/元组*):空间步幅,或 (stride_height, stride_width)。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或*[str](https://docs.python.org/3/library/stdtypes.html#str))**:** 填充大小,或 ['VALID', 'SAME']。 * **dilation**([int](https://docs.python.org/3/library/functions.html#int)*或*两个 int*的列表/元组*):扩张大小,或 [dilation_height, dilation_width]。 * **out_dtype**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*)*:* 输出数据类型。 * **返回:Output** *:* 4–D,形状为 [batch, out_channel, out_height, out_width]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.depthwise_conv2d_nhwc(*Input*, *Filter*, *stride*, *padding*, *dilation*, *kernel_layout='HWOI'*, *out_dtype=None*) 深度卷积 nhwc 前向操作符。 * **参数:** - * **输入**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D,形状为[batch, in_height, in_width, in_channel]。 - * **过滤器**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))*:* 4–D,形状为[filter_height,filter_width,in_channel,channel_multiplier]。 + * **输入**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D,形状为[batch, in_height, in_width, in_channel]。 + * **过滤器**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))*:* 4–D,形状为[filter_height,filter_width,in_channel,channel_multiplier]。 * **stride**(*两个整数的元*[组](https://docs.python.org/3/library/stdtypes.html#tuple)):沿高度和宽度的空间步幅。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或*[str](https://docs.python.org/3/library/stdtypes.html#str)):填充大小,或 ['VALID', 'SAME']。 * **dilation**([int](https://docs.python.org/3/library/functions.html#int)*或*两个 int*的列表/元组*)*:* 扩张大小,或 [dilation_height, dilation_width]。 * **out_dtype**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*):输出数据类型。 * **返回:Output** *:* 4–D,形状为 [batch, out_height, out_width, out_channel]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.dilate(*data*, *strides*, *dilation_value=0.0*, *name='DilatedInput'*) 使用给定的扩张值(默认为 0)扩张数据。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):nD,可以是任何布局。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):nD,可以是任何布局。 * **strides**(*n 个整数**的**列表/元组*):每个维度上的扩张步幅,1 表示无扩张。 * dilation_value(int/float,*可选*):用于扩大输入的值。 * **name**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*):生成的名称前缀运算符。 -* **返回:Output** [:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)nD,与数据相同的布局。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回:Output** [:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)nD,与数据相同的布局。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.equal_const_int(*expr*, *value*) 如果 expr 等于 value,则返回。 -* **参数:expr** (*tvm.Expr*) [:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)输入表达式。 +* **参数:expr** (*tvm.Expr*) [:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)输入表达式。 * **返回:equal** **:** 是否相等。 * **返回类型:**[bool](https://docs.python.org/3/library/functions.html#bool)。 @@ -2994,10 +2994,10 @@ topi 中 dense_pack 的默认实现。 对数据执行 softmax 激活。使用近似值计算指数可以提高速度。 * **参数:** - * **x** ( [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) ):可以是任意维度。 + * **x** ( [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ):可以是任意维度。 * **axis**([int](https://docs.python.org/3/library/functions.html#int)):通道轴。 * **返回:output** :输出形状与输入相同。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.fifo_buffer(*data*, *buffer*, *axis*) @@ -3020,19 +3020,19 @@ concat(buffer, data, axis=axis) * 在滑动窗口输入上操作的卷积操作中,对计算的显式重用进行编码。 * 实现 FIFO 队列来缓存中间结果,例如在 Fast WaveNet 中。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入数据。 - * **buffer**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):FIFO 缓冲区的先前值。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入数据。 + * **buffer**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):FIFO 缓冲区的先前值。 * **axis** ( [int](https://docs.python.org/3/library/functions.html#int) ):指定应该使用哪个轴进行缓冲。 * **返回:result** *:* 缓冲区的更新值。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.flatten(*data*) 通过折叠较高维度将输入数组展平为二维数组。 -* **参数:data** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) :输入数组。 -* **返回:output** [:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)具有折叠高维的二维数组。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **参数:data** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) :输入数组。 +* **返回:output** [:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)具有折叠高维的二维数组。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.get_const_int(*expr*) @@ -3106,7 +3106,7 @@ concat(buffer, data, axis=axis) 应用填充后计算张量的输出形状。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):应用填充的输入张量。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):应用填充的输入张量。 * **pad_before** *:* n 个整数的列表/元组,在每个维度上填充宽度以在轴开始之前进行填充。 * **pad_after**:n 个整数的列表/元组,可选填充宽度,每个维度在轴端后进行填充。 * **抛出:**[ValueError](https://docs.python.org/3/library/exceptions.html#ValueError):如果 pad_before 或 pad_after 长度与数据维度不匹配。 @@ -3121,19 +3121,19 @@ concat(buffer, data, axis=axis) 它根据布局字符串决定高度和宽度尺寸,其中「W」和「H」分别表示宽度和高度。宽度和高度尺寸不能拆分。例如,NCHW、NCHW16c 等适用于池,而 NCHW16w、NCHW16h 则不适用。有关布局字符串约定的更多信息,请参阅参数布局。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):具有布局形状的 nD。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):具有布局形状的 nD。 * **pool_type** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ):池类型,“max”或“avg”。 * **layout** ( [str](https://docs.python.org/3/library/stdtypes.html#str) )*:* 输入数据的布局。布局应该由大写字母、小写字母和数字组成,其中大写字母表示维度,对应的小写字母(因子大小)表示分割维度。例如,NCHW16c 可以描述一个 5 维张量,其值为 [batch_size, channel, height, width, channel_block],其中 channel_block=16 表示对 channel 维度的分割。 * **返回:output** :nD 采用相同的布局,高度和宽度尺寸为 1。例如,对于 NCHW,输出形状将为 [batch, channel, 1, 1]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.group_conv1d_ncw(*data*, *kernel*, *strides=1*, *padding='VALID'*, *dilation=1*, *groups=1*, *out_dtype=None*) 用于 NCW 布局的一维卷积前向操作符。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))*:* 三维,形状为[batch, in_channel, in_width]。 - * **内核**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):形状为[num_filter,in_channel,filter_size]的 3–D。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))*:* 三维,形状为[batch, in_channel, in_width]。 + * **内核**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):形状为[num_filter,in_channel,filter_size]的 3–D。 * **strides**([int](https://docs.python.org/3/library/functions.html#int)*或*[tuple](https://docs.python.org/3/library/stdtypes.html#tuple)):沿宽度的空间步幅。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*、*[tuple](https://docs.python.org/3/library/stdtypes.html#tuple)*或*[str](https://docs.python.org/3/library/stdtypes.html#str)):填充大小可以是相等填充的整数、(左、右)的元组或 ['VALID', 'SAME'] 中的字符串。 * **dilation**([整数](https://docs.python.org/3/library/functions.html#int)*或*[元组](https://docs.python.org/3/library/stdtypes.html#tuple)):如果卷积需要扩张,则扩张率。 @@ -3145,8 +3145,8 @@ concat(buffer, data, axis=axis) 用于 NWC 布局的一维卷积前向操作符。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):三维,形状为[batch, in_width, in_channel]。 - * **内核**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):3–D,形状为[filter_size,in_channel,num_filter]。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):三维,形状为[batch, in_width, in_channel]。 + * **内核**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):3–D,形状为[filter_size,in_channel,num_filter]。 * **strides**([int](https://docs.python.org/3/library/functions.html#int)*或*[tuple](https://docs.python.org/3/library/stdtypes.html#tuple))*:* 沿宽度的空间步幅。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*、*[tuple](https://docs.python.org/3/library/stdtypes.html#tuple)*或*[str](https://docs.python.org/3/library/stdtypes.html#str)):填充大小可以是相等填充的整数、(左、右)的元组或 ['VALID', 'SAME'] 中的字符串。 * **dilation**([整数](https://docs.python.org/3/library/functions.html#int)*或*[元组](https://docs.python.org/3/library/stdtypes.html#tuple)):如果卷积需要扩张,则扩张率。 @@ -3157,8 +3157,8 @@ concat(buffer, data, axis=axis) 转置的一维组卷积 ncw 前向操作符。 - * **参数:数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)三维,形状为[batch, in_channel, in_width]。 - * **内核**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))*:* 3–D,形状为[in_channel,num_filter,filter_width]。 + * **参数:数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)三维,形状为[batch, in_channel, in_width]。 + * **内核**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))*:* 3–D,形状为[in_channel,num_filter,filter_width]。 * **步幅**(*ints*):沿宽度的空间步幅。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或*[str](https://docs.python.org/3/library/stdtypes.html#str)):填充大小,或 ['VALID', 'SAME']。 * **out_dtype** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ):输出数据类型。用于混合精度。 @@ -3168,82 +3168,82 @@ concat(buffer, data, axis=axis) 组数 * **返回:output** :3–D,形状为[batch, out_channel, out_width]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.group_conv2d_nchw(*Input*, *Filter*, *stride*, *padding*, *dilation*, *groups*, *out_dtype=None*) NCHW 布局中的组卷积操作符。 * **参数:** - * **输入**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D,形状为[batch, in_channel, in_height, in_width]。 - * **过滤器**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D,形状为[num_filter,in_channel // groups,filter_height,filter_width]。 + * **输入**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D,形状为[batch, in_channel, in_height, in_width]。 + * **过滤器**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D,形状为[num_filter,in_channel // groups,filter_height,filter_width]。 * **stride**([int](https://docs.python.org/3/library/functions.html#int)*或*两个 int*的列表/元组*):步幅大小,或 [stride_height, stride_width]。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或*2 个*或4 个 int*的列表/元组):填充大小,或 2 个 int 的 [pad_height, pad_width],或 4 个 int 的 [pad_top, pad_left, pad_bottom, pad_right]。 * **dilation**([int](https://docs.python.org/3/library/functions.html#int)*或*两个 int*的列表/元组)**:** 扩张大小,或 [dilation_height, dilation_width]。 * **groups**([int](https://docs.python.org/3/library/functions.html#int)):组数。 * **out_dtype** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ):输出类型。用于混合精度。 * **返回:Output** :4–D,形状为 [batch, out_channel, out_height, out_width]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.group_conv2d_nhwc(*Input*, *Filter*, *stride*, *padding*, *dilation*, *groups*, *out_dtype=None*) NHWC 布局中的组卷积操作符。 * **参数:** - * **输入**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D,形状为[batch, in_height, in_width, in_channel, …]。 - * **过滤器**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D,形状为[filter_height,filter_width,in_channel // groups,num_filter]。 + * **输入**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D,形状为[batch, in_height, in_width, in_channel, …]。 + * **过滤器**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D,形状为[filter_height,filter_width,in_channel // groups,num_filter]。 * **stride**([int](https://docs.python.org/3/library/functions.html#int)*或*两个 int*的列表/元组*):步幅大小,或 [stride_height, stride_width]。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或* 2 个*或* 4 个 int*的列表/元组*):填充大小,或 2 个 int 的 [pad_height, pad_width],或 4 个 int 的 [pad_top, pad_left, pad_bottom, pad_right]。 * **dilation**([int](https://docs.python.org/3/library/functions.html#int)*或*两个 int*的列表/元组*):扩张大小,或 [dilation_height, dilation_width]。 * **groups**([int](https://docs.python.org/3/library/functions.html#int)):组数。 * **out_dtype** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ):输出类型。用于混合精度。 * **返回:Output** *:* 4–D,形状为 [batch, out_height, out_width, out_channel]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.group_conv2d_transpose_nchw(*data*, *kernel*, *stride*, *padding*, *out_dtype*, *output_padding*, *groups*) NCHW 布局中的组卷积操作符。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 4–D,形状为[batch, in_channel, in_height, in_width]。 - * **内核**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 4–D,形状为[in_channel,out_channel // groups,filter_height,filter_width]。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 4–D,形状为[batch, in_channel, in_height, in_width]。 + * **内核**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 4–D,形状为[in_channel,out_channel // groups,filter_height,filter_width]。 * **stride**([int](https://docs.python.org/3/library/functions.html#int)*或*两个 int*的列表/元组*):步幅大小,或 [stride_height, stride_width]。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或*2 个***或**4 个 int*的列表/元组):填充大小,或 2 个 int 的 [pad_height, pad_width],或 4 个 int 的 [pad_top, pad_left, pad_bottom, pad_right]。 * **out_dtype** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ):输出数据类型。用于混合精度。 * **output_padding**(*整数元*[组](https://docs.python.org/3/library/stdtypes.html#tuple)):用于获取渐变的正确输出形状。 * **groups**([int](https://docs.python.org/3/library/functions.html#int)):组数。 - * **out_dtype**[:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)输出类型。用于混合精度。 + * **out_dtype**[:](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)输出类型。用于混合精度。 * **返回:Output** :4–D,形状为 [batch, out_channel, out_height, out_width]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.group_conv3d_transpose_ncdhw(*data*, *kernel*, *strides*, *padding*, *out_dtype*, *output_padding*, *groups*) 转置组3D 卷积 ncdhw 前向操作符。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):5–D,形状为[batch,in_channel,in_depth,in_height,in_width]。 - * **内核**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))*:* 5–D,形状为[in_channel,num_filter,filter_depth,filter_height,filter_width]。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):5–D,形状为[batch,in_channel,in_depth,in_height,in_width]。 + * **内核**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))*:* 5–D,形状为[in_channel,num_filter,filter_depth,filter_height,filter_width]。 * **strides**([int](https://docs.python.org/3/library/functions.html#int)*或*三个 int*的列表/元组*):沿深度、高度和宽度的空间步幅。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或*[str](https://docs.python.org/3/library/stdtypes.html#str))**:** 填充大小,或 ['VALID', 'SAME']。 * **out_dtype** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ):输出数据类型。用于混合精度。 * **output_padding**(*整数元*[组](https://docs.python.org/3/library/stdtypes.html#tuple)):用于获取渐变的正确输出形状。 * **groups**([int](https://docs.python.org/3/library/functions.html#int)):组数。 * **返回:Output** :5–D,形状为[batch, out_channel, out_depth, out_height, out_width]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.if_then_else(*cond*, *t*, *f*, *span=None*) 条件选择表达式。 * **参数:** - * **cond** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) )[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)条件。 - * **t** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):如果 cond 为真,则结果表达式。 - * **f** ( [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) ):如果 cond 为假,则结果表达式。 - * *span*(可选[ [Span](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Span)*]*):此运算符在源中的位置。 + * **cond** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) )[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)条件。 + * **t** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):如果 cond 为真,则结果表达式。 + * **f** ( [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) ):如果 cond 为假,则结果表达式。 + * *span*(可选[ [Span](/docs/api-reference/python-api/tvm-ir#class-tvmirspansource_name-line-end_line-column-end_column)*]*):此运算符在源中的位置。 * **返回:result** :条件表达式的结果。 -* **返回类型:**[Node](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Node)。 +* **返回类型:**[Node](/docs/api-reference/python-api/tvm-ir#class-tvmirnode)。 -:::Note +:::note 与 Select 不同,if_then_else 不会执行不满足条件的分支。您可以使用它来防止越界访问。与 Select 不同,如果向量中某些通道的条件不同,则 if_then_else 无法进行向量化。 @@ -3253,20 +3253,20 @@ NCHW 布局中的组卷积操作符。 取输入 x 的 leaky relu。 * **参数:** - * **x**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))–输入参数。 + * **x**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))–输入参数。 * **alpha**([float](https://docs.python.org/3/library/functions.html#float))*:* x < 0 时小梯度的斜率。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.log_softmax(*x*, *axis=-1*) 对数据执行对数 softmax 激活。 * **参数:** - * **x**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):ND 输入数据。 + * **x**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):ND 输入数据。 * **axis**([int](https://docs.python.org/3/library/functions.html#int))[:](https://docs.python.org/3/library/functions.html#int)通道轴。 * **返回:output** :具有相同形状的 ND 输出。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.lrn(*data*, *size*, *axis=1*, *alpha=0.0001*, *beta=0.75*, *bias=2*) @@ -3276,66 +3276,66 @@ NCHW 布局中的组卷积操作符。 sum_sqr_up^i{x, y} = (bias+((alpha/size)* {sum_{j=max(0, i-size/2)}^{min(N-1,i+size/2)} (data^j{x,y})^2}))^beta output^i{x, y} = data^i{x, y}/sum_sqr_up^i{x, y} N 是输入通道数。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 4–D,形状为[批次,通道,高度,宽度]。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 4–D,形状为[批次,通道,高度,宽度]。 * **size**([int](https://docs.python.org/3/library/functions.html#int)):标准化窗口大小。 * **axis**([int](https://docs.python.org/3/library/functions.html#int))**:** 输入数据布局通道轴默认值为 1(对于 NCHW 格式)。 * **偏差**([浮点型](https://docs.python.org/3/library/functions.html#float)):避免除以 0 的偏移量。 * **alpha**([浮点数](https://docs.python.org/3/library/functions.html#float)):待除。 * **beta**([浮点数](https://docs.python.org/3/library/functions.html#float)):指数。 * **返回:output** :具有相同形状的 4–D 输出。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.lstm(*Xs*, *Wi*, *Wh*, *Bi=None*, *Bh=None*, *h_init=None*, *c_init=None*, *proj=None*, *p_i=None*, *p_f=None*, *p_o=None*, *f_act=*, *g_act=*, *h_act=*, *reverse=False*, *weight_layout: str = 'IFGO'*) 使用 TE 扫描实现的通用 LSTM。 * **参数:** - * **Xs**([te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):形状为(seq_len、batch_size、in_dim)的输入序列。 - * **Wi** ( [te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) ):输入权重矩阵,形状为(4 * hidden_​​dim, in_dim)。权重根据 weight_layout 进行打包。 - * **Wh** ( [te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) ):隐藏权重矩阵,形状为(4 * hidden_​​dim, hidden_​​dim 或 proj_dim)。打包为 Wh。 - * **Bi** ( [te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*,可选*):输入偏差,形状为(4 * hidden_​​dim,),默认为 None 。打包为 Wh。 - * **Bh**([te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*,可选*):形状为 Bi 的隐藏偏差,默认为 None 。打包为 Wh。 - * **h_init** ( [te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*,可选*):初始隐藏状态,形状为(batch_size, hidden_​​dim 或 proj_dim),若为 None 则为零。 - * **c_init** ( [te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*,可选*)*:* 初始单元状态,形状与 h_init 相同,若为 None 则为零。 - * **proj** ( [te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*,可选*)[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)形状为(proj_dim, hidden_​​dim)的投影矩阵,默认为 None。 - * **p_i** ( [te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*,可选*):形状为(batch_size, hidden_​​dim)的 Peephole LSTM 矩阵,默认为 None。 - * **p_f** ( [te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*,可选*)*:* 形状为(batch_size, hidden_​​dim)的 Peephole LSTM 矩阵,默认为 None。 - * **p_o** ( [te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*,可选*):形状为(batch_size, hidden_​​dim)的 Peephole LSTM 矩阵,默认为 None。 + * **Xs**([te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):形状为(seq_len、batch_size、in_dim)的输入序列。 + * **Wi** ( [te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ):输入权重矩阵,形状为(4 * hidden_​​dim, in_dim)。权重根据 weight_layout 进行打包。 + * **Wh** ( [te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ):隐藏权重矩阵,形状为(4 * hidden_​​dim, hidden_​​dim 或 proj_dim)。打包为 Wh。 + * **Bi** ( [te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*,可选*):输入偏差,形状为(4 * hidden_​​dim,),默认为 None 。打包为 Wh。 + * **Bh**([te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*,可选*):形状为 Bi 的隐藏偏差,默认为 None 。打包为 Wh。 + * **h_init** ( [te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*,可选*):初始隐藏状态,形状为(batch_size, hidden_​​dim 或 proj_dim),若为 None 则为零。 + * **c_init** ( [te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*,可选*)*:* 初始单元状态,形状与 h_init 相同,若为 None 则为零。 + * **proj** ( [te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*,可选*)[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)形状为(proj_dim, hidden_​​dim)的投影矩阵,默认为 None。 + * **p_i** ( [te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*,可选*):形状为(batch_size, hidden_​​dim)的 Peephole LSTM 矩阵,默认为 None。 + * **p_f** ( [te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*,可选*)*:* 形状为(batch_size, hidden_​​dim)的 Peephole LSTM 矩阵,默认为 None。 + * **p_o** ( [te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*,可选*):形状为(batch_size, hidden_​​dim)的 Peephole LSTM 矩阵,默认为 None。 * *f_act**(*F*,*可选*):门激活函数。 * **g_act** (*F,optional*) *:* *g_act**(*F*,*可选*):门激活函数。 * **h_act** (*F,optional*) : *h_act**(*F*,*可选*)*:* 门激活函数。 * **reverse**([bool](https://docs.python.org/3/library/functions.html#bool)*,可选*):是否反向处理 X,默认为 False。 * **weight_layout**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*):门控的打包权重布局,默认为“IFGO”。注意:I = 输入,F = 遗忘,G = 单元,O = 输出。 * **返回:result** *:* 隐藏状态的元组(形状为(seq_len, batch_size, hidden_​​dim 或 proj_dim))和单元状态(形状为(seq_len, batch_size, hidden_​​dim))。 -* **返回类型:**[te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor), [te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor), [te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.matmul(*tensor_a*, *tensor_b*, *bias=None*, *out_dtype=None*, *transpose_a=False*, *transpose_b=False*, *auto_scheduler_rewritten_layout=''*, *meta_schedule_original_shape=None*) topi 中 matmul 的默认实现。 * **参数:** - * **tensor_a** ( [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) ):二维,形状为 [batch, in_dim]。 - * **tensor_b** ( [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) ):二维,形状为 [out_dim, in_dim]。 - * *偏差**(*可选**[ [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*]*)*:* 形状为 [out_dim] 的一维 + * **tensor_a** ( [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ):二维,形状为 [batch, in_dim]。 + * **tensor_b** ( [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ):二维,形状为 [out_dim, in_dim]。 + * *偏差**(*可选**[ [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*]*)*:* 形状为 [out_dim] 的一维 * *out_dtype**(*可选**[ [str](https://docs.python.org/3/library/stdtypes.html#str)*]*)*:* 输出类型。用于混合精度。 - * *transpose_a**(*可选**[ [bool](https://docs.python.org/3/library/functions.html#bool)*]= False*)[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)tensor_a 是否为转置格式。 + * *transpose_a**(*可选**[ [bool](https://docs.python.org/3/library/functions.html#bool)*]= False*)[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)tensor_a 是否为转置格式。 * *transpose_b**(*可选**[ [bool](https://docs.python.org/3/library/functions.html#bool)*]= False*):tensor_b 是否为转置格式。 * *auto_scheduler_rewritten_layout**(*可选**[ [str](https://docs.python.org/3/library/stdtypes.html#str)*]= ""*):自动调度程序布局重写传递后的布局。 - * **meta_schedule_original_shape** ( *Optional[List[*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)*]]= None* ):输入张量的原始形状。 + * **meta_schedule_original_shape** ( *Optional[List[*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)*]]= None* ):输入张量的原始形状。 * **返回:output** :二维,形状为 [batch, out_dim]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.mirror_pad(*data*, *pad_before*, *pad_after=None*, *mode='SYMMETRIC'*, *name='MirrorPadInput'*) 具有对称或反射功能的镜像平板输入。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):nD 输入,可以是任何布局。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):nD 输入,可以是任何布局。 * **pad_before**(*n 个整数的列表/元组*):在每个维度上填充宽度以在轴开始之前进行填充。 * *pad_after**(*n 个整数**的**列表/元组*,可选):填充每个维度的宽度以填充轴端之后。 * **mode**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*):镜像填充的类型。必须为 SYMMETRIC 或 REFLECT。 * **name**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*)*:* 生成的名称前缀运算符。 -* **返回:Output** [:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)nD,与输入相同的布局。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回:Output** [:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)nD,与输入相同的布局。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.namedtuple(*typename*, *field_names*, ***, *rename=False*, *defaults=None*, *module=None*) @@ -3377,26 +3377,26 @@ p = 预测{n,t,i_1,i_2,i_k} w = 权重{n,i_1,i_2,…,i_k} 如果 结果 = 减少(输出)。 * **参数:** - * **预测**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):(k + 2)–D,形状为(N,C,d_1,d_2,…,d_k),其中 C 是目标类别的数量。 - * **目标**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))*:* 形状为(n,d_1,d_2,…,d_k)的(k + 1)–D 输入的目标值。 - * **权重**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):形状为(C,)的 1–D 每个目标值的权重。 + * **预测**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):(k + 2)–D,形状为(N,C,d_1,d_2,…,d_k),其中 C 是目标类别的数量。 + * **目标**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))*:* 形状为(n,d_1,d_2,…,d_k)的(k + 1)–D 输入的目标值。 + * **权重**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):形状为(C,)的 1–D 每个目标值的权重。 * **reduction**(*字符串*)**:** 应用于输出的缩减方法。可以是“mean”、“sum”或“none”。 * **ignore_index** ( [int](https://docs.python.org/3/library/functions.html#int) ):要忽略的目标值。 * **返回:output** :如果约简类型为“平均值”或“总和”,则为标量,否则与目标形状相同。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.pad(*data*, *pad_before*, *pad_after=None*, *pad_value=0.0*, *name='PadInput'*, *attrs=None*) 使用 pad 值的 Pad 输入。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):nD 输入,可以是任何布局。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):nD 输入,可以是任何布局。 * **pad_before**(*n 个整数的*列表/元组):在每个维度上填充宽度以在轴开始之前进行填充。 * *pad_after*(n 个整数**的列表/元组**,*可选*):填充每个维度的宽度以填充轴端之后。 * **pad_value**([float](https://docs.python.org/3/library/functions.html#float)*,可选*):要填充的值。 * **name**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*):生成的名称前缀运算符。 -* **返回:Output** [:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)nD,与输入相同的布局。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回:Output** [:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)nD,与输入相同的布局。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.pool1d(*data*, *kernel*, *stride*, *dilation*, *padding*, *pool_type*, *ceil_mode=False*, *layout='NCW'*, *count_include_pad=True*) @@ -3406,7 +3406,7 @@ p = 预测{n,t,i_1,i_2,i_k} w = 权重{n,i_1,i_2,…,i_k} 如果 宽度轴根据布局字符串确定。其中“w”表示宽度。宽度维度不可拆分。例如,NCW、NCW16c 等适用于池,而 NCW16w 则不适用。有关布局字符串约定的更多信息,请参阅参数布局。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):具有布局形状的 nD。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):具有布局形状的 nD。 * **kernel**(*一个 int**或***[int](https://docs.python.org/3/library/functions.html#int)***的****列表/元组*):内核大小,[kernel_width]。 * **stride**(*一个 int**或***[int](https://docs.python.org/3/library/functions.html#int)***的****列表/元组*):步幅大小,[stride_width]。 * **dilation**(*两个整数**的***列表/元组*):扩张大小,[dilation_height,dilation_width]。 @@ -3416,7 +3416,7 @@ p = 预测{n,t,i_1,i_2,i_k} w = 权重{n,i_1,i_2,…,i_k} 如果 * **layout**(*字符串*):输入数据的布局。布局应该由大写字母、小写字母和数字组成,其中大写字母表示维度,对应的小写字母(因子大小)表示分割维度。例如,NCW16c 可以描述一个 [batch_size, channel, width, channel_block] 的四维张量,其中 channel_block=16 表示对 channel 维度的分割。 * **count_include_pad** ( [bool](https://docs.python.org/3/library/functions.html#bool) )[:](https://docs.python.org/3/library/functions.html#bool)当 pool_type 为 'avg' 时,是否在计算中包含填充。 * **返回:output** :nD 在同一布局中。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.pool2d(*data*, *kernel*, *stride*, *dilation*, *padding*, *pool_type*, *ceil_mode=False*, *layout='NCHW'*, *count_include_pad=True*) @@ -3426,7 +3426,7 @@ p = 预测{n,t,i_1,i_2,i_k} w = 权重{n,i_1,i_2,…,i_k} 如果 它根据布局字符串决定高度和宽度尺寸,其中“W”和“H”分别表示宽度和高度。宽度和高度尺寸不能拆分。例如,NCHW、NCHW16c 等适用于池,而 NCHW16w、NCHW16h 则不适用。有关布局字符串约定的更多信息,请参阅参数布局。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):具有布局形状的 nD。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):具有布局形状的 nD。 * **kernel**(*两个整数**的***列表/元组):内核大小,[kernel_height,kernel_width]。 * **stride**(*两个整数**的***列表/元组):步幅大小,[stride_height,stride_width]。 * **dilation**(*两个整数**的***列表/元组):扩张大小,[dilation_height,dilation_width]。 @@ -3436,7 +3436,7 @@ p = 预测{n,t,i_1,i_2,i_k} w = 权重{n,i_1,i_2,…,i_k} 如果 * **layout**(*字符串*):输入数据的布局。布局应该由大写字母、小写字母和数字组成,其中大写字母表示维度,对应的小写字母(因子大小)表示分割维度。例如,NCHW16c 可以描述一个 5 维张量,其值为 [batch_size, channel, height, width, channel_block],其中 channel_block=16 表示对 channel 维度的分割。 * **count_include_pad** ( [bool](https://docs.python.org/3/library/functions.html#bool) ):当 pool_type 为 'avg' 时,是否在计算中包含填充。 * **返回:output** :nD 在同一布局中。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.pool3d(*data*, *kernel*, *stride*, *dilation*, *padding*, *pool_type*, *ceil_mode=False*, *layout='NCDHW'*, *count_include_pad=True*) @@ -3446,7 +3446,7 @@ p = 预测{n,t,i_1,i_2,i_k} w = 权重{n,i_1,i_2,…,i_k} 如果 它根据布局字符串决定深度、高度和宽度尺寸,其中“D”、“W”和“H”分别表示深度、宽度和高度。深度、宽度和高度尺寸不能拆分。例如,NCDHW、NCDHW16c 等适用于池,而 NCDHW16d、NCDHW16w 和 NCDHW16h 则不适用。有关布局字符串约定的更多信息,请参阅参数布局。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):具有布局形状的 nD。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):具有布局形状的 nD。 * **kernel**(*三个整数**的***列表/元组):内核大小,[kernel_depth、kernel_height、kernel_width]。 * **stride**(*三个整数**的***列表/元组):步幅大小,[stride_depth,stride_height,stride_width]。 * **dilation**(*两个整数**的***列表/元组):扩张大小,[dilation_height,dilation_width]。 @@ -3456,7 +3456,7 @@ p = 预测{n,t,i_1,i_2,i_k} w = 权重{n,i_1,i_2,…,i_k} 如果 * **layout**(*字符串*):输入数据的布局。布局应该由大写字母、小写字母和数字组成,其中大写字母表示维度,对应的小写字母(因子大小)表示分割维度。例如,NCDHW16c 可以描述一个 6 维张量,其值为 [batch_size, channel,depth, height, width, channel_block],其中 channel_block=16 表示对 channel 维度的分割。 * **count_include_pad** ( [bool](https://docs.python.org/3/library/functions.html#bool) )**:** 当 pool_type 为 'avg' 时,是否在计算中包含填充。 * **返回:output** :nD 在同一布局中。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.pool_grad(*grads*, *data*, *kernel*, *stride*, *padding*, *pool_type*, *ceil_mode=False*, *count_include_pad=True*, *layout='NCHW'*) @@ -3466,8 +3466,8 @@ p = 预测{n,t,i_1,i_2,i_k} w = 权重{n,i_1,i_2,…,i_k} 如果 它根据布局字符串决定高度和宽度尺寸,其中“W”和“H”分别表示宽度和高度。宽度和高度尺寸不能拆分。例如,NCHW、NCHW16c 等适用于池,而 NCHW16w、NCHW16h 则不适用。有关布局字符串约定的更多信息,请参阅参数布局。 * **参数:** - * **grads**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):具有布局形状的 nD。 - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):具有布局形状的 nD。 + * **grads**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):具有布局形状的 nD。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):具有布局形状的 nD。 * **kernel**(*两个整数**的***列表/元组):内核大小,[kernel_height,kernel_width]。 * **stride**(*两个整数**的***列表/元组):步幅大小,[stride_height,stride_width]。 * **padding**(*四个整数**的*** *列表/元组*):填充大小,[pad_top, pad_left, pad_bottom, pad_right]。 @@ -3476,15 +3476,15 @@ p = 预测{n,t,i_1,i_2,i_k} w = 权重{n,i_1,i_2,…,i_k} 如果 * **count_include_pad** ( [bool](https://docs.python.org/3/library/functions.html#bool) )**:** 当 pool_type 为 'avg' 时,是否在计算中包含填充。 * **layout**(*字符串*)**:** 输入数据的布局。布局应该由大写字母、小写字母和数字组成,其中大写字母表示维度,对应的小写字母(因子大小)表示分割维度。例如,NCHW16c 可以描述一个 5 维张量,其值为 [batch_size, channel, height, width, channel_block],其中 channel_block=16 表示对 channel 维度的分割。 * **返回:output** :nD 在同一布局中。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.prelu(*x*, *slope*, *axis=1*) PReLU。它接受两个参数:一个输入`x`和一个权重数组`W` ,并计算输出为 PReLU(x)y=x>0?x:W∗x, 在哪里∗是批次中每个样本的元素乘法。 * **参数:** - * **x**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入参数。 - * **斜率**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))*:* 用于 prelu 的通道化斜率张量。 + * **x**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入参数。 + * **斜率**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))*:* 用于 prelu 的通道化斜率张量。 * **axis**([int](https://docs.python.org/3/library/functions.html#int)):需要应用通道数据的轴。 * **返回:** * **y** ( *tvm.te.Tensor* ):结果。 @@ -3500,64 +3500,64 @@ PReLU。它接受两个参数:一个输入`x`和一个权重数组`W` ,并 将反射填充应用于输入张量。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入张量。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入张量。 * *pad_before* ( *List[*[int](https://docs.python.org/3/library/functions.html#int)*]* ):每个维度前填充的量。 * **pad_after**(*List[*[int](https://docs.python.org/3/library/functions.html#int)*],可选*):每个维度后的填充量。如果为 None ,则默认为 pad_before 。 * **name** ([str](https://docs.python.org/3/library/stdtypes.html#str)) : **name**([str](https://docs.python.org/3/library/stdtypes.html#str)):结果张量的名称。 * **返回:out** :反射填充张量。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.relu(*x*) 取输入 x 的 relu。 -* **参数:x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)) :输入参数。 +* **参数:x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)) :输入参数。 * **返回:y** *:* 结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.replicate_pad(*data*, *pad_before*, *pad_after=None*, *name='ReplicatePadInput'*) 对输入张量应用重复填充(边缘填充)。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入张量。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入张量。 * *pad_before* ( *List[*[int](https://docs.python.org/3/library/functions.html#int)*]* ):每个维度前填充的量。 * **pad_after**(*List[*[int](https://docs.python.org/3/library/functions.html#int)*],可选*):每个维度后的填充量。如果为 None ,则默认为 pad_before 。 * **name**([str](https://docs.python.org/3/library/stdtypes.html#str))*:* 结果张量的名称。 * **返回:out** :复制填充的张量。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.scale_shift_nchw(*Input*, *Scale*, *Shift*) 推理中的批量标准化运算符。 * **参数:** - * **输入**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D 输入张量,NCHW 布局 [批次、通道、高度、宽度]。 - * **比例尺**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)比例尺张量,大小为通道数的一维。 - * **Shift** ( [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) ):移位张量,大小为通道数的一维 + * **输入**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D 输入张量,NCHW 布局 [批次、通道、高度、宽度]。 + * **比例尺**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)比例尺张量,大小为通道数的一维。 + * **Shift** ( [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ):移位张量,大小为通道数的一维 * **。返回:Output** :输出张量,布局为 NCHW。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.scale_shift_nchwc(*Input*, *Scale*, *Shift*) 推理中的批量标准化运算符。 * **参数:** - * **输入**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):5D 输入张量,NCHWc 布局[batch,channel_chunk,height,width,channel_block]。 - * **Scale**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):缩放张量,二维,大小为 [channel_chunk, channel_block]。 - * **Shift** ( [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) ):移位张量,二维,大小为 [channel_chunk, channel_block]。 + * **输入**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):5D 输入张量,NCHWc 布局[batch,channel_chunk,height,width,channel_block]。 + * **Scale**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):缩放张量,二维,大小为 [channel_chunk, channel_block]。 + * **Shift** ( [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ):移位张量,二维,大小为 [channel_chunk, channel_block]。 * **返回:Output** :输出张量,布局为 NHWC。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.scale_shift_nhwc(*Input*, *Scale*, *Shift*) 推理中的批量标准化运算符。 * **参数:** - * **输入**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D 输入张量,NHWC 布局[批次,高度,宽度,通道]。 - * **比例尺**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):比例尺张量,大小为通道数的一维。 - * **Shift** ( [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) ):移位张量,大小为通道数的一维。 + * **输入**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D 输入张量,NHWC 布局[批次,高度,宽度,通道]。 + * **比例尺**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):比例尺张量,大小为通道数的一维。 + * **Shift** ( [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ):移位张量,大小为通道数的一维。 * **返回:Output** :输出张量,布局为 NHWC。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.simplify(*expr*) @@ -3572,10 +3572,10 @@ PReLU。它接受两个参数:一个输入`x`和一个权重数组`W` ,并 模拟 QNN 反量化运算符,可模拟 QNN 输出,而无需更改数据类型。与真正的 QNN 反量化相比,此运算符的优势在于,它允许动态选择数据类型,并且可以对每个通道、标量尺度和零点进行操作,而 QNN 反量化则需要在编译时修复这两者。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):运算符的 ND 输入张量。 - * **in_dtype** ( [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) ):标量变量,指示使用哪种数据类型来模拟反量化。使用 SQNN_DTYPE_TO_CODE 将 dtype 字符串转换为相应的变量值。 - * **input_scale**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*,可选*)[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)标量张量,表示从整数数据类型反量化时使用的比例。当它包含多个值时,N 必须与数据的通道数匹配。 - * **input_zero_point**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*,可选*)**:** 一维张量,表示从整数数据类型反量化时使用的零点。当它包含多个值时,N 必须与数据的通道数匹配。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):运算符的 ND 输入张量。 + * **in_dtype** ( [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ):标量变量,指示使用哪种数据类型来模拟反量化。使用 SQNN_DTYPE_TO_CODE 将 dtype 字符串转换为相应的变量值。 + * **input_scale**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*,可选*)[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)标量张量,表示从整数数据类型反量化时使用的比例。当它包含多个值时,N 必须与数据的通道数匹配。 + * **input_zero_point**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*,可选*)**:** 一维张量,表示从整数数据类型反量化时使用的零点。当它包含多个值时,N 必须与数据的通道数匹配。 * **axis**([int](https://docs.python.org/3/library/functions.html#int)*,可选*):用于量化的通道轴。默认值为 –1,对应于最后一个轴。 ## tvm.topi.nn.simulated_quantize(*data*, *out_dtype*, *output_scale=None*, *output_zero_point=None*, *axis=-1*) @@ -3583,10 +3583,10 @@ PReLU。它接受两个参数:一个输入`x`和一个权重数组`W` ,并 模拟 QNN 量化运算符,可模拟 QNN 输出,无需更改数据类型。与真正的 QNN 量化相比,此运算符的优势在于,它允许动态选择数据类型,并且可以对每个通道、标量尺度和零点进行操作,而 QNN 量化则要求在编译时固定这两个参数。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):运算符的 ND 输入张量。 - * **out_dtype** ( [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) ):一个标量变量,用于指示要使用哪种数据类型来模拟量化。使用 SQNN_DTYPE_TO_CODE 将 dtype 字符串转换为相应的变量值。 - * **output_scale**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*,可选*)*:* 标量张量,表示量化为整数数据类型时使用的比例。当它包含多个值时,N 必须与数据的通道数匹配。 - * **output_zero_point**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)*,可选*):一个一维张量,表示量化为整数数据类型时使用的零点。当它包含多个值时,N 必须与数据的通道数匹配。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):运算符的 ND 输入张量。 + * **out_dtype** ( [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ):一个标量变量,用于指示要使用哪种数据类型来模拟量化。使用 SQNN_DTYPE_TO_CODE 将 dtype 字符串转换为相应的变量值。 + * **output_scale**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*,可选*)*:* 标量张量,表示量化为整数数据类型时使用的比例。当它包含多个值时,N 必须与数据的通道数匹配。 + * **output_zero_point**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)*,可选*):一个一维张量,表示量化为整数数据类型时使用的零点。当它包含多个值时,N 必须与数据的通道数匹配。 * **axis**([int](https://docs.python.org/3/library/functions.html#int)*,可选*):用于量化的通道轴。默认值为 –1,对应于最后一个轴。 ## tvm.topi.nn.softmax(*x*, *axis=-1*) @@ -3594,10 +3594,10 @@ PReLU。它接受两个参数:一个输入`x`和一个权重数组`W` ,并 对数据执行 softmax 激活。 * **参数:** - * **x** ( [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) ):可以是任意维度。 + * **x** ( [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ):可以是任意维度。 * **axis**([int](https://docs.python.org/3/library/functions.html#int)):通道轴。 * **返回:output** :输出形状与输入相同。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.softmax_common(*x*, *axis*, *use_fast_exp*) @@ -3609,41 +3609,41 @@ softmax 和 fast_softmax 的共同部分。 计算具有数值稳定性的输入 x 的 Softplus 激活。 * **参数:** - * **x**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入张量。 + * **x**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入张量。 * **beta**([浮点数](https://docs.python.org/3/library/functions.html#float)*,可选*):Softplus 公式中的比例因子 β(默认值为 1.0)。 * **阈值**([浮点数](https://docs.python.org/3/library/functions.html#float)*,可选*)[:](https://docs.python.org/3/library/functions.html#float)数值稳定性的阈值(默认值为 20.0)。 * **返回:y** :结果。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.space_to_batch_nd(*data*, *block_shape*, *pad_before*, *pad_after*, *pad_value=0.0*) 对数据执行批量到空间的转换 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):形状为 [batch, spatial_shape, remaining_shapes] 的 ND Tensor,其中 spatial_shape 有 M 维。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):形状为 [batch, spatial_shape, remaining_shapes] 的 ND Tensor,其中 spatial_shape 有 M 维。 * **block_shape**(*整数*[列表](https://docs.python.org/3/library/stdtypes.html#list)):大小为 [M] 的列表,其中 M 是空间维度的数量,指定每个空间维度的块大小。 * **pad_before**(*整数*[列表](https://docs.python.org/3/library/stdtypes.html#list)*):形状为 [M] 的列表,其中 M 是空间维度的*数量,指定每个空间维度之前的零填充大小。 * **pad_after**(*整数*[列表](https://docs.python.org/3/library/stdtypes.html#list)):形状为 [M] 的列表,*其中 M 是空间维度的数量,指定每个空间维度后的零填充大小。 * **pad_value**([float](https://docs.python.org/3/library/functions.html#float)*,可选*):用于填充的值。 * **返回:output。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.space_to_depth(*data*, *block_size*, *layout='NCHW'*) 对数据执行空间到深度的转换。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):NCHW 或 NHWC 布局中的 4–D 张量。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):NCHW 或 NHWC 布局中的 4–D 张量。 * **block_size** ( [int](https://docs.python.org/3/library/functions.html#int) ):分解为通道维度的块的大小。 * **布局**(*字符串*):NCHW 或 NHWC,表示数据布局。 * **返回:output** :形状输出[N,C * block_size**2,H / block_size,W / block_size]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.strided_slice(*a*, *begin*, *end*, *strides=None*, *axes=None*, *slice_mode='end'*, *assume_inbound=True*) 数组的切片。 * **参数:** - * **a**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** 要切片的张量。 + * **a**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** 要切片的张量。 * **begin**(*int*[列表](https://docs.python.org/3/library/stdtypes.html#list))*:* 切片中开始的索引[。](https://docs.python.org/3/library/functions.html#int) * **end**(*int*[列表](https://docs.python.org/3/library/stdtypes.html#list))*:* 指示切片结束的索引[。](https://docs.python.org/3/library/functions.html#int) * **strides**(*整数*[列表](https://docs.python.org/3/library/stdtypes.html#list)*,可选):指定*[步幅](https://docs.python.org/3/library/functions.html#int)值,在这种情况下可以为负数,输入张量将在该特定轴上反转。 @@ -3651,17 +3651,17 @@ softmax 和 fast_softmax 的共同部分。 * **slice_mode**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*)*:* 切片模式 [end, size]。end*:*切片的结束索引 [默认]。size:输入的步幅将被忽略,此模式下的输入 end 表示从 begin 指定位置开始的切片大小。如果 end[i] 为 –1,则该维度上的所有剩余元素都将包含在切片中。 * **假设_inbound** ( [bool](https://docs.python.org/3/library/functions.html#bool)*,可选*)*:* 一个标志,指示是否假定所有索引都是入站的。 * **返回:ret。** -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.unpack_NCHWc_to_nchw(*packed_out*, *out_dtype*) 将 conv2d_NCHWc 输出从布局 NCHWc 解包为 NCHW。 * **参数:** - * **packed_out** ( [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) ):conv2d_NCHWc 的输出张量。 + * **packed_out** ( [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ):conv2d_NCHWc 的输出张量。 * **out_dtype** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ):输出 dtype。 * **返回:unpacked_out** :NCHW 布局中解包的输出张量。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.upsampling(*data*, *scale_h*, *scale_w*, *layout='NCHW'*, *method='nearest_neighbor'*, *align_corners=False*, *output_shape=None*) @@ -3671,14 +3671,14 @@ softmax 和 fast_softmax 的共同部分。 支持最近邻和双线性上采样。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入是形状为 [batch, channel, in_height, in_width] 或 [batch, in_height, in_width, channel] 的 4–D 张量。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入是形状为 [batch, channel, in_height, in_width] 或 [batch, in_height, in_width, channel] 的 4–D 张量。 * **scale_h** ( [float](https://docs.python.org/3/library/functions.html#float) ):高度的缩放因子。 * **scale_w** ( [float](https://docs.python.org/3/library/functions.html#float) )*:* 宽度的缩放因子。 * *布局**(*字符串**,*可选*):“NCHW”或“NHWC”。 * **方法**(*{“bilinear”,**“nearest_neighbor”*** ***,****“bicubic”}*):用于上采样的方法。 * *output_shape*(*tvm.tir.container.Array,*可选*):返回的形状。如果为 None,则推断为 None (如果形状是动态确定的,则将 out_dtype.shape 传递为 output_shape)。 * **返回:output** *:* 4–D,形状为 [batch, channel, in_height*scale_h, in_width*scale_w] 或 [batch, in_height*scale, in_width*scale, channel]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.upsampling3d(*data*, *scale_d*, *scale_h*, *scale_w*, *layout='NCDHW'*, *method='nearest_neighbor'*, *coordinate_transformation_mode='half_pixel'*, *output_shape=None*) @@ -3688,16 +3688,16 @@ softmax 和 fast_softmax 的共同部分。 支持最近邻和双线性上采样。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入是一个 5–D 张量,形状为 [batch, channel, in_depth, in_height, in_width] 或 [batch, in_depth, in_height, in_width, channel]。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入是一个 5–D 张量,形状为 [batch, channel, in_depth, in_height, in_width] 或 [batch, in_depth, in_height, in_width, channel]。 * **scale_d**([float](https://docs.python.org/3/library/functions.html#float)):深度的缩放因子。 * **scale_h** ( [float](https://docs.python.org/3/library/functions.html#float) ):高度的缩放因子。 * **scale_w** ( [float](https://docs.python.org/3/library/functions.html#float) ):宽度的缩放因子。 * *布局**(*字符串*,可选*):“NCDHW”或“NDHWC”。 * *方法**(*{“trilinear”,*“nearest_neighbor”}*):用于上采样的方法。 * *coordinate_transformation_mode**(*字符串**,*可选*):描述如何将调整大小后的张量中的坐标转换为原始张量中的坐标。有关详细信息,请参阅 ONNX Resize 运算符规范。可用选项包括“half_pixel”、“align_corners”和“asymmetric”。 - * *output_shape**(*tvm.tir.container.Array,****可选*)[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)返回的形状。如果为 None,则推断为 None (如果形状是动态确定的,则将 out_dtype.shape 传递为 output_shape)。 + * *output_shape**(*tvm.tir.container.Array,****可选*)[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)返回的形状。如果为 None,则推断为 None (如果形状是动态确定的,则将 out_dtype.shape 传递为 output_shape)。 * **返回:output** *:*5–D,形状为 [batch, channel, in_depth*scale, in_height*scale, in_width*scale] 或 [batch, in_depth*scale, in_height*scale, in_width*scale, channel]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.winograd_transform_matrices(*tile_size*, *kernel_size*, *out_dtype*) @@ -3707,53 +3707,53 @@ softmax 和 fast_softmax 的共同部分。 实例规范化运算符。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):形状为(d_0,d_1,…,d_{N–1})的 ND。 - * **gamma** ( [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) )[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)形状为 (r_0, r_1, …, r_{K–1}) 的 KD,其中 K == len(axis) 且 d_{axis_k} == r_k。 - * **beta**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):可选,KD 形状为 (r_0, r_1, …, r_{K–1}),其中 K == len(axis) 且 d_{axis_k} == r_k。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):形状为(d_0,d_1,…,d_{N–1})的 ND。 + * **gamma** ( [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) )[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)形状为 (r_0, r_1, …, r_{K–1}) 的 KD,其中 K == len(axis) 且 d_{axis_k} == r_k。 + * **beta**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):可选,KD 形状为 (r_0, r_1, …, r_{K–1}),其中 K == len(axis) 且 d_{axis_k} == r_k。 * **axis**(*int*[列表)](https://docs.python.org/3/library/stdtypes.html#list)[:](https://docs.python.org/3/library/stdtypes.html#list)[应用标准化](https://docs.python.org/3/library/stdtypes.html#list)[的](https://docs.python.org/3/library/functions.html#int)轴(计算平均值和方差的轴)。 * **epsilon**([float](https://docs.python.org/3/library/functions.html#float)):避免被零除的 epsilon 值。。 -* **返回:result** [:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)形状为 (d_0, d_1, …, d_{N–1}) 的 ND。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回:result** [:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)形状为 (d_0, d_1, …, d_{N–1}) 的 ND。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.layer_norm(*data*, *gamma*, *beta*, *axis*, *epsilon=1e-05*) 层归一化运算符。它接受 fp16 和 fp32 作为输入数据类型。它会将输入转换为 fp32 来执行计算。输出将具有与输入相同的数据类型。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):形状为(d_0,d_1,…,d_{N–1})的 ND。 - * **gamma** ( [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) ):形状为 (r_0, r_1, …, r_{K–1}) 的 KD,其中 K == len(axis) 且 d_{axis_k} == r_k。 - * **beta**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)可选,KD 形状为 (r_0, r_1, …, r_{K–1}),其中 K == len(axis) 且 d_{axis_k} == r_k。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):形状为(d_0,d_1,…,d_{N–1})的 ND。 + * **gamma** ( [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ):形状为 (r_0, r_1, …, r_{K–1}) 的 KD,其中 K == len(axis) 且 d_{axis_k} == r_k。 + * **beta**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)可选,KD 形状为 (r_0, r_1, …, r_{K–1}),其中 K == len(axis) 且 d_{axis_k} == r_k。 * **axis**(*int*[列表](https://docs.python.org/3/library/stdtypes.html#list)):应用规范化的[轴](https://docs.python.org/3/library/functions.html#int)。 * **epsilon**([float](https://docs.python.org/3/library/functions.html#float)):避免被零除的 epsilon 值。 -* **返回:result** [:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)形状为 (d_0, d_1, …, d_{N–1}) 的 ND。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回:result** [:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)形状为 (d_0, d_1, …, d_{N–1}) 的 ND。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.group_norm(*data*, *gamma*, *beta*, *num_groups*, *channel_axis*, *axes*, *epsilon=1e-05*) 组规范化运算符。它接受 fp16 和 fp32 作为输入数据类型。它会将输入转换为 fp32 来执行计算。输出将具有与输入相同的数据类型。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)形状为(d_0,d_1,…,d_{N–1})的 ND。 - * **gamma** ( [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) ):一维,形状为 (r_0),其中 r_0 == d_{channel_axis}。 - * **beta**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):可选,一维,形状为(r_0),其中 r_0 == d_{channel_axis}。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)形状为(d_0,d_1,…,d_{N–1})的 ND。 + * **gamma** ( [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ):一维,形状为 (r_0),其中 r_0 == d_{channel_axis}。 + * **beta**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):可选,一维,形状为(r_0),其中 r_0 == d_{channel_axis}。 * **num_groups**([int](https://docs.python.org/3/library/functions.html#int))*:* 组数。 * **channel_axis**([int](https://docs.python.org/3/library/functions.html#int)):通道轴。 * **轴**(*整数*[列表)](https://docs.python.org/3/library/stdtypes.html#list)[:](https://docs.python.org/3/library/stdtypes.html#list)[应用标准化](https://docs.python.org/3/library/stdtypes.html#list)[的](https://docs.python.org/3/library/functions.html#int)轴,不包括通道轴。 * **epsilon**([float](https://docs.python.org/3/library/functions.html#float)):避免被零除的 epsilon 值。 -* **返回:result** [:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)形状为 (d_0, d_1, …, d_{N–1}) 的 ND。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回:result** [:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)形状为 (d_0, d_1, …, d_{N–1}) 的 ND。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.nn.rms_norm(*data*, *weight*, *axis*, *epsilon=1e-05*) 均方根归一化运算符。输出将具有与输入相同的数据类型。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):形状为(d_0,d_1,…,d_{N–1})的 ND。 - * **权重**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))*:* 形状为 (r_0, r_1, …, r_{K–1}) 的 KD,其中 K == len(axis) 且 d_{axis_k} == r_k。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):形状为(d_0,d_1,…,d_{N–1})的 ND。 + * **权重**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))*:* 形状为 (r_0, r_1, …, r_{K–1}) 的 KD,其中 K == len(axis) 且 d_{axis_k} == r_k。 * **axis**(*int*[列表](https://docs.python.org/3/library/stdtypes.html#list)):应用规范化的[轴](https://docs.python.org/3/library/functions.html#int)。 * **epsilon**([float](https://docs.python.org/3/library/functions.html#float))*:* 避免被零除的 epsilon 值。 * **返回:result** :形状为 (d_0, d_1, …, d_{N–1}) 的 ND。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 @@ -3768,29 +3768,29 @@ IMAGE 网格操作符。 **函数:** -|[affine_grid](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.image.affine_grid)(data,target_shape)|生成二维采样网格的 affine_grid 操作符。| +|[affine_grid](/docs/api-reference/python-api/tvm-topi#tvmtopiimageaffine_griddata-target_shape)(data,target_shape)|生成二维采样网格的 affine_grid 操作符。| |:----|:----| -|[can_convert_multiply_to_intdiv](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.image.can_convert_multiply_to_intdiv)(origin_size,…)|检查是否可以将乘法转换为除法。| -|[crop_and_resize](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.image.crop_and_resize)(data,boxes,box_indices,…)|对数据执行裁剪和调整大小操作。| -|[dilation2d_nchw](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.image.dilation2d_nchw)(input,filter,stride,…)|NCHW 布局中的形态膨胀操作符。| -|[dilation2d_nhwc](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.image.dilation2d_nhwc)(input,filter,stride,…)|形态学二维扩张 NHWC 布局。| -|[get_1d_indices](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.image.get_1d_indices)(indices[,layout])|获取一维索引。| -|[get_1d_pixel](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.image.get_1d_pixel)(data,layout,image_width,n,…)|获取 1d 像素。| -|[get_2d_indices](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.image.get_2d_indices)(indices[,layout])|获取二维索引。| -|[get_2d_pixel](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.image.get_2d_pixel)(data,layout,image_height,…)|获取二维像素。| -|[get_3d_indices](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.image.get_3d_indices)(indices[,layout])|获取 3d 索引。| -|[get_3d_pixel](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.image.get_3d_pixel)(data,layout,image_depth,…)|获取 3d 像素。| -|[get_closest_index](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.image.get_closest_index)(in_x,rounding_method,boxes)|根据某种舍入方法获取最接近某个值的索引。| -|[get_inx](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.image.get_inx)(x,image_width,target_width,…[,…])|使用各种坐标变换方法从输出 x 推断输入 x。| -|[get_pad_tuple](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.image.get_pad_tuple)(padding,kernel)|获取 pad 选项的通用代码。| -|[grid_sample](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.image.grid_sample)(data,grid[,method,layout,…])|将网格采样应用于输入特征图。| -|[nchw_pack_layout](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.image.nchw_pack_layout)(layout_info)|检查布局类型是否为 NCHWinic。| -|[nchw_xc_layout](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.image.nchw_xc_layout)(layout_info)|检查布局类型是否为 NCHWxc。| -|[pad](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.image.pad)(data,pad_before[,pad_after,…])|使用 pad 值的 Pad 输入。| -|[resize1d](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.image.resize1d)(data,roi,size[,layout,method,…])|对数据执行调整大小操作。| -|[resize2d](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.image.resize2d)(data,roi,size[,layout,method,…])|对数据执行调整大小操作。| -|[resize3d](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.image.resize3d)(data,roi,size[,layout,method,…])|对数据执行调整大小操作。| -|[simplify](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.image.simplify)(expr)|如果是 Expr 则化简表达式,如果是 int 则直接返回。| +|[can_convert_multiply_to_intdiv](/docs/api-reference/python-api/tvm-topi#tvmtopiimagecan_convert_multiply_to_intdivorigin_size-scaled_size)(origin_size,…)|检查是否可以将乘法转换为除法。| +|[crop_and_resize](/docs/api-reference/python-api/tvm-topi#tvmtopiimagecrop_and_resizedata-boxes-box_indices-crop_size-layoutnchw-methodbilinear-extrapolation_valuenone-out_dtypenone)(data,boxes,box_indices,…)|对数据执行裁剪和调整大小操作。| +|[dilation2d_nchw](/docs/api-reference/python-api/tvm-topi#tvmtopiimagedilation2d_nchwinput-filter-stride-padding-dilations-out_dtypenone)(input,filter,stride,…)|NCHW 布局中的形态膨胀操作符。| +|[dilation2d_nhwc](/docs/api-reference/python-api/tvm-topi#tvmtopiimagedilation2d_nhwcinput-filter-stride-padding-dilations-out_dtypenone)(input,filter,stride,…)|形态学二维扩张 NHWC 布局。| +|[get_1d_indices](/docs/api-reference/python-api/tvm-topi#tvmtopiimageget_1d_indicesindices-layoutncw)(indices[,layout])|获取一维索引。| +|[get_1d_pixel](/docs/api-reference/python-api/tvm-topi#tvmtopiimageget_1d_pixeldata-layout-image_width-n-c-x-cc-ib-ic)(data,layout,image_width,n,…)|获取 1d 像素。| +|[get_2d_indices](/docs/api-reference/python-api/tvm-topi#tvmtopiimageget_2d_indicesindices-layoutnchw)(indices[,layout])|获取二维索引。| +|[get_2d_pixel](/docs/api-reference/python-api/tvm-topi#tvmtopiimageget_2d_pixeldata-layout-image_height-image_width-n-c-y-x-cc-ib-ic)(data,layout,image_height,…)|获取二维像素。| +|[get_3d_indices](/docs/api-reference/python-api/tvm-topi#tvmtopiimageget_3d_indicesindices-layoutncdhw)(indices[,layout])|获取 3d 索引。| +|[get_3d_pixel](/docs/api-reference/python-api/tvm-topi#tvmtopiimageget_3d_pixeldata-layout-image_depth-image_height-image_width-n-c-z-y-x-cc)(data,layout,image_depth,…)|获取 3d 像素。| +|[get_closest_index](/docs/api-reference/python-api/tvm-topi#tvmtopiimageget_closest_indexin_x-rounding_method-boxes-use_int_divfalse)(in_x,rounding_method,boxes)|根据某种舍入方法获取最接近某个值的索引。| +|[get_inx](/docs/api-reference/python-api/tvm-topi#tvmtopiimageget_inxx-image_width-target_width-coordinate_transformation_mode-start_x0-end_x-1-use_int_divfalse)(x,image_width,target_width,…[,…])|使用各种坐标变换方法从输出 x 推断输入 x。| +|[get_pad_tuple](/docs/api-reference/python-api/tvm-topi#tvmtopiimageget_pad_tuplepadding-kernel)(padding,kernel)|获取 pad 选项的通用代码。| +|[grid_sample](/docs/api-reference/python-api/tvm-topi#tvmtopiimagegrid_sampledata-grid-methodbilinear-layoutnchw-padding_modezeros-align_cornerstrue)(data,grid[,method,layout,…])|将网格采样应用于输入特征图。| +|[nchw_pack_layout](/docs/api-reference/python-api/tvm-topi#tvmtopiimagenchw_pack_layoutlayout_info)(layout_info)|检查布局类型是否为 NCHWinic。| +|[nchw_xc_layout](/docs/api-reference/python-api/tvm-topi#tvmtopiimagenchw_xc_layoutlayout_info)(layout_info)|检查布局类型是否为 NCHWxc。| +|[pad](/docs/api-reference/python-api/tvm-topi#tvmtopiimagepaddata-pad_before-pad_afternone-pad_value00-namepadinput-attrsnone)(data,pad_before[,pad_after,…])|使用 pad 值的 Pad 输入。| +|[resize1d](/docs/api-reference/python-api/tvm-topi#tvmtopiimageresize1ddata-roi-size-layoutncw-methodlinear-coordinate_transformation_modehalf_pixel-rounding_method-bicubic_alpha-075-bicubic_exclude0-extrapolation_value00-out_dtypenone-output_shapenone)(data,roi,size[,layout,method,…])|对数据执行调整大小操作。| +|[resize2d](/docs/api-reference/python-api/tvm-topi#tvmtopiimageresize2ddata-roi-size-layoutnchw-methodlinear-coordinate_transformation_modehalf_pixel-rounding_method-bicubic_alpha-075-bicubic_exclude0-extrapolation_value00-out_dtypenone-output_shapenone)(data,roi,size[,layout,method,…])|对数据执行调整大小操作。| +|[resize3d](/docs/api-reference/python-api/tvm-topi#tvmtopiimageresize3ddata-roi-size-layoutncdhw-methodlinear-coordinate_transformation_modehalf_pixel-rounding_method-bicubic_alpha-075-bicubic_exclude0-extrapolation_value00-out_dtypenone-output_shapenone)(data,roi,size[,layout,method,…])|对数据执行调整大小操作。| +|[simplify](/docs/api-reference/python-api/tvm-topi#tvmtopiimagesimplifyexpr)(expr)|如果是 Expr 则化简表达式,如果是 int 则直接返回。| ## tvm.topi.image.affine_grid(*data*, *target_shape*) @@ -3801,7 +3801,7 @@ IMAGE 网格操作符。 [此操作在 https://arxiv.org/pdf/1506.02025.pdf](https://arxiv.org/pdf/1506.02025.pdf) 中进行了描述。它在目标形状内生成一个均匀的采样网格,并将其归一化到 [-1, 1]。然后将提​​供的仿射变换应用于采样网格。 * **参数:** * **数据**(*tvm.Tensor*):三维,形状为 [batch, 2, 3]。仿射矩阵。 - * **target_shape**(*两个 int**的***列表/元组)[:](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)指定输出形状(H,W)。 + * **target_shape**(*两个 int**的***列表/元组)[:](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)指定输出形状(H,W)。 * **返回:Output** **:**4–D,形状为 [batch, 2, target_height, target_width]。 * **返回类型:** tvm.Tensor。 @@ -3815,44 +3815,44 @@ IMAGE 网格操作符。 对数据执行裁剪和调整大小操作。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入是形状为 [batch, channel, in_height, in_width] 或 [batch, in_height, in_width, channel] 的 4–D 张量。 - * **boxes** ( [tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) )*:* 形状为 [num_boxes, 4] 的二维张量。张量的每一行指定一个框的坐标。 - * **box_indices**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):形状为 [num_boxes] 的一维张量,box_indices[i] 指定第 i 个框引用的数据。 - * **crop_size**([元组](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)):每个框的目标大小。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入是形状为 [batch, channel, in_height, in_width] 或 [batch, in_height, in_width, channel] 的 4–D 张量。 + * **boxes** ( [tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) )*:* 形状为 [num_boxes, 4] 的二维张量。张量的每一行指定一个框的坐标。 + * **box_indices**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):形状为 [num_boxes] 的一维张量,box_indices[i] 指定第 i 个框引用的数据。 + * **crop_size**([元组](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)):每个框的目标大小。 * *布局**(*字符串*,可选):“NCHW”,“NHWC”。 * *方法**(*{“bilinear”,*“nearest_neighbor”}*):用于调整大小的方法。 * **extrapolation_value**([float](https://docs.python.org/3/library/functions.html#float)*,可选*)*:*用于外推的值(如适用)。 * *out_dtype*(*字符串*,可选):返回类型。如果为 None ,则返回与输入类型相同的类型。 * **返回:output** :4–D,形状为 [num_boxes, channel, crop_height, crop_width] 或 [num_boxes, crop_height, crop_width, channel]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.image.dilation2d_nchw(*input*, *filter*, *stride*, *padding*, *dilations*, *out_dtype=None*) NCHW 布局中的形态膨胀操作符。 * **参数:** - * **输入**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D,形状为[batch, in_channel, in_height, in_width]。 - * **过滤器**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):三维,形状为[in_channel, filter_height, filter_width]。 + * **输入**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D,形状为[batch, in_channel, in_height, in_width]。 + * **过滤器**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):三维,形状为[in_channel, filter_height, filter_width]。 * **stride**([int](https://docs.python.org/3/library/functions.html#int)*或*两个 int***的列表/元组*)**:步幅大小,或 [stride_height, stride_width]。 * **padding**([int](https://docs.python.org/3/library/functions.html#int)*或*[str](https://docs.python.org/3/library/stdtypes.html#str)):填充大小。 * **扩张**([int](https://docs.python.org/3/library/functions.html#int)*或**两个 int***的列表/元组):扩张大小,或 [dilation_height, dilation_width]。 * *out_dtype*(*可选*[ [str](https://docs.python.org/3/library/stdtypes.html#str)*]*)*:* 指定输出数据类型。 * **返回:Output** **:** 4–D,形状为 [batch, in_channel, out_height, out_width]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.image.dilation2d_nhwc(*input*, *filter*, *stride*, *padding*, *dilations*, *out_dtype=None*) 形态学二维扩张 NHWC 布局。 * **参数:** - * **输入**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):4–D,形状为[batch, in_height, in_width, in_channel]。 - * **过滤器**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))*:* 三维,形状为[filter_height, filter_width, in_channel]。 + * **输入**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):4–D,形状为[batch, in_height, in_width, in_channel]。 + * **过滤器**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))*:* 三维,形状为[filter_height, filter_width, in_channel]。 * **stride**([int](https://docs.python.org/3/library/functions.html#int)*或*两个 int*的列表/元组*)*:* 步幅大小,或 [stride_height, stride_width]。 * **padding**([int](https://docs.python.org/3/library/functions.html#int))**:** 填充大小。 * **扩张**([int](https://docs.python.org/3/library/functions.html#int)*或*两个 int*的列表/元组*):扩张大小,或 [dilation_height, dilation_width]。 * *out_dtype*(*可选*[ [str](https://docs.python.org/3/library/stdtypes.html#str)*]*):指定输出数据类型。 * **返回:Output** **:** 4–D,形状为 [batch, out_height, out_width, in_channel]。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.image.get_1d_indices(*indices*, *layout='NCW'*) @@ -3959,22 +3959,22 @@ grid_sample 经常与 affine_grid 配合使用,后者为 grid_sample 生成采 使用 pad 值的 Pad 输入。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):nD 输入,可以是任何布局。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):nD 输入,可以是任何布局。 * **pad_before**(*n 个整数**的***列表/元组):在每个维度上填充宽度以在轴开始之前进行填充。 * *pad_after**(*n 个整数**的**列表/元组*,*可选*):填充每个维度的宽度以填充轴端之后。 * **pad_value**([float](https://docs.python.org/3/library/functions.html#float)*,可选*):要填充的值。 * **name**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*):生成的名称前缀运算符。 * **返回:Output** :nD,与输入相同的布局。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.image.resize1d(*data*, *roi*, *size*, *layout='NCW'*, *method='linear'*, *coordinate_transformation_mode='half_pixel'*, *rounding_method=''*, *bicubic_alpha=-0.75*, *bicubic_exclude=0*, *extrapolation_value=0.0*, *out_dtype=None*, *output_shape=None*) 对数据执行调整大小操作。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入是形状为[batch, channel in_width]或[batch in_width, channel]的三维张量。 - * **roi**(*浮点数**或** **表达式的*[元组](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple))**:** 用于裁剪输入图像的感兴趣区域。预期大小为 2,格式为 [start_w, end_w]。仅在 coordinate_transformation_mode 为 tf_crop_and_resize 时使用。 - * **size**([Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple))*:* 输出分辨率缩放至。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入是形状为[batch, channel in_width]或[batch in_width, channel]的三维张量。 + * **roi**(*浮点数**或** **表达式的*[元组](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone))**:** 用于裁剪输入图像的感兴趣区域。预期大小为 2,格式为 [start_w, end_w]。仅在 coordinate_transformation_mode 为 tf_crop_and_resize 时使用。 + * **size**([Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone))*:* 输出分辨率缩放至。 * *布局*(*字符串*,*可选*):“NCW”、“NWC”或“NCWc”。 * *coordinate_transformation_mode*(*字符串**,*可选*)*:* 描述如何将调整大小后的张量中的坐标转换为原始张量中的坐标。有关详细信息,请参阅 ONNX Resize 运算符规范。可用选项包括“half_pixel”、“align_corners”和“asymmetric”。 * *方法**(*字符串**,可选*):插值方法(“最近”、“线性”、“双三次”)。 @@ -3986,16 +3986,16 @@ grid_sample 经常与 affine_grid 配合使用,后者为 grid_sample 生成采 * *out_dtype*(*字符串*,*可选*)*:* 返回类型。如果为 None ,则返回与输入类型相同的类型。 * *output_shape*(tvm.tir.container.Array,*可选*):返回的形状。如果为 None,则推断为 None (如果形状是动态确定的,则将 out_dtype.shape 传递为 output_shape)。 * **返回:output** :形状为 [batch, chananel, in_width*scale] 或 [batch, in_width*scale, channel] 的 4–D 或形状为 [batch, channel–major, in_width*scale, channel–minor] 的 5–D。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor) +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor) ## tvm.topi.image.resize2d(*data*, *roi*, *size*, *layout='NCHW'*, *method='linear'*, *coordinate_transformation_mode='half_pixel'*, *rounding_method=''*, *bicubic_alpha=-0.75*, *bicubic_exclude=0*, *extrapolation_value=0.0*, *out_dtype=None*, *output_shape=None*) 对数据执行调整大小操作。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入是形状为 [batch, channel, in_height, in_width] 或 [batch, in_height, in_width, channel] 的 4–D 张量。 - * **roi**(*浮点数**或****表达式的*[元组](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)):用于裁剪输入图像的感兴趣区域。预期大小为 4,格式为 [start_h, start_w, end_h, end_w]。仅在 coordinate_transformation_mode 为 tf_crop_and_resize 时使用。 - * **size**([Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)):输出分辨率缩放至。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入是形状为 [batch, channel, in_height, in_width] 或 [batch, in_height, in_width, channel] 的 4–D 张量。 + * **roi**(*浮点数**或****表达式的*[元组](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)):用于裁剪输入图像的感兴趣区域。预期大小为 4,格式为 [start_h, start_w, end_h, end_w]。仅在 coordinate_transformation_mode 为 tf_crop_and_resize 时使用。 + * **size**([Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)):输出分辨率缩放至。 * *布局**(*字符串*,*可选*):“NCHW”、“NHWC”或“NCHWc”。 * *方法**(*字符串*,*可选*):插值方法(「最近」、「线性」、「双三次」)。 * *coordinate_transformation_mode*(*字符串*,*可选*):描述如何将调整大小后的张量中的坐标转换为原始张量中的坐标。[half_pixel、align_corners、asymmetric、pytorch_half_pixel、tf_half_pixel_for_nn 和 tf_crop_and_resize]。 @@ -4006,16 +4006,16 @@ grid_sample 经常与 affine_grid 配合使用,后者为 grid_sample 生成采 * *out_dtype*(*字符串*,可选)*:* 返回类型。如果为 None ,则返回与输入类型相同的类型。 * *output_shape*(tvm.tir.container.Array,***可选*)*:* 返回的形状。如果为 None,则推断为 None (如果形状是动态确定的,则将 out_dtype.shape 传递为 output_shape)。 * **返回:output** :形状为 [batch, channel, in_height*scale, in_width*scale] 或 [batch, in_height*scale, in_width*scale, channel] 的 4–D 或形状为 [batch, channel–major, in_height*scale, in_width*scale, channel–minor] 的 5–D。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.image.resize3d(*data*, *roi*, *size*, *layout='NCDHW'*, *method='linear'*, *coordinate_transformation_mode='half_pixel'*, *rounding_method=''*, *bicubic_alpha=-0.75*, *bicubic_exclude=0*, *extrapolation_value=0.0*, *out_dtype=None*, *output_shape=None*) 对数据执行调整大小操作。 * **参数:** - * **数据**([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入是一个 5–D 张量,形状为 [batch, channel, in_depth, in_height, in_width] 或 [batch, in_depth, in_height, in_width, channel]。 - * **roi**(*浮点数**或*** *表达式的*[元组](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple))**:** 用于裁剪输入图像的感兴趣区域。预期大小为 6,格式为 [start_d, start_h, start_w, end_d, end_h, end_w]。仅在 coordinate_transformation_mode 为 tf_crop_and_resize 时使用。 - * **size**([Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)):输出分辨率缩放至。 + * **数据**([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入是一个 5–D 张量,形状为 [batch, channel, in_depth, in_height, in_width] 或 [batch, in_depth, in_height, in_width, channel]。 + * **roi**(*浮点数**或*** *表达式的*[元组](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone))**:** 用于裁剪输入图像的感兴趣区域。预期大小为 6,格式为 [start_d, start_h, start_w, end_d, end_h, end_w]。仅在 coordinate_transformation_mode 为 tf_crop_and_resize 时使用。 + * **size**([Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)):输出分辨率缩放至。 * *布局**(*字符串*,*可选*):“NCDHW”、“NDHWC”或“NCDHWc”。 * *方法**(*字符串*,*可选*):插值方法(“最近”、“线性”、“双三次”)。 * *coordinate_transformation_mode*(*字符串*,*可选*):描述如何将调整大小后的张量中的坐标转换为原始张量中的坐标。[half_pixel、align_corners、asymmetric、pytorch_half_pixel、tf_half_pixel_for_nn 和 tf_crop_and_resize]。 @@ -4026,7 +4026,7 @@ grid_sample 经常与 affine_grid 配合使用,后者为 grid_sample 生成采 * *out_dtype*(*字符串*,可选):返回类型。如果为 None ,则返回与输入类型相同的类型。 * *output_shape*(tvm.tir.container.Array,*可选*):返回的形状。如果为 None,则推断为 None (如果形状是动态确定的,则将 out_dtype.shape 传递为 output_shape)。 * **返回:output** :形状为 [batch, channel, in_depth*scale, in_height*scale, in_width*scale] 或 [batch, in_depth*scale, in_height*scale, in_width*scale, channel] 的 4–D 或形状为 [batch, channel–major, in_depth*scale, in_height*scale, in_width*scale, channel–minor] 的 5–D。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.topi.image.simplify(*expr*) diff --git a/docs/04-api-reference/01-python-api/24-tvm-meta_schedule.md b/docs/04-api-reference/01-python-api/24-tvm-meta_schedule.md index a52b02b..d8b0785 100644 --- a/docs/04-api-reference/01-python-api/24-tvm-meta_schedule.md +++ b/docs/04-api-reference/01-python-api/24-tvm-meta_schedule.md @@ -11,30 +11,30 @@ tvm.meta_schedule 软件包。元调度基础设施。 **类:** -|[Builder](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Builder)|抽象构建器接口。| +|[Builder](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulebuilder)|抽象构建器接口。| |:----|:----| -|[CostModel](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.CostModel)|成本模型。| -|[Database](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database)|抽象数据库接口。| -|[ExtractedTask](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.ExtractedTask)(task_name,mod,target,…)|从高级 IR 中提取的调优任务。| -|[FeatureExtractor](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.FeatureExtractor)|从测量候选中提取特征以用于成本模型。| -|[MeasureCallback](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.MeasureCallback)|测量结果出来后适用的规则可用。| -|[Mutator](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Mutator)|Mutator 旨在改变轨迹以探索设计空间。| -|[Postproc](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Postproc)|将后处理器应用于调度的规则。| -|[Profiler](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Profiler)()|调整时间分析器。| -|[Runner](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Runner)|抽象运行器接口。| -|[ScheduleRule](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.ScheduleRule)|修改调度中的块的规则。| -|[MeasureCandidate](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.MeasureCandidate)(sch,args_info)|衡量候选类别。| -|[SearchStrategy](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.SearchStrategy)|搜索策略是生成度量候选的类。| -|[SpaceGenerator](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.SpaceGenerator)|抽象设计空间生成器接口。| -|[TaskScheduler](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TaskScheduler)|抽象任务调度程序接口。| -|[TuneContext](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TuneContext)([mod,target,space_generator,…])|调整上下文类旨在包含调整任务的所有资源。| +|[CostModel](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulecostmodel)|成本模型。| +|[Database](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduledatabase)|抽象数据库接口。| +|[ExtractedTask](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduleextractedtasktask_namestr-modirmodule-targettarget-dispatchedlistirmodule-weightint)(task_name,mod,target,…)|从高级 IR 中提取的调优任务。| +|[FeatureExtractor](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulefeatureextractor)|从测量候选中提取特征以用于成本模型。| +|[MeasureCallback](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemeasurecallback)|测量结果出来后适用的规则可用。| +|[Mutator](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemutator)|Mutator 旨在改变轨迹以探索设计空间。| +|[Postproc](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulepostproc)|将后处理器应用于调度的规则。| +|[Profiler](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduleprofiler)()|调整时间分析器。| +|[Runner](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulerunner)|抽象运行器接口。| +|[ScheduleRule](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduleschedulerule)|修改调度中的块的规则。| +|[MeasureCandidate](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemeasurecandidateschschedule-args_infolistarginfo)(sch,args_info)|衡量候选类别。| +|[SearchStrategy](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulesearchstrategy)|搜索策略是生成度量候选的类。| +|[SpaceGenerator](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulespacegenerator)|抽象设计空间生成器接口。| +|[TaskScheduler](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduletaskscheduler)|抽象任务调度程序接口。| +|[TuneContext](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduletunecontextmodirmodulenone-none--target-target--str--none--none-space_generator-spacegeneratorspacegeneratortype--none--none-search_strategy-searchstrategysearchstrategytype--none--none-task_name-str--main-rand_state-int---1-num_threads-int--typing_extensionsliteralphysical-logical--physical-logger-logger--none--none)([mod,target,space_generator,…])|调整上下文类旨在包含调整任务的所有资源。| **函数:** -|[tune_tir](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.tune_tir)(mod,target,work_dir,…[,…])|调整 TIR 函数或 TIR 函数的 IRModule。| +|[tune_tir](/docs/api-reference/python-api/tvm-meta_schedule#tvmmeta_scheduletune_tirmodirmoduleprimfunc-targetstrtarget-work_dirstr-max_trials_globalint--max_trials_per_task-int--none--none-num_trials_per_iter-int--64-builder-builder--typing_extensionsliterallocal--local-runner-runner--typing_extensionsliterallocal-rpc--local-database-database--typing_extensionsliteraljson-memory--json-cost_model-costmodel--typing_extensionsliteralxgb-mlp-random--xgb-measure_callbacks-listmeasurecallback--measurecallback--typing_extensionsliteraldefault--default-task_scheduler-literalgradient-round---robin--gradient-space-literalpost---order---apply-union--post-order-apply-strategy-literalreplay---func-replay---trace-evolutionary--evolutionary-num_tuning_cores-typing_extensionsliteralphysical-logical--int--physical-seed-int--none--none-module_equality-str--structural-special_space-literalpost---order---apply-union--none--none-post_optimization-bool--none--false--database)(mod,target,work_dir,…[,…])|调整 TIR 函数或 TIR 函数的 IRModule。| |:----|:----| -|[tune_tasks](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.tune_tasks)(*,tasks,task_weights,work_dir,…)|调整任务列表。使用任务调度程序。| -|[derived_object](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.derived_object)(cls)|用于为 TVM 对象注册派生子类的装饰器。| +|[tune_tasks](/docs/api-reference/python-api/tvm-meta_schedule#tvmmeta_scheduletune_tasks-tasks-listtunecontext-task_weights-listfloat-work_dir-str-max_trials_global-int-max_trials_per_task-int--none--none-num_trials_per_iter-int--64-builder-builder--typing_extensionsliterallocal--local-runner-runner--typing_extensionsliterallocal-rpc--local-database-database--typing_extensionsliteraljson-memory--json-cost_model-costmodel--typing_extensionsliteralxgb-mlp-random--xgb-measure_callbacks-listmeasurecallback--measurecallback--typing_extensionsliteraldefault--default-task_scheduler-literalgradient-round---robin--gradient-module_equality-str--structural-post_optimization-bool--none--false--database)(*,tasks,task_weights,work_dir,…)|调整任务列表。使用任务调度程序。| +|[derived_object](/docs/api-reference/python-api/tvm-meta_schedule#tvmmeta_schedulederived_objectclstype--type)(cls)|用于为 TVM 对象注册派生子类的装饰器。| ## *class* tvm.meta_schedule.Builder @@ -44,9 +44,9 @@ tvm.meta_schedule 软件包。元调度基础设施。 **方法:** -|[build](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Builder.build)(build_inputs)|构建给定的输入。| +|[build](/docs/api-reference/python-api/tvm-meta_schedule#buildbuild_inputslistbuilderinput--listbuilderresult)(build_inputs)|构建给定的输入。| |:----|:----| -|[create](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Builder.create)([kind])|创建一个构建器。| +|[create](/docs/api-reference/python-api/tvm-meta_schedule#static-createkind-typing_extensionsliterallocal--local-args-kwargs--builder)([kind])|创建一个构建器。| ### build(*build_inputs:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[BuilderInput]*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[BuilderResult] @@ -56,13 +56,13 @@ tvm.meta_schedule 软件包。元调度基础设施。 * **返回:build_results**:构建给定输入的结果。 * **返回类型:** List[BuilderResult]。 -### *static* create(*kind: typing_extensions.Literal[local] = 'local'*, args*, ***kwargs*) → [Builder](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Builder) +### *static* create(*kind: typing_extensions.Literal[local] = 'local'*, args*, ***kwargs*) → [Builder](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulebuilder) 创建一个构建器。 * **参数:kind** (*Literal*[*"local"]*):构建器的类型。目前仅支持「local」。 * **返回:builder**:构建器创建。 -* **返回类型:**[Builder](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Builder)。 +* **返回类型:**[Builder](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulebuilder)。 ## *class* tvm.meta_schedule.CostModel @@ -72,12 +72,12 @@ tvm.meta_schedule 软件包。元调度基础设施。 **方法:** -|[load](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.CostModel.load)(path)|从给定的文件位置加载成本模型。| +|[load](/docs/api-reference/python-api/tvm-meta_schedule#loadpathstr--none)(path)|从给定的文件位置加载成本模型。| |:----|:----| -|[save](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.CostModel.save)(path)|将成本模型保存到给定的文件位置。| -|[update](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.CostModel.update)(context, candidates, results)|根据运行结果更新成本模型。| -|[predict](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.CostModel.predict)(context, candidates)|使用成本模型预测标准化分数。| -|[create](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.CostModel.create)(kind, *args, **kwargs)|创建一个 CostModel。| +|[save](/docs/api-reference/python-api/tvm-meta_schedule#savepathstr--none)(path)|将成本模型保存到给定的文件位置。| +|[update](/docs/api-reference/python-api/tvm-meta_schedule#updatecontexttunecontext-candidateslistmeasurecandidate-resultslistrunnerresult--none)(context, candidates, results)|根据运行结果更新成本模型。| +|[predict](/docs/api-reference/python-api/tvm-meta_schedule#predictcontexttunecontext-candidateslistmeasurecandidate--ndarray)(context, candidates)|使用成本模型预测标准化分数。| +|[create](/docs/api-reference/python-api/tvm-meta_schedule#static-createkind-typing_extensionsliteralxgb-mlp-random-none-args-kwargs--costmodel)(kind, *args, **kwargs)|创建一个 CostModel。| ### load(*path:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [None](https://docs.python.org/3/library/constants.html#None) @@ -91,31 +91,31 @@ tvm.meta_schedule 软件包。元调度基础设施。 将成本模型保存到给定的文件位置。 * **参数:path** ([str](https://docs.python.org/3/library/stdtypes.html#str)):文件路径。 -### update(*context:*[TuneContext](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TuneContext), *candidates:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[MeasureCandidate](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.MeasureCandidate)*]*, *results:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[RunnerResult]*) → [None](https://docs.python.org/3/library/constants.html#None) +### update(*context:*[TuneContext](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduletunecontextmodirmodulenone-none--target-target--str--none--none-space_generator-spacegeneratorspacegeneratortype--none--none-search_strategy-searchstrategysearchstrategytype--none--none-task_name-str--main-rand_state-int---1-num_threads-int--typing_extensionsliteralphysical-logical--physical-logger-logger--none--none), *candidates:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[MeasureCandidate](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemeasurecandidateschschedule-args_infolistarginfo)*]*, *results:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[RunnerResult]*) → [None](https://docs.python.org/3/library/constants.html#None) 根据运行结果更新成本模型。 * **参数:** - * **context** ( [TuneContext](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TuneContext)*,* ) :调整上下文。 - * candidates(*列表*[ [MeasureCandidate](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.MeasureCandidate)*]*):衡量 candidates。 + * **context** ( [TuneContext](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduletunecontextmodirmodulenone-none--target-target--str--none--none-space_generator-spacegeneratorspacegeneratortype--none--none-search_strategy-searchstrategysearchstrategytype--none--none-task_name-str--main-rand_state-int---1-num_threads-int--typing_extensionsliteralphysical-logical--physical-logger-logger--none--none)*,* ) :调整上下文。 + * candidates(*列表*[ [MeasureCandidate](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemeasurecandidateschschedule-args_infolistarginfo)*]*):衡量 candidates。 * *results*( *List[RunnerResult]* ) :度量候选的运行结果。 -### predict(*context:*[TuneContext](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TuneContext), *candidates:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[MeasureCandidate](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.MeasureCandidate)*]*) → ndarray +### predict(*context:*[TuneContext](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduletunecontextmodirmodulenone-none--target-target--str--none--none-space_generator-spacegeneratorspacegeneratortype--none--none-search_strategy-searchstrategysearchstrategytype--none--none-task_name-str--main-rand_state-int---1-num_threads-int--typing_extensionsliteralphysical-logical--physical-logger-logger--none--none), *candidates:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[MeasureCandidate](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemeasurecandidateschschedule-args_infolistarginfo)*]*) → ndarray 使用成本模型预测标准化分数。 * **参数:** - * **context** ( [TuneContext](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TuneContext)*,* ) :调整上下文。 - * candidates(*列表*[ [MeasureCandidate](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.MeasureCandidate)*]*):衡量 candidates。 + * **context** ( [TuneContext](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduletunecontextmodirmodulenone-none--target-target--str--none--none-space_generator-spacegeneratorspacegeneratortype--none--none-search_strategy-searchstrategysearchstrategytype--none--none-task_name-str--main-rand_state-int---1-num_threads-int--typing_extensionsliteralphysical-logical--physical-logger-logger--none--none)*,* ) :调整上下文。 + * candidates(*列表*[ [MeasureCandidate](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemeasurecandidateschschedule-args_infolistarginfo)*]*):衡量 candidates。 * **返回:result**:预测的标准分数。 * **返回类型:** np.ndarray。 -### *static* create(*kind: typing_extensions.Literal[xgb, mlp, random, none]*, args*, ***kwargs*) → [CostModel](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.CostModel) +### *static* create(*kind: typing_extensions.Literal[xgb, mlp, random, none]*, args*, ***kwargs*) → [CostModel](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulecostmodel) 创建一个 CostModel。 * **参数:** 成本模型的种类。可以是“xgb”、“mlp”、“random”或“none”。 -* **返回:cost_model**[:](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.CostModel)创建的成本模型。 -* **返回类型:**[CostModel](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.CostModel) +* **返回:cost_model**[:](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulecostmodel)创建的成本模型。 +* **返回类型:**[CostModel](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulecostmodel) ## *class* tvm.meta_schedule.Database @@ -124,34 +124,34 @@ tvm.meta_schedule 软件包。元调度基础设施。 **方法:** -|[has_workload](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database.has_workload)(mod)|检查数据库是否具有给定的工作负载。| +|[has_workload](/docs/api-reference/python-api/tvm-meta_schedule#has_workloadmodirmodule--bool)(mod)|检查数据库是否具有给定的工作负载。| |:----|:----| -|[commit_workload](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database.commit_workload)(mod)|如果缺失,则将工作负载提交到数据库。| -|[commit_tuning_record](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database.commit_tuning_record)(record)|将调整记录提交到数据库。| -|[get_top_k](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database.get_top_k)(workload, top_k)|从数据库中获取给定工作负载的前 K 条有效调优记录。| -|[get_all_tuning_records](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database.get_all_tuning_records)()|从数据库中获取所有调优记录。| -|[query_tuning_record](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database.query_tuning_record)(mod, target, workload_name)|从数据库中查询给定工作量的最佳记录。| -|[query_schedule](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database.query_schedule)(mod, target, workload_name)|从数据库中查询给定工作负载的最佳调度。| -|[query_ir_module](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database.query_ir_module)(mod, target, workload_name)|从数据库中查询给定工作负载的最佳 IRModule。| -|[dump_pruned](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database.dump_pruned)(destination)|将修剪后的数据库转储为 JSONDatabase 格式的文件。| -|[query](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database.query)(mod, target, *[, workload_name, kind])|查询数据库以检索给定工作负载的最佳优化结果。| -|[current](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database.current)()|获取范围内的当前数据库。| -|[create](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database.create)([kind])|创建数据库。| +|[commit_workload](/docs/api-reference/python-api/tvm-meta_schedule#commit_workloadmodirmodule--workload)(mod)|如果缺失,则将工作负载提交到数据库。| +|[commit_tuning_record](/docs/api-reference/python-api/tvm-meta_schedule#commit_tuning_recordrecord-tuningrecord--none)(record)|将调整记录提交到数据库。| +|[get_top_k](/docs/api-reference/python-api/tvm-meta_schedule#get_top_kworkload-workload-top_kint--listtuningrecord)(workload, top_k)|从数据库中获取给定工作负载的前 K 条有效调优记录。| +|[get_all_tuning_records](/docs/api-reference/python-api/tvm-meta_schedule#get_all_tuning_records--listtuningrecord)()|从数据库中获取所有调优记录。| +|[query_tuning_record](/docs/api-reference/python-api/tvm-meta_schedule#query_tuning_recordmodirmodule-targettarget-workload_namestr--tuningrecord--none)(mod, target, workload_name)|从数据库中查询给定工作量的最佳记录。| +|[query_schedule](/docs/api-reference/python-api/tvm-meta_schedule#query_schedulemodirmodule-targettarget-workload_namestr--schedule--none)(mod, target, workload_name)|从数据库中查询给定工作负载的最佳调度。| +|[query_ir_module](/docs/api-reference/python-api/tvm-meta_schedule#query_ir_modulemodirmodule-targettarget-workload_namestr--irmodule--none)(mod, target, workload_name)|从数据库中查询给定工作负载的最佳 IRModule。| +|[dump_pruned](/docs/api-reference/python-api/tvm-meta_schedule#dump_pruneddestinationdatabase--none)(destination)|将修剪后的数据库转储为 JSONDatabase 格式的文件。| +|[query](/docs/api-reference/python-api/tvm-meta_schedule#querymodirmodule-targettarget--workload_name-str--main-kind-typing_extensionsliteralschedule--typing_extensionsliteralrecord--typing_extensionsliteralir_module--schedule--schedule--irmodule--tuningrecord)(mod, target, *[, workload_name, kind])|查询数据库以检索给定工作负载的最佳优化结果。| +|[current](/docs/api-reference/python-api/tvm-meta_schedule#static-current--database--none)()|获取范围内的当前数据库。| +|[create](/docs/api-reference/python-api/tvm-meta_schedule#static-createkind-typing_extensionsliteraljson-memory-union-ordered_union-callableschedulebool--json-args-kwargs--database)([kind])|创建数据库。| -### has_workload(*mod:*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)) → [bool](https://docs.python.org/3/library/functions.html#bool) +### has_workload(*mod:*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)) → [bool](https://docs.python.org/3/library/functions.html#bool) 检查数据库是否具有给定的工作负载。:param mod: 要搜索的 IRModule。:type mod: IRModule。 * **返回:result**:数据库是否具有给定的工作负载。 * **返回类型:**[bool](https://docs.python.org/3/library/functions.html#bool)。 -### commit_workload(*mod:*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)) → Workload +### commit_workload(*mod:*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)) → Workload 如果缺失,则将工作负载提交到数据库。 -* **参数:mod** ([IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)):要搜索或添加的 IRModule。 -* **返回:workload**[:](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.Workload)与给定 IRModule 对应的工作负载。 -* **返回类型:**[Workload](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.Workload)。 +* **参数:mod** ([IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)):要搜索或添加的 IRModule。 +* **返回:workload**:与给定 IRModule 对应的工作负载。 +* **返回类型:**[Workload](/docs/api-reference/python-api/tvm-topi#class-tvmtopinnworkloadin_dtype-out_dtype-height-width-in_filter-out_filter-kernel_h-kernel_w-padt-padl-padb-padr-dilation_h-dilation_w-stride_h-stride_w)。 ### commit_tuning_record(*record: TuningRecord*) → [None](https://docs.python.org/3/library/constants.html#None) @@ -164,7 +164,7 @@ tvm.meta_schedule 软件包。元调度基础设施。 从数据库中获取给定工作负载的前 K 条有效调优记录。 * **参数:** - * **工作负载**([Workload](https://tvm.apache.org/docs/reference/api/python/topi.html#tvm.topi.nn.Workload)) :要搜索的工作负载。 + * **工作负载**([Workload](/docs/api-reference/python-api/tvm-topi#class-tvmtopinnworkloadin_dtype-out_dtype-height-width-in_filter-out_filter-kernel_h-kernel_w-padt-padl-padb-padr-dilation_h-dilation_w-stride_h-stride_w)) :要搜索的工作负载。 * **top_k** ( [int](https://docs.python.org/3/library/functions.html#int) ) :要获取的顶级记录的数量。 * **返回:top_k_records**:前 K 条记录。 * **返回类型:** List[TuningRecord]。 @@ -176,62 +176,62 @@ tvm.meta_schedule 软件包。元调度基础设施。 * **返回:tuning_records**:来自数据库的所有调整记录。 * **返回类型:** List[TuningRecord]。 -### query_tuning_record(*mod:*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule), *target:*[Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target), *workload_name:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → TuningRecord | [None](https://docs.python.org/3/library/constants.html#None) +### query_tuning_record(*mod:*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone), *target:*[Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone), *workload_name:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → TuningRecord | [None](https://docs.python.org/3/library/constants.html#None) 从数据库中查询给定工作量的最佳记录。 * **参数:** - * **mod**([IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)) :要搜索的 IRModule。 - * **目标**([Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target)) :要搜索的目标。 + * **mod**([IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)) :要搜索的 IRModule。 + * **目标**([Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone)) :要搜索的目标。 * **workload_name** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ) :要搜索的工作负载的名称。 * **返回:tuning_record**:给定工作负载的最佳记录;如果未找到,则返回 None。 * **返回类型:** Optional[TuningRecord]。 -### query_schedule(*mod:*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule), *target:*[Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target), *workload_name:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [Schedule](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule) | [None](https://docs.python.org/3/library/constants.html#None) +### query_schedule(*mod:*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone), *target:*[Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone), *workload_name:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [Schedule](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulemodprimfuncirmodule--seed-int--none--none-debug_mask-str--int--none-error_render_level-str--detail-enable_check-bool--true) | [None](https://docs.python.org/3/library/constants.html#None) 从数据库中查询给定工作负载的最佳调度。 * **参数:** - * **mod**([IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)) :要搜索的 IRModule。 - * **目标**([Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target)) **:** 要搜索的目标。 + * **mod**([IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)) :要搜索的 IRModule。 + * **目标**([Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone)) **:** 要搜索的目标。 * **workload_name** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ) :要搜索的工作负载的名称。 * **返回:schedule**:给定工作负载的最佳调度;如果未找到,则为 None。 * **返回类型:** Optional[tvm.tir.Schedule]。 -### query_ir_module(*mod:*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule), *target:*[Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target), *workload_name:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule) | [None](https://docs.python.org/3/library/constants.html#None) +### query_ir_module(*mod:*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone), *target:*[Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone), *workload_name:*[str](https://docs.python.org/3/library/stdtypes.html#str)) → [IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone) | [None](https://docs.python.org/3/library/constants.html#None) 从数据库中查询给定工作负载的最佳 IRModule。 * **参数:** - * **mod**([IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)) :要搜索的 IRModule。 - * **目标**([Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target)) **:** 要搜索的目标。 + * **mod**([IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)) :要搜索的 IRModule。 + * **目标**([Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone)) **:** 要搜索的目标。 * **workload_name** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ) :要搜索的工作负载的名称。 * **返回:ir_module**:给定工作负载的最佳 IRModule;如果未找到,则为 None。 -* **返回类型:** Optional[[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)]。 +* **返回类型:** Optional[[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)]。 -### dump_pruned(*destination:*[Database](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database)) → [None](https://docs.python.org/3/library/constants.html#None) +### dump_pruned(*destination:*[Database](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduledatabase)) → [None](https://docs.python.org/3/library/constants.html#None) 将修剪后的数据库转储为 JSONDatabase 格式的文件。 -* **参数:destination** ([Database](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database)):要转储到的目标数据库。 +* **参数:destination** ([Database](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduledatabase)):要转储到的目标数据库。 -### query(*mod:*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule), *target:*[Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target), *, *workload_name: [str](https://docs.python.org/3/library/stdtypes.html#str) = 'main'*, *kind: typing_extensions.Literal[schedule] | typing_extensions.Literal[record] | typing_extensions.Literal[ir_module] = 'schedule'*) → [Schedule](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule) | [IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule) | TuningRecord +### query(*mod:*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone), *target:*[Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone), *, *workload_name: [str](https://docs.python.org/3/library/stdtypes.html#str) = 'main'*, *kind: typing_extensions.Literal[schedule] | typing_extensions.Literal[record] | typing_extensions.Literal[ir_module] = 'schedule'*) → [Schedule](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulemodprimfuncirmodule--seed-int--none--none-debug_mask-str--int--none-error_render_level-str--detail-enable_check-bool--true) | [IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone) | TuningRecord 查询数据库以检索给定工作负载的最佳优化结果。 * **参数:** - * **mod**([IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)) :要搜索的 IRModule。 - * **目标**([Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target)) *:* 要搜索的目标。 + * **mod**([IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)) :要搜索的 IRModule。 + * **目标**([Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone)) *:* 要搜索的目标。 * **kind**(*str =“schedule”|“record”|“ir_module”*)**:** 要返回的优化结果的类型。 * **返回:result** *:* 给定工作负载的最佳优化结果。 -* **返回类型:** Union[tvm.tir.Schedule, [IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule), TuningRecord]。 +* **返回类型:** Union[tvm.tir.Schedule, [IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone), TuningRecord]。 -### *static* current() → [Database](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database) | [None](https://docs.python.org/3/library/constants.html#None) +### *static* current() → [Database](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduledatabase) | [None](https://docs.python.org/3/library/constants.html#None) 获取范围内的当前数据库。 -### *static* create(*kind: typing_extensions.Literal[json, memory, union, ordered_union] |*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*[[*[Schedule](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule)*],*[bool](https://docs.python.org/3/library/functions.html#bool)*] = 'json'*, args*, ***kwargs*) → [Database](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database) +### *static* create(*kind: typing_extensions.Literal[json, memory, union, ordered_union] |*[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)*[[*[Schedule](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulemodprimfuncirmodule--seed-int--none--none-debug_mask-str--int--none-error_render_level-str--detail-enable_check-bool--true)*],*[bool](https://docs.python.org/3/library/functions.html#bool)*] = 'json'*, args*, ***kwargs*) → [Database](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduledatabase) 创建数据库。 @@ -239,17 +239,17 @@ tvm.meta_schedule 软件包。元调度基础设施。 * **kind** (*str = "json"|"memory"|"union"|"ordered_union"|Callable**[****[**tvm.tir.Schedule****],*)。 * **bool** :要创建的数据库类型。支持以下类型:“json”、“memory”、“union”、“ordered_union”和自定义调度函数。 * **返回:database**:创建的数据库。 -* **返回类型:**[Database](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database)。 +* **返回类型:**[Database](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduledatabase)。 -## *class* tvm.meta_schedule.ExtractedTask(*task_name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *mod:*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule), *target:*[Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target), *dispatched:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)*]*, *weight:*[int](https://docs.python.org/3/library/functions.html#int)) +## *class* tvm.meta_schedule.ExtractedTask(*task_name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *mod:*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone), *target:*[Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone), *dispatched:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)*]*, *weight:*[int](https://docs.python.org/3/library/functions.html#int)) 从高级 IR 中提取的调优任务。 * **参数:** - * **task_name** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ) [:](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)提取的任务名称。 - * **mod** ( [IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule) ) :高级 IR。 - * **目标**([Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target)) *:* 目标信息。 - * *dispatched*( *List[*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)*]* ) :高级 IR 可能分派到的低级 IR 列表。 + * **task_name** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ) [:](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)提取的任务名称。 + * **mod** ( [IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone) ) :高级 IR。 + * **目标**([Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone)) *:* 目标信息。 + * *dispatched*( *List[*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)*]* ) :高级 IR 可能分派到的低级 IR 列表。 * **weight**([int](https://docs.python.org/3/library/functions.html#int)) :任务的权重。 ## *class* tvm.meta_schedule.FeatureExtractor @@ -260,21 +260,21 @@ tvm.meta_schedule 软件包。元调度基础设施。 **方法:** -|[extract_from](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.FeatureExtractor.extract_from)(context, candidates)|从给定的测量候选中提取特征。| +|[extract_from](/docs/api-reference/python-api/tvm-meta_schedule#extract_fromcontexttunecontext-candidateslistmeasurecandidate--listndarray)(context, candidates)|从给定的测量候选中提取特征。| |:----|:----| -|[create](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.FeatureExtractor.create)(kind, *args, **kwargs)|创建一个 CostModel。| +|[create](/docs/api-reference/python-api/tvm-meta_schedule#static-createkind-typing_extensionsliteralper---store---feature-args-kwargs--featureextractor)(kind, *args, **kwargs)|创建一个 CostModel。| -### extract_from(*context:*[TuneContext](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TuneContext), *candidates:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[MeasureCandidate](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.MeasureCandidate)*]*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray)] +### extract_from(*context:*[TuneContext](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduletunecontextmodirmodulenone-none--target-target--str--none--none-space_generator-spacegeneratorspacegeneratortype--none--none-search_strategy-searchstrategysearchstrategytype--none--none-task_name-str--main-rand_state-int---1-num_threads-int--typing_extensionsliteralphysical-logical--physical-logger-logger--none--none), *candidates:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[MeasureCandidate](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemeasurecandidateschschedule-args_infolistarginfo)*]*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[NDArray] 从给定的测量候选中提取特征。 * **参数:** - * **context**([TuneContext](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TuneContext))[:](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.MeasureCandidate)特征提取的调整上下文。 - * **candidates*(*列表**[ [MeasureCandidate](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.MeasureCandidate)*]*):从中提取特征的测量 candidates。 + * **context**([TuneContext](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduletunecontextmodirmodulenone-none--target-target--str--none--none-space_generator-spacegeneratorspacegeneratortype--none--none-search_strategy-searchstrategysearchstrategytype--none--none-task_name-str--main-rand_state-int---1-num_threads-int--typing_extensionsliteralphysical-logical--physical-logger-logger--none--none))[:](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemeasurecandidateschschedule-args_infolistarginfo)特征提取的调整上下文。 + * **candidates*(*列表**[ [MeasureCandidate](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemeasurecandidateschschedule-args_infolistarginfo)*]*):从中提取特征的测量 candidates。 * **返回:features** *:* tvm ndarray 提取的特征。 -* **返回类型:** List[[NDArray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html#tvm.runtime.ndarray.NDArray)]。 +* **返回类型:** List[NDArray]。 -### *static* create(*kind: typing_extensions.Literal[per - store - feature]*, args*, ***kwargs*) → [FeatureExtractor](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.FeatureExtractor) +### *static* create(*kind: typing_extensions.Literal[per - store - feature]*, args*, ***kwargs*) → [FeatureExtractor](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulefeatureextractor) 创建一个 CostModel。 @@ -287,22 +287,22 @@ tvm.meta_schedule 软件包。元调度基础设施。 **方法:** -|[apply](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.MeasureCallback.apply)(task_scheduler, task_id, …)|将测量回调应用于给定的调度。| +|[apply](/docs/api-reference/python-api/tvm-meta_schedule#applytask_schedulertaskscheduler-task_idint-measure_candidateslistmeasurecandidate-builder_resultslistbuilderresult-runner_resultslistrunnerresult--none)(task_scheduler, task_id, …)|将测量回调应用于给定的调度。| |:----|:----| -|[create](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.MeasureCallback.create)(kind)|创建测量回调列表。| +|[create](/docs/api-reference/python-api/tvm-meta_schedule#static-createkind-typing_extensionsliteraldefault--listmeasurecallback)(kind)|创建测量回调列表。| -### apply(*task_scheduler:*[TaskScheduler](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TaskScheduler), *task_id:*[int](https://docs.python.org/3/library/functions.html#int), *measure_candidates:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[MeasureCandidate](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.MeasureCandidate)*]*, *builder_results:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[BuilderResult]*, *runner_results:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[RunnerResult]*) → [None](https://docs.python.org/3/library/constants.html#None) +### apply(*task_scheduler:*[TaskScheduler](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduletaskscheduler), *task_id:*[int](https://docs.python.org/3/library/functions.html#int), *measure_candidates:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[MeasureCandidate](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemeasurecandidateschschedule-args_infolistarginfo)*]*, *builder_results:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[BuilderResult]*, *runner_results:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[RunnerResult]*) → [None](https://docs.python.org/3/library/constants.html#None) 将测量回调应用于给定的调度。 * **参数:** - * **task_scheduler**([TaskScheduler](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TaskScheduler)) :任务调度程序。 + * **task_scheduler**([TaskScheduler](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduletaskscheduler)) :任务调度程序。 * **task_id** ( [int](https://docs.python.org/3/library/functions.html#int) ) *:* 任务 ID。 - * *measure_candidates* ( *List[*[MeasureCandidate](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.MeasureCandidate)*]* ) :测量候选对象。 + * *measure_candidates* ( *List[*[MeasureCandidate](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemeasurecandidateschschedule-args_infolistarginfo)*]* ) :测量候选对象。 * *builder_results* ( *List[BuilderResult]* ) *:* 通过构建度量候选来获得构建器结果。 * *runner_results* ( *List[RunnerResult]* ) *:* 通过运行构建的测量候选结果来获得运行器的结果。 -### *static* create(*kind: typing_extensions.Literal[default]*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[MeasureCallback](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.MeasureCallback)] +### *static* create(*kind: typing_extensions.Literal[default]*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[MeasureCallback](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemeasurecallback)] 创建测量回调列表。 @@ -315,33 +315,33 @@ Mutator 旨在改变轨迹以探索设计空间。 **方法:** -|[apply](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Mutator.apply)(trace)|将变异函数应用于给定的跟踪。| +|[apply](/docs/api-reference/python-api/tvm-meta_schedule#applytracetrace--trace--none)(trace)|将变异函数应用于给定的跟踪。| |:----|:----| -|[clone](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Mutator.clone)()|克隆变异器。| -|[create](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Mutator.create)(kind)|创建默认变量列表。| +|[clone](/docs/api-reference/python-api/tvm-meta_schedule#clone--mutator)()|克隆变异器。| +|[create](/docs/api-reference/python-api/tvm-meta_schedule#static-createkind-typing_extensionsliteralllvm-cuda-cuda---tensorcore-hexagon--dictmutator-float)(kind)|创建默认变量列表。| -### apply(*trace:*[Trace](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Trace)) → [Trace](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Trace) | [None](https://docs.python.org/3/library/constants.html#None) +### apply(*trace:*[Trace](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduletraceinstslistinstruction-decisionsdictinstructionany)) → [Trace](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduletraceinstslistinstruction-decisionsdictinstructionany) | [None](https://docs.python.org/3/library/constants.html#None) 将变异函数应用于给定的跟踪。 -* **参数:trace** ([Trace](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Trace))[:](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Mutator)给定的突变轨迹。 +* **参数:trace** ([Trace](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduletraceinstslistinstruction-decisionsdictinstructionany)):给定的突变轨迹。 * **返回:trace**:如果变异器失败则返回 None,否则返回变异的跟踪。 -* **返回类型:** Optional[[Trace](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Trace)]。 +* **返回类型:** Optional[[Trace](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduletraceinstslistinstruction-decisionsdictinstructionany)]。 -### clone() → [Mutator](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Mutator) +### clone() → [Mutator](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemutator) 克隆变异器。 * **返回:mutator**:–已克隆的 mutator。 -* **返回类型:**[Mutator](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Mutator)。 +* **返回类型:**[Mutator](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemutator)。 -### *static* create(*kind: typing_extensions.Literal[llvm, cuda, cuda - tensorcore, hexagon]*) → [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)[[Mutator](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Mutator), [float](https://docs.python.org/3/library/functions.html#float)] +### *static* create(*kind: typing_extensions.Literal[llvm, cuda, cuda - tensorcore, hexagon]*) → [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)[[Mutator](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemutator), [float](https://docs.python.org/3/library/functions.html#float)] 创建默认变量列表。 * **参数:kind** (Literal[**"llvm"**, "cuda","cuda-tensorcore"*, "hexagon"]):tensorcore”* ,“hexagon”) **:** 变量的种类。 * **返回:mutators**:修改器列表。 -* **返回类型:** List[[Mutator](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Mutator)]。 +* **返回类型:** List[[Mutator](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemutator)]。 ## *class* tvm.meta_schedule.Postproc @@ -351,12 +351,12 @@ Mutator 旨在改变轨迹以探索设计空间。 **方法:** -|[apply](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Postproc.apply)(sch)|将后处理器应用于给定的调度。| +|[apply](/docs/api-reference/python-api/tvm-meta_schedule#applyschschedule--bool)(sch)|将后处理器应用于给定的调度。| |:----|:----| -|[clone](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Postproc.clone)()|克隆后处理器。| -|[create](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Postproc.create)(kind)|创建默认后处理器列表。| +|[clone](/docs/api-reference/python-api/tvm-meta_schedule#clone--postproc)()|克隆后处理器。| +|[create](/docs/api-reference/python-api/tvm-meta_schedule#static-createkind-typing_extensionsliteralllvm-cuda-cuda---tensorcore-hexagon--listpostproc)(kind)|创建默认后处理器列表。| -### apply(*sch:*[Schedule](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule)) → [bool](https://docs.python.org/3/library/functions.html#bool) +### apply(*sch:*[Schedule](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulemodprimfuncirmodule--seed-int--none--none-debug_mask-str--int--none-error_render_level-str--detail-enable_check-bool--true)) → [bool](https://docs.python.org/3/library/functions.html#bool) 将后处理器应用于给定的调度。 @@ -364,20 +364,20 @@ Mutator 旨在改变轨迹以探索设计空间。 * **返回:result**:后处理器是否成功应用。 * **返回类型:**[bool](https://docs.python.org/3/library/functions.html#bool)。 -### clone() → [Postproc](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Postproc) +### clone() → [Postproc](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulepostproc) 克隆后处理器。 * **返回:cloned_postproc**:克隆的后处理器。 -* **返回类型:**[Postproc](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Postproc)。 +* **返回类型:**[Postproc](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulepostproc)。 -### *static* create(*kind: typing_extensions.Literal[llvm, cuda, cuda - tensorcore, hexagon]*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Postproc](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Postproc)] +### *static* create(*kind: typing_extensions.Literal[llvm, cuda, cuda - tensorcore, hexagon]*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Postproc](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulepostproc)] 创建默认后处理器列表。 * **参数:kind** (*Literal**[****"llvm"**,*** ***"cuda"****,"cuda-tensorcore"**,*** ***"hexagon"****]*)*:*tensorcore”* *,“hexagon”*) :后处理器的种类。 * **返回:postprocs**:后处理器列表。 -* **返回类型:** List[[Mutator](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Mutator)]。 +* **返回类型:** List[[Mutator](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemutator)]。 ## *class* tvm.meta_schedule.Profiler @@ -387,11 +387,11 @@ Mutator 旨在改变轨迹以探索设计空间。 **方法:** -|[get](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Profiler.get)()|几秒钟内即可获得分析结果。| +|[get](http://tvm.hyper.ai/docs/api-reference/python-api/tvm-meta_schedule#get--dictstr-float)()|几秒钟内即可获得分析结果。| |:----|:----| -|[table](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Profiler.table)()|以表格形式获取分析结果。| -|[current](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Profiler.current)()|获取当前分析器。| -|[timeit](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Profiler.timeit)(name)|Timeit 代码块。| +|[table](/docs/api-reference/python-api/tvm-meta_schedule#table--str)()|以表格形式获取分析结果。| +|[current](/docs/api-reference/python-api/tvm-meta_schedule#static-current--profiler--none)()|获取当前分析器。| +|[timeit](/docs/api-reference/python-api/tvm-meta_schedule#static-timeitnamestr)(name)|Timeit 代码块。| ### get() → [Dict](https://docs.python.org/3/library/typing.html#typing.Dict)[[str](https://docs.python.org/3/library/stdtypes.html#str), [float](https://docs.python.org/3/library/functions.html#float)] @@ -402,7 +402,7 @@ Mutator 旨在改变轨迹以探索设计空间。 以表格形式获取分析结果。 -### *static* current() → [Profiler](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Profiler) | [None](https://docs.python.org/3/library/constants.html#None) +### *static* current() → [Profiler](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduleprofiler) | [None](https://docs.python.org/3/library/constants.html#None) 获取当前分析器。 @@ -418,9 +418,9 @@ Timeit 代码块。 **方法:** -|[run](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Runner.run)(runner_inputs)|运行构建的工件并获取运行器未来。| +|[run](/docs/api-reference/python-api/tvm-meta_schedule#runrunner_inputslistrunnerinput--listrunnerfuture)(runner_inputs)|运行构建的工件并获取运行器未来。| |:----|:----| -|[create](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Runner.create)([kind])|创建一个 Runner。| +|[create](/docs/api-reference/python-api/tvm-meta_schedule#static-createkind-typing_extensionsliterallocal-rpc--local-args-kwargs--runner)([kind])|创建一个 Runner。| ### run(*runner_inputs:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[RunnerInput]*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[RunnerFuture] @@ -430,7 +430,7 @@ Timeit 代码块。 * **返回:runner_futures**:运行器的未来。 * **返回类型:** List[RunnerFuture] -### *static* create(*kind: typing_extensions.Literal[local, rpc] = 'local'*, args*, ***kwargs*) → [Runner](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Runner) +### *static* create(*kind: typing_extensions.Literal[local, rpc] = 'local'*, args*, ***kwargs*) → [Runner](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulerunner) 创建一个 Runner。 @@ -443,37 +443,37 @@ Timeit 代码块。 **方法:** -|[apply](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.ScheduleRule.apply)(sch, block)|将调度规则应用于给定调度中的特定块。| +|[apply](/docs/api-reference/python-api/tvm-meta_schedule#applyschschedule-blockblockrv--listschedule)(sch, block)|将调度规则应用于给定调度中的特定块。| |:----|:----| -|[clone](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.ScheduleRule.clone)()|深度克隆调度规则。| -|[create](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.ScheduleRule.create)(kind)|为给定类型创建调度规则列表。| +|[clone](/docs/api-reference/python-api/tvm-meta_schedule#clone--schedulerule)()|深度克隆调度规则。| +|[create](/docs/api-reference/python-api/tvm-meta_schedule#static-createkind-typing_extensionsliteralllvm-cuda-cuda---tensorcore-hexagon--listschedulerule)(kind)|为给定类型创建调度规则列表。| -### apply(*sch:*[Schedule](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule), *block:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Schedule](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule)] +### apply(*sch:*[Schedule](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulemodprimfuncirmodule--seed-int--none--none-debug_mask-str--int--none-error_render_level-str--detail-enable_check-bool--true), *block:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Schedule](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulemodprimfuncirmodule--seed-int--none--none-debug_mask-str--int--none-error_render_level-str--detail-enable_check-bool--true)] 将调度规则应用于给定调度中的特定块。 * **参数:** * **sch**(*tvm.tir.Schedule*):要修改的调度。 - * **块**([BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV)):应用调度规则的特定块。 -* **返回:design_spaces**[:](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.ScheduleRule)应用调度规则生成的调度列表。 + * **块**([BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv)):应用调度规则的特定块。 +* **返回:design_spaces**:应用调度规则生成的调度列表。 * **返回类型:** List[tvm.tir.Schedule]。 -### clone() → [ScheduleRule](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.ScheduleRule) +### clone() → [ScheduleRule](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduleschedulerule) 深度克隆调度规则。 -* **返回:cloned_rule**[:](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.ScheduleRule)克隆的调度规则。 -* **返回类型:**[ScheduleRule](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.ScheduleRule)。 +* **返回:cloned_rule**:克隆的调度规则。 +* **返回类型:**[ScheduleRule](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduleschedulerule)。 -### *static* create(*kind: typing_extensions.Literal[llvm, cuda, cuda - tensorcore, hexagon]*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[ScheduleRule](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.ScheduleRule)] +### *static* create(*kind: typing_extensions.Literal[llvm, cuda, cuda - tensorcore, hexagon]*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[ScheduleRule](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduleschedulerule)] 为给定类型创建调度规则列表。 * **参数:kind** (*Literal**[****"llvm"**,*** ***"cuda"****,"cuda-tensorcore"**,*** ***"hexagon"****]*):tensorcore"* *,"hexagon"]*) :调度规则的种类。 -* **返回:rules**[:](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.ScheduleRule)调度规则列表。 -* **返回类型:** List[[ScheduleRule](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.ScheduleRule)]。 +* **返回:rules**:调度规则列表。 +* **返回类型:** List[[ScheduleRule](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduleschedulerule)]。 -## *class* tvm.meta_schedule.MeasureCandidate(*sch:*[Schedule](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule), *args_info:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[ArgInfo]*) +## *class* tvm.meta_schedule.MeasureCandidate(*sch:*[Schedule](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulemodprimfuncirmodule--seed-int--none--none-debug_mask-str--int--none-error_render_level-str--detail-enable_check-bool--true), *args_info:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[ArgInfo]*) 衡量候选类别。 * **参数:** @@ -488,51 +488,51 @@ Timeit 代码块。 **方法:** -|[pre_tuning](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.SearchStrategy.pre_tuning)(max_trials, num_trials_per_iter, …)|预先调整搜索策略。| +|[pre_tuning](/docs/api-reference/python-api/tvm-meta_schedule#pre_tuningmax_trialsint-num_trials_per_iterint-design_spaceslistschedule-databasedatabasenone-none-cost_modelcostmodelnone-none--none)(max_trials, num_trials_per_iter, …)|预先调整搜索策略。| |:----|:----| -|[post_tuning](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.SearchStrategy.post_tuning)()|对搜索策略进行后期调整。| -|[generate_measure_candidates](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.SearchStrategy.generate_measure_candidates)()|从设计空间生成测量候选以进行测量。| -|[notify_runner_results](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.SearchStrategy.notify_runner_results)(measure_candidates, …)|使用分析结果更新搜索策略。| -|[clone](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.SearchStrategy.clone)()|克隆搜索策略。| -|[create](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.SearchStrategy.create)([kind])|创建搜索策略。| +|[post_tuning](/docs/api-reference/python-api/tvm-meta_schedule#post_tuning--none)()|对搜索策略进行后期调整。| +|[generate_measure_candidates](/docs/api-reference/python-api/tvm-meta_schedule#generate_measure_candidates--listmeasurecandidate--none)()|从设计空间生成测量候选以进行测量。| +|[notify_runner_results](/docs/api-reference/python-api/tvm-meta_schedule#notify_runner_resultsmeasure_candidateslistmeasurecandidate-resultslistrunnerresult--none)(measure_candidates, …)|使用分析结果更新搜索策略。| +|[clone](/docs/api-reference/python-api/tvm-meta_schedule#clone--searchstrategy)()|克隆搜索策略。| +|[create](/docs/api-reference/python-api/tvm-meta_schedule#static-createkind-typing_extensionsliteralevolutionary-replay---trace-replay---func--evolutionary-args-kwargs--searchstrategy)([kind])|创建搜索策略。| -### pre_tuning(*max_trials:*[int](https://docs.python.org/3/library/functions.html#int), *num_trials_per_iter:*[int](https://docs.python.org/3/library/functions.html#int), *design_spaces:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Schedule](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule)*]*, *database:*[Database](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *cost_model:*[CostModel](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.CostModel)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [None](https://docs.python.org/3/library/constants.html#None) +### pre_tuning(*max_trials:*[int](https://docs.python.org/3/library/functions.html#int), *num_trials_per_iter:*[int](https://docs.python.org/3/library/functions.html#int), *design_spaces:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Schedule](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulemodprimfuncirmodule--seed-int--none--none-debug_mask-str--int--none-error_render_level-str--detail-enable_check-bool--true)*]*, *database:*[Database](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduledatabase)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *cost_model:*[CostModel](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulecostmodel)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [None](https://docs.python.org/3/library/constants.html#None) 预先调整搜索策略。 * **参数:** * **max_trials** ( [int](https://docs.python.org/3/library/functions.html#int) ) :最大试验次数。 * **num_trials_per_iter**([int](https://docs.python.org/3/library/functions.html#int))*:* 每次迭代的试验次数。 * design_spaces(List *[tvm.tir.Schedule]*):调整过程中使用的设计空间。 - * *数据库*(*可选**[[数据库](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database)] *= 无*) *:* 调整过程中使用的数据库。 - * *cost_model**(*可选**[* [CostModel](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.CostModel)*]= None*):调整过程中使用的成本模型。 + * *数据库*(*可选**[[数据库](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduledatabase)] *= 无*) *:* 调整过程中使用的数据库。 + * *cost_model**(*可选**[* [CostModel](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulecostmodel)*]= None*):调整过程中使用的成本模型。 ### post_tuning() → [None](https://docs.python.org/3/library/constants.html#None) 对搜索策略进行后期调整。 -### generate_measure_candidates() → [List](https://docs.python.org/3/library/typing.html#typing.List)[[MeasureCandidate](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.MeasureCandidate)] | [None](https://docs.python.org/3/library/constants.html#None) +### generate_measure_candidates() → [List](https://docs.python.org/3/library/typing.html#typing.List)[[MeasureCandidate](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemeasurecandidateschschedule-args_infolistarginfo)] | [None](https://docs.python.org/3/library/constants.html#None) 从设计空间生成测量候选以进行测量。 * **返回:measure_candidates** *:* 生成的测量候选,如果完成则为 None。 -* **返回类型:** Optional[List[[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)]]。 +* **返回类型:** Optional[List[[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)]]。 -### notify_runner_results(*measure_candidates:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[MeasureCandidate](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.MeasureCandidate)*]*, *results:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[RunnerResult]*) → [None](https://docs.python.org/3/library/constants.html#None) +### notify_runner_results(*measure_candidates:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[MeasureCandidate](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemeasurecandidateschschedule-args_infolistarginfo)*]*, *results:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[RunnerResult]*) → [None](https://docs.python.org/3/library/constants.html#None) 使用分析结果更新搜索策略。 * **参数:** - * *measure_candidates* ( *List[*[MeasureCandidate](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.MeasureCandidate)*]* ) :需要更新的测量候选。 + * *measure_candidates* ( *List[*[MeasureCandidate](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemeasurecandidateschschedule-args_infolistarginfo)*]* ) :需要更新的测量候选。 * *results* ( *List[RunnerResult]* ) :来自运行器的分析结果。 -### clone() → [SearchStrategy](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.SearchStrategy) +### clone() → [SearchStrategy](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulesearchstrategy) 克隆搜索策略。 * **返回:cloned**:克隆的搜索策略。 -* **返回类型:**[SearchStrategy](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.SearchStrategy)。 +* **返回类型:**[SearchStrategy](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulesearchstrategy)。 -### *static* create(*kind: typing_extensions.Literal[evolutionary, replay - trace, replay - func] = 'evolutionary'*, args*, ***kwargs*) → [SearchStrategy](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.SearchStrategy) +### *static* create(*kind: typing_extensions.Literal[evolutionary, replay - trace, replay - func] = 'evolutionary'*, args*, ***kwargs*) → [SearchStrategy](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulesearchstrategy) 创建搜索策略。 @@ -545,27 +545,27 @@ Timeit 代码块。 **方法:** -|[generate_design_space](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.SpaceGenerator.generate_design_space)(mod)|给定一个模块生成设计空间。| +|[generate_design_space](/docs/api-reference/python-api/tvm-meta_schedule#generate_design_spacemodirmodule--listschedule)(mod)|给定一个模块生成设计空间。| |:----|:----| -|[clone](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.SpaceGenerator.clone)()|克隆设计空间生成器。| -|[create](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.SpaceGenerator.create)([kind])|创建一个设计空间生成器。| +|[clone](/docs/api-reference/python-api/tvm-meta_schedule#clone--spacegenerator)()|克隆设计空间生成器。| +|[create](/docs/api-reference/python-api/tvm-meta_schedule#static-createkind-typing_extensionsliteralpost---order---apply-union--typingcallabletvmtirschedulescheduleschedule-none--typingcallabletvmtirschedulescheduleschedule-tvmtirschedulescheduleschedule--typingcallabletvmtirschedulescheduleschedule-typinglisttvmtirschedulescheduleschedule--post-order-apply-args-kwargs--spacegenerator)([kind])|创建一个设计空间生成器。| -### generate_design_space(*mod:*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Schedule](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule)] +### generate_design_space(*mod:*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Schedule](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulemodprimfuncirmodule--seed-int--none--none-debug_mask-str--int--none-error_render_level-str--detail-enable_check-bool--true)] 给定一个模块生成设计空间。 -* **参数:mod** ([IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)):用于设计空间生成的模块。 +* **参数:mod** ([IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)):用于设计空间生成的模块。 * **返回:design_spaces**:生成的设计空间,即调度。 * **返回类型:** List[tvm.tir.Schedule]。 -### clone() → [SpaceGenerator](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.SpaceGenerator) +### clone() → [SpaceGenerator](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulespacegenerator) 克隆设计空间生成器。 * **返回:cloned_sg** *:* 克隆的设计空间生成器。 -* **返回类型:**[SpaceGenerator](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.SpaceGenerator)。 +* **返回类型:**[SpaceGenerator](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulespacegenerator)。 -### *static* create(*kind: typing_extensions.Literal[post - order - apply, union] | ~typing.Callable[[~tvm.tir.schedule.schedule.Schedule], None] | ~typing.Callable[[~tvm.tir.schedule.schedule.Schedule], ~tvm.tir.schedule.schedule.Schedule] | ~typing.Callable[[~tvm.tir.schedule.schedule.Schedule], ~typing.List[~tvm.tir.schedule.schedule.Schedule]] = 'post-order-apply'*, args*, ***kwargs*) → [SpaceGenerator](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.SpaceGenerator) +### *static* create(*kind: typing_extensions.Literal[post - order - apply, union] | ~typing.Callable[[~tvm.tir.schedule.schedule.Schedule], None] | ~typing.Callable[[~tvm.tir.schedule.schedule.Schedule], ~tvm.tir.schedule.schedule.Schedule] | ~typing.Callable[[~tvm.tir.schedule.schedule.Schedule], ~typing.List[~tvm.tir.schedule.schedule.Schedule]] = 'post-order-apply'*, args*, ***kwargs*) → [SpaceGenerator](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulespacegenerator) 创建一个设计空间生成器。 @@ -578,14 +578,14 @@ Timeit 代码块。 **方法:** -|[next_task_id](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TaskScheduler.next_task_id)()|获取下一个任务 ID。| +|[next_task_id](/docs/api-reference/python-api/tvm-meta_schedule#next_task_id--int)()|获取下一个任务 ID。| |:----|:----| -|[join_running_task](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TaskScheduler.join_running_task)(task_id)|等待任务完成。| -|[tune](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TaskScheduler.tune)(tasks, task_weights, max_trials_global, …)|自动调节。| -|[terminate_task](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TaskScheduler.terminate_task)(task_id)|终止任务。| -|[touch_task](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TaskScheduler.touch_task)(task_id)|触摸任务并更新其状态。| -|[print_tuning_statistics](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TaskScheduler.print_tuning_statistics)()|打印出人类可读的调整统计数据格式。| -|[create](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TaskScheduler.create)([kind])|创建任务调度程序。| +|[join_running_task](/docs/api-reference/python-api/tvm-meta_schedule#join_running_tasktask_idint--listrunnerresult)(task_id)|等待任务完成。| +|[tune](/docs/api-reference/python-api/tvm-meta_schedule#tunetaskslisttunecontext-task_weightslistfloat-max_trials_globalint-max_trials_per_taskint-num_trials_per_iterint-builderbuilder-runnerrunner-measure_callbackslistmeasurecallback-databasedatabasenone-cost_modelcostmodelnone--none)(tasks, task_weights, max_trials_global, …)|自动调节。| +|[terminate_task](/docs/api-reference/python-api/tvm-meta_schedule#terminate_tasktask_idint--none)(task_id)|终止任务。| +|[touch_task](/docs/api-reference/python-api/tvm-meta_schedule#touch_tasktask_idint--none)(task_id)|触摸任务并更新其状态。| +|[print_tuning_statistics](/docs/api-reference/python-api/tvm-meta_schedule#print_tuning_statistics--noneprint_tuning_statistics)()|打印出人类可读的调整统计数据格式。| +|[create](/docs/api-reference/python-api/tvm-meta_schedule#static-createkind-typing_extensionsliteralround---robin-gradient--gradient-args-kwargs--taskscheduler)([kind])|创建任务调度程序。| ### next_task_id() → [int](https://docs.python.org/3/library/functions.html#int) @@ -601,20 +601,20 @@ Timeit 代码块。 * **返回:results**:结果列表。 * **返回类型:** List[RunnerResult]。 -### tune(*tasks:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[TuneContext](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TuneContext)*]*, *task_weights:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[float](https://docs.python.org/3/library/functions.html#float)*]*, *max_trials_global:*[int](https://docs.python.org/3/library/functions.html#int), *max_trials_per_task:*[int](https://docs.python.org/3/library/functions.html#int), *num_trials_per_iter:*[int](https://docs.python.org/3/library/functions.html#int), *builder:*[Builder](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Builder), *runner:*[Runner](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Runner), *measure_callbacks:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[MeasureCallback](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.MeasureCallback)*]*, *database:*[Database](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database)*|*[None](https://docs.python.org/3/library/constants.html#None), *cost_model:*[CostModel](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.CostModel)*|*[None](https://docs.python.org/3/library/constants.html#None)) → [None](https://docs.python.org/3/library/constants.html#None) +### tune(*tasks:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[TuneContext](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduletunecontextmodirmodulenone-none--target-target--str--none--none-space_generator-spacegeneratorspacegeneratortype--none--none-search_strategy-searchstrategysearchstrategytype--none--none-task_name-str--main-rand_state-int---1-num_threads-int--typing_extensionsliteralphysical-logical--physical-logger-logger--none--none)*]*, *task_weights:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[float](https://docs.python.org/3/library/functions.html#float)*]*, *max_trials_global:*[int](https://docs.python.org/3/library/functions.html#int), *max_trials_per_task:*[int](https://docs.python.org/3/library/functions.html#int), *num_trials_per_iter:*[int](https://docs.python.org/3/library/functions.html#int), *builder:*[Builder](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulebuilder), *runner:*[Runner](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulerunner), *measure_callbacks:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[MeasureCallback](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemeasurecallback)*]*, *database:*[Database](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduledatabase)*|*[None](https://docs.python.org/3/library/constants.html#None), *cost_model:*[CostModel](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulecostmodel)*|*[None](https://docs.python.org/3/library/constants.html#None)) → [None](https://docs.python.org/3/library/constants.html#None) 自动调节。 * **参数:** - * *任务( List *[*[TuneContext](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TuneContext)*]* ) :作为任务的调整上下文列表。 + * *任务( List *[*[TuneContext](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduletunecontextmodirmodulenone-none--target-target--str--none--none-space_generator-spacegeneratorspacegeneratortype--none--none-search_strategy-searchstrategysearchstrategytype--none--none-task_name-str--main-rand_state-int---1-num_threads-int--typing_extensionsliteralphysical-logical--physical-logger-logger--none--none)*]* ) :作为任务的调整上下文列表。 * *task_weights(*List *[*[float](https://docs.python.org/3/library/functions.html#float)*]*) :任务权重列表。 * **max_trials_global** ( [int](https://docs.python.org/3/library/functions.html#int) ) :全局最大试验次数。 * **max_trials_per_task** ( [int](https://docs.python.org/3/library/functions.html#int) ) :每个任务的最大试验次数。 * **num_trials_per_iter**([int](https://docs.python.org/3/library/functions.html#int)):每次迭代的试验次数。 - * **builder**([Builder](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Builder)):构建器。 - * **runner**([Runner](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Runner)) :运行器。 - * *measure_callbacks* ( *List[*[MeasureCallback](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.MeasureCallback)*]* ) [:](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.CostModel)测量回调列表。 - * *数据库**(*可选**[[数据库](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database)]) :数据库。 - * *cost_model**(*可选**[ [CostModel](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.CostModel)*]*):成本模型。 + * **builder**([Builder](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulebuilder)):构建器。 + * **runner**([Runner](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulerunner)) :运行器。 + * *measure_callbacks* ( *List[*[MeasureCallback](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemeasurecallback)*]* ) [:](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulecostmodel)测量回调列表。 + * *数据库**(*可选**[[数据库](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduledatabase)]) :数据库。 + * *cost_model**(*可选**[ [CostModel](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulecostmodel)*]*):成本模型。 ### terminate_task(*task_id:*[int](https://docs.python.org/3/library/functions.html#int)) → [None](https://docs.python.org/3/library/constants.html#None) @@ -625,25 +625,25 @@ Timeit 代码块。 ### touch_task(*task_id:*[int](https://docs.python.org/3/library/functions.html#int)) → [None](https://docs.python.org/3/library/constants.html#None) 触摸任务并更新其状态。 -* **参数:task_id** ([int](https://docs.python.org/3/library/functions.html#int))[:](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TaskScheduler)要检查的任务 ID。 +* **参数:task_id** ([int](https://docs.python.org/3/library/functions.html#int))[:](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduletaskscheduler)要检查的任务 ID。 ### print_tuning_statistics() → [None](https://docs.python.org/3/library/constants.html#None)print_tuning_statistics) 打印出人类可读的调整统计数据格式。 -### *static* create(*kind: typing_extensions.Literal[round - robin, gradient] = 'gradient'*, args*, ***kwargs*) → [TaskScheduler](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TaskScheduler) +### *static* create(*kind: typing_extensions.Literal[round - robin, gradient] = 'gradient'*, args*, ***kwargs*) → [TaskScheduler](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduletaskscheduler) 创建任务调度程序。 -## tvm.meta_schedule.tune_tir(*mod:*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)*|*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc), *target:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target), *work_dir:*[str](https://docs.python.org/3/library/stdtypes.html#str), *max_trials_global:*[int](https://docs.python.org/3/library/functions.html#int), ***, *max_trials_per_task: [int](https://docs.python.org/3/library/functions.html#int) | [None](https://docs.python.org/3/library/constants.html#None) = None*, *num_trials_per_iter: [int](https://docs.python.org/3/library/functions.html#int) = 64*, *builder: [Builder](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Builder) | typing_extensions.Literal[local] = 'local'*, *runner: [Runner](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Runner) | typing_extensions.Literal[local, rpc] = 'local'*, *database: [Database](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database) | typing_extensions.Literal[json, memory] = 'json'*, *cost_model: [CostModel](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.CostModel) | typing_extensions.Literal[xgb, mlp, random] = 'xgb'*, *measure_callbacks: [List](https://docs.python.org/3/library/typing.html#typing.List)[[MeasureCallback](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.MeasureCallback)] | [MeasureCallback](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.MeasureCallback) | typing_extensions.Literal[default] = 'default'*, *task_scheduler: Literal[gradient, round - robin] = 'gradient'*, *space: Literal[post - order - apply, union] = 'post-order-apply'*, *strategy: Literal[replay - func, replay - trace, evolutionary] = 'evolutionary'*, *num_tuning_cores: typing_extensions.Literal[physical, logical] | [int](https://docs.python.org/3/library/functions.html#int) = 'physical'*, *seed: [int](https://docs.python.org/3/library/functions.html#int) | [None](https://docs.python.org/3/library/constants.html#None) = None*, *module_equality: [str](https://docs.python.org/3/library/stdtypes.html#str) = 'structural'*, *special_space: Literal[post - order - apply, union]] | None = None*, *post_optimization: [bool](https://docs.python.org/3/library/functions.html#bool) | [None](https://docs.python.org/3/library/constants.html#None) = False*) → [Database](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database) +## tvm.meta_schedule.tune_tir(*mod:*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)*|*[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone), *target:*[str](https://docs.python.org/3/library/stdtypes.html#str)*|*[Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone), *work_dir:*[str](https://docs.python.org/3/library/stdtypes.html#str), *max_trials_global:*[int](https://docs.python.org/3/library/functions.html#int), ***, *max_trials_per_task: [int](https://docs.python.org/3/library/functions.html#int) | [None](https://docs.python.org/3/library/constants.html#None) = None*, *num_trials_per_iter: [int](https://docs.python.org/3/library/functions.html#int) = 64*, *builder: [Builder](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulebuilder) | typing_extensions.Literal[local] = 'local'*, *runner: [Runner](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulerunner) | typing_extensions.Literal[local, rpc] = 'local'*, *database: [Database](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduledatabase) | typing_extensions.Literal[json, memory] = 'json'*, *cost_model: [CostModel](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulecostmodel) | typing_extensions.Literal[xgb, mlp, random] = 'xgb'*, *measure_callbacks: [List](https://docs.python.org/3/library/typing.html#typing.List)[[MeasureCallback](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemeasurecallback)] | [MeasureCallback](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemeasurecallback) | typing_extensions.Literal[default] = 'default'*, *task_scheduler: Literal[gradient, round - robin] = 'gradient'*, *space: Literal[post - order - apply, union] = 'post-order-apply'*, *strategy: Literal[replay - func, replay - trace, evolutionary] = 'evolutionary'*, *num_tuning_cores: typing_extensions.Literal[physical, logical] | [int](https://docs.python.org/3/library/functions.html#int) = 'physical'*, *seed: [int](https://docs.python.org/3/library/functions.html#int) | [None](https://docs.python.org/3/library/constants.html#None) = None*, *module_equality: [str](https://docs.python.org/3/library/stdtypes.html#str) = 'structural'*, *special_space: Literal[post - order - apply, union]] | None = None*, *post_optimization: [bool](https://docs.python.org/3/library/functions.html#bool) | [None](https://docs.python.org/3/library/constants.html#None) = False*) → [Database](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduledatabase) 调整 TIR 函数或 TIR 函数的 IRModule。 * **参数:** - * *mod* ( *Union[*[ir.IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)*,*[tir.PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)*]* ) :要调整的 TIR IRModule。 - * *target* ( *Union[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target)*]* ) :需要调整的目标。 + * *mod* ( *Union[*[ir.IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)*,*[tir.PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)*]* ) :要调整的 TIR IRModule。 + * *target* ( *Union[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone)*]* ) :需要调整的目标。 * **work_dir** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ) *:* 工作目录。 * **max_trials_global** ( [int](https://docs.python.org/3/library/functions.html#int) ) :全局运行的最大试验次数。 * *max_trials_per_task**(*可选**[ [int](https://docs.python.org/3/library/functions.html#int)*]*):每个任务运行的最大试验次数。 @@ -661,13 +661,13 @@ Timeit 代码块。 * *module_equality* (*可选[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]* ) *:* 用于指定模块相等性测试和散列方法的字符串。 * *special_space* (*可选[Mapping[*[str](https://docs.python.org/3/library/stdtypes.html#str)*,SpaceGenerator.SpaceGeneratorType]]* ) :从任务名称到该任务的特殊空间生成器的映射。 * **返回:database**:包含所有调优记录的数据库。 -* **返回类型:**[Database](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database)。 +* **返回类型:**[Database](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduledatabase)。 -## tvm.meta_schedule.tune_tasks(***, *tasks: [List](https://docs.python.org/3/library/typing.html#typing.List)[[TuneContext](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TuneContext)]*, *task_weights: [List](https://docs.python.org/3/library/typing.html#typing.List)[[float](https://docs.python.org/3/library/functions.html#float)]*, *work_dir: [str](https://docs.python.org/3/library/stdtypes.html#str)*, *max_trials_global: [int](https://docs.python.org/3/library/functions.html#int)*, *max_trials_per_task: [int](https://docs.python.org/3/library/functions.html#int) | [None](https://docs.python.org/3/library/constants.html#None) = None*, *num_trials_per_iter: [int](https://docs.python.org/3/library/functions.html#int) = 64*, *builder: [Builder](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Builder) | typing_extensions.Literal[local] = 'local'*, *runner: [Runner](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Runner) | typing_extensions.Literal[local, rpc] = 'local'*, *database: [Database](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database) | typing_extensions.Literal[json, memory] = 'json'*, *cost_model: [CostModel](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.CostModel) | typing_extensions.Literal[xgb, mlp, random] = 'xgb'*, *measure_callbacks: [List](https://docs.python.org/3/library/typing.html#typing.List)[[MeasureCallback](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.MeasureCallback)] | [MeasureCallback](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.MeasureCallback) | typing_extensions.Literal[default] = 'default'*, *task_scheduler: Literal[gradient, round - robin] = 'gradient'*, *module_equality: [str](https://docs.python.org/3/library/stdtypes.html#str) = 'structural'*, *post_optimization: [bool](https://docs.python.org/3/library/functions.html#bool) | [None](https://docs.python.org/3/library/constants.html#None) = False*) → [Database](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database) +## tvm.meta_schedule.tune_tasks(***, *tasks: [List](https://docs.python.org/3/library/typing.html#typing.List)[[TuneContext](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduletunecontextmodirmodulenone-none--target-target--str--none--none-space_generator-spacegeneratorspacegeneratortype--none--none-search_strategy-searchstrategysearchstrategytype--none--none-task_name-str--main-rand_state-int---1-num_threads-int--typing_extensionsliteralphysical-logical--physical-logger-logger--none--none)]*, *task_weights: [List](https://docs.python.org/3/library/typing.html#typing.List)[[float](https://docs.python.org/3/library/functions.html#float)]*, *work_dir: [str](https://docs.python.org/3/library/stdtypes.html#str)*, *max_trials_global: [int](https://docs.python.org/3/library/functions.html#int)*, *max_trials_per_task: [int](https://docs.python.org/3/library/functions.html#int) | [None](https://docs.python.org/3/library/constants.html#None) = None*, *num_trials_per_iter: [int](https://docs.python.org/3/library/functions.html#int) = 64*, *builder: [Builder](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulebuilder) | typing_extensions.Literal[local] = 'local'*, *runner: [Runner](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulerunner) | typing_extensions.Literal[local, rpc] = 'local'*, *database: [Database](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduledatabase) | typing_extensions.Literal[json, memory] = 'json'*, *cost_model: [CostModel](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulecostmodel) | typing_extensions.Literal[xgb, mlp, random] = 'xgb'*, *measure_callbacks: [List](https://docs.python.org/3/library/typing.html#typing.List)[[MeasureCallback](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemeasurecallback)] | [MeasureCallback](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemeasurecallback) | typing_extensions.Literal[default] = 'default'*, *task_scheduler: Literal[gradient, round - robin] = 'gradient'*, *module_equality: [str](https://docs.python.org/3/library/stdtypes.html#str) = 'structural'*, *post_optimization: [bool](https://docs.python.org/3/library/functions.html#bool) | [None](https://docs.python.org/3/library/constants.html#None) = False*) → [Database](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduledatabase) 调整任务列表。使用任务调度程序。 * **参数:** - * *任务**(*列表**[ [TuneContext](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TuneContext)*]*) :要调整的任务列表。 + * *任务**(*列表**[ [TuneContext](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduletunecontextmodirmodulenone-none--target-target--str--none--none-space_generator-spacegeneratorspacegeneratortype--none--none-search_strategy-searchstrategysearchstrategytype--none--none-task_name-str--main-rand_state-int---1-num_threads-int--typing_extensionsliteralphysical-logical--physical-logger-logger--none--none)*]*) :要调整的任务列表。 * *task_weights(*List *[*[float](https://docs.python.org/3/library/functions.html#float)*]*):每个任务的权重。 * **work_dir** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ) :工作目录。 * **max_trials_global** ( [int](https://docs.python.org/3/library/functions.html#int) ) **:** 全局运行的最大试验次数。 @@ -689,17 +689,17 @@ Timeit 代码块。 给定模块。“ignore–ndarray”变量用于提取的块或未找到锚块的情况。有关锚块的定义,请参阅 tir/analysis/analysis.py。 * **post_optimization**(*可选*[*布尔值]*):使用 Droplet Search 作为利用空间生成后优化。 * **返回:database**:包含所有调优记录的数据库。 -* **返回类型:**[Database](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database)。 +* **返回类型:**[Database](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduledatabase)。 -## *class* tvm.meta_schedule.TuneContext(*mod:*[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *, *target: [Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target) | [str](https://docs.python.org/3/library/stdtypes.html#str) | [None](https://docs.python.org/3/library/constants.html#None) = None*, *space_generator: SpaceGenerator.SpaceGeneratorType | [None](https://docs.python.org/3/library/constants.html#None) = None*, *search_strategy: SearchStrategy.SearchStrategyType | [None](https://docs.python.org/3/library/constants.html#None) = None*, *task_name: [str](https://docs.python.org/3/library/stdtypes.html#str) = 'main'*, *rand_state: [int](https://docs.python.org/3/library/functions.html#int) = -1*, *num_threads: [int](https://docs.python.org/3/library/functions.html#int) | typing_extensions.Literal[physical, logical] = 'physical'*, *logger: [Logger](https://docs.python.org/3/library/logging.html#logging.Logger) | [None](https://docs.python.org/3/library/constants.html#None) = None*) +## *class* tvm.meta_schedule.TuneContext(*mod:*[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *, *target: [Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone) | [str](https://docs.python.org/3/library/stdtypes.html#str) | [None](https://docs.python.org/3/library/constants.html#None) = None*, *space_generator: SpaceGenerator.SpaceGeneratorType | [None](https://docs.python.org/3/library/constants.html#None) = None*, *search_strategy: SearchStrategy.SearchStrategyType | [None](https://docs.python.org/3/library/constants.html#None) = None*, *task_name: [str](https://docs.python.org/3/library/stdtypes.html#str) = 'main'*, *rand_state: [int](https://docs.python.org/3/library/functions.html#int) = -1*, *num_threads: [int](https://docs.python.org/3/library/functions.html#int) | typing_extensions.Literal[physical, logical] = 'physical'*, *logger: [Logger](https://docs.python.org/3/library/logging.html#logging.Logger) | [None](https://docs.python.org/3/library/constants.html#None) = None*) 调整上下文类旨在包含调整任务的所有资源。 * **参数:** - * *mod**(*可选**[ [IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)*]= None*) [:](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.SpaceGenerator)要优化的工作负载。 - * *目标**(*可选**[[目标](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target)] *= 无*) *:* 要优化的目标。 - * **space_generator** ( *Union[None,ScheduleFnType,*[SpaceGenerator](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.SpaceGenerator)*]= None* ) *:* 设计空间生成器。 - * *search_strategy* ( *Union[None,*[SearchStrategy](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.SearchStrategy)*]= None* ) :搜索策略。如果为 None ,则策略留空。 + * *mod**(*可选**[ [IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)*]= None*) :要优化的工作负载。 + * *目标**(*可选**[[目标](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone)] *= 无*) *:* 要优化的目标。 + * **space_generator** ( *Union[None,ScheduleFnType,*[SpaceGenerator](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulespacegenerator)*]= None* ) *:* 设计空间生成器。 + * *search_strategy* ( *Union[None,*[SearchStrategy](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulesearchstrategy)*]= None* ) :搜索策略。如果为 None ,则策略留空。 * *task_name**(*可选**[ [str](https://docs.python.org/3/library/stdtypes.html#str)*]= None*):调整任务的名称。 * **logger**([logging.Logger](https://docs.python.org/3/library/logging.html#logging.Logger)) *:* 用于调整任务的记录器。 * **rand_state** ( *int = –1* ) :随机状态。需为 [1, 2^31–1] 范围内的整数,–1 表示使用随机数。 @@ -708,15 +708,15 @@ Timeit 代码块。 **方法:** -|[generate_design_space](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TuneContext.generate_design_space)()|给定一个模块生成设计空间。| +|[generate_design_space](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduletunecontextmodirmodulenone-none--target-target--str--none--none-space_generator-spacegeneratorspacegeneratortype--none--none-search_strategy-searchstrategysearchstrategytype--none--none-task_name-str--main-rand_state-int---1-num_threads-int--typing_extensionsliteralphysical-logical--physical-logger-logger--none--none.generate_design_space)()|给定一个模块生成设计空间。| |:----|:----| -|[pre_tuning](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TuneContext.pre_tuning)(max_trials[, …])|在调整之前,SearchStrategy 需要调用的方法来做必要的准备。| -|[post_tuning](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TuneContext.post_tuning)()|调用 SearchStrategy 进行调整后必要清理的方法。| -|[generate_measure_candidates](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TuneContext.generate_measure_candidates)()|从设计空间中生成一批测量候选对象以供测量。| -|[notify_runner_results](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TuneContext.notify_runner_results)(measure_candidates, …)|使用分析结果更新 SearchStrategy 中的状态。| -|[clone](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TuneContext.clone)()|克隆 TuneContext。| +|[pre_tuning](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduletunecontextmodirmodulenone-none--target-target--str--none--none-space_generator-spacegeneratorspacegeneratortype--none--none-search_strategy-searchstrategysearchstrategytype--none--none-task_name-str--main-rand_state-int---1-num_threads-int--typing_extensionsliteralphysical-logical--physical-logger-logger--none--none.pre_tuning)(max_trials[, …])|在调整之前,SearchStrategy 需要调用的方法来做必要的准备。| +|[post_tuning](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduletunecontextmodirmodulenone-none--target-target--str--none--none-space_generator-spacegeneratorspacegeneratortype--none--none-search_strategy-searchstrategysearchstrategytype--none--none-task_name-str--main-rand_state-int---1-num_threads-int--typing_extensionsliteralphysical-logical--physical-logger-logger--none--none.post_tuning)()|调用 SearchStrategy 进行调整后必要清理的方法。| +|[generate_measure_candidates](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduletunecontextmodirmodulenone-none--target-target--str--none--none-space_generator-spacegeneratorspacegeneratortype--none--none-search_strategy-searchstrategysearchstrategytype--none--none-task_name-str--main-rand_state-int---1-num_threads-int--typing_extensionsliteralphysical-logical--physical-logger-logger--none--none.generate_measure_candidates)()|从设计空间中生成一批测量候选对象以供测量。| +|[notify_runner_results](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduletunecontextmodirmodulenone-none--target-target--str--none--none-space_generator-spacegeneratorspacegeneratortype--none--none-search_strategy-searchstrategysearchstrategytype--none--none-task_name-str--main-rand_state-int---1-num_threads-int--typing_extensionsliteralphysical-logical--physical-logger-logger--none--none.notify_runner_results)(measure_candidates, …)|使用分析结果更新 SearchStrategy 中的状态。| +|[clone](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduletunecontextmodirmodulenone-none--target-target--str--none--none-space_generator-spacegeneratorspacegeneratortype--none--none-search_strategy-searchstrategysearchstrategytype--none--none-task_name-str--main-rand_state-int---1-num_threads-int--typing_extensionsliteralphysical-logical--physical-logger-logger--none--none.clone)()|克隆 TuneContext。| -### generate_design_space() → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Schedule](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule)] +### generate_design_space() → [List](https://docs.python.org/3/library/typing.html#typing.List)[[Schedule](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulemodprimfuncirmodule--seed-int--none--none-debug_mask-str--int--none-error_render_level-str--detail-enable_check-bool--true)] 给定一个模块生成设计空间。 @@ -726,7 +726,7 @@ Timeit 代码块。 * **返回:design_spaces** *:* 生成的设计空间,即调度。 * **返回类型:** List[tvm.tir.Schedule]。 -### pre_tuning(*max_trials:*[int](https://docs.python.org/3/library/functions.html#int), *num_trials_per_iter:*[int](https://docs.python.org/3/library/functions.html#int)*= 64*, *design_spaces:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Schedule](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *database:*[Database](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *cost_model:*[CostModel](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.CostModel)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [None](https://docs.python.org/3/library/constants.html#None) +### pre_tuning(*max_trials:*[int](https://docs.python.org/3/library/functions.html#int), *num_trials_per_iter:*[int](https://docs.python.org/3/library/functions.html#int)*= 64*, *design_spaces:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[Schedule](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulemodprimfuncirmodule--seed-int--none--none-debug_mask-str--int--none-error_render_level-str--detail-enable_check-bool--true)*] |*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *database:*[Database](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduledatabase)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*, *cost_model:*[CostModel](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulecostmodel)*|*[None](https://docs.python.org/3/library/constants.html#None)*= None*) → [None](https://docs.python.org/3/library/constants.html#None) 在调整之前,SearchStrategy 需要调用的方法来做必要的准备。 @@ -736,8 +736,8 @@ Timeit 代码块。 * **max_trials** ( [int](https://docs.python.org/3/library/functions.html#int) ) *:* 要执行的最大试验次数。 * **num_trials_per_iter**(*int = 64*):每次迭代要执行的试验次数。 * **design_spaces** ( *Optional[List[tvm.tir.Schedule]] ):调优过程中使用的设计空间。若为 None,则使用*self.generate_design_space()的结果。 - * *database**(*可选**[ [Database](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.Database)*]= None*):调优过程中使用的数据库。如果为 None 且搜索策略为 EvolutionarySearch,则使用 tvm.meta_schedule.database.MemoryDatabase。 - * *cost_model* (*可选[*[CostModel](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.CostModel)*]= None* ) :调优过程中使用的成本模型。如果为 None,且搜索策略为 EvolutionarySearch,则使用tvm.meta_schedule.cost_model.RandomModel。 + * *database**(*可选**[ [Database](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduledatabase)*]= None*):调优过程中使用的数据库。如果为 None 且搜索策略为 EvolutionarySearch,则使用 tvm.meta_schedule.database.MemoryDatabase。 + * *cost_model* (*可选[*[CostModel](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulecostmodel)*]= None* ) :调优过程中使用的成本模型。如果为 None,且搜索策略为 EvolutionarySearch,则使用tvm.meta_schedule.cost_model.RandomModel。 ### post_tuning() → [None](https://docs.python.org/3/library/constants.html#None) @@ -747,7 +747,7 @@ Timeit 代码块。 委托给 self.search_strategy.post_tuning。 -### generate_measure_candidates() → [List](https://docs.python.org/3/library/typing.html#typing.List)[[MeasureCandidate](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.MeasureCandidate)] | [None](https://docs.python.org/3/library/constants.html#None) +### generate_measure_candidates() → [List](https://docs.python.org/3/library/typing.html#typing.List)[[MeasureCandidate](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemeasurecandidateschschedule-args_infolistarginfo)] | [None](https://docs.python.org/3/library/constants.html#None) 从设计空间中生成一批测量候选对象以供测量。 @@ -755,9 +755,9 @@ Timeit 代码块。 委托给 self.search_strategy.generate_measure_candidates。 * **返回:measure_candidates**:生成的测量候选,如果搜索完成则为 None。 -* **返回类型:** Optional[List[[IRModule](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.IRModule)]]。 +* **返回类型:** Optional[List[[IRModule](/docs/api-reference/python-api/tvm-ir#class-tvmirirmodulefunctionsnone-attrsnone-global_infosnone)]]。 -### notify_runner_results(*measure_candidates:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[MeasureCandidate](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.MeasureCandidate)*]*, *results:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[RunnerResult]*) → [None](https://docs.python.org/3/library/constants.html#None) +### notify_runner_results(*measure_candidates:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[MeasureCandidate](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemeasurecandidateschschedule-args_infolistarginfo)*]*, *results:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[RunnerResult]*) → [None](https://docs.python.org/3/library/constants.html#None) 使用分析结果更新 SearchStrategy 中的状态。 @@ -765,15 +765,15 @@ Timeit 代码块。 委托给 self.search_strategy.notify_runner_results。 * **参数:** - * *measure_candidates* ( *List[*[MeasureCandidate](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.MeasureCandidate)*]* ) **:** 需要更新的测量候选。 - * *results* ( *List[RunnerResult]* ) [:](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TuneContext)来自运行器的分析结果。 + * *measure_candidates* ( *List[*[MeasureCandidate](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_schedulemeasurecandidateschschedule-args_infolistarginfo)*]* ) **:** 需要更新的测量候选。 + * *results* ( *List[RunnerResult]* ) [:](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduletunecontextmodirmodulenone-none--target-target--str--none--none-space_generator-spacegeneratorspacegeneratortype--none--none-search_strategy-searchstrategysearchstrategytype--none--none-task_name-str--main-rand_state-int---1-num_threads-int--typing_extensionsliteralphysical-logical--physical-logger-logger--none--none)来自运行器的分析结果。 -### clone() → [TuneContext](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TuneContext) +### clone() → [TuneContext](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduletunecontextmodirmodulenone-none--target-target--str--none--none-space_generator-spacegeneratorspacegeneratortype--none--none-search_strategy-searchstrategysearchstrategytype--none--none-task_name-str--main-rand_state-int---1-num_threads-int--typing_extensionsliteralphysical-logical--physical-logger-logger--none--none) 克隆 TuneContext。 * **返回:cloned_context**:克隆的 TuneContext。 -* **返回类型:**[TuneContext](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html#tvm.meta_schedule.TuneContext)。 +* **返回类型:**[TuneContext](/docs/api-reference/python-api/tvm-meta_schedule#class-tvmmeta_scheduletunecontextmodirmodulenone-none--target-target--str--none--none-space_generator-spacegeneratorspacegeneratortype--none--none-search_strategy-searchstrategysearchstrategytype--none--none-task_name-str--main-rand_state-int---1-num_threads-int--typing_extensionsliteralphysical-logical--physical-logger-logger--none--none)。 ## tvm.meta_schedule.derived_object(*cls:*[type](https://docs.python.org/3/library/functions.html#type)) → [type](https://docs.python.org/3/library/functions.html#type) diff --git a/docs/04-api-reference/01-python-api/25-tvm-dlight.md b/docs/04-api-reference/01-python-api/25-tvm-dlight.md index 96ccf55..c3be440 100644 --- a/docs/04-api-reference/01-python-api/25-tvm-dlight.md +++ b/docs/04-api-reference/01-python-api/25-tvm-dlight.md @@ -7,11 +7,11 @@ title: tvm.dlight DLight 包为深度学习工作负载提供了开箱即用的高效调度。 -## *class* tvm.dlight.BlockInfo(*name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *iters:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[IterInfo](https://tvm.apache.org/docs/reference/api/python/dlight.html#tvm.dlight.IterInfo)*]*, *block_rv:*[BlockRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.BlockRV), *reduction_block:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) +## *class* tvm.dlight.BlockInfo(*name:*[str](https://docs.python.org/3/library/stdtypes.html#str), *iters:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[IterInfo](/docs/api-reference/python-api/tvm-dlight#class-tvmdlightiterinfokind-typing_extensionsliterals-r-o-varvar-domprimexpr-loop_rvlooprv)*]*, *block_rv:*[BlockRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleblockrv), *reduction_block:*[bool](https://docs.python.org/3/library/functions.html#bool)*= False*) 有关 TIR 区块的信息。 -### dom() → [List](https://docs.python.org/3/library/typing.html#typing.List)[[int](https://docs.python.org/3/library/functions.html#int) | [PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr)] +### dom() → [List](https://docs.python.org/3/library/typing.html#typing.List)[[int](https://docs.python.org/3/library/functions.html#int) | [PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr)] 块的迭代域。 @@ -26,7 +26,7 @@ DLight 包为深度学习工作负载提供了开箱即用的高效调度。 该块是否是可注入的,即其所有迭代域都是可注入的。 -### is_elementwise(*sch:*[Schedule](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule)) → [bool](https://docs.python.org/3/library/functions.html#bool) +### is_elementwise(*sch:*[Schedule](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulemodprimfuncirmodule--seed-int--none--none-debug_mask-str--int--none-error_render_level-str--detail-enable_check-bool--true)) → [bool](https://docs.python.org/3/library/functions.html#bool) 该块是否是元素级的,即读/写区域之间的简单映射. @@ -45,22 +45,22 @@ DLight 包为深度学习工作负载提供了开箱即用的高效调度。 该块是否为 GEMM 工作负载。 -## *class* tvm.dlight.IterInfo(*kind: typing_extensions.Literal[S, R, O]*, *var:*[Var](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.Var), *dom:*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr), *loop_rv:*[LoopRV](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.LoopRV)) +## *class* tvm.dlight.IterInfo(*kind: typing_extensions.Literal[S, R, O]*, *var:*[Var](/docs/api-reference/python-api/tvm-tir#class-tvmtirvarnamestr-dtypestrtype-spanspannone-none), *dom:*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr), *loop_rv:*[LoopRV](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirschedulelooprv)) 有关循环/iter var 的信息。 -### *property* dom*:*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.PrimExpr) +### *property* dom*:*[int](https://docs.python.org/3/library/functions.html#int)*|*[PrimExpr](/docs/api-reference/python-api/tvm-ir#class-tvmirprimexpr) 循环的迭代域。 -## tvm.dlight.normalize_prim_func(*sch:*[Schedule](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[BlockInfo](https://tvm.apache.org/docs/reference/api/python/dlight.html#tvm.dlight.BlockInfo)] | [None](https://docs.python.org/3/library/constants.html#None) +## tvm.dlight.normalize_prim_func(*sch:*[Schedule](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulemodprimfuncirmodule--seed-int--none--none-debug_mask-str--int--none-error_render_level-str--detail-enable_check-bool--true)) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[BlockInfo](/docs/api-reference/python-api/tvm-dlight#class-tvmdlightblockinfonamestr-iterslistiterinfo-block_rvblockrv-reduction_blockbool-false)] | [None](https://docs.python.org/3/library/constants.html#None) 将 primfunc 规范化为范式. -## *class* tvm.dlight.ApplyDefaultSchedule(rules:*[ScheduleRule](https://tvm.apache.org/docs/reference/api/python/dlight.html#tvm.dlight.ScheduleRule)) +## *class* tvm.dlight.ApplyDefaultSchedule(rules:*[ScheduleRule](/docs/api-reference/python-api/tvm-dlight#class-tvmdlightschedulerule)) IRModule 过程将 ScheduleRules 列表应用于模块中的所有 PrimFuncs。 @@ -73,18 +73,18 @@ IRModule 过程将 ScheduleRules 列表应用于模块中的所有 PrimFuncs。 给定一个 PrimFunc、一个目标和一个可调标志,ScheduleRule 的 apply 方法将返回一个 Schedule、一个 Schedule 列表或 None,其中 None 表示该规则不适用于给定的 PrimFunc。如果可调标志为 True,则 ScheduleRule 可以返回一个 Schedule 或一个 Schedule 列表,并且 Schedule 可以包含可调指令。如果可调标志为 False,则 ScheduleRule 只能返回一个 Schedule,并且 Schedule 不允许包含可调指令。 -### apply(*func:*[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc), *target:*[Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target), *tunable:*[bool](https://docs.python.org/3/library/functions.html#bool)) → [None](https://docs.python.org/3/library/constants.html#None) | [Schedule](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule) | [List](https://docs.python.org/3/library/typing.html#typing.List)[[Schedule](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule)] +### apply(*func:*[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone), *target:*[Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone), *tunable:*[bool](https://docs.python.org/3/library/functions.html#bool)) → [None](https://docs.python.org/3/library/constants.html#None) | [Schedule](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulemodprimfuncirmodule--seed-int--none--none-debug_mask-str--int--none-error_render_level-str--detail-enable_check-bool--true) | [List](https://docs.python.org/3/library/typing.html#typing.List)[[Schedule](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulemodprimfuncirmodule--seed-int--none--none-debug_mask-str--int--none-error_render_level-str--detail-enable_check-bool--true)] 将 ScheduleRule 应用于给定的 PrimFunc。 * **参数:** - * **func** ([tir.PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc)):应用 ScheduleRule 的 PrimFunc。 - * **target** ([Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target)):调度所要构建的编译目标。 + * **func** ([tir.PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone)):应用 ScheduleRule 的 PrimFunc。 + * **target** ([Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone)):调度所要构建的编译目标。 * **tunable** ([bool](https://docs.python.org/3/library/functions.html#bool)):调度是否允许包含可调指令。 * **返回:results**:可以是 Schedule、Schedule 列表或 None,其中 None 表示该规则不适用于给定的 PrimFunc。 * **返回类型:** Union[None, tir.Schedule, List[tir.Schedule]]. -### *static* from_callable(*name*) → [Callable](https://docs.python.org/3/library/typing.html#typing.Callable)[[[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)[[[PrimFunc](https://tvm.apache.org/docs/reference/api/python/tir/tir.html#tvm.tir.PrimFunc), [Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target), [bool](https://docs.python.org/3/library/functions.html#bool)], [None](https://docs.python.org/3/library/constants.html#None) | [Schedule](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule) | [List](https://docs.python.org/3/library/typing.html#typing.List)[[Schedule](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule)]]], [ScheduleRule](https://tvm.apache.org/docs/reference/api/python/dlight.html#tvm.dlight.ScheduleRule)] +### *static* from_callable(*name*) → [Callable](https://docs.python.org/3/library/typing.html#typing.Callable)[[[Callable](https://docs.python.org/3/library/typing.html#typing.Callable)[[[PrimFunc](/docs/api-reference/python-api/tvm-tir#class-tvmtirprimfuncparams-body-ret_typenone-buffer_mapnone-attrsnone-spannone), [Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone), [bool](https://docs.python.org/3/library/functions.html#bool)], [None](https://docs.python.org/3/library/constants.html#None) | [Schedule](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulemodprimfuncirmodule--seed-int--none--none-debug_mask-str--int--none-error_render_level-str--detail-enable_check-bool--true) | [List](https://docs.python.org/3/library/typing.html#typing.List)[[Schedule](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulemodprimfuncirmodule--seed-int--none--none-debug_mask-str--int--none-error_render_level-str--detail-enable_check-bool--true)]]], [ScheduleRule](/docs/api-reference/python-api/tvm-dlight#class-tvmdlightschedulerule)] 从可调用对象创建 ScheduleRule。 @@ -100,32 +100,32 @@ IRModule 过程将 ScheduleRules 列表应用于模块中的所有 PrimFuncs。 def my_rule(func: tir.PrimFunc, target: Target, tunable: bool) -> Union[None, Schedule] # 使用 func 和 target 做一些操作 ``` -### is_target_available(*target:*[Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target)) → [bool](https://docs.python.org/3/library/functions.html#bool) +### is_target_available(*target:*[Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone)) → [bool](https://docs.python.org/3/library/functions.html#bool) 检查该规则是否适用于给定的目标。 -* **参数:target** ([Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target)):调度所要构建的编译目标。 +* **参数:target** ([Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone)):调度所要构建的编译目标。 * **返回:available:** 该规则是否适用于给定的目标。 * **返回类型:**[bool](https://docs.python.org/3/library/functions.html#bool)。 -## tvm.dlight.try_inline(*sch:*[Schedule](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule), *blocks:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[BlockInfo](https://tvm.apache.org/docs/reference/api/python/dlight.html#tvm.dlight.BlockInfo)*]*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[BlockInfo](https://tvm.apache.org/docs/reference/api/python/dlight.html#tvm.dlight.BlockInfo)] +## tvm.dlight.try_inline(*sch:*[Schedule](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulemodprimfuncirmodule--seed-int--none--none-debug_mask-str--int--none-error_render_level-str--detail-enable_check-bool--true), *blocks:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[BlockInfo](/docs/api-reference/python-api/tvm-dlight#class-tvmdlightblockinfonamestr-iterslistiterinfo-block_rvblockrv-reduction_blockbool-false)*]*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[BlockInfo](/docs/api-reference/python-api/tvm-dlight#class-tvmdlightblockinfonamestr-iterslistiterinfo-block_rvblockrv-reduction_blockbool-false)] 尝试内联尽可能多的块,并返回剩余的块。 * **参数:** * **sch** (*tir.Schedule*)**:** 用于内联块的 TIR 调度。 - * **blocks** (*List[*[BlockInfo](https://tvm.apache.org/docs/reference/api/python/dlight.html#tvm.dlight.BlockInfo)*]*):要内联的块。 -* **返回:remaining**[:](https://tvm.apache.org/docs/reference/api/python/dlight.html#tvm.dlight.BlockInfo)无法内联的剩余块。 -* **返回类型:** List[[BlockInfo](https://tvm.apache.org/docs/reference/api/python/dlight.html#tvm.dlight.BlockInfo)]。 + * **blocks** (*List[*[BlockInfo](/docs/api-reference/python-api/tvm-dlight#class-tvmdlightblockinfonamestr-iterslistiterinfo-block_rvblockrv-reduction_blockbool-false)*]*):要内联的块。 +* **返回:remaining**[:](/docs/api-reference/python-api/tvm-dlight#class-tvmdlightblockinfonamestr-iterslistiterinfo-block_rvblockrv-reduction_blockbool-false)无法内联的剩余块。 +* **返回类型:** List[[BlockInfo](/docs/api-reference/python-api/tvm-dlight#class-tvmdlightblockinfonamestr-iterslistiterinfo-block_rvblockrv-reduction_blockbool-false)]。 -## tvm.dlight.try_inline_contiguous_spatial(*sch:*[Schedule](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html#tvm.tir.schedule.Schedule), *block_infos:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[BlockInfo](https://tvm.apache.org/docs/reference/api/python/dlight.html#tvm.dlight.BlockInfo)*]*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[BlockInfo](https://tvm.apache.org/docs/reference/api/python/dlight.html#tvm.dlight.BlockInfo)] +## tvm.dlight.try_inline_contiguous_spatial(*sch:*[Schedule](/docs/api-reference/python-api/tvm-tir-schedule#class-tvmtirscheduleschedulemodprimfuncirmodule--seed-int--none--none-debug_mask-str--int--none-error_render_level-str--detail-enable_check-bool--true), *block_infos:*[List](https://docs.python.org/3/library/typing.html#typing.List)*[*[BlockInfo](/docs/api-reference/python-api/tvm-dlight#class-tvmdlightblockinfonamestr-iterslistiterinfo-block_rvblockrv-reduction_blockbool-false)*]*) → [List](https://docs.python.org/3/library/typing.html#typing.List)[[BlockInfo](/docs/api-reference/python-api/tvm-dlight#class-tvmdlightblockinfonamestr-iterslistiterinfo-block_rvblockrv-reduction_blockbool-false)] 尝试在时间表中内联连续的空间块。 * **参数:** * **sch** (*tir.Schedule*):用于内联块的 TIR 调度。 - * **block_infos** (*List[*[BlockInfo](https://tvm.apache.org/docs/reference/api/python/dlight.html#tvm.dlight.BlockInfo)*]*):要尝试的区块。 + * **block_infos** (*List[*[BlockInfo](/docs/api-reference/python-api/tvm-dlight#class-tvmdlightblockinfonamestr-iterslistiterinfo-block_rvblockrv-reduction_blockbool-false)*]*):要尝试的区块。 * **返回:remaining**:无法内联的剩余块。 -* **返回类型:** List[[BlockInfo](https://tvm.apache.org/docs/reference/api/python/dlight.html#tvm.dlight.BlockInfo)]。 +* **返回类型:** List[[BlockInfo](/docs/api-reference/python-api/tvm-dlight#class-tvmdlightblockinfonamestr-iterslistiterinfo-block_rvblockrv-reduction_blockbool-false)]。 diff --git a/docs/04-api-reference/01-python-api/26-tvm-rpc.md b/docs/04-api-reference/01-python-api/26-tvm-rpc.md index 8c014ce..1a1454b 100644 --- a/docs/04-api-reference/01-python-api/26-tvm-rpc.md +++ b/docs/04-api-reference/01-python-api/26-tvm-rpc.md @@ -19,19 +19,19 @@ TVM RPC 服务器假定用户是可信的,需要在可信网络环境和加密 **类:** -|[Server](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.Server)([host, port, port_end, is_proxy, …])|在单独的进程上启动 RPC 服务器。| +|[Server](/docs/api-reference/python-api/tvm-rpc#class-tvmrpcserverhost0000-port9091-port_end9199-is_proxyfalse-tracker_addrnone-key-load_librarynone-custom_addrnone-silentfalse-no_forkfalse-server_init_callbacknone-reuse_addrtrue-timeoutnone)([host, port, port_end, is_proxy, …])|在单独的进程上启动 RPC 服务器。| |:----|:----| -|[RPCSession](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.RPCSession)(sess)|RPC 客户端会话模块。| -|[LocalSession](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.LocalSession)()|由本地环境支持的 RPCSession 接口。| -|[PopenSession](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.PopenSession)(binary)|由 popen 支持的 RPCSession 接口。| -|[TrackerSession](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.TrackerSession)(addr)|跟踪器客户端会话。| +|[RPCSession](/docs/api-reference/python-api/tvm-rpc#class-tvmrpcrpcsessionsess)(sess)|RPC 客户端会话模块。| +|[LocalSession](/docs/api-reference/python-api/tvm-rpc#class-tvmrpclocalsession)()|由本地环境支持的 RPCSession 接口。| +|[PopenSession](/docs/api-reference/python-api/tvm-rpc#class-tvmrpcpopensessionbinary)(binary)|由 popen 支持的 RPCSession 接口。| +|[TrackerSession](/docs/api-reference/python-api/tvm-rpc#class-tvmrpctrackersessionaddr)(addr)|跟踪器客户端会话。| **函数:** -|[connect](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.connect)(url, port[, key, session_timeout, …])|连接到 RPC 服务器。| +|[connect](/docs/api-reference/python-api/tvm-rpc#tvmrpcconnecturl-port-key-session_timeout0-session_constructor_argsnone-enable_loggingfalse)(url, port[, key, session_timeout, …])|连接到 RPC 服务器。| |:----|:----| -|[connect_tracker](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.connect_tracker)(url, port)|连接到 RPC 跟踪器。| -|[with_minrpc](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.with_minrpc)(compile_func[, server, runtime])|使用 minrpc 相关选项附加将编译器函数。| +|[connect_tracker](/docs/api-reference/python-api/tvm-rpc#tvmrpcconnect_trackerurl-port)(url, port)|连接到 RPC 跟踪器。| +|[with_minrpc](/docs/api-reference/python-api/tvm-rpc#tvmrpcwith_minrpccompile_func-serverposix_popen_server-runtimelibtvm)(compile_func[, server, runtime])|使用 minrpc 相关选项附加将编译器函数。| ## *class* tvm.rpc.Server(*host='0.0.0.0'*, *port=9091*, *port_end=9199*, *is_proxy=False*, *tracker_addr=None*, *key=''*, *load_library=None*, *custom_addr=None*, *silent=False*, *no_fork=False*, *server_init_callback=None*, *reuse_addr=True*, *timeout=None*) @@ -45,7 +45,7 @@ TVM RPC 服务器假定用户是可信的,需要在可信网络环境和加密 * **port**([int](https://docs.python.org/3/library/functions.html#int)):要绑定的端口。 * **port_end** ( [int](https://docs.python.org/3/library/functions.html#int)*,可选*):要搜索的结束端口。 * **is_proxy**([bool](https://docs.python.org/3/library/functions.html#bool)*,可选*):指定的地址是否为代理。如果为真,则主机和端口实际上对应于代理服务器的地址。 - * **tracker_addr** ( [Tuple](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Tuple)*(*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[int](https://docs.python.org/3/library/functions.html#int)*),可选*):RPC Tracker 的地址,以 tuple(host, ip) 格式表示。如果不为 None,则服务器会将自身注册到 Tracker。 + * **tracker_addr** ( [Tuple](/docs/api-reference/python-api/tvm-relax#classtvmrelaxtuplefieldslistrelaxexprtuplerelaxexprspanspannonenone)*(*[str](https://docs.python.org/3/library/stdtypes.html#str)*,*[int](https://docs.python.org/3/library/functions.html#int)*),可选*):RPC Tracker 的地址,以 tuple(host, ip) 格式表示。如果不为 None,则服务器会将自身注册到 Tracker。 * **key**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*):用于识别跟踪器中的设备类型的密钥。 * **load_library**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*):执行期间要加载的附加库列表。 * **custom_addr**([str](https://docs.python.org/3/library/stdtypes.html#str)*,可选*):向 RPC 跟踪器报告的自定义 IP 地址。 @@ -55,7 +55,7 @@ TVM RPC 服务器假定用户是可信的,需要在可信网络环境和加密 * **reuse_addr** ( [bool](https://docs.python.org/3/library/functions.html#bool)*,可选*):允许内核重用处于 TIME_WAIT 状态的本地套接字。 * **timeout**([float](https://docs.python.org/3/library/functions.html#float)*,可选*):设置套接字上所有操作的超时时间。 -:::Note +:::note TVM RPC 服务器假定用户是可信的,需要在可信网络环境和加密通道中使用。它允许将任意文件写入服务器,并为任何可以访问此 API 的人提供完整的远程代码执行能力。 @@ -76,7 +76,7 @@ server = rpc.Server(host, server_init_callback=server_init_callback) **方法:** -|[terminate](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.Server.terminate)()|终止服务器进程| +|[terminate](/docs/api-reference/python-api/tvm-rpc#terminate)()|终止服务器进程| |:----|:----| ### terminate() @@ -95,7 +95,7 @@ server = rpc.Server(host, server_init_callback=server_init_callback) * **session_constructor_args** ( *List* ):作为远程会话构造函数传递的附加参数列表。列表的第一个元素始终是一个字符串,用于指定会话构造函数的名称,后续参数是该函数的位置参数。 * **enable_logging**(*布尔值*)**:** 启用/禁用日志记录的标志。默认情况下,日志记录处于禁用状态。 * **返回:sess:** 连接的会话。 -* **返回类型:**[RPCSession](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.RPCSession)。 +* **返回类型:**[RPCSession](/docs/api-reference/python-api/tvm-rpc#class-tvmrpcrpcsessionsess)。 **示例** @@ -117,10 +117,10 @@ client_via_proxy = rpc.connect( 连接到 RPC 跟踪器。 * **参数:** - * **url** ( [str](https://docs.python.org/3/library/stdtypes.html#str) ):主机的 url。 - * **port**([int](https://docs.python.org/3/library/functions.html#int))[:](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.TrackerSession)要连接的端口。 + * **url** ( [str](https://docs.python.org/3/library/stdtypes.html#str)):主机的 url。 + * **port**([int](https://docs.python.org/3/library/functions.html#int)):要连接的端口。 * **返回:sess** :连接的跟踪器会话。 -* **返回类型:**[TrackerSession](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.TrackerSession)。 +* **返回类型:**[TrackerSession](/docs/api-reference/python-api/tvm-rpc#class-tvmrpctrackersessionaddr)。 ## *class* tvm.rpc.RPCSession(*sess*) @@ -133,25 +133,25 @@ RPC 客户端会话模块。 **方法:** -|[system_lib](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.RPCSession.system_lib)()|获取系统范围的库模块。| +|[system_lib](/docs/api-reference/python-api/tvm-rpc#system_lib)()|获取系统范围的库模块。| |:----|:----| -|[get_function](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.RPCSession.get_function)(name)|从会话中获取函数。| -|[device](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.RPCSession.device)(dev_type[, dev_id])|构建一个远程设备。| -|[upload](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.RPCSession.upload)(data[, target])|将文件上传到远程运行时临时文件夹。| -|[download](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.RPCSession.download)(path)|从远程临时文件夹下载文件。| -|[remove](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.RPCSession.remove)(path)|从远程临时文件夹中删除文件。| -|[listdir](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.RPCSession.listdir)(path)|从远程临时文件夹中 ls 文件。| -|[load_module](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.RPCSession.load_module)(path)|加载远程模块,需要先上传文件。| -|[download_linked_module](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.RPCSession.download_linked_module)(path)|链接远程模块并下载。| -|[cpu](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.RPCSession.cpu)([dev_id])|构建 CPU 设备。| -|[cuda](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.RPCSession.cuda)([dev_id])|构建 CUDA GPU 设备。| -|[cl](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.RPCSession.cl)([dev_id])|构建 OpenCL 设备。| -|[vulkan](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.RPCSession.vulkan)([dev_id])|构建 Vulkan 设备。| -|[metal](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.RPCSession.metal)([dev_id])|建造金属装置。| -|[rocm](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.RPCSession.rocm)([dev_id])|构建 ROCm 设备。| -|[ext_dev](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.RPCSession.ext_dev)([dev_id])|构建扩展设备。| -|[hexagon](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.RPCSession.hexagon)([dev_id])|构建六边形装置。| -|[webgpu](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.RPCSession.webgpu)([dev_id])|构建 WebGPU 设备。| +|[get_function](/docs/api-reference/python-api/tvm-rpc#get_functionname)(name)|从会话中获取函数。| +|[device](/docs/api-reference/python-api/tvm-rpc#devicedev_type-dev_id0)(dev_type[, dev_id])|构建一个远程设备。| +|[upload](/docs/api-reference/python-api/tvm-rpc#uploaddata-targetnone)(data[, target])|将文件上传到远程运行时临时文件夹。| +|[download](/docs/api-reference/python-api/tvm-rpc#downloadpath)(path)|从远程临时文件夹下载文件。| +|[remove](/docs/api-reference/python-api/tvm-rpc#removepath)(path)|从远程临时文件夹中删除文件。| +|[listdir](/docs/api-reference/python-api/tvm-rpc#listdirpath)(path)|从远程临时文件夹中 ls 文件。| +|[load_module](/docs/api-reference/python-api/tvm-rpc#load_modulepath)(path)|加载远程模块,需要先上传文件。| +|[download_linked_module](/docs/api-reference/python-api/tvm-rpc#download_linked_modulepath)(path)|链接远程模块并下载。| +|[cpu](/docs/api-reference/python-api/tvm-rpc#cpudev_id0)([dev_id])|构建 CPU 设备。| +|[cuda](/docs/api-reference/python-api/tvm-rpc#cudadev_id0)([dev_id])|构建 CUDA GPU 设备。| +|[cl](/docs/api-reference/python-api/tvm-rpc#cldev_id0)([dev_id])|构建 OpenCL 设备。| +|[vulkan](/docs/api-reference/python-api/tvm-rpc#vulkandev_id0)([dev_id])|构建 Vulkan 设备。| +|[metal](/docs/api-reference/python-api/tvm-rpc#metaldev_id0)([dev_id])|建造金属装置。| +|[rocm](/docs/api-reference/python-api/tvm-rpc#rocmdev_id0)([dev_id])|构建 ROCm 设备。| +|[ext_dev](/docs/api-reference/python-api/tvm-rpc#ext_devdev_id0)([dev_id])|构建扩展设备。| +|[hexagon](/docs/api-reference/python-api/tvm-rpc#hexagondev_id0)([dev_id])|构建六边形装置。| +|[webgpu](/docs/api-reference/python-api/tvm-rpc#webgpudev_id0)([dev_id])|构建 WebGPU 设备。| ### system_lib() @@ -171,7 +171,7 @@ RPC 客户端会话模块。 从会话中获取函数。 * **参数:name** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :函数名称 * **返回:f** :结果函数。 -* **返回类型:**[Function](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Function)。 +* **返回类型:**[Function](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfunctionparamslistvarbodyrelaxexprret_struct_infostructinfononenoneis_pureboolnonetrueattrsdictattrsnonenonespanspannonenone)。 ### device(*dev_type*, *dev_id=0*) @@ -195,7 +195,7 @@ RPC 客户端会话模块。 从远程临时文件夹下载文件。 -* **参数:path** ([str](https://docs.python.org/3/library/stdtypes.html#str)) [:](https://docs.python.org/3/library/stdtypes.html#bytearray)远程临时文件夹的相对位置。 +* **参数:path** ([str](https://docs.python.org/3/library/stdtypes.html#str)) :远程临时文件夹的相对位置。 * **返回:blob** :来自文件的结果 blob。 * **返回类型:**[bytearray](https://docs.python.org/3/library/stdtypes.html#bytearray)。 @@ -229,7 +229,7 @@ RPC 客户端会话模块。 * **返回:blob** :来自文件的结果 blob。 * **返回类型:**[bytearray](https://docs.python.org/3/library/stdtypes.html#bytearray)。 -:::Note +:::note 当本地客户端上没有可用的链接器时,此函数会很有帮助。 @@ -310,12 +310,12 @@ with open("lib.so", "wb") as file: **方法:** -|[close](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.TrackerSession.close)()|关闭跟踪器连接。| +|[close](/docs/api-reference/python-api/tvm-rpc#close)()|关闭跟踪器连接。| |:----|:----| -|[summary](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.TrackerSession.summary)()|获取跟踪器的摘要字典。| -|[text_summary](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.TrackerSession.text_summary)()|获取跟踪器的文本摘要。| -|[request](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.TrackerSession.request)(key[, priority, session_timeout, …])|向跟踪器请求新的连接。| -|[request_and_run](https://tvm.apache.org/docs/reference/api/python/rpc.html#tvm.rpc.TrackerSession.request_and_run)(key, func[, priority, …])|从跟踪器请求资源并运行该函数。| +|[summary](/docs/api-reference/python-api/tvm-rpc#summary)()|获取跟踪器的摘要字典。| +|[text_summary](/docs/api-reference/python-api/tvm-rpc#text_summary)()|获取跟踪器的文本摘要。| +|[request](/docs/api-reference/python-api/tvm-rpc#requestkey-priority1-session_timeout0-max_retry5-session_constructor_argsnone)(key[, priority, session_timeout, …])|向跟踪器请求新的连接。| +|[request_and_run](/docs/api-reference/python-api/tvm-rpc#request_and_runkey-func-priority1-session_timeout0-max_retry2)(key, func[, priority, …])|从跟踪器请求资源并运行该函数。| ### close() diff --git a/docs/04-api-reference/01-python-api/27-tvm-contrib.md b/docs/04-api-reference/01-python-api/27-tvm-contrib.md index a380d02..be43032 100644 --- a/docs/04-api-reference/01-python-api/27-tvm-contrib.md +++ b/docs/04-api-reference/01-python-api/27-tvm-contrib.md @@ -23,24 +23,24 @@ BLAS 库的外部函数接口。 创建一个外部操作,使用 CrhsLAS 计算 A 和 rhs 的矩阵乘法,此函数作为如何调用外部库的示例。 * **参数:** - * **lhs** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):左矩阵操作数。 - * **rhs** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):右矩阵操作数。 + * **lhs** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):左矩阵操作数。 + * **rhs** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):右矩阵操作数。 * **transa** ([bool](https://docs.python.org/3/library/functions.html#bool)):是否转置 lhs。 * **transb** ([bool](https://docs.python.org/3/library/functions.html#bool)):是否转置 rhs。 * **返回:C**:结果张量。 -* **返回类型:**[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.contrib.cblas.batch_matmul(*lhs*, *rhs*, *transa=False*, *transb=False*, *iterative=False*, ***kwargs*) 创建一个外部操作,使用 CBLAS 计算 A 和 rhs 的分批矩阵乘法。此函数作为如何调用外部库的示例。 * **参数:** - * **lhs** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):左矩阵操作数。 - * **rhs** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):右矩阵操作数。 + * **lhs** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):左矩阵操作数。 + * **rhs** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):右矩阵操作数。 * **transa** ([bool](https://docs.python.org/3/library/functions.html#bool)):是否转置 lhs。 * **transb** ([bool](https://docs.python.org/3/library/functions.html#bool)):是否转置 rhs。 * **返回:C**:结果张量。 -* **返回类型:**[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 @@ -61,7 +61,7 @@ BLAS 库的外部函数接口。 * **返回:valid_list**:可能路径的列表。 * **返回类型:**[list](https://docs.python.org/3/library/stdtypes.html#list) of [str](https://docs.python.org/3/library/stdtypes.html#str). -:::Note +:::note 此函数将首先搜索与使用 tvm 构建的主要 llvm 版本匹配的 clang。 @@ -188,23 +188,23 @@ cuBLAS 库的外部函数接口。 创建一个外部操作,使用 cuBLAS 计算矩阵 A 和 rhs 的乘数。 * **参数:** - * **lhs** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):左矩阵操作数。 - * **rhs** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))*:* 右矩阵操作数。 + * **lhs** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):左矩阵操作数。 + * **rhs** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))*:* 右矩阵操作数。 * **transa** ([bool](https://docs.python.org/3/library/functions.html#bool))*:* 是否转置 lhs。 * **transb** ([bool](https://docs.python.org/3/library/functions.html#bool)):是否转置 rhs。 * **返回:C**:结果张量。 -* **返回类型:**[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.contrib.cublas.batch_matmul(*lhs*, *rhs*, *transa=False*, *transb=False*, *dtype=None*) 创建一个外部操作,使用 cuBLAS 计算批量矩阵 A 和 rhs 的乘数。 * **参数:** - * **lhs** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):左矩阵操作数。 - * **rhs** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):右矩阵操作数。 + * **lhs** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):左矩阵操作数。 + * **rhs** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):右矩阵操作数。 * **transa** ([bool](https://docs.python.org/3/library/functions.html#bool)):是否转置 lhs。 * **transb** ([bool](https://docs.python.org/3/library/functions.html#bool)):是否转置 rhs。 * **返回:C**:结果张量。 -* **返回类型:**[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 @@ -219,16 +219,16 @@ cuBLAS 库的外部函数接口。 将一个 TVM 函数转换为能够接受来自其他框架的张量的函数,前提是该框架支持 DLPACK。 * **参数:** - * **tvm_func** ([Function](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Function)):构建对数组进行操作的 tvm 函数。 - * **tensor_type** ([Type](https://tvm.apache.org/docs/reference/api/python/ir.html#tvm.ir.Type)):目标框架的张量类型。 - * **to_dlpack_func** ([Function](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Function)):将源张量转换为 DLPACK 的函数。 + * **tvm_func** ([Function](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfunctionparamslistvarbodyrelaxexprret_struct_infostructinfononenoneis_pureboolnonetrueattrsdictattrsnonenonespanspannonenone)):构建对数组进行操作的 tvm 函数。 + * **tensor_type** ([Type](/docs/api-reference/python-api/tvm-ir#class-tvmirtype)):目标框架的张量类型。 + * **to_dlpack_func** ([Function](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfunctionparamslistvarbodyrelaxexprret_struct_infostructinfononenoneis_pureboolnonetrueattrsdictattrsnonenonespanspannonenone)):将源张量转换为 DLPACK 的函数。 ## tvm.contrib.dlpack.to_pytorch_func(*tvm_func*) 将 tvm 函数转换为接受 PyTorch 张量的函数。 -* **参数:tvm_func** ([Function](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Function)):构建对数组进行操作的 tvm 函数。 +* **参数:tvm_func** ([Function](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfunctionparamslistvarbodyrelaxexprret_struct_infostructinfononenoneis_pureboolnonetrueattrsdictattrsnonenonespanspannonenone)):构建对数组进行操作的 tvm 函数。 * **返回:wrapped_func**:对 PyTorch 张量进行操作的包装 tvm 函数。 -* **返回类型:**[Function](https://tvm.apache.org/docs/reference/api/python/relax/relax.html#tvm.relax.Function)。 +* **返回类型:**[Function](/docs/api-reference/python-api/tvm-relax#classtvmrelaxfunctionparamslistvarbodyrelaxexprret_struct_infostructinfononenoneis_pureboolnonetrueattrsdictattrsnonenonespanspannonenone)。 # tvm.contrib.emcc @@ -258,8 +258,8 @@ MIOpen 库的外部函数接口。 创建一个使用 MIOpen 计算 2D 卷积的外部操作。 * **参数:** - * **x** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入特征图。 - * **w** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):卷积权重。 + * **x** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入特征图。 + * **w** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):卷积权重。 * **stride_h** ([int](https://docs.python.org/3/library/functions.html#int)):身高步幅。 * **stride_w** ([int](https://docs.python.org/3/library/functions.html#int)):宽度步幅。 * **pad_h** ([int](https://docs.python.org/3/library/functions.html#int))**:** 高度垫。 @@ -270,25 +270,25 @@ MIOpen 库的外部函数接口。 * **data_type** ([int](https://docs.python.org/3/library/functions.html#int))**:** 0:miopenHalf(fp16)1:miopenFloat(fp32)。 * **group_count** ([int](https://docs.python.org/3/library/functions.html#int)):组数。 * **返回:y**:结果张量。 -* **返回类型:**[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.contrib.miopen.softmax(*x*, *axis=-1*) 使用 MIOpen 计算 softmax。 * **参数:** - * **x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入张量。 + * **x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入张量。 * **axis** ([int](https://docs.python.org/3/library/functions.html#int)):计算 softmax 的轴。 * **返回:ret**:结果张量。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.contrib.miopen.log_softmax(*x*, *axis=-1*) 使用 MIOpen 计算对数 softmax。 * **参数:** - * **x** ([tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):输入张量。 + * **x** ([tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):输入张量。 * **axis** ([int](https://docs.python.org/3/library/functions.html#int))*:* 计算 log softmax 的轴。 * **返回:ret**:结果张量。 -* **返回类型:**[tvm.te.Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[tvm.te.Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 @@ -343,43 +343,43 @@ NNPACK 库的外部函数接口。 创建一个外部操作,使用 nnpack 计算 1D 张量 lhs 和 2D 张量 rhs 的完全连接。 * **参数:** - * **lhs** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):FP32 元素的 lhs 1D 数组输入[input_channels]。 - * **rhs** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):FP32 元素的 lhs 二维矩阵核[输出通道][输入通道]。 + * **lhs** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):FP32 元素的 lhs 1D 数组输入[input_channels]。 + * **rhs** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):FP32 元素的 lhs 二维矩阵核[输出通道][输入通道]。 * **返回:C**:FP32 元素的 lhs 1D 数组 out[output_channels]。 -* **返回类型:**[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.contrib.nnpack.convolution_inference(*data*, *kernel*, *bias*, *padding*, *stride*, *nthreads=1*, *algorithm=0*) 创建一个外部操作,使用 nnpack 对 4D 张量数据和 4D 张量核以及 1D 张量偏差进行推理卷积。 * **参数:** - * **data** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):FP32 元素的数据 4D 张量输入[batch][input_channels][input_height][input_width]。 - * **kernel** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** FP32 元素的内核 4D 张量 kernel[output_channels][input_channels][kernel_height] [kernel_width]。 - * **bias** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):FP32 元素的偏差 1D 数组偏差[output_channels][input_channels][kernel_height] [kernel_width]。 + * **data** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):FP32 元素的数据 4D 张量输入[batch][input_channels][input_height][input_width]。 + * **kernel** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** FP32 元素的内核 4D 张量 kernel[output_channels][input_channels][kernel_height] [kernel_width]。 + * **bias** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):FP32 元素的偏差 1D 数组偏差[output_channels][input_channels][kernel_height] [kernel_width]。 * **padding** ([list](https://docs.python.org/3/library/stdtypes.html#list)):padding 一个 4 维列表,包含 [pad_top、pad_bottom、pad_left、pad_right],表示特征图周围的填充。 * **stride** ([list](https://docs.python.org/3/library/stdtypes.html#list)):步幅 [stride_height,stride_width] 的 2 维列表,表示步幅。 * **返回:output**:FP32 元素的输出 4D 张量输出[batch][output_channels][output_height][output_width]。 -* **返回类型:**[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.contrib.nnpack.convolution_inference_without_weight_transform(*data*, *transformed_kernel*, *bias*, *padding*, *stride*, *nthreads=1*, *algorithm=0*) 创建一个外部操作,使用 nnpack 对 4D 张量数据和 4D 预转换张量核和 1D 张量偏差进行推理卷积。 * **参数:** - * **data** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))**:** FP32 元素的数据 4D 张量输入[batch][input_channels][input_height][input_width]。 - * **transformed_kernel** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):transformed_kernel 4D 张量 kernel[output_channels][input_channels][tile] [tile] 由 FP32 元素组成。 - * **bias** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):FP32 元素的偏差 1D 数组偏差[output_channels][input_channels][kernel_height] [kernel_width]。 + * **data** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))**:** FP32 元素的数据 4D 张量输入[batch][input_channels][input_height][input_width]。 + * **transformed_kernel** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):transformed_kernel 4D 张量 kernel[output_channels][input_channels][tile] [tile] 由 FP32 元素组成。 + * **bias** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):FP32 元素的偏差 1D 数组偏差[output_channels][input_channels][kernel_height] [kernel_width]。 * **padding** ([list](https://docs.python.org/3/library/stdtypes.html#list))*:* padding 一个 4 维列表,包含 [pad_top、pad_bottom、pad_left、pad_right],表示特征图周围的填充。 * **stride** ([list](https://docs.python.org/3/library/stdtypes.html#list)):步幅 [stride_height,stride_width] 的 2 维列表,表示步幅。 * **返回:output**:FP32 元素的输出 4D 张量输出[batch][output_channels][output_height][output_width]。 -* **返回类型:**[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.contrib.nnpack.convolution_inference_weight_transform(*kernel*, *nthreads=1*, *algorithm=0*, *dtype='float32'*) 创建一个外部操作,使用 nnpack 对 3D 张量数据和 4D 张量核以及 1D 张量偏差进行推理卷积。 -* **参数:kernel** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor))*:* FP32 元素的内核 4D 张量 kernel[output_channels][input_channels][kernel_height] [kernel_width]。 +* **参数:kernel** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor))*:* FP32 元素的内核 4D 张量 kernel[output_channels][input_channels][kernel_height] [kernel_width]。 * **返回:output**:FP32 元素的输出 4D 张量输出[output_channels][input_channels][tile][tile]。 -* **返回类型:**[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 @@ -449,7 +449,7 @@ NNPACK 库的外部函数接口。 计算功能中是否提供 TensorCore 支持。 * 参数: * **compute_version** ([str](https://docs.python.org/3/library/stdtypes.html#str)*,optional*):GPU 的计算能力(例如“7.0”)。 - * **target** ([tvm.target.Target](https://tvm.apache.org/docs/reference/api/python/target.html#tvm.target.Target)*,optional*)*:*编译目标,如果未指定 compute_version,则将用于确定 arch。 + * **target** ([tvm.target.Target](/docs/api-reference/python-api/tvm-target#class-tvmtargettargettarget-hostnone)*,optional*)*:*编译目标,如果未指定 compute_version,则将用于确定 arch。 ## tvm.contrib.nvcc.have_cudagraph() @@ -497,7 +497,7 @@ NNPACK 库的外部函数接口。 * **low** ([int](https://docs.python.org/3/library/functions.html#int)):从分布中抽取的最低(有符号)整数。 * **high** ([int](https://docs.python.org/3/library/functions.html#int)):从分布中抽取的最大(有符号)整数的上一个。 * **返回:out** *:* 具有指定大小和 dtype 的张量。 -* **返回类型:**[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.contrib.random.uniform(*low*, *high*, *size*) @@ -511,7 +511,7 @@ NNPACK 库的外部函数接口。 * **high** ([float](https://docs.python.org/3/library/functions.html#float)):输出间隔的上限。所有生成的值都将小于 high。 * **size** ([tuple](https://docs.python.org/3/library/stdtypes.html#tuple)*ofints*):输出形状。如果给定形状为 (m, n, k),则绘制 m * n * k 个样本。 * **返回:out**:具有指定大小和 dtype 的张量。 -* **返回类型:**[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.contrib.random.normal(*loc*, *scale*, *size*) @@ -525,7 +525,7 @@ NNPACK 库的外部函数接口。 * **scale** ([float](https://docs.python.org/3/library/functions.html#float)):分布的标准差。 * **size** ([tuple](https://docs.python.org/3/library/stdtypes.html#tuple)*ofints*):输出形状。如果给定形状为 (m, n, k),则绘制 m * n * k 个样本。 * **返回:out**:具有指定大小和 dtype 的张量。 -* **返回类型:**[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 @@ -539,24 +539,24 @@ rocBLAS 库的外部函数接口。 创建一个外部操作,使用 rocBLAS 计算 A 和 rhs 的矩阵乘法。 * **参数:** - * **lhs** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):左矩阵操作数。 - * **rhs** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):右矩阵操作数。 + * **lhs** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):左矩阵操作数。 + * **rhs** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):右矩阵操作数。 * **transa** ([bool](https://docs.python.org/3/library/functions.html#bool)):是否转置 lhs。 * **transb** ([bool](https://docs.python.org/3/library/functions.html#bool)):是否转置 rhs。 * **返回:C**:结果张量。 -* **返回类型:**[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 ## tvm.contrib.rocblas.batch_matmul(*lhs*, *rhs*, *transa=False*, *transb=False*) 创建一个外部操作,使用 rocBLAS 计算 A 和 rhs 的矩阵乘法。 * **参数:** - * **lhs** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):左批处理矩阵操作数。 - * **rhs** ([Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)):右批处理矩阵操作数。 + * **lhs** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):左批处理矩阵操作数。 + * **rhs** ([Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)):右批处理矩阵操作数。 * **transa** ([bool](https://docs.python.org/3/library/functions.html#bool))**:** 是否转置 lhs。 * **transb** ([bool](https://docs.python.org/3/library/functions.html#bool)):是否转置 rhs。 * **返回:C**:结果张量。 -* **返回类型:**[Tensor](https://tvm.apache.org/docs/reference/api/python/te.html#tvm.te.Tensor)。 +* **返回类型:**[Tensor](/docs/api-reference/python-api/tvm-te#class-tvmtetensor)。 # tvm.contrib.rocm @@ -572,7 +572,7 @@ ROCm 后端实用程序。 * **返回:valid_list**:可能路径的列表。 * **返回类型:**[list](https://docs.python.org/3/library/stdtypes.html#list) of [str](https://docs.python.org/3/library/stdtypes.html#str)。 -:::Note +:::note 此函数将首先搜索与使用 tvm 构建的主要 llvm 版本匹配的 ld.lld @@ -662,7 +662,7 @@ ROCm 后端实用程序。 这对于解压 tar 中的对象然后将其转换为库很有用。 * **参数:** - * **temp** ([tvm.contrib.utils.TempDirectory](https://tvm.apache.org/docs/reference/api/python/contrib.html#tvm.contrib.utils.TempDirectory)):用于保存解压文件的临时目录。 + * **temp** ([tvm.contrib.utils.TempDirectory](/docs/api-reference/python-api/tvm-contrib#class-tvmcontributilstempdirectorycustom_pathnone-keep_for_debugnone)):用于保存解压文件的临时目录。 * **file_list** (*List[*[str](https://docs.python.org/3/library/stdtypes.html#str)*]*):路径列表。 * **返回:ret_list**:更新的文件列表。 * **返回类型:** List[[str](https://docs.python.org/3/library/stdtypes.html#str)]。 @@ -720,7 +720,7 @@ ROCm 后端实用程序。 * **custom_path** ([str](https://docs.python.org/3/library/stdtypes.html#str)*,optional*):手动指定准确的临时目录路径。 * **keep_for_debug** ([bool](https://docs.python.org/3/library/functions.html#bool)):保留临时目录以用于调试目的。 * **返回:temp**:临时目录对象。 -* **返回类型:**[TempDirectory](https://tvm.apache.org/docs/reference/api/python/contrib.html#tvm.contrib.utils.TempDirectory)。 +* **返回类型:**[TempDirectory](/docs/api-reference/python-api/tvm-contrib#class-tvmcontributilstempdirectorycustom_pathnone-keep_for_debugnone)。 ## *class* tvm.contrib.utils.FileLock(*path*) diff --git a/docs/04-api-reference/01-python-api/index.md b/docs/04-api-reference/01-python-api/index.md index 680a4f8..1f668d5 100644 --- a/docs/04-api-reference/01-python-api/index.md +++ b/docs/04-api-reference/01-python-api/index.md @@ -5,47 +5,46 @@ title: Pyhon API --- **tvm** -* [tvm.error](https://tvm.apache.org/docs/reference/api/python/error.html) -* [tvm.ir](https://tvm.apache.org/docs/reference/api/python/ir.html) -* [tvm.instrument](https://tvm.apache.org/docs/reference/api/python/instrument.html) -* [tvm.transform](https://tvm.apache.org/docs/reference/api/python/transform.html) -* [tvm.target](https://tvm.apache.org/docs/reference/api/python/target.html) -* [tvm.driver](https://tvm.apache.org/docs/reference/api/python/driver.html) +* [tvm.error](/docs/api-reference/python-api/tvm-error) +* [tvm.ir](/docs/api-reference/python-api/tvm-ir) +* [tvm.instrument](/docs/api-reference/python-api/tvm-instrument) +* [tvm.transform](/docs/api-reference/python-api/tvm-instrument) +* [tvm.target](/docs/api-reference/python-api/tvm-target) +* [tvm.driver](/docs/api-reference/python-api/tvm-driver) **tvm.runtime** -* [tvm.runtime](https://tvm.apache.org/docs/reference/api/python/runtime/runtime.html) -* [tvm.runtime.ndarray](https://tvm.apache.org/docs/reference/api/python/runtime/ndarray.html) -* [tvm.runtime.relax_vm](https://tvm.apache.org/docs/reference/api/python/runtime/relax_vm.html) -* [tvm.runtime.disco](https://tvm.apache.org/docs/reference/api/python/runtime/disco.html) -* [tvm.runtime.profiling](https://tvm.apache.org/docs/reference/api/python/runtime/profiling.html) +* [tvm.runtime](/docs/api-reference/python-api/tvm-runtime) +* [tvm.runtime.relax_vm](/docs/api-reference/python-api/tvm-runtime-vm) +* [tvm.runtime.disco](/docs/api-reference/python-api/tvm-runtime-disco) +* [tvm.runtime.profiling](/docs/api-reference/python-api/tvm-runtime-profiling) **tvm.relax** -* [tvm.relax](https://tvm.apache.org/docs/reference/api/python/relax/relax.html) -* [tvm.relax.analysis](https://tvm.apache.org/docs/reference/api/python/relax/analysis.html) -* [tvm.relax.block_builder](https://tvm.apache.org/docs/reference/api/python/relax/block_builder.html) -* [tvm.relax.frontend](https://tvm.apache.org/docs/reference/api/python/relax/frontend.html) -* [tvm.relax.op](https://tvm.apache.org/docs/reference/api/python/relax/op.html) -* [tvm.relax.transform](https://tvm.apache.org/docs/reference/api/python/relax/transform.html) +* [tvm.relax](/docs/api-reference/python-api/tvm-relax) +* [tvm.relax.analysis](/docs/api-reference/python-api/tvm-relax-analysis) +* [tvm.relax.block_builder](/docs/api-reference/python-api/tvm-relax_block_builder) +* [tvm.relax.frontend](/docs/api-reference/python-api/tvm-relax-frontend) +* [tvm.relax.op](/docs/api-reference/python-api/tvm-relax-op) +* [tvm.relax.transform](/docs/api-reference/python-api/tvm-relax-transform) **tvm.tir** -* [tvm.tir](https://tvm.apache.org/docs/reference/api/python/tir/tir.html) -* [tvm.tir.analysis](https://tvm.apache.org/docs/reference/api/python/tir/analysis.html) -* [tvm.tir.schedule](https://tvm.apache.org/docs/reference/api/python/tir/schedule.html) -* [tvm.tir.stmt_functor](https://tvm.apache.org/docs/reference/api/python/tir/stmt_functor.html) -* [tvm.tir.transform](https://tvm.apache.org/docs/reference/api/python/tir/transform.html) +* [tvm.tir](/docs/api-reference/python-api/tvm-tir) +* [tvm.tir.analysis](/docs/api-reference/python-api/tvm-tir-analysis) +* [tvm.tir.schedule](/docs/api-reference/python-api/tvm-tir-schedule) +* [tvm.tir.stmt_functor](/docs/api-reference/python-api/tvm-tir-stmt_functor) +* [tvm.tir.transform](/docs/api-reference/python-api/tvm-tir-transform) **tvm.te** -* [tvm.te](https://tvm.apache.org/docs/reference/api/python/te.html) -* [tvm.topi](https://tvm.apache.org/docs/reference/api/python/topi.html) +* [tvm.te](/docs/api-reference/python-api/tvm-te) +* [tvm.topi](/docs/api-reference/python-api/tvm-topi) **tvm.meta_schedule** -* [tvm.meta_schedule](https://tvm.apache.org/docs/reference/api/python/meta_schedule.html) +* [tvm.meta_schedule](/docs/api-reference/python-api/tvm-meta_schedule) **tvm.dlight** -* [tvm.dlight](https://tvm.apache.org/docs/reference/api/python/dlight.html) +* [tvm.dlight](/docs/api-reference/python-api/tvm-dlight) **Misc** -* [tvm.rpc](https://tvm.apache.org/docs/reference/api/python/rpc.html) -* [tvm.contrib](https://tvm.apache.org/docs/reference/api/python/contrib.html) +* [tvm.rpc](/docs/api-reference/python-api/tvm-rpc) +* [tvm.contrib](/docs/api-reference/python-api/tvm-contrib) diff --git a/docs/05-about/01-contribute/01-TVM-Community-community.md b/docs/05-about/01-contribute/01-TVM-Community-community.md index 69c26d1..f1adf28 100644 --- a/docs/05-about/01-contribute/01-TVM-Community-community.md +++ b/docs/05-about/01-contribute/01-TVM-Community-community.md @@ -4,10 +4,10 @@ title: 社区准则 --- -* [通用开发流程](https://tvm.apache.org/docs/contribute/community.html#general-development-process) -* [战略决策流程](https://tvm.apache.org/docs/contribute/community.html#general-development-process) -* [提交者](https://tvm.apache.org/docs/contribute/community.html#strategy-decision-process) -* [审阅者](https://tvm.apache.org/docs/contribute/community.html#committers) +* [通用开发流程](/docs/about/contribute/TVM-Community-community#%E9%80%9A%E7%94%A8%E5%BC%80%E5%8F%91%E6%B5%81%E7%A8%8B) +* [战略决策流程](/docs/about/contribute/TVM-Community-community#%E6%88%98%E7%95%A5%E5%86%B3%E7%AD%96%E6%B5%81%E7%A8%8B) +* [提交者](/docs/about/contribute/TVM-Community-community#%E6%8F%90%E4%BA%A4%E8%80%85) +* [审阅者](/docs/about/contribute/TVM-Community-community#%E5%AE%A1%E9%98%85%E8%80%85) diff --git a/docs/05-about/01-contribute/010-error_handling-guide.md b/docs/05-about/01-contribute/010-error_handling-guide.md index 8df06e9..9174e4d 100644 --- a/docs/05-about/01-contribute/010-error_handling-guide.md +++ b/docs/05-about/01-contribute/010-error_handling-guide.md @@ -4,8 +4,8 @@ title: 错误处理指南 --- -* [在 C++ 中抛出特定错误](https://tvm.apache.org/docs/contribute/error_handling.html#raise-a-specific-error-in-c) -* [如何选择错误类型](https://tvm.apache.org/docs/contribute/error_handling.html#how-to-choose-an-error-type) +* [在 C++ 中抛出特定错误](/docs/about/contribute/error_handling-guide#%E5%9C%A8-c-%E4%B8%AD%E6%8A%9B%E5%87%BA%E7%89%B9%E5%AE%9A%E9%94%99%E8%AF%AF) +* [如何选择错误类型](/docs/about/contribute/error_handling-guide#%E5%9C%A8-c-%E4%B8%AD%E6%8A%9B%E5%87%BA%E7%89%B9%E5%AE%9A%E9%94%99%E8%AF%AF) TVM 包含结构化的错误类,用于指示特定类型的错误。请尽可能抛出特定的错误类型,以便用户在必要时可以编写代码处理某一类特定错误。在 Python 中,你可以直接抛出具体的错误对象。而在 C++ 等其他语言中,你只需在错误信息前添加 `:` 前缀(见下文)。 diff --git a/docs/05-about/01-contribute/02-Submit_a_pull_request.md b/docs/05-about/01-contribute/02-Submit_a_pull_request.md index 1a009cb..3cdfb89 100644 --- a/docs/05-about/01-contribute/02-Submit_a_pull_request.md +++ b/docs/05-about/01-contribute/02-Submit_a_pull_request.md @@ -4,13 +4,13 @@ title: 提交 Pull Request --- -* [指南](https://tvm.apache.org/docs/contribute/pull_request.html#guidelines) -* [提交信息指南](https://tvm.apache.org/docs/contribute/pull_request.html#commit-message-guideline) -* [持续集成(CI)环境](https://tvm.apache.org/docs/contribute/pull_request.html#ci-environment) -* [测试](https://tvm.apache.org/docs/contribute/pull_request.html#testing) - * [ Docker(推荐)](https://tvm.apache.org/docs/contribute/pull_request.html#docker-recommended) - * [C++(本地)](https://tvm.apache.org/docs/contribute/pull_request.html#c-local) - * [Python(本地)](https://tvm.apache.org/docs/contribute/pull_request.html#python-local) +* [指南](/docs/about/contribute/Submit_a_pull_request#%E6%8C%87%E5%8D%97) +* [提交信息指南](/docs/about/contribute/Submit_a_pull_request#%E6%8F%90%E4%BA%A4%E4%BF%A1%E6%81%AF%E6%8C%87%E5%8D%97) +* [持续集成(CI)环境](/docs/about/contribute/Submit_a_pull_request#ci-%E7%8E%AF%E5%A2%83) +* [测试](/docs/about/contribute/Submit_a_pull_request#ci-%E7%8E%AF%E5%A2%83) + * [ Docker(推荐)](/docs/about/contribute/Submit_a_pull_request#docker%E6%8E%A8%E8%8D%90) + * [C++(本地)](/docs/about/contribute/Submit_a_pull_request#c%E6%9C%AC%E5%9C%B0) + * [Python(本地)](/docs/about/contribute/Submit_a_pull_request#python%E6%9C%AC%E5%9C%B0) ## 指南 @@ -51,8 +51,8 @@ docker/lint.sh ... docker/bash.sh ci_lint ./tests/lint/git-clang-format.sh --rev upstream/main ``` * 请为你引入的新功能或修复添加测试用例。 -* 为你编写的代码添加文档,详见 [文档指南](https://tvm.apache.org/docs/contribute/document.html#doc-guide)。 -* 创建 [Pull Request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request),并修复 CI 检查中发现的问题。 +* 为你编写的代码添加文档,详见 [文档指南](/docs/about/contribute/documentation)。 +* 创建 [Pull Request](https://docs.github.com/zh/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request),并修复 CI 检查中发现的问题。 * 邀请其他贡献者进行代码审查,并根据审查反馈改进补丁,可以通过 `@用户名` 的方式在 PR 中标记审查者。PR 标题中的标签会自动通知订阅用户,因此请确保标题包含相关标签(例如 `[microTVM] Add a cool change`,而不是 `a cool change for microTVM`)。更多关于标签和消息写法的内容请见下方的提交信息指南。 * 为了更快获得审查,我们鼓励你也积极审查他人的代码,互帮互助。 * 代码审查是一个提升代码质量的过程,请积极对待,尽量在审查前完善你的代码。我们非常欢迎那些不需要反复审查就可以合并的补丁。 @@ -179,7 +179,7 @@ docker/clear-stale-images.sh ### C++(本地) -运行 C++ 测试需要安装 gtest,请参考 [启用 C++ 测试](https://tvm.apache.org/docs/install/from_source.html#install-from-source-cpp-tests) 中的说明。 +运行 C++ 测试需要安装 gtest,请参考 [启用 C++ 测试](/docs/getting-started/installing-tvm/install-from-source#%E5%90%AF%E7%94%A8-c-%E6%B5%8B%E8%AF%95) 中的说明。 ```plain diff --git a/docs/05-about/01-contribute/03-code_review.md b/docs/05-about/01-contribute/03-code_review.md index e8593ab..7a45715 100644 --- a/docs/05-about/01-contribute/03-code_review.md +++ b/docs/05-about/01-contribute/03-code_review.md @@ -4,28 +4,28 @@ title: 代码审查 --- -* [建立信任](https://tvm.apache.org/docs/contribute/code_review.html#building-trust) -* [社区参与](https://tvm.apache.org/docs/contribute/code_review.html#community-participation) -* [仔细阅读代码](https://tvm.apache.org/docs/contribute/code_review.html#read-the-code-carefully) -* [保持尊重](https://tvm.apache.org/docs/contribute/code_review.html#be-respectful) -* [代码质量考量因素](https://tvm.apache.org/docs/contribute/code_review.html#factors-to-consider-about-code-quality) -* [达成共识](https://tvm.apache.org/docs/contribute/code_review.html#consensus-building) -* [一致性](https://tvm.apache.org/docs/contribute/code_review.html#consistency) -* [其他建议](https://tvm.apache.org/docs/contribute/code_review.html#additional-recommendations) - * [深思 API ](https://tvm.apache.org/docs/contribute/code_review.html#deliberate-on-api-and-data-structures)[与](https://tvm.apache.org/docs/contribute/code_review.html#deliberate-on-api-and-data-structures)[数据结构设计](https://tvm.apache.org/docs/contribute/code_review.html#deliberate-on-api-and-data-structures) - * [最小化依赖](https://tvm.apache.org/docs/contribute/code_review.html#minimize-dependencies) - * [简洁实现](https://tvm.apache.org/docs/contribute/code_review.html#concise-implementation) - * 在代码审阅中记录经验教训 - * 学习其他人的代码审阅 - * [明确批准或请求更改](https://tvm.apache.org/docs/contribute/code_review.html#approve-and-request-changes-explicitly) - * 审阅者职责 +* [建立信任](/docs/about/contribute/code_review#%E5%BB%BA%E7%AB%8B%E4%BF%A1%E4%BB%BB) +* [社区参与](/docs/about/contribute/code_review#%E7%A4%BE%E5%8C%BA%E5%8F%82%E4%B8%8Ecommunity-participation) +* [仔细阅读代码](/docs/about/contribute/code_review#%E8%AE%A4%E7%9C%9F%E9%98%85%E8%AF%BB%E4%BB%A3%E7%A0%81) +* [保持尊重](/docs/about/contribute/code_review#%E4%BF%9D%E6%8C%81%E5%B0%8A%E9%87%8D) +* [代码质量考量因素](/docs/about/contribute/code_review#%E4%BB%A3%E7%A0%81%E8%B4%A8%E9%87%8F%E8%80%83%E9%87%8F%E5%9B%A0%E7%B4%A0) +* [达成共识](/docs/about/contribute/code_review#%E4%BB%A3%E7%A0%81%E8%B4%A8%E9%87%8F%E8%80%83%E9%87%8F%E5%9B%A0%E7%B4%A0) +* [一致性](/docs/about/contribute/code_review#%E4%B8%80%E8%87%B4%E6%80%A7) +* [其他建议](/docs/about/contribute/code_review#%E5%85%B6%E4%BB%96%E5%BB%BA%E8%AE%AE) + * [深思 API ](/docs/about/contribute/code_review#%E6%B7%B1%E6%80%9D-api-%E4%B8%8E%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E8%AE%BE%E8%AE%A1)[与](/docs/about/contribute/code_review#%E6%B7%B1%E6%80%9D-api-%E4%B8%8E%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E8%AE%BE%E8%AE%A1)[数据结构设计](/docs/about/contribute/code_review#%E6%B7%B1%E6%80%9D-api-%E4%B8%8E%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E8%AE%BE%E8%AE%A1) + * [最小化依赖](/docs/about/contribute/code_review#%E6%9C%80%E5%B0%8F%E5%8C%96%E4%BE%9D%E8%B5%96) + * [简洁实现](/docs/about/contribute/code_review#%E7%AE%80%E6%B4%81%E5%AE%9E%E7%8E%B0) + * [在代码审阅中记录经验教训](/docs/about/contribute/code_review#%E5%9C%A8%E4%BB%A3%E7%A0%81%E5%AE%A1%E9%98%85%E4%B8%AD%E8%AE%B0%E5%BD%95%E7%BB%8F%E9%AA%8C%E6%95%99%E8%AE%AD) + * [学习其他人的代码审阅](/docs/about/contribute/code_review#%E5%AD%A6%E4%B9%A0%E5%85%B6%E4%BB%96%E4%BA%BA%E7%9A%84%E4%BB%A3%E7%A0%81%E5%AE%A1%E9%98%85) + * [明确批准或请求更改](/docs/about/contribute/code_review#%E6%98%8E%E7%A1%AE%E6%89%B9%E5%87%86%E6%88%96%E8%AF%B7%E6%B1%82%E6%9B%B4%E6%94%B9) + * [审阅者职责](/docs/about/contribute/code_review#%E5%AE%A1%E9%98%85%E8%80%85%E8%81%8C%E8%B4%A3) 开源代码是由背景、兴趣、目标多样的社区成员共同维护的。因此,提供清晰、文档齐全、易维护的代码和流程非常重要。代码评审是一种协作过程,旨在集体发现潜在问题、提升代码质量,同时让贡献者与评审者深入了解代码库及其设计假设。它也是保证多个开发者可以共同维护某一部分代码的机制之一。我们鼓励贡献者在请求评审之前将代码打磨到可评审的状态。对于候选提交者(committer)来说尤其重要,因为提交者不仅要写代码,还要参与评审工作。 -本文档是关于开源代码评审的活动文档。建议同时阅读 [TVM 社区指南](https://tvm.apache.org/docs/contribute/community.html#community-guide) 了解通用的开发流程。 +本文档是关于开源代码评审的活动文档。建议同时阅读 [TVM 社区指南](/docs/about/contribute/TVM-Community-community/) 了解通用的开发流程。 ## 建立信任 @@ -80,7 +80,7 @@ title: 代码审查 相较于其他方面,代码可读性是一个相对主观的问题。每个人对「怎样写出好的代码」都有不同的看法。评审者应提供具有建设性和可操作性的意见。但代码审阅不应变成强迫别人照你那样写代码的过程。相反,你也应意识到你觉得没问题的内容,可能并不适合更广泛的社区。应根据代码的内容、贡献的范围以及贡献者的背景,合理判断什么是合适的。 -我们在编写代码时遵循通用的[代码指南与技巧](https://tvm.apache.org/docs/contribute/code_guide.html#code-guide)。风格指南的目的是确保代码在原作者离开后依然具有可读性与可维护性。风格不仅仅是格式,还包括如何撰写文档、变量命名以及其他格式器无法自动强制执行的约定。 +我们在编写代码时遵循通用的[代码指南与技巧](/docs/about/contribute/code_guide_and_Tips)。风格指南的目的是确保代码在原作者离开后依然具有可读性与可维护性。风格不仅仅是格式,还包括如何撰写文档、变量命名以及其他格式器无法自动强制执行的约定。 ## 达成共识 @@ -129,7 +129,7 @@ title: 代码审查 ### 在代码审阅中记录经验教训 -如果你发现某些问题是反复出现的、具有共性的,可以将其总结并添加到[代码指南与技巧](https://tvm.apache.org/docs/contribute/code_guide.html#code-guide)。在要求改动时引用该文档,有助于将经验传达给整个社区。 +如果你发现某些问题是反复出现的、具有共性的,可以将其总结并添加到[代码指南与技巧](/docs/about/contribute/code_guide_and_Tips)。在要求改动时引用该文档,有助于将经验传达给整个社区。 ### diff --git a/docs/05-about/01-contribute/04-committer_guide.md b/docs/05-about/01-contribute/04-committer_guide.md index a7cfbc4..cad6503 100644 --- a/docs/05-about/01-contribute/04-committer_guide.md +++ b/docs/05-about/01-contribute/04-committer_guide.md @@ -4,15 +4,15 @@ title: 提交者指南 --- -* [社区优先](https://tvm.apache.org/docs/contribute/committer_guide.html#community-first) -* [公开归档原则](https://tvm.apache.org/docs/contribute/committer_guide.html#public-archive-principle) -* [独立项目管理](https://tvm.apache.org/docs/contribute/committer_guide.html#independent-project-management) -* [指导 Pull Request(PR)](https://tvm.apache.org/docs/contribute/committer_guide.html#shepherd-a-pull-request) -* [时间管理](https://tvm.apache.org/docs/contribute/committer_guide.html#time-management) -* [广泛协作](https://tvm.apache.org/docs/contribute/committer_guide.html#broad-collaboration) +* [社区优先](/docs/about/contribute/committer_guide#%E7%A4%BE%E5%8C%BA%E4%BC%98%E5%85%88) +* [公开归档原则](/docs/about/contribute/committer_guide#%E5%85%AC%E5%BC%80%E5%BD%92%E6%A1%A3%E5%8E%9F%E5%88%99) +* [独立项目管理](/docs/about/contribute/committer_guide#%E7%8B%AC%E7%AB%8B%E9%A1%B9%E7%9B%AE%E7%AE%A1%E7%90%86) +* [指导 Pull Request(PR)](/docs/about/contribute/committer_guide#%E6%8C%87%E5%AF%BC-pull-requestpr) +* [时间管理](/docs/about/contribute/committer_guide#%E6%97%B6%E9%97%B4%E7%AE%A1%E7%90%86) +* [广泛协作](/docs/about/contribute/committer_guide#%E5%B9%BF%E6%B3%9B%E5%8D%8F%E4%BD%9C) -本指南是一个不断发展的文档,旨在为提交者(Committer)提供一些实用的建议。大多数内容都源自开发过程中的经验教训。我们欢迎每一位提交者为本文档作出贡献。有关提交者职责和开发流程的总体概览,请参阅 [TVM 社区指南](https://tvm.apache.org/docs/contribute/community.html#community-guide)。 +本指南是一个不断发展的文档,旨在为提交者(Committer)提供一些实用的建议。大多数内容都源自开发过程中的经验教训。我们欢迎每一位提交者为本文档作出贡献。有关提交者职责和开发流程的总体概览,请参阅 [TVM 社区指南](/docs/about/contribute/TVM-Community-community)。 ## 社区优先 @@ -43,7 +43,7 @@ title: 提交者指南 ## 指导 Pull Request(PR) -以下是一些帮助你指导 PR 的建议。你也可以参考 [代码审查指南](https://tvm.apache.org/docs/contribute/code_review.html#code-review-guide)。 +以下是一些帮助你指导 PR 的建议。你也可以参考 [代码审查指南](/docs/about/contribute/code_review)。 * 将 PR 分配给自己,让其他提交者知道该 PR 已经在处理。 * 使用状态标签表示当前处理进度。 * 检查是否需要提交 RFC。 diff --git a/docs/05-about/01-contribute/05-documentation.md b/docs/05-about/01-contribute/05-documentation.md index 38e2c41..55fc8d5 100644 --- a/docs/05-about/01-contribute/05-documentation.md +++ b/docs/05-about/01-contribute/05-documentation.md @@ -4,18 +4,18 @@ title: 文档 --- -* [四种文档类型](https://tvm.apache.org/docs/contribute/document.html#the-four-document-types) - * [入门教程](https://tvm.apache.org/docs/contribute/document.html#introductory-tutorials) - * [操作指南](https://tvm.apache.org/docs/contribute/document.html#how-to-guides) - * [参考手册](https://tvm.apache.org/docs/contribute/document.html#reference) - * [架构指南](https://tvm.apache.org/docs/contribute/document.html#architecture-guides) - * [TVM 的特殊注意事项](https://tvm.apache.org/docs/contribute/document.html#special-considerations-for-tvm) -* [技术细节](https://tvm.apache.org/docs/contribute/document.html#technical-details) - * [Python 参考文档](https://tvm.apache.org/docs/contribute/document.html#python-reference-documentation) - * [C++ 参考文档](https://tvm.apache.org/docs/contribute/document.html#c-reference-documentation) - * [Sphinx Gallery 操作指南](https://tvm.apache.org/docs/contribute/document.html#sphinx-gallery-how-tos) - * [文档内部引用](https://tvm.apache.org/docs/contribute/document.html#refer-to-another-location-in-the-document) - * [含图像/图表的文档](https://tvm.apache.org/docs/contribute/document.html#documents-with-images-figures) +* [四种文档类型](/docs/about/contribute/documentation#%E5%9B%9B%E7%A7%8D%E6%96%87%E6%A1%A3%E7%B1%BB%E5%9E%8B) + * [入门教程](/docs/about/contribute/documentation#%E5%85%A5%E9%97%A8%E6%95%99%E7%A8%8B) + * [操作指南](/docs/about/contribute/documentation#%E6%93%8D%E4%BD%9C%E6%8C%87%E5%8D%97) + * [参考手册](/docs/about/contribute/documentation#%E5%8F%82%E8%80%83%E6%89%8B%E5%86%8C) + * [架构指南](/docs/about/contribute/documentation#%E6%9E%B6%E6%9E%84%E6%8C%87%E5%8D%97) + * [TVM 的特殊注意事项](/docs/about/contribute/documentation#tvm-%E7%9A%84%E7%89%B9%E6%AE%8A%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9) +* [技术细节](/docs/about/contribute/documentation#%E6%8A%80%E6%9C%AF%E7%BB%86%E8%8A%82) + * [Python 参考文档](/docs/about/contribute/documentation#python-%E5%8F%82%E8%80%83%E6%96%87%E6%A1%A3) + * [C++ 参考文档](/docs/about/contribute/documentation#c-%E5%8F%82%E8%80%83%E6%96%87%E6%A1%A3) + * [Sphinx Gallery 操作指南](/docs/about/contribute/documentation#sphinx-gallery-%E6%93%8D%E4%BD%9C%E6%8C%87%E5%8D%97) + * [文档内部引用](/docs/about/contribute/documentation#%E6%96%87%E6%A1%A3%E5%86%85%E9%83%A8%E5%BC%95%E7%94%A8) + * [含图像/图表的文档](/docs/about/contribute/documentation#%E5%90%AB%E5%9B%BE%E7%89%87%E5%9B%BE%E8%A1%A8%E7%9A%84%E6%96%87%E6%A1%A3) TVM 文档大致遵循 [Divio 提出的正式文档风格](https://documentation.divio.com/)。选择这一体系是因为它「简单、全面且几乎普适。经过广泛领域和实践验证,具有极高的实用性。」 diff --git a/docs/05-about/01-contribute/06-code_guide_and_Tips.md b/docs/05-about/01-contribute/06-code_guide_and_Tips.md index 769d27d..bdaa0eb 100644 --- a/docs/05-about/01-contribute/06-code_guide_and_Tips.md +++ b/docs/05-about/01-contribute/06-code_guide_and_Tips.md @@ -4,11 +4,11 @@ title: 代码指南和提示 --- -* [C++ 代码风格](https://tvm.apache.org/docs/contribute/code_guide.html#c-code-styles) -* [Python 代码风格](https://tvm.apache.org/docs/contribute/code_guide.html#python-code-styles) -* [编写 Python 测试](https://tvm.apache.org/docs/contribute/code_guide.html#writing-python-tests) -* [网络](https://tvm.apache.org/docs/contribute/code_guide.html#network-resources)[资源](https://tvm.apache.org/docs/contribute/code_guide.html#network-resources) -* 整型常量表达式处理 +* [C++ 代码风格](/docs/about/contribute/code_guide_and_Tips#c-%E4%BB%A3%E7%A0%81%E9%A3%8E%E6%A0%BC) +* [Python 代码风格](/docs/about/contribute/code_guide_and_Tips#python-%E4%BB%A3%E7%A0%81%E6%A0%B7%E5%BC%8F) +* [编写 Python 测试](/docs/about/contribute/code_guide_and_Tips#%E7%BC%96%E5%86%99-python-%E6%B5%8B%E8%AF%95) +* [网络](/docs/about/contribute/code_guide_and_Tips#%E7%BD%91%E7%BB%9C%E8%B5%84%E6%BA%90%E5%A4%84%E7%90%86)[资源](/docs/about/contribute/code_guide_and_Tips#%E7%BD%91%E7%BB%9C%E8%B5%84%E6%BA%90%E5%A4%84%E7%90%86) +* [整型常量表达式处理](/docs/about/contribute/code_guide_and_Tips#%E6%95%B4%E5%9E%8B%E5%B8%B8%E9%87%8F%E8%A1%A8%E8%BE%BE%E5%BC%8F%E5%A4%84%E7%90%86) 本文档记录 TVM 代码库中供评审者和贡献者参考的实用技巧,多数内容源自贡献过程中的经验总结。 diff --git a/docs/05-about/01-contribute/07-Git_Usage_Tips.md b/docs/05-about/01-contribute/07-Git_Usage_Tips.md index 2863541..1513803 100644 --- a/docs/05-about/01-contribute/07-Git_Usage_Tips.md +++ b/docs/05-about/01-contribute/07-Git_Usage_Tips.md @@ -4,12 +4,12 @@ title: Git 使用技巧 --- -* [如何解决与](https://tvm.apache.org/docs/contribute/git_howto.html#how-to-resolve-a-conflict-with-main) `main`[ 分支的冲突](https://tvm.apache.org/docs/contribute/git_howto.html#how-to-resolve-a-conflict-with-main) -* [如何合并多个提交](https://tvm.apache.org/docs/contribute/git_howto.html#how-to-combine-multiple-commits-into-one) -* [重置到最新的 main 分支](https://tvm.apache.org/docs/contribute/git_howto.html#reset-to-the-most-recent-main-branch) -* [恢复重置前的提交](https://tvm.apache.org/docs/contribute/git_howto.html#recover-a-previous-commit-after-reset) -* [仅将最新的 k 个提交到 main 分支](https://tvm.apache.org/docs/contribute/git_howto.html#apply-only-k-latest-commits-on-to-the-main) -* [强制推送的后果](https://tvm.apache.org/docs/contribute/git_howto.html#what-is-the-consequence-of-force-push) +* [如何解决与 `main` 分支的冲突](/docs/about/contribute/Git_Usage_Tips#%E5%A6%82%E4%BD%95%E8%A7%A3%E5%86%B3%E4%B8%8Emain%E5%88%86%E6%94%AF%E7%9A%84%E5%86%B2%E7%AA%81) +* [如何合并多个提交](/docs/about/contribute/Git_Usage_Tips#%E5%A6%82%E4%BD%95%E5%90%88%E5%B9%B6%E5%A4%9A%E4%B8%AA%E6%8F%90%E4%BA%A4) +* [重置到最新的 main 分支](/docs/about/contribute/Git_Usage_Tips#%E9%87%8D%E7%BD%AE%E5%88%B0%E6%9C%80%E6%96%B0%E7%9A%84-main-%E5%88%86%E6%94%AF) +* [恢复重置前的提交](/docs/about/contribute/Git_Usage_Tips#%E6%81%A2%E5%A4%8D%E9%87%8D%E7%BD%AE%E5%89%8D%E7%9A%84%E6%8F%90%E4%BA%A4) +* [仅将最新的 k 个提交到 main 分支](/docs/about/contribute/Git_Usage_Tips#%E4%BB%85%E5%B0%86%E6%9C%80%E6%96%B0%E7%9A%84-k-%E4%B8%AA%E6%8F%90%E4%BA%A4%E5%88%B0-main-%E5%88%86%E6%94%AF) +* [强制推送的后果](/docs/about/contribute/Git_Usage_Tips#%E5%BC%BA%E5%88%B6%E6%8E%A8%E9%80%81%E7%9A%84%E5%90%8E%E6%9E%9C) diff --git a/docs/05-about/01-contribute/08-Using_TVM's_Ci.md b/docs/05-about/01-contribute/08-Using_TVM's_Ci.md index 18e269f..85ffa32 100644 --- a/docs/05-about/01-contribute/08-Using_TVM's_Ci.md +++ b/docs/05-about/01-contribute/08-Using_TVM's_Ci.md @@ -4,20 +4,20 @@ title: 使用 TVM 的 CI --- -* 贡献者指南 - * [调试失败](https://tvm.apache.org/docs/contribute/ci.html#debugging-failures) - * [Jenkins 日志](https://tvm.apache.org/docs/contribute/ci.html#jenkins-logs) - * [重现失败](https://tvm.apache.org/docs/contribute/ci.html#reproduce-failures) - * [报告问题](https://tvm.apache.org/docs/contribute/ci.html#reporting-issues) -* [维护者](https://tvm.apache.org/docs/contribute/ci.html#for-maintainers)[指南](https://tvm.apache.org/docs/contribute/ci.html#procedures-for-keeping-ci-green) - * [保持 CI 通过的常规操作](https://tvm.apache.org/docs/contribute/ci.html#procedures-for-keeping-ci-green) - * [同时合并导致的 CI 中断](https://tvm.apache.org/docs/contribute/ci.html#broken-ci-due-to-simultaneous-merge) - * [处理不稳定测试](https://tvm.apache.org/docs/contribute/ci.html#dealing-with-flakiness) - * [跳过 CI](https://tvm.apache.org/docs/contribute/ci.html#skipping-ci) - * [Docker 镜像](https://tvm.apache.org/docs/contribute/ci.html#docker-images) - * [更新 Docker 镜像标签](https://tvm.apache.org/docs/contribute/ci.html#updating-a-docker-image-tag) - * [添加新的 Docker 镜像](https://tvm.apache.org/docs/contribute/ci.html#adding-a-new-docker-image) - * [CI 监控轮值](https://tvm.apache.org/docs/contribute/ci.html#ci-monitoring-rotation) +* [贡献者指南](/docs/about/contribute/Using_TVM's_Ci#贡献者指南) + * [调试失败](/docs/about/contribute/Using_TVM's_Ci#调试失败) + * [Jenkins 日志](/docs/about/contribute/Using_TVM's_Ci#jenkins-%E6%97%A5%E5%BF%97) + * [重现失败](/docs/about/contribute/Using_TVM's_Ci#%E5%A4%8D%E7%8E%B0%E5%A4%B1%E8%B4%A5) + * [报告问题](/docs/about/contribute/Using_TVM's_Ci#%E6%8A%A5%E5%91%8A%E9%97%AE%E9%A2%98) +* [维护者指南](/docs/about/contribute/Using_TVM's_Ci#%E7%BB%B4%E6%8A%A4%E8%80%85%E6%8C%87%E5%8D%97) + * [保持 CI 通过的常规操作](/docs/about/contribute/Using_TVM's_Ci#%E4%BF%9D%E6%8C%81-ci-%E9%80%9A%E8%BF%87%E7%9A%84%E5%B8%B8%E8%A7%84%E6%93%8D%E4%BD%9C) + * [同时合并导致的 CI 中断](/docs/about/contribute/Using_TVM's_Ci#%E5%90%8C%E6%97%B6%E5%90%88%E5%B9%B6%E5%AF%BC%E8%87%B4%E7%9A%84-ci-%E4%B8%AD%E6%96%AD) + * [处理不稳定测试](/docs/about/contribute/Using_TVM's_Ci#%E5%A4%84%E7%90%86%E4%B8%8D%E7%A8%B3%E5%AE%9A%E6%B5%8B%E8%AF%95) + * [跳过 CI](/docs/about/contribute/Using_TVM's_Ci#%E8%B7%B3%E8%BF%87-ci) + * [Docker 镜像](/docs/about/contribute/Using_TVM's_Ci#docker-%E9%95%9C%E5%83%8F) + * [更新 Docker 镜像标签](/docs/about/contribute/Using_TVM's_Ci#%E6%9B%B4%E6%96%B0-docker-%E9%95%9C%E5%83%8F%E6%A0%87%E7%AD%BE) + * [添加新的 Docker 镜像](/docs/about/contribute/Using_TVM's_Ci#%E6%B7%BB%E5%8A%A0%E6%96%B0-docker-%E9%95%9C%E5%83%8F) + * [CI 监控轮值](/docs/about/contribute/Using_TVM's_Ci#ci-%E7%9B%91%E6%8E%A7%E8%BD%AE%E5%80%BC) @@ -47,7 +47,7 @@ TVM 主要使用 Jenkins 运行 Linux 持续集成(CI)测试,通过 [Jenkinsf #### 复现失败 -大多数 TVM Python 测试使用 `pytest` 运行,可按[测试指南](https://tvm.apache.org/docs/contribute/pull_request.html#pr-testing)操作复现。 +大多数 TVM Python 测试使用 `pytest` 运行,可按[测试指南](/docs/about/contribute/Submit_a_pull_request#%E6%B5%8B%E8%AF%95)操作复现。 ### 报告问题 @@ -182,3 +182,6 @@ Docker 镜像通过 [tvm-docker](https://ci.tlcpack.ai/job/tvm-docker/) 每晚 部分测试不稳定可能因与 PR 无关的原因失败。[CI 监控轮值](https://github.com/apache/tvm/wiki/CI-Monitoring-Runbook) 监视这些失败并按需禁用测试。测试作者有责任最终修复并重新启用测试。 + + + diff --git a/docs/05-about/01-contribute/09-Release_Process.md b/docs/05-about/01-contribute/09-Release_Process.md index f61e8fe..832e323 100644 --- a/docs/05-about/01-contribute/09-Release_Process.md +++ b/docs/05-about/01-contribute/09-Release_Process.md @@ -4,18 +4,18 @@ title: 发布流程 --- -* [准备发布说明](https://tvm.apache.org/docs/contribute/release_process.html#prepare-the-release-notes) -* [准备候选版本](https://tvm.apache.org/docs/contribute/release_process.html#prepare-the-release-candidate) -* [准备 GPG 密钥](https://tvm.apache.org/docs/contribute/release_process.html#prepare-the-gpg-key) -* [创建候选版本](https://tvm.apache.org/docs/contribute/release_process.html#cut-a-release-candidate) -* [在 main 上更新 TVM 版本](https://tvm.apache.org/docs/contribute/release_process.html#update-tvm-version-on-main) -* [上传候选版本](https://tvm.apache.org/docs/contribute/release_process.html#upload-the-release-candidate) -* [拣选提交](https://tvm.apache.org/docs/contribute/release_process.html#cherry-picking) -* [发起候选版本投票](https://tvm.apache.org/docs/contribute/release_process.html#call-a-vote-on-the-release-candidate) -* [完成发布](https://tvm.apache.org/docs/contribute/release_process.html#post-the-release) -* [更新 TVM 官网](https://tvm.apache.org/docs/contribute/release_process.html#update-the-tvm-website) -* [发布公告](https://tvm.apache.org/docs/contribute/release_process.html#post-the-announcement) -* [补丁发布](https://tvm.apache.org/docs/contribute/release_process.html#patch-releases) +* [准备发布说明](/docs/about/contribute/Release_Process#%E5%87%86%E5%A4%87%E5%8F%91%E5%B8%83%E8%AF%B4%E6%98%8E) +* [准备候选版本](/docs/about/contribute/Release_Process#%E5%87%86%E5%A4%87%E5%80%99%E9%80%89%E7%89%88%E6%9C%AC) +* [准备 GPG 密钥](/docs/about/contribute/Release_Process#%E5%87%86%E5%A4%87-gpg-%E5%AF%86%E9%92%A5) +* [创建候选版本](/docs/about/contribute/Release_Process#%E5%88%9B%E5%BB%BA%E5%80%99%E9%80%89%E7%89%88%E6%9C%AC%E5%88%86%E6%94%AF) +* [在 main 上更新 TVM 版本](/docs/about/contribute/Release_Process#%E5%9C%A8-main-%E4%B8%8A%E6%9B%B4%E6%96%B0-tvm-%E7%89%88%E6%9C%AC) +* [上传候选版本](/docs/about/contribute/Release_Process#%E4%B8%8A%E4%BC%A0%E5%80%99%E9%80%89%E7%89%88%E6%9C%AC) +* [拣选提交](/docs/about/contribute/Release_Process#%E6%8B%A3%E9%80%89%E6%8F%90%E4%BA%A4) +* [发起候选版本投票](/docs/about/contribute/Release_Process#%E5%8F%91%E8%B5%B7%E5%80%99%E9%80%89%E7%89%88%E6%9C%AC%E6%8A%95%E7%A5%A8) +* [完成发布](/docs/about/contribute/Release_Process#%E5%AE%8C%E6%88%90%E5%8F%91%E5%B8%83) +* [更新 TVM 官网](/docs/about/contribute/Release_Process#%E6%9B%B4%E6%96%B0-tvm-%E5%AE%98%E7%BD%91) +* [发布公告](/docs/about/contribute/Release_Process#%E5%8F%91%E5%B8%83%E5%85%AC%E5%91%8A) +* [补丁发布](/docs/about/contribute/Release_Process#%E8%A1%A5%E4%B8%81%E5%8F%91%E5%B8%83) TVM 项目的发布管理员需要负责以下工作内容: diff --git a/docs/05-about/01-contribute/index.md b/docs/05-about/01-contribute/index.md index f53400d..0b3a5d7 100644 --- a/docs/05-about/01-contribute/index.md +++ b/docs/05-about/01-contribute/index.md @@ -17,66 +17,66 @@ TVM 由社区成员共同开发,欢迎任何人参与贡献。我们重视各 以下是各方面贡献的指导: -* [TVM 社区准则](https://tvm.apache.org/docs/contribute/community.html) - * [通用开发流程](https://tvm.apache.org/docs/contribute/community.html#general-development-process) - * [策略决策流程](https://tvm.apache.org/docs/contribute/community.html#strategy-decision-process) - * [提交者 (Committers)](https://tvm.apache.org/docs/contribute/community.html#committers) - * [审阅者 (Reviewers)](https://tvm.apache.org/docs/contribute/community.html#reviewers) -* [提交 Pull Request](https://tvm.apache.org/docs/contribute/pull_request.html) - * [指南](https://tvm.apache.org/docs/contribute/pull_request.html#guidelines) - * [提交信息指南](https://tvm.apache.org/docs/contribute/pull_request.html#commit-message-guideline) - * [CI 环境](https://tvm.apache.org/docs/contribute/pull_request.html#ci-environment) - * [测试](https://tvm.apache.org/docs/contribute/pull_request.html#testing) -* [代码审查](https://tvm.apache.org/docs/contribute/code_review.html) - * [建立信任](https://tvm.apache.org/docs/contribute/code_review.html#building-trust) - * [社区参与](https://tvm.apache.org/docs/contribute/code_review.html#community-participation) - * [仔细阅读代码](https://tvm.apache.org/docs/contribute/code_review.html#read-the-code-carefully) - * [保持尊重](https://tvm.apache.org/docs/contribute/code_review.html#be-respectful) - * [代码质量考量因素](https://tvm.apache.org/docs/contribute/code_review.html#factors-to-consider-about-code-quality) - * [达成共识](https://tvm.apache.org/docs/contribute/code_review.html#consensus-building) - * [一致性](https://tvm.apache.org/docs/contribute/code_review.html#consistency) - * [其他建议](https://tvm.apache.org/docs/contribute/code_review.html#additional-recommendations) -* [提交者指南](https://tvm.apache.org/docs/contribute/committer_guide.html) - * [社区优先](https://tvm.apache.org/docs/contribute/committer_guide.html#community-first) - * [公开归档原则](https://tvm.apache.org/docs/contribute/committer_guide.html#public-archive-principle) - * [独立项目管理](https://tvm.apache.org/docs/contribute/committer_guide.html#independent-project-management) - * [指导 Pull Request](https://tvm.apache.org/docs/contribute/committer_guide.html#shepherd-a-pull-request) - * [时间管理](https://tvm.apache.org/docs/contribute/committer_guide.html#time-management) - * [广泛协作](https://tvm.apache.org/docs/contribute/committer_guide.html#broad-collaboration) -* [文档撰写](https://tvm.apache.org/docs/contribute/document.html) - * [四种文档类型](https://tvm.apache.org/docs/contribute/document.html#the-four-document-types) - * [技术细节](https://tvm.apache.org/docs/contribute/document.html#technical-details) -* [代码规范与技巧](https://tvm.apache.org/docs/contribute/code_guide.html) - * [C++ 代码风格](https://tvm.apache.org/docs/contribute/code_guide.html#c-code-styles) - * [Python 代码风格](https://tvm.apache.org/docs/contribute/code_guide.html#python-code-styles) - * [编写 Python 测试](https://tvm.apache.org/docs/contribute/code_guide.html#writing-python-tests) - * [网络资源](https://tvm.apache.org/docs/contribute/code_guide.html#network-resources) - * [整数常量表达式处理](https://tvm.apache.org/docs/contribute/code_guide.html#handle-integer-constant-expression) -* [Git 使用技巧](https://tvm.apache.org/docs/contribute/git_howto.html) - * [如何解决与 main 分支的冲突](https://tvm.apache.org/docs/contribute/git_howto.html#how-to-resolve-a-conflict-with-main) - * [如何合并多个提交](https://tvm.apache.org/docs/contribute/git_howto.html#how-to-combine-multiple-commits-into-one) - * [重置到最新的 main 分支](https://tvm.apache.org/docs/contribute/git_howto.html#reset-to-the-most-recent-main-branch) - * [恢复重置前的提交](https://tvm.apache.org/docs/contribute/git_howto.html#recover-a-previous-commit-after-reset) - * [仅将最新的 k 个提交到 main 分支](https://tvm.apache.org/docs/contribute/git_howto.html#apply-only-k-latest-commits-on-to-the-main) - * [强制推送的后果](https://tvm.apache.org/docs/contribute/git_howto.html#what-is-the-consequence-of-force-push) -* [使用 TVM 的 CI](https://tvm.apache.org/docs/contribute/ci.html) - * [贡献者指南](https://tvm.apache.org/docs/contribute/ci.html#for-contributors) - * [维护者指南](https://tvm.apache.org/docs/contribute/ci.html#for-maintainers) -* [发布流程](https://tvm.apache.org/docs/contribute/release_process.html) - * [准备发布说明](https://tvm.apache.org/docs/contribute/release_process.html#prepare-the-release-notes) - * [准备候选版本](https://tvm.apache.org/docs/contribute/release_process.html#prepare-the-release-candidate) - * [准备 GPG 密钥](https://tvm.apache.org/docs/contribute/release_process.html#prepare-the-gpg-key) - * [创建候选版本](https://tvm.apache.org/docs/contribute/release_process.html#cut-a-release-candidate) - * [在 main 上更新 TVM 版本](https://tvm.apache.org/docs/contribute/release_process.html#update-tvm-version-on-main) - * [上传发布候选版](https://tvm.apache.org/docs/contribute/release_process.html#upload-the-release-candidate) - * [拣选提交](https://tvm.apache.org/docs/contribute/release_process.html#cherry-picking) - * [发起候选版本投票](https://tvm.apache.org/docs/contribute/release_process.html#call-a-vote-on-the-release-candidate) - * [完成发布](https://tvm.apache.org/docs/contribute/release_process.html#post-the-release) - * [更新 TVM 网站](https://tvm.apache.org/docs/contribute/release_process.html#update-the-tvm-website) - * [发布公告](https://tvm.apache.org/docs/contribute/release_process.html#post-the-announcement) - * [补丁发布](https://tvm.apache.org/docs/contribute/release_process.html#patch-releases) -* [错误处理指南](https://tvm.apache.org/docs/contribute/error_handling.html) - * [在 C++ 中抛出特定错误](https://tvm.apache.org/docs/contribute/error_handling.html#raise-a-specific-error-in-c) - * [如何选择错误类型](https://tvm.apache.org/docs/contribute/error_handling.html#how-to-choose-an-error-type) +* [TVM 社区准则](/docs/about/contribute/TVM-Community-community) + * [通用开发流程](/docs/about/contribute/TVM-Community-community#%E9%80%9A%E7%94%A8%E5%BC%80%E5%8F%91%E6%B5%81%E7%A8%8B) + * [战略决策流程](/docs/about/contribute/TVM-Community-community#%E6%88%98%E7%95%A5%E5%86%B3%E7%AD%96%E6%B5%81%E7%A8%8B) + * [提交者](/docs/about/contribute/TVM-Community-community#%E6%8F%90%E4%BA%A4%E8%80%85) + * [审阅者](/docs/about/contribute/TVM-Community-community#%E5%AE%A1%E9%98%85%E8%80%85) +* [提交 Pull Request](/docs/about/contribute/Submit_a_pull_request) + * [指南](/docs/about/contribute/Submit_a_pull_request#%E6%8C%87%E5%8D%97) + * [提交信息指南](/docs/about/contribute/Submit_a_pull_request#%E6%8F%90%E4%BA%A4%E4%BF%A1%E6%81%AF%E6%8C%87%E5%8D%97) + * [持续集成(CI)环境](/docs/about/contribute/Submit_a_pull_request#ci-%E7%8E%AF%E5%A2%83) + * [测试](/docs/about/contribute/Submit_a_pull_request#ci-%E7%8E%AF%E5%A2%83) +* [代码审查](/docs/about/contribute/code_review) + * [建立信任](/docs/about/contribute/code_review#%E5%BB%BA%E7%AB%8B%E4%BF%A1%E4%BB%BB) + * [社区参与](/docs/about/contribute/code_review#%E7%A4%BE%E5%8C%BA%E5%8F%82%E4%B8%8Ecommunity-participation) + * [仔细阅读代码](/docs/about/contribute/code_review#%E8%AE%A4%E7%9C%9F%E9%98%85%E8%AF%BB%E4%BB%A3%E7%A0%81) + * [保持尊重](/docs/about/contribute/code_review#%E4%BF%9D%E6%8C%81%E5%B0%8A%E9%87%8D) + * [代码质量考量因素](/docs/about/contribute/code_review#%E4%BB%A3%E7%A0%81%E8%B4%A8%E9%87%8F%E8%80%83%E9%87%8F%E5%9B%A0%E7%B4%A0) + * [达成共识](/docs/about/contribute/code_review#%E8%BE%BE%E6%88%90%E5%85%B1%E8%AF%86) + * [一致性](/docs/about/contribute/code_review#%E4%B8%80%E8%87%B4%E6%80%A7) + * [其他建议](/docs/about/contribute/code_review#%E5%85%B6%E4%BB%96%E5%BB%BA%E8%AE%AE) +* [提交者指南](/docs/about/contribute/committer_guide) + * [社区优先](/docs/about/contribute/committer_guide#%E7%A4%BE%E5%8C%BA%E4%BC%98%E5%85%88) + * [公开归档原则](/docs/about/contribute/committer_guide#%E5%85%AC%E5%BC%80%E5%BD%92%E6%A1%A3%E5%8E%9F%E5%88%99) + * [独立项目管理](/docs/about/contribute/committer_guide#%E7%8B%AC%E7%AB%8B%E9%A1%B9%E7%9B%AE%E7%AE%A1%E7%90%86) + * [指导 Pull Request(PR)](/docs/about/contribute/committer_guide#%E6%8C%87%E5%AF%BC-pull-requestpr) + * [时间管理](/docs/about/contribute/committer_guide#%E6%97%B6%E9%97%B4%E7%AE%A1%E7%90%86) + * [广泛协作](/docs/about/contribute/committer_guide#%E5%B9%BF%E6%B3%9B%E5%8D%8F%E4%BD%9C) +* [文档撰写](/docs/about/contribute/documentation) + * [四种文档类型](/docs/about/contribute/documentation#%E5%9B%9B%E7%A7%8D%E6%96%87%E6%A1%A3%E7%B1%BB%E5%9E%8B) + * [技术细节](/docs/about/contribute/documentation#%E6%8A%80%E6%9C%AF%E7%BB%86%E8%8A%82) +* [代码规范与技巧](/docs/about/contribute/code_guide_and_Tips) + * [C++ 代码风格](/docs/about/contribute/code_guide_and_Tips#c-%E4%BB%A3%E7%A0%81%E9%A3%8E%E6%A0%BC) + * [Python 代码风格](/docs/about/contribute/code_guide_and_Tips#python-%E4%BB%A3%E7%A0%81%E6%A0%B7%E5%BC%8F) + * [编写 Python 测试](/docs/about/contribute/code_guide_and_Tips#%E7%BC%96%E5%86%99-python-%E6%B5%8B%E8%AF%95) + * [网络资源](/docs/about/contribute/code_guide_and_Tips#%E7%BD%91%E7%BB%9C%E8%B5%84%E6%BA%90%E5%A4%84%E7%90%86) + * [整型常量表达式处理](/docs/about/contribute/code_guide_and_Tips#%E6%95%B4%E5%9E%8B%E5%B8%B8%E9%87%8F%E8%A1%A8%E8%BE%BE%E5%BC%8F%E5%A4%84%E7%90%86) +* [Git 使用技巧](/docs/about/contribute/Git_Usage_Tips) + * [如何解决与 main 分支冲突](/docs/about/contribute/Git_Usage_Tips#%E5%A6%82%E4%BD%95%E8%A7%A3%E5%86%B3%E4%B8%8Emain%E5%88%86%E6%94%AF%E7%9A%84%E5%86%B2%E7%AA%81) + * [如何合并多个提交](/docs/about/contribute/Git_Usage_Tips#%E5%A6%82%E4%BD%95%E5%90%88%E5%B9%B6%E5%A4%9A%E4%B8%AA%E6%8F%90%E4%BA%A4) + * [重置到最新的 main 分支](/docs/about/contribute/Git_Usage_Tips#%E9%87%8D%E7%BD%AE%E5%88%B0%E6%9C%80%E6%96%B0%E7%9A%84-main-%E5%88%86%E6%94%AF) + * [恢复重置前的提交](/docs/about/contribute/Git_Usage_Tips#%E6%81%A2%E5%A4%8D%E9%87%8D%E7%BD%AE%E5%89%8D%E7%9A%84%E6%8F%90%E4%BA%A4) + * [仅将最新的 k 个提交到 main 分支](/docs/about/contribute/Git_Usage_Tips#%E4%BB%85%E5%B0%86%E6%9C%80%E6%96%B0%E7%9A%84-k-%E4%B8%AA%E6%8F%90%E4%BA%A4%E5%88%B0-main-%E5%88%86%E6%94%AF) + * [强制推送的后果](/docs/about/contribute/Git_Usage_Tips#%E5%BC%BA%E5%88%B6%E6%8E%A8%E9%80%81%E7%9A%84%E5%90%8E%E6%9E%9C) +* [使用 TVM 的 CI](/docs/about/contribute/Using_TVM's_Ci) + * [贡献者指南](/docs/about/contribute/Using_TVM's_Ci#%E8%B4%A1%E7%8C%AE%E8%80%85%E6%8C%87%E5%8D%97) + * [维护者指南](/docs/about/contribute/Using_TVM's_Ci#%E7%BB%B4%E6%8A%A4%E8%80%85%E6%8C%87%E5%8D%97) +* [发布流程](/docs/about/contribute/Release_Process) + * [准备发布说明](/docs/about/contribute/Release_Process#%E5%87%86%E5%A4%87%E5%8F%91%E5%B8%83%E8%AF%B4%E6%98%8E) + * [准备候选版本](/docs/about/contribute/Release_Process#%E5%87%86%E5%A4%87%E5%80%99%E9%80%89%E7%89%88%E6%9C%AC) + * [准备 GPG 密钥](/docs/about/contribute/Release_Process#%E5%87%86%E5%A4%87-gpg-%E5%AF%86%E9%92%A5) + * [创建候选版本](/docs/about/contribute/Release_Process#%E5%88%9B%E5%BB%BA%E5%80%99%E9%80%89%E7%89%88%E6%9C%AC%E5%88%86%E6%94%AF) + * [在 main 上更新 TVM 版本](/docs/about/contribute/Release_Process#%E5%9C%A8-main-%E4%B8%8A%E6%9B%B4%E6%96%B0-tvm-%E7%89%88%E6%9C%AC) + * [上传候选版本](/docs/about/contribute/Release_Process#%E4%B8%8A%E4%BC%A0%E5%80%99%E9%80%89%E7%89%88%E6%9C%AC) + * [拣选提交](/docs/about/contribute/Release_Process#%E6%8B%A3%E9%80%89%E6%8F%90%E4%BA%A4) + * [发起候选版本投票](/docs/about/contribute/Release_Process#%E5%8F%91%E8%B5%B7%E5%80%99%E9%80%89%E7%89%88%E6%9C%AC%E6%8A%95%E7%A5%A8) + * [完成发布](/docs/about/contribute/Release_Process#%E5%AE%8C%E6%88%90%E5%8F%91%E5%B8%83) + * [更新 TVM 官网](/docs/about/contribute/Release_Process#%E6%9B%B4%E6%96%B0-tvm-%E5%AE%98%E7%BD%91) + * [发布公告](/docs/about/contribute/Release_Process#%E5%8F%91%E5%B8%83%E5%85%AC%E5%91%8A) + * [补丁发布](/docs/about/contribute/Release_Process#%E8%A1%A5%E4%B8%81%E5%8F%91%E5%B8%83) +* [错误处理指南](/docs/about/contribute/error_handling-guide) + * [在 C++ 中抛出特定错误](/docs/about/contribute/error_handling-guide#%E5%9C%A8-c-%E4%B8%AD%E6%8A%9B%E5%87%BA%E7%89%B9%E5%AE%9A%E9%94%99%E8%AF%AF) + * [如何选择错误类型](/docs/about/contribute/error_handling-guide#%E5%A6%82%E4%BD%95%E9%80%89%E6%8B%A9%E9%94%99%E8%AF%AF%E7%B1%BB%E5%9E%8B) diff --git a/static/img/docs/v21/03-deep-dive-01-design-and-architecture-01-runtime-2.png b/static/img/docs/v21/03-deep-dive-01-design-and-architecture-01-runtime-2.png new file mode 100644 index 0000000..c2020e8 Binary files /dev/null and b/static/img/docs/v21/03-deep-dive-01-design-and-architecture-01-runtime-2.png differ diff --git a/static/img/docs/v21/03-deep-dive-01-design-and-architecture-01-runtime.png b/static/img/docs/v21/03-deep-dive-01-design-and-architecture-01-runtime.png new file mode 100644 index 0000000..82ac132 Binary files /dev/null and b/static/img/docs/v21/03-deep-dive-01-design-and-architecture-01-runtime.png differ