Pull Request已成功合入, 合并人@CANN-robot
(感谢 xuejinghui 的贡献)变更摘要
本 PR 主要为 9 个迁移算子的 InferShape 逻辑适配 unknown shape(维度为 -1)和 unknown rank(秩为 -2)场景,并补充对应单测及 tiling/InferShape 入口日志。核心做法是在推理前通过 Ops::Base::IsUnknownRank / Ops::Base::IsUnknownShape 识别动态 shape/rank,无法推导时将输出设置为 unknown rank 或 unknown dim(部分算子如 SparseReshape、Trace 采用固定 rank 或标量透传策略),从而在 canndev 日落迁移背景下保证动态 shape 场景下不因缺少维度信息而推理失败。
主要改动
InferShape适配 unknown rank(-2):MatrixDiagPart、CosineSimilarity、ProdForceSeA、ProdVirialSeA、SparseBincount、StrideAdd等算子在输入为 unknown rank 时,通过Ops::Base::SetUnknownRank将输出透传为 unknown rank 并提前返回成功。InferShape适配 unknown shape(-1):SparseReshape在输入含 unknown rank 时将y_indices、y_shape固定为{-1, -1}和{-1};ProdVirialSeA在natoms为 unknown rank/shape 时将atom_virial的shape[1]置为-1。- 动态维度下跳过不可推导的校验:
StrideAdd仅在 C1 维度>= 0时执行c1_offset + c1_len越界校验;Trace在 unknown rank 时跳过 2D 维度数校验并保持标量输出。 - 补充 tiling 与
InferShape入口日志:为MatrixDiagPart、SparseReshape、Trilu、CosineSimilarity、ProdForceSeA、ProdVirialSeA、SparseBincount、StrideAdd、Trace等算子的 tiling 函数及部分InferShape函数添加OP_LOGD入口日志。 - 补充 unknown shape/rank 单测:各算子测试文件中新增
unknown_shape与unknown_rank用例,覆盖输入含-1/-2时的输出 shape 期望,包括标量输出、固定 rank 输出和 unknown rank 透传等场景。


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 |
|---|---|---|
| experimental | ✅ 王瑞, 宋恺 (2/2) | ✅ 王瑞 (1/1) |
| repo-cann/ops-math | ✅ 王瑞, 宋恺 (2/2) | ✅ 王瑞 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
xuejinghui, thanks for your pull request. All authors of the commits have signed the CLA. 👍


/lgtm


描述
9个迁移算子适配unknown shape/rank InferShape并补UT及入口日志
关联的Issue
https://gitcode.com/cann/ops-math/issues/2909
测试
文档更新
类型标签