Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

English | 中文版

11. 把安全卫士延伸到 ingested linalg 内核

摘要:第 10 章把安全卫士跑在 .acl.pto 文件上——由本仓库自己的 mlir_to_pto 后端产出的 PTO-MLIR。本章把同一个卫士延伸到 ascend-rs 管线之外 进来的内核:第三方前端(例如 torch-mlir)产出的上游 linalg dialect MLIR。本章给出两条路径。Path A 是一段约 300 行的 projector,直接从 ascend_tile MLIR 合成一个 stage-2 Plan,在上面跑第 10 章六遍 check 中的一个子集;Path C 则把每一个 ingested 内核都通过真实的 mlir_to_pto → ptoas --print-after-all → parse_stage2 链路,把六遍 check 完整跑在 PlanMemoryPass 之后的 plan 上。两条路径都通过同一个环境变量 ACLRS_LINALG_SAFETY 接入 ingress 驱动,并且都能在 adablue 上纯主机运行(使用 x86 版 ptoas,无需 NPU)。两条路径互为补充:Path A 快、能抓整块 tile 级别的问题;Path C 精度更高,在 blocked matmul 场景下尤其关键,因为在那里 Path A 会对容量做保守的 over-approximation。


11.1 / 11.2 详见英文版

本章的完整内容目前只维护了英文版:

简要概括:上游 linalg MLIR(torch-mlir 等前端产出)经 linalg → ascend_tile → mlir_to_pto → ptoas → parse_stage2 → check_all 走完整条路径,在 adablue 上用 ~/ptoas-x86/bin/ptoas 即可纯主机运行,无需 910c。matmul_row_overflow 这个对抗性示例演示了:Path A 会把 blocked matmul 的容量 over-approximate 成 8 MiB 误报;而 Path C 读取的是 PlanMemoryPass 之后的真实 plan,因此给出 clean 结论。驱动入口 ACLRS_LINALG_SAFETY=path-a|path-c、报错模式 ACLRS_LINALG_SAFETY_ABORT=1、以及 ptoas 路径覆写 ACLRS_PTOAS_BIN 的细节见英文版。