Pull Request已成功合入, 合并人@CANN-robot
(感谢 wangqi_ai 的贡献)变更摘要
本次 PR 为 select 算子新增了 op_api 级别的单元测试文件,覆盖 aclnnSWhere 接口在多种数据类型、不同维度以及异常场景下的 GetWorkspaceSize 行为验证。测试以 l2_s_where_test 测试套件组织,主要验证输入/输出为空指针时的错误状态码、常见数据类型(float32/float16/int32/int64)的正常路径、以及维度超过 8 时的参数校验拒绝行为。
主要改动
- 新增
test_aclnn_s_where.cpp测试文件: 在math/select/tests/ut/op_api/目录下新增 178 行测试代码,定义l2_s_where_test测试类,包含 10 个测试用例。 - 空指针异常场景测试(4 个用例): 分别测试
condition、self、other、out四个输入/输出参数为nullptr的情况,验证TestGetWorkspaceSize返回值不等于ACLNN_ERR_INNER_NULLPTR(说明框架有提前拦截处理)。 - 多数据类型正常路径测试(4 个用例): 覆盖
ACL_FLOAT、ACL_FLOAT16、ACL_INT32、ACL_INT64四种数据类型,验证GetWorkspaceSize返回ACL_SUCCESS,预测精度校验(TestPrecision)当前被注释未启用。 - 不同维度场景测试(2 个用例): 覆盖 3 维正常输入(shape
{2,3,4})和空 Tensor(shape{4,0})场景;同时测试超 8 维输入(10 维 shape),验证返回ACLNN_ERR_PARAM_INVALID参数校验错误。


代码审查
经过全面审查,该测试文件整体质量良好,未发现需要报告的实际缺陷。
逐测试用例分析:
-
nullptr 测试(第26-75行):分别测试 condition/self/other/out 为空指针的场景,断言
EXPECT_NE(result, ACLNN_ERR_INNER_NULLPTR)与实现中CheckNotNull4Tensor返回ACLNN_ERR_PARAM_NULLPTR一致。CheckNotNull4Tensor按 t0=self, t1=other, t2=condition, t3=out 顺序检查,与各测试用例中传参位置完全匹配。 -
dtype 测试(第78-135行):覆盖 float32/float16/int32/int64 四种数据类型,condition 统一使用
ACL_BOOL,符合算子规范。TestPrecision()被注释掉是合理的——这些是 infershape 级别测试。 -
3维输入测试(第138-150行):shape
{2,3,4}在MAX_DIM=8范围内,预期ACL_SUCCESS。 -
空tensor测试(第152-164行):shape
{4,0},算子实现中CheckParams通过后IsEmpty()分支返回ACL_SUCCESS,测试断言正确。 -
超维度测试(第167-178行):10维输入,
OP_CHECK_MAX_DIM(MAX_DIM=8)应返回ACLNN_ERR_PARAM_INVALID,断言正确。
验证项:
- 头文件依赖路径正确(
../../../op_api/aclnn_s_where.h指向math/select/op_api/aclnn_s_where.h) uint64_t workspaceSize类型与 API 签名一致- 所有
TensorDesc对象为栈分配,无资源泄漏 - nullptr 测试的
EXPECT_NE断言模式与项目中其他算子测试一致(如 reduce_sum、reduce_log_sum) - 无未初始化变量、越界访问、悬垂引用等问题
审查结论:
- 变更文件数:1
math/select/tests/ut/op_api/test_aclnn_s_where.cpp:经审查,未发现问题- 发现数:P0: 0, P1: 0, P2: 0, P3: 0
- 整体风险判定:低风险。该变更新增了 select 算子的 op_api infershape 级别单元测试,覆盖了正常路径、nullptr 异常、空tensor、超维度边界等场景,测试逻辑与算子实现一致,代码质量良好。
⚠️ 已识别出整体风险,但无法提取行内评论,请参考整体评估。


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


流水线任务触发成功
任务链接 [3b3273e04fdd4d21be67182f2708e813][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_experimental_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_harmony-infer | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_ARM_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_experimental_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910b | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910c | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_A5_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A5_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station_9030_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single | ✅ SUCCESS | >>>>> | >>>>> |
| UT_Test | ✅ SUCCESS | ||
| UT_Test_experimental | ✅ SUCCESS | ||
| UT_Test_kernel | ✅ SUCCESS | ||
| PreSmoke_A900 | ✅ SUCCESS | >>>>> | |
| API_Check | ✅ SUCCESS | >>>>> | |
| PreSmoke_ATK_Test_A2 | ✅ SUCCESS | >>>>> | |
| UT_Test_harmony-infer-chs-math | ✅ SUCCESS |
[2026-07-27 19:22:33] CI执行结束


流水线任务触发成功
任务链接 [56257f5e55364859bf17c1140a504ea2][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| SCA | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| codecheck_Pr | ✅ SUCCESS | ||
| StaticCheck_codespell | ✅ SUCCESS | ||
| StaticCheck_link_validity | ✅ SUCCESS | ||
| StaticCheck_resource_existence | ✅ SUCCESS | ||
| StaticCheck_tag_closed | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS | ||
| codecheck_precommit | ✅ SUCCESS | >>>>> |
[2026-07-27 19:13:39] CI执行结束


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.


描述
补充select算子的op_api和op_host infershape级别单元测试,覆盖以下场景:
关联的Issue
测试
文档更新
类型标签
关联 Issue: #2369