已合并
feat: index_fill、avg_pool、avg_pool_v2算子新增ascend960芯片支持 #11274
klein8793创建于 9月28日
feat: index_fill、avg_pool、avg_pool_v2算子新增ascend960芯片支持 #11274
已合并
klein8793创建于 9月28日
klein8793
klein8793成员
9月28日

描述

为 index_fill、avg_pool、avg_pool_v2 三个算子新增 ascend960dt(Ascend 960)芯片支持。

改动原因

Ascend 960 芯片推出,需要上述算子适配新平台,扩大算子可用硬件范围。

改动方法

  • index_fill:
    • op_graph/index_fill_proto.h 新增 hifloat4、float4_e2m1、float4_e1m2 类型注册(METADEF_VERSION_NUM >= 90300000 宏防护);
    • op_host/index_fill_def.cpp 新增 ascend960dt 算子配置与类型列表;
    • op_host/arch35 新增 SIMD DMA tiling 子场景(index_fill_tiling_simd_dma.cpp/.h),tiling_common 新增 hifloat4/fp4 支持校验(CheckSupportForHif4,FP4 按 int8 搬运、尾轴减半);
    • op_kernel 新增 arch92 内核(index_fill_apt.cpp、index_fill_simd_dma.h),arch35 内核新增 fp4Mode 与 fp4 值打包处理;
    • 新增 ascend960dt 编译配置(index_fill_binary.json、index_fill_simplified_key.ini);
    • 新增 geir 图模式示例(examples/test_geir_index_fill.cpp)。
  • avg_pool / avg_pool_v2:
    • op_host 新增 ascend960dt 算子配置与编译配置(avg_pool.json / avg_pool_v2_binary.json、*_simplified_key.ini);
    • op_kernel/arch35 新增 SUPPORT_MERGE_MODE 与 AddWithMergeMode(arch 9201/9202 使用 Reg::Add MERGING 模式),avg_pool_big_kernel_nhwc.h 改用该模板。
  • scripts:
    • ascendc_config.json 为 IndexFill/AvgPool/AvgPoolV2 增加 ascend960dt compute_unit;
    • ascendc_impl_build.py 增加 hifloat4 类型映射,parse_ini_to_json.py 增加 hifloat4 类型。

关联的Issue

  • #6758

测试

  • 编译通过,geir 示例(test_geir_index_fill.cpp)编译并运行成功(build.sh --run_example index_fill graph)。
  • obp冒烟、david冒烟

文档更新

无

类型标签

AI/Agent生成声明

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 klein8793 的贡献)
klein8793klein8793成员
9月28日 创建了 pull request,commit 81a85fb8
atomgit-bot
atomgit-bot
9月28日 评论:

变更摘要

本 PR 为 IndexFill 算子补充 fp4 系列数据类型(DT_HIFLOAT4、DT_FLOAT4_E2M1、DT_FLOAT4_E1M2)在 Ascend 960 平台(ascend960dt / ascend960pr)上的支持,并为此引入了新的 IndexFillSimdDmaTiling 模板与对应的 IndexFillSimdDmaImpl kernel,同时在公共 tiling 中增加 fp4 相关的芯片与尾轴校验、数据类型与规模换算,以及各 kernel 中 fp4 填充值的位拼接处理。

主要改动

  • 新增 fp4 数据类型与 Ascend 960 配置:算子原型 index_fill_proto.h 的 IndexFill 输入 x/val 与输出 y 增加 DT_HIFLOAT4、DT_FLOAT4_E2M1、DT_FLOAT4_E1M2,index_fill_def.cpp 新增 ascend960XDataType、ascend960IndicesDataType、ascend960FormatList 并向 AICore() 注册 ascend960dt、ascend960pr 两个 config_960 配置。
  • 新增 SIMD DMA 模板与 kernel:新增 IndexFillSimdDmaTiling(index_fill_tiling_simd_dma.h/.cpp,注册优先级 1,原 SIMD 模板改为 2)与 IndexFillSimdDmaImpl(op_kernel/arch35/index_fill_simd_dma.h),并在 index_fill_apt.cpp 中按 TPL_MODE_TEMPLATE_SIMD_DMA 分派 B32/B64 两种索引位宽。
  • tiling key 扩展:index_fill_tiling_key.h 新增 TPL_MODE_TEMPLATE_SIMD_DMA,TEMPLATE_MODE 声明位宽由 2 调整为 3,并为各模板选择项补充 ASCENDC_TPL_KERNEL_TYPE_SEL(ASCENDC_TPL_MIX_AIV_1_0)。
  • fp4 校验与数据换算:index_fill_tiling_common.cpp 新增 CheckSupportForHif4,对 fp4 类型校验芯片架构为 NpuArch::DAV_9201 且尾轴 Q 为偶数,随后将 Q 与 numel 减半、dtype 置为 DT_INT8 并置 fp4Support = 1;同时新增 isAscend960DT 记录当前架构。
  • fp4 填充值处理与结构体扩展:index_fill_struct.h 新增 FOUR_BIT、HIGH_FOUR_BIT 常量与各 TilingData 的 fp4Mode 字段及新的 IndexFillSimdDmaTilingData,index_fill_simd.h、index_fill_simt.h、index_fill_simt_dense_indices.h、index_fill_simd_dma.h 在 fp4Mode 下对 fillValue 执行高低 4 位复制。
  • 配置与校验调整:新增 config/ascend960dt、config/ascend960pr 下的 index_fill_binary.json 与 index_fill_simplified_key.ini,并将公共 tiling 中 x/y 的 dtype、shape 及 dim 等校验改为 OP_CHECK_IF + OP_LOGE 的写法。
likedislike
不准确?
atomgit-bot
atomgit-bot
9月28日 评论:

代码审查

审查结论

  • [阻塞] index/index_fill/op_host/arch35/index_fill_tiling_common.cpp:127 fix: CheckSupportForHif4 返回值被丢弃,fp4 校验失败仍继续 tiling
类型 数量
🔴 阻塞 1
🟡 建议 0

⛔ 需要修改

likedislike
不准确?
CANN-robotCANN-robot成员
9月28日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
9月28日 评论:

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_graph/*_proto.h ✅ 王永光, 陈展熹, 上官秦南 (3/2) ✅ 王永光 (1/1)
*/*/op_host/*_def.cpp ✅ 陈展熹, 王永光, 上官秦南 (3/2) ✅ 王永光 (1/1)
index ✅ 上官秦南, 陈展熹 (2/2) ✅ 陈展熹 (1/1)
pooling ✅ 陈展熹, 上官秦南 (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

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

likedislike
此处折叠了408条消息 查看更多
sgqt12
sgqt12成员
17 天前 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
17 天前 添加了label:lgtm
CANN-robotCANN-robot成员
17 天前 关闭了关联的issue
CANN-robotCANN-robot成员
17 天前 合入了pull request
CANN-robot
CANN-robot成员
17 天前 评论:

Pull Request 已合并或已关闭。

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

likedislike