Merged
refactor: 迁移 Resize ONNX 插件至 cv 仓并补充 Slice 等算子桩 (9.1.0) #1418
refactor: 迁移 Resize ONNX 插件至 cv 仓并补充 Slice 等算子桩 (9.1.0) #1418
Merged
chenfengAdd on Aug 27
chenfeng
chenfengCollaborators
Aug 27

描述

resize 类算子属视觉算子,其 IR 原型、框架插件等内容应统一归属 ops-cv 仓。此前 Resize 的 ONNX 插件误落在 ops-nn 仓,本 PR 将其迁移至 ops-cv 仓(新增 488 行)。

改动:

  • 新增 common/src/framework/resize_onnx_plugin.cpp:由 ops-nn 迁移而来,通过 REGISTER_CUSTOM_OP("PartitionedCall") 分别注册 ai.onnx::11~18::Resize(含 ParseParamsResize/ParseOpToGraphResize)与 ai.onnx::10::Resize(含 ParseParamsResizeV10/ParseOpToGraphResizeV10)两套处理流程,按 nearest/linear/cubic 模式分别构图到 ResizeNearestNeighborV2 或 Resize;include 调整为 op_cv_proto_extend.h + resize_nearest_neighbor_v2_proto.h(Resize/ResizeNearestNeighborV2 原型 cv 仓已存在),构图逻辑与原文件逐字一致;ChangeFormatFromOnnx 已由 cv 仓 onnx_common.h 提供,无需前置声明。
  • 补充 common/stub/inc/framework/stub_ops.h 中 Mul、Identity、Shape、Empty、Slice 算子桩定义:9.1.0 分支 stub 此前仅有 Data/Cast/Const/Concat/Unsqueeze/Transpose,本 PR 补充插件构图所需的 Mul/Identity/Shape 算子桩及 Empty/Slice 桩,供插件 CreateSliceForResize 等函数使用。

本 PR 为 master 分支 PR #1406 的 9.1.0 分支同步版本。因 9.1.0 stub 缺少 Mul/Identity/Shape/Empty,相比 master 版本额外补入了这些算子桩。

关联的Issue

https://gitcode.com/cann/ops-cv/issues/827

配套 PR(ops-nn 侧删除,9.1.0 分支):https://gitcode.com/cann/ops-nn/pull/9384

主分支配套 PR:

测试

  • 两仓 pre-commit 全部通过(clang-format / OAT / codespell 等)
  • 插件正文与 nn 原文件逐字一致,include 依赖在 cv 仓均可解析

文档更新

无文档更新。

类型标签

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for chenfeng's contribution.)
chenfengchenfengCollaborators
Aug 27 Created pull request, commit e568307a
chenfengchenfengCollaborators
Aug 27 Associated issue: [Bug-Report|缺陷反馈]: 【CANN开源内测】image/col2im/算子目录下没有README.md算子介绍文档,且aclnn的参数说明没有按照表格的样式呈现,与首页的算子目录结构介绍不一样
atomgit-bot
atomgit-bot
Aug 27 Comments:

变更摘要

本 PR 为 9.1.0 分支的重构改动:将原误落在 ops-nn 仓的 Resize ONNX 框架插件迁移至 ops-cv 仓,新增 common/src/framework/resize_onnx_plugin.cpp(372 行),通过 REGISTER_CUSTOM_OP("PartitionedCall") 注册 ai.onnx::11~18::Resize 与 ai.onnx::10::Resize 两套解析/构图流程,按 nearest/linear/cubic 插值模式分别构图到 ResizeNearestNeighborV2 或 Resize;同时为 9.1.0 分支的 common/stub/inc/framework/stub_ops.h 补充插件构图所需的 Mul、Identity、Shape、Empty、Slice 算子桩定义。插件正文与 ops-nn 原文件逐字一致,仅 include 依赖调整为 cv 仓已具备的 op_cv_proto_extend.h、resize_nearest_neighbor_v2_proto.h 与 onnx_common.h。

主要改动

  • 新增 resize_onnx_plugin.cpp 并注册两套 Resize 处理流程:通过 REGISTER_CUSTOM_OP("PartitionedCall") 分别注册 ai.onnx::11~18::Resize(ParseParamsResize/ParseOpToGraphResize)与 ai.onnx::10::Resize(ParseParamsResizeV10/ParseOpToGraphResizeV10)两条解析与构图链路。
  • 按插值模式分别构图到不同算子:nearest 模式经 BuildNearestResize/BuildNearestResizeV10 构图到 ResizeNearestNeighborV2(设置 align_corners/half_pixel_centers 属性),linear/cubic 模式经 BuildInterpolatingResize/BuildLinearResizeV10 构图到 Resize(透传 coordinate_transformation_mode/mode 属性),并对 roi/scales 输入缺失时用空 Const 补齐。
  • 新增辅助函数支撑尺寸计算与模式解析:CreateSliceForResize 基于 Const + Slice 从 sizes 中切取输出尺寸;BuildResizeSizesFromInputs 依据输入个数用 Shape/Cast/Mul 计算目标尺寸;ParseResizeModeAttrs 将 coordinate_transformation_mode 映射为 half_pixel_centers/align_corners 标志。
  • 补充 stub 算子桩定义:在 common/stub/inc/framework/stub_ops.h 中新增 Mul(逐元素乘法,支持广播与类型提升 Promote)、Identity、Shape(含 dtype 属性)、Empty(含 dtype/init 属性)、Slice(x/offsets/size 三输入)五个算子注册,供迁移后的插件构图使用。
  • 移除对 nn 仓头文件的依赖:include 由原 nn 仓头文件调整为 cv 仓的 op_cv_proto_extend.h + resize_nearest_neighbor_v2_proto.h,ChangeFormatFromOnnx 直接使用 cv 仓 onnx_common.h 提供的实现,无需前置声明。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Aug 27 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Aug 27 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Aug 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
9.1.0 ✅ Andy-lb, 张磊, 刘伟 (3/2) ✅ Andy-lb (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-robotCollaborators
Aug 27 Set yue-ma,zhou-qilong,rxtfeng,loov1,zhangzijie,TianXL,yourealize,zl_hw,liu-wei,jiangtao_rts,gitcode-chenjiao,hanxiaolong,pingchuantang,llimwang,gubaocheng,gcw_kUomxQ2l,Andy-lb as approver
CANN-robotCANN-robotCollaborators
Aug 27 Set TianXL,jiangtao_rts,gitcode-chenjiao,hanxiaolong,gcw_kUomxQ2l,Andy-lb as approver
chenfengchenfengCollaborators
Aug 27 Modify description of pull request
chenfengchenfengCollaborators
Aug 29 Modify description of pull request
chenfeng
chenfengCollaborators
Aug 29 Comments:

compile

likedislike
chenfengchenfengCollaborators
Aug 29 Pre merge succeeded (commit_id: fffd808796f570266de9f191682ea631d5ba948d)
7 event messages are collapsed here。 See more
CANN-robotCANN-robotCollaborators
Aug 29 Added label: cann-cla/yes
chenfeng
chenfengCollaborators
Aug 29 Comments:

compile

likedislike
chenfengchenfengCollaborators
Aug 29 Pre merge succeeded (commit_id: 03468939fb3f4de6599bf09b03533e33351cbeb6)
CANN-robotCANN-robotCollaborators
Aug 29 Removed label: ci-pipeline-failed
CANN-robotCANN-robotCollaborators
Aug 29 Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Aug 29 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Aug 29 Added label: ci-pipeline-passed
chenfeng
chenfengCollaborators
Aug 31 Comments:

compile

likedislike
chenfengchenfengCollaborators
Aug 31 Pre merge succeeded (commit_id: c8ce15e7cc43025906a95d0a11dbac385425f2d7)
CANN-robotCANN-robotCollaborators
Aug 31 Removed label: ci-pipeline-passed
CANN-robotCANN-robotCollaborators
Aug 31 Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Aug 31 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Aug 31 Added label: ci-pipeline-passed
zl_hwCollaborators
Sep 1 Comments:

/lgtm

likedislike
liu-wei
liu-weiCollaborators
Sep 1 Comments:

/lgtm

likedislike
CANN-robotCANN-robotCollaborators
Sep 1 Added label: lgtm
chenfeng
chenfengCollaborators
Sep 2 Comments:

compile

likedislike
chenfengchenfengCollaborators
Sep 2 Pre merge succeeded (commit_id: ac144319d5cdceb72b0ca94dbbbc86a3004261ac)
CANN-robot
CANN-robotCollaborators
Sep 2 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 2 Removed label: ci-pipeline-passed
CANN-robotCANN-robotCollaborators
Sep 2 Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 2 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 2 Added label: ci-pipeline-passed
Andy-lbCollaborators
Sep 3 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Sep 3 Added label: approved
CANN-robotCANN-robotCollaborators
Sep 3 Merged pull request