Merged
fix: 清理 Math 独立实现路径的未使用 workspace #6711
fix: 清理 Math 独立实现路径的未使用 workspace #6711
Merged
zhang-song-ruiAdd on 12 days ago
zhang-song-rui
zhang-song-ruiCollaborators
12 days ago

修改内容

清理 Lerp、Muls、Pow、Select SIMT、TanhGrad 独立实现路径中未使用的 workspace 申请。没有额外用户 workspace 的路径将申请量设为 0;kernel 入口允许零 workspace 下继续执行计算。保留内部 kernel 的 workspace 参数及原调用形式。

算子/路径 修改位置 修改内容及影响
Lerp math/lerp/op_host/arch35/lerp_tiling_arch35.cpp WORKSPACE_SIZE 从 32 改为 0,保留常量及原赋值方式;不改变 tiling key 和计算分支。
Muls math/muls/op_host/arch35/muls_tiling_arch35.cpp 将申报的 workspace 从固定系统预留量改为 0,计算和 tiling 策略保持原样。
Pow math/pow/op_host/arch35/pow_tiling_arch35.cpp GetWorkspaceSize 中将申请量设为 0,移除仅为查询系统 workspace 大小使用的平台信息获取和 include。
Pow math/pow/op_kernel/pow_apt.cpp 移除 workspace 为空时直接返回的判断,以及无用的系统 workspace 设置、用户 workspace 地址转换,使零 workspace 时仍执行原计算分支。内部 Init 接口及 workspace 参数保持原样。
Select SIMT math/select/op_host/arch35/select_simt_tiling.cpp WORKSPACE_SIZE 从 32 改为 0,保留常量和赋值形式;只修改 SIMT 路径。
TanhGrad math/tanh_grad/op_host/arch35/tanh_grad_tiling_arch35.cpp WORKSPACE_SIZE 从 32 改为 0,保留常量和赋值形式,不调整原计算流程。

同时原样包含 Lerp、Muls、Pow、TanhGrad 对应的 4 个算子 Host UT 文件修改,将 workspace 期望值更新为 0。本 PR 共 10 个文件。

与 BRC PR 的边界

本 PR 为原 PR #6242 的独立实现部分;公共 BroadcastBaseTiling(BRC)模板相关的 29 个算子 UT 文件留在 #6242。

Select 的现有 UT 命中 BRC 路径,原期望为 16 MiB,其断言修改留在 #6242;本 PR 的 Select 修改仅为 SIMT 独立实现。Lerp、Pow、TanhGrad 中使用底层 BroadcastTiling 的实现按其自行申报 workspace 的实际修改归入本 PR。

两个 PR 使用相同基线,各一次提交,改动文件互不重叠;两份补丁合并后的 Git tree 与拆分前提交 6875c10f04af0cc8f012cba867892a1f660702d5 完全一致。拆分未改变任何代码内容、排版或换行格式。

验证

拆分前整体联调版本在 CANN 9.2.0、已接入 Broadcast workspace 补丁的依赖环境下,完成 Host UT 对象编译、静态归档重建、最终链接及运行,333/333 通过,39 个改动文件 pre-commit 通过。

该结果属于拆分前整体版本,不替代本 PR 拆分后的线上 CI。Pow arch35 原有用例整段处于注释中,其 workspace 断言未实际执行。

关联

公共 BRC 算子 UT 更新:PR #6242。本 PR 不修改 CMake、公共 UT 框架或远程依赖版本。

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for zhang-song-rui's contribution.)
zhang-song-ruizhang-song-ruiCollaborators
12 days ago Created pull request, commit 3ee8d977
atomgit-bot
atomgit-bot
12 days ago Comments:

变更摘要

本 PR 从原 #6242 中拆出「算子独立实现路径」的 workspace 清理,涉及 Lerp、Muls、Pow、Select SIMT、TanhGrad 五个算子。核心是将各 tiling 侧申请的 workspace 大小从系统库 API 默认值(32 或 16777216)统一置为 0,并同步移除 Pow kernel 入口中针对零 workspace 的判空返回、SetSysWorkspace/GetUserWorkspace 调用以及不再需要的 platform_ascendc.h 依赖,配套更新相关算子 UT 的 workspace 期望值。

主要改动

  • Tiling 侧 workspace 申请量归零: Lerp、TanhGrad、Select SIMT 将 WORKSPACE_SIZE 常量由 32 改为 0,Muls 的 SetTilingData 与 Pow 的 GetWorkspaceSize 则直接将 workspaces[0] 赋为 0,不再调用 GetLibApiWorkSpaceSize()。
  • Pow kernel 入口简化: pow_apt.cpp 的 pow kernel 删除 workspace == nullptr 判空返回、SetSysWorkspace 与 GetUserWorkspace 转换逻辑,保留 KERNEL_TASK_TYPE_DEFAULT、TPipe 及原有 tiling key 分支调用形式。
  • Pow tiling 依赖清理: pow_tiling_arch35.cpp 移除 #include "platform/platform_ascendc.h" 及 GetPlatformInfo/OP_CHECK_NULL_WITH_CONTEXT 相关代码,仅保留 workspace 指针获取与失败校验。
  • UT 期望值同步调整: test_lerp_tiling_arch35.cpp、test_muls_tiling_arch35.cpp、test_pow_tiling_arch35.cpp、test_tanh_grad_tiling_arch35.cpp 中的 expectWorkspaces 由 {32} 或 {16777216} 改为 {0};其中 Pow 对应用例的 ExecuteTestCaseForEle 调用仍处于注释状态,未实际执行该断言。
  • 拆分边界说明: Select 公共 BroadcastBaseTiling 路径的 16 MiB→0 断言不在本 PR 内,保留在 #6242,本 PR 仅覆盖 Select SIMT 独立路径。

🧩 本次 Review 已使用自定义 Skill:

likedislike
Incorrect?
atomgit-bot
atomgit-bot
12 days ago Comments:

代码审查

✅ 未发现问题


🧩 本次 Review 已使用自定义 Skill:

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
12 days ago Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
12 days ago 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.
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
math/lerp ✅ 顾宝成, 王林木 (2/2) ✅ 顾宝成 (1/1)
math/muls ✅ 顾宝成, 王林木 (2/2) ✅ 顾宝成 (1/1)
math/pow ✅ 顾宝成, 王林木 (2/2) ✅ 顾宝成 (1/1)
math/select ✅ 王林木, 顾宝成 (2/2) ✅ 顾宝成 (1/1)
math/tanh_grad ✅ 顾宝成, 王林木 (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

zhang-song-rui, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robotCANN-robotCollaborators
12 days ago Set FelixTang7,yue-ma,zhou-qilong,wangrui_,rxtfeng,loov1,zhangzijie,jia0liang,zl_hw,songkai111,chenxingyu18,pingchuantang,llimwang,gubaocheng,andong_hw,xuejinghui,onanfield,zhanw_coding,clinglai0517 as approver
CANN-robotCANN-robotCollaborators
12 days ago Set FelixTang7,yue-ma,zhou-qilong,wangrui_,rxtfeng,loov1,zhangzijie,zl_hw,songkai111,chenxingyu18,pingchuantang,llimwang,gubaocheng,andong_hw,xuejinghui,onanfield,zhanw_coding,clinglai0517 as approver
zhang-song-rui
zhang-song-ruiCollaborators
12 days ago Comments:

/compile

likedislike
zhang-song-ruizhang-song-ruiCollaborators
12 days ago Pre merge succeeded (commit_id: 79b945e0ed31315e695986f66815fd2d94015516)
CANN-robot
CANN-robotCollaborators
12 days ago Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
12 days ago Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
12 days ago Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
12 days ago Added label: ci-pipeline-passed
gubaochengCollaborators
12 days ago Comments:

/lgtm
/approve
by agent

likedislike
CANN-robotCANN-robotCollaborators
12 days ago Added label: approved
zhang-song-ruizhang-song-ruiCollaborators
12 days ago Modify description of pull request
llimwangCollaborators
11 days ago Comments:

/lgtm

likedislike
CANN-robotCANN-robotCollaborators
11 days ago Added label: lgtm
CANN-robotCANN-robotCollaborators
11 days ago Merged pull request