已合并
feat: 迁移Yolo系列和TransArgb ONNX插件 #1122
tianqiguang创建于 7月14日
feat: 迁移Yolo系列和TransArgb ONNX插件 #1122
已合并
Pull Request已成功合入, 合并人@CANN-robot
(感谢 tianqiguang 的贡献)7月14日 创建了 pull request,commit 56a04af6
atomgit-bot
7月14日 评论:
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 插件,解析boxes、coords、classes、yolo_version等属性,覆盖ai.onnx::8..16::Yolo。 - 新增
yolo_predetection_onnx_plugin.cpp:注册YoloPreDetection算子 ONNX 插件,除与 Yolo 相同的属性外还解析softmax、background、softmaxtree,默认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.cpp和yolox_bounding_box_decode_onnx_plugin.cpp**:分别注册YoloBoxesEncode(解析performance_mode)和YoloxBoundingBoxDecode(无属性解析)的两个辅助算子。


atomgit-bot
7月14日 评论:
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 |
💬 仅评论


7月14日 添加了label:cann-cla/yes
CANN-robot
7月14日 评论:
7月14日 评论:
此处折叠了89条消息 查看更多
CANN-robot
7月15日 评论:
7月15日 评论:
The following users do not have permission to comment /lgtm or /approve on any module in this PR:
宋恺


7月15日 添加了label:lgtm
7月15日 关闭了关联的issue
7月15日 合入了pull request
描述
将 Yolo 系列和 TransArgb ONNX 算子插件从内部仓库迁移至开源仓库,新增 7 个 ONNX 插件文件并更新算子注册头文件。
实现方式
每个插件文件通过
REGISTER_CUSTOM_OP宏注册算子,实现 ONNX NodeProto 属性到 Ascend GE IR 的映射,注册为FrameworkType(ONNX)+ImplyType(TVM)。同时更新
op_cv_proto_extend.h头文件中的算子注册声明,适配新的插件化架构。测试
类型标签
关联的Issue