已合并
SparseReshape输入和输出shape相同时直接输入到输出 #4607
kevin_huang1234创建于 1 天前
SparseReshape输入和输出shape相同时直接输入到输出 #4607
已合并
kevin_huang1234创建于 1 天前
kevin_huang1234成员
1 天前
  1. 实现内容:
    SparseReshape输入和输出shape相同时直接输入到输出

  2. 测试
    已完成OBP冒烟
    已完成DAVID冒烟
    ST测试完成

  3. 关联ISSUE
    https://gitcode.com/cann/ops-math/issues/2618

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

变更摘要

该 PR 针对 SparseReshape 算子进行了性能优化:当输入与输出的 shape 相同时(即 isIdentityReshape 场景),跳过原有的 flat index 计算和 UintDiv 分解流程,改为直接逐元素拷贝索引。变更集中在 conversion/sparse_reshape/op_kernel/arch35/sparse_reshape_simt.h,新增了一个恒等拷贝的 VF kernel,并在 PrepareAndLaunchVF 中根据 td->isIdentityReshape 分支提前返回,避免分配中间 UB 缓冲和计算 stride/divisor。

主要改动

  • 新增恒等拷贝 kernel OpSparseReshapeIdentitySimtKernel: 该模板 kernel 采用 Grid-Stride 遍历非零元素,按 rank 逐列直接执行 yIndices[i * rank + j] = indices[i * rank + j],不做 flat index 计算与 UintDiv 分解。
  • PrepareAndLaunchVF 增加恒等分支提前返回: 函数开头先构造 indicesGmyIndicesGm,当 td->isIdentityReshape 为真时通过 asc_vf_call 直接调用恒等 kernel 并 return,跳过 UB 分配、stride/divisor 填充及数据同步。
  • 调整 GM 指针声明位置: 将 indicesGmyIndicesGm 的声明从非恒等路径中上移到 PrepareAndLaunchVF 开头,使其可同时服务于恒等与非恒等两条路径。
  • 更新 Process 相关注释: 明确说明 VF kernel 通过 Grid-Stride 分区同时处理恒等与非恒等路径,避免多核竞争,其中 isIdentityReshape==1 直接拷贝索引,isIdentityReshape==0 走 flat index 加 UintDiv 分解。
likedislike
atomgit-bot
atomgit-bot
1 天前 评论:

代码审查

✅ 未发现问题

likedislike
CANN-robotCANN-robot成员
1 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
1 天前 评论:

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
repo-cann/ops-math xuejinghui, wangrui_ (2/2) xuejinghui, wangrui_ (2/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)
likedislike
CANN-robot
CANN-robot成员
1 天前 评论:

CLA Signature Pass

kevin_huang1234, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robotCANN-robot成员
1 天前 将yue-ma,zhou-qilong,wangrui_,rxtfeng,loov1,zhangzijie,jia0liang,zl_hw,songkai111,chenxingyu18,pingchuantang,llimwang,gubaocheng,andong_hw,xuejinghui,zhanw_coding设为评审人
CANN-robotCANN-robot成员
1 天前 将yue-ma,zhou-qilong,wangrui_,rxtfeng,loov1,zhangzijie,jia0liang,zl_hw,songkai111,chenxingyu18,pingchuantang,llimwang,gubaocheng,andong_hw,xuejinghui,zhanw_coding设为审查人
kevin_huang1234成员
1 天前 评论:

compile

likedislike
Kkevin_huang1234成员
1 天前 update merge request[project id: 7649531, iid: 4607, commit_id: 68fa15738cc4c8dc35bcf3800db47b9aa0823776] virtual merging success
CANN-robotCANN-robot成员
1 天前 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
1 天前 评论:

流水线任务触发成功
任务链接 [4098ff848617478bb8842c0900331c18][流水线指导]

任务名称状态日志下载链接
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 >>>>>

[2026-08-13 11:38:39]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
1 天前 评论:

流水线任务触发成功
任务链接 [8940a77a0ee7419dba6bec760e69d52a][流水线指导]

任务名称状态日志下载链接
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-08-13 11:27:49]    CI执行结束

likedislike
CANN-robotCANN-robot成员
1 天前 添加了label:api-check-pass
CANN-robotCANN-robot成员
1 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
1 天前 添加了label:ci-pipeline-passed
kevin_huang1234成员
1 天前 评论:

compile

likedislike
Kkevin_huang1234成员
1 天前 update merge request[project id: 7649531, iid: 4607, commit_id: 18671ae92a674aaff4c0b0d54439165836ce25ed] virtual merging success
CANN-robotCANN-robot成员
1 天前 删除了label:ci-pipeline-passedapi-check-pass
CANN-robotCANN-robot成员
1 天前 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
1 天前 评论:

流水线任务触发成功
任务链接 [c0196da0a90f4ccc9efaceb3e1e96c5f][流水线指导]

任务名称状态日志下载链接
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 >>>>>

[2026-08-13 15:29:41]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
1 天前 评论:

流水线任务触发成功
任务链接 [46f42703e7684e5ab74eebb6703ab69b][流水线指导]

任务名称状态日志下载链接
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-08-13 15:17:11]    CI执行结束

likedislike
CANN-robotCANN-robot成员
1 天前 添加了label:api-check-pass
此处折叠了6条事件消息 查看更多
Kkevin_huang1234成员
8 小时前 修改了pull request 的描述
xuejinghui成员
8 小时前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
8 小时前 添加了label:approved
RuiWang_成员
8 小时前 评论:

/lgtm
/approve

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