已合并
feat: 9个迁移算子适配unknown shape/rank InferShape并补UT及入口日志 #4811
xuejinghui创建于 24 天前
feat: 9个迁移算子适配unknown shape/rank InferShape并补UT及入口日志 #4811
已合并
xuejinghui创建于 24 天前
xuejinghui成员
24 天前

描述

9个迁移算子适配unknown shape/rank InferShape并补UT及入口日志

关联的Issue

https://gitcode.com/cann/ops-math/issues/2909

测试

文档更新

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 xuejinghui 的贡献)
Xxuejinghui成员
24 天前 创建了 pull request,commit ba6c5094
atomgit-bot
atomgit-bot
24 天前 评论:

变更摘要

本 PR 主要为 9 个迁移算子的 InferShape 逻辑适配 unknown shape(维度为 -1)和 unknown rank(秩为 -2)场景,并补充对应单测及 tiling/InferShape 入口日志。核心做法是在推理前通过 Ops::Base::IsUnknownRank / Ops::Base::IsUnknownShape 识别动态 shape/rank,无法推导时将输出设置为 unknown rank 或 unknown dim(部分算子如 SparseReshapeTrace 采用固定 rank 或标量透传策略),从而在 canndev 日落迁移背景下保证动态 shape 场景下不因缺少维度信息而推理失败。

主要改动

  • InferShape 适配 unknown rank(-2MatrixDiagPartCosineSimilarityProdForceSeAProdVirialSeASparseBincountStrideAdd 等算子在输入为 unknown rank 时,通过 Ops::Base::SetUnknownRank 将输出透传为 unknown rank 并提前返回成功。
  • InferShape 适配 unknown shape(-1SparseReshape 在输入含 unknown rank 时将 y_indicesy_shape 固定为 {-1, -1}{-1}ProdVirialSeAnatoms 为 unknown rank/shape 时将 atom_virialshape[1] 置为 -1
  • 动态维度下跳过不可推导的校验StrideAdd 仅在 C1 维度 >= 0 时执行 c1_offset + c1_len 越界校验;Trace 在 unknown rank 时跳过 2D 维度数校验并保持标量输出。
  • 补充 tiling 与 InferShape 入口日志:为 MatrixDiagPartSparseReshapeTriluCosineSimilarityProdForceSeAProdVirialSeASparseBincountStrideAddTrace 等算子的 tiling 函数及部分 InferShape 函数添加 OP_LOGD 入口日志。
  • 补充 unknown shape/rank 单测:各算子测试文件中新增 unknown_shapeunknown_rank 用例,覆盖输入含 -1/-2 时的输出 shape 期望,包括标量输出、固定 rank 输出和 unknown rank 透传等场景。
likedislike
不准确?
atomgit-bot
atomgit-bot
24 天前 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robotCANN-robot成员
24 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
24 天前 评论:

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 /approve or /lgtm
  • Commenting /approve implies 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. 👍

likedislike
此处折叠了81条消息 查看更多
CANN-robotCANN-robot成员
10 天前 添加了label:approved
songkai111成员
10 天前 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
10 天前 添加了label:lgtm
CANN-robotCANN-robot成员
10 天前 关闭了关联的issue
CANN-robotCANN-robot成员
10 天前 合入了pull request