Merged
fix(index): validate empty self and handle empty indices #12074
fazhenyao123Add on 27 days ago
fix(index): validate empty self and handle empty indices #12074
Merged
Pull Request has been successfully merged by CANN-robot.
(Thank you for fazhenyao123's contribution.)27 days ago Created pull request, commit c56bc7ac
27 days ago Associated issue: [Bug-Report|缺陷反馈]: aclnnIndex 空 self × 非空 out 时早退不填输出,返回成功但输出为未初始化内存
27 days ago Associated issue: [Bug-Report|缺陷反馈]: aclnnIndex 空 self × 非空 out 时早退不填输出,返回成功但输出为未初始化内存
atomgit-bot
27 days ago Comments:
27 days ago Comments:
变更摘要
本次变更修复了 aclnnIndex 在 self 为空、out 非空时直接返回成功却不写输出的问题。核心改动是在 CheckParams 中新增非法组合校验,拒绝该组合并返回 ACLNN_ERR_PARAM_INVALID;同时将 aclnnIndexGetWorkspaceSize 的空张量早退条件由 self 或 out 任一为空收窄为仅 out 为空,并配套更新了单元测试与接口文档的错误码说明。
主要改动
- 参数检查拒绝非法组合: 在
CheckParams中新增判断,当self->IsEmpty()且!out->IsEmpty()时记录错误日志并返回ACLNN_ERR_PARAM_INVALID。 - 收窄空张量早退条件: 将
aclnnIndexGetWorkspaceSize中的早退判断从self->IsEmpty() || out->IsEmpty()改为仅out->IsEmpty(),此路径仍设置*workspaceSize = 0并直接返回ACLNN_SUCCESS。 - 更新回归用例期望: 将
l2_test_self_empty_fp32的期望结果由ACLNN_SUCCESS改为ACLNN_ERR_PARAM_INVALID,以反映self为空的非法组合被拒绝。 - 新增空张量用例: 新增
l2_test_self_and_out_empty_fp32,验证self与out同时为空时返回ACLNN_SUCCESS且workspaceSize为 0。 - 更新接口文档: 同步更新
index/index/docs/aclnnIndex.md中的错误码说明(该文件未嵌入补丁,仅据 PR 描述归纳)。
🧩 本次 Review 已使用自定义 Skill:


Incorrect?
atomgit-bot
27 days ago Comments:
27 days ago Comments:


Incorrect?
27 days ago Added label: cann-cla/yes
44 messages are collapsed here。 See more
23 days ago Added label: approved
CANN-robot
23 days ago Comments:
23 days ago Comments:
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.


23 days ago Resolved final issue
23 days ago Merged pull request
CANN-robot
23 days ago Comments:
23 days ago Comments:
Pull Request 已合并或已关闭。
If you want to solve this problem, you can click here to do it in the FAQs.


描述
修复 aclnnIndex 的两类空输入问题:self 为空且 out 非空时成功返回但不写输出,以及 indices 全为空占位时访问空 allDefinedIndices 导致越界。
关联的Issue
https://gitcode.com/cann/ops-nn/issues/6304
测试
文档更新
已更新 index/index/docs/aclnnIndex.md。
类型标签
AI/Agent生成声明