diff --git a/README_zh.md b/README_zh.md
index 4c3f4412..43f7972a 100644
--- a/README_zh.md
+++ b/README_zh.md
@@ -7,54 +7,64 @@
PTO(Parallel Tile Operation)是昇腾 CANN 定义的一套面向 tile 编程的虚拟 ISA。本仓库提供 PTO Tile 指令的实现、示例、测试与文档,帮助开发者在不同昇腾代际之间更平滑地迁移和优化算子。
[](LICENSE)
-[](#️-平台支持)
-[](docs/README_zh.md)
+[](#-平台支持)
+[](docs/README_zh.md)
-## 📰 新闻
+## 最新动态
-- 🎉 **2025-12-27**:PTO Tile Library 正式开源发布。
-- ✨ **2026-01-30**:新增合轴类指令、MX 指令。
-- 🚀 **2026-02-28**:新增卷积类指令、量化类指令、核间通信类指令。
-- 🔥 **2026-03-30**:支持昇腾 A5 芯片,新增异步通信指令、CostModel 性能仿真。
-- 🛠️ **2026-04-02**:本地工程链路进一步完善,补充了 pre-commit 检查、文档构建校验与 CPU-SIM 验证能力。
+- **2025-12-27**:PTO Tile Library 正式开源发布。
+- **2026-01-30**:新增归约类指令与 MX 指令。
+- **2026-02-28**:新增卷积类指令、量化类指令、核间通信类指令。
+- **2026-03-30**:支持昇腾 A5 芯片,新增异步通信指令与 CostModel 性能仿真。
+- **2026-04-02**:本地工程链路进一步完善,补充 pre-commit 检查、文档构建校验与 CPU-SIM 验证能力。
-## 🎯 项目定位
+## 项目定位
PTO ISA 基于昇腾底层硬件与软件抽象,定义 90+ 条标准 tile 指令,用更高层的 tile 编程模型桥接不同代际之间的实现差异。它的目标不是隐藏底层能力,而是在提升抽象层级的同时保留性能调优空间。
- **统一跨代 tile 抽象**:降低不同 Ascend 代际之间的迁移成本。
-- **兼顾可移植性与性能**:在固定 tile shape 下保证正确工作,同时保留 tile size、tile shape、指令顺序等调优能力。
-- **面向框架、算子与工具链**:可作为上层框架、算子实现和编译工具链的共同接口。
-- **支持持续扩展**:当前已定义 90+ 条标准操作,并持续补充实现与生态集成。
+- **兼顾可移植性与性能**:在固定 tile shape 下保证正确工作,同时保留 tile size、tile shape、指令顺序等调优空间。
+- **面向框架、算子与工具链**:作为上层框架、算子实现和编译工具链的共同接口。
+- **持续可扩展**:当前已定义 90+ 条标准操作,并持续补充实现与生态集成。
-除计算与数据搬运指令外,PTO ISA 还提供了面向 NPU 间数据传输与同步的**通信扩展指令集**,覆盖点对点通信、信号同步和集合通信三类能力。
+PTO 指令现已集成到以下框架中:
-这些通信原语延续了与计算指令一致的 tile 级抽象和跨平台设计,并可驱动昇腾上的多种数据搬移硬件引擎,帮助用户构建计算与通信深度融合的 kernel。通信 ISA 入口见 [docs/isa/comm/README_zh.md](docs/isa/comm/README_zh.md)。
+- [PyPTO](https://gitcode.com/cann/pypto/) — PTO 上层 Python 编程框架
+- [TileLang Ascend](https://github.com/tile-ai/tilelang-ascend/) — TileLang 昇腾后端
+- 更多语言与前端支持持续完善中
-目前,PTO 指令已集成到以下框架中:
-
-- [PyPTO](https://gitcode.com/cann/pypto/)
-- [TileLang Ascend](https://github.com/tile-ai/tilelang-ascend/)
-- 更多语言与前端持续完善中
-
-## ✨ 核心特性
+## 核心特性
- **统一的 Tile ISA 抽象**:用标准 PTO 指令描述 tile 级计算与数据流。
-- **跨代迁移与性能调优兼顾**:既提升可移植性,也保留足够的底层控制能力。
-- **Auto / Manual 双模式开发路径**:先快速验证逻辑,再逐步深入优化实现。当前 Auto Mode 主要可用于 CPU 仿真。
-- **CPU Simulator 支持**:支持在 CPU 上进行功能验证与开发调试。
-- **覆盖关键编程要素**:支持 tile shape、tile mask、事件同步、固定功能单元与流水线建模。
-- **文档、测试、示例齐全**:提供 ISA 文档、开发文档、测试脚本和性能案例。
+- **跨代迁移与性能调优兼顾**:既提升可移植性,也保留充足的底层控制能力。
+- **Auto / Manual 双模式开发路径**:先快速验证逻辑,再逐步深入优化。Auto Mode 目前可用于 CPU 仿真。
+- **CPU Simulator 支持**:无需 Ascend 硬件即可在 CPU 上进行功能验证与开发调试。
+- **覆盖关键编程要素**:tile shape、tile mask、事件同步、固定功能单元与流水线建模。
+- **文档、测试、示例齐全**:ISA 文档、开发文档、测试脚本和性能案例全面覆盖。
-## 👥 适用人群
+## 适用人群
-PTO Tile Lib 主要面向以下开发者:
+PTO Tile Library 主要面向以下开发者:
- 直接对接昇腾硬件的框架或编译器后端开发者
- 需要跨平台迁移与复用实现的高性能算子开发者
-- 需要显式控制 tile、buffer 与 pipeline 的性能优化工程师
+- 需要显式控制 tile、buffer 与流水线的性能优化工程师
+
+## Tile 指令 vs Vector 指令
+
+| 判断标准 | Tile 指令(`pto.t*`) | Vector 指令(`pto.v*`) |
+|----------|----------------------|------------------------|
+| **典型用途** | 密集张量代数、矩阵乘法、逐元素运算 | 细粒度向量流水线控制、lane 级 mask |
+| **数据搬运** | `TLOAD`/`TSTORE`(隐式 tile↔UB) | `copy_gm_to_ubuf` + `vlds`/`vsts` + `copy_ubuf_to_gm` |
+| **同步方式** | `TSYNC`、`set_flag`/`wait_flag` | `set_flag`/`wait_flag`(向量流水线)、`mem_bar` |
+| **布局控制** | 通过 tile 布局参数(`RowMajor`、`ColMajor`、分形布局) | 通过 distribution mode(`NORM`、`BRC`、`DS` 等) |
+| **谓词** | 无 lane 级 mask(有效区域是粗粒度的) | 每个操作都支持完整 lane 级谓词 mask |
+| **目标可移植性** | 所有 Profile(CPU、A2/A3、A5) | A5 硬件支持;CPU/A2/A3 为仿真 |
+| **抽象层级** | 高层 tile 语义、有效区域 | 低层向量寄存器、显式 UB 暂存 |
-## 🚀 快速开始
+> **经验法则:** 张量运算优先使用 tile 指令。只有在需要 lane 级 mask、自定义数据布局或 tile 指令无法表达的性能微调时,才降级到向量指令。
+
+## 快速开始
### 环境准备
@@ -65,7 +75,7 @@ PTO Tile Lib 主要面向以下开发者:
### 编译与运行
```bash
-# CPU Simulator(建议第一步)
+# CPU Simulator(推荐第一步)
python3 tests/run_cpu.py --clean --verbose
# 运行 GEMM demo
@@ -85,9 +95,9 @@ python3 tests/script/run_st.py -r sim -v a3 -t tadd -g TADDTest.case_float_64x64
### 推荐样例
-- [Auto Mode Add 示例](demos/auto_mode/baseline/add/README_zh.md):适合第一次了解 PTO 指令组织方式
-- [GEMM 性能示例](kernels/manual/a2a3/gemm_performance/README_zh.md):适合理解 tile 级算子优化
-- [Flash Attention 示例](kernels/manual/common/flash_atten/README_zh.md):适合理解复杂算子与性能调优
+- [Auto Mode Add 示例](demos/auto_mode/baseline/add/README_zh.md):了解 PTO 指令如何组织 tile 级计算与数据搬运
+- [GEMM 性能示例](kernels/manual/a2a3/gemm_performance/README_zh.md):理解 tile 级算子优化与性能调参
+- [Flash Attention 示例](kernels/manual/common/flash_atten/README_zh.md):理解复杂算子与性能调优
### 推荐上手路径
@@ -96,30 +106,36 @@ python3 tests/script/run_st.py -r sim -v a3 -t tadd -g TADDTest.case_float_64x64
3. 将代码移植到昇腾硬件上验证正确性并采集性能数据。参见 [msprof 工具](https://www.hiascend.com/document/detail/zh/canncommercial/850/devaids/Profiling/atlasprofiling_16_0010.html)
4. 定位性能瓶颈(CUBE Bound / MTE Bound / Vector Bound),开始优化与调参。参见 [性能优化](docs/coding/opt_zh.md)
-本仓库也展示了标准 tile 操作如何通过模板参数映射到不同流水线实现:
+本仓库展示了标准 tile 操作如何通过模板参数映射到不同流水线实现:
- [Tile 编程模型](docs/coding/Tile_zh.md):理解静态 tile shape、动态 tile mask 与数据组织方式
- [事件与同步](docs/coding/Event_zh.md):理解 set/wait flag 与流水线同步
+- [Auto Mode](docs/auto_mode/Auto_Mode_Overview_zh.md):编译器自动管理资源绑定与同步插入
- [通用约定](docs/isa/conventions_zh.md):理解 PTO 编程中的通用规则与约束
-- [PTO 指令列表](docs/isa/README_zh.md):查看 PTO ISA 已定义的标准操作
+- [PTO 指令列表](docs/isa/README_zh.md):按分类查看 PTO ISA 已定义的标准操作
-## 🗂️ 文档导航
+## 文档导航
### ISA 与编程模型
-- [ISA 总览](docs/README_zh.md):PTO ISA 文档入口与阅读导航
-- [PTO 指令列表](docs/isa/README_zh.md):按指令分类查看 PTO 标准操作
-- [Tile 编程模型](docs/coding/Tile_zh.md):理解 tile 的形状、mask 与编程模型
-- [事件与同步](docs/coding/Event_zh.md):理解事件记录、等待与同步方式
-- [通用约定](docs/isa/conventions_zh.md):查看命名、约束与通用规则
+| 文档 | 内容 |
+|------|------|
+| [ISA 总览](docs/README_zh.md) | PTO ISA 文档入口与阅读导航 |
+| [PTO 指令列表](docs/isa/README_zh.md) | 按指令分类查看 PTO 标准操作 |
+| [Tile 编程模型](docs/coding/Tile_zh.md) | tile 的形状、mask 与编程模型 |
+| [事件与同步](docs/coding/Event_zh.md) | 事件记录、等待与同步方式 |
+| [通用约定](docs/isa/conventions_zh.md) | 命名、约束与通用规则 |
+| [Auto Mode](docs/auto_mode/Auto_Mode_Overview_zh.md) | 编译器驱动的资源管理与同步 |
### 开发与优化
-- [开发文档索引](docs/coding/README_zh.md):查看扩展 PTO Tile Lib 的开发文档
-- [性能优化](docs/coding/opt_zh.md):查看性能分析与调优建议
-- [文档构建说明](docs/mkdocs/README_zh.md):查看 MkDocs 文档的本地构建方式
+| 文档 | 内容 |
+|------|------|
+| [开发文档索引](docs/coding/README_zh.md) | 扩展 PTO Tile Library 的开发文档入口 |
+| [性能优化](docs/coding/opt_zh.md) | 性能分析与调优建议 |
+| [文档构建说明](docs/mkdocs/README_zh.md) | MkDocs 文档的本地构建方式 |
-## 📊 示例与性能参考
+## 性能参考
### GEMM
@@ -137,21 +153,7 @@ python3 tests/script/run_st.py -r sim -v a3 -t tadd -g TADDTest.case_float_64x64

-### 通信指令带宽
-
-- 参考实现:`kernels/manual/a2a3/tget_bandwidth/`
-- 详细分析与构建运行说明:[TGET / TGET_ASYNC 带宽对比示例](kernels/manual/a2a3/tget_bandwidth/README_zh.md)
-
-该示例在 Ascend A2/A3 上测量点对点远程读带宽,对比 `TGET`(同步,经 UB 中转)与 `TGET_ASYNC`(异步,经 DMA 引擎直接传输)的表现。
-
-### GEMM AllReduce 通算融合
-
-- 参考实现:`kernels/manual/a2a3/gemm_ar/`
-- 详细分析与调参说明:[高性能 GEMM AllReduce 融合算子示例](kernels/manual/a2a3/gemm_ar/README_zh.md)
-
-该示例展示了如何在同一个算子流水线中融合 PTO 通信原语与计算 kernel,实现 GEMM 与 AllReduce 的重叠执行。
-
-## 🖥️ 平台支持
+## 平台支持
- Ascend A2(Ascend 910B)
- Ascend A3(Ascend 910C)
@@ -160,56 +162,62 @@ python3 tests/script/run_st.py -r sim -v a3 -t tadd -g TADDTest.case_float_64x64
更多细节请参考 [include/README_zh.md](include/README_zh.md)。
-## 🛣️ 路线图
-
-未来计划发布的特性:
+## 路线图
| 功能 | 描述 | 范围 |
| --- | --- | --- |
| PTO Auto Mode | BiSheng 编译器支持:自动分配 tile buffer 并插入同步。 | 编译器 / 工具链 |
| PTO Tile Fusion | BiSheng 编译器支持:自动融合 tile 操作。 | 编译器 / 工具链 |
-| PTO-AS | PTO ISA 的字节码(Byte Code)支持。 | 编译器 / 工具链 |
+| PTO-AS | PTO ISA 的字节码支持。 | 编译器 / 工具链 |
| **卷积扩展** | PTO ISA 对卷积 kernel 的支持。 | ISA 扩展 |
| **集合通信扩展** | PTO ISA 对集合通信 kernel 的支持。 | ISA 扩展 |
| **系统调度扩展** | PTO ISA 对 SPMD/MPMD 编程的调度支持。 | ISA 扩展 |
-## 🗃️ 目录结构
-
-关键目录如下:
+## 目录结构
-```text
+```
+PTO Tile Library
├── include/ # PTO 对外头文件与接口
-│ └── pto/ # 公共类型、ISA 接口、CPU/NPU 实现
-├── kernels/ # kernel 与算子实现
-│ ├── manual/ # 手工优化实现与性能示例
-│ └── custom/ # 自定义算子示例
-├── docs/ # ISA、编程模型、快速开始与文档站点源文件
-│ ├── isa/ # 指令参考与分类索引
-│ ├── coding/ # 开发与性能优化文档
-│ ├── assembly/ # PTO-AS 汇编语法与规范
-│ └── mkdocs/ # MkDocs 文档构建配置与源文件
-├── demos/ # Auto Mode、baseline 与 torch_jit 示例
-├── tests/ # CPU / NPU 测试、脚本与测试入口
-│ ├── cpu/ # CPU 仿真测试
-│ ├── npu/ # 按 SoC 拆分的 NPU 测试
-│ └── script/ # 测试构建与运行脚本
-├── scripts/ # 构建、安装与发布脚本
-├── cmake/ # CMake 公共配置与打包逻辑
-├── build.sh # 一键构建与运行入口脚本
-└── CMakeLists.txt # 顶层 CMake 配置
+│ └── pto/ # 公共类型、ISA 接口、CPU/NPU 实现
+│ ├── common/ # 平台无关的 Tile 与指令基础设施
+│ ├── cpu/ # CPU 侧仿真支持
+│ └── npu/ # NPU 侧实现(按 SoC 代际划分)
+│ ├── a2a3/ # Ascend A2/A3 系列
+│ └── a5/ # Ascend A5 系列
+├── kernels/ # kernel 与算子实现
+│ ├── manual/ # 手工优化实现与性能示例
+│ │ ├── a2a3/ # A2/A3 平台 kernels(GEMM、Conv2D、TopK)
+│ │ ├── a5/ # A5 平台 kernels(Flash Attention、MXFP4/8 Matmul)
+│ │ └── common/ # 跨平台 kernels(Flash Attention)
+│ └── custom/ # 自定义算子脚手架
+├── demos/ # Auto Mode、baseline 与 torch_jit 示例
+├── docs/ # ISA、编程模型、快速开始与文档站点源文件
+│ ├── isa/ # 指令参考与分类索引
+│ ├── coding/ # 开发与性能优化文档
+│ ├── assembly/ # PTO-AS 汇编语法与规范
+│ ├── auto_mode/ # Auto Mode 文档
+│ └── mkdocs/ # MkDocs 文档构建配置与源文件
+├── tests/ # CPU / NPU 测试、脚本与测试入口
+│ ├── cpu/ # CPU 仿真测试
+│ ├── npu/ # 按 SoC 拆分的 NPU 测试
+│ └── script/ # 测试构建与运行脚本
+├── scripts/ # 构建、安装与发布脚本
+├── cmake/ # CMake 公共配置与打包逻辑
+├── build.sh # 一键构建与运行入口脚本
+└── CMakeLists.txt # 顶层 CMake 配置
```
-## ℹ️ 相关信息
+## 相关信息
- [贡献指南](CONTRIBUTING_zh.md):参与项目开发与提交流程
- [安全与漏洞披露](SECURITY_zh.md):安全问题反馈流程
- [版本说明](ReleaseNote_zh.md):版本更新与发布记录
- [许可证](LICENSE):CANN Open Software License Agreement Version 2.0
-- [PyPTO](https://gitcode.com/cann/pypto/):PTO 生态中的上层编程框架
+- [PyPTO](https://gitcode.com/cann/pypto/):PTO 生态中的上层 Python 编程框架
- [PTOAS](https://gitcode.com/cann/PTOAS/):面向 PTO 工作流的汇编器与编译后端
- [pto-dsl](https://gitcode.com/cann/pto-dsl/):面向 PTO 的 Python 前端与 JIT 工作流探索
-## 📬 联系我们
+## 联系我们
- **问题反馈**:通过仓库 Issues 提交问题
- **功能建议**:通过仓库 Issues 或讨论区反馈需求
diff --git a/demos/README.md b/demos/README.md
index 435c41ad..f6830096 100644
--- a/demos/README.md
+++ b/demos/README.md
@@ -2,19 +2,35 @@
This directory contains demonstration examples showing how to use PTO Tile Library in different scenarios.
+## Choose by Task
+
+| Your goal | Start here |
+|-----------|-----------|
+| Verify algorithms quickly (no hardware needed) | CPU simulation demos — `tests/run_cpu.py --demo` |
+| Learn PTO tile programming | CPU demos — `flash_attn` or `gemm` |
+| Production NPU operators | `baseline/` — full examples with PyTorch integration |
+| Just-in-time compilation and debugging | `torch_jit/` — JIT compilation examples |
+| Auto Mode | `auto_mode/baseline/add/` — Auto Mode example |
+
## Directory Structure
```
demos/
-├── baseline/ # Production PyTorch operator examples (NPU)
-│ ├── add/ # Basic element-wise addition
-│ ├── gemm_basic/ # GEMM with pipeline optimization
-│ └── flash_atten/ # Flash Attention with dynamic tiling
-├── cpu/ # CPU simulation demos (cross-platform)
+├── baseline/ # Production-grade PyTorch operator examples (NPU)
+│ ├── add/ # Element-wise addition
+│ ├── gemm_basic/ # GEMM with pipeline optimization
+│ ├── flash_atten/ # Flash Attention with dynamic tiling
+│ └── allgather_async/ # Asynchronous AllGather
+│
+├── auto_mode/ # Auto Mode examples (CPU / NPU compatible)
+│ └── baseline/add/ # Auto Mode element-wise addition
+│
+├── cpu/ # CPU simulation demos (cross-platform, no Ascend hardware)
│ ├── gemm_demo/
│ ├── flash_attention_demo/
│ └── mla_attention_demo/
-└── torch_jit/ # PyTorch JIT compilation examples
+│
+└── torch_jit/ # PyTorch JIT compilation examples
├── add/
├── gemm/
└── flash_atten/
@@ -28,15 +44,25 @@ Production-ready examples showing how to implement custom PTO kernels and expose
**Supported Platforms**: A2/A3/A5
-**Examples**: Element-wise addition, GEMM with double-buffering pipeline, Flash Attention with automatic tile size selection.
+**Examples**:
+- Element-wise addition — the most basic PTO operator example
+- GEMM — matrix multiplication with double-buffering pipeline
+- Flash Attention — with automatic tile size selection
+- AllGather-Async — asynchronous AllGather communication
### 2. CPU Simulation (`cpu/`)
Cross-platform examples that run on CPU (x86_64/AArch64) without requiring Ascend hardware. Ideal for algorithm prototyping, learning PTO programming model, and CI/CD testing.
-**Examples**: Basic GEMM, Flash Attention, Multi-Latent Attention.
+**Examples**: Basic GEMM, Flash Attention, Multi-Latent Attention (MLA)
+
+### 3. Auto Mode (`auto_mode/`)
-### 3. PyTorch JIT (`torch_jit/`)
+Examples showcasing PTO AUTO mode. In Auto mode, the compiler automatically manages tile buffer address allocation and pipeline synchronization — no manual `TASSIGN` or `set_flag`/`wait_flag` needed.
+
+**Examples**: Auto Mode element-wise addition
+
+### 4. PyTorch JIT (`torch_jit/`)
Examples showing on-the-fly C++ compilation and direct integration with PyTorch tensors. Useful for rapid prototyping without pre-building wheels.
@@ -63,6 +89,13 @@ pip install dist/*.whl
cd test && python3 test.py
```
+### Auto Mode Example
+
+```bash
+cd demos/auto_mode/baseline/add
+# See the README inside for build and run instructions
+```
+
### JIT Example
```bash
@@ -74,24 +107,21 @@ python add_compile_and_run.py
## Prerequisites
**For Baseline and JIT (NPU)**:
-- Ascend AI Processor A2/A3/A5(910B/910C/950)
+- Ascend AI Processor A2/A3/A5 (910B/910C/950)
- CANN Toolkit 8.5.0+
- PyTorch with `torch_npu`
- Python 3.8+, CMake 3.16+
**For CPU Demos**:
-- C++ compiler with C++23 support
+- C++ compiler with C++20 support
- CMake 3.16+
- Python 3.8+ (optional)
-## Documentation
-
-- Getting Started: [docs/getting-started.md](../docs/getting-started.md)
-- Programming Tutorial: [docs/coding/tutorial.md](../docs/coding/tutorial.md)
-- ISA Reference: [docs/isa/README.md](../docs/isa/README.md)
-
-## Related
+## Related Documents
-- Manual Kernels: [kernels/manual/README.md](../kernels/manual/README.md)
-- Custom Operators: [kernels/custom/README.md](../kernels/custom/README.md)
-- Test Cases: [tests/README.md](../tests/README.md)
+| Document | Content |
+|----------|---------|
+| [demos/README_zh.md](./README_zh.md) | 中文版入口 |
+| [docs/getting-started.md](../docs/getting-started.md) | Getting started guide |
+| [docs/coding/tutorial.md](../docs/coding/tutorial.md) | Programming tutorial |
+| [docs/isa/README.md](../docs/isa/README.md) | ISA reference |
diff --git a/demos/README_zh.md b/demos/README_zh.md
index ebdf32f0..4d18766b 100644
--- a/demos/README_zh.md
+++ b/demos/README_zh.md
@@ -1,97 +1,127 @@
-# PTO 演示示例
-
-本目录包含演示示例,展示如何在不同场景中使用 PTO Tile Library。
-
-## 目录结构
-
-```
-demos/
-├── baseline/ # 生产级 PyTorch 算子示例(NPU)
-│ ├── add/ # 基础逐元素加法
-│ ├── gemm_basic/ # 带流水线优化的 GEMM
-│ └── flash_atten/ # 带动态分块的 Flash Attention
-├── cpu/ # CPU 模拟演示(跨平台)
-│ ├── gemm_demo/
-│ ├── flash_attention_demo/
-│ └── mla_attention_demo/
-└── torch_jit/ # PyTorch JIT 编译示例
- ├── add/
- ├── gemm/
- └── flash_atten/
-```
-
-## 演示类别
-
-### 1. Baseline (`baseline/`)
-
-生产级示例,展示如何实现自定义 PTO 内核并通过 `torch_npu` 将其作为 PyTorch 算子公开。包含从内核实现到 Python 集成的完整工作流程,带 CMake 构建系统和 wheel 打包。
-
-**支持平台**:A2/A3/A5
-
-**示例**:逐元素加法、带双缓冲流水线的 GEMM、带自动 tile 大小选择的 Flash Attention。
-
-### 2. CPU 模拟 (`cpu/`)
-
-在 CPU(x86_64/AArch64)上运行的跨平台示例,无需 Ascend 硬件。适用于算法原型设计、学习 PTO 编程模型和 CI/CD 测试。
-
-**示例**:基础 GEMM、Flash Attention、多潜在注意力。
-
-### 3. PyTorch JIT (`torch_jit/`)
-
-展示即时 C++ 编译和与 PyTorch 张量直接集成的示例。适用于快速原型设计,无需预先构建 wheel。
-
-**示例**:JIT 加法、JIT GEMM、带基准测试套件的 JIT Flash Attention。
-
-## 快速开始
-
-### CPU 模拟(推荐第一步)
-
-```bash
-python3 tests/run_cpu.py --demo gemm --verbose
-python3 tests/run_cpu.py --demo flash_attn --verbose
-```
-
-### NPU Baseline 示例
-
-```bash
-cd demos/baseline/add
-python -m venv virEnv && source virEnv/bin/activate
-pip install -r requirements.txt
-export PTO_LIB_PATH=[YOUR_PATH]/pto-isa
-python3 setup.py bdist_wheel
-pip install dist/*.whl
-cd test && python3 test.py
-```
-
-### JIT 示例
-
-```bash
-export PTO_LIB_PATH=[YOUR_PATH]/pto-isa
-cd demos/torch_jit/add
-python add_compile_and_run.py
-```
-
-## 前置要求
-
-**Baseline 和 JIT(NPU)**:
-- Ascend AI 处理器 A2/A3/A5(910B/910C/950)
-- CANN Toolkit 8.5.0+
-- 带 `torch_npu` 的 PyTorch
-- Python 3.8+、CMake 3.16+
-
-**CPU 演示**:
-- 支持 C++23 的 C++ 编译器
-- CMake 3.16+
-- Python 3.8+(可选)
-
-## 文档
-
-- 入门指南:[docs/getting-started.md](../docs/getting-started_zh.md)
-- 编程教程:[docs/coding/tutorial.md](../docs/coding/tutorial_zh.md)
-- ISA 参考:[docs/isa/README.md](../docs/isa/README_zh.md)
-
-## 相关
-
-- 手工内核:[kernels/manual/README.md](../kernels/manual/README_zh.md)
-- 自定义算子:[kernels/custom/README.md](../kernels/custom/README_zh.md)
-- 测试用例:[tests/README.md](../tests/README_zh.md)
+# PTO Demos
+
+本目录包含 PTO Tile Library 在不同场景下的演示示例。
+
+## 按任务选择
+
+| 你的目标 | 从这里开始 |
+|----------|----------|
+| 快速验证算法(无需硬件) | CPU 模拟 demo — `tests/run_cpu.py --demo` |
+| 学习 PTO tile 编程 | CPU demo — `flash_attn` 或 `gemm` |
+| 生产级 NPU 算子 | `baseline/` — 带 PyTorch 集成的完整示例 |
+| 即时编译与调试 | `torch_jit/` — JIT 编译示例 |
+| Auto Mode | `auto_mode/baseline/add/` — Auto Mode 示例 |
+
+## 目录结构
+
+```
+demos/
+├── baseline/ # 生产级 PyTorch 算子示例(NPU)
+│ ├── add/ # 逐元素加法
+│ ├── gemm_basic/ # GEMM(含流水线优化)
+│ ├── flash_atten/ # Flash Attention(含动态分块)
+│ └── allgather_async/ # 异步 AllGather
+│
+├── auto_mode/ # Auto Mode 示例(CPU / NPU 均可)
+│ └── baseline/add/ # Auto Mode 逐元素加法
+│
+├── cpu/ # CPU 模拟 demo(跨平台,无需 Ascend 硬件)
+│ ├── gemm_demo/
+│ ├── flash_attention_demo/
+│ └── mla_attention_demo/
+│
+└── torch_jit/ # PyTorch JIT 编译示例
+ ├── add/
+ ├── gemm/
+ └── flash_atten/
+```
+
+## 示例类别
+
+### 1. Baseline(`baseline/`)
+
+生产级示例,展示如何实现自定义 PTO kernel 并通过 `torch_npu` 将其作为 PyTorch 算子公开。包含从 kernel 实现到 Python 集成的完整工作流程,带 CMake 构建系统和 wheel 打包。
+
+**支持平台**:A2/A3/A5
+
+**示例**:
+- 逐元素加法 — 最基础的 PTO 算子示例
+- GEMM — 带双缓冲流水线的矩阵乘法
+- Flash Attention — 带自动 tile 大小选择的 Flash Attention
+- AllGather-Async — 异步 AllGather 通信
+
+### 2. CPU 模拟(`cpu/`)
+
+在 CPU(x86_64/AArch64)上运行的跨平台示例,无需 Ascend 硬件。适用于算法原型设计、学习 PTO 编程模型和 CI/CD 测试。
+
+**示例**:基础 GEMM、Flash Attention、多潜在注意力(MLA)
+
+### 3. Auto Mode(`auto_mode/`)
+
+展示 PTO AUTO 模式的代码。Auto 模式下编译器自动管理 tile buffer 地址分配与流水线同步,无需手动 `TASSIGN` 和 `set_flag`/`wait_flag`。
+
+**示例**:Auto Mode 逐元素加法
+
+### 4. PyTorch JIT(`torch_jit/`)
+
+展示即时 C++ 编译和与 PyTorch 张量直接集成的示例。适用于快速原型设计,无需预先构建 wheel。
+
+**示例**:JIT 加法、JIT GEMM、带基准测试套件的 JIT Flash Attention
+
+## 快速开始
+
+### CPU 模拟(推荐第一步)
+
+```bash
+python3 tests/run_cpu.py --demo gemm --verbose
+python3 tests/run_cpu.py --demo flash_attn --verbose
+```
+
+### NPU Baseline 示例
+
+```bash
+cd demos/baseline/add
+python -m venv virEnv && source virEnv/bin/activate
+pip install -r requirements.txt
+export PTO_LIB_PATH=[YOUR_PATH]/pto-isa
+python3 setup.py bdist_wheel
+pip install dist/*.whl
+cd test && python3 test.py
+```
+
+### Auto Mode 示例
+
+```bash
+cd demos/auto_mode/baseline/add
+# See the README_zh.md inside for build and run instructions
+```
+
+### JIT 示例
+
+```bash
+export PTO_LIB_PATH=[YOUR_PATH]/pto-isa
+cd demos/torch_jit/add
+python add_compile_and_run.py
+```
+
+## 前置要求
+
+**Baseline 和 JIT(NPU)**:
+- Ascend AI 处理器 A2/A3/A5(910B/910C/950)
+- CANN Toolkit 8.5.0+
+- 带 `torch_npu` 的 PyTorch
+- Python 3.8+、CMake 3.16+
+
+**CPU 演示**:
+- 支持 C++20 的 C++ 编译器
+- CMake 3.16+
+- Python 3.8+(可选)
+
+## 相关文档
+
+| 文档 | 内容 |
+|------|------|
+| [demos/README_zh.md](./README_zh.md) | 中文版入口 |
+| [docs/getting-started_zh.md](../docs/getting-started_zh.md) | 入门指南 |
+| [docs/coding/tutorial_zh.md](../docs/coding/tutorial_zh.md) | 编程教程 |
+| [docs/isa/README_zh.md](../docs/isa/README_zh.md) | ISA 参考 |
diff --git a/docs/README.md b/docs/README.md
index a7f2f461..22fadfff 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -1,81 +1,283 @@
+# PTO ISA Documentation
+
-
+
-# PTO ISA Documentation Guide
+**PTO ISA** (Parallel Tile Operation Instruction Set Architecture) defines a stable, machine-independent instruction set for Huawei Ascend NPUs. It sits between high-level frontends (C/C++, Python, TileLang, PyPTO) and target-specific backends, providing one versioned instruction language across Ascend generations.
+
+> **Documentation version:** PTO ISA 1.0
+> **Applicable targets:** CPU Simulator · A2/A3 (Ascend 910B/910C) · A5 (Ascend 950)
+
+---
+
+## Quick Navigation
+
+Use this page as a **reading guide**, not a table of contents. The manual is organized into five layers — start at the layer that matches your goal.
+
+### Five-Layer Structure
+
+| Layer | Contents | Audience |
+|-------|----------|----------|
+| **1. Foundations** | Introduction, programming model, machine model | Everyone — start here |
+| **2. Syntax and Semantics** | Assembly model, operands, types, memory model | Kernel authors, compiler developers |
+| **3. Instruction Surface** | Instruction-set overview and contracts | All users |
+| **4. Reference Manual** | Tile, vector, scalar, and communication reference | Performance engineers, kernel authors |
+| **5. Appendices** | Format guidelines, diagnostics, glossary, portability | Everyone |
+
+### By Instruction Set
+
+| Instruction Set | Prefix | Role | Count | Reference |
+|----------------|--------|------|-------|-----------|
+| **Tile** | `pto.t*` | Tile-oriented compute, data movement, layout transforms, synchronization | ~120 ops | [Tile reference](isa/tile/README.md) |
+| **Vector** | `pto.v*` | Low-level vector micro-instructions, per-lane masking, pipeline control | ~99 ops | [Vector reference](isa/vector/README.md) |
+| **Scalar & Control** | `pto.*` | Configuration, control flow, DMA setup, predicate operations | ~60 ops | [Scalar reference](isa/scalar/README.md) |
+| **Communication** | `pto.*` | Multi-NPU collective operations and runtime support | ~24 ops | [Communication reference](isa/other/README.md) |
+
+### By Task
+
+| What you're doing | Start here |
+|-------------------|------------|
+| Understanding PTO's place in the stack | [What is PTO ISA?](isa/introduction/what-is-pto-visa.md) |
+| Writing a matrix multiplication kernel | [Tile → Matrix ops](isa/tile/matrix-and-matrix-vector.md) |
+| Optimizing elementwise operations | [Tile → Elementwise ops](isa/tile/elementwise-tile-tile.md) |
+| Implementing a convolution kernel | [Tile → img2col](isa/tile/ops/layout-and-rearrangement/timg2col.md) |
+| Setting up data movement (GM ↔ tile) | [Tile memory ops](isa/tile/memory-and-data-movement.md) |
+| Hand-tuning vector kernels | [Vector instructions](isa/vector/README.md) |
+| Using per-lane masking and predicates | [Vector → Predicate ops](isa/vector/predicate-and-materialization.md) |
+| Implementing collective communication | [Communication instructions](isa/other/README.md) |
+| Sorting, quantization, or histogram ops | [Irregular ops](isa/tile/irregular-and-complex.md) |
+| Letting the compiler manage synchronization | [Auto vs Manual mode](isa/programming-model/auto-vs-manual.md) |
+| Managing pipeline synchronization manually | [Synchronization model](isa/machine-model/ordering-and-synchronization.md) |
+| Checking which types/features are on A5 vs A2/A3 | [Target profiles](isa/machine-model/execution-agents.md) |
+| Reading a per-instruction page for the first time | [Format of instruction descriptions](isa/reference/format-of-instruction-descriptions.md) |
+
+---
+
+## Get Started
+
+New to PTO? Follow this path:
+
+1. **[What is PTO ISA?](isa/introduction/what-is-pto-visa.md)** — Core concepts, design rationale, and where PTO fits in the software stack
+2. **[Programming Model: Tiles and Valid Regions](isa/programming-model/tiles-and-valid-regions.md)** — The tile abstraction that makes PTO tile-first
+3. **[Machine Model: Execution Agents and Profiles](isa/machine-model/execution-agents.md)** — Execution hierarchy, pipelines, target profiles, and synchronization
+4. **[Instruction Set Overview](isa/instruction-surfaces/README.md)** — High-level map of all four instruction sets and when to use each
+5. **[Per-Instruction Reference](isa/README.md)** — Complete catalog organized by category
+
+---
+
+## What is PTO ISA?
+
+PTO ISA is the stable instruction language for Ascend NPU software. It abstracts away hardware differences across A2/A3/A5 generations while preserving enough control for performance tuning.
+
+```
+Source Languages
+(C/C++, Python, TileLang, PyPTO, code generators)
+ │
+ ▼
+ PTO instructions (.pto text)
+ │
+ ├──► ptoas ──► C++ ──► bisheng ──► binary (Flow A: via C++ intermediate)
+ │
+ └──► ptoas ────────────────────► binary (Flow B: direct assemble)
+
+Targets: CPU simulation / A2A3 (Ascend 910B / 910C) / A5 (Ascend 950 PR / 950 DT)
+```
+
+### Tile vs Vector: When To Use Which?
+
+| Criteria | Tile Instructions (`pto.t*`) | Vector Instructions (`pto.v*`) |
+|----------|-------------------------------|--------------------------------|
+| **Typical use** | Dense tensor algebra, matmul, elementwise operations | Fine-grained vector-pipe control, per-lane masking |
+| **Data movement** | `TLOAD`/`TSTORE` (implicit tile↔UB) | `copy_gm_to_ubuf` + `vlds`/`vsts` + `copy_ubuf_to_gm` |
+| **Synchronization** | `TSYNC`, `set_flag`/`wait_flag` | `set_flag`/`wait_flag` on vector pipe, `mem_bar` |
+| **Layout control** | Via tile layout parameters (`RowMajor`, `ColMajor`, fractal) | Via distribution mode (`NORM`, `BRC`, `DS`, etc.) |
+| **Predication** | No per-lane masking (valid region is coarse-grained) | Full per-lane predicate mask on every operation |
+| **Target portability** | All profiles (CPU, A2/A3, A5) | A5 hardware; emulated on CPU/A2/A3 |
+| **Abstraction level** | High-level tile semantics, valid regions | Low-level vector registers, explicit UB staging |
+
+> **Rule of thumb:** Start with tile instructions for tensor operations. Drop to vector instructions only when you need per-lane masking, custom data layouts, or micro-optimization that tile instructions cannot express.
+
+---
+
+## Core Concepts
+
+Understanding these concepts is essential before reading per-instruction pages.
+
+### Tile
+
+A **tile** is a bounded multi-dimensional array fragment with architecturally visible shape, layout, and valid-region metadata. Tiles are the primary programming objects in PTO.
+
+```cpp
+Tile a; // 16×16 f32 tile in vector tile buffer (UB)
+Tile b; // 64×64 f16 left operand (L0A)
+Tile c; // 128×128 i32 accumulator (L0C)
+```
+
+[Learn more →](isa/programming-model/tiles-and-valid-regions.md)
+
+### Valid Region
+
+The **valid region** `(Rv, Cv)` is the subset of a tile's declared shape that contains meaningful data. Operations iterate over the destination tile's valid region; source tiles with smaller valid regions yield implementation-defined values outside their valid region.
+
+### TileType (Location Intent)
+
+The **TileType** determines which hardware buffer backs a tile:
+
+| TileType | Hardware Buffer | Capacity | Typical Use |
+|----------|----------------|----------|-------------|
+| `Vec` | Unified Buffer (UB) | 256 KB | General elementwise operations |
+| `Left` | L0A | 64 KB | Matmul A operand |
+| `Right` | L0B | 64 KB | Matmul B operand |
+| `Acc` | L0C | 256 KB | Matmul accumulator/output |
+| `Mat` | L1 | 512 KB | 2D matrix operands |
+
+### GlobalTensor
+
+A **GlobalTensor** is a view of off-chip device memory (`__gm__` address space). All data movement between GM and tile buffers happens through explicit `TLOAD`/`TSTORE` or DMA operations.
-This page is the main documentation entry for PTO Tile Lib. It helps readers locate documents by topic instead of navigating directories one by one.
+[Learn more →](isa/programming-model/globaltensor-and-data-movement.md)
-The PTO documentation mainly covers the following areas:
+### Auto vs Manual Mode
-- ISA fundamentals and an overall reading path
-- Instruction indexes and per-instruction reference pages
-- PTO assembly syntax and the PTO-AS specification
-- Tile programming model, event synchronization, and performance tuning
-- Getting started, test execution, and documentation build instructions
+| Mode | Resource Binding | Synchronization | Data Movement | Who manages it? |
+|------|-----------------|-----------------|---------------|-----------------|
+| **Auto** | Compiler inserts `TASSIGN` | Compiler inserts `TSYNC` | Compiler inserts `TLOAD`/`TSTORE` | Compiler |
+| **Manual** | Author writes `TASSIGN` explicitly | Author writes `TSYNC` explicitly | Author writes `TLOAD`/`TSTORE` explicitly | You |
-## Recommended Reading Path
+[Auto vs Manual →](isa/programming-model/auto-vs-manual.md)
-If you are new to PTO Tile Lib, we recommend reading in the following order:
+### Target Profiles
-1. [Getting Started](getting-started.md): set up the environment and run the CPU simulator first
-2. [ISA Overview](PTOISA.md): build an overall understanding of the PTO ISA
-3. [PTO Instruction List](isa/README.md): browse the standard operations by category
-4. [Tile Programming Model](coding/Tile.md): understand tile shape, tile mask, and data organization
-5. [Events and Synchronization](coding/Event.md): understand set/wait flag usage and pipeline synchronization
-6. [Performance Optimization](coding/opt.md): understand common bottlenecks and tuning directions
+PTO ISA is instantiated by concrete **target profiles** that narrow the accepted subset for a specific backend.
-## Documentation Categories
+| Feature | CPU Simulator | A2/A3 Profile | A5 Profile |
+|---------|:--------------:|:--------------:|:----------:|
+| Tile instructions (`pto.t*`) | Full | Full | Full |
+| Vector instructions (`pto.v*`) | Emulated | Emulated | Full hardware |
+| Matmul / CUBE ops | Software fallback | Hardware | Hardware |
+| Vector width (f32 / f16,bf16 / i8) | Configurable | 64 / 128 / 256 | 64 / 128 / 256 |
+| FP8 types (`f8e4m3`, `f8e5m2`) | — | — | Supported |
+| Fractal layouts (NZ/ZN/FR/RN) | Simulated | Simulated | Full |
+| Block-scoped collective comm | — | Supported | Supported |
-### 1. ISA and Instruction Reference
+---
-- [Virtual ISA Manual Entry](PTO-Virtual-ISA-Manual.md): top-level entry for the PTO ISA manual
-- [ISA Overview](PTOISA.md): background, goals, and overall structure of the PTO ISA
-- [PTO Instruction List](isa/README.md): index of PTO standard operations organized by category
-- [General Conventions](isa/conventions.md): common naming rules, constraints, and usage conventions
+## Instruction-Set Navigation Map
-### 2. PTO Assembly and Representation
+PTO groups its instructions into four named instruction sets. Each set has a **contract page** (shared rules) and **per-op pages** (individual instructions).
-- [PTO Assembly Index](assembly/README.md): entry for PTO-AS documentation
-- [PTO Assembly Syntax (PTO-AS)](assembly/PTO-AS.md): PTO assembly syntax and specification
+### Tile Instruction Set — `pto.t*`
-### 3. Programming Model and Development Notes
+```
+Tile Instruction Set
+├── Sync and Config → tassign, tsync, tsettf32mode, tsetfmatrix, tset_img2col_*, tsubview, tget_scale_addr
+├── Elementwise Tile-Tile → tadd, tsub, tmul, tdiv, tmin, tmax, tcmp, tcvt, tsel, tlog, trecip, texp, tsqrt, trsqrt, trem, tfmod, tabs, tand, tor, txor, tnot, tneg, tprelu, taddc, tsubc, tshl, tshr
+├── Tile-Scalar and Immediate → tadds, tsubs, tmuls, tdivs, tminmaxs, tcmps, tsels, texpands, tfmods, trems, tands, tors, txors, tshls, tshrs, tlrelu, taddsc, tsubsc
+├── Reduce and Expand → trowsum, tcolsum, trowprod, tcolprod, tcolmax, tcolmin, trowmax, trowmin, tcolargmax, tcolargmin, trowargmax, trowargmin
+│ → trowexpand, trowexpandadd, trowexpanddiv, trowexpandmul, trowexpandsub, trowexpandmax, trowexpandmin, trowexpandexpdif
+│ → tcolexpand, tcolexpandadd, tcolexpanddiv, tcolexpandmul, tcolexpandsub, tcolexpandmax, tcolexpandmin, tcolexpandexpdif
+├── Memory and Data Movement → tload, tprefetch, tstore, tstore_fp, mgather, mscatter
+├── Matrix and Matrix-Vector → tgemv, tgemv_mx, tgemv_acc, tgemv_bias, tmatmul, tmatmul_mx, tmatmul_acc, tmatmul_bias
+├── Layout and Rearrangement → tmov, tmov_fp, ttrans, textract, textract_fp, tinsert, tinsert_fp, timg2col, tfillpad, tfillpad_inplace, tfillpad_expand, treshape
+└── Irregular and Complex → tprint, tmrgsort, tsort32, tgather, tgatherb, tscatter, tci, ttri, tpartadd, tpartmul, tpartmax, tpartmin, tquant
+```
-- [Development Documentation Index](coding/README.md): entry for developer-facing PTO Tile Lib documentation
-- [Tile Programming Model](coding/Tile.md): tile shape, tile mask, and data layout
-- [Events and Synchronization](coding/Event.md): event recording, waiting, and synchronization behavior
-- [Performance Optimization](coding/opt.md): performance analysis and tuning guidance
+[Tile instruction set contract →](isa/instruction-families/tile-families.md)
-### 4. Getting Started, Testing, and Documentation Build
+### Vector Instruction Set — `pto.v*`
+
+```
+Vector Instruction Set
+├── Vector Load Store → vlds, vldas, vldus, vldx2, vsld, vsldb, vgather2, vgatherb, vgather2_bc
+│ → vsts, vstx2, vsst, vsstb, vscatter, vsta, vstas, vstar, vstu, vstus, vstur
+├── Predicate and Materialization → vbr, vdup
+├── Unary Vector Ops → vabs, vneg, vexp, vln, vsqrt, vrsqrt, vrec, vrelu, vnot, vbcnt, vcls, vmov
+├── Binary Vector Ops → vadd, vsub, vmul, vdiv, vmax, vmin, vand, vor, vxor, vshl, vshr, vaddc, vsubc
+├── Vector-Scalar Ops → vadds, vsubs, vmuls, vmaxs, vmins, vands, vors, vxors, vshls, vshrs, vlrelu, vaddcs, vsubcs
+├── Conversion Ops → vci, vcvt, vtrc
+├── Reduction Ops → vcadd, vcmax, vcmin, vcgadd, vcgmax, vcgmin, vcpadd
+├── Compare and Select → vcmp, vcmps, vsel, vselr, vselrv2
+├── Data Rearrangement → vintlv, vdintlv, vslide, vshift, vsqz, vusqz, vperm, vpack, vsunpack, vzunpack, vintlvv2, vdintlvv2
+└── SFU and DSA → vprelu, vexpdiff, vaddrelu, vsubrelu, vaxpy, vaddreluconv, vmulconv, vmull, vmula, vtranspose, vsort32, vbitsort, vmrgsort
+```
-- [Getting Started](getting-started.md): environment setup and CPU / NPU execution guide
-- [Test Guide](../tests/README.md): test entry points, scripts, and common commands
-- [Documentation Build Guide](mkdocs/README.md): how to build the docs locally with MkDocs
+[Vector instruction set contract →](isa/instruction-families/vector-families.md)
-### 5. Other Related Documents
+### Scalar and Control Instruction Set — `pto.*`
-- [Machine Documentation](machine/README.md): abstract machine model and related notes
+```
+Scalar and Control Instruction Set
+├── Control and Configuration → nop, barrier, yield; tsetf32mode, tsethf32mode, tsetfmatrix
+├── Pipeline Sync → set_flag, wait_flag, wait_flag_dev, pipe_barrier, mem_bar, get_buf, rls_buf, set_cross_core, set_intra_block, wait_intra_core
+├── DMA Copy → set_loop_size_outtoub, set_loop1/2_stride_outtoub
+│ → set_loop_size_ubtoout, set_loop1/2_stride_ubtoout
+│ → copy_gm_to_ubuf, copy_ubuf_to_gm, copy_ubuf_to_ubuf
+├── Predicate Load Store → pld, plds, pldi, psts, pst, psti, pstu
+├── Predicate Generation → pset_b8/b16/b32, pge_b8/b16/b32, plt_b8/b16/b32
+│ → pand, por, pxor, pnot, psel, ppack, punpack
+│ → pdintlv_b8, pintlv_b16
+├── Shared Arithmetic → Scalar arithmetic ops shared across instruction sets
+├── Shared SCF → Scalar structured control flow
+└── Micro-Instructions → BlockDim queries, pointer ops, vector scope, alignment state
+ [Micro-instruction summary →](isa/vector/micro-instruction-summary.md)
+```
-## Directory Structure
+[Scalar instruction set contract →](isa/instruction-families/scalar-and-control-families.md)
-Key entries are listed below:
+### Communication Instruction Set — `pto.*`
-```text
-├── isa/ # PTO instruction reference and category indexes
-├── assembly/ # PTO assembly syntax and PTO-AS specification
-├── coding/ # Programming model, development, and optimization docs
-├── auto_mode/ # Auto Mode related documents
-├── machine/ # Abstract machine model documents
-├── mkdocs/ # Documentation site build config and scripts
-├── figures/ # Images and diagram assets used in docs
-├── README* # Documentation entry pages
-├── PTOISA* # ISA overview documents
-└── getting-started* # Getting started guides
```
+Communication Instruction Set
+├── Collective Ops → tbroadcast, tget, tget_async, tput, tput_async
+│ → tscatter, tgather, treduce, ttest, twait, tnotify
+└── Non-ISA Supporting Ops → talias, taxpy, tconcat, tdequant, tfree, thistogram
+ → tpack, tpop, tpush, trandom
+```
+
+[Communication instruction set contract →](isa/instruction-families/other-families.md)
+
+---
+
+## Compilation Flows
+
+### Flow A: High-Level Compile (ptoas → C++ → bisheng → binary)
+
+High-level frontends emit `.pto` text files. `ptoas` parses, validates, and lowers these to C++ code calling the `pto-isa` C++ library. A backend compiler (bisheng) then produces the final binary.
+
+**Who uses this:** Compiler developers, library authors, high-level framework integrators. The `.pto` format is portable and cacheable.
+
+### Flow B: Direct Assemble (ptoas → binary)
+
+`ptoas` assembles directly to target binary, bypassing the C++ intermediate step.
+
+**Who uses this:** Performance engineers who need direct control over the final instruction stream, or toolchains that embed `ptoas` as a pure assembler.
+
+[Learn more about the compilation flows →](isa/introduction/what-is-pto-visa.md#two-compilation-flows)
+
+---
+
+## Key References
+
+| Reference | What it covers |
+|-----------|---------------|
+| **[PTO-AS Specification](assembly/PTO-AS.md)** | Assembly syntax and grammar for `.pto` text files |
+| **[Tile Programming Model](coding/Tile.md)** | Tile shape, tile mask, and data organization |
+| **[Events and Synchronization](coding/Event.md)** | set/wait flag and pipeline synchronization |
+| **[Performance Optimization](coding/opt.md)** | Bottleneck analysis and tuning guidance |
+| **[Auto Mode Overview](auto_mode/Auto_Mode_Overview.md)** | Compiler-driven resource management and synchronization |
+| **[Micro-Instruction Summary](isa/vector/micro-instruction-summary.md)** | Scalar micro-instructions: BlockDim, pointer ops, vector scope |
+| **[Portability and Target Profiles](isa/reference/portability-and-target-profiles.md)** | Which features exist on which target |
+| **[Glossary](isa/reference/glossary.md)** | Terminology reference |
+| **[Source of Truth](isa/reference/source-of-truth.md)** | Which files define authoritative semantics |
+| **[Build the Docs](mkdocs/README.md)** | Generate this site locally |
+
+---
+
+## Contributing
+
+This documentation is generated from the canonical PTO ISA specification at [github.com/PTO-ISA/pto-isa](https://github.com/PTO-ISA/pto-isa). Report issues and submit changes there.
-## Related Entry Points
+---
-- [Root README](../README.md): project overview, quick start, and repository entry page
-- [kernels Directory Guide](../kernels/README.md): kernel and operator implementation entry point
-- [include Directory Guide](../include/README.md): headers and public interface overview
-- [tests Directory Guide](../tests/README.md): testing and execution entry point
+*PTO ISA is part of the Ascend software stack. Copyright © Huawei Technologies Co., Ltd.*
diff --git a/docs/README_zh.md b/docs/README_zh.md
index 5802cf0e..6b547fb8 100644
--- a/docs/README_zh.md
+++ b/docs/README_zh.md
@@ -1,81 +1,284 @@
+# PTO ISA 文档导航
+
-
+
-# PTO ISA 文档导航
+**PTO ISA**(Parallel Tile Operation Instruction Set Architecture,平行瓦片操作指令集架构)是昇腾 NPU 的稳定、跨代际的机器无关指令集。它位于高层前端(C/C++、Python、TileLang、PyPTO)与目标特定后端之间,在昇腾各代际(A2/A3/A5)间提供统一版本化的指令语言。
+
+> **文档版本:** PTO ISA 1.0
+> **适用目标:** CPU 模拟器 · A2/A3(Ascend 910B/910C) · A5(Ascend 950)
+
+---
+
+## 快速导航
+
+使用本页面作为**阅读指南**,而非目录索引。手册按五个逻辑层次组织——从与你的目标匹配的层次开始阅读。
+
+### 五层结构
+
+| 层次 | 内容 | 受众 |
+|------|------|------|
+| **1. 基础** | 引言、编程模型、机器模型 | 所有人——从此开始 |
+| **2. 语法与语义** | 汇编模型、操作数、类型系统、内存模型 | 内核作者、编译器开发者 |
+| **3. 指令集概述** | 指令集总览与指令族契约 | 所有用户 |
+| **4. 参考手册** | Tile、Vector、Scalar、通信参考 | 性能工程师、内核作者 |
+| **5. 附录** | 格式指南、诊断、术语表、可移植性 | 所有人 |
+
+### 按指令集导航
+
+| 指令集 | 前缀 | 职责 | 数量 | 参考 |
+|--------|------|------|------|------|
+| **Tile** | `pto.t*` | Tile 级计算、数据搬运、布局变换、同步 | ~120 条 | [Tile 参考](isa/tile/README_zh.md) |
+| **Vector** | `pto.v*` | 向量微指令、lane 级 mask、流水线控制 | ~99 条 | [Vector 参考](isa/vector/README_zh.md) |
+| **标量与控制** | `pto.*` | 配置、控制流、DMA 设置、谓词操作 | ~60 条 | [Scalar 参考](isa/scalar/README_zh.md) |
+| **通信** | `pto.*` | 多 NPU 集体通信与运行时支撑 | ~24 条 | [通信参考](isa/other/README_zh.md) |
+
+### 按任务导航
+
+| 你的任务 | 从这里开始 |
+|----------|----------|
+| 理解 PTO 在软件栈中的位置 | [PTO ISA 是什么?](isa/introduction/what-is-pto-visa_zh.md) |
+| 编写矩阵乘法 kernel | [Tile → 矩阵运算](isa/tile/matrix-and-matrix-vector_zh.md) |
+| 优化逐元素运算 | [Tile → 逐元素](isa/tile/elementwise-tile-tile_zh.md) |
+| 实现卷积 kernel | [Tile → img2col](isa/tile/ops/layout-and-rearrangement/timg2col_zh.md) |
+| 设置数据搬运(GM ↔ tile) | [Tile 内存操作](isa/tile/memory-and-data-movement_zh.md) |
+| 手写向量 kernel | [Vector 指令](isa/vector/README_zh.md) |
+| 使用 lane 级 mask 与谓词 | [Vector → 谓词操作](isa/vector/predicate-and-materialization_zh.md) |
+| 实现多 NPU 集体通信 | [通信指令](isa/other/README_zh.md) |
+| 排序、量化或直方图操作 | [非常规操作](isa/tile/irregular-and-complex_zh.md) |
+| 让编译器管理同步 | [Auto vs Manual 模式](isa/programming-model/auto-vs-manual_zh.md) |
+| 手动管理流水线同步 | [同步模型](isa/machine-model/ordering-and-synchronization_zh.md) |
+| 查询 A5 vs A2/A3 支持的数据类型/特性 | [目标 Profile](isa/machine-model/execution-agents_zh.md) |
+| 首次阅读单条指令页面 | [指令描述格式](isa/reference/format-of-instruction-descriptions_zh.md) |
+
+---
+
+## 新手上路
+
+初次接触 PTO?按以下路径阅读:
+
+1. **[PTO ISA 是什么?](isa/introduction/what-is-pto-visa_zh.md)** — 核心概念、设计理念、PTO 在软件栈中的位置
+2. **[编程模型:Tile 与有效区域](isa/programming-model/tiles-and-valid-regions_zh.md)** — Tile 抽象——PTO 的核心编程对象
+3. **[机器模型:执行代理与 Profile](isa/machine-model/execution-agents_zh.md)** — 执行层次、流水线、目标 Profile 与同步
+4. **[指令集概述](isa/instruction-surfaces/README_zh.md)** — 四大指令集总览及选用指南
+5. **[逐指令参考](isa/README_zh.md)** — 按类别组织的完整指令目录
+
+---
+
+## 什么是 PTO ISA?
+
+PTO ISA 是昇腾 NPU 软件栈的稳定指令语言。它抽象了 A2/A3/A5 各代际间的硬件差异,同时保留了充足的性能调优控制能力。
+
+```
+高层语言
+(C/C++、Python、TileLang、PyPTO、代码生成器)
+ │
+ ▼
+ PTO 指令(.pto 文本)
+ │
+ ├──► ptoas ──► C++ ──► bisheng ──► 二进制 (Flow A:经 C++ 中间层)
+ │
+ └──► ptoas ──────────────────────► 二进制 (Flow B:直接汇编)
+
+目标平台:CPU 模拟器 / A2A3(Ascend 910B / 910C)/ A5(Ascend 950)
+```
+
+### Tile 指令 vs Vector 指令:何时选哪个?
+
+| 判断标准 | Tile 指令(`pto.t*`) | Vector 指令(`pto.v*`) |
+|----------|----------------------|------------------------|
+| **典型用途** | 密集张量代数、矩阵乘法、逐元素运算 | 细粒度向量流水线控制、lane 级 mask |
+| **数据搬运** | `TLOAD`/`TSTORE`(隐式 tile↔UB) | `copy_gm_to_ubuf` + `vlds`/`vsts` + `copy_ubuf_to_gm` |
+| **同步方式** | `TSYNC`、`set_flag`/`wait_flag` | `set_flag`/`wait_flag`(向量流水线)、`mem_bar` |
+| **布局控制** | 通过 tile 布局参数(`RowMajor`、`ColMajor`、分形布局) | 通过 distribution mode(`NORM`、`BRC`、`DS` 等) |
+| **谓词** | 无 lane 级 mask(有效区域是粗粒度的) | 每个操作都支持完整 lane 级谓词 mask |
+| **目标可移植性** | 所有 Profile(CPU、A2/A3、A5) | A5 硬件支持;CPU/A2/A3 为仿真 |
+| **抽象层级** | 高层 tile 语义、有效区域 | 低层向量寄存器、显式 UB 暂存 |
+
+> **经验法则:** 张量运算优先使用 tile 指令。只有在需要 lane 级 mask、自定义数据布局或 tile 指令无法表达的性能微调时,才降级到向量指令。
+
+---
+
+## 核心概念
+
+阅读逐指令页面之前,以下概念必不可少。
+
+### Tile
+
+**Tile** 是带有架构可见 shape、layout 和有效区域元数据的受限多维数组片段。Tile 是 PTO 中的主要编程对象。
+
+```cpp
+Tile a; // 16×16 f32 tile,位于向量 tile buffer(UB)
+Tile b; // 64×64 f16 左操作数(L0A)
+Tile c; // 128×128 i32 累加器(L0C)
+```
+
+[了解更多 →](isa/programming-model/tiles-and-valid-regions_zh.md)
+
+### 有效区域(Valid Region)
-这里是 PTO Tile Lib 的文档入口页,用于帮助读者按主题快速定位文档,而不是逐个目录查找。
+**有效区域** `(Rv, Cv)` 是 tile 声明形状中含有有效数据的子集。操作在目标 tile 的有效区域内迭代;源 tile 有效区域外的值为实现定义。
-PTO 相关文档主要覆盖以下几类内容:
+### TileType(位置意图)
-- ISA 基础概念与整体阅读路径
-- 指令索引与逐条指令参考
-- PTO 汇编语法与 PTO-AS 规范
-- Tile 编程模型、事件同步与性能优化
-- 快速开始、测试运行与文档构建说明
+**TileType** 决定 tile 由哪种硬件 buffer 支撑:
-## 建议阅读路径
+| TileType | 硬件 Buffer | 容量 | 典型用途 |
+|----------|------------|------|----------|
+| `Vec` | Unified Buffer(UB) | 256 KB | 通用逐元素运算 |
+| `Left` | L0A | 64 KB | 矩阵乘法 A 操作数 |
+| `Right` | L0B | 64 KB | 矩阵乘法 B 操作数 |
+| `Acc` | L0C | 256 KB | 矩阵乘法累加器/输出 |
+| `Mat` | L1 | 512 KB | 2D 矩阵操作数 |
-如果您第一次接触 PTO Tile Lib,建议按以下顺序阅读:
+### GlobalTensor
-1. [快速开始指南](getting-started_zh.md):先完成环境准备并运行 CPU Simulator
-2. [ISA 总览](PTOISA_zh.md):建立对 PTO ISA 的整体认识
-3. [PTO 指令列表](isa/README_zh.md):按类别浏览已定义的标准操作
-4. [Tile 编程模型](coding/Tile_zh.md):理解 tile shape、tile mask 与数据组织方式
-5. [事件与同步](coding/Event_zh.md):理解 set/wait flag 与流水线同步
-6. [性能优化](coding/opt_zh.md):理解常见瓶颈与调优方向
+**GlobalTensor** 是片外设备内存(`__gm__` 地址空间)的视图。GM 与 tile buffer 之间的所有数据搬运均通过显式的 `TLOAD`/`TSTORE` 或 DMA 操作完成。
-## 文档分类
+[了解更多 →](isa/programming-model/globaltensor-and-data-movement_zh.md)
-### 1. ISA 与指令参考
+### Auto vs Manual 模式
-- [虚拟 ISA 手册入口](PTO-Virtual-ISA-Manual_zh.md):PTO ISA 手册总入口
-- [ISA 总览](PTOISA_zh.md):介绍 PTO ISA 的背景、目标与整体结构
-- [PTO 指令列表](isa/README_zh.md):按类别组织的 PTO 标准操作索引
-- [通用约定](isa/conventions_zh.md):命名、约束、使用规范等通用规则
+| 模式 | 资源绑定 | 同步 | 数据搬运 | 管理方 |
+|------|---------|------|----------|--------|
+| **Auto** | 编译器插入 `TASSIGN` | 编译器插入 `TSYNC` | 编译器插入 `TLOAD`/`TSTORE` | 编译器 |
+| **Manual** | 作者显式写 `TASSIGN` | 作者显式写 `TSYNC` | 作者显式写 `TLOAD`/`TSTORE` | 你 |
-### 2. PTO 汇编与表示形式
+[Auto vs Manual →](isa/programming-model/auto-vs-manual_zh.md)
-- [PTO 汇编索引](assembly/README_zh.md):PTO-AS 文档入口
-- [PTO 汇编语法(PTO-AS)](assembly/PTO-AS_zh.md):PTO 汇编语法与规范说明
+### 目标 Profile
-### 3. 编程模型与开发文档
+PTO ISA 由具体的**目标 Profile** 实例化,为特定后端限定可接受的子集。
-- [开发文档索引](coding/README_zh.md):扩展 PTO Tile Lib 的开发文档入口
-- [Tile 编程模型](coding/Tile_zh.md):介绍 tile shape、tile mask 与数据布局
-- [事件与同步](coding/Event_zh.md):介绍事件记录、等待与同步机制
-- [性能优化](coding/opt_zh.md):介绍性能分析与调优建议
+| 特性 | CPU 模拟器 | A2/A3 Profile | A5 Profile |
+|------|:---------:|:-------------:|:----------:|
+| Tile 指令(`pto.t*`) | 完整 | 完整 | 完整 |
+| Vector 指令(`pto.v*`) | 仿真 | 仿真 | 硬件完整支持 |
+| 矩阵乘法 / CUBE 运算 | 软件回退 | 硬件 | 硬件 |
+| 向量宽度(f32 / f16,bf16 / i8) | 可配置 | 64 / 128 / 256 | 64 / 128 / 256 |
+| FP8 类型(`f8e4m3`、`f8e5m2`) | — | — | 支持 |
+| 分形布局(NZ/ZN/FR/RN) | 仿真 | 仿真 | 完整 |
+| 分块级集体通信 | — | 支持 | 支持 |
-### 4. 入门、测试与文档构建
+---
-- [快速开始指南](getting-started_zh.md):环境准备、CPU / NPU 运行说明
-- [测试说明](../tests/README_zh.md):测试入口、测试脚本与常用命令
-- [文档构建说明](mkdocs/README_zh.md):MkDocs 文档本地构建说明
+## 指令集导航地图
-### 5. 其他相关文档
+PTO 将其指令分为四个命名指令集。每个指令集有**契约页面**(共享规则)和**逐指令页面**(单条指令说明)。
-- [Machine 文档](machine/README_zh.md):抽象机器模型与相关说明
+### Tile 指令集 — `pto.t*`
-## 目录结构
+```
+Tile 指令集
+├── 同步与配置 → tassign、tsync、tsetf32mode、tsetfmatrix、tset_img2col_*、tsubview、tget_scale_addr
+├── 逐元素 Tile-Tile → tadd、tsub、tmul、tdiv、tmin、tmax、tcmp、tcvt、tsel、tlog、trecip、texp、tsqrt、trsqrt、trem、tfmod、tabs、tand、tor、txor、tnot、tneg、tprelu、taddc、tsubc、tshl、tshr
+├── Tile-标量与立即数 → tadds、tsubs、tmuls、tdi等等vs、tcmps、tsels、texpands、tfmods、trems、tands、tors、txors、tshls、tshrs、tlrelu、taddsc、tsubsc
+├── 归约与扩展 → trowsum、tcolsum、trowprod、tcolprod、tcolmax、tcolmin、trowmax、trowmin、tcolargmax、tcolargmin、trowargmax、trowargmin
+│ → trowexpand、trowexpandadd、trowexpanddiv、trowexpandmul、trowexpandsub、trowexpandmax、trowexpandmin、trowexpandexpdif
+│ → tcolexpand、tcolexpandadd、tcolexpanddiv、tcolexpandmul、tcolexpandsub、tcolexpandmax、tcolexpandmin、tcolexpandexpdif
+├── 内存与数据搬运 → tload、tprefetch、tstore、tstore_fp、mgather、mscatter
+├── 矩阵与矩阵-向量 → tgemv、tgemv_mx、tgemv_acc、tgemv_bias、tmatmul、tmatmul_mx、tmatmul_acc、tmatmul_bias
+├── 布局与重排 → tmov、tmov_fp、ttrans、textract、textract_fp、tinsert、tinsert_fp、timg2col、tfillpad、tfillpad_inplace、tfillpad_expand、treshape
+└── 非常规与复杂操作 → tprint、tmrgsort、tsort32、tgather、tgatherb、tscatter、tci、ttri、tpartadd、tpartmul、tpartmax、tpartmin、tquant
+```
-关键目录如下:
+[Tile 指令族契约 →](isa/instruction-families/tile-families_zh.md)
+
+### Vector 指令集 — `pto.v*`
+
+```
+Vector 指令集
+├── 向量加载存储 → vlds、vldas、vldus、vldx2、vsld、vsldb、vgather2、vgatherb、vgather2_bc
+│ → vsts、vstx2、vsst、vsstb、vscatter、vsta、vstas、vstar、vstu、vstus、vstur
+├── 谓词与物化 → vbr、vdup
+├── 一元向量运算 → vabs、vneg、vexp、vln、vsqrt、vrsqrt、vrec、vrelu、vnot、vbcnt、vcls、vmov
+├── 二元向量运算 → vadd、vsub、vmul、vdiv、vmax、vmin、vand、vor、vxor、vshl、vshr、vaddc、vsubc
+├── 向量-标量运算 → vadds、vsubs、vmuls、vmaxs、vmins、vands、vors、vxors、vshls、vshrs、vlrelu、vaddcs、vsubcs
+├── 类型转换 → vci、vcvt、vtrc
+├── 归约指令 → vcadd、vcmax、vcmin、vcgadd、vcgmax、vcgmin、vcpadd
+├── 比较与选择 → vcmp、vcmps、vsel、vselr、vselrv2
+├── 数据重排 → vintlv、vdintlv、vslide、vshift、vsqz、vusqz、vperm、vpack、vsunpack、vzunpack、vintlvv2、vdintlvv2
+└── SFU 与 DSA → vprelu、vexpdiff、vaddrelu、vsubrelu、vaxpy、vaddreluconv、vmulconv、vmull、vmula、vtranspose、vsort32、vbitsort、vmrgsort
+```
-```text
-├── isa/ # PTO 指令参考与分类索引
-├── assembly/ # PTO 汇编语法与 PTO-AS 规范
-├── coding/ # 编程模型、开发与性能优化文档
-├── auto_mode/ # Auto Mode 相关文档
-├── machine/ # 抽象机器模型相关文档
-├── mkdocs/ # 文档站点构建配置与脚本
-├── figures/ # 文档中使用的图片与图示资源
-├── README* # 文档入口页
-├── PTOISA* # ISA 总览文档
-└── getting-started* # 快速开始指南
+[Vector 指令族契约 →](isa/instruction-families/vector-families_zh.md)
+
+### 标量与控制指令集 — `pto.*`
+
+```
+标量与控制指令集
+├── 控制与配置 → nop、barrier、yield;tsetf32mode、tsethf32mode、tsetfmatrix
+├── 流水线同步 → set_flag、wait_flag、wait_flag_dev、pipe_barrier、mem_bar、get_buf、rls_buf
+│ → set_cross_core、set_intra_block、wait_intra_core
+├── DMA 拷贝 → set_loop_size_outtoub、set_loop1/2_stride_outtoub
+│ → set_loop_size_ubtoout、set_loop1/2_stride_ubtoout
+│ → copy_gm_to_ubuf、copy_ubuf_to_gm、copy_ubuf_to_ubuf
+├── 谓词加载存储 → pld、plds、pldi、psts、pst、psti、pstu
+├── 谓词生成 → pset_b8/b16/b32、pge_b8/b16/b32、plt_b8/b16/b32
+│ → pand、por、pxor、pnot、psel、ppack、punpack
+│ → pdintlv_b8、pintlv_b16
+├── 共享标量算术 → 跨指令集共享的标量算术运算
+├── 共享结构化控制流 → 标量结构化控制流
+└── 微指令 → BlockDim 查询、指针操作、向量作用域、对齐状态
+ [微指令汇总 →](isa/vector/micro-instruction-summary.md)
+```
+
+[标量指令族契约 →](isa/instruction-families/scalar-and-control-families_zh.md)
+
+### 通信指令集 — `pto.*`
+
+```
+通信指令集
+├── 集体操作 → tbroadcast、tget、tget_async、tput、tput_async
+│ → tscatter、tgather、treduce、ttest、twait、tnotify
+└── 非 ISA 支撑操作 → talias、taxpy、tconcat、tdequant、tfree、thistogram
+ → tpack、tpop、tpush、trandom
```
-## 相关入口
+[通信指令族契约 →](isa/instruction-families/other-families_zh.md)
+
+---
+
+## 编译流程
+
+### Flow A:高层编译(ptoas → C++ → bisheng → 二进制)
+
+高层前端发出 `.pto` 文本文件。`ptoas` 解析、验证并降级为调用 `pto-isa` C++ 库的 C++ 代码。后端编译器(bisheng)再生成最终二进制。
+
+**适用人群:** 编译器开发者、库作者、高层框架集成商。`.pto` 格式可移植、可缓存。
+
+### Flow B:直接汇编(ptoas → 二进制)
+
+`ptoas` 直接汇编为目标二进制,跳过 C++ 中间步骤。
+
+**适用人群:** 需要直接控制最终指令流的性能工程师,或将 `ptoas` 作为纯汇编器使用的工具链。
+
+[了解更多编译流程 →](isa/introduction/what-is-pto-visa_zh.md#two-compilation-flows)
+
+---
+
+## 关键参考
+
+| 参考资料 | 内容 |
+|----------|------|
+| **[PTO-AS 规范](assembly/PTO-AS_zh.md)** | `.pto` 文本文件的汇编语法与文法 |
+| **[Tile 编程模型](coding/Tile_zh.md)** | Tile shape、mask 与数据组织 |
+| **[事件与同步](coding/Event_zh.md)** | set/wait flag 与流水线同步 |
+| **[性能优化](coding/opt_zh.md)** | 瓶颈分析与调优指导 |
+| **[Auto Mode 概述](auto_mode/Auto_Mode_Overview_zh.md)** | 编译器驱动的资源管理与同步插入 |
+| **[微指令汇总](isa/vector/micro-instruction-summary.md)** | 标量微指令:BlockDim、指针操作、向量作用域 |
+| **[可移植性与目标 Profile](isa/reference/portability-and-target-profiles_zh.md)** | 各目标支持哪些特性 |
+| **[术语表](isa/reference/glossary_zh.md)** | 术语定义参考 |
+| **[规范来源](isa/reference/source-of-truth_zh.md)** | 哪些文件定义权威语义 |
+| **[构建文档](mkdocs/README_zh.md)** | 本地生成文档站点 |
+
+---
+
+## 参与贡献
+
+本文档源自 [github.com/PTO-ISA/pto-isa](https://github.com/PTO-ISA/pto-isa) 的权威 PTO ISA 规范。通过仓库 Issues 反馈问题,通过 Pull Request 提交更改。
+
+---
-- [根目录 README_zh](../README_zh.md):项目总览、快速开始与仓库入口
-- [kernels 目录说明](../kernels/README_zh.md):kernel 与算子实现入口
-- [include 目录说明](../include/README_zh.md):头文件与接口说明
-- [tests 目录说明](../tests/README_zh.md):测试与运行入口
+*PTO ISA 是昇腾软件栈的一部分。版权所有 © Huawei Technologies Co., Ltd.*
diff --git a/docs/assembly/README_zh.md b/docs/assembly/README_zh.md
index 492028ad..f8562a60 100644
--- a/docs/assembly/README_zh.md
+++ b/docs/assembly/README_zh.md
@@ -2,74 +2,56 @@
这里是 PTO AS 文档的主入口页,用于帮助读者按主题快速定位汇编相关文档,而不是逐个文件查找。
-PTO AS 文档主要覆盖以下几类内容:
+## 按任务选择
-- PTO-AS 语法、文法与文本表示形式
-- ISA 级 tile 操作与辅助 AS 构造
-- 从 MLIR 复用的标量算术与控制流操作
-- 汇编相关约定与配套参考资料
-
-## 建议阅读路径
-
-如果您第一次接触 PTO-AS,建议按以下顺序阅读:
-
-1. [PTO-AS 规范](PTO-AS_zh.md):先理解文本格式、语法与 directives
-2. [PTO AS 操作参考](README_zh.md):建立对操作分类及链接入口的整体认识
-3. [PTO-AS 约定](conventions_zh.md):理解命名与文档编写约定
-4. 各类操作文档:按任务需要继续阅读对应分类页面
+| 你的需求 | 从这里开始 |
+|----------|----------|
+| 理解 PTO-AS 语法与文法 | [PTO-AS 规范](PTO-AS_zh.md) |
+| 了解操作分类与链接入口 | [PTO AS 操作参考](README_zh.md) |
+| 理解命名与文档编写约定 | [PTO-AS 约定](conventions_zh.md) |
+| 按类别查找操作 | 见下方文档分类 |
## 文档分类
### 1. PTO-AS 语法与核心规范
-- [PTO-AS 规范](PTO-AS_zh.md):文本格式、SSA 风格命名、directives 与文法概览
-- [PTO-AS 约定](conventions_zh.md):汇编语法约定与相关文档规则
-- `PTO-AS.bnf`:PTO-AS 的 BNF 形式文法定义
+| 文档 | 内容 |
+|------|------|
+| [PTO-AS 规范](PTO-AS_zh.md) | 文本格式、SSA 风格命名、directives 与文法概览 |
+| [PTO-AS 约定](conventions_zh.md) | 汇编语法约定与相关文档规则 |
+| `PTO-AS.bnf` | PTO-AS 的 BNF 形式文法定义 |
### 2. PTO Tile 操作分类
-- [逐元素操作](elementwise-ops_zh.md):tile-tile 逐元素操作
-- [Tile-标量操作](tile-scalar-ops_zh.md):tile 与标量之间的算术、比较与激活操作
-- [轴归约和扩展](axis-ops_zh.md):行/列归约与广播式扩展操作
-- [内存操作](memory-ops_zh.md):GM 与 tile 之间的数据搬运操作
-- [矩阵乘法](matrix-ops_zh.md):GEMM 与 GEMV 相关操作
-- [数据移动和布局](data-movement-ops_zh.md):提取、插入、转置、reshape 与 padding 操作
-- [复杂操作](complex-ops_zh.md):排序、gather/scatter、随机数、量化与工具类操作
-- [手动资源绑定](manual-binding-ops_zh.md):赋值与硬件/资源配置类操作
+| 文档 | 内容 |
+|------|------|
+| [逐元素操作](elementwise-ops_zh.md) | tile-tile 逐元素操作 |
+| [Tile-标量操作](tile-scalar-ops_zh.md) | tile 与标量之间的算术、比较与激活操作 |
+| [轴归约和扩展](axis-ops_zh.md) | 行/列归约与广播式扩展操作 |
+| [内存操作](memory-ops_zh.md) | GM 与 tile 之间的数据搬运操作 |
+| [矩阵乘法](matrix-ops_zh.md) | GEMM 与 GEMV 相关操作 |
+| [数据移动和布局](data-movement-ops_zh.md) | 提取、插入、转置、reshape 与 padding 操作 |
+| [复杂操作](complex-ops_zh.md) | 排序、gather/scatter、随机数、量化与工具类操作 |
+| [手动资源绑定](manual-binding-ops_zh.md) | 赋值与硬件/资源配置类操作 |
### 3. 辅助 AS 与 MLIR 派生操作
-- [辅助函数](nonisa-ops_zh.md):张量视图、tile 分配、索引与同步辅助构造
-- [标量算术操作](scalar-arith-ops_zh.md):来自 MLIR `arith` 的标量算术操作
-- [控制流操作](control-flow-ops_zh.md):来自 MLIR `scf` 的结构化控制流操作
+| 文档 | 内容 |
+|------|------|
+| [辅助函数](nonisa-ops_zh.md) | 张量视图、tile 分配、索引与同步辅助构造 |
+| [标量算术操作](scalar-arith-ops_zh.md) | 来自 MLIR `arith` 的标量算术操作 |
+| [控制流操作](control-flow-ops_zh.md) | 来自 MLIR `scf` 的结构化控制流操作 |
### 4. 相关参考
-- [ISA 指令参考](../isa/README_zh.md):逐条指令的规范语义
-- [docs 文档入口](../README_zh.md):返回 PTO Tile Lib 文档总导航页
-
-## 目录结构
-
-关键条目如下:
-
-```text
-├── PTO-AS* # PTO-AS 语法与规范文档
-├── conventions* # 汇编约定文档
-├── elementwise-ops* # 逐元素操作参考
-├── tile-scalar-ops* # Tile-标量操作参考
-├── axis-ops* # 轴归约与扩展参考
-├── memory-ops* # 内存操作参考
-├── matrix-ops* # 矩阵乘法参考
-├── data-movement-ops* # 数据移动与布局参考
-├── complex-ops* # 复杂操作参考
-├── manual-binding-ops* # 手动资源绑定参考
-├── scalar-arith-ops* # 标量算术参考
-├── control-flow-ops* # 控制流参考
-└── nonisa-ops* # 辅助 AS 构造参考
-```
+| 文档 | 内容 |
+|------|------|
+| [ISA 指令参考](../isa/README_zh.md) | 逐条指令的规范语义 |
+| [docs 文档入口](../README_zh.md) | PTO Tile Library 文档总导航页 |
+| [Machine 文档](../machine/README_zh.md) | 抽象执行模型 |
## 相关入口
-- [ISA 指令参考](../isa/README_zh.md):查看 PTO 指令的规范语义
-- [docs 文档入口](../README_zh.md):返回文档总导航页
-- [Machine 文档](../machine/README_zh.md):了解抽象执行模型
+- [ISA 指令参考](../isa/README_zh.md)
+- [docs 文档入口](../README_zh.md)
+- [Machine 文档](../machine/README_zh.md)
diff --git a/docs/auto_mode/README.md b/docs/auto_mode/README.md
index 6ff6140f..3ecfcb90 100644
--- a/docs/auto_mode/README.md
+++ b/docs/auto_mode/README.md
@@ -1,105 +1,51 @@
# PTO AUTO Mode
-## What is PTO AUTO
-
-PTO AUTO is a programming mode for PTO that provides two major benefits:
-
-* Simpify developing efficient PTO code while providing kernel developers with the mechanisms that are necessary to implement their optimizations.
-* Compatibility across different generations of the Ascend architecture.
-
-More specifically, in PTO AUTO, the kernel developer does not need to explicitly specify tile memory addresses or synchronization between different pipes. Instead the PTO AUTO compiler automatically allocates optimal memory addressess for the tiles in different chip buffers. Moreover, the compiler automatically synchronizes the PTO tile operations in order to maximize parallelism among different pipes. Finally, the kernel developer does not need to be concerned with the minor differences between various generations of the Ascend architecture (particulary in terms of the way Cube and Vector computations are coordinated).
-
-Note: auto mode currently only supports the compiler `-O2` option.
-
-## Simple Example
-
-A simple example, elementwise multiplication demonstrates the key differences between the PTO AUTO and manual modes:
-
-### TMUL Manual Mode
-
-```cpp
-template
-__global__ AICORE void runTMul(__gm__ T __out__ *out, __gm__ T __in__ *src0, __gm__ T __in__ *src1)
-{
- using DynShapeDim5 = Shape<1, 1, 1, kGRows_, kGCols_>;
- using DynStridDim5 = Stride<1, 1, 1, kGCols_, 1>;
- using GlobalData = GlobalTensor;
- using TileData = Tile;
- TileData src0Tile(kGRows_, kGCols_);
- TileData src1Tile(kGRows_, kGCols_);
- TileData dstTile(kGRows_, kGCols_);
+This directory contains detailed documentation for PTO AUTO Mode, helping developers understand and use Auto Mode for PTO programming.
- TASSIGN(src0Tile, 0x0 + 0x400 * block_idx);
- TASSIGN(src1Tile, 0x4000 + 0x400 * block_idx);
- TASSIGN(dstTile, 0x8000 + 0x400 * block_idx);
+## Choose by Task
- int offset = (block_idx / 4) * (64 * 16) + (block_idx % 4) * 16;
- GlobalData src0Global(src0 + offset);
- GlobalData src1Global(src1 + offset);
- GlobalData dstGlobal(out + offset);
+| Your need | Start here |
+|-----------|-----------|
+| What is Auto Mode | [Auto Mode Overview](Auto_Mode_Overview.md) |
+| Kernel development rules and limitations | [Kernel Developer Rules](Kernel_Developer_Rules_And_Limitations.md) |
+| Library development rules and limitations | [Library Developer Rules](Library_Developer_Rules_And_Limitations.md) |
+| Code examples | [Examples](Examples.md) |
- TLOAD(src0Tile, src0Global);
- TLOAD(src1Tile, src1Global);
- set_flag(PIPE_MTE2, PIPE_V, EVENT_ID0);
- wait_flag(PIPE_MTE2, PIPE_V, EVENT_ID0);
- TMUL(dstTile, src0Tile, src1Tile);
- set_flag(PIPE_V, PIPE_MTE3, EVENT_ID0);
- wait_flag(PIPE_V, PIPE_MTE3, EVENT_ID0);
- TSTORE(dstGlobal, dstTile);
-
- out = dstGlobal.data();
-}
-```
-
-### TMUL AUTO Mode
-
-```cpp
-template
-__global__ AICORE void runTMul(__gm__ T __out__ *out, __gm__ T __in__ *src0, __gm__ T __in__ *src1)
-{
- using DynShapeDim5 = Shape<1, 1, 1, kGRows_, kGCols_>;
- using DynStridDim5 = Stride<1, 1, 1, kGCols_, 1>;
- using GlobalData = GlobalTensor;
- using TileData = Tile;
-
- TileData src0Tile(kGRows_, kGCols_);
- TileData src1Tile(kGRows_, kGCols_);
- TileData dstTile(kGRows_, kGCols_);
-
- int offset = (block_idx / 4) * (64 * 16) + (block_idx % 4) * 16;
- GlobalData src0Global(src0 + offset);
- GlobalData src1Global(src1 + offset);
- GlobalData dstGlobal(out + offset);
-
- TLOAD(src0Tile, src0Global);
- TLOAD(src1Tile, src1Global);
- TMUL(dstTile, src0Tile, src1Tile);
- TSTORE(dstGlobal, dstTile);
-
- out = dstGlobal.data();
-}
-```
-
-## PTO AUTO Compiler Features
+## What is PTO AUTO
-### Cross-Architecture Compatibility
+PTO AUTO is a programming mode that provides two major benefits:
-PTO AUTO Compiler ensures a single source PTO program can be compiled for different Ascend architecture generations without requiring any source-level modifications while maintaining performance.
+1. **Simplifies development** while enabling necessary optimizations.
+2. **Ensures cross-generation compatibility** across Ascend hardware.
-### Automatic Synchronization
+In AUTO mode, kernel developers **do not need to** manually assign tile memory (`TASSIGN`) or manage synchronization between pipes (`set_flag`/`wait_flag`). The compiler handles these automatically while maintaining good performance.
-In manual mode, user would normally have to keep track of the asynchronous nature of the hardware by using PTO's [`event model`](../coding/Event.md) at precise code locations in order to ensure both functional correctness and high performance in execution. This might be tedious and error prone.
+## Auto vs Manual Mode Comparison
-Auto mode compilation will allow users to avoid having to use the event model to synchronize their code. The compiler will automatically determine the locations to insert synchronization under the hood - ensuring functional correctness and competitive performance.
+| Aspect | Auto Mode | Manual Mode |
+|--------|-----------|-------------|
+| Tile address allocation | Compiler automatic | Author explicit `TASSIGN` |
+| Synchronization management | Compiler automatic | Author explicit `set_flag`/`wait_flag` |
+| Data movement | Compiler automatic `TLOAD`/`TSTORE` | Author explicit `TLOAD`/`TSTORE` |
+| Performance | Near hand-tuned | Highest performance |
+| Development difficulty | Low | High |
+| Cross-generation compatibility | Best | Requires per-generation tuning |
-### Tile Memory Allocation
+> Note: auto mode currently only supports the compiler `-O2` option.
-In the default mode of PTO compilation, after instantiating `Tile` variables, we would need to complement them with a `TASSIGN` instruction to manually assign a dedicated buffer address that it operates on. However in auto mode, this is not required anymore. By simply instantiating the `Tile` variable the compiler will automatically allocate the buffer addresses under the hood for the user.
+## Document Index
-## PTO AUTO Documents
+| Document | Content |
+|----------|---------|
+| [Auto Mode Overview](Auto_Mode_Overview.md) | Core concepts, compiler features, comparison with Manual mode |
+| [Kernel Developer Rules](Kernel_Developer_Rules_And_Limitations.md) | Programming rules and limitations for kernel developers in Auto Mode |
+| [Library Developer Rules](Library_Developer_Rules_And_Limitations.md) | Programming rules and limitations for library developers in Auto Mode |
+| [Examples](Examples.md) | Auto Mode code examples |
-More detailed documentations of the PTO AUTO programming and compilations are organized into the following documents.
+## Related Docs
-* [PTO_AUTO_kernel_developer_rules_and_limitations](Kernel_Developer_Rules_And_Limitations_zh.md)
-* [PTO_AUTO_library_developer_rules_and_limitations](Library_Developer_Rules_And_Limitations.md)
-* [PTO AUTO Code Examples](Examples.md)
+| Document | Content |
+|----------|---------|
+| [docs/README.md](../README.md) | Documentation hub |
+| [docs/coding/README.md](../coding/README.md) | Programming model docs entry |
+| [docs/isa/README.md](../isa/README.md) | ISA instruction reference |
diff --git a/docs/auto_mode/README_zh.md b/docs/auto_mode/README_zh.md
index 474e4e90..81ad0f9e 100644
--- a/docs/auto_mode/README_zh.md
+++ b/docs/auto_mode/README_zh.md
@@ -1,106 +1,51 @@
-# PTO AUTO模式
+# PTO AUTO 文档
-## auto模式是什么
+本目录包含 PTO AUTO 模式的详细文档,帮助开发者理解并使用 Auto Mode 进行 PTO 编程。
-PTO AUTO是一种新的编程模式,主要提供以下两点优势:
+## 按任务选择
-* 降低kernel的开发难度的同时能使开发者实现必要的优化
-* 确保跨代兼容不同的昇腾硬件架构
+| 你的需求 | 从这里开始 |
+|----------|----------|
+| 什么是 Auto Mode | [Auto Mode 概述](Auto_Mode_Overview_zh.md) |
+| Kernel 开发规范与限制 | [Kernel Developer Rules](Kernel_Developer_Rules_And_Limitations_zh.md) |
+| Library 开发规范与限制 | [Library Developer Rules](Library_Developer_Rules_And_Limitations_zh.md) |
+| 代码示例 | [Examples](Examples_zh.md) |
-更具体来说,在AUTO模式下,kernel开发者不用手动为tile分配内存,也不用亲自手写不同pipe间的同步。作为替代,PTO AUTO编译器会帮助kernel开发者在不同buffer上分配内存。而且,编译器也会在PTO指令之间自动插入同步,最大化pipe之间的流水线并行。最后,kernel开发者也不用关心不同昇腾硬件架构之间的区别(尤其是关于CUBE和VECTOR交流和同步的机制)。
+## Auto Mode 是什么
-注意:auto模式目前仅支持编译器`-O2`选项。
+PTO AUTO 是一种新的编程模式,主要提供以下两点优势:
-## 简单示例
+1. **降低开发难度**的同时使开发者实现必要的优化。
+2. **确保跨代兼容**不同的昇腾硬件架构。
-一个简单的示例:逐元素的乘法。这展示了最关键的auto模式与manual模式的区别:
+在 AUTO 模式下,kernel 开发者**无需手动**为 tile 分配内存(`TASSIGN`),也**无需手动**管理不同 pipe 间的同步(`set_flag`/`wait_flag`)。编译器自动完成这些工作,同时保持良好的性能。
-### TMUL manual模式
+## Auto vs Manual 模式对比
-```cpp
-template
-__global__ AICORE void runTMul(__gm__ T __out__ *out, __gm__ T __in__ *src0, __gm__ T __in__ *src1)
-{
- using DynShapeDim5 = Shape<1, 1, 1, kGRows_, kGCols_>;
- using DynStridDim5 = Stride<1, 1, 1, kGCols_, 1>;
- using GlobalData = GlobalTensor;
- using TileData = Tile;
- TileData src0Tile(kGRows_, kGCols_);
- TileData src1Tile(kGRows_, kGCols_);
- TileData dstTile(kGRows_, kGCols_);
+| 方面 | Auto Mode | Manual Mode |
+|------|-----------|-------------|
+| Tile 地址分配 | 编译器自动 | 作者显式 `TASSIGN` |
+| 同步管理 | 编译器自动 | 作者显式 `set_flag`/`wait_flag` |
+| 数据搬运 | 编译器自动 `TLOAD`/`TSTORE` | 作者显式 `TLOAD`/`TSTORE` |
+| 性能 | 接近手工调优 | 最高性能 |
+| 开发难度 | 低 | 高 |
+| 跨代兼容性 | 最好 | 需要针对不同代际调整 |
- TASSIGN(src0Tile, 0x0 + 0x400 * block_idx);
- TASSIGN(src1Tile, 0x4000 + 0x400 * block_idx);
- TASSIGN(dstTile, 0x8000 + 0x400 * block_idx);
+> 注意:auto 模式目前仅支持编译器 `-O2` 选项。
- int offset = (block_idx / 4) * (64 * 16) + (block_idx % 4) * 16;
- GlobalData src0Global(src0 + offset);
- GlobalData src1Global(src1 + offset);
- GlobalData dstGlobal(out + offset);
+## 文档列表
- TLOAD(src0Tile, src0Global);
- TLOAD(src1Tile, src1Global);
- set_flag(PIPE_MTE2, PIPE_V, EVENT_ID0);
- wait_flag(PIPE_MTE2, PIPE_V, EVENT_ID0);
- TMUL(dstTile, src0Tile, src1Tile);
- set_flag(PIPE_V, PIPE_MTE3, EVENT_ID0);
- wait_flag(PIPE_V, PIPE_MTE3, EVENT_ID0);
- TSTORE(dstGlobal, dstTile);
+| 文档 | 内容 |
+|------|------|
+| [Auto Mode 概述](Auto_Mode_Overview_zh.md) | Auto Mode 核心概念、编译器特性、与 Manual 模式对比 |
+| [Kernel Developer Rules](Kernel_Developer_Rules_And_Limitations_zh.md) | kernel 开发者在 Auto Mode 下的编程规范与限制 |
+| [Library Developer Rules](Library_Developer_Rules_And_Limitations_zh.md) | 库开发者在 Auto Mode 下的编程规范与限制 |
+| [Examples](Examples_zh.md) | Auto Mode 代码示例 |
- out = dstGlobal.data();
-}
-```
+## 相关文档
-### TMUL AUTO模式
-
-```cpp
-template
-__global__ AICORE void runTMul(__gm__ T __out__ *out, __gm__ T __in__ *src0, __gm__ T __in__ *src1)
-{
- using DynShapeDim5 = Shape<1, 1, 1, kGRows_, kGCols_>;
- using DynStridDim5 = Stride<1, 1, 1, kGCols_, 1>;
- using GlobalData = GlobalTensor;
- using TileData = Tile;
-
- TileData src0Tile(kGRows_, kGCols_);
- TileData src1Tile(kGRows_, kGCols_);
- TileData dstTile(kGRows_, kGCols_);
-
- int offset = (block_idx / 4) * (64 * 16) + (block_idx % 4) * 16;
- GlobalData src0Global(src0 + offset);
- GlobalData src1Global(src1 + offset);
- GlobalData dstGlobal(out + offset);
-
- TLOAD(src0Tile, src0Global);
- TLOAD(src1Tile, src1Global);
- TMUL(dstTile, src0Tile, src1Tile);
- TSTORE(dstGlobal, dstTile);
-
- out = dstGlobal.data();
-}
-```
-
-## PTO AUTO编译器特性
-
-### 不同架构之间的兼容性
-
-PTO AUTO编译器确保同一个PTO源码程序能在不同昇腾架构上编译和运行,同时确保性能。
-
-### 自动同步
-
-在manual模式下,程序员需要使用PTO的Event机制,精准地在必要的源码位置上手动调用同步指令来确保正确的结果和性能。这非常繁琐且容易出错。
-
-Auto模式编译器让程序员避免了这个麻烦。编译器会自动在需要的位置插入同步,确保正确的结果和较好的性能。
-
-### Tile内存分配
-
-在manual模式下,当用户声定义一个Tile变量后,需要显式调用`TASSIGN`来为这个Tile分配在指定内存空间里的内存地址。
-在auto模式下,用户不需要手动分配内存,只需要定义Tile变量即可;编译器会自动为所有Tile在正确的buffer上分配内存地址。
-
-## PTO AUTO文档
-
-更多PTO AUTO的详细文档如下:
-
-* [PTO_AUTO_kernel_developer_rules_and_limitations](Kernel_Developer_Rules_And_Limitations_zh.md)
-* [PTO_AUTO_library_developer_rules_and_limitations](Library_Developer_Rules_And_Limitations_zh.md)
-* [PTO AUTO Code Examples](Examples_zh.md)
+| 文档 | 内容 |
+|------|------|
+| [docs/README_zh.md](../README_zh.md) | 文档总入口 |
+| [docs/coding/README_zh.md](../coding/README_zh.md) | 编程模型文档入口 |
+| [docs/isa/README_zh.md](../isa/README_zh.md) | ISA 指令参考 |
diff --git a/docs/coding/README.md b/docs/coding/README.md
index 31d772af..fb51684c 100644
--- a/docs/coding/README.md
+++ b/docs/coding/README.md
@@ -1,20 +1,69 @@
# docs/coding/
-This directory describes the **PTO Tile Lib programming model as seen from C++** (Tiles, GlobalTensor, events, scalar parameters) and provides guidance for extending the library.
+This directory describes the **PTO Tile Library programming model as seen from C++** (Tiles, GlobalTensor, events, scalar parameters) and provides guidance for extending the library.
-If you are looking for the *ISA reference*, start from [docs/isa/README.md](../isa/README.md).
+If you are looking for the **ISA reference**, start from [docs/isa/README.md](../isa/README.md).
-## Documents
+## Choose by Task
-- [High-level model and PTO-Auto/PTO-Manual](ProgrammingModel.md)
-- [Hands-on tutorial (write your first kernels)](tutorial.md)
-- [More tutorial examples](tutorials/README.md)
-- [Debugging and assertion lookup](debug.md)
-- [Tile abstraction and layout/valid-region rules](Tile.md)
-- [Global memory tensors (shape/stride/layout)](GlobalTensor.md)
-- [Events and synchronization model](Event.md)
-- [Scalar values, type mnemonics, and enums](Scalar.md)
+| Your goal | Start here |
+|-----------|-----------|
+| First time learning PTO | [Hands-on tutorial](tutorial.md) |
+| Understanding Tile abstraction and valid regions | [Tile programming model](Tile.md) |
+| Understanding global memory tensors | [GlobalTensor](GlobalTensor.md) |
+| Understanding events and synchronization | [Events and synchronization](Event.md) |
+| Understanding Auto Mode | [Auto Mode overview](../auto_mode/Auto_Mode_Overview.md) |
+| Understanding the compilation pipeline | [Compilation process](compilation-process.md) |
+| Finding performance bottlenecks | [Performance optimization](opt.md) |
+| Understanding operator fusion | [Operator fusion](operator-fusion.md) |
+| Debugging and error handling | [Debugging guide](debug.md), [Error codes](error-codes.md) |
+| Multi-core programming | [Multi-core programming](multi-core-programming.md) |
+| Memory optimization | [Memory optimization](memory-optimization.md) |
+| PTO vs other frameworks | [PTO comparison](pto-comparison.md) |
-## Related
+## Document Index
-- [PTO abstract machine model](../machine/README.md)
+### Foundations
+
+- [Hands-on tutorial (write your first kernel)](tutorial.md) — Step-by-step guide to your first PTO kernel
+- [More tutorial examples](tutorials/README.md) — Additional getting-started examples
+- [Tile abstraction and layout/valid-region rules](Tile.md) — Tile model in depth
+- [Global memory tensors (shape/stride/layout)](GlobalTensor.md) — GM tensor types
+- [Events and synchronization model](Event.md) — Event recording, waiting, and synchronization
+- [Scalar values, type mnemonics, and enums](Scalar.md) — Scalar parameters and type aliases
+- [Auto Mode overview](../auto_mode/Auto_Mode_Overview.md) — Compiler-driven resource and sync management
+
+### Build and Compilation
+
+- [Compilation process](compilation-process.md) — Full pipeline from source to binary
+- [CPU Simulator](cpu_sim.md) — Running PTO code on CPU
+
+### Debugging and Error Handling
+
+- [Debugging and assertion lookup](debug.md) — Debugging strategies
+- [Error codes](error-codes.md) — Error code reference
+
+### Advanced Topics
+
+- [Performance optimization](opt.md) — Performance analysis and tuning guidance
+- [Performance best practices](performance-best-practices.md) — Best practices and performance tips
+- [Operator fusion](operator-fusion.md) — Tensor fusion techniques
+- [Memory optimization](memory-optimization.md) — Memory optimization strategies
+- [Pipeline parallelism](pipeline-parallel.md) — Pipeline-parallel programming
+- [Multi-core programming](multi-core-programming.md) — Multi-core programming model
+- [Version compatibility](version-compatibility.md) — Compatibility and migration
+- [Framework integration](framework-integration.md) — Integration with PyTorch and other frameworks
+
+### Reference
+
+- [PTO comparison with other frameworks](pto-comparison.md) — PTO vs TVM, CUTLASS, etc.
+- [References](references.md) — Bibliography and further reading
+- [ConvTile](ConvTile.md) — Conv2D tile optimization
+
+## Related Docs
+
+| Document | Content |
+|----------|---------|
+| [PTO abstract machine model](../machine/README.md) | Abstract execution model |
+| [docs/README.md](../README.md) | Documentation hub |
+| [docs/isa/README.md](../isa/README.md) | ISA instruction reference |
diff --git a/docs/coding/README_zh.md b/docs/coding/README_zh.md
index 55bdc4c5..e0e32892 100644
--- a/docs/coding/README_zh.md
+++ b/docs/coding/README_zh.md
@@ -1,20 +1,69 @@
# docs/coding/
-本目录描述 **从 C++ 角度看到的 PTO Tile Lib 编程模型**(Tiles、GlobalTensor、事件、标量参数),并提供扩展库的指导。
+本目录从 **C++ 编程视角**描述 PTO Tile Library 的编程模型(Tile、GlobalTensor、事件、标量参数),并提供扩展库的指导。
-如果你在寻找 *ISA 参考*,请从 [docs/isa/README_zh.md](../isa/README_zh.md) 开始。
+如果你在寻找 **ISA 参考**,请从 [docs/isa/README_zh.md](../isa/README_zh.md) 开始。
-## 文档列表
+## 按任务选择
-- [高层模型与 PTO-Auto / PTO-Manual](ProgrammingModel_zh.md)
-- [上手教程(编写第一个 kernel)](tutorial_zh.md)
-- [更多教程示例](tutorials/README_zh.md)
-- [调试与断言查找](debug_zh.md)
-- [Tile 抽象与布局/有效区域规则](Tile_zh.md)
-- [全局内存张量(shape/stride/layout)](GlobalTensor_zh.md)
-- [事件与同步模型](Event_zh.md)
-- [标量值、类型助记符与枚举](Scalar_zh.md)
+| 你的目标 | 从这里开始 |
+|----------|----------|
+| 学习 PTO 编程(第一次) | [上手教程](tutorial_zh.md) |
+| 理解 Tile 抽象与有效区域 | [Tile 编程模型](Tile_zh.md) |
+| 理解全局内存张量 | [GlobalTensor](GlobalTensor_zh.md) |
+| 理解事件与同步 | [事件与同步](Event_zh.md) |
+| 理解 Auto Mode | [Auto Mode 概述](../auto_mode/Auto_Mode_Overview_zh.md) |
+| 理解编译流程 | [编译流程](compilation-process_zh.md) |
+| 定位性能瓶颈 | [性能优化](opt_zh.md) |
+| 理解张量融合 | [算子融合](operator-fusion_zh.md) |
+| 调试与错误处理 | [调试指南](debug_zh.md)、[错误码](error-codes_zh.md) |
+| 多核编程 | [多核编程](multi-core-programming_zh.md) |
+| 内存优化 | [内存优化](memory-optimization_zh.md) |
+| PTO 与其他框架对比 | [PTO 对比](pto-comparison_zh.md) |
+
+## 文档索引
+
+### 基础
+
+- [上手教程(编写第一个 kernel)](tutorial_zh.md) — 一步一步写出你的第一个 PTO kernel
+- [更多教程示例](tutorials/README_zh.md) — 更多上手示例
+- [Tile 编程模型](Tile_zh.md) — Tile 抽象与布局/有效区域规则
+- [GlobalTensor](GlobalTensor_zh.md) — 全局内存张量(shape/stride/layout)
+- [事件与同步](Event_zh.md) — 事件与同步模型
+- [标量值、类型与枚举](Scalar_zh.md) — 标量参数、类型助记符与枚举
+- [Auto Mode 概述](../auto_mode/Auto_Mode_Overview_zh.md) — 编译器自动管理资源与同步
+
+### 编译与构建
+
+- [编译流程](compilation-process_zh.md) — PTO 程序从源码到二进制的完整流程
+- [CPU Simulator](cpu_sim.md) — 如何在 CPU 上运行 PTO 代码
+
+### 调试与错误处理
+
+- [调试指南](debug_zh.md) — 调试与断言查找
+- [错误码](error-codes_zh.md) — 错误码说明
+
+### 高级话题
+
+- [性能优化](opt_zh.md) — 性能分析与调优建议
+- [性能最佳实践](performance-best-practices_zh.md) — 最佳实践与性能要点
+- [算子融合](operator-fusion_zh.md) — 张量融合技术
+- [内存优化](memory-optimization_zh.md) — 内存优化策略
+- [流水线并行](pipeline-parallel_zh.md) — 流水线并行编程
+- [多核编程](multi-core-programming_zh.md) — 多核编程模型
+- [版本兼容性](version-compatibility_zh.md) — 版本兼容性与迁移
+- [框架集成](framework-integration_zh.md) — 与 PyTorch 等框架集成
+
+### 参考
+
+- [PTO 对比其他框架](pto-comparison_zh.md) — PTO 与 TVM、CUTLASS 等的对比
+- [参考资料](references_zh.md) — 参考资料汇总
+- [ConvTile](ConvTile.md) — Conv2D tile 优化
## 相关文档
-- [PTO 抽象机器模型](../machine/README_zh.md)
+| 文档 | 内容 |
+|------|------|
+| [PTO 抽象机器模型](../machine/README_zh.md) | 抽象执行模型 |
+| [docs/README_zh.md](../README_zh.md) | 文档总入口 |
+| [docs/isa/README_zh.md](../isa/README_zh.md) | ISA 指令参考 |
diff --git a/docs/coding/tutorials/README_zh.md b/docs/coding/tutorials/README_zh.md
index 83511595..aa2d919e 100644
--- a/docs/coding/tutorials/README_zh.md
+++ b/docs/coding/tutorials/README_zh.md
@@ -1,9 +1,27 @@
-# PTO 教程(更多示例)
+# PTO Tutorials (更多示例)
-本目录收集更长、更偏实战的示例讲解,用于补充 `docs/coding/tutorial_zh.md`。
+本目录收集更长、更偏实战的示例讲解,用于补充 `docs/coding/tutorial.md`。
-## 内容
+## 按任务选择
-- 向量加法:分块、边界 mask、以及 ping-pong(双缓冲)概念结构:`docs/coding/tutorials/vec-add_zh.md`
-- 行 softmax 模式(attention 的基础组件):`docs/coding/tutorials/row-softmax_zh.md`
-- GEMM 模式与常见 tile 类型/布局:`docs/coding/tutorials/gemm_zh.md`
+| 示例 | 说明 | 难度 |
+|------|------|------|
+| [向量加法 + ping-pong](./vec-add_zh.md) | 向量加法、分块、边界 mask、双缓冲流水线 | 入门 |
+| [行 softmax](./row-softmax_zh.md) | attention 的基础组件,行级归一化模式 | 进阶 |
+| [GEMM](./gemm_zh.md) | 矩阵乘模式与常见 tile 类型 / 布局 | 进阶 |
+
+## 文档
+
+| 文档 | 说明 |
+|------|------|
+| [向量加法 + ping-pong](./vec-add_zh.md) | 向量加法:分块、边界 mask、以及 ping-pong(双缓冲)概念结构 |
+| [行 softmax](./row-softmax_zh.md) | 行 softmax 模式(attention 的基础组件) |
+| [GEMM](./gemm_zh.md) | GEMM 模式与常见 tile 类型/布局 |
+
+## 相关文档
+
+| 文档 | 内容 |
+|------|------|
+| [docs/coding/tutorial_zh.md](../tutorial_zh.md) | 上手指南 |
+| [docs/coding/Tile_zh.md](../Tile_zh.md) | Tile 编程模型 |
+| [docs/coding/opt_zh.md](../opt_zh.md) | 性能优化 |
diff --git a/docs/isa/README.md b/docs/isa/README.md
index 8b436c46..f751b4c1 100644
--- a/docs/isa/README.md
+++ b/docs/isa/README.md
@@ -1,98 +1,54 @@
-
-
-
-
-# PTO ISA Manual And Reference
-
-This directory is the canonical PTO ISA tree. It combines the architecture manual, the instruction set guides, the instruction set contracts, and the exact instruction-reference groupings in one place.
-
-## Textual Assembly Inside PTO ISA
-
-This tree is the canonical PTO ISA manual. Textual assembly spelling belongs to the PTO ISA syntax instruction set, not to a second parallel architecture manual.
-
-- PTO ISA defines architecture-visible semantics, legality, state, ordering, target-profile boundaries, and the visible behavior of `pto.t*`, `pto.v*`, `pto.*`, and other operations.
-- PTO-AS is the assembler-facing spelling used to write those operations and operands. It is part of how PTO ISA is expressed, not a separate ISA with different semantics.
-
-If the question is "what does this legal PTO program mean across CPU, A2/A3, and A5?", stay in this tree. If the question is "what is the operand shape or textual spelling of this operation?", use the syntax-and-operands pages in this same tree.
-
-## Start Here
-
-## Axis Reduce / Expand
-- [TROWSUM](TROWSUM.md) - Reduce each row by summing across columns.
-- [TROWPROD](TROWPROD.md) - Reduce each row by multiplying across columns.
-- [TCOLSUM](TCOLSUM.md) - Reduce each column by summing across rows.
-- [TCOLPROD](TCOLPROD.md) - Reduce each column by multiplying across rows.
-- [TCOLMAX](TCOLMAX.md) - Reduce each column by taking the maximum across rows.
-- [TROWMAX](TROWMAX.md) - Reduce each row by taking the maximum across columns.
-- [TROWMIN](TROWMIN.md) - Reduce each row by taking the minimum across columns.
-- [TROWARGMAX](TROWARGMAX.md) - Get the column index of the maximum element for each row.
-- [TROWARGMIN](TROWARGMIN.md) - Get the column index of the minimum element for each row.
-- [TCOLARGMAX](TCOLARGMAX.md) - Get the row index of the maximum element for each column.
-- [TCOLARGMIN](TCOLARGMIN.md) - Get the row index of the minimum element for each column.
-- [TROWEXPAND](TROWEXPAND.md) - Broadcast the first element of each source row across the destination row.
-- [TROWEXPANDDIV](TROWEXPANDDIV.md) - Row-wise broadcast divide: divide each row of `src0` by a per-row scalar vector `src1`.
-- [TROWEXPANDMUL](TROWEXPANDMUL.md) - Row-wise broadcast multiply: multiply each row of `src0` by a per-row scalar vector `src1`.
-- [TROWEXPANDSUB](TROWEXPANDSUB.md) - Row-wise broadcast subtract: subtract a per-row scalar vector `src1` from each row of `src0`.
-- [TROWEXPANDADD](TROWEXPANDADD.md) - Row-wise broadcast add: add a per-row scalar vector.
-- [TROWEXPANDMAX](TROWEXPANDMAX.md) - Row-wise broadcast max with a per-row scalar vector.
-- [TROWEXPANDMIN](TROWEXPANDMIN.md) - Row-wise broadcast min with a per-row scalar vector.
-- [TROWEXPANDEXPDIF](TROWEXPANDEXPDIF.md) - Row-wise exp-diff: compute exp(src0 - src1) with per-row scalars.
-- [TCOLMIN](TCOLMIN.md) - Reduce each column by taking the minimum across rows.
-- [TCOLEXPAND](TCOLEXPAND.md) - Broadcast the first element of each source column across the destination column.
-- [TCOLEXPANDDIV](TCOLEXPANDDIV.md) - Column-wise broadcast divide: divide each column by a per-column scalar vector.
-- [TCOLEXPANDMUL](TCOLEXPANDMUL.md) - Column-wise broadcast multiply: multiply each column by a per-column scalar vector.
-- [TCOLEXPANDADD](TCOLEXPANDADD.md) - Column-wise broadcast add with per-column scalar vector.
-- [TCOLEXPANDMAX](TCOLEXPANDMAX.md) - Column-wise broadcast max with per-column scalar vector.
-- [TCOLEXPANDMIN](TCOLEXPANDMIN.md) - Column-wise broadcast min with per-column scalar vector.
-- [TCOLEXPANDSUB](TCOLEXPANDSUB.md) - Column-wise broadcast subtract: subtract a per-column scalar vector from each column.
-- [TCOLEXPANDEXPDIF](TCOLEXPANDEXPDIF.md) - Column-wise exp-diff: compute exp(src0 - src1) with per-column scalars.
-
-## Model Layers
-
-Reading order matches the manual chapter map: programming and machine models, then syntax and state, then memory, then opcode reference.
-
-- [Programming model](programming-model/tiles-and-valid-regions.md)
-- [Machine model](machine-model/execution-agents.md)
-- [Syntax and operands](syntax-and-operands/assembly-model.md)
-- [Type system](state-and-types/type-system.md)
-- [Location intent and legality](state-and-types/location-intent-and-legality.md)
-- [Memory model](memory-model/consistency-baseline.md)
-
-## Complex
-- [TPRINT](TPRINT.md) - Debug/print elements from a tile (implementation-defined).
-- [TMRGSORT](TMRGSORT.md) - Merge sort for multiple sorted lists (implementation-defined element format and layout).
-- [TSORT32](TSORT32.md) - Sort each 32-element block of `src` together with the corresponding indices from `idx`, and write the sorted value-index pairs into `dst`.
-- [TGATHER](TGATHER.md) - Gather/select elements using either an index tile or a compile-time mask pattern.
-- [TCI](TCI.md) - Generate a contiguous integer sequence into a destination tile.
-- [TTRI](TTRI.md) - Generate a triangular (lower/upper) mask tile.
-- [TRANDOM](TRANDOM.md) - Generates random numbers in the destination tile using a counter-based cipher algorithm.
-- [TPARTADD](TPARTADD.md) - Partial elementwise add with implementation-defined handling of mismatched valid regions.
-- [TPARTMUL](TPARTMUL.md) - Partial elementwise multiply with implementation-defined handling of mismatched valid regions.
-- [TPARTMAX](TPARTMAX.md) - Partial elementwise max with implementation-defined handling of mismatched valid regions.
-- [TPARTMIN](TPARTMIN.md) - Partial elementwise min with implementation-defined handling of mismatched valid regions.
-- [TGATHERB](TGATHERB.md) - Gather elements using byte offsets.
-- [TSCATTER](TSCATTER.md) - Scatter rows of a source tile into a destination tile using per-element row indices.
-- [TQUANT](TQUANT.md) - Quantize a tile (e.g. FP32 to FP8) producing exponent/scaling/max outputs.
-
-- [Instruction overview](instruction-surfaces/README.md)
-- [Instruction set contracts](instruction-families/README.md)
-- [Format of instruction descriptions](reference/format-of-instruction-descriptions.md)
-- [Tile instruction reference](tile/README.md)
-- [Vector instruction reference](vector/README.md)
-- [Scalar and control reference](scalar/README.md)
-- [Other and communication reference](other/README.md)
-- [Common conventions](conventions.md)
-
-## Supporting Reference
-
-- [Reference notes](reference/README.md) (glossary, diagnostics, portability, source of truth)
-
-## Compatibility Wrappers
-
-The grouped instruction set trees under `tile/`, `vector/`, `scalar/`, and `other/` are the canonical PTO ISA paths.
-
-Some older root-level tile pages such as `TADD.md`, `TLOAD.md`, and `TMATMUL.md` now remain only as compatibility wrappers so existing links do not break immediately. New PTO ISA documentation should link to the grouped instruction set paths, especially the standalone per-op pages under:
-
-- `docs/isa/tile/ops/`
-- `docs/isa/vector/ops/`
-- `docs/isa/scalar/ops/`
+# docs/isa/
+
+This directory is the top-level index for the PTO ISA manual. It provides a guided navigation through all instruction references and conceptual documentation.
+
+## How This Manual Is Organized
+
+The manual is organized into five logical layers:
+
+| Layer | Contents | Audience |
+|-------|----------|----------|
+| **1. Foundations** | Introduction, programming model, machine model | Everyone — start here |
+| **2. Syntax and Semantics** | Assembly model, operands, types, memory model | Compiler developers, kernel authors |
+| **3. Instruction Surface** | Instruction-set overview and contracts | All users |
+| **4. Reference Manual** | Tile, vector, scalar, and communication reference | Performance engineers, kernel authors |
+| **5. Appendices** | Format guidelines, diagnostics, glossary, portability | Everyone |
+
+## Key Entry Points
+
+| Document | Content |
+|----------|---------|
+| [What is PTO ISA?](./introduction/what-is-pto-visa.md) | Core concepts and where PTO fits in the software stack |
+| [Tiles and Valid Regions](./programming-model/tiles-and-valid-regions.md) | The tile abstraction — PTO's primary programming object |
+| [Execution Agents and Profiles](./machine-model/execution-agents.md) | Execution hierarchy, pipelines, target profiles |
+| [Instruction Surfaces Overview](./instruction-surfaces/README.md) | Map of all four instruction sets and when to use each |
+| [Per-Instruction Reference](./tile/README.md) | Complete catalog organized by category |
+| [Format of instruction descriptions](./reference/format-of-instruction-descriptions.md) | How to read each per-op page |
+
+## Four Instruction Sets
+
+| Instruction Set | Prefix | Operations | Reference |
+|----------------|--------|------------|-----------|
+| **Tile** | `pto.t*` | ~120 | [Tile reference](./tile/README.md) |
+| **Vector** | `pto.v*` | ~99 | [Vector reference](./vector/README.md) |
+| **Scalar & Control** | `pto.*` | ~60 | [Scalar reference](./scalar/README.md) |
+| **Communication** | `pto.*` | ~24 | [Communication reference](./other/README.md) |
+
+## By Task
+
+| What you're doing | Start here |
+|-------------------|------------|
+| Writing a matrix multiplication kernel | [Tile → Matrix ops](./tile/matrix-and-matrix-vector.md) |
+| Optimizing elementwise operations | [Tile → Elementwise ops](./tile/elementwise-tile-tile.md) |
+| Setting up data movement (GM ↔ tile) | [Tile memory ops](./tile/memory-and-data-movement.md) |
+| Hand-tuning vector kernels | [Vector instructions](./vector/README.md) |
+| Using per-lane masking and predicates | [Vector → Predicate ops](./vector/predicate-and-materialization.md) |
+| Implementing collective communication | [Communication instructions](./other/README.md) |
+| Understanding Auto vs Manual mode | [Auto vs Manual](./programming-model/auto-vs-manual.md) |
+| Checking target profile support | [Execution agents](./machine-model/execution-agents.md) |
+
+## See Also
+
+- [docs/README.md](../README.md) — Documentation hub
+- [docs/coding/README.md](../coding/README.md) — Programming model docs
+- [PTO-AS specification](../assembly/PTO-AS.md) — Assembly syntax and grammar
diff --git a/docs/isa/TALIAS_zh.md b/docs/isa/TALIAS_zh.md
index e7cde27a..df548b0c 100644
--- a/docs/isa/TALIAS_zh.md
+++ b/docs/isa/TALIAS_zh.md
@@ -1,38 +1,36 @@
-# TALIAS
+# pto.talias
-## 指令示意图
+`pto.talias` 属于[布局与重排指令](./tile/layout-and-rearrangement_zh.md)集。
-
+## 概述
-## 简介
+`TALIAS` 创建一个与源 Tile 共享底层存储的别名视图。它不复制数据,只改变后续代码观察这块存储的逻辑方式。`TALIAS` 的结果与源 Tile 指向同一块底层存储,通过任一别名写入的数据都会对共享该存储的其他别名立即可见。
-`TALIAS` 创建一个与源 Tile 共享底层存储的别名视图。它不复制数据,只改变后续代码观察这块存储的逻辑方式。
+## 机制
-这类操作通常用于:
+### 数学语义
-- 在同一块 tile buffer 上建立新的 shape 或切片视图
-- 把同一份数据交给不同的后续操作,以不同逻辑边界读取
-- 避免为了得到子视图或重解释视图而额外搬运数据
-
-## 语义
+```math
+\mathrm{dst} \equiv \mathrm{src} \quad \text{其中 } \mathrm{storage}(\mathrm{dst}) = \mathrm{storage}(\mathrm{src})
+```
-`TALIAS` 的结果与源 Tile 指向同一块底层存储。通过任一别名写入的数据,都会对共享该存储的其他别名立即可见。
+别名视图共享同一底层 buffer,但可具有不同的 shape、stride 或 layout 解释方式。
-它本身不定义新的数值变换;后续行为仍由消费该别名的具体指令决定,并且默认只在目标 valid region 内具有架构意义。
+## 语法
-## 汇编语法
+### PTO-AS
-PTO-AS 形式见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.talias ...
```
### AS Level 2(DPS)
-```text
+```mlir
pto.talias ins(...) outs(%dst : !pto.tile_buf<...>)
```
@@ -40,17 +38,61 @@ pto.talias ins(...) outs(%dst : !pto.tile_buf<...>)
声明于 `include/pto/common/pto_instr.hpp`。
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| `src` | 输入 | 源 Tile,提供底层存储 |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `dst` | Tile | 与源共享底层存储的别名视图 |
+
+## 副作用
+
+通过任一别名写入的数据,对共享该存储的其他别名立即可见。
+
## 约束
-- `TALIAS` 不会修复原始 Tile 的非法 shape、layout 或 location intent。
-- alias 后得到的 Tile 仍需满足后续消费者指令的合法性要求。
-- 若多个别名在没有额外同步的情况下并发读写,共享存储的可见顺序由后续使用这些别名的指令负责建立。
+- `TALIAS` 不会修复原始 Tile 的非法 shape、layout 或 location intent
+- alias 后得到的 Tile 仍需满足后续消费者指令的合法性要求
+- 若多个别名在没有额外同步的情况下并发读写,共享存储的可见顺序由后续使用这些别名的指令负责建立
+
+## 异常与非法情形
+
+- 若源 Tile 本身未绑定有效存储,行为未定义
+- 若别名视图被后续指令以不兼容的 shape 或 layout 使用,结果未定义
## 示例
-`TALIAS` 常与子视图、局部重排和“同存储多视图”模式配合使用。更具体的用法见相关的 tile 搬运与布局页。
+### C++
+
+`TALIAS` 常与子视图、局部重排和"同存储多视图"模式配合使用。
+
+```cpp
+#include
+
+using namespace pto;
+
+void example_alias() {
+ using TileT = Tile;
+ TileT src;
+ // 创建别名视图
+ auto alias_view = TALIAS(src);
+ // alias_view 与 src 共享底层存储
+}
+```
+
+### PTO-AS
+
+```mlir
+# 创建别名视图
+%dst = pto.talias %src : (!pto.tile<...>) -> !pto.tile<...>
+```
## 相关页面
-- [布局与重排指令集](./tile/layout-and-rearrangement_zh.md)
+- 指令集总览:[布局与重排指令](./tile/layout-and-rearrangement_zh.md)
- [Tile 与有效区域](./programming-model/tiles-and-valid-regions_zh.md)
diff --git a/docs/isa/TASSIGN_zh.md b/docs/isa/TASSIGN_zh.md
index c5395285..552e07be 100644
--- a/docs/isa/TASSIGN_zh.md
+++ b/docs/isa/TASSIGN_zh.md
@@ -1,24 +1,18 @@
-# TASSIGN
+# pto.tassign
-## 指令示意图
+`pto.tassign` 属于[同步与配置](./tile/sync-and-config_zh.md)指令集。
-
+## 概述
-## 简介
+将 Tile 对象绑定到实现定义的片上地址(手动放置)。TASSIGN 通常在将 SSA tile 映射到物理存储时由缓冲化/降级引入。
-将 Tile 对象绑定到实现定义的片上地址(手动放置)。
+## 机制
-## 数学语义
+该指令将 Tile 或 GlobalTensor 绑定到指定地址。对于 Tile,它设置片上缓冲区地址;对于 GlobalTensor,它绑定主机内存指针。编译时地址重载执行静态边界检查以确保地址有效性。
-不适用。
+## 语法
-## 汇编语法
-
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
-
-`TASSIGN` 通常在将 SSA tile 映射到物理存储时由缓冲化/降级引入。
-
-同步形式:
+### PTO-AS
```text
tassign %tile, %addr : !pto.tile<...>, index
@@ -26,13 +20,13 @@ tassign %tile, %addr : !pto.tile<...>, index
### AS Level 1(SSA)
-```text
+```mlir
pto.tassign %tile, %addr : !pto.tile<...>, dtype
```
### AS Level 2(DPS)
-```text
+```mlir
pto.tassign ins(%tile, %addr : !pto.tile_buf<...>, dtype)
```
@@ -56,22 +50,21 @@ template
PTO_INST void TASSIGN(T& obj);
```
-将 `obj` 绑定到片上地址 `Addr`。由于 `Addr` 是非类型模板参数,编译器通过 `static_assert`
-执行以下**编译时**检查:
+将 `obj` 绑定到片上地址 `Addr`。由于 `Addr` 是非类型模板参数,编译器通过 `static_assert` 执行编译时检查:
| 检查项 | 条件 | 断言 ID | 错误信息 |
-|--------|------|---------|----------|
-| 内存空间存在 | `capacity > 0` | SA-0351 | 当前架构不支持该内存空间。 |
-| Tile 可放入内存 | `tile_size <= capacity` | SA-0352 | Tile 存储大小超出内存空间容量。 |
-| 地址未越界 | `Addr + tile_size <= capacity` | SA-0353 | addr + tile_size 超出内存空间容量(越界)。 |
-| 地址对齐 | `Addr % alignment == 0` | SA-0354 | addr 未按目标内存空间要求对齐。 |
+| --- | --- | --- | --- |
+| 内存空间存在 | capacity > 0 | SA-0351 | 当前架构不支持该内存空间。 |
+| Tile 可放入内存 | tile_size <= capacity | SA-0352 | Tile 存储大小超出内存空间容量。 |
+| 地址未越界 | Addr + tile_size <= capacity | SA-0353 | addr + tile_size 超出内存空间容量(越界)。 |
+| 地址对齐 | Addr % alignment == 0 | SA-0354 | addr 未按目标内存空间要求对齐。 |
修复建议请参阅 `docs/coding/debug.md`(修复方案 `FIX-A12`)。
-内存空间、容量和对齐由 Tile 的 `TileType`(即 `Loc` 模板参数)自动确定:
+内存空间、容量和对齐由 Tile 的 `TileType` 自动确定:
| TileType | 内存空间 | 容量 (A2A3) | 容量 (A5) | 容量 (Kirin9030) | 容量 (KirinX90) | 对齐 |
-|----------|----------|-------------|-----------|------------------|-----------------|------|
+| --- | --- | --- | --- | --- | --- | --- |
| Vec | UB | 192 KB | 256 KB | 128 KB | 128 KB | 32 B |
| Mat | L1 | 512 KB | 512 KB | 512 KB | 1024 KB | 32 B |
| Left | L0A | 64 KB | 64 KB | 32 KB | 64 KB | 32 B |
@@ -86,15 +79,43 @@ PTO_INST void TASSIGN(T& obj);
**注意:** 该重载仅适用于 `Tile` 和 `ConvTile` 类型。对于 `GlobalTensor`,请使用 `TASSIGN(obj, pointer)`(形式 1)。
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| obj | 输入/输出 | Tile 或 GlobalTensor 对象 |
+| addr | 输入 | 片上地址(形式 1)或编译时常量地址(形式 2) |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| 无 | void | 该指令为原地操作 |
+
+## 副作用
+
+该指令修改 Tile 的内部存储地址绑定。
+
## 约束
-- **实现检查**:
- - 如果 `obj` 是 Tile:
- - 在手动模式下(未定义 `__PTO_AUTO__` 时),`addr` 必须是整数类型,并被重新解释为 tile 的存储地址。
- - 在自动模式下(定义了 `__PTO_AUTO__` 时),`TASSIGN(tile, addr)` 是空操作。
- - 如果 `obj` 是 `GlobalTensor`:
- - `addr` 必须是指针类型。
- - 指向的元素类型必须匹配 `GlobalTensor::DType`。
+- 实现检查:
+ - 如果 obj 是 Tile:
+ - 在手动模式下(未定义 __PTO_AUTO__ 时),addr 必须是整数类型,并被重新解释为 tile 的存储地址
+ - 在自动模式下(定义了 __PTO_AUTO__ 时),TASSIGN(tile, addr) 是空操作
+ - 如果 obj 是 GlobalTensor:
+ - addr 必须是指针类型
+ - 指向的元素类型必须匹配 GlobalTensor::DType
+
+## 异常与非法情形
+
+- 形式 2 编译时检查失败会触发 static_assert,断言 ID 为 SA-0351、SA-0352、SA-0353 或 SA-0354
+
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| 运行时地址形式 | 支持 | 支持 | 支持 |
+| 编译时地址形式 | 支持 | 支持 | 支持 |
## 示例
@@ -173,29 +194,21 @@ void example_pingpong() {
}
```
-## 汇编示例(ASM)
-
-### 自动模式
+### PTO-AS
```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
+# 自动模式
pto.tassign %tile, %addr : !pto.tile<...>, dtype
-```
-
-### 手动模式
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
+# 手动模式
pto.tassign %tile, %addr : !pto.tile<...>, dtype
-```
-
-### PTO 汇编形式
-```text
+# PTO 汇编形式
tassign %tile, %addr : !pto.tile<...>, index
# AS Level 2 (DPS)
pto.tassign ins(%tile, %addr : !pto.tile_buf<...>, dtype)
```
+
+## 相关页面
+
+- 指令集总览:[同步与配置](./tile/sync-and-config_zh.md)
diff --git a/docs/isa/TAXPY_zh.md b/docs/isa/TAXPY_zh.md
index abc19743..1ceacd46 100644
--- a/docs/isa/TAXPY_zh.md
+++ b/docs/isa/TAXPY_zh.md
@@ -1,41 +1,91 @@
-# TAXPY
+# pto.taxpy
-## 指令示意图
+`pto.taxpy` 属于[矩阵与矩阵向量指令](./tile/matrix-and-matrix-vector_zh.md)集。
-
+## 概述
-## 简介
+AXPY 风格融合更新:将 Tile 乘以标量并累加到目标 Tile。TAXPY 计算 `dst = dst + alpha * src`,其中 alpha 为标量,src 为源 Tile。
-AXPY 风格融合更新:将 Tile 乘以标量并累加到目标 Tile。
+## 机制
-## 数学语义
+### 数学语义
-语义随指令而变化。 除非另有说明,行为都按目标 valid region 定义。
+对有效区域中的每个元素 `(i, j)`:
-## 汇编语法
+$$ \mathrm{dst}_{i,j} = \mathrm{dst}_{i,j} + \alpha \cdot \mathrm{src}_{i,j} $$
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+其中 $\alpha$ 为标量系数。行为按目标 valid region 定义。
+
+## 语法
+
+### PTO-AS
+
+参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
-%dst = pto.taxpy ...
+```mlir
+%dst = pto.taxpy %src, %alpha : (!pto.tile<...>, dtype) -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
-pto.taxpy ins(...) outs(%dst : !pto.tile_buf<...>)
+```mlir
+pto.taxpy ins(%src, %alpha : !pto.tile_buf<...>, dtype) outs(%dst : !pto.tile_buf<...>)
```
## C++ 内建接口
-声明于 `include/pto/common/pto_instr.hpp`.
+声明于 `include/pto/common/pto_instr.hpp`。
+
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| `src` | 输入 | 源 Tile |
+| `alpha` | 标量 | 缩放系数 |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `dst` | Tile(累加器) | 原地更新:$dst = dst + \alpha \cdot src$ |
+
+## 副作用
+
+`dst` 原地被修改。
## 约束
-数据类型、layout、location 和 shape 的进一步限制以对应 backend 的合法性检查为准。
+- 数据类型、layout、location 和 shape 的进一步限制以对应 backend 的合法性检查为准
+- `dst` 和 `src` 的 valid region 必须兼容
+- 标量 `alpha` 的类型必须与 tile 元素类型匹配或可隐式转换
+
+## 异常与非法情形
+
+- 若 `dst` 和 `src` 的 valid region 不匹配,行为未定义
+- 若 `alpha` 类型不兼容,编译失败
## 示例
-具体的 Auto / Manual 使用方式见 `docs/isa/` 下的相关指令页。
+### C++
+
+```cpp
+#include
+
+using namespace pto;
+
+void example() {
+ using TileT = Tile;
+ TileT dst, src;
+ float alpha = 2.5f;
+ TAXPY(dst, src, alpha);
+}
+```
+
+### PTO-AS
+
+```mlir
+# 自动模式
+%dst = pto.taxpy %src, %alpha : (!pto.tile, f32) -> !pto.tile
+```
diff --git a/docs/isa/TCMP_zh.md b/docs/isa/TCMP_zh.md
index fa239a17..15b6f60b 100644
--- a/docs/isa/TCMP_zh.md
+++ b/docs/isa/TCMP_zh.md
@@ -1,26 +1,24 @@
-# TCMP
-
-## 指令示意图
+# pto.tcmp

-## 简介
+`pto.tcmp` 属于[逐元素 Tile-Tile](./tile/elementwise-tile-tile_zh.md)指令集。
-比较两个 Tile 并写入一个打包的谓词掩码。
+## 概述
-## 数学语义
+比较两个 tile 并将结果写成打包谓词 tile。迭代域由目标 tile 的 valid region 决定。
-概念上,对于有效区域中的每个元素 `(i, j)`,定义一个谓词:
+## 机制
-$$ p_{i,j} = \left(\mathrm{src0}_{i,j}\ \mathrm{cmpMode}\ \mathrm{src1}_{i,j}\right) $$
+从语义上看,对目标 tile 的 valid region 中每个 `(i, j)`,先定义一个谓词:
-谓词掩码使用实现定义的打包布局存储在 `dst` 中。
+$$ p_{i,j} = \left(\mathrm{src0}_{i,j}\ \mathrm{cmpMode}\ \mathrm{src1}_{i,j}\right) $$
-## 汇编语法
+随后把这些谓词位按目标定义的 packed layout 写入 `dst`。也就是说,`dst` 不是"每个 lane 一个布尔数"的朴素 tile,而是某种目标定义的压缩谓词表示。程序不能假设谓词 tile 的具体编码。
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+## 语法
-同步形式:
+### PTO-AS
```text
%dst = tcmp %src0, %src1 {cmpMode = #pto.cmp} : !pto.tile<...> -> !pto.tile<...>
@@ -28,50 +26,87 @@ PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
-%dst = pto.tcmp %src0, %src1{cmpMode = #pto}: (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
+```mlir
+%dst = pto.tcmp %src0, %src1 {cmpMode = #pto.cmp} : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
-pto.tcmp ins(%src0, %src1{cmpMode = #pto}: !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
+```mlir
+pto.tcmp ins(%src0, %src1 {cmpMode = #pto.cmp}: !pto.tile_buf<...>, !pto.tile_buf<...>)
+ outs(%dst : !pto.tile_buf<...>)
```
## C++ 内建接口
-声明于 `include/pto/common/pto_instr.hpp` 和 `include/pto/common/type.hpp`:
-
```cpp
template
-PTO_INST RecordEvent TCMP(TileDataDst &dst, TileDataSrc &src0, TileDataSrc &src1, CmpMode cmpMode, WaitEvents &... events);
+PTO_INST RecordEvent TCMP(TileDataDst &dst, TileDataSrc &src0, TileDataSrc &src1,
+ CmpMode cmpMode, WaitEvents &... events);
```
+### 比较模式
+
+| 模式 | 含义 |
+| --- | --- |
+| `EQ` | 等于 |
+| `NE` | 不等于 |
+| `LT` | 小于 |
+| `LE` | 小于等于 |
+| `GT` | 大于 |
+| `GE` | 大于等于 |
+
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| `%src0` | 左 tile | 在 `dst` valid region 上逐坐标参与比较 |
+| `%src1` | 右 tile | 在 `dst` valid region 上逐坐标参与比较 |
+| `%dst` | 谓词 tile | 保存打包后的比较结果 |
+| `cmpMode` | 比较谓词 | 选择 EQ / NE / LT / LE / GT / GE |
+| `WaitEvents...` | 可选同步 | 发射前需要等待的事件 |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `%dst` | `!pto.tile<...>` | 打包后的谓词结果 tile,具体编码由目标 profile 定义 |
+
+## 副作用
+
+除产生谓词 tile 外,没有额外架构副作用。
+
## 约束
-- **实现检查 (A2A3)**:
- - 输入类型必须是以下之一:`int32_t`、`half`、`float`。
- - 输出类型必须是 `uint8_t`。
- - `src0/src1/dst` tile 位置必须是 `TileType::Vec`。
- - 静态有效边界:`TileDataSrc::ValidRow <= TileDataSrc::Rows` 且 `TileDataSrc::ValidCol <= TileDataSrc::Cols`。
- - 运行时:`src0.GetValidRow() == dst.GetValidRow()` 且 `src0.GetValidCol() == dst.GetValidCol()`。
- - 注意:`src1` 的形状/有效性在此实现中不通过显式运行时断言进行验证。
- - 对于 `TileDataSrc::DType == int32_t`,实现使用 `EQ` 比较路径,无论 `cmpMode` 如何。
-- **实现检查 (A5)**:
- - 输入类型必须是以下之一:`uint32_t`、`int32_t`、`uint16_t`、`int16_t`、`uint8_t`、`int8_t`、`float`、`half`。
- - 输出类型必须是 `uint32_t`。
- - 已实现(参见 `include/pto/npu/a5/TCmp.hpp`)。
- - A5 实现使用 `dst.GetValidRow()` / `dst.GetValidCol()` 作为迭代域,并将打包的谓词掩码写入 `dst`(目标定义的打包方式)。
-- **掩码编码**:
- - 掩码 tile 被解释为目标定义布局中的打包谓词位。
+- 迭代域是 `dst.GetValidRow() × dst.GetValidCol()`。
+- `src0` 的 validRow / validCol 必须与 `dst` 一致。
+- `src1` 的 shape / valid 在某些实现里不会做完整运行时校验,因此域外读值属于 implementation-defined。
+- 程序不能假设谓词 tile 的具体编码。
+
+## 异常与非法情形
+
+- 假设谓词 tile 是"一位一元素"的普通展开布尔 tile,会导致行为不可预期。
+- 对 `dst` 使用不符合目标定义的谓词输出 dtype,会被 verifier 或后端拒绝。
+
+## Target-Profile 限制
+
+| 检查项 | A2/A3 | A5 |
+| --- | :---: | :---: |
+| 支持输入类型 | `int32_t`、`half`、`float` | `uint32_t`、`int32_t`、`uint16_t`、`int16_t`、`uint8_t`、`int8_t`、`float`、`half` |
+| 输出谓词 dtype | `uint8_t` | `uint32_t` |
+| tile 位置 | `TileType::Vec` | `TileType::Vec` |
+| 布局 | RowMajor | RowMajor |
+| `src0` valid == `dst` valid | Required | Required |
+| `src1` validity 校验 | Not fully verified | Not fully verified |
+
+对 A2A3,若输入类型是 `int32_t`,实现里可能只走 `EQ` 比较路径;A5 则支持完整比较模式。
## 示例
-### 自动(Auto)
+### C++ 自动模式
```cpp
#include
-
using namespace pto;
void example_auto() {
@@ -83,11 +118,10 @@ void example_auto() {
}
```
-### 手动(Manual)
+### C++ 手动模式
```cpp
#include
-
using namespace pto;
void example_manual() {
@@ -102,29 +136,25 @@ void example_manual() {
}
```
-## 汇编示例(ASM)
-
-### 自动模式
+### PTO-AS
```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
-%dst = pto.tcmp %src0, %src1{cmpMode = #pto}: (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-```
+# 自动模式
+%dst = pto.tcmp %src0, %src1 {cmpMode = #pto.cmp} : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-### 手动模式
+# 手动模式
+pto.tassign %arg0, @tile(0x1000)
+pto.tassign %arg1, @tile(0x2000)
+%dst = pto.tcmp %src0, %src1 {cmpMode = #pto.cmp} : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
-%dst = pto.tcmp %src0, %src1{cmpMode = #pto}: (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-```
-
-### PTO 汇编形式
-
-```text
+# PTO 汇编形式
%dst = tcmp %src0, %src1 {cmpMode = #pto.cmp} : !pto.tile<...> -> !pto.tile<...>
# AS Level 2 (DPS)
-pto.tcmp ins(%src0, %src1{cmpMode = #pto}: !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
+pto.tcmp ins(%src0, %src1 {cmpMode = #pto.cmp}: !pto.tile_buf<...>, !pto.tile_buf<...>)
+ outs(%dst : !pto.tile_buf<...>)
```
+
+## 相关页面
+
+- 指令集总览:[逐元素 Tile-Tile](./tile/elementwise-tile-tile_zh.md)
+- 规范页:[pto.tcmp](./tile/ops/elementwise-tile-tile/tcmp_zh.md)
diff --git a/docs/isa/TCOLARGMAX_zh.md b/docs/isa/TCOLARGMAX_zh.md
index 4d90318f..599eac89 100644
--- a/docs/isa/TCOLARGMAX_zh.md
+++ b/docs/isa/TCOLARGMAX_zh.md
@@ -1,103 +1,96 @@
-# TCOLARGMAX
+# pto.tcolargmax
-## 指令示意图
+`pto.tcolargmax` 属于[归约与扩展](./tile/reduce-and-expand_zh.md)指令集。
-
-
-## 简介
+## 概述
获取每列最大值对应行索引。
-## 数学语义
+## 机制
-Let `R = src.GetValidRow()` and `C = src.GetValidCol()`. For `0 <= j < C`:
+设 `R = src.GetValidRow()`,`C = src.GetValidCol()`。对 `0 <= j < C`:
$$ \mathrm{dst}_{0,j} = \underset{0 \le i < R}{\operatorname{argmax}} \; \mathrm{src}_{i,j} $$
-## 汇编语法
+输出 tile 中每个元素为源 tile 对应列中最大值的行索引(0-based)。`tmp` 操作数用于存储中间结果(当前行索引、argmax 索引、当前最大值元素)。若 `src.GetValidRow() == 0` 或 `src.GetValidCol() == 0`,实现会直接返回。
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+A2A3 实现中 `tmp` 始终被使用;A5 实现中 `tmp` 保留但不使用。
-同步形式:
+## 语法
-```text
-%dst = tcolargmax %src : !pto.tile<...> -> !pto.tile<...>
-```
-Lowering may introduce internal scratch tiles; the C++ intrinsic requires an explicit `tmp` operand.
+### PTO-AS
-### IR Level 1(SSA)
+参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
-```text
+### AS Level 1(SSA)
+
+```mlir
%dst = pto.tcolargmax %src, %tmp : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
-### IR Level 2(DPS)
+### AS Level 2(DPS)
-```text
+```mlir
pto.tcolargmax ins(%src, %tmp : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
## C++ 内建接口
-声明于 `include/pto/common/pto_instr.hpp`:
+声明于 `include/pto/common/pto_instr.hpp`:
```cpp
template
-PTO_INST RecordEvent TCOLARGMAX(TileDataOut& dst, TileDataIn& src, TileDataTmp& tmp, WaitEvents&... events);
+PTO_INST RecordEvent TCOLARGMAX(TileDataOut &dst, TileDataIn &src, TileDataTmp &tmp, WaitEvents &... events);
```
-## 约束
+## 输入
-### 通用约束或检查
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| `%src` | 源 tile | 输入 tile,源元素类型支持数值类型 |
+| `%dst` | 目标 tile | 接收 argmax 索引结果,目标元素类型为 `uint32_t` 或 `int32_t` |
+| `%tmp` | 临时 tile | A2A3 必需(存储中间结果);A5 保留但不使用 |
+| `WaitEvents...` | 可选同步 | 发射前需要等待的事件 |
-- `dst` 和 `src` 必须为 `TileType::Vec`。
-- 由于已检查到的辅助检查仅要求 `SLayout::NoneBox`,因此 `src` 可使用 ND 或 DN 的非分形布局。
-- `dst` 必须使用标准 ND 布局:行主且非分形(`BLayout::RowMajor`、`SLayout::NoneBox`)。
-- 支持的目标元素类型:`uint32_t`、`int32_t`。
-- 编译时检查:`TileDataIn::ValidCol == 1 || TileDataIn::ValidCol == -1`。
-- 运行时检查:
- - `src.GetValidRow() != 0`
- - `src.GetValidCol() != 0`
- - `dst.GetValidRow() == 1`
- - `src.GetValidCol() == dst.GetValidCol()`
+## 预期输出
-### A2A3 实现检查
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `%dst` | `!pto.tile<1, C>` | 每列最大值的行索引(0-based) |
-- 支持的源元素类型:`half`、`float`、`uint16_t`、`uint32_t`。
-- `tmp` 的元素类型必须与 `src` 一致。
-- 在已检查到的 A2A3 实现路径中,`tmp` 用作索引跟踪和当前比较值的临时存储。
+## 副作用
-### A5 实现检查
+除产生目标 tile 外,没有额外架构副作用。
-- 支持的源元素宽度为 8 位、16 位或 32 位,因此已检查到的实现覆盖 `int8_t`、`uint8_t`、`int16_t`、`uint16_t`、`int32_t`、`uint32_t`、`half`、`float`。
-- 在已检查到的 A5 实现路径中,接口仍接收 `tmp`,但 `TCOLARGMAX_IMPL` 实际并不使用它。
+## 约束
-### A2A3 `tmp` 临时 Tile 相关说明
+- `dst` 和 `src` 必须为 `TileType::Vec`。
+- 由于辅助检查仅要求 `SLayout::NoneBox`,`src` 可使用 ND 或 DN 的非分形布局。
+- `dst` 必须使用标准 ND 布局:行主且非分形(`BLayout::RowMajor`、`SLayout::NoneBox`)。
+- 目标元素类型:`uint32_t`、`int32_t`。
+- 编译时检查:`TileDataIn::ValidCol == 1 || TileDataIn::ValidCol == -1`。
+- 运行时检查:`src.GetValidRow() != 0`、`src.GetValidCol() != 0`、`dst.GetValidRow() == 1`、`src.GetValidCol() == dst.GetValidCol()`。
+- A2A3:`tmp` 元素类型必须与 `src` 一致,`tmp` 用作索引跟踪和当前比较值的临时存储。
+- A5:`tmp` 保留但不使用,A5 使用基于向量寄存器的计算方式。
-* A2A3 实现中 `tmp` **始终被使用**,作为中间结果的临时存储空间(当前行索引、argmax 索引、当前最大值元素)。
-* `tmp` Tile 的数据类型必须与 `src` 的数据类型一致。
-* `tmp` Tile 在单行内被划分为三个区域:
- - 区域 0(`[0, tmpGapEles)`):当前行索引计数器(每行递增)。
- - 区域 1(`[tmpGapEles, 2 * tmpGapEles)`):当前最大值元素,用于比较。
- - 区域 2(`[2 * tmpGapEles, 3 * tmpGapEles)`):argmax 索引结果(最终转换后写入 `dst`)。
-* `tmpGapEles` 的确定方式:
- - 当 `srcValidCol >= elemPerRpt` 时:`tmpGapEles = elemPerRpt`。
- - 当 `srcValidCol < elemPerRpt` 时:`tmpGapEles = ceil(srcValidCol / elemPerBlock) * elemPerBlock`。
-* 当 `src` 较小时,可直接将 `tmp` Tile 大小设为与 `src` 相同;也可按以下公式根据 `src` 的 `validCol` 算出 `tmp` Tile 所需 stride:
+## 异常与非法情形
-```text
-repeats = ceil(validCol / elementPerRepeat)
-stride = ceil(repeats * 2 / elementPerBlock) * elementPerBlock + ceil(repeats / elementPerBlock) * elementPerBlock
-```
+- 非法操作数组合、不支持的数据类型、不合法布局或不支持的 target-profile 模式,会被 verifier 或后端实现拒绝。
-### A5 `tmp` 临时 Tile 相关说明
+## Target-Profile 限制
-* A5 实现中 `tmp` 临时 Tile **不使用**。A5 使用基于向量寄存器的计算方式(`__VEC_SCOPE__`),不需要临时 Tile 存储。
-* `tmp` 在 C++ 内建接口签名中保留,仅为了与 A2A3 的 API 兼容。
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| 源 `float` | Simulated | Supported | Supported |
+| 源 `half` | Simulated | Supported | Supported |
+| 源 `uint16_t` / `uint32_t` | — | Supported | Supported |
+| 源 `int8_t` / `uint8_t` / `int16_t` / `int32_t` | — | — | Supported |
+| 目标 `uint32_t` / `int32_t` | Simulated | Supported | Supported |
+| `tmp` 临时 tile | — | Required | Unused (API compat) |
## 示例
-### 自动(Auto)
+### C++ 自动模式
```cpp
#include
@@ -115,7 +108,7 @@ void example_auto() {
}
```
-### 手动(Manual)
+### C++ 手动模式
```cpp
#include
@@ -136,40 +129,23 @@ void example_manual() {
}
```
-## 汇编示例(ASM)
-
-### 自动模式
+### PTO-AS
```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
+# 自动模式
%dst = pto.tcolargmax %src, %tmp : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-```
-
-### 手动模式
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
+# 手动模式
+pto.tassign %arg0, @tile(0x1000)
+pto.tassign %arg1, @tile(0x2000)
%dst = pto.tcolargmax %src, %tmp : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-```
-
-### PTO 汇编形式
-```text
+# PTO 汇编形式
%dst = tcolargmax %src : !pto.tile<...> -> !pto.tile<...>
-# IR Level 2 (DPS)
+# AS Level 2 (DPS)
pto.tcolargmax ins(%src, %tmp : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
-
-- [x] Explore existing docs/isa for documentation style and format
-- [x] Read tcolargmax and tcolargmin A2A3 implementation in include/
-- [x] Read tcolargmax and tcolargmin A5 implementation in include/
-- [x] Read test cases for tcolargmax and tcolargmin
-- [x] Understand A2A3 vs A5 differences and tmp handling
-- [x] Write tcolargmax English documentation (docs/isa/TCOLARGMAX.md)
-- [x] Write tcolargmax Chinese documentation (docs/isa/TCOLARGMAX_zh.md)
-- [ ] Verify documentation completeness and accuracy
-
-
+
+## 相关页面
+
+- 指令集总览:[归约与扩展](./tile/reduce-and-expand_zh.md)
diff --git a/docs/isa/TCOLARGMIN_zh.md b/docs/isa/TCOLARGMIN_zh.md
index 612b5d79..258464e9 100644
--- a/docs/isa/TCOLARGMIN_zh.md
+++ b/docs/isa/TCOLARGMIN_zh.md
@@ -1,103 +1,96 @@
-# TCOLARGMIN
+# pto.tcolargmin
-## 指令示意图
+`pto.tcolargmin` 属于[归约与扩展](./tile/reduce-and-expand_zh.md)指令集。
-
-
-## 简介
+## 概述
获取每列最小值对应行索引。
-## 数学语义
+## 机制
-Let `R = src.GetValidRow()` and `C = src.GetValidCol()`. For `0 <= j < C`:
+设 `R = src.GetValidRow()`,`C = src.GetValidCol()`。对 `0 <= j < C`:
$$ \mathrm{dst}_{0,j} = \underset{0 \le i < R}{\operatorname{argmin}} \; \mathrm{src}_{i,j} $$
-## 汇编语法
+输出 tile 中每个元素为源 tile 对应列中最小值的行索引(0-based)。`tmp` 操作数用于存储中间结果(当前行索引、argmin 索引、当前最小值元素)。若 `src.GetValidRow() == 0` 或 `src.GetValidCol() == 0`,实现会直接返回。
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+A2A3 实现中 `tmp` 始终被使用;A5 实现中 `tmp` 保留但不使用。
-同步形式:
+## 语法
-```text
-%dst = tcolargmin %src : !pto.tile<...> -> !pto.tile<...>
-```
-Lowering may introduce internal scratch tiles; the C++ intrinsic requires an explicit `tmp` operand.
+### PTO-AS
-### IR Level 1(SSA)
+参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
-```text
+### AS Level 1(SSA)
+
+```mlir
%dst = pto.tcolargmin %src, %tmp : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
-### IR Level 2(DPS)
+### AS Level 2(DPS)
-```text
+```mlir
pto.tcolargmin ins(%src, %tmp : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
## C++ 内建接口
-声明于 `include/pto/common/pto_instr.hpp`:
+声明于 `include/pto/common/pto_instr.hpp`:
```cpp
template
-PTO_INST RecordEvent TCOLARGMIN(TileDataOut& dst, TileDataIn& src, TileDataTmp& tmp, WaitEvents&... events);
+PTO_INST RecordEvent TCOLARGMIN(TileDataOut &dst, TileDataIn &src, TileDataTmp &tmp, WaitEvents &... events);
```
-## 约束
+## 输入
-### 通用约束或检查
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| `%src` | 源 tile | 输入 tile,源元素类型支持数值类型 |
+| `%dst` | 目标 tile | 接收 argmin 索引结果,目标元素类型为 `uint32_t` 或 `int32_t` |
+| `%tmp` | 临时 tile | A2A3 必需(存储中间结果);A5 保留但不使用 |
+| `WaitEvents...` | 可选同步 | 发射前需要等待的事件 |
-- `dst` 和 `src` 必须为 `TileType::Vec`。
-- 由于已检查到的辅助检查仅要求 `SLayout::NoneBox`,因此 `src` 可使用 ND 或 DN 的非分形布局。
-- `dst` 必须使用标准 ND 布局:行主且非分形(`BLayout::RowMajor`、`SLayout::NoneBox`)。
-- 支持的目标元素类型:`uint32_t`、`int32_t`。
-- 编译时检查:`TileDataIn::ValidCol == 1 || TileDataIn::ValidCol == -1`。
-- 运行时检查:
- - `src.GetValidRow() != 0`
- - `src.GetValidCol() != 0`
- - `dst.GetValidRow() == 1`
- - `src.GetValidCol() == dst.GetValidCol()`
+## 预期输出
-### A2A3 实现检查
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `%dst` | `!pto.tile<1, C>` | 每列最小值的行索引(0-based) |
-- 支持的源元素类型:`half`、`float`、`uint16_t`、`uint32_t`。
-- `tmp` 的元素类型必须与 `src` 一致。
-- 在已检查到的 A2A3 实现路径中,`tmp` 用作索引跟踪和当前比较值的临时存储。
+## 副作用
-### A5 实现检查
+除产生目标 tile 外,没有额外架构副作用。
-- 支持的源元素宽度为 8 位、16 位或 32 位,因此已检查到的实现覆盖 `int8_t`、`uint8_t`、`int16_t`、`uint16_t`、`int32_t`、`uint32_t`、`half`、`float`。
-- 在已检查到的 A5 实现路径中,接口仍接收 `tmp`,但 `TCOLARGMIN_IMPL` 实际并不使用它。
+## 约束
-### A2A3 `tmp` 临时 Tile 相关说明
+- `dst` 和 `src` 必须为 `TileType::Vec`。
+- 由于辅助检查仅要求 `SLayout::NoneBox`,`src` 可使用 ND 或 DN 的非分形布局。
+- `dst` 必须使用标准 ND 布局:行主且非分形(`BLayout::RowMajor`、`SLayout::NoneBox`)。
+- 目标元素类型:`uint32_t`、`int32_t`。
+- 编译时检查:`TileDataIn::ValidCol == 1 || TileDataIn::ValidCol == -1`。
+- 运行时检查:`src.GetValidRow() != 0`、`src.GetValidCol() != 0`、`dst.GetValidRow() == 1`、`src.GetValidCol() == dst.GetValidCol()`。
+- A2A3:`tmp` 元素类型必须与 `src` 一致,`tmp` 用作索引跟踪和当前比较值的临时存储。
+- A5:`tmp` 保留但不使用,A5 使用基于向量寄存器的计算方式。
-* A2A3 实现中 `tmp` **始终被使用**,作为中间结果的临时存储空间(当前行索引、argmin 索引、当前最小值元素)。
-* `tmp` Tile 的数据类型必须与 `src` 的数据类型一致。
-* `tmp` Tile 在单行内被划分为三个区域:
- - 区域 0(`[0, tmpGapEles)`):当前行索引计数器(每行递增)。
- - 区域 1(`[tmpGapEles, 2 * tmpGapEles)`):当前最小值元素,用于比较。
- - 区域 2(`[2 * tmpGapEles, 3 * tmpGapEles)`):argmin 索引结果(最终转换后写入 `dst`)。
-* `tmpGapEles` 的确定方式:
- - 当 `srcValidCol >= elemPerRpt` 时:`tmpGapEles = elemPerRpt`。
- - 当 `srcValidCol < elemPerRpt` 时:`tmpGapEles = ceil(srcValidCol / elemPerBlock) * elemPerBlock`。
-* 当 `src` 较小时,可直接将 `tmp` Tile 大小设为与 `src` 相同;也可按以下公式根据 `src` 的 `validCol` 算出 `tmp` Tile 所需 stride:
+## 异常与非法情形
-```text
-repeats = ceil(validCol / elementPerRepeat)
-stride = ceil(repeats * 2 / elementPerBlock) * elementPerBlock + ceil(repeats / elementPerBlock) * elementPerBlock
-```
+- 非法操作数组合、不支持的数据类型、不合法布局或不支持的 target-profile 模式,会被 verifier 或后端实现拒绝。
-### A5 `tmp` 临时 Tile 相关说明
+## Target-Profile 限制
-* A5 实现中 `tmp` 临时 Tile **不使用**。A5 使用基于向量寄存器的计算方式(`__VEC_SCOPE__`),不需要临时 Tile 存储。
-* `tmp` 在 C++ 内建接口签名中保留,仅为了与 A2A3 的 API 兼容。
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| 源 `float` | Simulated | Supported | Supported |
+| 源 `half` | Simulated | Supported | Supported |
+| 源 `uint16_t` / `uint32_t` | — | Supported | Supported |
+| 源 `int8_t` / `uint8_t` / `int16_t` / `int32_t` | — | — | Supported |
+| 目标 `uint32_t` / `int32_t` | Simulated | Supported | Supported |
+| `tmp` 临时 tile | — | Required | Unused (API compat) |
## 示例
-### 自动(Auto)
+### C++ 自动模式
```cpp
#include
@@ -115,7 +108,7 @@ void example_auto() {
}
```
-### 手动(Manual)
+### C++ 手动模式
```cpp
#include
@@ -136,34 +129,23 @@ void example_manual() {
}
```
-## 汇编示例(ASM)
-
-### 自动模式
+### PTO-AS
```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
+# 自动模式
%dst = pto.tcolargmin %src, %tmp : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-```
-
-### 手动模式
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
+# 手动模式
+pto.tassign %arg0, @tile(0x1000)
+pto.tassign %arg1, @tile(0x2000)
%dst = pto.tcolargmin %src, %tmp : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-```
-
-### PTO 汇编形式
-```text
+# PTO 汇编形式
%dst = tcolargmin %src : !pto.tile<...> -> !pto.tile<...>
-# IR Level 2 (DPS)
+# AS Level 2 (DPS)
pto.tcolargmin ins(%src, %tmp : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
-
-- [x] Write tcolargmin English documentation (docs/isa/TCOLARGMIN.md)
-- [x] Write tcolargmin Chinese documentation (docs/isa/TCOLARGMIN_zh.md)
-
-
+
+## 相关页面
+
+- 指令集总览:[归约与扩展](./tile/reduce-and-expand_zh.md)
diff --git a/docs/isa/TCOLMAX_zh.md b/docs/isa/TCOLMAX_zh.md
index daf6e76b..353b16d6 100644
--- a/docs/isa/TCOLMAX_zh.md
+++ b/docs/isa/TCOLMAX_zh.md
@@ -1,38 +1,34 @@
-# TCOLMAX
+# pto.tcolmax
-## 指令示意图
+`pto.tcolmax` 属于[归约与扩展](./tile/reduce-and-expand_zh.md)指令集。
-
-
-## 简介
+## 概述
通过取行间最大值来归约每一列。
-## 数学语义
+## 机制
设 `R = src.GetValidRow()`,`C = src.GetValidCol()`。对 `0 <= j < C`:
$$ \mathrm{dst}_{0,j} = \max_{0 \le i < R} \mathrm{src}_{i,j} $$
-## 汇编语法
+迭代域由 `src` 的 valid region 决定。若 `src.GetValidRow() == 0` 或 `src.GetValidCol() == 0`,实现会直接返回。
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+## 语法
-同步形式:
+### PTO-AS
-```text
-%dst = tcolmax %src : !pto.tile<...> -> !pto.tile<...>
-```
+参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.tcolmax %src : !pto.tile<...> -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.tcolmax ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
@@ -45,28 +41,49 @@ template
PTO_INST RecordEvent TCOLMAX(TileDataOut &dst, TileDataIn &src, WaitEvents &... events);
```
-## 约束
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| `%src` | 源 tile | 输入 tile |
+| `%dst` | 目标 tile | 接收按列取最大值结果 |
+| `WaitEvents...` | 可选同步 | 发射前需要等待的事件 |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `%dst` | `!pto.tile<1, C>` | 每列的最大元素值 |
+
+## 副作用
-### 通用约束或检查
+除产生目标 tile 外,没有额外架构副作用。
+
+## 约束
- `dst` 和 `src` 必须为 `TileType::Vec`。
- `dst` 和 `src` 必须使用标准 ND 布局:行主且非分形(`BLayout::RowMajor`、`SLayout::NoneBox`)。
- `dst` 和 `src` 的元素类型必须一致。
-- 运行时检查:
- - `src.GetValidCol() == dst.GetValidCol()`
-- 若 `src.GetValidRow() == 0` 或 `src.GetValidCol() == 0`,实现会直接返回。
+- 运行时检查:`src.GetValidCol() == dst.GetValidCol()`。
-### A2A3 实现检查
+## 异常与非法情形
-- 支持的元素类型:`half`、`float`、`int16_t`、`int32_t`。
+- 非法操作数组合、不支持的数据类型、不合法布局或不支持的 target-profile 模式,会被 verifier 或后端实现拒绝。
-### A5 实现检查
+## Target-Profile 限制
-- 支持的元素类型:`half`、`float`、`int8_t`、`uint8_t`、`int16_t`、`uint16_t`、`int32_t`、`uint32_t`、`bfloat16_t`。
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| `float` | Simulated | Supported | Supported |
+| `half` | Simulated | Supported | Supported |
+| `int16_t` / `int32_t` | — | Supported | — |
+| `int8_t` / `uint8_t` | — | — | Supported |
+| `uint16_t` / `uint32_t` | — | — | Supported |
+| `bfloat16_t` | — | — | Supported |
## 示例
-### 自动(Auto)
+### C++ 自动模式
```cpp
#include
@@ -82,7 +99,7 @@ void example_auto() {
}
```
-### 手动(Manual)
+### C++ 手动模式
```cpp
#include
@@ -100,29 +117,23 @@ void example_manual() {
}
```
-## 汇编示例(ASM)
-
-### 自动模式
+### PTO-AS
```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
+# 自动模式
%dst = pto.tcolmax %src : !pto.tile<...> -> !pto.tile<...>
-```
-
-### 手动模式
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
+# 手动模式
+pto.tassign %arg0, @tile(0x1000)
+pto.tassign %arg1, @tile(0x2000)
%dst = pto.tcolmax %src : !pto.tile<...> -> !pto.tile<...>
-```
-
-### PTO 汇编形式
-```text
+# PTO 汇编形式
%dst = tcolmax %src : !pto.tile<...> -> !pto.tile<...>
# AS Level 2 (DPS)
pto.tcolmax ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
+
+## 相关页面
+
+- 指令集总览:[归约与扩展](./tile/reduce-and-expand_zh.md)
diff --git a/docs/isa/TCOLMIN_zh.md b/docs/isa/TCOLMIN_zh.md
index f9089695..e0fa7a3a 100644
--- a/docs/isa/TCOLMIN_zh.md
+++ b/docs/isa/TCOLMIN_zh.md
@@ -1,38 +1,34 @@
-# TCOLMIN
+# pto.tcolmin
-## 指令示意图
+`pto.tcolmin` 属于[归约与扩展](./tile/reduce-and-expand_zh.md)指令集。
-
-
-## 简介
+## 概述
通过取行间最小值来归约每一列。
-## 数学语义
+## 机制
设 `R = src.GetValidRow()`,`C = src.GetValidCol()`。对 `0 <= j < C`:
$$ \mathrm{dst}_{0,j} = \min_{0 \le i < R} \mathrm{src}_{i,j} $$
-## 汇编语法
+迭代域由 `src` 的 valid region 决定。若 `src.GetValidRow() == 0` 或 `src.GetValidCol() == 0`,实现会直接返回。
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+## 语法
-同步形式:
+### PTO-AS
-```text
-%dst = tcolmin %src : !pto.tile<...> -> !pto.tile<...>
-```
+参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.tcolmin %src : !pto.tile<...> -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.tcolmin ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
@@ -45,28 +41,49 @@ template
PTO_INST RecordEvent TCOLMIN(TileDataOut &dst, TileDataIn &src, WaitEvents &... events);
```
-## 约束
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| `%src` | 源 tile | 输入 tile |
+| `%dst` | 目标 tile | 接收按列取最小值结果 |
+| `WaitEvents...` | 可选同步 | 发射前需要等待的事件 |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `%dst` | `!pto.tile<1, C>` | 每列的最小元素值 |
+
+## 副作用
-### 通用约束或检查
+除产生目标 tile 外,没有额外架构副作用。
+
+## 约束
- `dst` 和 `src` 必须为 `TileType::Vec`。
- `dst` 和 `src` 必须使用标准 ND 布局:行主且非分形(`BLayout::RowMajor`、`SLayout::NoneBox`)。
- `dst` 和 `src` 的元素类型必须一致。
-- 运行时检查:
- - `src.GetValidCol() == dst.GetValidCol()`
-- 若 `src.GetValidRow() == 0` 或 `src.GetValidCol() == 0`,实现会直接返回。
+- 运行时检查:`src.GetValidCol() == dst.GetValidCol()`。
-### A2A3 实现检查
+## 异常与非法情形
-- 支持的元素类型:`half`、`float`、`int16_t`、`int32_t`。
+- 非法操作数组合、不支持的数据类型、不合法布局或不支持的 target-profile 模式,会被 verifier 或后端实现拒绝。
-### A5 实现检查
+## Target-Profile 限制
-- 支持的元素类型:`half`、`float`、`int8_t`、`uint8_t`、`int16_t`、`uint16_t`、`int32_t`、`uint32_t`、`bfloat16_t`。
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| `float` | Simulated | Supported | Supported |
+| `half` | Simulated | Supported | Supported |
+| `int16_t` / `int32_t` | — | Supported | — |
+| `int8_t` / `uint8_t` | — | — | Supported |
+| `uint16_t` / `uint32_t` | — | — | Supported |
+| `bfloat16_t` | — | — | Supported |
## 示例
-### 自动(Auto)
+### C++ 自动模式
```cpp
#include
@@ -82,7 +99,7 @@ void example_auto() {
}
```
-### 手动(Manual)
+### C++ 手动模式
```cpp
#include
@@ -100,29 +117,23 @@ void example_manual() {
}
```
-## 汇编示例(ASM)
-
-### 自动模式
+### PTO-AS
```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
+# 自动模式
%dst = pto.tcolmin %src : !pto.tile<...> -> !pto.tile<...>
-```
-
-### 手动模式
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
+# 手动模式
+pto.tassign %arg0, @tile(0x1000)
+pto.tassign %arg1, @tile(0x2000)
%dst = pto.tcolmin %src : !pto.tile<...> -> !pto.tile<...>
-```
-
-### PTO 汇编形式
-```text
+# PTO 汇编形式
%dst = tcolmin %src : !pto.tile<...> -> !pto.tile<...>
# AS Level 2 (DPS)
pto.tcolmin ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
+
+## 相关页面
+
+- 指令集总览:[归约与扩展](./tile/reduce-and-expand_zh.md)
diff --git a/docs/isa/TCOLPROD_zh.md b/docs/isa/TCOLPROD_zh.md
index 9c706e65..b00b5bab 100644
--- a/docs/isa/TCOLPROD_zh.md
+++ b/docs/isa/TCOLPROD_zh.md
@@ -1,38 +1,34 @@
-# TCOLPROD
+# pto.tcolprod
-## 指令示意图
+`pto.tcolprod` 属于[归约与扩展](./tile/reduce-and-expand_zh.md)指令集。
-
-
-## 简介
+## 概述
通过跨行乘积来归约每一列。
-## 数学语义
+## 机制
设 `R = src.GetValidRow()`,`C = src.GetValidCol()`。对 `0 <= j < C`:
$$ \mathrm{dst}_{0,j} = \prod_{i=0}^{R-1} \mathrm{src}_{i,j} $$
-## 汇编语法
+迭代域由 `src` 的 valid region 决定。若 `src.GetValidRow() == 0` 或 `src.GetValidCol() == 0`,实现会直接返回。
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+## 语法
-同步形式:
+### PTO-AS
-```text
-%dst = tcolprod %src : !pto.tile<...> -> !pto.tile<...>
-```
+参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.tcolprod %src : !pto.tile<...> -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.tcolprod ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
@@ -45,28 +41,48 @@ template
PTO_INST RecordEvent TCOLPROD(TileDataOut &dst, TileDataIn &src, WaitEvents &... events);
```
-## 约束
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| `%src` | 源 tile | 输入 tile |
+| `%dst` | 目标 tile | 接收按列乘积结果 |
+| `WaitEvents...` | 可选同步 | 发射前需要等待的事件 |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `%dst` | `!pto.tile<1, C>` | 每列的 `R` 个元素乘积 |
+
+## 副作用
-### 通用约束或检查
+除产生目标 tile 外,没有额外架构副作用。
+
+## 约束
- `dst` 和 `src` 必须为 `TileType::Vec`。
- `dst` 和 `src` 必须使用标准 ND 布局:行主且非分形(`BLayout::RowMajor`、`SLayout::NoneBox`)。
- `dst` 和 `src` 的元素类型必须一致。
-- 运行时检查:
- - `src.GetValidCol() == dst.GetValidCol()`
-- 若 `src.GetValidRow() == 0` 或 `src.GetValidCol() == 0`,实现会直接返回。
+- 运行时检查:`src.GetValidCol() == dst.GetValidCol()`。
-### A2A3 实现检查
+## 异常与非法情形
-- 支持的元素类型:`half`、`float`、`int16_t`、`int32_t`。
+- 非法操作数组合、不支持的数据类型、不合法布局或不支持的 target-profile 模式,会被 verifier 或后端实现拒绝。
-### A5 实现检查
+## Target-Profile 限制
-- 支持的元素类型:`half`、`float`、`bfloat16_t`、`int16_t`、`uint16_t`、`int32_t`、`uint32_t`。
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| `float` | Simulated | Supported | Supported |
+| `half` | Simulated | Supported | Supported |
+| `bfloat16_t` | — | — | Supported |
+| `int16_t` / `uint16_t` | — | Supported | Supported |
+| `int32_t` / `uint32_t` | — | Supported | Supported |
## 示例
-### 自动(Auto)
+### C++ 自动模式
```cpp
#include
@@ -82,7 +98,7 @@ void example_auto() {
}
```
-### 手动(Manual)
+### C++ 手动模式
```cpp
#include
@@ -100,29 +116,23 @@ void example_manual() {
}
```
-## 汇编示例(ASM)
-
-### 自动模式
+### PTO-AS
```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
+# 自动模式
%dst = pto.tcolprod %src : !pto.tile<...> -> !pto.tile<...>
-```
-
-### 手动模式
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
+# 手动模式
+pto.tassign %arg0, @tile(0x1000)
+pto.tassign %arg1, @tile(0x2000)
%dst = pto.tcolprod %src : !pto.tile<...> -> !pto.tile<...>
-```
-
-### PTO 汇编形式
-```text
+# PTO 汇编形式
%dst = tcolprod %src : !pto.tile<...> -> !pto.tile<...>
# AS Level 2 (DPS)
pto.tcolprod ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
+
+## 相关页面
+
+- 指令集总览:[归约与扩展](./tile/reduce-and-expand_zh.md)
diff --git a/docs/isa/TCOLSUM_zh.md b/docs/isa/TCOLSUM_zh.md
index d9dbce4c..58f464d5 100644
--- a/docs/isa/TCOLSUM_zh.md
+++ b/docs/isa/TCOLSUM_zh.md
@@ -1,42 +1,35 @@
-# TCOLSUM
+# pto.tcolsum
-## 指令示意图
+`pto.tcolsum` 属于[归约与扩展](./tile/reduce-and-expand_zh.md)指令集。
-
+## 概述
-## 简介
+通过对行求和来归约每一列,`isBinary` 选择实现路径(二叉树累加 vs. 顺序累加)。
-通过对行求和来归约每一列。
-
-## 数学语义
+## 机制
设 `R = src.GetValidRow()`,`C = src.GetValidCol()`。对 `0 <= j < C`:
$$ \mathrm{dst}_{0,j} = \sum_{i=0}^{R-1} \mathrm{src}_{i,j} $$
-`isBinary` 选择实现路径(二叉树累加 vs. 顺序累加)。
-
-## 汇编语法
+迭代域由 `src` 的 valid region 决定,`isBinary = true` 时使用 `tmp` 做二叉树累加,`isBinary = false` 时直接在 `dst` 上做顺序累加。若 `src.GetValidRow() == 0` 或 `src.GetValidCol() == 0`,实现会直接返回。
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+## 语法
-同步形式:
+### PTO-AS
-```text
-%dst = tcolsum %src {isBinary = false} : !pto.tile<...> -> !pto.tile<...>
-```
-降低时可能引入内部临时 Tile;C++ 内建接口需要显式传入 `tmp` 操作数。
+参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.tcolsum %src : !pto.tile<...> -> !pto.tile<...>
%dst = pto.tcolsum %src, %tmp {isBinary = false} : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.tcolsum ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
pto.tcolsum ins(%src, %tmp {isBinary = false} : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
@@ -53,37 +46,54 @@ template ` | 每列的 `R` 个元素求和 |
+
+## 副作用
-### 通用约束或检查
+除产生目标 tile 外,没有额外架构副作用。
+
+## 约束
- `dst` 和 `src` 必须为 `TileType::Vec`。
- `dst` 和 `src` 必须使用标准 ND 布局:行主且非分形(`BLayout::RowMajor`、`SLayout::NoneBox`)。
- `dst` 和 `src` 的元素类型必须一致。
-- 运行时检查:
- - `src.GetValidCol() == dst.GetValidCol()`
- - `src.GetValidRow() != 0`
- - `src.GetValidCol() != 0`
- - `src.GetValidCol()` 必须不大于按 `src` 元素计的 `tmp` 行跨度
-- `isBinary` 选择已检查到的后端路径:
- - `true`:使用 `tmp` 做二叉树累加
- - `false`:直接在 `dst` 上做顺序累加
+- 运行时检查:`src.GetValidCol() == dst.GetValidCol()`、`src.GetValidRow() != 0`、`src.GetValidCol() != 0`。
+- `src.GetValidCol()` 必须不大于按 `src` 元素计的 `tmp` 行跨度。
+- A2A3:`tmp` 必须为 `TileType::Vec`,使用标准 ND 布局,元素类型与 `src` 和 `dst` 一致。
-### A2A3 实现检查
+## 异常与非法情形
-- 支持的元素类型:`half`、`float`、`int16_t`、`int32_t`。
-- `tmp` 必须为 `TileType::Vec`,且使用标准 ND 布局:行主且非分形(`BLayout::RowMajor`、`SLayout::NoneBox`)。
-- `tmp` 的元素类型必须与 `src` 和 `dst` 一致。
-- 若 `src.GetValidRow() == 0` 或 `src.GetValidCol() == 0`,实现会直接返回。
+- 非法操作数组合、不支持的数据类型、不合法布局或不支持的 target-profile 模式,会被 verifier 或后端实现拒绝。
-### A5 实现检查
+## Target-Profile 限制
-- A5 共享列归约检查允许的元素类型为:`half`、`float`、`int8_t`、`uint8_t`、`int16_t`、`uint16_t`、`int32_t`、`uint32_t`、`bfloat16_t`。
-- 已检查到的 A5 `TCOLSUM` 路径中,`tmp` 仍只用于二叉累加路径;`TCOLSUM_IMPL` 中没有额外显式加入 `tmp` 的编译期类型/布局断言。
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| `float` | Simulated | Supported | Supported |
+| `half` | Simulated | Supported | Supported |
+| `int16_t` | — | Supported | — |
+| `int32_t` | — | Supported | — |
+| `int8_t` / `uint8_t` | — | — | Supported |
+| `uint16_t` / `uint32_t` | — | — | Supported |
+| `bfloat16_t` | — | — | Supported |
## 示例
-### 自动(Auto)
+### C++ 自动模式
```cpp
#include
@@ -101,7 +111,7 @@ void example_auto() {
}
```
-### 手动(Manual)
+### C++ 手动模式
```cpp
#include
@@ -122,29 +132,23 @@ void example_manual() {
}
```
-## 汇编示例(ASM)
-
-### 自动模式
+### PTO-AS
```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
+# 自动模式
%dst = pto.tcolsum %src : !pto.tile<...> -> !pto.tile<...>
-```
-
-### 手动模式
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
+# 手动模式
+pto.tassign %arg0, @tile(0x1000)
+pto.tassign %arg1, @tile(0x2000)
%dst = pto.tcolsum %src : !pto.tile<...> -> !pto.tile<...>
-```
-
-### PTO 汇编形式
-```text
+# PTO 汇编形式
%dst = tcolsum %src {isBinary = false} : !pto.tile<...> -> !pto.tile<...>
# AS Level 2 (DPS)
pto.tcolsum ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
+
+## 相关页面
+
+- 指令集总览:[归约与扩展](./tile/reduce-and-expand_zh.md)
diff --git a/docs/isa/TCONCAT_zh.md b/docs/isa/TCONCAT_zh.md
index 6a8232ac..ee91c1b8 100644
--- a/docs/isa/TCONCAT_zh.md
+++ b/docs/isa/TCONCAT_zh.md
@@ -1,41 +1,90 @@
-# TCONCAT
+# pto.tconcat
-## 指令示意图
+`pto.tconcat` 属于[布局与重排](./tile/layout-and-rearrangement_zh.md)指令集。
-
+## 概述
-## 简介
+沿列维度将两个源 Tile 拼接到目标 Tile 中,形成更宽的 Tile。
-沿列维将两个源 Tile 拼接到目标 Tile。
+## 机制
-## 数学语义
+语义随具体指令变体而变化。除非另有说明,行为都按目标 valid region 定义。
-语义随指令而变化。 除非另有说明,行为都按目标 valid region 定义。
+## 语法
-## 汇编语法
+### PTO-AS
PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.tconcat ...
```
### AS Level 2(DPS)
-```text
+```mlir
pto.tconcat ins(...) outs(%dst : !pto.tile_buf<...>)
```
## C++ 内建接口
-声明于 `include/pto/common/pto_instr.hpp`.
+声明于 `include/pto/common/pto_instr.hpp`。
+
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| 源 Tile 1 | 输入 | 待拼接的第一个 Tile |
+| 源 Tile 2 | 输入 | 待拼接的第二个 Tile |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `%dst` | `!pto.tile_buf<...>` | 拼接后的目标 Tile |
+
+## 副作用
+
+拼接操作会产生目标 Tile,无额外架构副作用。
## 约束
-数据类型、layout、location 和 shape 的进一步限制以对应 backend 的合法性检查为准。
+- 数据类型、layout、location 和 shape 的进一步限制以对应 backend 的合法性检查为准。
+
+## 异常与非法情形
+
+- 不支持的 Tile 形状/布局组合会被 verifier 或后端拒绝。
+
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| 拼接操作 | Simulated | Supported | Supported |
## 示例
+### C++ 自动模式
+
具体的 Auto / Manual 使用方式见 `docs/isa/` 下的相关指令页。
+
+### C++ 手动模式
+
+具体的 Auto / Manual 使用方式见 `docs/isa/` 下的相关指令页。
+
+### PTO-AS
+
+```text
+%dst = pto.tconcat %src1, %src2 : !pto.tile<...>
+```
+
+### AS Level 2(DPS)
+
+```mlir
+pto.tconcat ins(%src1, %src2 : ...) outs(%dst : !pto.tile_buf<...>)
+```
+
+## 相关页面
+
+- 指令集总览:[布局与重排](./tile/layout-and-rearrangement_zh.md)
diff --git a/docs/isa/TDEQUANT_zh.md b/docs/isa/TDEQUANT_zh.md
index 2b4373f7..8f598fb0 100644
--- a/docs/isa/TDEQUANT_zh.md
+++ b/docs/isa/TDEQUANT_zh.md
@@ -1,41 +1,91 @@
-# TDEQUANT
+# pto.tdequant
-## 指令示意图
+`pto.tdequant` 属于[不规则与复杂](./tile/irregular-and-complex_zh.md)指令集。
-
-
-## 简介
+## 概述
使用 scale 与 offset Tile 将整数量化 Tile 反量化为浮点 Tile。
-## 数学语义
+## 机制
+
+语义随具体指令变体而变化。除非另有说明,行为都按目标 valid region 定义。
-语义随指令而变化。 除非另有说明,行为都按目标 valid region 定义。
+## 语法
-## 汇编语法
+### PTO-AS
PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.tdequant ...
```
### AS Level 2(DPS)
-```text
+```mlir
pto.tdequant ins(...) outs(%dst : !pto.tile_buf<...>)
```
## C++ 内建接口
-声明于 `include/pto/common/pto_instr.hpp`.
+声明于 `include/pto/common/pto_instr.hpp`。
+
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| 量化 Tile | 输入 | 待反量化的整数量化 Tile |
+| Scale Tile | 输入 | 反量化使用的缩放系数 |
+| Offset Tile | 输入 | 反量化使用的偏移量(可选) |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `%dst` | `!pto.tile_buf` | 反量化后的浮点 Tile |
+
+## 副作用
+
+反量化操作会产生目标浮点 Tile,无额外架构副作用。
## 约束
-数据类型、layout、location 和 shape 的进一步限制以对应 backend 的合法性检查为准。
+- 数据类型、layout、location 和 shape 的进一步限制以对应 backend 的合法性检查为准。
+
+## 异常与非法情形
+
+- 不支持的量化格式或数据类型组合会被 verifier 或后端拒绝。
+
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| 反量化操作 | Simulated | Supported | Supported |
## 示例
+### C++ 自动模式
+
+具体的 Auto / Manual 使用方式见 `docs/isa/` 下的相关指令页。
+
+### C++ 手动模式
+
具体的 Auto / Manual 使用方式见 `docs/isa/` 下的相关指令页。
+
+### PTO-AS
+
+```text
+%dst = pto.tdequant %quant_tile, %scale_tile, %offset_tile : ...
+```
+
+### AS Level 2(DPS)
+
+```mlir
+pto.tdequant ins(%quant, %scale : ...) outs(%dst : !pto.tile_buf<...>)
+```
+
+## 相关页面
+
+- 指令集总览:[不规则与复杂](./tile/irregular-and-complex_zh.md)
diff --git a/docs/isa/TDIVS_zh.md b/docs/isa/TDIVS_zh.md
index ef120aec..58856deb 100644
--- a/docs/isa/TDIVS_zh.md
+++ b/docs/isa/TDIVS_zh.md
@@ -1,159 +1,171 @@
-# TDIVS
-
-## 指令示意图
-
-
-
-## 简介
-
-与标量的逐元素除法(Tile/标量 或 标量/Tile)。
-
-## 数学语义
-
-对有效区域内的每个元素 `(i, j)`:
-
-- Tile/标量形式:
-
- $$ \mathrm{dst}_{i,j} = \frac{\mathrm{src}_{i,j}}{\mathrm{scalar}} $$
-
-- 标量/Tile 形式:
-
- $$ \mathrm{dst}_{i,j} = \frac{\mathrm{scalar}}{\mathrm{src}_{i,j}} $$
-
-## 汇编语法
-
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
-
-Tile/标量形式:
-
-```text
-%dst = tdivs %src, %scalar : !pto.tile<...>, f32
-```
-
-标量/Tile 形式:
-
-```text
-%dst = tdivs %scalar, %src : f32, !pto.tile<...>
-```
-
-### AS Level 1(SSA)
-
-```text
-%dst = pto.tdivs %src, %scalar : (!pto.tile<...>, dtype) -> !pto.tile<...>
-%dst = pto.tdivs %scalar, %src : (dtype, !pto.tile<...>) -> !pto.tile<...>
-```
-
-### AS Level 2(DPS)
-
-```text
-pto.tdivs ins(%src, %scalar : !pto.tile_buf<...>, dtype) outs(%dst : !pto.tile_buf<...>)
-pto.tdivs ins(%scalar, %src : dtype, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
-```
-
-## C++ 内建接口
-
-声明于 `include/pto/common/pto_instr.hpp`:
-
-```cpp
-template
-PTO_INST RecordEvent TDIVS(TileDataDst &dst, TileDataSrc &src0, typename TileDataSrc::DType scalar,
- WaitEvents &... events);
-
-template
-PTO_INST RecordEvent TDIVS(TileDataDst &dst, typename TileDataDst::DType scalar, TileDataSrc &src0,
- WaitEvents &... events)
-```
-
-`PrecisionType`可指定以下值:
-
-* `DivAlgorithm::DEFAULT`:普通算法,速度快但精度较低。
-* `DivAlgorithm::HIGH_PRECISION`:高精度算法,速度较慢。
-
-## 约束
-
-- **实现检查 (A2A3)**(两个重载):
- - `TileData::DType` 必须是以下之一:`int32_t`、`int`、`int16_t`、`half`、`float16_t`、`float`、`float32_t`。
- - Tile 位置必须是向量(`TileData::Loc == TileType::Vec`)。
- - 静态有效边界:`TileData::ValidRow <= TileData::Rows` 且 `TileData::ValidCol <= TileData::Cols`。
- - 运行时:`src0.GetValidRow() == dst.GetValidRow()` 且 `src0.GetValidCol() == dst.GetValidCol()`。
- - Tile 布局必须是行主序(`TileData::isRowMajor`)。
-- **实现检查 (A5)**(两个重载):
- - `TileData::DType` 必须是以下之一:`uint8_t`、`int8_t`、`uint16_t`、`int16_t`、`uint32_t`、`int32_t`、`half`、`float`。
- - Tile 位置必须是向量(`TileData::Loc == TileType::Vec`)。
- - 静态有效边界:`TileData::ValidRow <= TileData::Rows` 且 `TileData::ValidCol <= TileData::Cols`。
- - 运行时:`src0.GetValidRow() == dst.GetValidRow()` 且 `src0.GetValidCol() == dst.GetValidCol()`。
- - Tile 布局必须是行主序(`TileData::isRowMajor`)。
-- **有效区域**:
- - 该操作使用 `dst.GetValidRow()` / `dst.GetValidCol()` 作为迭代域。
-- **除零**:
- - 行为由目标定义;在 A5 上,Tile/标量形式映射到乘以倒数,并对 `scalar == 0` 使用 `1/0 -> +inf`。dst.GetValidRow()`且`src0.GetValidCol() == dst.GetValidCol()`.
- - Tile 布局必须是行主序(`TileData::isRowMajor`)。
-- **有效区域**:
- - 该操作使用 `dst.GetValidRow()` / `dst.GetValidCol()` 作为迭代域.
-- **除零**:
- - 行为由目标定义;在 A5 上,tile/标量形式映射到乘以倒数,并对 `scalar == 0` 使用 `1/0 -> +inf`。
-- **高精度算法**
- - 仅在A5上有效,`PrecisionType`选项A3上将被忽略。
-
-## 示例
-
-### 自动(Auto)
-
-```cpp
-#include
-
-using namespace pto;
-
-void example_auto() {
- using TileT = Tile;
- TileT src, dst;
- TDIVS(dst, src, 2.0f);
- TDIVS(dst, src, 2.0f);
-}
-```
-
-### 手动(Manual)
-
-```cpp
-#include
-
-using namespace pto;
-
-void example_manual() {
- using TileT = Tile;
- TileT src, dst;
- TASSIGN(src, 0x1000);
- TASSIGN(dst, 0x2000);
- TDIVS(dst, 2.0f, src);
- TDIVS(dst, 2.0f, src);
-}
-```
-
-## 汇编示例(ASM)
-
-### 自动模式
-
-```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
-%dst = pto.tdivs %src, %scalar : (!pto.tile<...>, dtype) -> !pto.tile<...>
-```
-
-### 手动模式
-
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
-%dst = pto.tdivs %src, %scalar : (!pto.tile<...>, dtype) -> !pto.tile<...>
-```
-
-### PTO 汇编形式
-
-```text
-%dst = pto.tdivs %src, %scalar : (!pto.tile<...>, dtype) -> !pto.tile<...>
-# AS Level 2 (DPS)
-pto.tdivs ins(%src, %scalar : !pto.tile_buf<...>, dtype) outs(%dst : !pto.tile_buf<...>)
-```
+# pto.tdivs
+
+
+
+`pto.tdivs` 属于[Tile-标量与立即数](./tile/tile-scalar-and-immediate_zh.md)指令集。
+
+## 概述
+
+带标量的逐元素除法,支持 tile / scalar 和 scalar / tile 两种方向,标量广播到 tile 有效区域的所有元素。
+
+## 机制
+
+对目标 tile 的 valid region 中每个 `(i, j)`:
+
+- tile / scalar 形式:
+
+ $$ \mathrm{dst}_{i,j} = \frac{\mathrm{src}_{i,j}}{\mathrm{scalar}} $$
+
+- scalar / tile 形式:
+
+ $$ \mathrm{dst}_{i,j} = \frac{\mathrm{scalar}}{\mathrm{src}_{i,j}} $$
+
+除零行为由目标 profile 定义。在 A5 上,tile / scalar 形式通常映射到"乘以倒数"的实现路径。
+
+## 语法
+
+### PTO-AS
+
+tile / scalar 形式:
+
+```text
+%dst = tdivs %src, %scalar : !pto.tile<...>, f32
+```
+
+scalar / tile 形式:
+
+```text
+%dst = tdivs %scalar, %src : f32, !pto.tile<...>
+```
+
+### AS Level 1(SSA)
+
+```mlir
+%dst = pto.tdivs %src, %scalar : (!pto.tile<...>, dtype) -> !pto.tile<...>
+%dst = pto.tdivs %scalar, %src : (dtype, !pto.tile<...>) -> !pto.tile<...>
+```
+
+### AS Level 2(DPS)
+
+```mlir
+pto.tdivs ins(%src, %scalar : !pto.tile_buf<...>, dtype) outs(%dst : !pto.tile_buf<...>)
+pto.tdivs ins(%scalar, %src : dtype, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
+```
+
+## C++ 内建接口
+
+```cpp
+template
+PTO_INST RecordEvent TDIVS(TileDataDst &dst, TileDataSrc &src0, typename TileDataSrc::DType scalar,
+ WaitEvents &... events);
+
+template
+PTO_INST RecordEvent TDIVS(TileDataDst &dst, typename TileDataDst::DType scalar, TileDataSrc &src0,
+ WaitEvents &... events);
+```
+
+`PrecisionType` 可选:
+
+- `DivAlgorithm::DEFAULT`:普通算法,速度快但精度较低。
+- `DivAlgorithm::HIGH_PRECISION`:高精度算法,速度较慢。
+
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| `%src` | 源 tile | tile / scalar 形式中被除数 |
+| `%scalar` | 标量 | 广播到所有元素的标量值 |
+| `%dst` | 目标 tile | 接收逐元素除法结果 |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `%dst` | `!pto.tile<...>` | `dst` valid region 内的每个元素都等于对应形式的除法结果 |
+
+## 副作用
+
+除产生目标 tile 外,没有额外架构副作用。
+
+## 约束
+
+- 操作迭代域由 `dst.GetValidRow()` / `dst.GetValidCol()` 决定。
+- 除零行为由目标 profile 定义。
+- `HIGH_PRECISION` 只在 A5 可用,A3 上该选项会被忽略。
+
+## 异常与非法情形
+
+- 非法操作数组合、不支持的数据类型、不合法布局或不支持的 target-profile 模式,会被 verifier 或后端实现拒绝。
+
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| `int32_t` / `uint32_t` | Simulated | Supported | Supported |
+| `int16_t` / `uint16_t` | Simulated | Supported | Supported |
+| `float` | Simulated | Supported | Supported |
+| `half` | Simulated | Supported | Supported |
+| `int8_t` / `uint8_t` | Simulated | No | Supported |
+| 布局 | Any | RowMajor only | RowMajor only |
+
+A2/A3 支持:`int32_t`、`int16_t`、`half`、`float`;A5 额外支持 `uint32_t`、`uint16_t`、`int8_t`、`uint8_t`。
+
+## 示例
+
+### C++ 自动模式
+
+```cpp
+#include
+using namespace pto;
+
+void example_auto() {
+ using TileT = Tile;
+ TileT src, dst;
+ TDIVS(dst, src, 2.0f);
+ TDIVS(dst, src, 2.0f);
+}
+```
+
+### C++ 手动模式
+
+```cpp
+#include
+using namespace pto;
+
+void example_manual() {
+ using TileT = Tile;
+ TileT src, dst;
+ TASSIGN(src, 0x1000);
+ TASSIGN(dst, 0x2000);
+ TDIVS(dst, 2.0f, src);
+ TDIVS(dst, 2.0f, src);
+}
+```
+
+### PTO-AS
+
+```text
+# tile / scalar 自动模式
+%dst = pto.tdivs %src, %scalar : (!pto.tile<...>, dtype) -> !pto.tile<...>
+
+# scalar / tile 自动模式
+%dst = pto.tdivs %scalar, %src : (dtype, !pto.tile<...>) -> !pto.tile<...>
+
+# 手动模式
+pto.tassign %arg0, @tile(0x1000)
+pto.tassign %arg1, @tile(0x2000)
+%dst = pto.tdivs %src, %scalar : (!pto.tile<...>, dtype) -> !pto.tile<...>
+
+# PTO 汇编形式
+%dst = tdivs %src, %scalar : !pto.tile<...>, f32
+%dst = tdivs %scalar, %src : f32, !pto.tile<...>
+# AS Level 2 (DPS)
+pto.tdivs ins(%src, %scalar : !pto.tile_buf<...>, dtype) outs(%dst : !pto.tile_buf<...>)
+```
+
+## 相关页面
+
+- 指令集总览:[Tile-标量与立即数](./tile/tile-scalar-and-immediate_zh.md)
+- 规范页:[pto.tdivs](./tile/ops/tile-scalar-and-immediate/tdivs_zh.md)
diff --git a/docs/isa/TDIV_zh.md b/docs/isa/TDIV_zh.md
index 7d0b14ca..1506c01b 100644
--- a/docs/isa/TDIV_zh.md
+++ b/docs/isa/TDIV_zh.md
@@ -1,24 +1,24 @@
-# TDIV
-
-## 指令示意图
+# pto.tdiv

-## 简介
+`pto.tdiv` 属于[逐元素 Tile-Tile](./tile/elementwise-tile-tile_zh.md)指令集。
+
+## 概述
-两个 Tile 的逐元素除法。
+对两个 tile 做逐元素除法,结果写入目标 tile。迭代域由目标 tile 的 valid region 决定。
-## 数学语义
+## 机制
-对每个元素 `(i, j)` 在有效区域内:
+对目标 tile 的 valid region 中每个 `(i, j)`:
$$ \mathrm{dst}_{i,j} = \frac{\mathrm{src0}_{i,j}}{\mathrm{src1}_{i,j}} $$
-## 汇编语法
+除零行为由目标 profile 定义。
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+## 语法
-同步形式:
+### PTO-AS
```text
%dst = tdiv %src0, %src1 : !pto.tile<...>
@@ -26,59 +26,78 @@ PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.tdiv %src0, %src1 : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
-pto.tdiv ins(%src0, %src1 : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
+```mlir
+pto.tdiv ins(%src0, %src1 : !pto.tile_buf<...>, !pto.tile_buf<...>)
+ outs(%dst : !pto.tile_buf<...>)
```
## C++ 内建接口
-声明于 `include/pto/common/pto_instr.hpp`:
-
```cpp
template
PTO_INST RecordEvent TDIV(TileDataDst &dst, TileDataSrc0 &src0, TileDataSrc1 &src1, WaitEvents &... events);
```
-`PrecisionType`可指定以下值:
+`PrecisionType` 可选:
+
+- `DivAlgorithm::DEFAULT`:普通算法,速度快但精度较低。
+- `DivAlgorithm::HIGH_PRECISION`:高精度算法,速度较慢。
-* `DivAlgorithm::DEFAULT`:普通算法,速度快但精度较低。
-* `DivAlgorithm::HIGH_PRECISION`:高精度算法,速度较慢。
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| `%src0` | 左 tile | 被除数 tile,在 `dst` valid region 上逐坐标读取 |
+| `%src1` | 右 tile | 除数 tile,在 `dst` valid region 上逐坐标读取 |
+| `WaitEvents...` | 可选同步 | 发射前需要等待的事件 |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `%dst` | `!pto.tile<...>` | `dst` valid region 内的每个元素都等于 `src0 / src1` |
+
+## 副作用
+
+除产生目标 tile 外,没有额外架构副作用。
## 约束
-- **实现检查 (A2A3)**:
- - `TileData::DType` 必须是以下之一: `half`, `float`.
- - Tile 布局必须是行主序(`TileData::isRowMajor`)。
- - Tile 位置必须是向量(`TileData::Loc == TileType::Vec`)。
- - 静态有效边界: `TileData::ValidRow <= TileData::Rows`且`TileData::ValidCol <= TileData::Cols`.
- - 运行时: `src0`, `src1`且`dst` tiles 应具有相同的 `validRow/validCol`.
-- **实现检查 (A5)**:
- - `TileData::DType` 必须是以下之一: `int32_t`, `uint32_t`, `float`, `int16_t`, `uint16_t`, `half`.
- - Tile 布局必须是行主序(`TileData::isRowMajor`)。
- - Tile 位置必须是向量(`TileData::Loc == TileType::Vec`)。
- - 静态有效边界: `TileData::ValidRow <= TileData::Rows`且`TileData::ValidCol <= TileData::Cols`.
- - 运行时: `src0`, `src1`且`dst` tiles 应具有相同的 `validRow/validCol`.
-- **有效区域**:
- - 该操作使用 `dst.GetValidRow()` / `dst.GetValidCol()` 作为迭代域;.
-- **除零**:
- - 行为由目标定义。
-- **高精度算法**
- - 仅在A5上有效,`PrecisionType`选项A3上将被忽略。
+- 操作迭代域由 `dst.GetValidRow()` / `dst.GetValidCol()` 决定。
+- 除零行为由目标 profile 定义。
+- `HIGH_PRECISION` 选项只在 A5 有效,A3 上会被忽略。
+
+## 异常与非法情形
+
+- 非法操作数组合、不支持的数据类型、不合法布局或不支持的 target-profile 模式,会被 verifier 或后端实现拒绝。
+
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| `float` | Simulated | Supported | Supported |
+| `half` | Simulated | Supported | Supported |
+| `int32_t` | Simulated | No | Supported |
+| `uint32_t` | Simulated | No | Supported |
+| `int16_t` | Simulated | No | Supported |
+| `uint16_t` | Simulated | No | Supported |
+| 布局 | Any | RowMajor only | RowMajor only |
+
+A2/A3 当前要求行主序布局;A5 支持更多整数类型。
## 示例
-### 自动(Auto)
+### C++ 自动模式
```cpp
#include
-
using namespace pto;
void example_auto() {
@@ -89,11 +108,10 @@ void example_auto() {
}
```
-### 手动(Manual)
+### C++ 手动模式
```cpp
#include
-
using namespace pto;
void example_manual() {
@@ -107,29 +125,24 @@ void example_manual() {
}
```
-## 汇编示例(ASM)
-
-### 自动模式
+### PTO-AS
```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
+# 自动模式
%dst = pto.tdiv %src0, %src1 : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-```
-### 手动模式
-
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
+# 手动模式
+pto.tassign %arg0, @tile(0x1000)
+pto.tassign %arg1, @tile(0x2000)
%dst = pto.tdiv %src0, %src1 : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-```
-
-### PTO 汇编形式
-```text
+# PTO 汇编形式
%dst = tdiv %src0, %src1 : !pto.tile<...>
# AS Level 2 (DPS)
pto.tdiv ins(%src0, %src1 : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
+
+## 相关页面
+
+- 指令集总览:[逐元素 Tile-Tile](./tile/elementwise-tile-tile_zh.md)
+- 规范页:[pto.tdiv](./tile/ops/elementwise-tile-tile/tdiv_zh.md)
diff --git a/docs/isa/TEXPANDS_zh.md b/docs/isa/TEXPANDS_zh.md
index 9a61e790..33998c89 100644
--- a/docs/isa/TEXPANDS_zh.md
+++ b/docs/isa/TEXPANDS_zh.md
@@ -1,24 +1,22 @@
-# TEXPANDS
+# pto.texpands
-## 指令示意图
+`pto.texpands` 属于[逐元素 Tile-标量](./tile/tile-scalar-and-immediate_zh.md)指令集。
-
+## 概述
-## 简介
+将标量广播到目标 Tile 中所有有效位置。
-将标量广播到目标 Tile 中。
+## 机制
-## 数学语义
-
-对每个元素 `(i, j)` 在有效区域内:
+对有效区域内每个元素 `(i, j)`:
$$ \mathrm{dst}_{i,j} = \mathrm{scalar} $$
-## 汇编语法
+对于向量 Tile,迭代域由 `dst.GetValidRow()` / `dst.GetValidCol()` 决定;对于 Mat Tile,迭代域由 `TileData::Rows` / `TileData::Cols` 决定。
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+## 语法
-同步形式:
+### PTO-AS
```text
%dst = texpands %scalar : f32, !pto.tile<...>
@@ -26,54 +24,70 @@ PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.texpands %scalar : dtype -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.texpands ins(%scalar : dtype) outs(%dst : !pto.tile_buf<...>)
```
## C++ 内建接口
-声明于 `include/pto/common/pto_instr.hpp`:
-
```cpp
template
PTO_INST RecordEvent TEXPANDS(TileData &dst, typename TileData::DType scalar, WaitEvents &... events);
```
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| `%scalar` | 标量 | 广播到目标 tile 的值 |
+| `WaitEvents...` | 可选同步 | 发射前需要等待的事件 |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `%dst` | `!pto.tile<...>` | 有效区域内所有元素等于标量值 |
+
+## 副作用
+
+除产生目标 tile 外,没有额外架构副作用。
+
## 约束
-- **实现检查 (A2A3)**:
- - 对于Tile位置是向量(`TileData::Loc == TileType::Vec`):
- - `TileData::DType` 必须是以下之一:`int8_t`、`uint8_t`、`int16_t`、`uint16_t`、`int32_t`、`uint32_t`、`half`、`bfloat16_t`、`float`。
- - 静态有效边界: `TileData::ValidRow <= TileData::Rows`且`TileData::ValidCol <= TileData::Cols`.
- - 对于Tile位置是Mat(`TileData::Loc == TileType::Mat`):
- - `TileData::DType` 必须是以下之一:`int8_t`、`uint8_t`、`int16_t`、`uint16_t`、`int32_t`、`uint32_t`、`half`、`bfloat16_t`、`float`。
- - 有效边界:`TileData::Rows * TileData::Cols * sizeof(T) / 32` 必须在`[1, 32767]`范围内。
-- **实现检查 (A5)**:
- - 对于Tile位置是向量(`TileData::Loc == TileType::Vec`):
- - 静态有效边界: `TileData::ValidRow <= TileData::Rows`且`TileData::ValidCol <= TileData::Cols`.
- - `TileData::DType` 必须是以下之一: `uint8_t`, `int8_t`, `uint16_t`, `int16_t`, `uint32_t`, `int32_t`, `half`, `float`.
- - 对于Tile位置是Mat(`TileData::Loc == TileType::Mat`):
- - `TileData::DType` 必须是以下之一: `uint8_t`, `int8_t`, `uint16_t`, `int16_t`, `uint32_t`, `int32_t`, `half`, `float`.
- - 对于`TileDataDst::layout == pto::Layout::NC1HWC0 || TileDataDst::layout == pto::Layout::FRACTAL_Z`:
- - `TileData::shape0 * TileData::shape1 * TileData::shape2 * TileData::shape3` 必须在`[1, 32767]`范围内。
- - 对于`TileDataDst::layout == pto::Layout::NDC1HWC0 || TileDataDst::layout == pto::Layout::FRACTAL_Z_3D`:
- - `TileData::shape0 * TileData::shape1 * TileData::shape2 * TileData::shape3 * TileData::shape4` 必须在`[1, 32767]`范围内。
-- **有效区域**:
- - 对于Tile位置是向量(`TileData::Loc == TileType::Vec`):
- - 该操作在 `dst.GetValidRow()` / `dst.GetValidCol()` 上填充 `dst`。
- - 对于Tile位置是Mat(`TileData::Loc == TileType::Mat`):
- - 对于Tile,该操作在 `TileData::Rows` / `TileData::Cols` 上填充 `dst`。
- - 对于convTile,该操作在`ConvTileData`的`shape`内填充`dst`。
+- Tile 位置可以是向量或 Mat。
+- A2/A3 向量支持:`int8_t`、`uint8_t`、`int16_t`、`uint16_t`、`int32_t`、`uint32_t`、`half`、`bfloat16_t`、`float`。
+- A5 向量支持:`uint8_t`、`int8_t`、`uint16_t`、`int16_t`、`uint32_t`、`int32_t`、`half`、`float`。
+- A2/A3 Mat 要求:`TileData::Rows * TileData::Cols * sizeof(T) / 32` 在 `[1, 32767]` 范围内。
+- A5 向量静态有效边界:`TileData::ValidRow <= TileData::Rows` 且 `TileData::ValidCol <= TileData::Cols`。
+- A5 Mat 约束因布局而异。
+
+## 异常与非法情形
+
+- 不支持的元素类型会被 verifier 拒绝。
+- 所选 target profile 不支持的形状/布局约束会被后端拒绝。
+
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| `f32` | Simulated | Supported | Supported |
+| `f16` | Simulated | Supported | Supported |
+| `bf16` | Simulated | Supported | No |
+| `i32 / u32` | Simulated | Supported | Supported |
+| `i16 / u16` | Simulated | Supported | Supported |
+| `i8 / u8` | Simulated | Supported | Supported |
+| Vec Layout | Any | Any | RowMajor |
+| Mat Layout | Any | Supported | Supported |
## 示例
-### 自动(Auto)
+### C++ 自动模式
```cpp
#include
@@ -87,7 +101,7 @@ void example_auto() {
}
```
-### 手动(Manual)
+### C++ 手动模式
```cpp
#include
@@ -102,29 +116,18 @@ void example_manual() {
}
```
-## 汇编示例(ASM)
-
-### 自动模式
+### PTO-AS
```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
-%dst = pto.texpands %scalar : dtype -> !pto.tile<...>
+%dst = texpands %scalar : f32, !pto.tile<...>
```
-### 手动模式
+### AS Level 2(DPS)
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
-%dst = pto.texpands %scalar : dtype -> !pto.tile<...>
+```mlir
+pto.texpands ins(%scalar : dtype) outs(%dst : !pto.tile_buf<...>)
```
-### PTO 汇编形式
+## 相关页面
-```text
-%dst = texpands %scalar : f32, !pto.tile<...>
-# AS Level 2 (DPS)
-pto.texpands ins(%scalar : dtype) outs(%dst : !pto.tile_buf<...>)
-```
+- 指令集总览:[逐元素 Tile-标量](./tile/tile-scalar-and-immediate_zh.md)
diff --git a/docs/isa/TEXP_zh.md b/docs/isa/TEXP_zh.md
index 5a4dcb18..848ce5cf 100644
--- a/docs/isa/TEXP_zh.md
+++ b/docs/isa/TEXP_zh.md
@@ -1,127 +1,140 @@
-# TEXP
-
-## 指令示意图
-
-
-
-## 简介
-
-逐元素指数运算。
-
-## 数学语义
-
-对每个元素 `(i, j)` 在有效区域内:
-
-$$ \mathrm{dst}_{i,j} = \exp(\mathrm{src}_{i,j}) $$
-
-## 汇编语法
-
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
-
-同步形式:
-
-```text
-%dst = texp %src : !pto.tile<...>
-```
-
-### AS Level 1(SSA)
-
-```text
-%dst = pto.texp %src : !pto.tile<...> -> !pto.tile<...>
-```
-
-### AS Level 2(DPS)
-
-```text
-pto.texp ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
-```
-
-## C++ 内建接口
-
-声明于 `include/pto/common/pto_instr.hpp`:
-
-```cpp
-template
-PTO_INST RecordEvent TEXP(TileDataDst &dst, TileDataSrc &src, WaitEvents &... events);
-```
-
-`PrecisionType`可指定以下值:
-
-* `ExpAlgorithm::DEFAULT`:普通算法,速度快但精度较低。
-* `ExpAlgorithm::HIGH_PRECISION`:高精度算法,速度较慢。
-
-
-## 约束
-
-- **实现检查 (NPU)**:
- - `TileData::DType` 必须是以下之一:`float` 或 `half`。
- - Tile 位置必须是向量(`TileData::Loc == TileType::Vec`);
- - 静态有效边界:`TileData::ValidRow <= TileData::Rows` 且 `TileData::ValidCol <= TileData::Cols`。
- - 运行时:`src.GetValidRow() == dst.GetValidRow()` 且 `src.GetValidCol() == dst.GetValidCol()`。
- - Tile 布局必须是行主序(`TileData::isRowMajor`)。
-- **有效区域**:
- - 该操作使用 `dst.GetValidRow()` / `dst.GetValidCol()` 作为迭代域。
-- **高精度算法**
- - 仅在A5上有效,`PrecisionType`选项A3上将被忽略。
-
-
-## 示例
-
-### 自动(Auto)
-
-```cpp
-#include
-
-using namespace pto;
-
-void example_auto() {
- using TileT = Tile;
- TileT src, dst;
- TEXP(dst, src);
- TEXP(dst, src); // A5 Only
-}
-```
-
-### 手动(Manual)
-
-```cpp
-#include
-
-using namespace pto;
-
-void example_manual() {
- using TileT = Tile;
- TileT src, dst;
- TASSIGN(src, 0x1000);
- TASSIGN(dst, 0x2000);
- TEXP(dst, src);
-}
-```
-
-## 汇编示例(ASM)
-
-### 自动模式
-
-```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
-%dst = pto.texp %src : !pto.tile<...> -> !pto.tile<...>
-```
-
-### 手动模式
-
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
-%dst = pto.texp %src : !pto.tile<...> -> !pto.tile<...>
-```
-
-### PTO 汇编形式
-
-```text
-%dst = texp %src : !pto.tile<...>
-# AS Level 2 (DPS)
-pto.texp ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
-```
+# pto.texp
+
+
+
+`pto.texp` 属于[逐元素 Tile-Tile](./tile/elementwise-tile-tile_zh.md)指令集。
+
+## 概述
+
+对 tile 做逐元素指数运算,结果写入目标 tile。迭代域由目标 tile 的 valid region 决定。
+
+## 机制
+
+对目标 tile 的 valid region 中每个 `(i, j)`:
+
+$$ \mathrm{dst}_{i,j} = \exp(\mathrm{src}_{i,j}) $$
+
+它是 tile 路径上的一元超越函数,常见于 softmax、归一化和指数域变换。
+
+## 语法
+
+### PTO-AS
+
+```text
+%dst = texp %src : !pto.tile<...>
+```
+
+### AS Level 1(SSA)
+
+```mlir
+%dst = pto.texp %src : !pto.tile<...> -> !pto.tile<...>
+```
+
+### AS Level 2(DPS)
+
+```mlir
+pto.texp ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
+```
+
+## C++ 内建接口
+
+```cpp
+template
+PTO_INST RecordEvent TEXP(TileDataDst &dst, TileDataSrc &src, WaitEvents &... events);
+```
+
+`PrecisionType` 可选:
+
+- `ExpAlgorithm::DEFAULT`:普通算法,速度快但精度较低。
+- `ExpAlgorithm::HIGH_PRECISION`:高精度算法,速度较慢。
+
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| `%src` | 源 tile | 输入 tile |
+| `%dst` | 目标 tile | 接收逐元素指数结果 |
+| `WaitEvents...` | 可选同步 | 发射前需要等待的事件 |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `%dst` | `!pto.tile<...>` | `dst` valid region 内的每个元素都等于 `exp(src)` |
+
+## 副作用
+
+除产生目标 tile 外,没有额外架构副作用。
+
+## 约束
+
+- 支持类型当前是 `float` / `half`。
+- tile 必须是行主序向量 tile。
+- 操作迭代域由 `dst.GetValidRow()` / `dst.GetValidCol()` 决定。
+- 高精度算法只在 A5 有效。
+
+## 异常与非法情形
+
+- 非法操作数组合、不支持的数据类型、不合法布局或不支持的 target-profile 模式,会被 verifier 或后端实现拒绝。
+
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| `float` | Simulated | Supported | Supported |
+| `half` | Simulated | Supported | Supported |
+| 布局 | Any | RowMajor only | RowMajor only |
+
+## 示例
+
+### C++ 自动模式
+
+```cpp
+#include
+using namespace pto;
+
+void example_auto() {
+ using TileT = Tile;
+ TileT src, dst;
+ TEXP(dst, src);
+ TEXP(dst, src); // A5 Only
+}
+```
+
+### C++ 手动模式
+
+```cpp
+#include
+using namespace pto;
+
+void example_manual() {
+ using TileT = Tile;
+ TileT src, dst;
+ TASSIGN(src, 0x1000);
+ TASSIGN(dst, 0x2000);
+ TEXP(dst, src);
+}
+```
+
+### PTO-AS
+
+```text
+# 自动模式
+%dst = pto.texp %src : !pto.tile<...> -> !pto.tile<...>
+
+# 手动模式
+pto.tassign %arg0, @tile(0x1000)
+pto.tassign %arg1, @tile(0x2000)
+%dst = pto.texp %src : !pto.tile<...> -> !pto.tile<...>
+
+# PTO 汇编形式
+%dst = texp %src : !pto.tile<...>
+# AS Level 2 (DPS)
+pto.texp ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
+```
+
+## 相关页面
+
+- 指令集总览:[逐元素 Tile-Tile](./tile/elementwise-tile-tile_zh.md)
+- 规范页:[pto.texp](./tile/ops/elementwise-tile-tile/texp_zh.md)
diff --git a/docs/isa/TEXTRACT_FP_zh.md b/docs/isa/TEXTRACT_FP_zh.md
index 648131b2..cc66c964 100644
--- a/docs/isa/TEXTRACT_FP_zh.md
+++ b/docs/isa/TEXTRACT_FP_zh.md
@@ -1,30 +1,30 @@
-# TEXTRACT_FP
+# pto.textract_fp
-## 指令示意图
+`pto.textract_fp` 属于[布局与重排](./tile/ops/layout-and-rearrangement/textract-fp_zh.md)指令集。
-
-
-## 简介
+## 概述
-带 fp/缩放 Tile 的提取(向量量化参数)。
+带 fp/缩放 Tile 的提取(向量量化参数),语义在有效区域上定义,目标相关的行为标记为实现定义。
-## 数学语义
+## 机制
除非另有说明,语义在有效区域上定义,目标相关的行为标记为实现定义。
-## 汇编语法
+## 语法
+
+### PTO-AS
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.textract_fp %src, %idxrow, %idxcol : (!pto.tile<...>, dtype, dtype) -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.textract_fp ins(%src, %idxrow, %idxcol : !pto.tile_buf<...>, dtype, dtype) outs(%dst : !pto.tile_buf<...>)
```
@@ -38,37 +38,89 @@ template , dtype, dtype) -> !pto.tile<...>
+## 示例
+
+### C++ 自动模式
+
+```cpp
+#include
+
+using namespace pto;
+
+void example_auto() {
+ using SrcT = Tile;
+ using DstT = TileLeft;
+ using FpT = TileScale;
+ SrcT src;
+ DstT dst;
+ FpT fp;
+ TEXTRACT_FP(dst, src, fp, /*indexRow=*/0, /*indexCol=*/0);
+}
```
-### 手动模式
+### C++ 手动模式
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
-%dst = pto.textract_fp %src, %idxrow, %idxcol : (!pto.tile<...>, dtype, dtype) -> !pto.tile<...>
+```cpp
+#include
+
+using namespace pto;
+
+void example_manual() {
+ using SrcT = Tile;
+ using DstT = TileLeft;
+ using FpT = TileScale;
+ SrcT src;
+ DstT dst;
+ FpT fp;
+ TASSIGN(src, 0x1000);
+ TASSIGN(dst, 0x2000);
+ TASSIGN(fp, 0x3000);
+ TEXTRACT_FP(dst, src, fp, /*indexRow=*/0, /*indexCol=*/0);
+}
```
-### PTO 汇编形式
+### PTO-AS
-```text
+```mlir
%dst = pto.textract_fp %src, %idxrow, %idxcol : (!pto.tile<...>, dtype, dtype) -> !pto.tile<...>
-# AS Level 2 (DPS)
-pto.textract_fp ins(%src, %idxrow, %idxcol : !pto.tile_buf<...>, dtype, dtype) outs(%dst : !pto.tile_buf<...>)
```
+
+
+
+## 相关页面
+
+- 指令集总览:[布局与重排](./tile/ops/layout-and-rearrangement/textract-fp_zh.md)
diff --git a/docs/isa/TEXTRACT_zh.md b/docs/isa/TEXTRACT_zh.md
index 14266890..71b0ba0a 100644
--- a/docs/isa/TEXTRACT_zh.md
+++ b/docs/isa/TEXTRACT_zh.md
@@ -1,24 +1,20 @@
# pto.textract
-旧路径兼容入口。规范页见 [pto.textract](./tile/ops/layout-and-rearrangement/textract_zh.md)。
+`pto.textract` 属于[布局与重排](./tile/ops/layout-and-rearrangement/textract_zh.md)指令集。
-
-
-## 简介
+## 概述
-从较大的源 Tile 中提取较小的子 Tile。
+从较大的源 Tile 中提取较小的子 Tile,概念上从较大的 `src` Tile 中,以 `(indexRow, indexCol)` 为起点复制一个较小窗口到 `dst`,确切的映射取决于 tile 布局。
-## 数学语义
-
-概念上从较大的 `src` Tile 中,以 `(indexRow, indexCol)` 为起点复制一个较小窗口到 `dst`。确切的映射取决于 tile 布局。
+## 机制
设 `R = dst.GetValidRow()` 和 `C = dst.GetValidCol()`。对于 `0 <= i < R` 和 `0 <= j < C`:
$$ \mathrm{dst}_{i,j} = \mathrm{src}_{\mathrm{indexRow}+i,\; \mathrm{indexCol}+j} $$
-## 汇编语法
+## 语法
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+### PTO-AS
同步形式:
@@ -28,13 +24,13 @@ PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.textract %src, %idxrow, %idxcol : (!pto.tile<...>, dtype, dtype) -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.textract ins(%src, %idxrow, %idxcol : !pto.tile_buf<...>, dtype, dtype) outs(%dst : !pto.tile_buf<...>)
```
@@ -58,6 +54,25 @@ template TileType::Left/Right/Scale`、`TileType::Acc -> TileType::Mat`(含 relu、标量量化、向量量化形式),以及特定的 `TileType::Vec -> TileType::Mat` 提取路径。
- 向量量化形式额外要求提供 `FpTileData` 缩放操作数,对应 `TEXTRACT_FP(...)` 接口。
+## 异常与非法情形
+
+- 当 `DstTileData::DType` 与 `SrcTileData::DType` 不匹配时行为未定义。
+- 当 `indexRow + DstTileData::Rows > SrcTileData::Rows` 时行为未定义。
+- 当 `indexCol + DstTileData::Cols > SrcTileData::Cols` 时行为未定义。
+
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| int8_t 提取 | ✓ | ✓ | ✓ |
+| float 提取 | ✓ | ✓ | ✓ |
+| bfloat16 提取 | ✓ | ✓ | ✓ |
+| 向量量化形式 | ✗ | ✗ | ✓ |
+
## 示例
-### 自动(Auto)
+### C++ 自动模式
```cpp
#include
@@ -105,7 +135,7 @@ void example_auto() {
}
```
-### 手动(Manual)
+### C++ 手动模式
```cpp
#include
@@ -123,31 +153,20 @@ void example_manual() {
}
```
-## 汇编示例(ASM)
-
-### 自动模式
+### PTO-AS
```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
-%dst = pto.textract %src, %idxrow, %idxcol : (!pto.tile<...>, dtype, dtype) -> !pto.tile<...>
+%dst = textract %src[%r0, %r1] : !pto.tile<...> -> !pto.tile<...>
```
-### 手动模式
+AS Level 2 (DPS):
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
-%dst = pto.textract %src, %idxrow, %idxcol : (!pto.tile<...>, dtype, dtype) -> !pto.tile<...>
+```mlir
+pto.textract ins(%src, %idxrow, %idxcol : !pto.tile_buf<...>, dtype, dtype) outs(%dst : !pto.tile_buf<...>)
```
-### PTO 汇编形式
+
-```text
-%dst = textract %src[%r0, %r1] : !pto.tile<...> -> !pto.tile<...>
-# AS Level 2 (DPS)
-pto.textract ins(%src, %idxrow, %idxcol : !pto.tile_buf<...>, dtype, dtype) outs(%dst : !pto.tile_buf<...>)
-```
+## 相关页面
-新的 PTO ISA 文档应直接链接到分组后的指令集路径。
+- 指令集总览:[布局与重排](./tile/ops/layout-and-rearrangement/textract_zh.md)
diff --git a/docs/isa/TFMOD_zh.md b/docs/isa/TFMOD_zh.md
index fbc25dfe..59389a59 100644
--- a/docs/isa/TFMOD_zh.md
+++ b/docs/isa/TFMOD_zh.md
@@ -1,24 +1,24 @@
-# TFMOD
-
-## 指令示意图
+# pto.tfmod

-## 简介
+`pto.tfmod` 属于[逐元素 Tile-Tile](./tile/elementwise-tile-tile_zh.md)指令集。
+
+## 概述
-两个 Tile 的逐元素余数,余数符号与被除数相同。
+对两个 tile 做逐元素 `fmod` 运算,结果写入目标 tile。迭代域由目标 tile 的 valid region 决定。
-## 数学语义
+## 机制
-对每个元素 `(i, j)` 在有效区域内:
+对目标 tile 的 valid region 中每个 `(i, j)`:
-$$\mathrm{dst}_{i,j} = \mathrm{fmod}(\mathrm{src0}_{i,j}, \mathrm{src1}_{i,j})$$
+$$ \mathrm{dst}_{i,j} = \mathrm{fmod}(\mathrm{src0}_{i,j}, \mathrm{src1}_{i,j}) $$
-## 汇编语法
+它表示浮点余数语义,余数符号与被除数(`src0`)相同。常用于周期折返、相位归一化和浮点余数路径。除零行为由目标 profile 定义。
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+## 语法
-同步形式:
+### PTO-AS
```text
%dst = tfmod %src0, %src1 : !pto.tile<...>
@@ -26,35 +26,68 @@ PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.tfmod %src0, %src1 : !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.tfmod ins(%src0, %src1 : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
## C++ 内建接口
-声明于 `include/pto/common/pto_instr.hpp`:
-
```cpp
template
PTO_INST RecordEvent TFMOD(TileDataDst &dst, TileDataSrc0 &src0, TileDataSrc1 &src1, WaitEvents &... events);
```
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| `%src0` | 左 tile | 被除数 tile,在 `dst` valid region 上逐坐标读取 |
+| `%src1` | 右 tile | 除数 tile,在 `dst` valid region 上逐坐标读取 |
+| `%dst` | 目标 tile | 接收逐元素 fmod 结果 |
+| `WaitEvents...` | 可选同步 | 发射前需要等待的事件 |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `%dst` | `!pto.tile<...>` | `dst` valid region 内的每个元素都等于 `fmod(src0, src1)` |
+
+## 副作用
+
+除产生目标 tile 外,没有额外架构副作用。
+
## 约束
-- 该操作在 `dst.GetValidRow()` / `dst.GetValidCol()` 上迭代。
-- 除零行为由目标定义;CPU 模拟器在调试构建中会断言。
+- 迭代域由 `dst.GetValidRow()` / `dst.GetValidCol()` 决定。
+- 除零行为由目标 profile 定义;CPU 模拟器在调试构建下会断言。
+
+## 异常与非法情形
+
+- 非法操作数组合、不支持的数据类型、不合法布局或不支持的 target-profile 模式,会被 verifier 或后端实现拒绝。
+
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| `int32_t` | Simulated | Supported | Supported |
+| `float` | Simulated | Supported | Supported |
+| `half` | Simulated | Supported | Supported |
+| 布局 | Any | RowMajor only | RowMajor only |
+
+`pto.tfmod` 在 CPU 仿真、A2/A3 和 A5 上保留相同的 PTO 可见语义,但具体支持子集仍取决于 profile。
## 示例
+### C++ 自动模式
+
```cpp
#include
-
using namespace pto;
void example() {
@@ -64,29 +97,40 @@ void example() {
}
```
-## 汇编示例(ASM)
+### C++ 手动模式
-### 自动模式
+```cpp
+#include
+using namespace pto;
-```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
-%dst = pto.tfmod %src0, %src1 : !pto.tile<...>
+void example_manual() {
+ using TileT = Tile;
+ TileT a, b, dst;
+ TASSIGN(a, 0x1000);
+ TASSIGN(b, 0x2000);
+ TASSIGN(dst, 0x3000);
+ TFMOD(dst, a, b);
+}
```
-### 手动模式
+### PTO-AS
```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
+# 自动模式
%dst = pto.tfmod %src0, %src1 : !pto.tile<...>
-```
-### PTO 汇编形式
+# 手动模式
+pto.tassign %arg0, @tile(0x1000)
+pto.tassign %arg1, @tile(0x2000)
+%dst = pto.tfmod %src0, %src1 : !pto.tile<...>
-```text
+# PTO 汇编形式
%dst = tfmod %src0, %src1 : !pto.tile<...>
# AS Level 2 (DPS)
pto.tfmod ins(%src0, %src1 : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
+
+## 相关页面
+
+- 指令集总览:[逐元素 Tile-Tile](./tile/elementwise-tile-tile_zh.md)
+- 规范页:[pto.tfmod](./tile/ops/elementwise-tile-tile/tfmod_zh.md)
diff --git a/docs/isa/TFREE_zh.md b/docs/isa/TFREE_zh.md
index 30cfbca7..8e1592dc 100644
--- a/docs/isa/TFREE_zh.md
+++ b/docs/isa/TFREE_zh.md
@@ -1,41 +1,91 @@
-# TFREE
+# pto.tfree
-## 指令示意图
+`pto.tfree` 属于[同步与配置](./tile/sync-and-config_zh.md)指令集。
-
-
-## 简介
+## 概述
将当前占用的 pipe 或 FIFO 槽位释放回生产者。
-## 数学语义
+## 机制
+
+语义随具体指令变体而变化。除非另有说明,行为都按目标 valid region 定义。
-语义随指令而变化。 除非另有说明,行为都按目标 valid region 定义。
+## 语法
-## 汇编语法
+### PTO-AS
PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.tfree ...
```
### AS Level 2(DPS)
-```text
+```mlir
pto.tfree ins(...) outs(%dst : !pto.tile_buf<...>)
```
## C++ 内建接口
-声明于 `include/pto/common/pto_instr.hpp`.
+声明于 `include/pto/common/pto_instr.hpp`。
+
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| 源 Tile | 输入 | 待释放槽位中的 Tile |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| 无 | - | 释放操作无返回值,仅将槽位归还生产者 |
+
+## 副作用
+
+释放 pipe 或 FIFO 槽位,将其归还给生产者供后续使用。
## 约束
-数据类型、layout、location 和 shape 的进一步限制以对应 backend 的合法性检查为准。
+- 数据类型、layout、location 和 shape 的进一步限制以对应 backend 的合法性检查为准。
+- 只能释放当前核/线程持有的槽位。
+
+## 异常与非法情形
+
+- 释放未持有的槽位属于未定义行为。
+- 在 pipe 或 FIFO 未正确初始化的情形下执行会被后端拒绝。
+
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| 释放操作 | Simulated | Supported | Supported |
## 示例
+### C++ 自动模式
+
+具体的 Auto / Manual 使用方式见 `docs/isa/` 下的相关指令页。
+
+### C++ 手动模式
+
具体的 Auto / Manual 使用方式见 `docs/isa/` 下的相关指令页。
+
+### PTO-AS
+
+```text
+%result = pto.tfree %tile : !pto.tile<...>
+```
+
+### AS Level 2(DPS)
+
+```mlir
+pto.tfree ins(%tile : ...) outs(%dst : !pto.tile_buf<...>)
+```
+
+## 相关页面
+
+- 指令集总览:[同步与配置](./tile/sync-and-config_zh.md)
diff --git a/docs/isa/TGEMV_MX_zh.md b/docs/isa/TGEMV_MX_zh.md
index b3544e3d..b01fac8a 100644
--- a/docs/isa/TGEMV_MX_zh.md
+++ b/docs/isa/TGEMV_MX_zh.md
@@ -1,26 +1,22 @@
-# TGEMV_MX
+# pto.tgemv.mx
-## 指令示意图
+`pto.tgemv.mx` 属于[矩阵与矩阵-向量运算](./tile/ops/matrix-and-matrix-vector/tgemv-mx_zh.md)指令集。
-
-
-## 简介
+## 概述
-带缩放 Tile 的 GEMV 变体,支持混合精度/量化矩阵向量计算。
+带缩放 Tile 的 GEMV 变体,支持混合精度/量化矩阵向量计算。缩放 tile 参与实现定义的混合精度重建/缩放,输出对应于目标定义的 mx GEMV 语义。
-## 数学语义
+## 机制
概念上(基础 GEMV 路径):
-$$
-\mathrm{C}_{0,j} = \sum_{k=0}^{K-1} \mathrm{A}_{0,k} \cdot \mathrm{B}_{k,j}
-$$
+$$ \mathrm{C}_{0,j} = \sum_{k=0}^{K-1} \mathrm{A}_{0,k} \cdot \mathrm{B}_{k,j} $$
对于 `TGEMV_MX`,缩放 tile 参与实现定义的混合精度重建/缩放。架构约定是输出对应于目标定义的 mx GEMV 语义。
-## 汇编语法
+## 语法
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+### PTO-AS
示意形式:
@@ -30,14 +26,14 @@ PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%acc = pto.tgemv.mx %a, %a_scale, %b, %b_scale : (!pto.tile<...>, !pto.tile<...>, !pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
-pto.tgemv.mx ins(%a, %a_scale, %b, %b_scale : (!pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>)) outs(%acc : !pto.tile_buf<...>)
+```mlir
+pto.tgemv.mx ins(%a, %a_scale, %b, %b_scale : !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%acc : !pto.tile_buf<...>)
```
## C++ 内建接口
@@ -72,42 +68,94 @@ PTO_INST RecordEvent TGEMV_MX(TileRes &cMatrix, TileLeft &aMatrix, TileLeftScale
附加重载支持累加/偏置变体和 `AccPhase` 选择。
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| `aMatrix` | Left | 左操作数向量 Tile |
+| `aScaleMatrix` | LeftScale | 左操作数缩放 Tile |
+| `bMatrix` | Right | 右操作数矩阵 Tile |
+| `bScaleMatrix` | RightScale | 右操作数缩放 Tile |
+| `biasData` | Bias | 偏置 Tile(偏置形式可选) |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `cMatrix` / `cOutMatrix` | Acc | MX GEMV 结果 Tile |
+
+## 副作用
+
+MX 混合精度操作可能触发目标特定的缩放、反量化或溢出处理行为。
+
## 约束
- 使用后端特定的 mx 合法性检查,用于数据类型、tile 位置、分形/布局组合以及缩放格式。
- 缩放 tile 兼容性和累加器提升由目标后端的实现定义。
- 为了可移植性,请根据目标实现约束验证确切的 `(A, B, scaleA, scaleB, C)` 类型元组和 tile 布局。
+## 异常与非法情形
+
+- 当缩放 tile 类型或布局不符合目标要求时行为未定义。
+- 当数据类型组合不符合目标支持的 mx 规格时行为未定义。
+
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| MX GEMV | ✓ | ✗ | ✓ |
+| MX GEMV 累加 | ✓ | ✗ | ✓ |
+| MX GEMV 偏置 | ✓ | ✗ | ✓ |
+
## 示例
-实际使用模式请参见:
+### C++ 自动模式
+实际使用模式请参见:
- `docs/isa/TMATMUL_MX.md`
- `docs/isa/TGEMV.md`
-## 汇编示例(ASM)
+### C++ 手动模式
-### 自动模式
-
-```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
-%acc = pto.tgemv.mx %a, %a_scale, %b, %b_scale : (!pto.tile<...>, !pto.tile<...>, !pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
+```cpp
+#include
+
+using namespace pto;
+
+void example_manual() {
+ using A = TileLeft;
+ using B = TileRight;
+ using ScaleA = TileLeftScale;
+ using ScaleB = TileRightScale;
+ using C = TileAcc;
+ A a;
+ B b;
+ ScaleA scaleA;
+ ScaleB scaleB;
+ C c;
+ TASSIGN(a, 0x1000);
+ TASSIGN(b, 0x2000);
+ TASSIGN(scaleA, GetScaleAddr(a.data()));
+ TASSIGN(scaleB, GetScaleAddr(b.data()));
+ TASSIGN(c, 0x3000);
+ TGEMV_MX(c, a, scaleA, b, scaleB);
+}
```
-### 手动模式
+### PTO-AS
```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
-%acc = pto.tgemv.mx %a, %a_scale, %b, %b_scale : (!pto.tile<...>, !pto.tile<...>, !pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
+%acc = tgemv.mx %a, %a_scale, %b, %b_scale : (!pto.tile<...>, !pto.tile<...>, !pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
-### PTO 汇编形式
+AS Level 2 (DPS):
-```text
-%acc = pto.tgemv.mx %a, %a_scale, %b, %b_scale : (!pto.tile<...>, !pto.tile<...>, !pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-# AS Level 2 (DPS)
-pto.tgemv.mx ins(%a, %a_scale, %b, %b_scale : (!pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>)) outs(%acc : !pto.tile_buf<...>)
+```mlir
+pto.tgemv.mx ins(%a, %a_scale, %b, %b_scale : !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%acc : !pto.tile_buf<...>)
```
+
+
+
+## 相关页面
+
+- 指令集总览:[矩阵与矩阵-向量运算](./tile/ops/matrix-and-matrix-vector/tgemv-mx_zh.md)
diff --git a/docs/isa/THISTOGRAM_zh.md b/docs/isa/THISTOGRAM_zh.md
index 6fd1c648..70ab70a2 100644
--- a/docs/isa/THISTOGRAM_zh.md
+++ b/docs/isa/THISTOGRAM_zh.md
@@ -1,41 +1,93 @@
-# THISTOGRAM
+# pto.thistogram
-## 指令示意图
+`pto.thistogram` 属于[不规则与复杂](./tile/irregular-and-complex_zh.md)指令集。
-
-
-## 简介
+## 概述
使用索引 Tile 从源值中累计直方图 bin 计数。
-## 数学语义
+## 机制
+
+语义随具体指令变体而变化。除非另有说明,行为都按目标 valid region 定义。
-语义随指令而变化。 除非另有说明,行为都按目标 valid region 定义。
+## 语法
-## 汇编语法
+### PTO-AS
PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.thistogram ...
```
### AS Level 2(DPS)
-```text
+```mlir
pto.thistogram ins(...) outs(%dst : !pto.tile_buf<...>)
```
## C++ 内建接口
-声明于 `include/pto/common/pto_instr.hpp`.
+声明于 `include/pto/common/pto_instr.hpp`。
+
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| 源值 Tile | 输入 | 待累计的源值 Tile |
+| 索引 Tile | 输入 | 指定每个值应落入的直方图 bin |
+| 直方图 Tile | 输入/输出 | 累计计数的直方图 Tile |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `%dst` | `!pto.tile_buf` | 更新后的直方图 Tile |
+
+## 副作用
+
+直方图 Tile 中的 bin 计数会被原地更新。
## 约束
-数据类型、layout、location 和 shape 的进一步限制以对应 backend 的合法性检查为准。
+- 数据类型、layout、location 和 shape 的进一步限制以对应 backend 的合法性检查为准。
+- 索引值必须在直方图 bin 范围内。
+
+## 异常与非法情形
+
+- 索引越界会被 verifier 或运行时检测并拒绝。
+- 不支持的元素类型或布局会被后端拒绝。
+
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| 直方图操作 | Simulated | Supported | Supported |
## 示例
+### C++ 自动模式
+
+具体的 Auto / Manual 使用方式见 `docs/isa/` 下的相关指令页。
+
+### C++ 手动模式
+
具体的 Auto / Manual 使用方式见 `docs/isa/` 下的相关指令页。
+
+### PTO-AS
+
+```text
+%dst = pto.thistogram %values, %indices, %histogram : ...
+```
+
+### AS Level 2(DPS)
+
+```mlir
+pto.thistogram ins(%values, %indices : ...) outs(%dst : !pto.tile_buf<...>)
+```
+
+## 相关页面
+
+- 指令集总览:[不规则与复杂](./tile/irregular-and-complex_zh.md)
diff --git a/docs/isa/TIMG2COL_zh.md b/docs/isa/TIMG2COL_zh.md
index 2fe24146..9ca57725 100644
--- a/docs/isa/TIMG2COL_zh.md
+++ b/docs/isa/TIMG2COL_zh.md
@@ -1,30 +1,30 @@
-# TIMG2COL
+# pto.timg2col
-## 指令示意图
+`pto.timg2col` 属于[布局与重排](./tile/ops/layout-and-rearrangement/timg2col_zh.md)指令集。
-
+## 概述
-## 简介
+用于类卷积工作负载的图像到列变换,将图像 tile 重新排列为适合 GEMM 操作的列格式,语义在有效区域上定义,目标相关的行为标记为实现定义。
-用于类卷积工作负载的图像到列变换。
+## 机制
-## 数学语义
+除非另有说明,语义在有效区域上定义,目标相关的行为标记为实现定义。
-除非另有说明, semantics are defined over the valid region and target-dependent behavior is marked as implementation-defined.
+## 语法
-## 汇编语法
+### PTO-AS
-PTO-AS 形式:参见 [PTO-AS Specification](../assembly/PTO-AS_zh.md).
+参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.timg2col %src : !pto.tile<...> -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.timg2col ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
@@ -37,10 +37,80 @@ PTO_INST RecordEvent TIMG2COL(TileData &dst, ConvTileData &src, uint16_t posM =
WaitEvents&... events);
```
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| `src` | Conv | 输入卷积图像 Tile |
+| `posM` | - | M 维度偏移量 |
+| `posK` | - | K 维度偏移量 |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `dst` | - | img2col 变换后的 Tile |
+
+## 副作用
+
+img2col 变换可能产生填充值或目标特定的填充模式。
+
## 约束
-- This instruction is target/implementation-specific. See `include/pto/npu/*/TImg2col.hpp` for the supported tile types/layouts and config fields.
+- 此指令是目标/实现特定的。
+- 参见 `include/pto/npu/*/TImg2col.hpp` 了解支持的 tile 类型/布局和配置字段。
+
+## 异常与非法情形
+
+- 当输入 tile 类型或布局不被目标支持时行为未定义。
+- 当偏移量超出有效范围时行为未定义。
+
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| img2col 变换 | ✓ | ✓ | ✓ |
## 示例
-See related examples in `docs/isa/` and `docs/coding/tutorials/`.
+### C++ 自动模式
+
+```cpp
+#include
+
+using namespace pto;
+
+void example_auto() {
+ ConvTileData src;
+ TileData dst;
+ TIMG2COL(dst, src);
+}
+```
+
+### C++ 手动模式
+
+```cpp
+#include
+
+using namespace pto;
+
+void example_manual() {
+ ConvTileData src;
+ TileData dst;
+ TASSIGN(src, 0x1000);
+ TASSIGN(dst, 0x2000);
+ TIMG2COL(dst, src);
+}
+```
+
+### PTO-AS
+
+```mlir
+%dst = pto.timg2col %src : !pto.tile<...> -> !pto.tile<...>
+```
+
+
+
+## 相关页面
+
+- 指令集总览:[布局与重排](./tile/ops/layout-and-rearrangement/timg2col_zh.md)
diff --git a/docs/isa/TINSERT_FP_zh.md b/docs/isa/TINSERT_FP_zh.md
index 7010594a..02f72b51 100644
--- a/docs/isa/TINSERT_FP_zh.md
+++ b/docs/isa/TINSERT_FP_zh.md
@@ -1,74 +1,121 @@
-# TINSERT_FP
+# pto.tinsert_fp
-## 指令示意图
+`pto.tinsert_fp` 属于[不规则与复杂指令](./tile/irregular-and-complex_zh.md)集。
-
+## 概述
-## 简介
+带 fp/缩放 Tile 的插入操作,用于向量量化参数。除非另有说明,语义在有效区域上定义,目标相关的行为标记为实现定义。
-带 fp/缩放 Tile 的插入(向量量化参数)。
+## 机制
-## 数学语义
+对目标有效区域内的每个元素 `(i, j)`,将 `fp` Tile 中对应位置的值插入到 `src` 中,索引由 `idxrow` 和 `idxcol` 指定。
-除非另有说明,语义在有效区域上定义,目标相关的行为标记为实现定义。
+## 语法
-## 汇编语法
+### PTO-AS
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.tinsert_fp %src, %fp, %idxrow, %idxcol : (!pto.tile<...>, !pto.tile<...>, dtype, dtype) -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.tinsert_fp ins(%src, %fp, %idxrow, %idxcol : !pto.tile_buf<...>, !pto.tile_buf<...>, dtype, dtype) outs(%dst : !pto.tile_buf<...>)
```
## C++ 内建接口
-声明于 `include/pto/common/pto_instr.hpp`:
-
```cpp
template
PTO_INST RecordEvent TINSERT_FP(DstTileData &dst, SrcTileData &src, FpTileData &fp, uint16_t indexRow, uint16_t indexCol, WaitEvents &... events);
```
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| `src` | 源 Tile | 源数据 |
+| `fp` | 源 Tile | fp/缩放 Tile |
+| `idxrow` | 标量 | 行索引 |
+| `idxcol` | 标量 | 列索引 |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `dst` | Tile | 插入操作后的目标 Tile |
+
+## 副作用
+
+无。
+
## 约束
-类型/布局/位置/形状的合法性取决于后端;将实现特定的说明视为该后端的规范。
+- 类型/布局/位置/形状的合法性取决于后端;将实现特定的说明视为该后端的规范。
+
+## 异常与非法情形
+
+- 未定义。
+
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
## 示例
-参见 `docs/isa/` 和 `docs/coding/tutorials/` 中的相关示例。
+### C++ 自动模式
+
+```cpp
+#include
-## 汇编示例(ASM)
+using namespace pto;
-### 自动模式
+void example_auto() {
+ using TileT = Tile;
+ TileT src, fp, dst;
+ uint16_t idxrow = 0, idxcol = 0;
+ TINSERT_FP(dst, src, fp, idxrow, idxcol);
+}
+```
-```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
-%dst = pto.tinsert_fp %src, %fp, %idxrow, %idxcol : (!pto.tile<...>, !pto.tile<...>, dtype, dtype) -> !pto.tile<...>
+### C++ 手动模式
+
+```cpp
+#include
+
+using namespace pto;
+
+void example_manual() {
+ using TileT = Tile;
+ TileT src, fp, dst;
+ uint16_t idxrow = 0, idxcol = 0;
+ TASSIGN(src, 0x1000);
+ TASSIGN(fp, 0x2000);
+ TASSIGN(dst, 0x3000);
+ TINSERT_FP(dst, src, fp, idxrow, idxcol);
+}
```
-### 手动模式
+### PTO-AS
```text
+# 自动模式:由编译器/运行时负责资源放置与调度。
+%dst = pto.tinsert_fp %src, %fp, %idxrow, %idxcol : (!pto.tile<...>, !pto.tile<...>, dtype, dtype) -> !pto.tile<...>
+
# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
+# pto.tassign %src, @tile(0x1000)
+# pto.tassign %fp, @tile(0x2000)
+# pto.tassign %dst, @tile(0x3000)
%dst = pto.tinsert_fp %src, %fp, %idxrow, %idxcol : (!pto.tile<...>, !pto.tile<...>, dtype, dtype) -> !pto.tile<...>
```
-### PTO 汇编形式
+## 相关页面
-```text
-%dst = pto.tinsert_fp %src, %fp, %idxrow, %idxcol : (!pto.tile<...>, !pto.tile<...>, dtype, dtype) -> !pto.tile<...>
-# AS Level 2 (DPS)
-pto.tinsert_fp ins(%src, %fp, %idxrow, %idxcol : !pto.tile_buf<...>, !pto.tile_buf<...>, dtype, dtype) outs(%dst : !pto.tile_buf<...>)
-```
+- 指令集总览:[不规则与复杂指令](./tile/irregular-and-complex_zh.md)
diff --git a/docs/isa/TLOG_zh.md b/docs/isa/TLOG_zh.md
index b712bc42..a2359594 100644
--- a/docs/isa/TLOG_zh.md
+++ b/docs/isa/TLOG_zh.md
@@ -1,24 +1,24 @@
-# TLOG
-
-## 指令示意图
+# pto.tlog

-## 简介
+`pto.tlog` 属于[逐元素 Tile-Tile](./tile/elementwise-tile-tile_zh.md)指令集。
+
+## 概述
-Tile 的逐元素自然对数。
+对 tile 做逐元素自然对数,结果写入目标 tile。迭代域由目标 tile 的 valid region 决定。
-## 数学语义
+## 机制
-对每个元素 `(i, j)` 在有效区域内:
+对目标 tile 的 valid region 中每个 `(i, j)`:
$$ \mathrm{dst}_{i,j} = \log(\mathrm{src}_{i,j}) $$
-## 汇编语法
+它是 tile 路径上的一元对数操作,用于归一化、损失计算前处理和指数域反变换。对 `log(<=0)` 的域外情况,行为由目标 profile 定义。
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+## 语法
-同步形式:
+### PTO-AS
```text
%dst = tlog %src : !pto.tile<...>
@@ -26,51 +26,73 @@ PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.tlog %src : !pto.tile<...> -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.tlog ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
## C++ 内建接口
-声明于 `include/pto/common/pto_instr.hpp`:
-
```cpp
template
PTO_INST RecordEvent TLOG(TileDataDst &dst, TileDataSrc &src, WaitEvents &... events);
```
-`PrecisionType`可指定以下值:
+`PrecisionType` 可选:
+
+- `LogAlgorithm::DEFAULT`:普通算法,速度快但精度较低。
+- `LogAlgorithm::HIGH_PRECISION`:高精度算法,速度较慢。
+
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| `%src` | 源 tile | 输入 tile |
+| `%dst` | 目标 tile | 接收逐元素对数结果 |
+| `WaitEvents...` | 可选同步 | 发射前需要等待的事件 |
-* `LogAlgorithm::DEFAULT`:普通算法,速度快但精度较低。
-* `LogAlgorithm::HIGH_PRECISION`:高精度算法,速度较慢。
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `%dst` | `!pto.tile<...>` | `dst` valid region 内的每个元素都等于 `log(src)` |
+
+## 副作用
+
+除产生目标 tile 外,没有额外架构副作用。
## 约束
-- **实现检查 (NPU)**:
- - `TileData::DType` 必须是以下之一:`float` 或 `half`。
- - Tile 位置必须是向量(`TileData::Loc == TileType::Vec`);
- - 静态有效边界:`TileData::ValidRow <= TileData::Rows` 且 `TileData::ValidCol <= TileData::Cols`。
- - 运行时:`src.GetValidRow() == dst.GetValidRow()` 且 `src.GetValidCol() == dst.GetValidCol()`。
- - Tile 布局必须是行主序(`TileData::isRowMajor`)。
-- **有效区域**:
- - 该操作使用 `dst.GetValidRow()` / `dst.GetValidCol()` 作为迭代域.
-- **域 / NaN**:
- - 域行为(例如,`log(<=0)`)由目标定义。
-- **高精度算法**
- - 仅在A5上有效,`PrecisionType`选项A3上将被忽略。
+- 支持类型当前是 `float` / `half`。
+- tile 必须是行主序向量 tile。
+- 操作迭代域由 `dst.GetValidRow()` / `dst.GetValidCol()` 决定。
+- 对 `log(<=0)` 的域外情况,行为由目标 profile 定义。
+- 高精度算法只在 A5 有效。
+
+## 异常与非法情形
+
+- 非法操作数组合、不支持的数据类型、不合法布局或不支持的 target-profile 模式,会被 verifier 或后端实现拒绝。
+
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| `float` | Simulated | Supported | Supported |
+| `half` | Simulated | Supported | Supported |
+| 布局 | Any | RowMajor only | RowMajor only |
## 示例
+### C++ 自动模式
+
```cpp
#include
-
using namespace pto;
void example() {
@@ -81,29 +103,39 @@ void example() {
}
```
-## 汇编示例(ASM)
+### C++ 手动模式
-### 自动模式
+```cpp
+#include
+using namespace pto;
-```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
-%dst = pto.tlog %src : !pto.tile<...> -> !pto.tile<...>
+void example_manual() {
+ using TileT = Tile;
+ TileT src, dst;
+ TASSIGN(src, 0x1000);
+ TASSIGN(dst, 0x2000);
+ TLOG(dst, src);
+}
```
-### 手动模式
+### PTO-AS
```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
+# 自动模式
%dst = pto.tlog %src : !pto.tile<...> -> !pto.tile<...>
-```
-### PTO 汇编形式
+# 手动模式
+pto.tassign %arg0, @tile(0x1000)
+pto.tassign %arg1, @tile(0x2000)
+%dst = pto.tlog %src : !pto.tile<...> -> !pto.tile<...>
-```text
+# PTO 汇编形式
%dst = tlog %src : !pto.tile<...>
# AS Level 2 (DPS)
pto.tlog ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
+
+## 相关页面
+
+- 指令集总览:[逐元素 Tile-Tile](./tile/elementwise-tile-tile_zh.md)
+- 规范页:[pto.tlog](./tile/ops/elementwise-tile-tile/tlog_zh.md)
diff --git a/docs/isa/TMATMUL_ACC_zh.md b/docs/isa/TMATMUL_ACC_zh.md
index 75590992..31b48f57 100644
--- a/docs/isa/TMATMUL_ACC_zh.md
+++ b/docs/isa/TMATMUL_ACC_zh.md
@@ -1,17 +1,14 @@
-# TMATMUL_ACC
+# pto.tmatmul.acc
-## 指令示意图
+`pto.tmatmul.acc` 属于[矩阵与矩阵-向量运算](./tile/ops/matrix-and-matrix-vector/tmatmul-acc_zh.md)指令集。
-
-
-## 简介
+## 概述
-带累加器输入的矩阵乘法(融合累加)。
+带累加器输入的矩阵乘法(融合累加),在有效域 `0 <= i < M`、`0 <= j < N` 上计算 $\mathrm{C1}_{i,j} = \mathrm{C0}_{i,j} + \sum_{k=0}^{K-1} \mathrm{A}_{i,k} \cdot \mathrm{B}_{k,j}$,其中 `M = aMatrix.GetValidRow()`、`K = aMatrix.GetValidCol()`、`N = bMatrix.GetValidCol()`。
-## 数学语义
+## 机制
设:
-
- `M = aMatrix.GetValidRow()`
- `K = aMatrix.GetValidCol()`
- `N = bMatrix.GetValidCol()`
@@ -20,9 +17,9 @@
$$ \mathrm{C1}_{i,j} = \mathrm{C0}_{i,j} + \sum_{k=0}^{K-1} \mathrm{A}_{i,k} \cdot \mathrm{B}_{k,j} $$
-## 汇编语法
+## 语法
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+### PTO-AS
同步形式:
@@ -32,13 +29,13 @@ PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%c_out = pto.tmatmul.acc %c_in, %a, %b : (!pto.tile<...>, !pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.tmatmul.acc ins(%c_in, %a, %b : !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%c_out : !pto.tile_buf<...>)
```
@@ -58,16 +55,45 @@ template
@@ -85,7 +111,7 @@ void example_auto() {
}
```
-### 手动(Manual)
+### C++ 手动模式
```cpp
#include
@@ -107,29 +133,20 @@ void example_manual() {
}
```
-## 汇编示例(ASM)
-
-### 自动模式
+### PTO-AS
```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
-%c_out = pto.tmatmul.acc %c_in, %a, %b : (!pto.tile<...>, !pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
+%acc1 = tmatmul.acc %acc0, %a, %b : (!pto.tile<...>, !pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
-### 手动模式
+AS Level 2 (DPS):
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
-%c_out = pto.tmatmul.acc %c_in, %a, %b : (!pto.tile<...>, !pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
+```mlir
+pto.tmatmul.acc ins(%c_in, %a, %b : !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%c_out : !pto.tile_buf<...>)
```
-### PTO 汇编形式
+
-```text
-%acc1 = tmatmul.acc %acc0, %a, %b : (!pto.tile<...>, !pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-# AS Level 2 (DPS)
-pto.tmatmul.acc ins(%c_in, %a, %b : !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%c_out : !pto.tile_buf<...>)
-```
+## 相关页面
+
+- 指令集总览:[矩阵与矩阵-向量运算](./tile/ops/matrix-and-matrix-vector/tmatmul-acc_zh.md)
diff --git a/docs/isa/TMATMUL_BIAS_zh.md b/docs/isa/TMATMUL_BIAS_zh.md
index 3eb19d81..accbadc7 100644
--- a/docs/isa/TMATMUL_BIAS_zh.md
+++ b/docs/isa/TMATMUL_BIAS_zh.md
@@ -1,17 +1,14 @@
-# TMATMUL_BIAS
+# pto.tmatmul.bias
-## 指令示意图
+`pto.tmatmul.bias` 属于[矩阵与矩阵-向量运算](./tile/ops/matrix-and-matrix-vector/tmatmul-bias_zh.md)指令集。
-
-
-## 简介
+## 概述
-带偏置加法的矩阵乘法。
+带偏置加法的矩阵乘法,在有效域 `0 <= i < M`、`0 <= j < N` 上计算 $\mathrm{C}_{i,j} = \sum_{k=0}^{K-1} \mathrm{A}_{i,k} \cdot \mathrm{B}_{k,j} + \mathrm{Bias}_{0,j}$,偏置广播行为由实现定义。
-## 数学语义
+## 机制
设:
-
- `M = aMatrix.GetValidRow()`
- `K = aMatrix.GetValidCol()`
- `N = bMatrix.GetValidCol()`
@@ -22,9 +19,9 @@ $$ \mathrm{C}_{i,j} = \sum_{k=0}^{K-1} \mathrm{A}_{i,k} \cdot \mathrm{B}_{k,j} +
偏置广播行为由实现定义。
-## 汇编语法
+## 语法
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+### PTO-AS
同步形式:
@@ -34,13 +31,13 @@ PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%c = pto.tmatmul.bias %a, %b, %bias : (!pto.tile<...>, !pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.tmatmul.bias ins(%a, %b, %bias : !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%c : !pto.tile_buf<...>)
```
@@ -57,19 +54,49 @@ template
@@ -89,7 +116,7 @@ void example_auto() {
}
```
-### 手动(Manual)
+### C++ 手动模式
```cpp
#include
@@ -113,29 +140,20 @@ void example_manual() {
}
```
-## 汇编示例(ASM)
-
-### 自动模式
+### PTO-AS
```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
-%c = pto.tmatmul.bias %a, %b, %bias : (!pto.tile<...>, !pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
+%acc = tmatmul.bias %a, %b, %bias : (!pto.tile<...>, !pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
-### 手动模式
+AS Level 2 (DPS):
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
-%c = pto.tmatmul.bias %a, %b, %bias : (!pto.tile<...>, !pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
+```mlir
+pto.tmatmul.bias ins(%a, %b, %bias : !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%c : !pto.tile_buf<...>)
```
-### PTO 汇编形式
+
-```text
-%acc = tmatmul.bias %a, %b, %bias : (!pto.tile<...>, !pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-# AS Level 2 (DPS)
-pto.tmatmul.bias ins(%a, %b, %bias : !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%c : !pto.tile_buf<...>)
-```
+## 相关页面
+
+- 指令集总览:[矩阵与矩阵-向量运算](./tile/ops/matrix-and-matrix-vector/tmatmul-bias_zh.md)
diff --git a/docs/isa/TMATMUL_MX_zh.md b/docs/isa/TMATMUL_MX_zh.md
index a4da1f49..45c97873 100644
--- a/docs/isa/TMATMUL_MX_zh.md
+++ b/docs/isa/TMATMUL_MX_zh.md
@@ -1,30 +1,27 @@
-# TMATMUL_MX
+# pto.tmatmul.mx
-## 指令示意图
+`pto.tmatmul.mx` 属于[矩阵与矩阵-向量运算](./tile/ops/matrix-and-matrix-vector/tmatmul-mx_zh.md)指令集。
-
-
-## 简介
+## 概述
-带额外缩放 Tile 的矩阵乘法 (GEMM),用于支持目标上的混合精度/量化矩阵乘法。
+带额外缩放 Tile 的矩阵乘法 (GEMM),用于支持目标上的混合精度/量化矩阵乘法。`aScaleMatrix` / `bScaleMatrix` 配置实现定义的混合精度行为,缩放 tile 的确切作用以及任何反量化/量化语义由目标定义。
-## 数学语义
+## 机制
设:
-
- `M = aMatrix.GetValidRow()`
- `K = aMatrix.GetValidCol()`
- `N = bMatrix.GetValidCol()`
-概念上,结果对应于有效矩阵乘法域(`0 <= i < M`,`0 <= j < N`)上的矩阵乘法,缩放 tile `aScaleMatrix` / `bScaleMatrix` 配置实现定义的混合精度行为:
+概念上,结果对应于有效矩阵乘法域(`0 <= i < M`,`0 <= j < N`)上的矩阵乘法:
$$ \mathrm{C}_{i,j} = \sum_{k=0}^{K-1} \mathrm{A}_{i,k} \cdot \mathrm{B}_{k,j} $$
`aScaleMatrix` / `bScaleMatrix` 的确切作用(以及任何反量化/量化语义)由目标定义。
-## 汇编语法
+## 语法
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+### PTO-AS
同步形式(概念性):
@@ -36,24 +33,18 @@ PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
-%c = pto.tmatmul.mx %a, %a_scale, %b, %b_scale : (!pto.tile<...>, !pto.tile<...>, !pto.tile<...>, !pto.tile<...>)
--> !pto.tile<...>
-%c_out = pto.tmatmul.mx.acc %c_in, %a, %a_scale, %b, %b_scale : (!pto.tile<...>, !pto.tile<...>,
-!pto.tile<...>, !pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-%c = pto.tmatmul.mx.bias %a, %a_scale, %b, %b_scale, %bias : (!pto.tile<...>, !pto.tile<...>,
-!pto.tile<...>, !pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
+```mlir
+%c = pto.tmatmul.mx %a, %a_scale, %b, %b_scale : (!pto.tile<...>, !pto.tile<...>, !pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
+%c_out = pto.tmatmul.mx.acc %c_in, %a, %a_scale, %b, %b_scale : (!pto.tile<...>, !pto.tile<...>, !pto.tile<...>, !pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
+%c = pto.tmatmul.mx.bias %a, %a_scale, %b, %b_scale, %bias : (!pto.tile<...>, !pto.tile<...>, !pto.tile<...>, !pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
-pto.tmatmul.mx ins(%a, %a_scale, %b, %b_scale : !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>)
-outs(%c : !pto.tile_buf<...>)
-pto.tmatmul.mx.acc ins(%c_in, %a, %a_scale, %b, %b_scale : !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>,
-!pto.tile_buf<...>, !pto.tile_buf<...>) outs(%c_out : !pto.tile_buf<...>)
-pto.tmatmul.mx.bias ins(%a, %a_scale, %b, %b_scale, %bias : !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>,
-!pto.tile_buf<...>, !pto.tile_buf<...>) outs(%c : !pto.tile_buf<...>)
+```mlir
+pto.tmatmul.mx ins(%a, %a_scale, %b, %b_scale : !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%c : !pto.tile_buf<...>)
+pto.tmatmul.mx.acc ins(%c_in, %a, %a_scale, %b, %b_scale : !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%c_out : !pto.tile_buf<...>)
+pto.tmatmul.mx.bias ins(%a, %a_scale, %b, %b_scale, %bias : !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%c : !pto.tile_buf<...>)
```
## C++ 内建接口
@@ -86,17 +77,50 @@ template ()`(类型、形状、分形和缩放 tile 合法性)。
-- **偏置形式**:
+- 偏置形式:
- `TileBias::DType` 必须是 `float` 且 `TileBias::Loc == TileType::Bias`,`TileBias::Rows == 1`(A5 通过 `static_assert` 检查)。
+## 异常与非法情形
+
+- 当缩放 tile 类型或布局不符合目标要求时行为未定义。
+- 当 `m/k/n` 超出目标允许范围时行为未定义。
+
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| MX 基本形式 | ✓ | ✗ | ✓ |
+| MX 累加形式 | ✓ | ✗ | ✓ |
+| MX 偏置形式 | ✓ | ✗ | ✓ |
+
## 示例
-### 自动(Auto)
+### C++ 自动模式
```cpp
#include
@@ -120,7 +144,7 @@ void example_auto() {
}
```
-### 手动(Manual)
+### C++ 手动模式
```cpp
#include
@@ -150,29 +174,20 @@ void example_manual() {
}
```
-## 汇编示例(ASM)
-
-### 自动模式
+### PTO-AS
```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
%c = pto.tmatmul.mx %a, %a_scale, %b, %b_scale : (!pto.tile<...>, !pto.tile<...>, !pto.tile<...>, !pto.tile<...>)
```
-### 手动模式
+AS Level 2 (DPS):
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
-%c = pto.tmatmul.mx %a, %a_scale, %b, %b_scale : (!pto.tile<...>, !pto.tile<...>, !pto.tile<...>, !pto.tile<...>)
+```mlir
+pto.tmatmul.mx ins(%a, %a_scale, %b, %b_scale : !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%c : !pto.tile_buf<...>)
```
-### PTO 汇编形式
+
-```text
-%c = pto.tmatmul.mx %a, %a_scale, %b, %b_scale : (!pto.tile<...>, !pto.tile<...>, !pto.tile<...>, !pto.tile<...>)
-# AS Level 2 (DPS)
-pto.tmatmul.mx ins(%a, %a_scale, %b, %b_scale : !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>, !pto.tile_buf<...>)
-```
+## 相关页面
+
+- 指令集总览:[矩阵与矩阵-向量运算](./tile/ops/matrix-and-matrix-vector/tmatmul-mx_zh.md)
diff --git a/docs/isa/TMATMUL_zh.md b/docs/isa/TMATMUL_zh.md
index 4dcfa8b2..5764b66c 100644
--- a/docs/isa/TMATMUL_zh.md
+++ b/docs/isa/TMATMUL_zh.md
@@ -1,17 +1,14 @@
-# TMATMUL
+# pto.tmatmul
-## 指令示意图
+`pto.tmatmul` 属于[矩阵与矩阵-向量运算](./tile/ops/matrix-and-matrix-vector/tmatmul_zh.md)指令集。
-
-
-## 简介
+## 概述
-矩阵乘法 (GEMM),生成累加器/输出 Tile。
+矩阵乘法 (GEMM),在有效矩阵乘法域 `0 <= i < M`、`0 <= j < N` 上计算 $\mathrm{C}_{i,j} = \sum_{k=0}^{K-1} \mathrm{A}_{i,k} \cdot \mathrm{B}_{k,j}$,其中 `M = aMatrix.GetValidRow()`、`K = aMatrix.GetValidCol()`、`N = bMatrix.GetValidCol()`,生成累加器/输出 Tile。精确的累加器行为和数据类型提升由目标/实现定义。
-## 数学语义
+## 机制
设:
-
- `M = aMatrix.GetValidRow()`
- `K = aMatrix.GetValidCol()`
- `N = bMatrix.GetValidCol()`
@@ -22,9 +19,9 @@ $$ \mathrm{C}_{i,j} = \sum_{k=0}^{K-1} \mathrm{A}_{i,k} \cdot \mathrm{B}_{k,j} $
精确的累加器行为和数据类型提升由目标/实现定义。
-## 汇编语法
+## 语法
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+### PTO-AS
同步形式:
@@ -34,13 +31,13 @@ PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%c = pto.tmatmul %a, %b : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.tmatmul ins(%a, %b : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%c : !pto.tile_buf<...>)
```
@@ -56,31 +53,62 @@ template
@@ -98,7 +126,7 @@ void example_auto() {
}
```
-### 手动(Manual)
+### C++ 手动模式
```cpp
#include
@@ -119,29 +147,20 @@ void example_manual() {
}
```
-## 汇编示例(ASM)
-
-### 自动模式
+### PTO-AS
```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
-%c = pto.tmatmul %a, %b : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
+%acc = tmatmul %a, %b : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
-### 手动模式
+AS Level 2 (DPS):
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
-%c = pto.tmatmul %a, %b : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
+```mlir
+pto.tmatmul ins(%a, %b : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%c : !pto.tile_buf<...>)
```
-### PTO 汇编形式
+
-```text
-%acc = tmatmul %a, %b : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-# AS Level 2 (DPS)
-pto.tmatmul ins(%a, %b : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%c : !pto.tile_buf<...>)
-```
+## 相关页面
+
+- 指令集总览:[矩阵与矩阵-向量运算](./tile/ops/matrix-and-matrix-vector/tmatmul_zh.md)
diff --git a/docs/isa/TMOV_FP_zh.md b/docs/isa/TMOV_FP_zh.md
index 78e13673..20890e3a 100644
--- a/docs/isa/TMOV_FP_zh.md
+++ b/docs/isa/TMOV_FP_zh.md
@@ -1,24 +1,18 @@
-# TMOV_FP
+# pto.tmov.fp
-## 指令示意图
+`pto.tmov.fp` 属于[布局与重排](./tile/layout-and-rearrangement_zh.md)指令集。
-
+## 概述
-## 简介
+使用缩放 (`fp`) Tile 作为向量量化参数,将累加器 Tile 移动/转换到目标 Tile。概念上使用从 `fp` 派生的实现定义的量化/反量化配置转换每个元素:$ \mathrm{dst}_{i,j} = \mathrm{Convert}\!\left(\mathrm{src}_{i,j};\ \mathrm{fp}\right) $
-使用缩放 (`fp`) Tile 作为向量量化参数,将累加器 Tile 移动/转换到目标 Tile。
+## 机制
-## 数学语义
+该指令将累加器 Tile 中的数据转换后写入目标 Tile,转换参数由 `fp` Tile 提供。`fp` Tile 包含实现定义的量化参数,用于控制转换行为。
-概念上使用从 `fp` 派生的实现定义的量化/反量化配置转换每个元素:
+## 语法
-$$ \mathrm{dst}_{i,j} = \mathrm{Convert}\!\left(\mathrm{src}_{i,j};\ \mathrm{fp}\right) $$
-
-## 汇编语法
-
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
-
-同步形式:
+### PTO-AS
```text
%dst = tmov.fp %src, %fp : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
@@ -26,13 +20,13 @@ PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.tmov.fp %src, %fp : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.tmov.fp ins(%src, %fp : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
@@ -46,19 +40,50 @@ template Vec (fp) | - | 支持 | 支持 |
+| Acc -> Mat (fp) | - | 支持 | 支持 |
## 示例
-### 自动(Auto)
+### C++ 自动模式
```cpp
#include
@@ -77,7 +102,7 @@ void example_auto() {
}
```
-### 手动(Manual)
+### C++ 手动模式
```cpp
#include
@@ -99,29 +124,22 @@ void example_manual() {
}
```
-## 汇编示例(ASM)
-
-### 自动模式
+### PTO-AS
```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
+# 自动模式
%dst = pto.tmov.fp %src, %fp : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
-```
-
-### 手动模式
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
+# 手动模式
%dst = pto.tmov.fp %src, %fp : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
-```
-
-### PTO 汇编形式
-```text
+# PTO 汇编形式
%dst = tmov.fp %src, %fp : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
# AS Level 2 (DPS)
pto.tmov.fp ins(%src, %fp : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
+
+## 相关页面
+
+- 指令集总览:[布局与重排](./tile/layout-and-rearrangement_zh.md)
+- 相关指令:[pto.tmov](./TMOV_zh.md)
diff --git a/docs/isa/TMOV_zh.md b/docs/isa/TMOV_zh.md
index 448878be..fd9874b9 100644
--- a/docs/isa/TMOV_zh.md
+++ b/docs/isa/TMOV_zh.md
@@ -1,30 +1,18 @@
# pto.tmov
-旧路径兼容入口。规范页见 [pto.tmov](./tile/ops/layout-and-rearrangement/tmov_zh.md)。
+`pto.tmov` 属于[布局与重排](./tile/layout-and-rearrangement_zh.md)指令集。
-
+## 概述
-## 简介
+在 Tile 之间移动/复制数据,可选通过模板参数和重载选择实现定义的转换模式。TMOV 用于 Vec -> Vec 移动、Mat -> Left/Right/Bias/Scaling/Scale(微缩放)移动(取决于目标)、以及 Acc -> Mat/Vec 移动(取决于目标)。
-在 Tile 之间移动/复制,可选通过模板参数和重载选择实现定义的转换模式。
+## 机制
-`TMOV` 用于:
+概念上在有效区域上将元素从 `src` 复制或转换到 `dst`。确切的转换取决于所选模式和目标。对于纯复制情况:$ \mathrm{dst}_{i,j} = \mathrm{src}_{i,j} $。支持多种转换模式,包括 relu 前处理、累加器到向量的特定模式、以及量化参数的微缩放。
-- Vec -> Vec 移动
-- Mat -> Left/Right/Bias/Scaling/Scale(微缩放)移动(取决于目标)
-- Acc -> Mat/Vec 移动(取决于目标)
+## 语法
-## 数学语义
-
-概念上在有效区域上将元素从 `src` 复制或转换到 `dst`。确切的转换取决于所选模式和目标。
-
-对于纯复制情况:
-
-$$ \mathrm{dst}_{i,j} = \mathrm{src}_{i,j} $$
-
-## 汇编语法
-
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+### PTO-AS
PTO AS 设计建议将 `TMOV` 拆分为一系列操作:
@@ -39,13 +27,13 @@ PTO AS 设计建议将 `TMOV` 拆分为一系列操作:
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.tmov.s2d %src : !pto.tile<...> -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.tmov ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
@@ -77,77 +65,110 @@ template (dst, src)`
- - 累加器到向量形式:`TMOV<..., mode, reluMode>(dst, src)`
- - 向量量化形式:`TMOV<..., FpTileData, mode, reluMode>(dst, src, fp)`
- - 标量量化形式:`TMOV<..., reluMode>(dst, src, preQuantScalar)` 和 `TMOV<..., mode, reluMode>(dst, src, preQuantScalar)`
-- `reluMode` 取值为 `ReluPreMode::{NoRelu, NormalRelu}`。
-- `mode` 取值为 `AccToVecMode::{SingleModeVec0, SingleModeVec1, DualModeSplitM, DualModeSplitN}`。
+- TMOV 包含以下重载族:
+ - 普通移动:TMOV(dst, src)
+ - relu 形式:TMOV<..., reluMode>(dst, src)
+ - 累加器到向量形式:TMOV<..., mode, reluMode>(dst, src)
+ - 向量量化形式:TMOV<..., FpTileData, mode, reluMode>(dst, src, fp)
+ - 标量量化形式:TMOV<..., reluMode>(dst, src, preQuantScalar) 和 TMOV<..., mode, reluMode>(dst, src, preQuantScalar)
+- reluMode 取值为 ReluPreMode::{NoRelu, NormalRelu}
+- mode 取值为 AccToVecMode::{SingleModeVec0, SingleModeVec1, DualModeSplitM, DualModeSplitN}
### A2A3 实现检查
-- 形状必须匹配:`SrcTileData::Rows == DstTileData::Rows` 且 `SrcTileData::Cols == DstTileData::Cols`。
+- 形状必须匹配:SrcTileData::Rows == DstTileData::Rows 且 SrcTileData::Cols == DstTileData::Cols
- 支持的 Tile 类型对在编译期限制为:
- - `TileType::Mat -> TileType::Left/Right/Bias/Scaling`
- - `TileType::Vec -> TileType::Vec`
- - `TileType::Acc -> TileType::Mat`
-- 对于 `TileType::Mat -> TileType::Bias`:
- - 支持的源/目标 dtype 对为 `int32_t -> int32_t`、`float -> float`、`half -> float`
- - 源行数必须为 `1`
- - `SrcTileData::Cols * sizeof(SrcType)` 必须按 `64` 字节对齐
-- 对于 `TileType::Mat -> TileType::Scaling`:
- - 目标 dtype 必须与源 dtype 相同,且必须为 `uint64_t`
- - 源行数必须为 `1`
- - `SrcTileData::Cols * sizeof(SrcType)` 必须按 `128` 字节对齐
-- 对于 `TileType::Acc -> TileType::Mat`:
- - 额外执行 `CheckTMovAccToMat<...>` 编译期检查
- - 普通/relu 形式使用 `GetCastPreQuantMode()` 推导的 cast pre-quant 模式
- - 标量量化形式使用 `GetScalarPreQuantMode()`
- - 向量量化形式要求提供 `FpTileData` 操作数,且 `FpTileData::Loc == TileType::Scaling`,并使用 `GetVectorPreQuantMode()`
+ - TileType::Mat -> TileType::Left/Right/Bias/Scaling
+ - TileType::Vec -> TileType::Vec
+ - TileType::Acc -> TileType::Mat
+- 对于 TileType::Mat -> TileType::Bias:
+ - 支持的源/目标 dtype 对为 int32_t -> int32_t、float -> float、half -> float
+ - 源行数必须为 1
+ - SrcTileData::Cols * sizeof(SrcType) 必须按 64 字节对齐
+- 对于 TileType::Mat -> TileType::Scaling:
+ - 目标 dtype 必须与源 dtype 相同,且必须为 uint64_t
+ - 源行数必须为 1
+ - SrcTileData::Cols * sizeof(SrcType) 必须按 128 字节对齐
+- 对于 TileType::Acc -> TileType::Mat:
+ - 额外执行 CheckTMovAccToMat<...> 编译期检查
+ - 普通/relu 形式使用 GetCastPreQuantMode() 推导的 cast pre-quant 模式
+ - 标量量化形式使用 GetScalarPreQuantMode()
+ - 向量量化形式要求提供 FpTileData 操作数,且 FpTileData::Loc == TileType::Scaling,并使用 GetVectorPreQuantMode()
### A5 实现检查
-- `CommonCheck()` 要求:
+- CommonCheck() 要求:
- 目标/源 dtype 必须相同
- - 支持的元素类型为 `int8_t`、`hifloat8_t`、`float8_e5m2_t`、`float8_e4m3_t`、`half`、`bfloat16_t`、`float`、`float4_e2m1x2_t`、`float4_e1m2x2_t`
+ - 支持的元素类型为 int8_t、hifloat8_t、float8_e5m2_t、float8_e4m3_t、half、bfloat16_t、float、float4_e2m1x2_t、float4_e1m2x2_t
- 源布局必须满足以下之一:
- - `(SrcTileData::SFractal == SLayout::ColMajor && SrcTileData::isRowMajor)`
- - `(SrcTileData::SFractal == SLayout::RowMajor && !SrcTileData::isRowMajor)`
- - `SrcTileData::isRowMajor`
-- `CommonCheckMX()` 用于 MX 路径时要求源/目标 dtype 相同,并支持 `float8_e8m0_t`。
+ - (SrcTileData::SFractal == SLayout::ColMajor && SrcTileData::isRowMajor)
+ - (SrcTileData::SFractal == SLayout::RowMajor && !SrcTileData::isRowMajor)
+ - SrcTileData::isRowMajor
+- CommonCheckMX() 用于 MX 路径时要求源/目标 dtype 相同,并支持 float8_e8m0_t
- 支持的路径包括:
- - `TileType::Mat -> TileType::Left/Right/Bias/Scaling/ScaleLeft/ScaleRight`
- - `TileType::Vec -> TileType::Vec/TileType::Mat`
- - `TileType::Acc -> TileType::Vec/TileType::Mat`
- - A5 实现中处理的特定 `ND -> ZZ` 及相关内部路径变体
-- 对于 `TileType::Mat -> TileType::Bias`:
- - 支持的 dtype 对为 `int32_t -> int32_t`、`float -> float`、`half -> float`、`bfloat16_t -> float`
- - 源行数必须为 `1`
- - `DstTileData::Cols * sizeof(DstType)` 必须按 `64` 字节对齐
- - bias table 占用 `DstTileData::Cols * sizeof(DstType)` 不得超过 `4096` 字节
-- 对于 `TileType::Mat -> TileType::Scaling`:
- - 源行数必须为 `1`
- - `DstTileData::Cols * sizeof(DstType)` 必须按 `128` 字节对齐
- - fixpipe buffer 占用 `DstTileData::Cols * sizeof(DstType)` 不得超过 `4096` 字节
-- 对于 `TileType::Acc -> TileType::Vec`:
- - `mode` 用于选择 `SingleModeVec0`、`SingleModeVec1`、`DualModeSplitM` 或 `DualModeSplitN`
- - 双目标模式要求 `QuantMode_t::NoQuant`
- - 双目标模式不支持 `nz2dn` 路径
- - 目标 stride 必须非零,且 `dstStride * sizeof(dstType)` 必须是 `32` 字节的整数倍
-- 对于 `TileType::Acc -> TileType::Mat`:
- - 目标 stride 必须非零,且 `dstStride * sizeof(dstType)` 必须是 `32` 字节的整数倍
+ - TileType::Mat -> TileType::Left/Right/Bias/Scaling/ScaleLeft/ScaleRight
+ - TileType::Vec -> TileType::Vec/TileType::Mat
+ - TileType::Acc -> TileType::Vec/TileType::Mat
+ - A5 实现中处理的特定 ND -> ZZ 及相关内部路径变体
+- 对于 TileType::Mat -> TileType::Bias:
+ - 支持的 dtype 对为 int32_t -> int32_t、float -> float、half -> float、bfloat16_t -> float
+ - 源行数必须为 1
+ - DstTileData::Cols * sizeof(DstType) 必须按 64 字节对齐
+ - bias table 占用 DstTileData::Cols * sizeof(DstType) 不得超过 4096 字节
+- 对于 TileType::Mat -> TileType::Scaling:
+ - 源行数必须为 1
+ - DstTileData::Cols * sizeof(DstType) 必须按 128 字节对齐
+ - fixpipe buffer 占用 DstTileData::Cols * sizeof(DstType) 不得超过 4096 字节
+- 对于 TileType::Acc -> TileType::Vec:
+ - mode 用于选择 SingleModeVec0、SingleModeVec1、DualModeSplitM 或 DualModeSplitN
+ - 双目标模式要求 QuantMode_t::NoQuant
+ - 双目标模式不支持 nz2dn 路径
+ - 目标 stride 必须非零,且 dstStride * sizeof(dstType) 必须是 32 字节的整数倍
+- 对于 TileType::Acc -> TileType::Mat:
+ - 目标 stride 必须非零,且 dstStride * sizeof(dstType) 必须是 32 字节的整数倍
- 支持通过对应重载启用 relu/标量量化/向量量化形式
+## 异常与非法情形
+
+- 未指定
+
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| Mat -> Left/Right/Bias/Scaling | - | 支持 | 支持 |
+| Vec -> Vec | - | 支持 | 支持 |
+| Acc -> Mat | - | 支持 | 支持 |
+| Acc -> Vec | - | 支持 | 支持 |
## 示例
-### 自动(Auto)
+### C++ 自动模式
```cpp
#include
@@ -161,7 +182,7 @@ void example_auto() {
}
```
-### 手动(Manual)
+### C++ 手动模式
```cpp
#include
@@ -179,31 +200,21 @@ void example_manual() {
}
```
-## 汇编示例(ASM)
-
-### 自动模式
+### PTO-AS
```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
+# 自动模式
%dst = pto.tmov.s2d %src : !pto.tile<...> -> !pto.tile<...>
-```
-### 手动模式
-
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
+# 手动模式
%dst = pto.tmov.s2d %src : !pto.tile<...> -> !pto.tile<...>
-```
-### PTO 汇编形式
-
-```text
+# PTO 汇编形式
%dst = pto.tmov.s2d %src : !pto.tile<...> -> !pto.tile<...>
# AS Level 2 (DPS)
pto.tmov ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
-新的 PTO ISA 文档应直接链接到分组后的指令集路径。
+## 相关页面
+
+- 指令集总览:[布局与重排](./tile/layout-and-rearrangement_zh.md)
diff --git a/docs/isa/TPACK_zh.md b/docs/isa/TPACK_zh.md
index 3211e59c..24a157c9 100644
--- a/docs/isa/TPACK_zh.md
+++ b/docs/isa/TPACK_zh.md
@@ -1,41 +1,89 @@
-# TPACK
+# pto.tpack
-## 指令示意图
+`pto.tpack` 属于[不规则与复杂](./tile/irregular-and-complex_zh.md)指令集。
-
-
-## 简介
+## 概述
将 Tile 元素打包或转换为更窄的目标表示。
-## 数学语义
+## 机制
+
+语义随具体指令变体而变化。除非另有说明,行为都按目标 valid region 定义。
-语义随指令而变化。 除非另有说明,行为都按目标 valid region 定义。
+## 语法
-## 汇编语法
+### PTO-AS
PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.tpack ...
```
### AS Level 2(DPS)
-```text
+```mlir
pto.tpack ins(...) outs(%dst : !pto.tile_buf<...>)
```
## C++ 内建接口
-声明于 `include/pto/common/pto_instr.hpp`.
+声明于 `include/pto/common/pto_instr.hpp`。
+
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| 源 Tile | 输入 | 待打包的源 Tile |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `%dst` | `!pto.tile_buf<...>` | 打包后的目标 Tile |
+
+## 副作用
+
+除产生目标 Tile 外,没有额外架构副作用。
## 约束
-数据类型、layout、location 和 shape 的进一步限制以对应 backend 的合法性检查为准。
+- 数据类型、layout、location 和 shape 的进一步限制以对应 backend 的合法性检查为准。
+
+## 异常与非法情形
+
+- 源 Tile 与目标 Tile 类型不兼容时会被 verifier 或后端拒绝。
+
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| 打包操作 | Simulated | Supported | Supported |
## 示例
+### C++ 自动模式
+
+具体的 Auto / Manual 使用方式见 `docs/isa/` 下的相关指令页。
+
+### C++ 手动模式
+
具体的 Auto / Manual 使用方式见 `docs/isa/` 下的相关指令页。
+
+### PTO-AS
+
+```text
+%dst = pto.tpack %src : ...
+```
+
+### AS Level 2(DPS)
+
+```mlir
+pto.tpack ins(%src : ...) outs(%dst : !pto.tile_buf<...>)
+```
+
+## 相关页面
+
+- 指令集总览:[不规则与复杂](./tile/irregular-and-complex_zh.md)
diff --git a/docs/isa/TPARTADD_zh.md b/docs/isa/TPARTADD_zh.md
index 1e7ccc49..b6933c2b 100644
--- a/docs/isa/TPARTADD_zh.md
+++ b/docs/isa/TPARTADD_zh.md
@@ -1,14 +1,12 @@
-# TPARTADD
+# pto.tpartadd
-## 指令示意图
+`pto.tpartadd` 属于[不规则及复杂运算](./tile/ops/irregular-and-complex/tpartadd_zh.md)指令集。
-
+## 概述
-## 简介
+在目标有效区域内执行逐元素加法。若某个位置上 `src0` 和 `src1` 都有效,则结果为两者之和;若只有一个输入在该位置有效,则结果直接取该输入的值。
-在目标有效区域内执行逐元素加法。若某个位置上 `src0` 和 `src1` 都有效,则结果为两者之和;若只有一个输入在该位置有效,则结果直接取该输入的值。其余有效区域不匹配的情况由具体实现定义。
-
-## 数学语义
+## 机制
对目标有效区域内的每个元素 `(i, j)`:
@@ -21,11 +19,9 @@ $$
\end{cases}
$$
-## 汇编语法
-
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+## 语法
-同步形式:
+### PTO-AS
```text
%dst = tpartadd %src0, %src1 : !pto.tile<...> -> !pto.tile<...>
@@ -33,13 +29,13 @@ PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.tpartadd %src0, %src1 : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.tpartadd ins(%src0, %src1 : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
@@ -52,31 +48,49 @@ template
@@ -90,7 +104,7 @@ void example_auto() {
}
```
-### 手动(Manual)
+### C++ 手动模式
```cpp
#include
@@ -107,29 +121,13 @@ void example_manual() {
}
```
-## 汇编示例(ASM)
-
-### 自动模式
-
-```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
-%dst = pto.tpartadd %src0, %src1 : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-```
-
-### 手动模式
+### PTO-AS
```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
+# 自动模式
%dst = pto.tpartadd %src0, %src1 : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
-### PTO 汇编形式
+## 相关页面
-```text
-%dst = tpartadd %src0, %src1 : !pto.tile<...> -> !pto.tile<...>
-# AS Level 2 (DPS)
-pto.tpartadd ins(%src0, %src1 : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
-```
+- 指令集总览:[不规则及复杂运算](./tile/ops/irregular-and-complex/tpartadd_zh.md)
diff --git a/docs/isa/TPARTMAX_zh.md b/docs/isa/TPARTMAX_zh.md
index 95087a22..b9ec9a86 100644
--- a/docs/isa/TPARTMAX_zh.md
+++ b/docs/isa/TPARTMAX_zh.md
@@ -1,29 +1,29 @@
-# TPARTMAX
+# pto.tpartmax
-## 指令示意图
+`pto.tpartmax` 属于[不规则与复杂指令](./tile/irregular-and-complex_zh.md)集。
-
-
-## 简介
+## 概述
在目标有效区域内执行逐元素最大值选择。若某个位置上 `src0` 和 `src1` 都有效,则结果为 `max(src0, src1)`;若只有一个输入在该位置有效,则结果直接取该输入的值。其余有效区域不匹配的情况由具体实现定义。
-## 数学语义
+## 机制
对目标有效区域内的每个元素 `(i, j)`:
$$
\mathrm{dst}_{i,j} =
\begin{cases}
-\max(\mathrm{src0}_{i,j}, \mathrm{src1}_{i,j}) & \text{若两个输入在 } (i,j) \text{ 处均有定义} \\\\
-\mathrm{src0}_{i,j} & \text{若仅 src0 在 } (i,j) \text{ 处有定义} \\\\
+\max(\mathrm{src0}_{i,j}, \mathrm{src1}_{i,j}) & \text{若两个输入在 } (i,j) \text{ 处均有定义} \\
+\mathrm{src0}_{i,j} & \text{若仅 src0 在 } (i,j) \text{ 处有定义} \\
\mathrm{src1}_{i,j} & \text{若仅 src1 在 } (i,j) \text{ 处有定义}
\end{cases}
$$
-## 汇编语法
+## 语法
+
+### PTO-AS
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
同步形式:
@@ -33,28 +33,41 @@ PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.tpartmax %src0, %src1 : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.tpartmax ins(%src0, %src1 : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
## C++ 内建接口
-声明于 `include/pto/common/pto_instr.hpp`:
-
```cpp
template
PTO_INST RecordEvent TPARTMAX(TileDataDst &dst, TileDataSrc0 &src0, TileDataSrc1 &src1, WaitEvents &... events);
```
-## 约束
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| `src0` | 源 Tile | 第一个输入 Tile |
+| `src1` | 源 Tile | 第二个输入 Tile |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `dst` | Tile | 逐元素最大值选择后的目标 Tile |
+
+## 副作用
-### 通用约束或检查
+无。
+
+## 约束
- `dst`、`src0` 和 `src1` 的元素类型必须一致。
- 目标有效区域定义结果的计算范围。
@@ -65,18 +78,20 @@ PTO_INST RecordEvent TPARTMAX(TileDataDst &dst, TileDataSrc0 &src0, TileDataSrc1
- 支持的部分有效区域模式要求至少有一个源 Tile 的有效区域与 `dst` 完全一致,另一个源 Tile 的有效区域在两个维度上都不能超过 `dst`。
- 上述范围之外的有效区域组合,其行为均由具体实现定义。
-### A2A3 实现检查
+## 异常与非法情形
-- 支持的元素类型:`int32_t`、`int16_t`、`half`、`float`。
-- `dst`、`src0` 和 `src1` 必须全部为行主序(`isRowMajor`)。
+- 未定义。
-### A5 实现检查
+## Target-Profile 限制
-- 支持的元素类型:`int8_t`、`uint8_t`、`int16_t`、`uint16_t`、`int32_t`、`uint32_t`、`half`、`bfloat16_t`、`float`。
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| 支持的元素类型 | - | `int32_t`、`int16_t`、`half`、`float` | `int8_t`、`uint8_t`、`int16_t`、`uint16_t`、`int32_t`、`uint32_t`、`half`、`bfloat16_t`、`float` |
+| 布局要求 | - | `isRowMajor` | - |
## 示例
-### 自动(Auto)
+### C++ 自动模式
```cpp
#include
@@ -90,7 +105,7 @@ void example_auto() {
}
```
-### 手动(Manual)
+### C++ 手动模式
```cpp
#include
@@ -107,29 +122,19 @@ void example_manual() {
}
```
-## 汇编示例(ASM)
-
-### 自动模式
+### PTO-AS
```text
# 自动模式:由编译器/运行时负责资源放置与调度。
%dst = pto.tpartmax %src0, %src1 : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-```
-
-### 手动模式
-```text
# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
+# pto.tassign %src0, @tile(0x1000)
+# pto.tassign %src1, @tile(0x2000)
+# pto.tassign %dst, @tile(0x3000)
%dst = pto.tpartmax %src0, %src1 : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
-### PTO 汇编形式
+## 相关页面
-```text
-%dst = tpartmax %src0, %src1 : !pto.tile<...> -> !pto.tile<...>
-# AS Level 2 (DPS)
-pto.tpartmax ins(%src0, %src1 : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
-```
+- 指令集总览:[不规则与复杂指令](./tile/irregular-and-complex_zh.md)
diff --git a/docs/isa/TPARTMIN_zh.md b/docs/isa/TPARTMIN_zh.md
index c548133e..73aefadf 100644
--- a/docs/isa/TPARTMIN_zh.md
+++ b/docs/isa/TPARTMIN_zh.md
@@ -1,29 +1,29 @@
-# TPARTMIN
+# pto.tpartmin
-## 指令示意图
+`pto.tpartmin` 属于[不规则与复杂指令](./tile/irregular-and-complex_zh.md)集。
-
-
-## 简介
+## 概述
在目标有效区域内执行逐元素最小值选择。若某个位置上 `src0` 和 `src1` 都有效,则结果为 `min(src0, src1)`;若只有一个输入在该位置有效,则结果直接取该输入的值。其余有效区域不匹配的情况由具体实现定义。
-## 数学语义
+## 机制
对目标有效区域内的每个元素 `(i, j)`:
$$
\mathrm{dst}_{i,j} =
\begin{cases}
-\min(\mathrm{src0}_{i,j}, \mathrm{src1}_{i,j}) & \text{若两个输入在 } (i,j) \text{ 处均有定义} \\\\
-\mathrm{src0}_{i,j} & \text{若仅 src0 在 } (i,j) \text{ 处有定义} \\\\
+\min(\mathrm{src0}_{i,j}, \mathrm{src1}_{i,j}) & \text{若两个输入在 } (i,j) \text{ 处均有定义} \\
+\mathrm{src0}_{i,j} & \text{若仅 src0 在 } (i,j) \text{ 处有定义} \\
\mathrm{src1}_{i,j} & \text{若仅 src1 在 } (i,j) \text{ 处有定义}
\end{cases}
$$
-## 汇编语法
+## 语法
+
+### PTO-AS
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
同步形式:
@@ -33,28 +33,41 @@ PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.tpartmin %src0, %src1 : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.tpartmin ins(%src0, %src1 : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
## C++ 内建接口
-声明于 `include/pto/common/pto_instr.hpp`:
-
```cpp
template
PTO_INST RecordEvent TPARTMIN(TileDataDst &dst, TileDataSrc0 &src0, TileDataSrc1 &src1, WaitEvents &... events);
```
-## 约束
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| `src0` | 源 Tile | 第一个输入 Tile |
+| `src1` | 源 Tile | 第二个输入 Tile |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `dst` | Tile | 逐元素最小值选择后的目标 Tile |
+
+## 副作用
-### 通用约束或检查
+无。
+
+## 约束
- `dst`、`src0` 和 `src1` 的元素类型必须一致。
- 目标有效区域定义结果的计算范围。
@@ -65,18 +78,20 @@ PTO_INST RecordEvent TPARTMIN(TileDataDst &dst, TileDataSrc0 &src0, TileDataSrc1
- 支持的部分有效区域模式要求至少有一个源 Tile 的有效区域与 `dst` 完全一致,另一个源 Tile 的有效区域在两个维度上都不能超过 `dst`。
- 上述范围之外的有效区域组合,其行为均由具体实现定义。
-### A2A3 实现检查
+## 异常与非法情形
-- 支持的元素类型:`int32_t`、`int16_t`、`half`、`float`。
-- `dst`、`src0` 和 `src1` 必须全部为行主序(`isRowMajor`)。
+- 未定义。
-### A5 实现检查
+## Target-Profile 限制
-- 支持的元素类型:`int8_t`、`uint8_t`、`int16_t`、`uint16_t`、`int32_t`、`uint32_t`、`half`、`bfloat16_t`、`float`。
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| 支持的元素类型 | - | `int32_t`、`int16_t`、`half`、`float` | `int8_t`、`uint8_t`、`int16_t`、`uint16_t`、`int32_t`、`uint32_t`、`half`、`bfloat16_t`、`float` |
+| 布局要求 | - | `isRowMajor` | - |
## 示例
-### 自动(Auto)
+### C++ 自动模式
```cpp
#include
@@ -90,7 +105,7 @@ void example_auto() {
}
```
-### 手动(Manual)
+### C++ 手动模式
```cpp
#include
@@ -107,29 +122,19 @@ void example_manual() {
}
```
-## 汇编示例(ASM)
-
-### 自动模式
+### PTO-AS
```text
# 自动模式:由编译器/运行时负责资源放置与调度。
%dst = pto.tpartmin %src0, %src1 : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-```
-
-### 手动模式
-```text
# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
+# pto.tassign %src0, @tile(0x1000)
+# pto.tassign %src1, @tile(0x2000)
+# pto.tassign %dst, @tile(0x3000)
%dst = pto.tpartmin %src0, %src1 : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
-### PTO 汇编形式
+## 相关页面
-```text
-%dst = tpartmin %src0, %src1 : !pto.tile<...> -> !pto.tile<...>
-# AS Level 2 (DPS)
-pto.tpartmin ins(%src0, %src1 : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
-```
+- 指令集总览:[不规则与复杂指令](./tile/irregular-and-complex_zh.md)
diff --git a/docs/isa/TPARTMUL_zh.md b/docs/isa/TPARTMUL_zh.md
index af778780..1e54a1a2 100644
--- a/docs/isa/TPARTMUL_zh.md
+++ b/docs/isa/TPARTMUL_zh.md
@@ -1,30 +1,29 @@
# pto.tpartmul
-旧路径兼容入口。规范页见 [pto.tpartmul](./tile/ops/irregular-and-complex/tpartmul_zh.md)。
+`pto.tpartmul` 属于[不规则与复杂指令](./tile/irregular-and-complex_zh.md)集。
-- 指令集:[不规则与复杂指令集](./tile/irregular-and-complex_zh.md)
-- 规范页:[pto.tpartmul](./tile/ops/irregular-and-complex/tpartmul_zh.md)
-
-## 简介
+## 概述
在目标有效区域内执行逐元素乘法。若某个位置上 `src0` 和 `src1` 都有效,则结果为两者之积;若只有一个输入在该位置有效,则结果直接取该输入的值。其余有效区域不匹配的情况由具体实现定义。
-## 数学语义
+## 机制
对目标有效区域内的每个元素 `(i, j)`:
$$
\mathrm{dst}_{i,j} =
\begin{cases}
-\mathrm{src0}_{i,j} \cdot \mathrm{src1}_{i,j} & \text{若两个输入在 } (i,j) \text{ 处均有定义} \\\\
-\mathrm{src0}_{i,j} & \text{若仅 src0 在 } (i,j) \text{ 处有定义} \\\\
+\mathrm{src0}_{i,j} \cdot \mathrm{src1}_{i,j} & \text{若两个输入在 } (i,j) \text{ 处均有定义} \\
+\mathrm{src0}_{i,j} & \text{若仅 src0 在 } (i,j) \text{ 处有定义} \\
\mathrm{src1}_{i,j} & \text{若仅 src1 在 } (i,j) \text{ 处有定义}
\end{cases}
$$
-## 汇编语法
+## 语法
+
+### PTO-AS
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
同步形式:
@@ -34,28 +33,41 @@ PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.tpartmul %src0, %src1 : !pto.tile<...> -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.tpartmul ins(%src0, %src1 : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
## C++ 内建接口
-声明于 `include/pto/common/pto_instr.hpp`:
-
```cpp
template
PTO_INST RecordEvent TPARTMUL(TileDataDst &dst, TileDataSrc0 &src0, TileDataSrc1 &src1, WaitEvents &... events);
```
-## 约束
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| `src0` | 源 Tile | 第一个输入 Tile |
+| `src1` | 源 Tile | 第二个输入 Tile |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `dst` | Tile | 逐元素乘法后的目标 Tile |
+
+## 副作用
-### 通用约束或检查
+无。
+
+## 约束
- `dst`、`src0` 和 `src1` 的元素类型必须一致。
- 目标有效区域定义结果的计算范围。
@@ -66,18 +78,20 @@ PTO_INST RecordEvent TPARTMUL(TileDataDst &dst, TileDataSrc0 &src0, TileDataSrc1
- 支持的部分有效区域模式要求至少有一个源 Tile 的有效区域与 `dst` 完全一致,另一个源 Tile 的有效区域在两个维度上都不能超过 `dst`。
- 上述范围之外的有效区域组合,其行为均由具体实现定义。
-### A2A3 实现检查
+## 异常与非法情形
-- 支持的元素类型:`int32_t`、`int16_t`、`half`、`float`。
-- `dst`、`src0` 和 `src1` 必须全部为行主序(`isRowMajor`)。
+- 未定义。
-### A5 实现检查
+## Target-Profile 限制
-- 支持的元素类型:`uint8_t`、`int8_t`、`uint16_t`、`int16_t`、`uint32_t`、`int32_t`、`half`、`float`、`bfloat16_t`。
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| 支持的元素类型 | - | `int32_t`、`int16_t`、`half`、`float` | `uint8_t`、`int8_t`、`uint16_t`、`int16_t`、`uint32_t`、`int32_t`、`half`、`float`、`bfloat16_t` |
+| 布局要求 | - | `isRowMajor` | - |
## 示例
-### 自动(Auto)
+### C++ 自动模式
```cpp
#include
@@ -90,7 +104,7 @@ void example_auto() {
}
```
-### 手动(Manual)
+### C++ 手动模式
```cpp
#include
@@ -106,29 +120,19 @@ void example_manual() {
}
```
-## 汇编示例(ASM)
-
-### 自动模式
+### PTO-AS
```text
# 自动模式:由编译器/运行时负责资源放置与调度。
%dst = pto.tpartmul %src0, %src1 : !pto.tile<...> -> !pto.tile<...>
-```
-
-### 手动模式
-```text
# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
+# pto.tassign %src0, @tile(0x1000)
+# pto.tassign %src1, @tile(0x2000)
+# pto.tassign %dst, @tile(0x3000)
%dst = pto.tpartmul %src0, %src1 : !pto.tile<...> -> !pto.tile<...>
```
-### PTO 汇编形式
+## 相关页面
-```text
-%dst = tpartmul %src0, %src1 : !pto.tile<...> -> !pto.tile<...>
-# AS Level 2 (DPS)
-pto.tpartmul ins(%src0, %src1 : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
-```
+- 指令集总览:[不规则与复杂指令](./tile/irregular-and-complex_zh.md)
diff --git a/docs/isa/TPOP_zh.md b/docs/isa/TPOP_zh.md
index 5582ef2f..f3797e65 100644
--- a/docs/isa/TPOP_zh.md
+++ b/docs/isa/TPOP_zh.md
@@ -1,41 +1,91 @@
-# TPOP
+# pto.tpop
-## 指令示意图
+`pto.tpop` 属于[同步与配置](./tile/sync-and-config_zh.md)指令集。
-
-
-## 简介
+## 概述
从 pipe 或 FIFO 的消费者端弹出一个 Tile。
-## 数学语义
+## 机制
+
+语义随具体指令变体而变化。除非另有说明,行为都按目标 valid region 定义。
-语义随指令而变化。 除非另有说明,行为都按目标 valid region 定义。
+## 语法
-## 汇编语法
+### PTO-AS
PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.tpop ...
```
### AS Level 2(DPS)
-```text
+```mlir
pto.tpop ins(...) outs(%dst : !pto.tile_buf<...>)
```
## C++ 内建接口
-声明于 `include/pto/common/pto_instr.hpp`.
+声明于 `include/pto/common/pto_instr.hpp`。
+
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| Pipe/FIFO 引用 | 输入 | 待弹出 Tile 的 pipe 或 FIFO |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `%dst` | `!pto.tile_buf<...>` | 从消费者端弹出的 Tile |
+
+## 副作用
+
+从 pipe 或 FIFO 中移除一个 Tile,该 Tile 所有权转移给消费者。
## 约束
-数据类型、layout、location 和 shape 的进一步限制以对应 backend 的合法性检查为准。
+- 数据类型、layout、location 和 shape 的进一步限制以对应 backend 的合法性检查为准。
+- 只能在 pipe 或 FIFO 有可用 Tile 时执行。
+
+## 异常与非法情形
+
+- 在 pipe 或 FIFO 为空时执行属于未定义行为。
+- 消费者无权访问该 pipe 或 FIFO 时会被拒绝。
+
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| 弹出操作 | Simulated | Supported | Supported |
## 示例
+### C++ 自动模式
+
+具体的 Auto / Manual 使用方式见 `docs/isa/` 下的相关指令页。
+
+### C++ 手动模式
+
具体的 Auto / Manual 使用方式见 `docs/isa/` 下的相关指令页。
+
+### PTO-AS
+
+```text
+%tile = pto.tpop %pipe : !pto.tile<...>
+```
+
+### AS Level 2(DPS)
+
+```mlir
+pto.tpop ins(%pipe : ...) outs(%dst : !pto.tile_buf<...>)
+```
+
+## 相关页面
+
+- 指令集总览:[同步与配置](./tile/sync-and-config_zh.md)
diff --git a/docs/isa/TPRINT_zh.md b/docs/isa/TPRINT_zh.md
index f6132a5d..fea1c078 100644
--- a/docs/isa/TPRINT_zh.md
+++ b/docs/isa/TPRINT_zh.md
@@ -1,172 +1,180 @@
-# TPRINT
-
-## 指令示意图
-
-
-
-## 简介
-
-调试/打印 Tile 中的元素(实现定义)。
-
-从设备代码直接打印 Tile 或 GlobalTensor 的内容以用于调试目的。
-
-`TPRINT` 指令输出存储在 Tile 或 GlobalTensor 中的数据的逻辑视图。它支持常见的数据类型(例如 `float`、`half`、`int8`、`uint32`)和多种内存布局(GlobalTensor 的 `ND`、`DN`、`NZ`;片上缓冲区的向量 tiles)。
-
-> **重要**:
-> - 此指令**仅用于开发和调试**。
-> - 它会产生**显著的运行时开销**,**不得在生产 kernel 中使用**。
-> - 如果输出超过内部打印缓冲区,可能会被**截断**。可以通过在编译选项中添加`-DCCEBlockMaxSize=16384`来修改打印缓冲区,默认为16KB。
-> - **需要 CCE 编译选项 `-D_DEBUG --cce-enable-print`**(参见 [行为](#behavior))。
-
-## 数学语义
-
-除非另有说明,语义在有效区域上定义,目标相关的行为标记为实现定义。
-
-## 汇编语法
-
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
-
-```text
-tprint %src : !pto.tile<...> | !pto.global<...>
-```
-
-### AS Level 1(SSA)
-
-```text
-pto.tprint %src : !pto.tile<...> | !pto.partition_tensor_view -> ()
-```
-
-### AS Level 2(DPS)
-
-```text
-pto.tprint ins(%src : !pto.tile_buf<...> | !pto.partition_tensor_view)
-```
-
-## C++ 内建接口
-
-声明于 `include/pto/common/pto_instr.hpp`:
-```cpp
-// 适用于打印GlobalTensor或Vec类型Tile
-template
-PTO_INST void TPRINT(TileData &src);
-
-// 适用于打印Acc类型Tile和Mat类型Tile(Mat打印仅适用于A3,A5暂不支持)
-template
-PTO_INTERNAL void TPRINT(TileData &src, GlobalData &tmp);
-```
-
-### PrintFormat 枚举
-声明于 `include/pto/common/type.hpp`:
-```cpp
-enum class PrintFormat : uint8_t
-{
- Width8_Precision4 = 0, // 打印宽度8,精度4
- Width8_Precision2 = 1, // 打印宽度8,精度2
- Width10_Precision6 = 2, // 打印宽度10,精度6
-};
-```
-
-### 支持的 T 类型
-- **Tile**:TileType必须是`Vec`、`Acc`、`Mat(仅A3支持)`,并具有支持的元素类型。
-- **GlobalTensor**:必须使用布局 `ND`、`DN` 或 `NZ`,并具有支持的元素类型。
-
-## 约束
-
-- **支持的元素类型**:
- - 浮点数:`float`、`half`
- - 有符号整数:`int8_t`、`int16_t`、`int32_t`
- - 无符号整数:`uint8_t`、`uint16_t`、`uint32_t`
-- **对于 GlobalTensor**:布局必须是 `Layout::ND`、`Layout::DN` 或 `Layout::NZ` 之一。
-- **对于 临时空间**:打印`TileType`为`Mat`或`Acc`的Tile时需要传入gm上的临时空间,临时空间不得小于`TileData::Numel * sizeof(T)`。
-- A5暂不支持`TileType`为`Mat`的Tile打印。
-- **回显信息**: `TileType`为`Mat`时,布局将按照`Layout::ND`进行打印,其他布局可能会导致信息错位。
-
-## 行为
-
-- **强制编译标志**:
-
- 在 A2/A3/A5 设备上,`TPRINT` 使用 `cce::printf` 通过设备到主机的调试通道输出。**必须启用 CCE 选项 `-D_DEBUG --cce-enable-print`**。
-
-- **缓冲区限制**:
-
- `cce::printf` 的内部打印缓冲区大小有限。如果输出超过此缓冲区,可能会出现类似 `"Warning: out of bound! try best to print"` 的警告消息,并且**只会打印部分数据**。
-
-- **同步**:
-
- 自动插入 `pipe_barrier(PIPE_ALL)` 以确保所有先前的操作完成且数据一致。
-
-- **格式化**:
-
- - 浮点数值:根据 `PrintFormat` 模板参数确定打印格式:
- - `PrintFormat::Width8_Precision4`: `%8.4f`(默认)
- - `PrintFormat::Width8_Precision2`: `%8.2f`
- - `PrintFormat::Width10_Precision6`: `%10.6f`
- - 整数值:根据 `PrintFormat` 模板参数确定打印格式:
- - `PrintFormat::Width8_Precision4` 或 `PrintFormat::Width8_Precision2`: `%8d`
- - `PrintFormat::Width10_Precision6`: `%10d`
- - 对于 `GlobalTensor`,由于数据大小和缓冲区限制,仅打印其逻辑形状(由 `Shape` 定义)内的元素。
- - 对于 `Tile`,无效区域(超出 `validRows`/`validCols`)仍会被打印,但在指定部分有效性时用 `|` 分隔符标记。
-
-## 示例
-
-### Print a Tile
-
-```cpp
-#include
-
-PTO_INTERNAL void DebugTile(__gm__ float *src) {
- using ValidSrcShape = TileShape2D;
- using NDSrcShape = BaseShape2D;
- using GlobalDataSrc = GlobalTensor;
- GlobalDataSrc srcGlobal(src);
-
- using srcTileData = Tile;
- srcTileData srcTile;
- TASSIGN(srcTile, 0x0);
-
- TLOAD(srcTile, srcGlobal);
- TPRINT(srcTile);
-}
-```
-
-### Print a GlobalTensor
-
-```cpp
-#include
-
-PTO_INTERNAL void DebugGlobalTensor(__gm__ float *src) {
- using ValidSrcShape = TileShape2D;
- using NDSrcShape = BaseShape2D;
- using GlobalDataSrc = GlobalTensor;
- GlobalDataSrc srcGlobal(src);
-
- TPRINT(srcGlobal);
-}
-```
-
-## 汇编示例(ASM)
-
-### 自动模式
-
-```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
-pto.tprint %src : !pto.tile<...> | !pto.partition_tensor_view -> ()
-```
-
-### 手动模式
-
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
-pto.tprint %src : !pto.tile<...> | !pto.partition_tensor_view -> ()
-```
-
-### PTO 汇编形式
-
-```text
-pto.tprint %src : !pto.tile<...> | !pto.partition_tensor_view -> ()
-# AS Level 2 (DPS)
-pto.tprint ins(%src : !pto.tile_buf<...> | !pto.partition_tensor_view)
-```
+# pto.tprint
+
+`pto.tprint` 属于[不规则与复杂操作](./tile/irregular-and-complex_zh.md)指令集。
+
+## 概述
+
+调试/打印 Tile 或 GlobalTensor 中的元素(实现定义)。`TPRINT` 指令输出存储在 Tile 或 GlobalTensor 中的数据的逻辑视图。它支持常见的数据类型(例如 `float`、`half`、`int8`、`uint32`)和多种内存布局(GlobalTensor 的 `ND`、`DN`、`NZ`;片上缓冲区的向量 tiles)。
+
+> **重要**:
+> - 此指令**仅用于开发和调试**
+> - 它会产生**显著的运行时开销**,**不得在生产 kernel 中使用**
+> - 如果输出超过内部打印缓冲区,可能会被**截断**。可以通过在编译选项中添加`-DCCEBlockMaxSize=16384`来修改打印缓冲区,默认为16KB
+> - **需要 CCE 编译选项 `-D_DEBUG --cce-enable-print`**(参见行为部分)
+
+## 机制
+
+该指令读取 Tile 或 GlobalTensor 中的数据并格式化输出。除非另有说明,语义在有效区域上定义,目标相关的行为标记为实现定义。
+
+## 语法
+
+### PTO-AS
+
+```text
+tprint %src : !pto.tile<...> | !pto.global<...>
+```
+
+### AS Level 1(SSA)
+
+```mlir
+pto.tprint %src : !pto.tile<...> | !pto.partition_tensor_view -> ()
+```
+
+### AS Level 2(DPS)
+
+```mlir
+pto.tprint ins(%src : !pto.tile_buf<...> | !pto.partition_tensor_view)
+```
+
+## C++ 内建接口
+
+声明于 `include/pto/common/pto_instr.hpp`:
+
+```cpp
+// 适用于打印GlobalTensor或Vec类型Tile
+template
+PTO_INST void TPRINT(TileData &src);
+
+// 适用于打印Acc类型Tile和Mat类型Tile(Mat打印仅适用于A3,A5暂不支持)
+template
+PTO_INTERNAL void TPRINT(TileData &src, GlobalData &tmp);
+```
+
+### PrintFormat 枚举
+
+声明于 `include/pto/common/type.hpp`:
+
+```cpp
+enum class PrintFormat : uint8_t
+{
+ Width8_Precision4 = 0, // 打印宽度8,精度4
+ Width8_Precision2 = 1, // 打印宽度8,精度2
+ Width10_Precision6 = 2, // 打印宽度10,精度6
+};
+```
+
+### 支持的 T 类型
+
+- **Tile**:TileType必须是`Vec`、`Acc`、`Mat(仅A3支持)`,并具有支持的元素类型
+- **GlobalTensor**:必须使用布局 `ND`、`DN` 或 `NZ`,并具有支持的元素类型
+
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| src | 输入 | Tile 或 GlobalTensor |
+| tmp | 可选 | 临时 GlobalTensor 空间(打印 Mat/Acc Tile 时需要) |
+| Format | 模板参数 | 打印格式(默认 Width8_Precision4) |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| 无 | void | 直接输出到调试通道 |
+
+## 副作用
+
+- **强制编译标志**: 在 A2/A3/A5 设备上,`TPRINT` 使用 `cce::printf` 通过设备到主机的调试通道输出。**必须启用 CCE 选项 `-D_DEBUG --cce-enable-print`**
+- **缓冲区限制**: `cce::printf` 的内部打印缓冲区大小有限。如果输出超过此缓冲区,可能会出现类似 `"Warning: out of bound! try best to print"` 的警告消息,并且**只会打印部分数据**
+- **同步**: 自动插入 `pipe_barrier(PIPE_ALL)` 以确保所有先前的操作完成且数据一致
+- **格式化**:
+ - 浮点数值:根据 `PrintFormat` 模板参数确定打印格式:
+ - `PrintFormat::Width8_Precision4`: `%8.4f`(默认)
+ - `PrintFormat::Width8_Precision2`: `%8.2f`
+ - `PrintFormat::Width10_Precision6`: `%10.6f`
+ - 整数值:根据 `PrintFormat` 模板参数确定打印格式:
+ - `PrintFormat::Width8_Precision4` 或 `PrintFormat::Width8_Precision2`: `%8d`
+ - `PrintFormat::Width10_Precision6`: `%10d`
+ - 对于 `GlobalTensor`,由于数据大小和缓冲区限制,仅打印其逻辑形状(由 `Shape` 定义)内的元素
+ - 对于 `Tile`,无效区域(超出 `validRows`/`validCols`)仍会被打印,但在指定部分有效性时用 `|` 分隔符标记
+
+## 约束
+
+- 支持的元素类型:
+ - 浮点数:float、half
+ - 有符号整数:int8_t、int16_t、int32_t
+ - 无符号整数:uint8_t、uint16_t、uint32_t
+- 对于 GlobalTensor:布局必须是 `Layout::ND`、`Layout::DN` 或 `Layout::NZ` 之一
+- 对于临时空间:打印 TileType 为 Mat 或 Acc 的 Tile 时需要传入 gm 上的临时空间,临时空间不得小于 TileData::Numel * sizeof(T)
+- A5 暂不支持 TileType 为 Mat 的 Tile 打印
+- 回显信息: TileType 为 Mat 时,布局将按照 `Layout::ND` 进行打印,其他布局可能会导致信息错位
+
+## 异常与非法情形
+
+- 输出超出打印缓冲区时显示警告并截断
+- 编译时未启用 `-D_DEBUG --cce-enable-print` 时指令不可用
+
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| Vec Tile 打印 | 支持 | 支持 | 支持 |
+| Acc Tile 打印 | 支持 | 支持 | 支持 |
+| Mat Tile 打印 | 支持 | 支持 | 不支持 |
+| GlobalTensor 打印 | 支持 | 支持 | 支持 |
+
+## 示例
+
+### C++ 自动模式 - 打印 Tile
+
+```cpp
+#include
+
+PTO_INTERNAL void DebugTile(__gm__ float *src) {
+ using ValidSrcShape = TileShape2D;
+ using NDSrcShape = BaseShape2D;
+ using GlobalDataSrc = GlobalTensor;
+ GlobalDataSrc srcGlobal(src);
+
+ using srcTileData = Tile;
+ srcTileData srcTile;
+ TASSIGN(srcTile, 0x0);
+
+ TLOAD(srcTile, srcGlobal);
+ TPRINT(srcTile);
+}
+```
+
+### C++ 自动模式 - 打印 GlobalTensor
+
+```cpp
+#include
+
+PTO_INTERNAL void DebugGlobalTensor(__gm__ float *src) {
+ using ValidSrcShape = TileShape2D;
+ using NDSrcShape = BaseShape2D;
+ using GlobalDataSrc = GlobalTensor;
+ GlobalDataSrc srcGlobal(src);
+
+ TPRINT(srcGlobal);
+}
+```
+
+### PTO-AS
+
+```text
+# 自动模式
+pto.tprint %src : !pto.tile<...> | !pto.partition_tensor_view -> ()
+
+# 手动模式
+pto.tprint %src : !pto.tile<...> | !pto.partition_tensor_view -> ()
+
+# PTO 汇编形式
+pto.tprint %src : !pto.tile<...> | !pto.partition_tensor_view -> ()
+# AS Level 2 (DPS)
+pto.tprint ins(%src : !pto.tile_buf<...> | !pto.partition_tensor_view)
+```
+
+## 相关页面
+
+- 指令集总览:[不规则与复杂操作](./tile/irregular-and-complex_zh.md)
diff --git a/docs/isa/TPUSH_zh.md b/docs/isa/TPUSH_zh.md
index bd0d01b9..5deb21e5 100644
--- a/docs/isa/TPUSH_zh.md
+++ b/docs/isa/TPUSH_zh.md
@@ -1,41 +1,92 @@
-# TPUSH
+# pto.tpush
-## 指令示意图
+`pto.tpush` 属于[同步与配置](./tile/sync-and-config_zh.md)指令集。
-
-
-## 简介
+## 概述
将 Tile 推入 pipe 或 FIFO 的生产者端。
-## 数学语义
+## 机制
+
+语义随具体指令变体而变化。除非另有说明,行为都按目标 valid region 定义。
-语义随指令而变化。 除非另有说明,行为都按目标 valid region 定义。
+## 语法
-## 汇编语法
+### PTO-AS
PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.tpush ...
```
### AS Level 2(DPS)
-```text
+```mlir
pto.tpush ins(...) outs(%dst : !pto.tile_buf<...>)
```
## C++ 内建接口
-声明于 `include/pto/common/pto_instr.hpp`.
+声明于 `include/pto/common/pto_instr.hpp`。
+
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| 源 Tile | 输入 | 待推入 pipe 或 FIFO 的 Tile |
+| Pipe/FIFO 引用 | 输入 | 目标 pipe 或 FIFO |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| 无 | - | 推送操作无返回值,Tile 所有权转移给生产者 |
+
+## 副作用
+
+将 Tile 移入 pipe 或 FIFO 的生产者端,Tile 所有权从消费者转移给生产者。
## 约束
-数据类型、layout、location 和 shape 的进一步限制以对应 backend 的合法性检查为准。
+- 数据类型、layout、location 和 shape 的进一步限制以对应 backend 的合法性检查为准。
+- 只能在 pipe 或 FIFO 有可用槽位时执行。
+
+## 异常与非法情形
+
+- 在 pipe 或 FIFO 满时执行属于未定义行为。
+- 生产者无权访问该 pipe 或 FIFO 时会被拒绝。
+
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| 推送操作 | Simulated | Supported | Supported |
## 示例
+### C++ 自动模式
+
+具体的 Auto / Manual 使用方式见 `docs/isa/` 下的相关指令页。
+
+### C++ 手动模式
+
具体的 Auto / Manual 使用方式见 `docs/isa/` 下的相关指令页。
+
+### PTO-AS
+
+```text
+pto.tpush %tile, %pipe : !pto.tile<...>
+```
+
+### AS Level 2(DPS)
+
+```mlir
+pto.tpush ins(%tile, %pipe : ...) outs(%dst : !pto.tile_buf<...>)
+```
+
+## 相关页面
+
+- 指令集总览:[同步与配置](./tile/sync-and-config_zh.md)
diff --git a/docs/isa/TRANDOM_zh.md b/docs/isa/TRANDOM_zh.md
index 2b83597b..2b7d3ce2 100644
--- a/docs/isa/TRANDOM_zh.md
+++ b/docs/isa/TRANDOM_zh.md
@@ -1,46 +1,42 @@
-# TRANDOM
+# pto.trandom
+`pto.trandom` 属于[不规则与复杂指令](./tile/irregular-and-complex_zh.md)集。
-## Tile Operation Diagram
+## 概述
-
+使用基于计数器的密码算法在目标 Tile 中生成伪随机数。该指令实现了一个基于计数器的随机数生成器,对于有效区域中的每个元素,它基于密钥和计数器状态,使用可配置轮数的密码类变换生成伪随机值。算法使用 128 位状态(4 × 32 位计数器)、64 位密钥(2 × 32 位字),以及类似 ChaCha 的四分之一轮操作。
-## 简介
+## 机制
-使用基于计数器的密码算法在目标 Tile 中生成随机数。
+### 数学语义
-## 数学解释
+对有效区域中的每个元素 `(i, j)`:
-该指令实现了一个基于计数器的随机数生成器。对于有效区域中的每个元素,它基于密钥和计数器状态,使用可配置轮数的密码类变换生成伪随机值。
+$$ \mathrm{dst}_{i,j} = \mathrm{CipherRound}^R\left(\mathrm{counter}_{i,j},\ \mathrm{key}\right) $$
-该算法使用:
-- 128 位状态(4 × 32 位计数器)
-- 64 位密钥(2 × 32 位字)
-- 类似 ChaCha 的四分之一轮操作,使用向量指令
+其中 $R$ 为轮数(默认 10 轮,可选 7 轮),使用类似 ChaCha 的四分之一轮操作进行密码学变换。
-## 汇编语法
+## 语法
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
-
-同步形式:
+### PTO-AS
```text
trandom %dst, %key, %counter : !pto.tile<...>
```
-### AS Level 1 (SSA)
+### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.trandom %key, %counter : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
-### AS Level 2 (DPS)
+### AS Level 2(DPS)
-```text
+```mlir
pto.trandom ins(%key, %counter : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
-## C++ 内置函数
+## C++ 内建接口
声明于 `include/pto/npu/a5/TRandom.hpp`:
@@ -49,19 +45,48 @@ template
PTO_INST void TRANDOM_IMPL(DstTile &dst, TRandomKey &key, TRandomCounter &counter);
```
-## 约束条件
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| `key` | 输入 | 64 位密钥(2 × 32 位字),包含 `key0` 和 `key1` |
+| `counter` | 输入 | 128 位计数器状态(4 × 32 位),每次调用后递增 |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `dst` | Tile | 生成的伪随机数,有效区域内有效 |
+
+## 副作用
+
+该操作通过密码学变换更新内部计数器状态。
+
+## 约束
+
+- A5 实现检查:
+ - `DstTile::DType` 必须为 `int32_t` 或 `uint32_t`
+ - Tile 布局必须为行主序(`DstTile::isRowMajor`)
+ - `Rounds` 必须为 7 或 10(默认为 10)
+ - `key` 和 `counter` 不能为空
+- 有效区域:
+ - 该操作使用 `dst.GetValidRow()` / `dst.GetValidCol()` 作为迭代域
+
+## 异常与非法情形
-- **实现检查(A5)**:
- - `DstTile::DType` 必须为以下类型之一:`int32_t`、`uint32_t`。
- - Tile 布局必须为行主序(`DstTile::isRowMajor`)。
- - `Rounds` 必须为 7 或 10(默认为 10)。
- - `key` 和 `counter` 不能为空。
-- **有效区域**:
- - 该操作使用 `dst.GetValidRow()` / `dst.GetValidCol()` 作为迭代域。
+- 若 `key` 或 `counter` 为空,行为未定义
+- 若 `DstTile::DType` 不是 `int32_t` 或 `uint32_t`,编译失败
+- 若 `Rounds` 不是 7 或 10,编译失败
+
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| 支持 | 是 | 否 | 是 |
## 示例
-### Auto 模式
+### C++ 自动模式
```cpp
#include
@@ -77,7 +102,7 @@ void example_auto() {
}
```
-### Manual 模式
+### C++ 手动模式
```cpp
#include
@@ -94,28 +119,17 @@ void example_manual() {
}
```
-## 汇编形式示例
-
-### Auto 模式
+### PTO-AS
```text
-# Auto 模式:编译器/运行时管理的布局和调度。
+# 自动模式:编译器/运行时管理的布局和调度
%dst = pto.trandom %key, %counter : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-```
-
-### Manual 模式
-```text
-# Manual 模式:在发出指令之前显式绑定资源。
-# Tile 操作数可选:
+# 手动模式:在发出指令之前显式绑定资源
# pto.tassign %arg0, @tile(0x3000)
%dst = pto.trandom %key, %counter : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
-### PTO 汇编形式
+## 相关页面
-```text
-trandom %dst, %key, %counter : !pto.tile<...>
-# AS Level 2 (DPS)
-pto.trandom ins(%key, %counter : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
-```
+- 指令集总览:[不规则与复杂指令](./tile/irregular-and-complex_zh.md)
diff --git a/docs/isa/TRECIP_zh.md b/docs/isa/TRECIP_zh.md
index 7ca039a0..a0f95e6c 100644
--- a/docs/isa/TRECIP_zh.md
+++ b/docs/isa/TRECIP_zh.md
@@ -1,24 +1,24 @@
-# TRECIP
-
-## 指令示意图
+# pto.trecip

-## 简介
+`pto.trecip` 属于[逐元素 Tile-Tile](./tile/elementwise-tile-tile_zh.md)指令集。
+
+## 概述
-Tile 的逐元素倒数。
+对 tile 做逐元素倒数,结果写入目标 tile。迭代域由目标 tile 的 valid region 决定。
-## 数学语义
+## 机制
-对每个元素 `(i, j)` 在有效区域内:
+对目标 tile 的 valid region 中每个 `(i, j)`:
$$ \mathrm{dst}_{i,j} = \frac{1}{\mathrm{src}_{i,j}} $$
-## 汇编语法
+它适合在后续仍要与其他 tile 做乘法组合时,替代显式除法。除零行为由目标定义。
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+## 语法
-同步形式:
+### PTO-AS
```text
%dst = trecip %src : !pto.tile<...>
@@ -26,52 +26,73 @@ PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.trecip %src : !pto.tile<...> -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.trecip ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
## C++ 内建接口
-声明于 `include/pto/common/pto_instr.hpp`:
-
```cpp
template
PTO_INST RecordEvent TRECIP(TileDataDst &dst, TileDataSrc &src, WaitEvents &... events);
```
-`PrecisionType`可指定以下值:
+`PrecisionType` 可选:
+
+- `RecipAlgorithm::DEFAULT`:普通算法,速度快但精度较低。
+- `RecipAlgorithm::HIGH_PRECISION`:高精度算法,速度较慢。
+
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| `%src` | 源 tile | 输入 tile |
+| `%dst` | 目标 tile | 接收逐元素倒数结果 |
+| `WaitEvents...` | 可选同步 | 发射前需要等待的事件 |
-* `RecipAlgorithm::DEFAULT`:普通算法,速度快但精度较低。
-* `RecipAlgorithm::HIGH_PRECISION`:高精度算法,速度较慢。
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `%dst` | `!pto.tile<...>` | `dst` valid region 内的每个元素都等于 `1 / src` |
+
+## 副作用
+
+除产生目标 tile 外,没有额外架构副作用。
## 约束
-- **实现检查 (NPU)**:
- - `TileData::DType` 必须是以下之一:`float` 或 `half`。
- - Tile 位置必须是向量(`TileData::Loc == TileType::Vec`);
- - 静态有效边界:`TileData::ValidRow <= TileData::Rows` 且 `TileData::ValidCol <= TileData::Cols`。
- - 运行时:`src.GetValidRow() == dst.GetValidRow()` 且 `src.GetValidCol() == dst.GetValidCol()`。
- - Tile 布局必须是行主序(`TileData::isRowMajor`)。
- - A3 的 TRECIP 指令不支持将源 Tile 和目标 Tile 设置为相同的内存。
-- **有效区域**:
- - 该操作使用 `dst.GetValidRow()` / `dst.GetValidCol()` 作为迭代域。
-- **域 / NaN**:
- - 除零行为由目标定义;CPU 模拟器在调试构建中会断言。
-- **高精度算法**
- - 仅在A5上有效,`PrecisionType`选项A3上将被忽略。
+- 迭代域由 `dst.GetValidRow()` / `dst.GetValidCol()` 决定。
+- 除零行为由目标定义;CPU 模拟器在调试构建下会断言。
+- 高精度算法只在 A5 有效。
+- A3 不支持源 tile 与目标 tile 绑定到同一片内存。
+
+## 异常与非法情形
+
+- 非法操作数组合、不支持的数据类型、不合法布局或不支持的 target-profile 模式,会被 verifier 或后端实现拒绝。
+
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| `float` | Simulated | Supported | Supported |
+| `half` | Simulated | Supported | Supported |
+| 布局 | Any | RowMajor only | RowMajor only |
+| 同址操作 | No | No | No |
## 示例
+### C++ 自动模式
+
```cpp
#include
-
using namespace pto;
void example() {
@@ -82,29 +103,39 @@ void example() {
}
```
-## 汇编示例(ASM)
+### C++ 手动模式
-### 自动模式
+```cpp
+#include
+using namespace pto;
-```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
-%dst = pto.trecip %src : !pto.tile<...> -> !pto.tile<...>
+void example_manual() {
+ using TileT = Tile;
+ TileT src, dst;
+ TASSIGN(src, 0x1000);
+ TASSIGN(dst, 0x2000);
+ TRECIP(dst, src);
+}
```
-### 手动模式
+### PTO-AS
```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
+# 自动模式
%dst = pto.trecip %src : !pto.tile<...> -> !pto.tile<...>
-```
-### PTO 汇编形式
+# 手动模式
+pto.tassign %arg0, @tile(0x1000)
+pto.tassign %arg1, @tile(0x2000)
+%dst = pto.trecip %src : !pto.tile<...> -> !pto.tile<...>
-```text
+# PTO 汇编形式
%dst = trecip %src : !pto.tile<...>
# AS Level 2 (DPS)
pto.trecip ins(%src : !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
+
+## 相关页面
+
+- 指令集总览:[逐元素 Tile-Tile](./tile/elementwise-tile-tile_zh.md)
+- 规范页:[pto.trecip](./tile/ops/elementwise-tile-tile/trecip_zh.md)
diff --git a/docs/isa/TROWARGMAX_zh.md b/docs/isa/TROWARGMAX_zh.md
index 517f2fb6..431322f7 100644
--- a/docs/isa/TROWARGMAX_zh.md
+++ b/docs/isa/TROWARGMAX_zh.md
@@ -1,41 +1,35 @@
# pto.trowargmax
-旧路径兼容入口。规范页见 [pto.trowargmax](./tile/ops/reduce-and-expand/trowargmax_zh.md)。
+`pto.trowargmax` 属于[行归约](./tile/ops/reduce-and-expand/trowargmax_zh.md)指令集。
-
+## 概述
-## 简介
+获取每行最大值对应列索引。对源 tile 的每一行,计算该行最大元素的列索引,写入目标 tile 对应行的第一个位置。
-获取每行最大值对应列索引,或同时获取每行最大值及其对应列索引。
-
-## 数学语义
+## 机制
设 `R = src.GetValidRow()`,`C = src.GetValidCol()`。对 `0 <= i < R`:
$$ \mathrm{dst}_{i,0} = \underset{0 \le j < C}{\operatorname{argmax}} \; \mathrm{src}_{i,j} $$
-$$ \mathrm{dstval}_{i,0} = \max_{0 \le j < C} \mathrm{src}_{i,j} $$
-
-## 汇编语法
+## 语法
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
-
-同步形式:
+### PTO-AS
```text
%dst = trowargmax %src : !pto.tile<...> -> !pto.tile<...>
```
Lowering may introduce internal scratch tiles; the C++ intrinsic requires an explicit `tmp` operand.
-### IR Level 1(SSA)
+### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.trowargmax %src, %tmp : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
-### IR Level 2(DPS)
+### AS Level 2(DPS)
-```text
+```mlir
pto.trowargmax ins(%src, %tmp : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
@@ -43,73 +37,63 @@ pto.trowargmax ins(%src, %tmp : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%ds
声明于 `include/pto/common/pto_instr.hpp`:
-仅输出索引:
-
```cpp
template
PTO_INST RecordEvent TROWARGMAX(TileDataOut& dst, TileDataIn& src, TileDataTmp& tmp, WaitEvents&... events);
```
-同时输出值和索引:
+## 输入
-```cpp
-template
-PTO_INST RecordEvent TROWARGMAX(TileDataOutVal &dstVal, TileDataOutIdx &dstIdx, TileDataIn &src, TileDataTmp &tmp,
- WaitEvents &... events)
-```
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| `src` | 输入 | 源 tile,支持 `half`、`float` 元素类型 |
+| `tmp` | 临时 | A3 临时 tile,取决于 `srcValidCol` 与 `ElementPerRepeat` 的关系 |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `dst` | 输出 | 每行最大值的列索引,`uint32_t` 或 `int32_t` 类型 |
+
+## 副作用
+
+指令执行完成后,`dst` 有效行数与 `src` 相同,有效列数为 1。
## 约束
-### 通用约束或检查
-
-- 支持的源元素类型:`half`、`float`。
-- `src` 必须使用标准 ND 布局:行主且非分形(`BLayout::RowMajor`、`SLayout::NoneBox`)。
-- 仅输出索引时:
- -`dst` 和 `src` 必须为 `TileType::Vec`。
- - 支持的目标元素类型:`uint32_t`、`int32_t`。
- - 运行时检查遵循共享的行归约检查路径:
- - `src.GetValidRow() != 0`
- - `src.GetValidCol() != 0`
- - `src.GetValidRow() == dst.GetValidRow()`
- - `dst` 通过共享的行归约索引检查路径约束,可使用以下任一非分形布局:
- - 单列 DN 布局(`BLayout::ColMajor`、`Cols == 1`),或
- - 有效列数为 1 的 ND 布局。
-- 同时输出值和索引时:
- - `dstVal`、`dstIdx`、`src` 必须为 `TileType::Vec`。
- - `dstVal`的元素类型必须与`src`的元素类型一致。
- - 支持的目标元素类型:
- - 源元素类型为`float`时,支持`uint32_t`、`int32_t`。
- - 源元素类型为`half`时,支持`uint16_t`、`int16_t`。
- - 运行时检查遵循共享的行归约检查路径:
- - `src.GetValidRow() != 0`
- - `src.GetValidCol() != 0`
- - `src.GetValidRow() == dstIdx.GetValidRow()`
- - `src.GetValidRow() == dstVal.GetValidRow()`
- - `dstVal`、`dstIdx`通过共享的行归约索引检查路径约束,可使用以下任一非分形布局:
- - 单列 DN 布局(`BLayout::ColMajor`、`Cols == 1`),或
- - 有效列数为 1 的 ND 布局。
-
-### `tmp`临时Tile相关说明
-
-- 仅A3使用`tmp`临时Tile,A5接收`tmp`但实际并不使用。
-- 仅输出索引时,`tmp`临时Tile在`srcValidCol <= ElementPerRepeat`时不使用。
-- 同时输出值和索引且`srcValidCol <= ElementPerRepeat`时,`tmp`临时Tile可使用以下任一非分形布局:
- - 单列 DN 布局(`BLayout::ColMajor`、`Cols == 1`),有效行数为`srcValidRow * 2`。
- - 有效行数为`srcValidRow`且有效列数为 2 的 ND 布局。
-- `srcValidCol > ElementPerRepeat`时:
- - `tmp` tile的行数和`src` tile的行数相同。
- - 按以下公式根据`src` tile的`validCol`算出`tmp` tile所需stride:
+- `dst` 和 `src` 必须为 `TileType::Vec`
+- 支持的源元素类型:`half`、`float`
+- 支持的目标元素类型:`uint32_t`、`int32_t`
+- `src.GetValidRow() != 0`
+- `src.GetValidCol() != 0`
+- `src.GetValidRow() == dst.GetValidRow()`
+- `src` 必须使用标准 ND 布局:行主且非分形(`BLayout::RowMajor`、`SLayout::NoneBox`)
+- `dst` 可使用单列 DN 布局(`BLayout::ColMajor`、`Cols == 1`)或有效列数为 1 的 ND 布局
+
+### A3 `tmp`临时Tile相关说明
+
+- `tmp`临时Tile在`srcValidCol <= ElementPerRepeat`时不使用,`srcValidCol > ElementPerRepeat`时需要使用
+- `tmp` tile的行数和`src` tile的行数相同
+- 按以下公式根据`src` tile的`validCol`算出`tmp` tile所需stride:
```text
repeats = ceil(validCol / elementPerRepeat)
-stride = (ceil(repeats * 2 / elementPerBlock) + ceil(repeats / elementPerBlock)) * elementPerBlock
+stride = ceil(repeats * 2 / elementPerBlock) * elementPerBlock + ceil(repeats / elementPerBlock) * elementPerBlock
```
+## 异常与非法情形
+
+- 运行时检查失败时,行为由具体实现定义
+
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| 支持 | 是 | 是 | 是 |
## 示例
-### 自动(Auto)
+### C++ 自动模式
```cpp
#include
@@ -119,18 +103,15 @@ using namespace pto;
void example_auto() {
using SrcT = Tile;
using DstT = Tile;
- using DstValT = Tile;
using TmpT = Tile;
SrcT src;
DstT dst;
- DstValT dst;
TmpT tmp;
TROWARGMAX(dst, src, tmp);
- TROWARGMAX(dstVal, dst, src, tmp);
}
```
-### 手动(Manual)
+### C++ 手动模式
```cpp
#include
@@ -140,46 +121,24 @@ using namespace pto;
void example_manual() {
using SrcT = Tile;
using DstT = Tile;
- using DstValT = Tile;
using TmpT = Tile;
SrcT src;
DstT dst;
- DstValT dst;
TmpT tmp;
TASSIGN(src, 0x1000);
TASSIGN(dst, 0x2000);
- TASSIGN(dstVal, 0x3000);
- TASSIGN(tmp, 0x4000);
+ TASSIGN(tmp, 0x3000);
TROWARGMAX(dst, src, tmp);
- TROWARGMAX(dstVal, dst, src, tmp);
}
```
-## 汇编示例(ASM)
-
-### 自动模式
-
-```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
-%dst = pto.trowargmax %src, %tmp : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-```
-
-### 手动模式
+### PTO-AS
```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
+# 自动模式
%dst = pto.trowargmax %src, %tmp : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
-### PTO 汇编形式
-
-```text
-%dst = trowargmax %src : !pto.tile<...> -> !pto.tile<...>
-# IR Level 2 (DPS)
-pto.trowargmax ins(%src, %tmp : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
-```
+## 相关页面
-新的 PTO ISA 文档应直接链接到分组后的指令集路径。
+- 指令集总览:[行归约](./tile/ops/reduce-and-expand/trowargmax_zh.md)
diff --git a/docs/isa/TROWARGMIN_zh.md b/docs/isa/TROWARGMIN_zh.md
index bc93817a..2fb10f15 100644
--- a/docs/isa/TROWARGMIN_zh.md
+++ b/docs/isa/TROWARGMIN_zh.md
@@ -1,41 +1,35 @@
# pto.trowargmin
-旧路径兼容入口。规范页见 [pto.trowargmin](./tile/ops/reduce-and-expand/trowargmin_zh.md)。
+`pto.trowargmin` 属于[行归约](./tile/ops/reduce-and-expand/trowargmin_zh.md)指令集。
-
+## 概述
-## 简介
+获取每行最小值对应列索引。对源 tile 的每一行,计算该行最小元素的列索引,写入目标 tile 对应行的第一个位置。
-获取每行最小值对应列索引,或同时获取每行最小值及其对应列索引。
-
-## 数学语义
+## 机制
设 `R = src.GetValidRow()`,`C = src.GetValidCol()`。对 `0 <= i < R`:
$$ \mathrm{dst}_{i,0} = \underset{0 \le j < C}{\operatorname{argmin}} \; \mathrm{src}_{i,j} $$
-$$ \mathrm{dstval}_{i,0} = \min_{0 \le j < C} \mathrm{src}_{i,j} $$
-
-## 汇编语法
+## 语法
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
-
-同步形式:
+### PTO-AS
```text
%dst = trowargmin %src : !pto.tile<...> -> !pto.tile<...>
```
Lowering may introduce internal scratch tiles; the C++ intrinsic requires an explicit `tmp` operand.
-### IR Level 1(SSA)
+### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.trowargmin %src, %tmp : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
-### IR Level 2(DPS)
+### AS Level 2(DPS)
-```text
+```mlir
pto.trowargmin ins(%src, %tmp : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
@@ -43,73 +37,63 @@ pto.trowargmin ins(%src, %tmp : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%ds
声明于 `include/pto/common/pto_instr.hpp`:
-仅输出索引:
-
```cpp
template
PTO_INST RecordEvent TROWARGMIN(TileDataOut& dst, TileDataIn& src, TileDataTmp& tmp, WaitEvents&... events);
```
-同时输出值和索引:
+## 输入
-```cpp
-template
-PTO_INST RecordEvent TROWARGMIN(TileDataOutVal &dstVal, TileDataOutIdx &dstIdx, TileDataIn &src, TileDataTmp &tmp,
- WaitEvents &... events)
-```
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| `src` | 输入 | 源 tile,支持 `half`、`float` 元素类型 |
+| `tmp` | 临时 | A3 临时 tile,取决于 `srcValidCol` 与 `ElementPerRepeat` 的关系 |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `dst` | 输出 | 每行最小值的列索引,`uint32_t` 或 `int32_t` 类型 |
+
+## 副作用
+
+指令执行完成后,`dst` 有效行数与 `src` 相同,有效列数为 1。
## 约束
-### 通用约束或检查
-
-- 支持的源元素类型:`half`、`float`。
-- `src` 必须使用标准 ND 布局:行主且非分形(`BLayout::RowMajor`、`SLayout::NoneBox`)。
-- 仅输出索引时:
- -`dst` 和 `src` 必须为 `TileType::Vec`。
- - 支持的目标元素类型:`uint32_t`、`int32_t`。
- - 运行时检查遵循共享的行归约检查路径:
- - `src.GetValidRow() != 0`
- - `src.GetValidCol() != 0`
- - `src.GetValidRow() == dst.GetValidRow()`
- - `dst` 通过共享的行归约索引检查路径约束,可使用以下任一非分形布局:
- - 单列 DN 布局(`BLayout::ColMajor`、`Cols == 1`),或
- - 有效列数为 1 的 ND 布局。
-- 同时输出值和索引时:
- - `dstVal`、`dstIdx`、`src` 必须为 `TileType::Vec`。
- - `dstVal`的元素类型必须与`src`的元素类型一致。
- - 支持的目标元素类型:
- - 源元素类型为`float`时,支持`uint32_t`、`int32_t`。
- - 源元素类型为`half`时,支持`uint16_t`、`int16_t`。
- - 运行时检查遵循共享的行归约检查路径:
- - `src.GetValidRow() != 0`
- - `src.GetValidCol() != 0`
- - `src.GetValidRow() == dstIdx.GetValidRow()`
- - `src.GetValidRow() == dstVal.GetValidRow()`
- - `dstVal`、`dstIdx`通过共享的行归约索引检查路径约束,可使用以下任一非分形布局:
- - 单列 DN 布局(`BLayout::ColMajor`、`Cols == 1`),或
- - 有效列数为 1 的 ND 布局。
-
-### `tmp`临时Tile相关说明
-
-- 仅A3使用`tmp`临时Tile,A5接收`tmp`但实际并不使用。
-- 仅输出索引时,`tmp`临时Tile在`srcValidCol <= ElementPerRepeat`时不使用。
-- 同时输出值和索引且`srcValidCol <= ElementPerRepeat`时,`tmp`临时Tile可使用以下任一非分形布局:
- - 单列 DN 布局(`BLayout::ColMajor`、`Cols == 1`),有效行数为`srcValidRow * 2`。
- - 有效行数为`srcValidRow`且有效列数为 2 的 ND 布局。
-- `srcValidCol > ElementPerRepeat`时:
- - `tmp` tile的行数和`src` tile的行数相同。
- - 按以下公式根据`src` tile的`validCol`算出`tmp` tile所需stride:
+- `dst` 和 `src` 必须为 `TileType::Vec`
+- 支持的源元素类型:`half`、`float`
+- 支持的目标元素类型:`uint32_t`、`int32_t`
+- `src.GetValidRow() != 0`
+- `src.GetValidCol() != 0`
+- `src.GetValidRow() == dst.GetValidRow()`
+- `src` 必须使用标准 ND 布局:行主且非分形(`BLayout::RowMajor`、`SLayout::NoneBox`)
+- `dst` 可使用单列 DN 布局(`BLayout::ColMajor`、`Cols == 1`)或有效列数为 1 的 ND 布局
+
+### A3 `tmp`临时Tile相关说明
+
+- `tmp`临时Tile在`srcValidCol <= ElementPerRepeat`时不使用,`srcValidCol > ElementPerRepeat`时需要使用
+- `tmp` tile的行数和`src` tile的行数相同
+- 按以下公式根据`src` tile的`validCol`算出`tmp` tile所需stride:
```text
repeats = ceil(validCol / elementPerRepeat)
-stride = (ceil(repeats * 2 / elementPerBlock) + ceil(repeats / elementPerBlock)) * elementPerBlock
+stride = ceil(repeats * 2 / elementPerBlock) * elementPerBlock + ceil(repeats / elementPerBlock) * elementPerBlock
```
+## 异常与非法情形
+
+- 运行时检查失败时,行为由具体实现定义
+
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| 支持 | 是 | 是 | 是 |
## 示例
-### 自动(Auto)
+### C++ 自动模式
```cpp
#include
@@ -119,18 +103,15 @@ using namespace pto;
void example_auto() {
using SrcT = Tile;
using DstT = Tile;
- using DstValT = Tile;
using TmpT = Tile;
SrcT src;
DstT dst;
- DstValT dst;
TmpT tmp;
TROWARGMIN(dst, src, tmp);
- TROWARGMIN(dstVal, dst, src, tmp);
}
```
-### 手动(Manual)
+### C++ 手动模式
```cpp
#include
@@ -140,46 +121,24 @@ using namespace pto;
void example_manual() {
using SrcT = Tile;
using DstT = Tile;
- using DstValT = Tile;
using TmpT = Tile;
SrcT src;
DstT dst;
- DstValT dst;
TmpT tmp;
TASSIGN(src, 0x1000);
TASSIGN(dst, 0x2000);
- TASSIGN(dstVal, 0x3000);
- TASSIGN(tmp, 0x4000);
+ TASSIGN(tmp, 0x3000);
TROWARGMIN(dst, src, tmp);
- TROWARGMIN(dstVal, dst, src, tmp);
}
```
-## 汇编示例(ASM)
-
-### 自动模式
-
-```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
-%dst = pto.trowargmin %src, %tmp : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-```
-
-### 手动模式
+### PTO-AS
```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
+# 自动模式
%dst = pto.trowargmin %src, %tmp : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
-### PTO 汇编形式
-
-```text
-%dst = trowargmin %src : !pto.tile<...> -> !pto.tile<...>
-# IR Level 2 (DPS)
-pto.trowargmin ins(%src, %tmp : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
-```
+## 相关页面
-新的 PTO ISA 文档应直接链接到分组后的指令集路径。
+- 指令集总览:[行归约](./tile/ops/reduce-and-expand/trowargmin_zh.md)
diff --git a/docs/isa/TROWEXPANDADD_zh.md b/docs/isa/TROWEXPANDADD_zh.md
index 7110c5d8..04746280 100644
--- a/docs/isa/TROWEXPANDADD_zh.md
+++ b/docs/isa/TROWEXPANDADD_zh.md
@@ -1,14 +1,12 @@
-# TROWEXPANDADD
+# pto.trowexpandadd
-## 指令示意图
+`pto.trowexpandadd` 属于[行归约](./tile/ops/reduce-and-expand/trowexpandadd_zh.md)指令集。
-
+## 概述
-## 简介
+行广播加法:将 `src1` 中每行的标量值加到 `src0` 对应行的所有元素上,结果写入 `dst`。
-行广播加法:加上一个每行标量向量。
-
-## 数学语义
+## 机制
设 `R = dst.GetValidRow()` 和 `C = dst.GetValidCol()`。设 `s_i` 为从 `src1` 中获取的每行标量(每行一个值)。
@@ -18,11 +16,9 @@ $$
\mathrm{dst}_{i,j} = \mathrm{src0}_{i,j} + s_i
$$
-## 汇编语法
-
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+## 语法
-同步形式:
+### PTO-AS
```text
%dst = trowexpandadd %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
@@ -30,13 +26,13 @@ PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.trowexpandadd %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.trowexpandadd ins(%src0, %src1 : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
@@ -53,42 +49,82 @@ template
-### 自动模式
+using namespace pto;
-```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
-%dst = pto.trowexpandadd %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
+void example_auto() {
+ using TileT = Tile;
+ TileT src0, src1, dst;
+ TROWEXPANDADD(dst, src0, src1);
+}
```
-### 手动模式
+### C++ 手动模式
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
-%dst = pto.trowexpandadd %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
+```cpp
+#include
+
+using namespace pto;
+
+void example_manual() {
+ using TileT = Tile;
+ TileT src0, src1, dst;
+ TASSIGN(src0, 0x1000);
+ TASSIGN(src1, 0x2000);
+ TASSIGN(dst, 0x3000);
+ TROWEXPANDADD(dst, src0, src1);
+}
```
-### PTO 汇编形式
+### PTO-AS
```text
-%dst = trowexpandadd %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
-# AS Level 2 (DPS)
-pto.trowexpandadd ins(%src0, %src1 : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
+# 自动模式
+%dst = pto.trowexpandadd %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
```
+
+## 相关页面
+
+- 指令集总览:[行归约](./tile/ops/reduce-and-expand/trowexpandadd_zh.md)
diff --git a/docs/isa/TROWEXPANDEXPDIF_zh.md b/docs/isa/TROWEXPANDEXPDIF_zh.md
index 8d08fdc5..4ddf7bf3 100644
--- a/docs/isa/TROWEXPANDEXPDIF_zh.md
+++ b/docs/isa/TROWEXPANDEXPDIF_zh.md
@@ -1,14 +1,12 @@
-# TROWEXPANDEXPDIF
+# pto.trowexpandexpdif
-## 指令示意图
+`pto.trowexpandexpdif` 属于[行归约](./tile/ops/reduce-and-expand/trowexpandexpdif_zh.md)指令集。
-
+## 概述
-## 简介
+行指数差运算:计算 `exp(src0 - src1)`,其中 `src1` 为每行标量,结果写入 `dst`。
-行指数差运算:计算 exp(src0 - src1),其中 src1 为每行标量。
-
-## 数学语义
+## 机制
设 `R = dst.GetValidRow()` 和 `C = dst.GetValidCol()`。设 `s_i` 为从 `src1` 中获取的每行标量(每行一个值)。
@@ -18,11 +16,9 @@ $$
\mathrm{dst}_{i,j} = \exp(\mathrm{src0}_{i,j} - s_i)
$$
-## 汇编语法
-
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+## 语法
-同步形式:
+### PTO-AS
```text
%dst = trowexpandexpdif %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
@@ -30,13 +26,13 @@ PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.trowexpandexpdif %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.trowexpandexpdif ins(%src0, %src1 : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
@@ -53,42 +49,82 @@ template
-### 自动模式
+using namespace pto;
-```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
-%dst = pto.trowexpandexpdif %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
+void example_auto() {
+ using TileT = Tile;
+ TileT src0, src1, dst;
+ TROWEXPANDEXPDIF(dst, src0, src1);
+}
```
-### 手动模式
+### C++ 手动模式
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
-%dst = pto.trowexpandexpdif %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
+```cpp
+#include
+
+using namespace pto;
+
+void example_manual() {
+ using TileT = Tile;
+ TileT src0, src1, dst;
+ TASSIGN(src0, 0x1000);
+ TASSIGN(src1, 0x2000);
+ TASSIGN(dst, 0x3000);
+ TROWEXPANDEXPDIF(dst, src0, src1);
+}
```
-### PTO 汇编形式
+### PTO-AS
```text
-%dst = trowexpandexpdif %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
-# AS Level 2 (DPS)
-pto.trowexpandexpdif ins(%src0, %src1 : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
+# 自动模式
+%dst = pto.trowexpandexpdif %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
```
+
+## 相关页面
+
+- 指令集总览:[行归约](./tile/ops/reduce-and-expand/trowexpandexpdif_zh.md)
diff --git a/docs/isa/TROWEXPANDMAX_zh.md b/docs/isa/TROWEXPANDMAX_zh.md
index b2fc538a..85ae6649 100644
--- a/docs/isa/TROWEXPANDMAX_zh.md
+++ b/docs/isa/TROWEXPANDMAX_zh.md
@@ -1,14 +1,12 @@
-# TROWEXPANDMAX
+# pto.trowexpandmax
-## 指令示意图
+`pto.trowexpandmax` 属于[行归约](./tile/ops/reduce-and-expand/trowexpandmax_zh.md)指令集。
-
+## 概述
-## 简介
+行广播最大值:将 `src1` 中每行的标量值与 `src0` 对应行的所有元素取最大值,结果写入 `dst`。
-行广播最大值:与每行标量向量取最大值。
-
-## 数学语义
+## 机制
设 `R = dst.GetValidRow()` 和 `C = dst.GetValidCol()`。设 `s_i` 为从 `src1` 中获取的每行标量(每行一个值)。
@@ -18,11 +16,9 @@ $$
\mathrm{dst}_{i,j} = \max(\mathrm{src0}_{i,j}, s_i)
$$
-## 汇编语法
-
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+## 语法
-同步形式:
+### PTO-AS
```text
%dst = trowexpandmax %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
@@ -30,13 +26,13 @@ PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.trowexpandmax %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.trowexpandmax ins(%src0, %src1 : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
@@ -53,42 +49,82 @@ template
-### 自动模式
+using namespace pto;
-```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
-%dst = pto.trowexpandmax %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
+void example_auto() {
+ using TileT = Tile;
+ TileT src0, src1, dst;
+ TROWEXPANDMAX(dst, src0, src1);
+}
```
-### 手动模式
+### C++ 手动模式
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
-%dst = pto.trowexpandmax %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
+```cpp
+#include
+
+using namespace pto;
+
+void example_manual() {
+ using TileT = Tile;
+ TileT src0, src1, dst;
+ TASSIGN(src0, 0x1000);
+ TASSIGN(src1, 0x2000);
+ TASSIGN(dst, 0x3000);
+ TROWEXPANDMAX(dst, src0, src1);
+}
```
-### PTO 汇编形式
+### PTO-AS
```text
-%dst = trowexpandmax %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
-# AS Level 2 (DPS)
-pto.trowexpandmax ins(%src0, %src1 : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
+# 自动模式
+%dst = pto.trowexpandmax %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
```
+
+## 相关页面
+
+- 指令集总览:[行归约](./tile/ops/reduce-and-expand/trowexpandmax_zh.md)
diff --git a/docs/isa/TROWEXPANDMIN_zh.md b/docs/isa/TROWEXPANDMIN_zh.md
index 8a28598b..9470f967 100644
--- a/docs/isa/TROWEXPANDMIN_zh.md
+++ b/docs/isa/TROWEXPANDMIN_zh.md
@@ -1,14 +1,12 @@
-# TROWEXPANDMIN
+# pto.trowexpandmin
-## 指令示意图
+`pto.trowexpandmin` 属于[行归约](./tile/ops/reduce-and-expand/trowexpandmin_zh.md)指令集。
-
+## 概述
-## 简介
+行广播最小值:将 `src1` 中每行的标量值与 `src0` 对应行的所有元素取最小值,结果写入 `dst`。
-行广播最小值:与每行标量向量取最小值。
-
-## 数学语义
+## 机制
设 `R = dst.GetValidRow()` 和 `C = dst.GetValidCol()`。设 `s_i` 为从 `src1` 中获取的每行标量(每行一个值)。
@@ -18,11 +16,9 @@ $$
\mathrm{dst}_{i,j} = \min(\mathrm{src0}_{i,j}, s_i)
$$
-## 汇编语法
-
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+## 语法
-同步形式:
+### PTO-AS
```text
%dst = trowexpandmin %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
@@ -30,13 +26,13 @@ PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.trowexpandmin %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.trowexpandmin ins(%src0, %src1 : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
@@ -53,42 +49,82 @@ template
-### 自动模式
+using namespace pto;
-```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
-%dst = pto.trowexpandmin %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
+void example_auto() {
+ using TileT = Tile;
+ TileT src0, src1, dst;
+ TROWEXPANDMIN(dst, src0, src1);
+}
```
-### 手动模式
+### C++ 手动模式
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
-%dst = pto.trowexpandmin %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
+```cpp
+#include
+
+using namespace pto;
+
+void example_manual() {
+ using TileT = Tile;
+ TileT src0, src1, dst;
+ TASSIGN(src0, 0x1000);
+ TASSIGN(src1, 0x2000);
+ TASSIGN(dst, 0x3000);
+ TROWEXPANDMIN(dst, src0, src1);
+}
```
-### PTO 汇编形式
+### PTO-AS
```text
-%dst = trowexpandmin %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
-# AS Level 2 (DPS)
-pto.trowexpandmin ins(%src0, %src1 : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
+# 自动模式
+%dst = pto.trowexpandmin %src0, %src1 : !pto.tile<...>, !pto.tile<...> -> !pto.tile<...>
```
+
+## 相关页面
+
+- 指令集总览:[行归约](./tile/ops/reduce-and-expand/trowexpandmin_zh.md)
diff --git a/docs/isa/TROWMAX_zh.md b/docs/isa/TROWMAX_zh.md
index 3038f9a0..dc92de16 100644
--- a/docs/isa/TROWMAX_zh.md
+++ b/docs/isa/TROWMAX_zh.md
@@ -1,39 +1,34 @@
-# TROWMAX
+# pto.trowmax
-## 指令示意图
+`pto.trowmax` 属于[归约与扩展](./tile/reduce-and-expand_zh.md)指令集。
-
-
-## 简介
+## 概述
通过取列间最大值来归约每一行。
-## 数学语义
+## 机制
设 `R = src.GetValidRow()`,`C = src.GetValidCol()`。对 `0 <= i < R`:
$$ \mathrm{dst}_{i,0} = \max_{0 \le j < C} \mathrm{src}_{i,j} $$
-## 汇编语法
+迭代域由 `src` 的 valid region 决定。C++ 内建接口需要显式传入 `tmp` 操作数。若 `src.GetValidRow() == 0` 或 `src.GetValidCol() == 0`,实现会直接返回。
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+## 语法
-同步形式:
+### PTO-AS
-```text
-%dst = trowmax %src : !pto.tile<...> -> !pto.tile<...>
-```
-降低时可能引入内部临时 Tile;C++ 内建接口需要显式传入 `tmp` 操作数。
+参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.trowmax %src, %tmp : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.trowmax ins(%src, %tmp : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
@@ -46,36 +41,48 @@ template ` | 每行的最大元素值 |
+
+## 副作用
+
+除产生目标 tile 外,没有额外架构副作用。
+
+## 约束
- `dst` 和 `src` 必须均为 `TileType::Vec`。
- `src` 必须使用标准 ND 布局:行主且非分形(`BLayout::RowMajor`、`SLayout::NoneBox`)。
-- `dst` 必须使用以下两种非分形布局之一:
- - ND 布局(`BLayout::RowMajor`、`SLayout::NoneBox`),或
- - 列数严格为 1 的 DN 布局(`BLayout::ColMajor`、`SLayout::NoneBox`、`Cols == 1`)。
+- `dst` 必须使用以下两种非分形布局之一:ND 布局(`BLayout::RowMajor`、`SLayout::NoneBox`),或列数严格为 1 的 DN 布局(`BLayout::ColMajor`、`SLayout::NoneBox`、`Cols == 1`)。
- `dst` 和 `src` 的元素类型必须一致。
-- 运行时有效区域检查:
- - `src.GetValidRow() != 0`
- - `src.GetValidCol() != 0`
- - `src.GetValidRow() == dst.GetValidRow()`
-- 内建接口签名要求显式传入 `tmp` 操作数。
+- 运行时有效区域检查:`src.GetValidRow() != 0`、`src.GetValidCol() != 0`、`src.GetValidRow() == dst.GetValidRow()`。
+
+## 异常与非法情形
-### A2A3 实现检查
+- 非法操作数组合、不支持的数据类型、不合法布局或不支持的 target-profile 模式,会被 verifier 或后端实现拒绝。
-- 支持的元素类型:`half`、`float`、`int32_t`、`int16_t`。
-- 实现同时接受 ND 输出和 `Cols == 1` 的 DN 输出。
-- 运行时检查遵循共享的行归约检查路径:
- - `src.GetValidRow() != 0`
- - `src.GetValidCol() != 0`
- - `src.GetValidRow() == dst.GetValidRow()`
-- 当前实现路径会将 `tmp` 传入后端调用,但本文档不额外补充 checked implementation 未显式约束的 `tmp` shape/layout 要求。
+## Target-Profile 限制
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| `float` | Simulated | Supported | — |
+| `half` | Simulated | Supported | — |
+| `int16_t` / `int32_t` | — | Supported | — |
## 示例
-### 自动(Auto)
+### C++ 自动模式
```cpp
#include
@@ -93,7 +100,7 @@ void example_auto() {
}
```
-### 手动(Manual)
+### C++ 手动模式
```cpp
#include
@@ -114,29 +121,23 @@ void example_manual() {
}
```
-## 汇编示例(ASM)
-
-### 自动模式
+### PTO-AS
```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
+# 自动模式
%dst = pto.trowmax %src, %tmp : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-```
-
-### 手动模式
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
+# 手动模式
+pto.tassign %arg0, @tile(0x1000)
+pto.tassign %arg1, @tile(0x2000)
%dst = pto.trowmax %src, %tmp : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-```
-
-### PTO 汇编形式
-```text
+# PTO 汇编形式
%dst = trowmax %src : !pto.tile<...> -> !pto.tile<...>
# AS Level 2 (DPS)
pto.trowmax ins(%src, %tmp : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
+
+## 相关页面
+
+- 指令集总览:[归约与扩展](./tile/reduce-and-expand_zh.md)
diff --git a/docs/isa/TROWMIN_zh.md b/docs/isa/TROWMIN_zh.md
index eb06e854..32d3248f 100644
--- a/docs/isa/TROWMIN_zh.md
+++ b/docs/isa/TROWMIN_zh.md
@@ -1,39 +1,34 @@
-# TROWMIN
+# pto.trowmin
-## 指令示意图
+`pto.trowmin` 属于[归约与扩展](./tile/reduce-and-expand_zh.md)指令集。
-
-
-## 简介
+## 概述
通过取列间最小值来归约每一行。
-## 数学语义
+## 机制
设 `R = src.GetValidRow()`,`C = src.GetValidCol()`。对 `0 <= i < R`:
$$ \mathrm{dst}_{i,0} = \min_{0 \le j < C} \mathrm{src}_{i,j} $$
-## 汇编语法
+迭代域由 `src` 的 valid region 决定。C++ 内建接口需要显式传入 `tmp` 操作数。若 `src.GetValidRow() == 0` 或 `src.GetValidCol() == 0`,实现会直接返回。
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+## 语法
-同步形式:
+### PTO-AS
-```text
-%dst = trowmin %src : !pto.tile<...> -> !pto.tile<...>
-```
-降低时可能引入内部临时 Tile;C++ 内建接口需要显式传入 `tmp` 操作数。
+参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.trowmin %src, %tmp : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.trowmin ins(%src, %tmp : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
@@ -46,36 +41,48 @@ template ` | 每行的最小元素值 |
+
+## 副作用
+
+除产生目标 tile 外,没有额外架构副作用。
+
+## 约束
- `dst` 和 `src` 必须均为 `TileType::Vec`。
- `src` 必须使用标准 ND 布局:行主且非分形(`BLayout::RowMajor`、`SLayout::NoneBox`)。
-- `dst` 必须使用以下两种非分形布局之一:
- - ND 布局(`BLayout::RowMajor`、`SLayout::NoneBox`),或
- - 列数严格为 1 的 DN 布局(`BLayout::ColMajor`、`SLayout::NoneBox`、`Cols == 1`)。
+- `dst` 必须使用以下两种非分形布局之一:ND 布局(`BLayout::RowMajor`、`SLayout::NoneBox`),或列数严格为 1 的 DN 布局(`BLayout::ColMajor`、`SLayout::NoneBox`、`Cols == 1`)。
- `dst` 和 `src` 的元素类型必须一致。
-- 运行时有效区域检查:
- - `src.GetValidRow() != 0`
- - `src.GetValidCol() != 0`
- - `src.GetValidRow() == dst.GetValidRow()`
-- 内建接口签名要求显式传入 `tmp` 操作数。
+- 运行时有效区域检查:`src.GetValidRow() != 0`、`src.GetValidCol() != 0`、`src.GetValidRow() == dst.GetValidRow()`。
+
+## 异常与非法情形
-### A2A3 实现检查
+- 非法操作数组合、不支持的数据类型、不合法布局或不支持的 target-profile 模式,会被 verifier 或后端实现拒绝。
-- 支持的元素类型:`half`、`float`、`int32_t`、`int16_t`。
-- 实现同时接受 ND 输出和 `Cols == 1` 的 DN 输出。
-- 运行时检查遵循共享的行归约检查路径:
- - `src.GetValidRow() != 0`
- - `src.GetValidCol() != 0`
- - `src.GetValidRow() == dst.GetValidRow()`
-- 当前实现路径会将 `tmp` 传入后端调用,但本文档不额外补充 checked implementation 未显式约束的 `tmp` shape/layout 要求。
+## Target-Profile 限制
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| `float` | Simulated | Supported | — |
+| `half` | Simulated | Supported | — |
+| `int16_t` / `int32_t` | — | Supported | — |
## 示例
-### 自动(Auto)
+### C++ 自动模式
```cpp
#include
@@ -93,7 +100,7 @@ void example_auto() {
}
```
-### 手动(Manual)
+### C++ 手动模式
```cpp
#include
@@ -114,29 +121,23 @@ void example_manual() {
}
```
-## 汇编示例(ASM)
-
-### 自动模式
+### PTO-AS
```text
-# 自动模式:由编译器/运行时负责资源放置与调度。
+# 自动模式
%dst = pto.trowmin %src, %tmp : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-```
-
-### 手动模式
-```text
-# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
+# 手动模式
+pto.tassign %arg0, @tile(0x1000)
+pto.tassign %arg1, @tile(0x2000)
%dst = pto.trowmin %src, %tmp : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-```
-
-### PTO 汇编形式
-```text
+# PTO 汇编形式
%dst = trowmin %src : !pto.tile<...> -> !pto.tile<...>
# AS Level 2 (DPS)
pto.trowmin ins(%src, %tmp : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
+
+## 相关页面
+
+- 指令集总览:[归约与扩展](./tile/reduce-and-expand_zh.md)
diff --git a/docs/isa/TROWPROD_zh.md b/docs/isa/TROWPROD_zh.md
index b29c8d67..f7e5b3e7 100644
--- a/docs/isa/TROWPROD_zh.md
+++ b/docs/isa/TROWPROD_zh.md
@@ -1,43 +1,39 @@
-# TROWPROD
+# pto.trowprod
-## 指令示意图
+`pto.trowprod` 属于[行归约](./tile/ops/reduce-and-expand/trowprod_zh.md)指令集。
-
+## 概述
-## 简介
+对每行元素进行乘积归约。将源 tile 每行的所有元素相乘,结果写入目标 tile 对应行的第一个位置。
-对每行元素进行乘积归约。
-
-## 数学定义
+## 机制
设 `R = src.GetValidRow()` 且 `C = src.GetValidCol()`。对于 `0 <= i < R`:
$$ \mathrm{dst}_{i,0} = \prod_{j=0}^{C-1} \mathrm{src}_{i,j} $$
-## 汇编语法
-
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+## 语法
-同步形式:
+### PTO-AS
```text
%dst = trowprod %src : !pto.tile<...> -> !pto.tile<...>
```
降级可能引入内部临时 tile;C++ 内建函数需要显式的 `tmp` 操作数。
-### AS Level 1 (SSA)
+### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.trowprod %src, %tmp : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
-### AS Level 2 (DPS)
+### AS Level 2(DPS)
-```text
+```mlir
pto.trowprod ins(%src, %tmp : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
-## C++ 内建函数
+## C++ 内建接口
声明于 `include/pto/common/pto_instr.hpp`:
@@ -46,41 +42,49 @@ template
@@ -98,7 +102,7 @@ void example_auto() {
}
```
-### Manual 模式
+### C++ 手动模式
```cpp
#include
@@ -119,29 +123,13 @@ void example_manual() {
}
```
-## ASM 形式示例
-
-### Auto 模式
+### PTO-AS
```text
-# Auto 模式:编译器/运行时管理的放置和调度。
+# 自动模式
%dst = pto.trowprod %src, %tmp : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
-### Manual 模式
+## 相关页面
-```text
-# Manual 模式:在发出指令前显式绑定资源。
-# Tile 操作数可选:
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
-%dst = pto.trowprod %src, %tmp : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-```
-
-### PTO 汇编形式
-
-```text
-%dst = trowprod %src : !pto.tile<...> -> !pto.tile<...>
-# AS Level 2 (DPS)
-pto.trowprod ins(%src, %tmp : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
-```
+- 指令集总览:[行归约](./tile/ops/reduce-and-expand/trowprod_zh.md)
diff --git a/docs/isa/TROWSUM_zh.md b/docs/isa/TROWSUM_zh.md
index d3b3c1df..2e39b4de 100644
--- a/docs/isa/TROWSUM_zh.md
+++ b/docs/isa/TROWSUM_zh.md
@@ -1,54 +1,68 @@
-# TROWSUM
+# pto.trowsum
-## 指令示意图
+`pto.trowsum` 属于[归约指令](./tile/reduce-and-expand_zh.md)集。
-
-
-## 简介
+## 概述
通过对列求和来归约每一行。
-## 数学语义
+## 机制
设 `R = src.GetValidRow()`,`C = src.GetValidCol()`。对 `0 <= i < R`:
$$ \mathrm{dst}_{i,0} = \sum_{j=0}^{C-1} \mathrm{src}_{i,j} $$
-## 汇编语法
+## 语法
+
+### PTO-AS
-PTO-AS 形式:参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
+参见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
同步形式:
```text
%dst = trowsum %src : !pto.tile<...> -> !pto.tile<...>
```
+
降低时可能引入内部临时 Tile;C++ 内建接口需要显式传入 `tmp` 操作数。
### AS Level 1(SSA)
-```text
+```mlir
%dst = pto.trowsum %src, %tmp : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
### AS Level 2(DPS)
-```text
+```mlir
pto.trowsum ins(%src, %tmp : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
```
## C++ 内建接口
-声明于 `include/pto/common/pto_instr.hpp`:
-
```cpp
template
PTO_INST RecordEvent TROWSUM(TileDataOut &dst, TileDataIn &src, TileDataTmp &tmp, WaitEvents &... events);
```
-## 约束
+## 输入
-### 通用约束或检查
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| `src` | 源 Tile | 输入 Tile |
+| `tmp` | 临时 Tile | 用于内部计算的临时 Tile |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| `dst` | Tile | 按行归约求和后的目标 Tile |
+
+## 副作用
+
+无。
+
+## 约束
- `dst` 和 `src` 必须均为 `TileType::Vec`。
- `src` 必须使用标准 ND 布局:行主且非分形(`BLayout::RowMajor`、`SLayout::NoneBox`)。
@@ -62,20 +76,20 @@ PTO_INST RecordEvent TROWSUM(TileDataOut &dst, TileDataIn &src, TileDataTmp &tmp
- `src.GetValidRow() == dst.GetValidRow()`
- 内建接口签名要求显式传入 `tmp` 操作数。
-### A2A3 实现检查
+## 异常与非法情形
-- 支持的元素类型:`half`、`float`、`int32_t`、`int16_t`。
-- 实现同时接受 ND 输出和 `Cols == 1` 的 DN 输出,并非仅支持 DN 输出。
-- 运行时检查遵循共享的行归约检查路径:
- - `src.GetValidRow() != 0`
- - `src.GetValidCol() != 0`
- - `src.GetValidRow() == dst.GetValidRow()`
-- 当前实现路径会将 `tmp` 传入后端调用,但本文档不额外补充 checked implementation 未显式约束的 `tmp` shape/layout 要求。
+- 未定义。
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| 支持的元素类型 | - | `half`、`float`、`int32_t`、`int16_t` | - |
+| 输出布局 | - | ND 或 `Cols==1` DN | - |
## 示例
-### 自动(Auto)
+### C++ 自动模式
```cpp
#include
@@ -93,7 +107,7 @@ void example_auto() {
}
```
-### 手动(Manual)
+### C++ 手动模式
```cpp
#include
@@ -114,29 +128,19 @@ void example_manual() {
}
```
-## 汇编示例(ASM)
-
-### 自动模式
+### PTO-AS
```text
# 自动模式:由编译器/运行时负责资源放置与调度。
%dst = pto.trowsum %src, %tmp : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
-```
-### 手动模式
-
-```text
# 手动模式:先显式绑定资源,再发射指令。
-# 可选(当该指令包含 tile 操作数时):
-# pto.tassign %arg0, @tile(0x1000)
-# pto.tassign %arg1, @tile(0x2000)
+# pto.tassign %src, @tile(0x1000)
+# pto.tassign %dst, @tile(0x2000)
+# pto.tassign %tmp, @tile(0x3000)
%dst = pto.trowsum %src, %tmp : (!pto.tile<...>, !pto.tile<...>) -> !pto.tile<...>
```
-### PTO 汇编形式
+## 相关页面
-```text
-%dst = trowsum %src : !pto.tile<...> -> !pto.tile<...>
-# AS Level 2 (DPS)
-pto.trowsum ins(%src, %tmp : !pto.tile_buf<...>, !pto.tile_buf<...>) outs(%dst : !pto.tile_buf<...>)
-```
+- 指令集总览:[归约指令](./tile/reduce-and-expand_zh.md)
diff --git a/docs/isa/TSETTF32MODE_zh.md b/docs/isa/TSETTF32MODE_zh.md
index b1c75bf9..64ecb77c 100644
--- a/docs/isa/TSETTF32MODE_zh.md
+++ b/docs/isa/TSETTF32MODE_zh.md
@@ -1,22 +1,18 @@
-# TSETTF32MODE
+# pto.tsettf32mode
-## 指令示意图
+`pto.tsettf32mode` 属于[同步与配置](./tile/sync-and-config_zh.md)指令集。
-
+## 概述
-## 简介
+`TSETTF32MODE` 设置 TF32 相关的变换模式。它本身不做张量算术,而是更新后续相关计算会读取的模式状态。该指令属于同步与配置路径,更接近"模式寄存器写入",而不是普通 tile 运算。它的效果取决于目标实现如何解释 TF32 模式配置。
-`TSETTF32MODE` 设置 TF32 相关的变换模式。它本身不做张量算术,而是更新后续相关计算会读取的模式状态。
+## 机制
-## 语义
+该指令写入 TF32 模式寄存器,设置是否启用 TF32 以及具体的变换模式。后续的矩阵运算指令会读取此状态来决定是否使用 TF32 计算路径。
-该指令属于同步与配置路径,更接近“模式寄存器写入”,而不是普通 tile 运算。它的效果取决于目标实现如何解释 TF32 模式配置。
+## 语法
-## 汇编语法
-
-PTO-AS 形式见 [PTO-AS 规范](../assembly/PTO-AS_zh.md)。
-
-示意形式:
+### PTO-AS
```text
tsettf32mode {enable = true, mode = ...}
@@ -24,13 +20,13 @@ tsettf32mode {enable = true, mode = ...}
### AS Level 1(SSA)
-```text
+```mlir
pto.tsettf32mode {enable = true, mode = ...}
```
### AS Level 2(DPS)
-```text
+```mlir
pto.tsettf32mode ins({enable = true, mode = ...}) outs()
```
@@ -43,14 +39,42 @@ template
using namespace pto;
@@ -60,7 +84,13 @@ void example_enable_tf32() {
}
```
+### PTO-AS
+
+```text
+pto.tsettf32mode {enable = true, mode = ...}
+```
+
## 相关页面
-- [同步与配置指令集](./tile/sync-and-config_zh.md)
-- [TSETHF32MODE](./TSETHF32MODE_zh.md)
+- 指令集总览:[同步与配置](./tile/sync-and-config_zh.md)
+- 相关指令:[TSETHF32MODE](./tsethf32mode_zh.md)
diff --git a/docs/isa/TSET_IMG2COL_PADDING_zh.md b/docs/isa/TSET_IMG2COL_PADDING_zh.md
index bf70ce99..7e1a8c75 100644
--- a/docs/isa/TSET_IMG2COL_PADDING_zh.md
+++ b/docs/isa/TSET_IMG2COL_PADDING_zh.md
@@ -1,22 +1,18 @@
-# TSET_IMG2COL_PADDING
+# pto.tset_img2col_padding
-## 指令示意图
+`pto.tset_img2col_padding` 属于[同步与配置](./tile/sync-and-config_zh.md)指令集。
-
+## 概述
-## 简介
+从 IMG2COL 配置 Tile 设置 IMG2COL 填充元数据。该指令本身不产生直接的张量算术结果,而是更新供后续数据搬运操作消费的 IMG2COL padding 控制状态。
-从 IMG2COL 配置 Tile 设置 IMG2COL 填充元数据。
+## 机制
-## 数学语义
+该指令将配置 Tile 中的填充参数写入硬件状态寄存器,后续的 IMG2COL 操作会读取这些参数来确定填充行为。
-该指令本身不产生直接的张量算术结果,而是更新供后续数据搬运操作消费的 IMG2COL padding 控制状态。
+## 语法
-## 汇编语法
-
-PTO-AS 形式:参见 [PTO-AS Specification](../assembly/PTO-AS_zh.md).
-
-示意形式:
+### PTO-AS
```text
tset_img2col_padding %cfg
@@ -24,13 +20,13 @@ tset_img2col_padding %cfg
### AS Level 1(SSA)
-```text
+```mlir
pto.tset_img2col_padding %cfg : !pto.fmatrix_config -> ()
```
### AS Level 2(DPS)
-```text
+```mlir
pto.tset_img2col_padding ins(%cfg : !pto.fmatrix_config) outs()
```
@@ -48,15 +44,44 @@ PTO_INST RecordEvent TSET_IMG2COL_PADDING(ConvTileData &src, WaitEvents &... eve
For `MEMORY_BASE` targets, an overload without `SetFmatrixMode` is also provided.
+## 输入
+
+| 操作数 | 角色 | 说明 |
+| --- | --- | --- |
+| src | 输入 | IMG2COL 配置 Tile |
+| events | 可选 | 等待事件 |
+
+## 预期输出
+
+| 结果 | 类型 | 说明 |
+| --- | --- | --- |
+| 事件 | RecordEvent | 同步事件 |
+
+## 副作用
+
+该指令更新 IMG2COL padding 控制状态,影响后续 TIMG2COL 操作的行为。
+
## 约束
-- This instruction is backend-specific and available only for backends that expose IMG2COL configuration state.
-- `src` must be a valid IMG2COL configuration tile type accepted by the backend implementation.
-- The exact padding fields updated by this instruction are implementation-defined.
-- Use this instruction before dependent `TIMG2COL` operations in the same execution stream.
+- 该指令是后端特定的,仅适用于暴露 IMG2COL 配置状态的硬件平台
+- src 必须是后端实现可接受的 IMG2COL 配置 tile 类型
+- 该指令更新的确切填充字段由实现定义
+- 在同一执行流中,应在依赖的 TIMG2COL 操作之前使用此指令
+
+## 异常与非法情形
+
+- 未指定
+
+## Target-Profile 限制
+
+| 特性 | CPU Simulator | A2/A3 | A5 |
+| --- | :---: | :---: | :---: |
+| IMG2COL Padding 配置 | - | 支持 | 支持 |
## 示例
+### C++ 自动模式
+
```cpp
#include
@@ -66,3 +91,14 @@ void example_set_img2col_padding(Img2colTileConfig