已合并
FM非全载场景增加小kernel模板 #8376
yangyang4536创建于 27 天前
FM非全载场景增加小kernel模板 #8376
已合并
yangyang4536创建于 27 天前
yangyang4536
yangyang4536
27 天前

描述

FM非全载场景缺少小kernel模板,新增模板,优化此场景性能

关联的Issue

https://gitcode.com/cann/ops-nn/issues/4984

测试

文档更新

类型标签

AI/Agent生成声明

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 yangyang4536 的贡献)
yangyang4536yangyang4536
27 天前 创建了 pull request,commit aae256c4
atomgit-bot
atomgit-bot
27 天前 评论:

变更摘要

此 PR 引入了「FM 不全载」(Feature Map 部分加载)的 Small Kernel 卷积优化路径。当 FM 无法全部放入 L1 缓存但 Weight 可以完全加载到 L1 时,新增的 CONV_SMALL_KERNEL_FM_PARTLOAD 策略将 FM 按 Cin 维度分块加载,Weight 则一次性全部载入 L1,从而扩展 Small Kernel 优化的适用范围。主要涉及新增 tiling key 枚举值、tiling 判定逻辑、内核模板类 Conv2dSmallKernelFmPartload,以及在 conv2d_v2 和 extend_conv2d 两个入口的调度分发。

主要改动

  • 新增 CONV_SMALL_KERNEL_FM_PARTLOAD tiling key:在 conv_tilingkey.h 中定义宏值为 2,并在 CONV2D_SCALAR_OPT_SEL 宏的 SmallKernel 选择器中增加该选项;同时 conv2d_v2_tilingkey.h 中将 SmallKernel 位宽从 1_BW 扩展为 2_BW 以支持三种状态。
  • 新增 FM 不全载判定逻辑:在 conv2d_v2_base_tiling_tilingkey.cppGetSmallKernelVal() 中,当 FM 不满足 L1 全载、Weight 满足 L1 全载、数据类型为 FP16×FP16 或 INT8×INT8、且 Weight 为 NZ 格式时,返回 CONV_SMALL_KERNEL_FM_PARTLOAD
  • 新增 Conv2dSmallKernelFmPartload 内核模板类:新增 conv2d_small_kernel_fm_partload.h(+297 行),继承自 Conv2dSmallKernelParallelism,仅覆写 InitProcess,并新增 LoadWeightL1Full 方法。其核心策略是 Weight 一次性全量加载到 L1(不分 K 维度),FM 则按 Cin 分块复用父类的分块辅助方法,支持 M 模式和 HW 模式。
  • Conv2dSmallKernelParallelism 访问权限调整:将 conv2d_small_kernel_parallelism.h 中的 private: 改为 protected:,使子类 Conv2dSmallKernelFmPartload 可以访问基类的共享成员和辅助方法。
  • 调度分发适配:在 conv2d_v2.cppextend_conv2d.cpp 中增加对 SmallKernel == CONV_SMALL_KERNEL_FM_PARTLOADif constexpr 分支,实例化并调用新模板类,使两个卷积入口均支持 FM 不全载优化路径。
likedislike
atomgit-bot
atomgit-bot
27 天前 评论:

代码审查

✅ 未发现问题

likedislike
CANN-robotCANN-robot成员
27 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
27 天前 评论:

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
conv 王慈孟, 郑李磊 (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

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

likedislike
此处折叠了67条消息 查看更多
wangcimeng成员
12 天前 评论:

/lgtm
/approve

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

Pull Request 已合并或已关闭。

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

likedislike