Pull Request has been successfully merged by CANN-robot.
(Thank you for yuwang-'s contribution.)变更摘要
本 PR 为图融合能力补充英文文档,新增 PermuteFusionPass、GlobalavgpoolFusionPass、ReduceMeanWithCastFusionPass 三份融合规则说明,覆盖融合模式、约束条件与适用产品等章节,用于说明相关算子在图编译阶段被替换或分解为等价算子的行为。
主要改动
PermuteFusionPass融合文档: 说明Permute按平台替换为TransposeD(A3、910b、910、310p、310b)或Transpose(950,perm以Const节点输入),置换顺序优先读perm属性、缺失时读order,并要求 GE 编译器版本不低于 9.1.0。GlobalavgpoolFusionPass融合文档: 说明GlobalAveragePool被替换为沿空间维度求均值的ReduceMean,替换后设置keep_dims=true与noop_with_empty_axes=true,且输入x仅支持 3D/4D/5D。ReduceMeanWithCastFusionPass融合文档: 说明ReduceMeanWithCast分解为Cast+ReduceMean,dtype非DT_UNDEFINED时插入Cast并以其作为dst_type,为DT_UNDEFINED时直接替换为ReduceMean。- 属性继承与默认值约定: 记录
keep_dims、noop_with_empty_axes、dtype等属性的默认值与继承关系,并明确输入形状与数据类型沿用底层算子约束。 - 平台相关标注: 通过
npu条件标注区分不同产品型号的支持范围,并引用docs/en/figures下的融合前后结构示意图。
🧩 本次 Review 已使用自定义 Skill:


Hi @yuwang-, welcome to submitting your first PR to CANN!
PR Merge Steps
1. CLA Signing
If the current PR label includes cann-cla/yes, it means you have signed the CLA and can proceed to the next step. If the label includes cann-cla/no, please sign the CLA first. If you have any questions, please refer to the FAQ.
2. CI Check
Please comment /compile to trigger the CI pipeline check. If the CI run is successful, the PR will be tagged with ci-pipeline-passed and you can proceed to the next step. If the CI run fails, the PR will be tagged with ci-pipeline-failed, please check the CI logs to fix the issues in the PR. If you have any questions, please refer to the FAQ.
3. Code Review
After CI passes, please refer to the PR Approval Progress and proactively @ the committers in the table to review the code. After approval, committers will comment /lgtm and /approve. Once the lgtm and approved labels are successfully added, the PR will be merged automatically.


代码审查
检视结论
逐文件确认
conversion/transpose/docs/PermuteFusionPass_en.md:no issues(平台标签、用例与约束、版本约束、图路径均自洽;无危险命令/不安全配置/密钥泄露)。math/reduce_mean/docs/GlobalavgpoolFusionPass_en.md:2 个问题(归约维度描述、标题与 pass 名不一致)。math/reduce_mean/docs/ReduceMeanWithCastFusionPass_en.md:1 个问题(Castdst_type描述未区分DT_UNDEFINED分支)。
问题统计:P0 × 0,P1 × 0,P2 × 1,P3 × 2。
整体风险判断:低。本次为纯文档新增(3 个英文页、无代码/配置/依赖变更),不涉及安全或运行时行为;主要风险是文档与实际 pass 语义描述不一致导致读者误用(P2 的 GlobalAveragePool 归约维度一项需对照实现核实),其余为可检索性与描述准确性层面的轻量问题。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 0 |
| 🟡 建议 | 1 |
💬 仅评论
🧩 本次 Review 已使用自定义 Skill:


Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| conversion/transpose | ✅ 顾宝成, 陈兴宇 (2/2) | ✅ 顾宝成 (1/1) |
| math/reduce_mean | ✅ 顾宝成, 陈兴宇 (2/2) | ✅ 顾宝成 (1/1) |
| repo-cann/ops-math | ✅ 顾宝成, 陈兴宇 (2/2) | ✅ 顾宝成 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


🟡 Medium Priority
变更行:math/reduce_mean/docs/GlobalavgpoolFusionPass_en.md:7 新增「computes the mean along the spatial dimensions (all dimensions from the second one onward)」。
问题链路:GlobalAveragePool 的语义是沿空间维度(NCHW 下的 H、W)求均值,输出仍保留 batch(N) 与 channel(C) 维,即归约轴为 {2,…,n-1};而该句把归约范围写成「从第 2 维起的所有维度」= {1,…,n-1},等于把 channel 维也一起平均掉,描述出的计算与 GlobalAveragePool 标准语义(输出 N×C×1×1)不一致。
失败模式:读者按此文档理解融合后 ReduceMean 的 axes,会认为 C 维被压平;若下游按此理解做 shape 推导、对齐适配层或编写校验用例,就会出现 shape/数值预期错误(例如期望输出为 N×1×1 而实际为 N×C×1×1)。触发条件:任何 4D NCHW 输入阅读该文档并据此推导输出形状。由于本环境无法读取 pass 实现核对实际 axes,置信度已下调,但即便是实现侧真的传 axes={1..n-1},该实现同样与 GlobalAveragePool 语义不符,仍需修正。
建议:核对 pass 实际传入的 axes 后修正该句:GlobalAveragePool 只沿空间维(NCHW 的 H、W,即从第三维起)求均值并保留 batch/channel 维;建议直接写出 axes 取值,避免「from the second one onward」这种会吞掉 channel 维的表述。


/lgtm
/approve
by agent


您好,PR已满足合入指标,请尽快联系Committer进行合入。如暂时不需要合入,请在PR标题前加[WIP]


/lgtm


/lgtm


The following users do not have permission to comment /lgtm or /approve on any module in this PR:
/lgtm: lwx1255555


The MR can not be merged, because of CodeReview discussion not resolved
If you want to solve this problem, you can click here to do it in the FAQs.


描述
图融合引用文档:
PermuteFusionPass_en.md
GlobalavgpoolFusionPass_en.md
ReduceMeanWithCastFusionPass_en.md
关联的Issue
https://gitcode.com/cann/ops-math/issues/4095
测试
文档更新
类型标签