Pull Request已成功合入, 合并人@CANN-robot
(感谢 lichunxiang8 的贡献)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
/approveor/lgtm- Commenting
/approveimplies 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. 👍


/compile


我已仔细审查了 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中。
审查结论: 对该文件的变更未发现实质性问题(如拼写错误、异常处理缺陷、安全隐患或性能问题),两处改动逻辑正确、边界安全。


代码审查
审查总结
对 ttk/core_modules/testcase_manager/testcase_aclnn.py 的变更进行了全面审查,涉及以下两个修改点:
-
_auto_fill_output_inplace_indices方法(第 913-914 行):将RuntimeError抛异常改为logging.info+continue,使得None(nullptr)的 inplace 参数被跳过而非报错。 -
_auto_fill_output_tensor_indexes方法(第 944-946 行):新增对Nonetensor shape 的检查,在输出索引自动填充时跳过 nullptr 参数。
审查结果:
| 优先级 | 数量 |
|---|---|
| P0 | 0 |
| P1 | 0 |
| P2 | 0 |
| P3 | 1 |
- 两处变更逻辑正确、一致,与 PR 描述的目标(支持 ACLNN Optional 参数合法为 nullptr 的场景,避免误报错误)完全吻合。
- 未发现正确性、安全性、可靠性或性能方面的回归问题。
- P3:现有单元测试未覆盖
Noneshape 的跳过路径,建议补充相关用例以防止未来回归。
整体风险判断:低风险。变更范围小、逻辑清晰,仅将原本的硬错误改为合法的跳过行为,且两处变更保持一致。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 0 |
| 🟡 建议 | 1 |
💬 仅评论


🔵 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
| - |
|
946 | + 1. 构造 `tensor_view_shapes` 包含 `None` 的用例,验证 `_auto_fill_output_tensor_indexes` 正确跳过 None 参数。 |
- 构造
tensor_view_shapes中Ref后缀参数为None的用例,验证_auto_fill_output_inplace_indices正确跳过而非抛 RuntimeError。 - 验证 None 参数被跳过后,剩余非 None 输出参数仍被正确收集。


/compile


/lgtm


/approve


/lgtm


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