Merged
[NpuArch整改] Index、Pooling 算子统一 DAV_3510 注册与平台判断 #13760
[NpuArch整改] Index、Pooling 算子统一 DAV_3510 注册与平台判断 #13760
Merged
陈展熹Add on 16 days ago
陈展熹
陈展熹Collaborators
16 days ago

描述

对 Index、Pooling 共 31 个 AI Core 算子进行 NpuArch 整改,统一 DAV_3510 及原有 DAV_9201/DAV_9202 平台的注册、构建配置和相关平台判断。

  • 算子注册:def.cpp 统一使用 opbase 的 ArchConfigHelper::AddConfigByArch 按架构注册,沿用原有 dtype、format、属性及平台支持范围。
  • Host 构建配置:使用 dav_3510、dav_9201、dav_9202 配置目标平台,与 tiling 目录逐项配对;删除与 dav_3510 重复的 ascend350 及对应目录项,950/350 统一由 DAV_3510 覆盖,其他平台保留原有 SoC 配置。
  • Kernel 构建配置:按 NpuArch 声明对应的 kernel 源码和编译选项,使用公共 CMake 的 SoC/NpuArch 混配能力。
  • 平台判断:相关 API/tiling 统一使用 NpuArch 查询及 opbase 公共架构常量 Ops::Base::DAV_3510/DAV_9201/DAV_9202。
  • 范围说明:本 PR 不含融合 pass 规则及对应 UT 改动,融合 pass 保持现状。

关联的Issue

测试

  • 31 个算子、15 种有效平台/别名,共 465 组配置对照通过。
  • Ascend950、Ascend350 各自的 31 算子 JIT 算子包构建通过。
  • pre-commit(含 OAT)通过。

文档更新

无。

类型标签

AI/Agent生成声明

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for 陈展熹's contribution.)
陈展熹陈展熹Collaborators
16 days ago Created pull request, commit c86398cd
atomgit-bot
atomgit-bot
16 days ago Comments:

变更摘要

本 PR 是 NpuArch 整改的一部分,将 Index 与 Pooling 类算子(AvgPool、GatherV2、ScatterNd、IndexFill、SegmentSum 等 31 个算子)的 AI Core 注册、图融合平台判断、tiling 架构判断与二进制编译配置由「按 soc 版本名(ascend950/ascend350)分支」统一改为「按 NpuArch(DAV_3510)」判断,使 Ascend950 与 Ascend350 走同一套注册与执行路径,同时保留 GatherV2 等算子在 950/350 上的既有二进制差异与非 DAV_3510 平台的原有配置。

主要改动

  • 算子定义统一按架构注册:各 *_def.cpp 引入 op_common/op_host/util/op_arch_helper.h,将原先分别调用 AddConfig("ascend950", ...) 与 AddConfig("ascend350", ...) 的两处注册合并为一次 opbase::ArchConfigHelper::AddConfigByArch(this->AICore(), Ops::Base::DAV_3510, ...),dtype、format、属性和 opFile.value 配置保持不变。
  • 融合 pass 平台判断改为读取编译目标 NpuArch:common/inc/op_graph/arch_utils.h 新增 GetNpuArch 接口,CheckNpuArch 改为基于其查询结果的集合匹配;bucketize_v2、gather_fusion_pass、tensor_scatter_add_fusion_pass、tensor_scatter_update_fusion_pass、inplace_add_fusion_pass、inplace_sub_fusion_pass、sorted_sparse_segment_mean_grad_fusion_pass 均删除本地 short_soc_version 字符串判断,改用 ops::CheckNpuArch/ops::GetNpuArch(如 {"3510"}、{"3510", "5102", "9201"}),使未在平台表中列举的 DAV_3510 soc 也能命中。
  • 架构常量与 tiling 判断统一:aclnn_gather_nd.cpp、aclnn_scatter.cpp、aclnn_scatter_nd_update.cpp、scatter_elements_v2_asc_tiling.cpp 中的 NpuArch::DAV_3510 改为 Ops::Base::DAV_3510,ScatterElementsV2 的确定性判断由 GetSocVersion() == ASCEND950 改为 GetCurNpuArch() == Ops::Base::DAV_3510;LinearIndexV2CompileInfo 字段 isAscend950 重命名为 isRegbase,tiling 逻辑随之调整。
  • 二进制编译配置合并:scripts/kernel/binary_config/ascendc_config.json 中相关算子的 compute_units 由 ascend950/ascend350 合并为 dav_3510(compile_options 同步改为 dav_3510 键,mc62、ascend960dt、ascend960pr 等其余平台项保留);build_binary_opc_gen_task.sh 中当 soc_version_lower 为 ascend950/ascend350 时额外匹配 dav_3510 配置项。
  • 测试桩与用例补充:新增 tests/ut/common/ut_platform_utils.h,提供 Ops::NN::Test::SetPlatformNpuArch(含 soc→NpuArch 映射表)用于构造平台资源;各融合 pass UT 在设置平台后调用该桩,并新增「未列举 soc + NpuArch=3510」的融合成功用例及 350 上跳过 legacy 融合的 dtype 覆盖用例。

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

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

代码审查

审查结论

  • [建议] index/scatter_sub/op_graph/fusion_pass/inplace_sub_fusion_pass.cpp:153 fix: GetNpuArch 查询失败时直接放弃融合,丢失非 3510 平台原有融合能力
类型 数量
🔴 阻塞 0
🟡 建议 1

💬 仅评论


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

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
16 days ago Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
16 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
*/*/op_host/*_def.cpp ✅ 汤磊, 汤平川, 钱泽洪 (3/2) ✅ 汤磊 (1/1)
index ✅ 汤平川, 钱泽洪 (2/2) ✅ 汤平川, 钱泽洪 (2/1)
pooling ✅ 汤平川, 钱泽洪 (2/2) ✅ 汤平川, 钱泽洪 (2/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
158 messages are collapsed here。 See more
CANN-robot
CANN-robotCollaborators
3 days ago Comments:

The MR can not be merged, because of CodeReview discussion not resolved

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike
陈展熹陈展熹Collaborators
2 days ago Resolved final issue
CANN-robotCANN-robotCollaborators
2 days ago Closed associated issue
CANN-robotCANN-robotCollaborators
2 days ago Merged pull request
CANN-robot
CANN-robotCollaborators
2 days ago Comments:

Pull Request 已合并或已关闭。

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike