Pull Request has been successfully merged by CANN-robot.
(Thank you for weike's contribution.)变更摘要
本 PR 修复 matrix_inverse 算子中 aclnnInverse 接口对输出 dtype 校验过于宽松的问题。原实现仅通过 OP_CHECK_RESULT_DTYPE_CAST_FAILED 校验 self 是否可转换为 out 的 dtype,导致 FP32 的 self 搭配 FP16/BF16/DOUBLE 的 out 会被静默接受并以降精度方式执行,与接口资料中“out 的 dtype 需与 self 一致”的要求不符。本次将该校验替换为严格的同 dtype 检查,并补充对应的异常场景单元测试。
主要改动
- dtype 校验规则收紧:在
index/matrix_inverse/op_host/op_api/aclnn_inverse.cpp的CheckDtypeValid中,将 cast 可行性检查OP_CHECK_RESULT_DTYPE_CAST_FAILED(self->GetDataType(), out->GetDataType(), return false)替换为OP_CHECK_DTYPE_NOT_SAME(self, out, return false),要求out与self的 dtype 完全一致,否则返回参数错误。 - 合法路径保持不变:支持列表检查
OP_CHECK_DTYPE_NOT_SUPPORT与 shape 等其余校验未作调整,同 dtype 的 FLOAT、FLOAT16、DOUBLE 等路径行为不受影响。 - 新增回归用例:在
index/matrix_inverse/tests/ut/op_host/test_aclnn_inverse.cpp中新增abnormal_self_out_dtype_not_same测试,遍历ACL_FLOAT16、ACL_BF16、ACL_DOUBLE三种out类型搭配 FP32self,断言均返回ACLNN_ERR_PARAM_INVALID。 - 文件格式补充:
aclnn_inverse.cpp末尾补充了缺失的换行符,仅格式层面调整。
🧩 本次 Review 已使用自定义 Skill:




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.
You can self-configure the PR merge rules for this repository. For more details, please refer to 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 |
|---|---|---|
| */*/docs/acl*.md | ✅ 陈兴宇, 杨露 (2/2) | ✅ 杨露 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
m0_55003149, thanks for your pull request. All authors of the commits have signed the CLA. 👍


compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


/lgtm
/approve


您好,pr合入已准备就绪,请尽快联系committer进行检视,谢谢!
@yangyang016 @su-yueming @wang-xing001 @fanqirui @gitee-duhuiping @fengying555682 @caiwenwen @yanglu-1 @lwx1255555


/lgtm
/approve


The following users do not have permission to comment /lgtm or /approve on any module in this PR:
/approve: 陈兴宇


描述
aclnnInverse不要求out与self严格同 dtype;它要求out属于支持范围,并且可由self转换。修改中英文接口资料:
out的使用说明为:数据类型需要是self可转换的数据类型,shape 需要与self一致;BFLOAT16、COMPLEX64、COMPLEX128输出类型,并补充self的复数类型;self和out数据类型不同”改为“out的数据类型不是self可转换的”。关联的Issue
https://gitcode.com/cann/ops-nn/issues/7880
测试
文档更新
更新
index/matrix_inverse/docs/aclnnInverse.md和index/matrix_inverse/docs/aclnnInverse_en.md。类型标签
AI/Agent生成声明