Pull Request已成功合入, 合并人@CANN-robot
(感谢 gaoxin 的贡献)变更摘要
本 PR 是一次重构,目标是消除 compare_v2_api_call.cpp 与 cast_v2_api_call.cpp 中重复的 ASCIR 节点参数获取/创建逻辑。核心做法是在 ascir_node_param 模块中新增统一的 GetOrCreateAscirNodeParams 接口,将「先通过扩展属性获取参数、不存在则创建并写回扩展属性」这一公共流程收敛到一处,随后让 Compare 与 Cast 的参数填充函数复用该 helper,并清理两个调用文件中不再使用的 <memory> 头文件与局部常量,降低后续维护成本。
主要改动
- 新增
GetOrCreateAscirNodeParams函数:在ascir_node_param.cpp中实现并通过ascir_node_param.h声明,统一处理AscirNodeParams的获取、创建与SetExtAttr写回逻辑。 - 复用 helper 重构
FillCastNodeParams:在cast_v2_api_call.cpp中将原先手动获取/创建参数的代码替换为调用ascir_param::GetOrCreateAscirNodeParams,并删除局部常量kAscirNodeParams与<memory>头文件。 - 复用 helper 重构
FillCompareNodeParams:在compare_v2_api_call.cpp中同样将原先重复的获取/创建逻辑替换为ascir_param::GetOrCreateAscirNodeParams,并删除局部常量kAscirNodeParams与<memory>头文件。 - 保留各自的 specific_params 处理:
FillCastNodeParams与FillCompareNodeParams仍分别通过std::get_if处理CastNodeParams与CompareNodeParams,未改变各自的参数类型处理逻辑。


代码审查
Closing Summary
审查完毕,4 个变更文件均已逐一核对:
autofuse/common/ascir_node_param/ascir_node_param.cpp— 1 个问题(P2):GetOrCreateAscirNodeParams失败路径返回空shared_ptr,而调用方未判空。autofuse/common/ascir_node_param/ascir_node_param.h— no issues(仅新增一处声明)。autofuse/v35/codegen/reg_api_call/cast_v2_api_call.cpp— 该文件是上述 P2 问题的空指针解引用调用点(cast_v2_api_call.cpp:38),本身无独立问题;<memory>include 与局部kAscirNodeParams删除经核对已无残留引用。autofuse/v35/codegen/reg_api_call/compare_v2_api_call.cpp— 同为上述 P2 问题的空指针解引用调用点(compare_v2_api_call.cpp:39),本身无独立问题;include 与局部常量删除安全。
发现统计:P2 × 1,P0/P1/P3 × 0。
整体风险评估:低-中。正常路径(op_desc 有效且 SetExtAttr 成功)行为与重构前等价;唯一回归在于防御性错误分支由"受控返回错误码"退化为"空指针解引用",属于错误处理契约的削弱,建议按上述方式补充判空或改为显式错误码传递。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 0 |
| 🟡 建议 | 1 |
💬 仅评论


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 | ✅ 张德鹏, zhang_shengjie, xchu42 (3/2) | ✅ 张德鹏 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
gcw_V3YyYBt1, thanks for your pull request. All authors of the commits have signed the CLA. 👍


流水线任务触发成功
任务链接 [ee83fa157cef4f279cef7db8a2517554][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| UT_Test_Python_superkernel | ✅ SUCCESS | >>>>> | |
| ST_Test_Python_superkernel | ✅ SUCCESS | >>>>> | |
| UT_Test_superkernel | ✅ SUCCESS | >>>>> | |
| UT_Test_autofuse_framework | ✅ SUCCESS | >>>>> | |
| ST_Test_autofuse_framework | ✅ SUCCESS | >>>>> | |
| UT_Test_autofuse_ascendc_api | ✅ SUCCESS | >>>>> | |
| ST_Test_autofuse_ascendc_api | ✅ SUCCESS | >>>>> | |
| ST_Test_autofuse_e2e | ✅ SUCCESS | >>>>> | |
| pre_comment | ✅ SUCCESS | >>>>> | |
| UT_Test_Report | ✅ SUCCESS | >>>>> | |
| ST_Test_Report | ❌ FAILED | >>>>> |


🟡 Medium Priority


流水线任务触发成功
任务链接 [b7c70167ed2342299e978f645f335624][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| UT_Test_Python_superkernel | ✅ SUCCESS | >>>>> | |
| ST_Test_Python_superkernel | ✅ SUCCESS | >>>>> | |
| UT_Test_superkernel | ✅ SUCCESS | >>>>> | |
| UT_Test_autofuse_framework | ✅ SUCCESS | >>>>> | |
| ST_Test_autofuse_framework | ✅ SUCCESS | >>>>> | |
| UT_Test_autofuse_ascendc_api | ✅ SUCCESS | >>>>> | |
| ST_Test_autofuse_ascendc_api | ✅ SUCCESS | >>>>> | |
| ST_Test_autofuse_e2e | ✅ SUCCESS | >>>>> | |
| pre_comment | ✅ SUCCESS | >>>>> | |
| UT_Test_Report | ✅ SUCCESS | >>>>> | |
| ST_Test_Report | ✅ SUCCESS | >>>>> |
[2026-08-17 19:44:15] CI执行结束


/lgtm


/lgtm


/lgtm


描述
消除 compare_v2_api_call.cpp 与 cast_v2_api_call.cpp 中重复的 ASCIR 节点参数创建代码。
背景
两处代码均负责获取或创建 AscirNodeParams,重复实现被代码质量检查识别为重复代码,增加了后续维护成本。
修改方案
变更类型
关联的Issue
无。
如何测试
核对清单
其他信息