Merged
fix(lp_norm_reduce): 加固 Ascend950 边界与极大 p 性能 #11238
raoliang_sacAdd on Sep 27
fix(lp_norm_reduce): 加固 Ascend950 边界与极大 p 性能 #11238
Merged
Pull Request has been successfully merged by CANN-robot.
(Thank you for raoliang_sac's contribution.)Sep 27 Created pull request, commit 56a842d3
atomgit-bot
Sep 27 Comments:
Sep 27 Comments:
变更摘要
本 PR 在已合入的 LpNormReduce 实现基础上做加固与测试资产补齐,未改动数值计算公式与现有支持面。Host 侧将超大 shape 的元素数上界由按元素计改为按字节跨度约束,避免 GM stride × sizeof(DT) 溢出;新增固定 UB 缓存归约树容量校验 CheckCacheCapacity;规范 kernel 文件名与绑定,将 lp_norm_reduce_apt.cpp 重命名为 lp_norm_reduce.cpp 并同步 opFile.value;同时新增独立 FP64 Golden 与 CPU-only 守卫测试。
主要改动
- Host shape 边界改为字节跨度口径:
GetShapeAndDtype中kNumelLimit由INT64_MAX - 4096收紧为(INT64_MAX - 4096) / FP32_BYTES,以最大元素字节数约束非零维连乘,防止下游 stride 与字节偏移溢出,并同步更新报错文案为字节跨度语义。 - 新增 UB 缓存容量校验:新增
CheckCacheCapacity,按 group 场景下最大的本地 R 循环数localRLoops计算二叉树层数cacheLevels,校验对齐后的层步长不超过CACHE_BUF_BYTES容量,并在TilingFuncLpNormReduce中于ComputeUbSizes前调用。 - kernel 入口命名规范化:kernel 文件由
op_kernel/lp_norm_reduce_apt.cpp重命名为op_kernel/lp_norm_reduce.cpp,lp_norm_reduce_def.cpp中ExtendCfgInfo("opFile.value", ...)由lp_norm_reduce_apt改为lp_norm_reduce,并同步lp_norm_reduce_tiling_key.h注释中的入口路径。 - 新增独立 FP64 Golden 资产:新增
tests/assets/golden.py,提供LpNormReduceTestSpec(NumPy FP64 oracle)与TorchLpNormReduce(原生 Torch 参考),覆盖 p=0/1/2/3/±inf、keepdim、空张量、标量等分支,并定义customize_inputs按用例名注入零点与 inf/NaN 特殊值、tolerance与third_party配置。 - 新增 CPU-only 测试守卫:新增
tests/golden/test_golden.py与tests/golden/test_assets.py,分别校验 oracle 与 Torch 参考的数值/类型/异常行为、TTK 容差与 promote 语义,以及 kernel 文件绑定、CMakeLists.txt中KERNEL_SRC、opFile.value配置与smoke.csv用例的 p 值与 dtype 覆盖。


Incorrect?
atomgit-bot
Sep 27 Comments:
Sep 27 Comments:
Sep 27 Added label: stat/needs-squash
Sep 27 Added label: cann-cla/yes
CANN-robot
Sep 27 Comments:
Sep 27 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 |
|---|---|---|
| */*/README.md | ✅ 陈展熹, 钱泽洪, 陈娇 (3/2) | ✅ 陈娇 (1/1) |
| */*/op_host/*_def.cpp | ✅ 钱泽洪, 陈展熹, 汤磊 (3/2) | ✅ 汤磊 (1/1) |
| norm | ✅ 钱泽洪, 陈展熹 (2/2) | ✅ 钱泽洪, 陈展熹 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
raoliang_sac, thanks for your pull request. All authors of the commits have signed the CLA. 👍


Sep 27 Set zengjuan,u010470851,chaotang233,kevin_huang1234,crystalhu,yangyang016,fanqirui,gitee-duhuiping,wangrui_,renruhai,su-yueming,zhajianqing123,tang-lei01,yourealize,chenqi317,wang-xing001,liubo75,tangweiwei2,gitcode-chenjiao,chenxingyu18,liujie12345678,pingchuantang,Chen_HaoWen,qianzehong,wangyongguang,fengying555682,caiwenwen,yanglu-1 as approver
Sep 27 Set zengjuan,u010470851,chaotang233,kevin_huang1234,crystalhu,yangyang016,fanqirui,gitee-duhuiping,wangrui_,renruhai,su-yueming,zhajianqing123,tang-lei01,yourealize,chenqi317,wang-xing001,liubo75,tangweiwei2,gitcode-chenjiao,chenxingyu18,liujie12345678,pingchuantang,Chen_HaoWen,qianzehong,wangyongguang,fengying555682,caiwenwen,yanglu-1 as approver
12 event messages are collapsed here。 See more
Sep 28 Added label: cann-cla/yes
raoliang_sac
Sep 28 Comments:
Sep 28 Comments:
compile


Sep 28 Pre merge succeeded (commit_id: 672601abfc0101c8e4f2c4fa3fadf47720b8b9af)
CANN-robot
Sep 28 Comments:
Sep 28 Comments:
| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


Sep 28 Added label: ci-pipeline-running
Sep 28 Removed label: ci-pipeline-running
Sep 28 Added label: ci-pipeline-passed
tang-lei01
Sep 28 Comments:
Sep 28 Comments:
/approve


Sep 28 Modify description of pull request
qianzehong
Sep 28 Comments:
Sep 28 Comments:
/lgtm
/approve


Sep 28 Added label: lgtm
Sep 28 Added label: approved
Sep 28 Closed associated issue
Sep 28 Merged pull request
描述
基于已合入的 LpNormReduce 实现,补齐独立 FP64 Golden 与 Kernel/GEIR 测试资产,规范 kernel 入口命名,修复 Host 超大 shape 字节跨度及 16KiB 归约树缓存容量边界;对 p≥2^31 的极大有限正整数幂增加 FP32 饱和等价快捷路径,并增加编译型 A100 第三方性能对照插件。Golden 数值公式未改,支持面仍仅 Kernel/GEIR,不新增 aclnn、e2e 或 Torch 算子接口。
关联的Issue
#6246
https://gitcode.com/cann/ops-nn/issues/6246
测试
文档更新
更新算子 README 与测试资产说明;正式迭代交付及原始证据边界见 https://gitcode.com/zl_hw/myOpen/merge_requests/8。
类型标签
AI/Agent生成声明