已合并
feat: skip None (nullptr) tensors in ACLNN output auto-fill #21
lichunxiang8创建于 6月22日
feat: skip None (nullptr) tensors in ACLNN output auto-fill #21
已合并
lichunxiang8创建于 6月22日
lichunxiang8
6月22日

描述

ACLNN 接口的 Optional 类型参数(如 OptionalRef、OutOptional、OutputOptional)在传入 None(nullptr)时,框架会错
误地抛出 RuntimeError 或将其加入输出/索引列表,导致测试失败,新增支持 ACLNN 中 Optional 参数合法为 nullptr 的场景,避免误报错误

关联的Issue

测试

DS_TRAIN_0_aclnnApplyAdamWV2

文档更新

类型标签

  • Bug修复
  • 新特性
  • 性能优化
  • 文档更新
  • 其他,请描述:
likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 lichunxiang8 的贡献)
CANN-robotCANN-robot成员
6月22日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
6月22日 评论:

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


PR Approval Progress

Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-cann/ops-test-kit dengguojie, wangmingli (2/2) dengguojie (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
lichunxiang8
6月22日 评论:

/compile

likedislike
atomgit-bot
atomgit-bot
6月22日 评论:

我已仔细审查了 ttk/core_modules/testcase_manager/testcase_aclnn.py 中的变更。以下是我的总结:

变更摘要

此 PR 修复了 ACLNN 接口中 Optional 类型参数(如 OptionalRef、OutOptional、OutputOptional)传入 None(nullptr)时框架的错误处理行为。主要包含两处改动:在 _auto_fill_output_inplace_indices 方法中,将原先对 None 值 inplace 参数抛出 RuntimeError 的行为改为记录 info 日志并跳过;在 _auto_fill_output_tensor_indexes 方法中,新增对 tensor_view_shapes[idx] is None 的检查,使 nullptr 的输出参数不再被错误地加入输出索引列表。

主要改动

  • _auto_fill_output_inplace_indices 中跳过 None 的 inplace 参数: 原先当 Ref 后缀参数的 tensor_view_shapes 元素为 None 时会抛出 RuntimeError,现改为 logging.info 记录并 continue 跳过,支持合法的 OptionalRef/nullptr 场景。
  • _auto_fill_output_tensor_indexes 中跳过 None 的输出参数: 在遍历 tensor_names 时新增前置检查 self.tensor_view_shapes[idx] is None(带 idx < len(...) 边界保护),使 None 的输出参数(如 OutOptional、OutputOptional)不再被添加到 output_indices 中。

审查结论: 对该文件的变更未发现实质性问题(如拼写错误、异常处理缺陷、安全隐患或性能问题),两处改动逻辑正确、边界安全。

likedislike
CANN-robotCANN-robot成员
6月22日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
6月22日 评论:

流水线任务触发成功
任务链接 [020bc591d4de4dadb150c9779d7f2b21][流水线指导]

任务名称状态日志下载链接
SCA ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
Check_Pr ✅ SUCCESS >>>>>
codecheck_style ✅ SUCCESS >>>>>
pre-commit ✅ SUCCESS
pre_comment ✅ SUCCESS >>>>>
UT_Test ✅ SUCCESS >>>>>

[2026-06-22 22:40:28]    CI执行结束

likedislike
atomgit-bot
atomgit-bot
6月22日 评论:

代码审查

审查总结

ttk/core_modules/testcase_manager/testcase_aclnn.py 的变更进行了全面审查,涉及以下两个修改点:

  1. _auto_fill_output_inplace_indices 方法(第 913-914 行):将 RuntimeError 抛异常改为 logging.info + continue,使得 None(nullptr)的 inplace 参数被跳过而非报错。

  2. _auto_fill_output_tensor_indexes 方法(第 944-946 行):新增对 None tensor shape 的检查,在输出索引自动填充时跳过 nullptr 参数。

审查结果

优先级 数量
P0 0
P1 0
P2 0
P3 1
  • 两处变更逻辑正确、一致,与 PR 描述的目标(支持 ACLNN Optional 参数合法为 nullptr 的场景,避免误报错误)完全吻合。
  • 未发现正确性、安全性、可靠性或性能方面的回归问题。
  • P3:现有单元测试未覆盖 None shape 的跳过路径,建议补充相关用例以防止未来回归。

整体风险判断:低风险。变更范围小、逻辑清晰,仅将原本的硬错误改为合法的跳过行为,且两处变更保持一致。

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

💬 仅评论

likedislike
atomgit-bot
atomgit-bot6月22日进行代码检视2
ttk/core_modules/testcase_manager/testcase_aclnn.py
已过期
@@ -943,1 +943,4 @@
943943 for idx, name in enumerate(tensor_names):
944+ if idx < len(self.tensor_view_shapes) and self.tensor_view_shapes[idx] is None:
945+ logging.info(f"Output parameter [{name}] is None (nullptr), skipping.")
946+ continue
atomgit-bot
atomgit-bot6月22日评论:

🔵 Low Priority

本次变更在 _auto_fill_output_inplace_indices_auto_fill_output_tensor_indexes 两个方法中新增了对 None(nullptr)tensor 的跳过逻辑。然而,现有单元测试(tests/test_testcase_aclnn.py 中的 TestAutoFillOutputTensorIndexes 类)以及整个测试文件中,所有测试用例的 tensor_view_shapes 均为非 None 值(默认 tuple((2, 3) for _ in tensor_names)),没有用例覆盖 None shape 的跳过路径。

具体回归风险:如果后续有人重构代码时意外移除或改错 None 跳过检查,将导致 Optional 类型参数传入 nullptr 时被错误加入输出/索引列表,这正是本 PR 要修复的问题,但现有测试无法捕获该回归。

建议:建议在 TestAutoFillOutputTensorIndexes 测试类中增加以下场景:

改动建议
946
- continue
946
+ 1. 构造 `tensor_view_shapes` 包含 `None` 的用例,验证 `_auto_fill_output_tensor_indexes` 正确跳过 None 参数。
应用建议
  1. 构造 tensor_view_shapesRef 后缀参数为 None 的用例,验证 _auto_fill_output_inplace_indices 正确跳过而非抛 RuntimeError。
  2. 验证 None 参数被跳过后,剩余非 None 输出参数仍被正确收集。
likedislike
System
系统消息系统
6月23日 评论:
likedislike
CANN-robotCANN-robot成员
6月22日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
6月22日 添加了label:ci-pipeline-passed
Llichunxiang8
6月23日 推送  1 个提交:8b38ed79-feat: skip None (nullptr) tensors in ACLNN inplace auto-fill
CANN-robotCANN-robot成员
6月23日 添加了label:stat/needs-squash
CANN-robotCANN-robot成员
6月23日 删除了label:ci-pipeline-passed
CANN-robot
CANN-robot成员
6月23日 评论:

Notification

This pull request has been changed(code update) or closed, so removes the following label(s): ci-pipeline-passed.

likedislike
lichunxiang8
6月23日 评论:

/compile

likedislike
CANN-robotCANN-robot成员
6月23日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
6月23日 评论:

流水线任务触发成功
任务链接 [8953a6f10ed54da0a5d5a660a169ee47][流水线指导]

任务名称状态日志下载链接
SCA ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
Check_Pr ✅ SUCCESS >>>>>
codecheck_style ✅ SUCCESS >>>>>
pre-commit ✅ SUCCESS
pre_comment ✅ SUCCESS >>>>>
UT_Test ✅ SUCCESS >>>>>

[2026-06-23 22:09:20]    CI执行结束

likedislike
CANN-robotCANN-robot成员
6月23日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
6月23日 添加了label:ci-pipeline-passed
Llichunxiang8
6月25日 强制推送  2 个提交:71aefb53-1 commit from branch master7af8831a-fix: skip None (nullptr) tensors in ACLNN inplace auto-fill
CANN-robotCANN-robot成员
6月25日 删除了label:ci-pipeline-passedstat/needs-squash
CANN-robotCANN-robot成员
6月25日 添加了label:ci-pipeline-passedstat/needs-squash
CANN-robot
CANN-robot成员
6月25日 评论:

Notification

This pull request has been changed(code update) or closed, so removes the following label(s): ci-pipeline-passed, stat/needs-squash.

likedislike
dengguojie成员
6月26日 评论:

/lgtm

likedislike
dengguojie成员
6月26日 评论:

/approve

likedislike
CANN-robotCANN-robot成员
6月26日 添加了label:approved
Ddengguojie成员
6月26日 将dengguojie设为审查人
Ddengguojie成员
6月26日 将dengguojie设为评审人
Ddengguojie成员
6月26日 通过审查
Ddengguojie成员
6月26日 通过了评审
wangmingli
wangmingli
6月26日 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
6月26日 添加了label:lgtm
CANN-robotCANN-robot成员
6月26日 解决了最后一个问题
CANN-robotCANN-robot成员
6月26日 合入了pull request