Merged
refactor(exp_segsum_grad): 将 arch22 tiling 与 host UT 隔离到 arch22 子目录 #4380
daiwei18Add on Aug 1
refactor(exp_segsum_grad): 将 arch22 tiling 与 host UT 隔离到 arch22 子目录 #4380
Merged
daiwei18Add on Aug 1
daiwei18
daiwei18Collaborators
Aug 1

描述

改动原因

ExpSegsumGrad 同时支持两代架构(op_host/exp_segsum_grad_def.cpp:39-50):

  • arch22:AddConfig("ascend910b")、AddConfig("ascend910_93")
  • arch35:AddConfig("ascend950", aicoreConfig)

改动前,arch35 的 tiling 已经放在 op_host/arch35/,而 arch22 的 tiling 仍散在 op_host/ 顶层。这导致 op_host/CMakeLists.txt 必须用「先让顶层文件被 glob 进来、再在 ascend950 分支里 list(REMOVE_ITEM) 把它剔除」的方式绕开冲突——两代实现靠"删除"而不是靠"目录"区分。op_kernel/ 侧已经是「顶层 arch22 + arch35/ 子目录」的布局,host 侧未对齐。

本 PR 把 arch22 的 host 侧文件收进独立的 arch22/ 子目录,使 host 侧的架构划分与 op_kernel/ 一致,也为后续切换到仓库通用的 add_all_modules_sources(... COMPUTE_UNIT ... TILING_DIR ...) 机制(cmake/func.cmake 中的 find_value_by_key + add_tiling_sources,math/abs/CMakeLists.txt 即此用法)做准备。

改动方法

变更 原路径 新路径
重命名(相似度 86%) op_host/exp_segsum_grad_tiling.cpp op_host/arch22/exp_segsum_grad_tiling.cpp
重命名(相似度 76%) op_host/exp_segsum_grad_tiling.h op_host/arch22/exp_segsum_grad_tiling.h
删除 + 新增 tests/ut/op_host/test_exp_segsum_grad_tiling.cpp tests/ut/op_host/arch22/test_exp_segsum_grad_tiling.cpp
修改 tests/ut/op_kernel/CMakeLists.txt tiling 源路径改为 ../../../op_host/arch22/exp_segsum_grad_tiling.cpp

随迁移一并做的非功能性整理(不改变任何计算逻辑):

  • License 头统一为仓库现行格式(Copyright 置顶,长行按 120 列折行),与 math/abs 等算子一致;
  • 按 clang-format 调整折行:AscendC::GetReduceSumMaxMinTmpSize(...)、tilingData.SaveToBuffer(...)、两处 OP_CHECK_IF(...) 的实参换行位置;
  • explicit ExpSegsumGradTiling(...) : tilingContext(context){}; → ... {};(大括号前补空格);
  • 补全文件末尾换行(原 .cpp / .h 均缺 newline at end of file);
  • exp_segsum_grad_tiling.h 的 } 补注为 } // namespace optiling;
  • 两个文件的 \brief 由空补为 arch22 / Ascend910B tiling implementation for ExpSegsumGrad. 与 ... tiling data for ExpSegsumGrad.;
  • UT 文件的 include 相对层级随目录下沉调整:../../../op_host/exp_segsum_grad_tiling.h → ../../../../op_host/arch22/exp_segsum_grad_tiling.h。

本 PR 未包含的内容

host 侧 tiling 的构建规则与 UT 收集规则尚未随目录调整,目前仍按旧路径匹配:

  • cmake/func.cmake 中 add_modules_sources 的 file(GLOB OPTILING_SRCS ${SOURCE_DIR}/*_tiling*.cpp) 为非递归匹配,该宏无 TILING_DIR 参数;
  • math/exp_segsum_grad/op_host/CMakeLists.txt 仅在 ASCEND_COMPUTE_UNIT STREQUAL "ascend950" 分支显式添加 arch35/ 源,其中的 list(REMOVE_ITEM ... "${CMAKE_CURRENT_SOURCE_DIR}/exp_segsum_grad_tiling.cpp") 指向的已是迁移前的旧路径;
  • cmake/ut.cmake 中 add_modules_ut_sources 的 glob 为 ${DIR}/test_*_tiling.cpp 与 ${DIR}/${TILING_DIR}/test_*_tiling*.cpp,而 tests/ut/op_host/CMakeLists.txt 的调用点未传 TILING_DIR。

这部分收敛方案见关联 Issue。

关联的Issue

关联Issue #2463

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

测试

  • UT 用例内容逐字未变:迁移后的 tests/ut/op_host/arch22/test_exp_segsum_grad_tiling.cpp 与原文件在测试语义上完全一致——输入/输出均为 {1, 1, 12, 12} 的 DT_FLOAT/FORMAT_ND,compileInfo = {1, 10},expectTilingKey = 1,expectTilingData 字符串逐字符相同(仅因行宽被拆成两段字面量拼接),expectWorkspaces = {33554432},断言 ge::GRAPH_SUCCESS。差异仅为 include 路径与 clang-format 折行。
  • kernel UT 链路已同步:tests/ut/op_kernel/CMakeLists.txt 中 exp_segsum_grad_tiling_files 已指向 op_host/arch22/exp_segsum_grad_tiling.cpp,该目标显式列出源文件路径,不依赖目录 glob。
  • 作者记录:ut 验证 ok。
  • 尚未覆盖:ascend910b / ascend910_93 的 host 侧构建与 tiling UT 收集,需待「本 PR 未包含的内容」一节所列的 CMake 规则调整后才能验证。

文档更新

本 PR 不涉及文档变更。math/exp_segsum_grad/README.md 与 docs/aclnnExpSegsumBackward.md 描述的是算子功能与 aclnn 接口,不含 host 侧源码目录结构,故无需同步修改。

类型标签

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for daiwei18's contribution.)
daiwei18daiwei18Collaborators
Aug 1 Created pull request, commit 7a4fe3fb
daiwei18daiwei18Collaborators
Aug 1 Pre merge succeeded (commit_id: 8a1288995aee188fadfc060c8aaffd44b9ace0db)
daiwei18daiwei18Collaborators
Aug 1 Pushed 29 commits:7a4fe3fb-28 commits from branch master,49cb6551-Merge branch '930-exp' of git@gitcode.com:daiwei18/ops-math.git into 'master'
daiwei18daiwei18Collaborators
Aug 1 Pre merge succeeded (commit_id: 52ba12df6ece6d25fd8b1ec39f0accb46867126f)
CANN-robotCANN-robotCollaborators
Aug 1 Added label: cann-cla/no
CANN-robotCANN-robotCollaborators
Aug 1 Added label: stat/needs-squash
CANN-robot
CANN-robotCollaborators
Aug 1 Comments:

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 ✅ wangrui_, 宋恺 (2/2) ✅ 宋恺, wangrui_ (2/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
Aug 1 Set zhou-qilong,wangrui_,rxtfeng,loov1,zhangzijie,jia0liang,zl_hw,songkai111,pingchuantang,llimwang,gubaocheng,andong_hw,xuejinghui,zhanw_coding as approver
CANN-robotCANN-robotCollaborators
Aug 1 Set zhou-qilong,wangrui_,rxtfeng,loov1,zhangzijie,jia0liang,zl_hw,songkai111,pingchuantang,llimwang,gubaocheng,andong_hw,xuejinghui,zhanw_coding as approver
daiwei18
daiwei18Collaborators
Aug 1 Comments:

compile

likedislike
daiwei18daiwei18Collaborators
Aug 1 Pre merge succeeded (commit_id: fe4eb5e2981f4f68f93a51620f0503477e1c58fd)
8 event messages are collapsed here。 See more
CANN-robotCANN-robotCollaborators
Aug 1 Added label: stat/needs-squash
CANN-robot
CANN-robotCollaborators
Aug 1 Comments:

Notification

This pull request has been changed(code update) or closed, so removes the following label(s): stat/needs-squash.

likedislike
CANN-robotCANN-robotCollaborators
Aug 1 Added label: ci-pipeline-running
CANN-robot
CANN-robotCollaborators
Aug 1 Comments:

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

任务名称状态日志下载链接
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 ⚠️ WARNING >>>>>
PreSmoke_ATK_Test_A2 ✅ SUCCESS >>>>>
UT_Test_harmony-infer-chs-math ✅ SUCCESS
UT_Test_harmony-infer-cpro-math ✅ SUCCESS

[2026-08-01 17:12:51]    CI执行结束

likedislike
daiwei18daiwei18Collaborators
Aug 1 Pre merge succeeded (commit_id: 0b92d8c715cfa6976c7a6c2170b5c63ed56d6d94)
daiwei18daiwei18Collaborators
Aug 1 Force-pushed 1 commits:0a4d2533-refactor(exp_segsum_grad): isolate arch22 host tiling
daiwei18daiwei18Collaborators
Aug 1 Pre merge succeeded (commit_id: 2e53b9ddcfd9ce8c56966b5d07f0bee478b04362)
CANN-robotCANN-robotCollaborators
Aug 1 Removed label: cann-cla/no
CANN-robotCANN-robotCollaborators
Aug 1 Removed label: stat/needs-squash
CANN-robot
CANN-robotCollaborators
Aug 1 Comments:

Notification

This pull request has been changed(code update) or closed, so removes the following label(s): stat/needs-squash.

likedislike
CANN-robotCANN-robotCollaborators
Aug 1 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Aug 1 Comments:

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

任务名称状态日志下载链接
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-01 16:58:43]    CI执行结束

likedislike
CANN-robotCANN-robotCollaborators
Aug 1 Added label: api-check-failed
CANN-robotCANN-robotCollaborators
Aug 1 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Aug 1 Added label: ci-pipeline-passed
songkai111Collaborators
Aug 1 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Aug 1 Added label: approved
RuiWang_Collaborators
Aug 1 Comments:

/lgtm
/approve

likedislike
CANN-robotCANN-robotCollaborators
Aug 1 Added label: lgtm
CANN-robotCANN-robotCollaborators
Aug 1 Closed associated issue
CANN-robotCANN-robotCollaborators
Aug 1 Merged pull request