已合并
refactor: 迁移 Resize ONNX 插件至 cv 仓并补充 Slice 算子桩定义 #1406
refactor: 迁移 Resize ONNX 插件至 cv 仓并补充 Slice 算子桩定义 #1406
已合并
chenfeng创建于 8月27日
chenfeng
chenfeng成员
8月27日

描述

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

改动:

  • 新增 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 中 Slice 算子桩定义:输入 x/offsets/size,输出 y,兼容 TensorFlow Slice,供插件 CreateSliceForResize 从 sizes 中切取尺寸使用(cv 仓此前无 Slice 桩)。

关联的Issue

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

配套 PR(ops-nn 侧删除):https://gitcode.com/cann/ops-nn/pull/9322

测试

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

文档更新

无文档更新。

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 chenfeng 的贡献)
chenfengchenfeng成员
8月27日 创建了 pull request,commit 977c4b4a
atomgit-bot
atomgit-bot
8月27日 评论:

变更摘要

本 PR 将 Resize 的 ONNX 框架插件从 ops-nn 仓迁移至 cv 仓(对应 issue-60 resize 类算子归属清理),并补充插件所需的 Slice 算子桩定义。迁移后插件在 cv 仓内注册 ai.onnx::10~18::Resize 算子,构图逻辑与原文件逐字一致,仅将 include 依赖调整为 cv 仓已有的 op_cv_proto_extend.h、resize_nearest_neighbor_v2_proto.h 及提供 ChangeFormatFromOnnx 的 onnx_common.h,不再需要前置声明。配套地,ops-nn 仓需在单独 PR 中删除重复的 Resize/ResizeNearestNeighborV2 原型及原插件。

主要改动

  • 新增 resize_onnx_plugin.cpp 插件文件: 新增 common/src/framework/resize_onnx_plugin.cpp(+372 行),通过 REGISTER_CUSTOM_OP("PartitionedCall") 注册 ai.onnx::11::Resize 至 ai.onnx::18::Resize(由 ParseParamsResize/ParseOpToGraphResize 处理)及 ai.onnx::10::Resize(由 ParseParamsResizeV10/ParseOpToGraphResizeV10 处理),ImplyType 均为 TVM。
  • 按插值模式构建子图: ParseOpToGraphResize 依据 mode 属性分流——nearest 走 BuildNearestResize(生成 ResizeNearestNeighborV2 算子并设置 align_corners/half_pixel_centers),linear/cubic 走 BuildInterpolatingResize(生成 Resize 算子并透传 coordinate_transformation_mode/mode 属性),不支持的模式返回 FAILED。
  • 新增尺寸推导与 Slice 处理: 新增 BuildResizeSizesFromInputs,根据 input_size(4 个输入时 Cast 尺寸,3 个输入时由 Shape/Mul/Cast 计算目标尺寸);新增 CreateSliceForResize 通过常量 offsets=2、size=2 构造 op::Slice 从 sizes 张量截取切片,供 ResizeNearestNeighborV2 的 size 输入使用。
  • 补充 Slice 算子桩定义: 在 common/stub/inc/framework/stub_ops.h 中新增 REG_OP(Slice) 桩定义(输入 x/offsets/size,输出 y,兼容 TensorFlow Slice 算子),为插件中的 CreateSliceForResize 提供编译期依赖,此前 cv 仓无该算子桩。
likedislike
不准确?
atomgit-bot
atomgit-bot
8月27日 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robotCANN-robot成员
8月27日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
8月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
repo-cann/ops-cv ✅ 汤平川, 刘伟 (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

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

likedislike
CANN-robotCANN-robot成员
8月27日 将yue-ma,zhou-qilong,rxtfeng,loov1,zhangzijie,zl_hw,liu-wei,pingchuantang,llimwang,gubaocheng设为评审人
CANN-robotCANN-robot成员
8月27日 将yue-ma,zhou-qilong,rxtfeng,loov1,zhangzijie,zl_hw,liu-wei,pingchuantang,llimwang,gubaocheng设为审查人
chenfeng
chenfeng成员
8月27日 评论:

compile

likedislike
chenfengchenfeng成员
8月27日 预合并成功(commit_id: 9e4dcefe81dacc416a594d553163625fbb82eae3)
此处折叠了7条事件消息 查看更多
chenfengchenfeng成员
8月27日 修改了pull request 的描述
TangPC
TangPC成员
8月28日 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
8月28日 添加了label:approved
liu-wei
liu-wei成员
8月28日 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
8月28日 添加了label:lgtm
CANN-robotCANN-robot成员
8月28日 关闭了关联的issue
CANN-robotCANN-robot成员
8月28日 合入了pull request