已合并
resize_nearest_neighbor_v2 nchw 格式性能优化 #822
chenfeng创建于 5月7日
resize_nearest_neighbor_v2 nchw 格式性能优化 #822
已合并
chenfeng创建于 5月7日
chenfeng
chenfeng成员
5月7日

描述

为 resize_nearest_neighbor_v2 算子新增 Gather 模版,提升 NCHW 格式场景的计算性能。

改动原因

现有调度策略在部分 NCHW 格式场景下性能不佳,需要新增基于 MicroAPI 的 Gather 调度策略,利用寄存器级操作提升计算效率。

改动方法

  1. 新增调度策略 ID:

    • TPL_SCH_MODE_GATHER_ALL_HW (ID=9): 所有 HW 可放入 UB 的场景
    • TPL_SCH_MODE_GATHER_CUT_H (ID=10): 需要切 H 的场景
  2. 新增 kernel 实现 (resize_nearest_neighbor_v2_nchw_gather.h):

    • 使用 MicroAPI RegTensor、AddrReg、UpdateMask 等特性
    • 实现高效坐标计算和 Gather 输出
    • 支持 alignCorners 和 halfPixelCenters 参数
  3. 扩展 Tiling 策略:

    • IsMatchTiling_NCHW_Gather(): 判断是否启用 Gather 调度
    • DoTilingGatherNchw(): 计算 GATHER_ALL_HW 场景 tiling 参数
    • ComputeGatherCutH(): 计算 GATHER_CUT_H 场景 tiling 参数
    • 使用动态 ubBlockSize_ 替换固定 ONE_BLOCK_SIZE
  4. 注册模版:

    • 新增 RESIZE_NEAREST_NEIGHBOR_V2_GATHER_TPL_KEY_SEL() 宏
    • 在 apt.cpp 中添加 Gather 调度分支处理

涉及文件

  • image/resize_nearest_neighbor_v2/op_kernel/arch35/resize_nearest_neighbor_v2_nchw_gather.h (新增 696 行)
  • image/resize_nearest_neighbor_v2/op_host/arch35/resize_nearest_neighbor_v2_tiling_base.cpp (修改 153+/19-)
  • image/resize_nearest_neighbor_v2/op_kernel/arch35/resize_nearest_neighbor_v2_tiling_key.h (修改 16+/2-)
  • image/resize_nearest_neighbor_v2/op_kernel/resize_nearest_neighbor_v2_apt.cpp (修改 13+/0-)

关联的Issue

测试

需要验证新增 Gather 调度策略在 NCHW 格式场景下的精度和性能。

文档更新

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 chenfeng 的贡献)
chenfengchenfeng成员
5月7日 创建了 pull request,commit 48fed175
CANN-robot
CANN-robot成员
5月7日 评论:

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


PR Approval Progress

Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
image/resize_nearest_neighbor_v2 刘伟, zhangzijie (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

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

likedislike
CANN-robotCANN-robot成员
5月7日 添加了label:cann-cla/yes
CANN-robotCANN-robot成员
5月7日 将zhou-qilong,renruhai,zhajianqing123,rxtfeng,luowen203_gg123,loov1,zl_hw,liu-wei,demoauguste,llimwang,gubaocheng设为评审人
CANN-robotCANN-robot成员
5月7日 将zhou-qilong,renruhai,zhajianqing123,rxtfeng,luowen203_gg123,loov1,liu-wei,demoauguste,llimwang,gubaocheng设为审查人
此处折叠了121条消息 查看更多
CANN-robot
CANN-robot成员
5月9日 评论:

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
liu-weiliu-wei成员
5月9日 解决了最后一个问题
CANN-robot
CANN-robot成员
5月9日 评论:

Review Guide

This pull-request passes review.
Committers who wrote a comment of /approve are: 刘伟.
Reviewers who wrote a comment of /lgtm are: 刘伟, zhangzijie.

likedislike
CANN-robotCANN-robot成员
5月9日 关闭了关联的issue
CANN-robotCANN-robot成员
5月9日 合入了pull request