已合并
fix: AcosGrad、AsinGrad 共性问题及 tiling 函数整改 #5268
fix: AcosGrad、AsinGrad 共性问题及 tiling 函数整改 #5268
已合并
wangweidong创建于 26 天前
wangweidong
26 天前

描述

基于原 PR #4843 的实际 head,rebase 到最新 master 后重新提交。保留原 PR 对 AcosGrad、AsinGrad arch35 tiling/kernel 源码和 def 驱动 dtype 的修复,并整改 AcosGrad tiling 超长函数。

新增整改:

  • 将 CalcTilingParams 中的多核分块计算抽取为 CalcBlockParams
  • CalcBlockParams 为24行,CalcTilingParams 为46行,均不超过50行
  • 不修改 tiling 常量、计算公式、分支和TilingData字段

原 PR 主要改动:

  • 补齐 AcosGrad、AsinGrad arch35 tiling_key、tiling_data 和 kernel 实现
  • TilingKey仅编码BUFFER_MODE,dtype由def.cpp驱动
  • 修正ASCENDC_TPL_SEL_PARAM和相关UT预期

关联的Issue

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

测试

  • bash build.sh -u --ophost --ops=acos_grad --soc=ascend950 -j16:18/18 UT通过
  • bash build.sh --pkg --soc=ascend950 --ops=acos_grad,asin_grad -j16:构建及打包通过
  • inspect_build.py:COMPLETE,6/6个dtype二进制完整,每个.o包含2个BUFFER_MODE子kernel
  • clang-format、git diff --check、pre-commit、codespell、OAT通过
  • 变更范围:与原PR一致的7个文件;新增整改只修改acos_grad_tiling_arch35.cpp

文档更新

无。

类型标签

AI/Agent生成声明

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 wangweidong 的贡献)
Wwangweidong
26 天前 创建了 pull request,commit f2b12b13
Wwangweidong
26 天前 关联了issue:[Bug-Report|缺陷反馈]: AcosGrad、AsinGrad算子共性问题排查
atomgit-bot
atomgit-bot
26 天前 评论:

变更摘要

该 PR 将原 PR #4843 的 AcosGrad、AsinGrad arch35 tiling/kernel 实现与 def 驱动 dtype 的修复 rebase 到最新 master 后重新提交,并新增对 acos_grad_tiling_arch35.cpp 超长 tiling 函数的整改。核心变化是:两个算子的 TilingKey 不再编码 dtype,只编码 BUFFER_MODE(0=单 buffer、1=双 buffer),实际 dtype 由 def.cpp 的 DataType 列表驱动、经构建系统注入的 DTYPE_Y 宏在 kernel 内直接使用;同时将 CalcTilingParams 中的多核分块计算抽取为独立的 CalcBlockParams 函数,在不修改 tiling 常量、计算公式、分支和 TilingData 字段的前提下把函数收敛到 50 行以内。

主要改动

  • TilingKey 只编码 BUFFER_MODE:在 acos_grad_tiling_key.h 与 asin_grad_tiling_key.h 中,ASCENDC_TPL_ARGS_DECL 移除 D_T 数据类型模板参数,仅保留 ASCENDC_TPL_UINT_DECL(BUFFER_MODE, 8, ASCENDC_TPL_UI_LIST, 0, 1),对应 ASCENDC_TPL_SEL 也只保留 BUFFER_MODE 的 0/1 选择,TilingKey 不再重复编码 dtype。

  • kernel 改由 DTYPE_Y 驱动 dtype:在 acos_grad_apt.cpp 与 asin_grad.cpp 中,kernel 模板参数由 D_T(或 D_T, BUFFER_MODE)简化为仅 BUFFER_MODE,算子类型统一改为直接使用构建系统注入的 DTYPE_Y 宏,dtype 由 def.cpp 驱动、与 TilingKey 解耦。

  • tiling 层按 buffer 模式设置 TilingKey:在 acos_grad_tiling_arch35.cpp 与 asin_grad_tiling_arch35.cpp 中,ASCENDC_TPL_SEL_PARAM 由传入 dType(及 useDoubleBuffer)改为只传 useDoubleBuffer;其中 AcosGrad 以 totalLength > 1024UL 决定是否启用双 buffer,空 tensor 分支也统一走 useDoubleBuffer = 0。

  • 整改 AcosGrad 超长 tiling 函数:在 acos_grad_tiling_arch35.cpp 中将 CalcTilingParams 内多核分块计算(coreNum/blockFormer/blockNum 推导)抽取为新的 CalcBlockParams 函数(约 24 行),CalcTilingParams 收敛至约 46 行,且不改变 tiling 常量、计算公式、分支与 TilingData 字段。

  • UT 预期随 TilingKey 语义更新:在 test_acos_grad_tiling_arch35.cpp 中,各用例的 expectTilingKey 由按 dtype 区分(FP32=0、FP16=1、BF16=27)改为按 buffer 模式区分——大 shape(如 8192、416910 等,totalLength>1024)统一为 1,小 shape(7、17)与空 tensor 统一为 0。

likedislike
不准确?
atomgit-bot
atomgit-bot
26 天前 评论:

代码审查

✅ 未发现问题

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

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
repo-cann/ops-math ✅ 周奇龙, jia0liang (2/2) ✅ 周奇龙, jia0liang (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成员
26 天前 评论:

CLA Signature Pass

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

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

compile

likedislike
Wwangweidong
26 天前 预合并成功(commit_id: 03f3555b7b6d372058a7e1b7c8a3346c83ce6018)
CANN-robotCANN-robot成员
26 天前 添加了label:ci-pipeline-running
CANN-robotCANN-robot成员
26 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
26 天前 添加了label:ci-pipeline-passed
sunchun成员
25 天前 评论:

您好,PR已满足合入指标,请尽快联系Committer进行合入。如暂时不需要合入,请在PR标题前加[WIP]

likedislike
sunday成员
25 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
25 天前 添加了label:approved
陈佳良成员
24 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
24 天前 添加了label:lgtm
CANN-robotCANN-robot成员
24 天前 合入了pull request