已合并
fix: Concat split 中 Scalar 节点错误参与轴替换导致断言失败 #1750
fix: Concat split 中 Scalar 节点错误参与轴替换导致断言失败 #1750
已合并
wei_shi创建于 8月15日
wei_shi
wei_shi成员
8月15日

描述

修复 Concat split 场景下 Scalar 节点错误进入 ReplaceAxis 导致断言失败的问题。

根因:PowEquivSubstitutionPass 通过 CreateOneScalarBrc 动态创建的 Scalar 节点发生在 AscGraphInfoComplete::CompleteApiInfo() 之后,api.type 保持默认 kAPITypeInvalid(2),导致 CloneNonConcatNodes 中 IsBuffer() 返回 false,Scalar 错误进入 ReplaceAxis,在 tensor_attr.axis=[5] 中找不到 Concat 轴 0→6,触发断言。

修复:在 CreateOneScalarBrc 中显式设置 scalar_one.attr.api.type = kAPITypeBuffer,使 IsBuffer() 正确返回 true,Scalar 在 CloneNonConcatNodes 中被正确跳过,不进入 ReplaceAxis。

变更类型

关联的Issue

无

如何测试

  1. 编译 optimize_ut 测试目标通过(cmake --build build --target optimize_ut -j 8)
  2. 运行 PowScalarDtypeCheck 测试通过,新增 api.type == kAPITypeBuffer 断言验证修复生效
  3. 运行全部 7 个 Pow 相关测试(--gtest_filter='*Pow*')通过,无回归

核对清单

其他信息

变更文件:

  • autofuse/optimize/graph_pass/pass_utils.cpp:CreateOneScalarBrc 中设置 api.type = kAPITypeBuffer
  • autofuse/tests/v35/ut/optimize/test_optimizer_v2.cpp:PowScalarDtypeCheck 增加 api.type == kAPITypeBuffer 断言

根因分析详见内部报告 013-ConcatFusionCaseGenerator Scalar轴替换断言失败分析报告.md。

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 wei_shi 的贡献)
wei_shiwei_shi成员
8月15日 创建了 pull request,commit 2120b62f
atomgit-bot
atomgit-bot
8月15日 评论:

变更摘要

本 PR 主要针对 Concat split 场景下 Scalar 节点进入 ReplaceAxis 后轴属性断言失败的问题,在 autofuse/optimize/task_generator/concat_schedule_case_generator.cpp 中的 CloneNonConcatNodes、ReplaceAxis 和 UpdateOutputAttr 三处增加诊断日志,用于记录节点 API 类型、调度轴以及输出 TensorAttr 的 axis/repeats/strides 等信息。变更仅增加日志输出,不修改原有控制流和断言逻辑。

主要改动

  • CloneNonConcatNodes 增加拷贝后诊断日志: 在拷贝节点 TensorAttr 后新增 GELOGI 日志,记录源/目标节点的名称、类型、api.type、sched.axis 以及首个输出的 axis,便于追踪克隆节点的属性状态。
  • ReplaceAxis 增加入口与逐输出诊断日志: 在函数入口新增 GELOGI 日志记录节点信息、api_type、新旧轴 ID 及 sched.axis;并在遍历输出时逐条记录各输出的 axis/repeats/strides,用于定位轴替换前后的属性变化。
  • UpdateOutputAttr 增加入口与失败诊断日志: 在函数入口新增 GELOGI 日志记录待处理的 axis/repeats/strides;当 axis_index 未找到(等于 std::numeric_limits<size_t>::max())时新增 GELOGE 错误日志,输出调度轴、张量轴及 repeats/strides 等完整信息,且保留原有断言不变。
  • 函数签名格式微调: 对 ReplaceAxis 和 UpdateOutputAttr 的参数换行与缩进进行了对齐调整,不影响函数行为。
likedislike
不准确?
atomgit-bot
atomgit-bot
8月15日 评论:

代码审查

关闭总结

审查了唯一变更文件 autofuse/optimize/task_generator/concat_schedule_case_generator.cpp:

  • 三处 GELOGI 诊断日志(CloneNonConcatNodes 行 564、ReplaceAxis 行 604/615、UpdateOutputAttr 行 628)格式串与实参个数匹配,af::ToString(...).c_str() 临时对象生命周期覆盖整条调用表达式,%zu/%ld/%s 与实参类型一致,未发现问题。
  • 发现 1 个 P0 问题:行 643 的 GELOGE 调用缺少 ERROR_CODE 首参(宏签名为 GELOGE(ERROR_CODE, fmt, ...)),会导致该编译单元编译失败或格式串误用。

按优先级统计:P0 × 1,P1 × 0,P2 × 0,P3 × 0。

整体风险判断:本次变更仅新增诊断日志,除一处 GELOGE 宏调用参数错位(引入编译失败风险)外,其余改动风险较低;但该 P0 问题会直接阻断构建,需修复后才能合入。

类型 数量
🔴 阻塞 1
🟡 建议 0

⛔ 需要修改

likedislike
不准确?
CANN-robotCANN-robot成员
8月15日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
8月15日 评论:

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.
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
repo-cann/graph-autofusion ✅ 张德鹏, wangxiaotian995, xchu42 (3/2) ✅ 张德鹏 (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

wei_shi, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
此处折叠了62条消息 查看更多
wei_shiwei_shi成员
8月17日 修改了pull request 的描述
wei_shiwei_shi成员
8月17日 修改了pull request 的描述
张德鹏成员
8月17日 评论:

/approve

likedislike
CANN-robotCANN-robot成员
8月17日 添加了label:approved
CANN-robotCANN-robot成员
8月17日 合入了pull request