已合并
feat: 迁移Yolo系列和TransArgb ONNX插件 #1122
tianqiguang创建于 7月14日
feat: 迁移Yolo系列和TransArgb ONNX插件 #1122
已合并
tianqiguang创建于 7月14日
tianqiguang成员
7月14日

描述

将 Yolo 系列和 TransArgb ONNX 算子插件从内部仓库迁移至开源仓库,新增 7 个 ONNX 插件文件并更新算子注册头文件。

序号 算子 文件名 行数
1 TransArgb trans_argb_onnx_plugin.cpp 43
2 Yolo yolo_onnx_plugin.cpp 69
3 YoloBoxesEncode yolo_boxes_encode_onnx_plugin.cpp 51
4 YoloPreDetection yolo_predetection_onnx_plugin.cpp 75
5 YoloV3DetectionOutputV2 yolov3_detection_output_v2_onnx_plugin.cpp 108
6 YoloV5DetectionOutput yolov5_detection_output_onnx_plugin.cpp 114
7 YoloXBoundingBoxDecode yolox_bounding_box_decode_onnx_plugin.cpp 35

实现方式

每个插件文件通过 REGISTER_CUSTOM_OP 宏注册算子,实现 ONNX NodeProto 属性到 Ascend GE IR 的映射,注册为 FrameworkType(ONNX) + ImplyType(TVM)

同时更新 op_cv_proto_extend.h 头文件中的算子注册声明,适配新的插件化架构。

测试

  • Yolo 系列 ONNX 模型推理兼容性验证
  • TransArgb 颜色空间转换正确性验证

类型标签

关联的Issue

  • #620
likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 tianqiguang 的贡献)
Ttianqiguang成员
7月14日 创建了 pull request,commit 56a04af6
atomgit-bot
atomgit-bot
7月14日 评论:

变更摘要

本 PR 主要将 Yolo 系列(Yolo、YoloPreDetection、YoloV3DetectionOutputV2、YoloV5DetectionOutput、YoloBoxesEncode、YoloxBoundingBoxDecode)和 TransArgb 共七个 ONNX 自定义算子迁移至项目。变更包括在头文件 op_cv_proto_extend.h 中新增算子注册定义,并为每个算子添加对应的 ONNX 插件实现文件,完成从 ONNX 算子到 GE 框架的解析与注册。

主要改动

  • op_cv_proto_extend.h 中新增 7 个算子注册定义:新增 REG_OP(Yolo)REG_OP(YoloPreDetection)REG_OP(YoloV5DetectionOutput)REG_OP(YoloV3DetectionOutputV2)REG_OP(YoloBoxesEncode)REG_OP(YoloxBoundingBoxDecode)REG_OP(TransArgb),每个算子均以 #ifndef 宏保护,定义输入/输出张量类型、属性及其默认值。
  • 新增 trans_argb_onnx_plugin.cpp:注册 TransArgb 算子的 ONNX 插件,通过 REGISTER_CUSTOM_OP 映射 ai.onnx::8..18::TransArgb 到自定义算子,ParseParamsFn 为空实现,标记为 ImplyType::TVM
  • 新增 yolo_onnx_plugin.cpp:注册 Yolo 算子 ONNX 插件,解析 boxescoordsclassesyolo_version 等属性,覆盖 ai.onnx::8..16::Yolo
  • 新增 yolo_predetection_onnx_plugin.cpp:注册 YoloPreDetection 算子 ONNX 插件,除与 Yolo 相同的属性外还解析 softmaxbackgroundsoftmaxtree,默认 yolo_version"V5"
  • 新增 yolov5_detection_output_onnx_plugin.cpp:注册 YoloV5DetectionOutput 算子,支持动态输入 DYNAMIC_INPUT("x"),解析 biases(必填)、alpha 及 NMS 相关阈值等多个属性。
  • 新增 yolov3_detection_output_v2_onnx_plugin.cpp:注册 YoloV3DetectionOutputV2 算子,结构与 YoloV5DetectionOutput 类似但不包含 alpha 属性,biases 同样为必填。
  • 新增 yolo_boxes_encode_onnx_plugin.cppyolox_bounding_box_decode_onnx_plugin.cpp**:分别注册 YoloBoxesEncode(解析 performance_mode)和 YoloxBoundingBoxDecode(无属性解析)的两个辅助算子。
likedislike
atomgit-bot
atomgit-bot
7月14日 评论:

代码审查

Now I have completed the thorough review of all 8 changed files. Let me provide the closing summary.


审查总结

已审查文件清单

文件 审查结果
common/inc/op_graph/op_cv_proto_extend.h 发现 1 个问题(P3 文档不一致)
common/src/framework/trans_argb_onnx_plugin.cpp 无问题
common/src/framework/yolo_boxes_encode_onnx_plugin.cpp 无问题
common/src/framework/yolo_onnx_plugin.cpp 发现 1 个问题(P2 漏解析属性)
common/src/framework/yolo_predetection_onnx_plugin.cpp 发现 1 个问题(P3 缺类型检查)
common/src/framework/yolov3_detection_output_v2_onnx_plugin.cpp 发现 1 个问题(P2 漏解析属性)
common/src/framework/yolov5_detection_output_onnx_plugin.cpp 同 P3 缺类型检查(已在 yolo_predetection 中报告)
common/src/framework/yolox_bounding_box_decode_onnx_plugin.cpp 无问题

问题统计

  • P0: 0
  • P1: 0
  • P2: 2(yolo_onnx_plugin.cpp 漏解析 softmax/background/softmaxtree;yolov3_detection_output_v2_onnx_plugin.cpp 漏解析 relative/resize_origin_img_to_net)
  • P3: 2(yolo_predetection/yolov5 缺属性类型检查;YoloV5DetectionOutput 文档 img_info 不一致)

总体风险评估

中等风险。两个 P2 问题均为 ONNX 属性漏解析:当 ONNX 模型对相关属性设置了非默认值时,插件将静默使用硬编码默认值而非模型实际值,导致推理结果与预期不一致。修复方案明确且范围可控,建议在合入前补齐缺失的属性解析逻辑。其余文件整体质量良好,无安全或崩溃风险。

类型 数量
🔴 阻塞 0
🟡 建议 4

💬 仅评论

likedislike
CANN-robotCANN-robot成员
7月14日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
7月14日 评论:

CLA Signature Pass

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

likedislike
此处折叠了89条消息 查看更多
zl_hw成员
7月15日 评论:

/lgtm
/approve

likedislike
CANN-robot
CANN-robot成员
7月15日 评论:

The following users do not have permission to comment /lgtm or /approve on any module in this PR:
宋恺

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