已关闭
[Bug-Report|缺陷反馈]: 修复 ONNX 插件零值属性解析异常 #1023
clinglai0517创建于  28 天前关闭于  21 天前
clinglai0517成员
28 天前 创建

Describe the current behavior / 问题描述 (Mandatory / 必填)

NpuNMSWithMask 与 PSROIPoolingV2 的 ONNX 插件通过 ParseParamsByOperatorFn 读取 GE 序列化的 attribute JSON。GE 在 ONNX 标量 FLOAT/INT 值为 0 时会省略对应的 f/i 字段,但保留属性的 name 和 type。

当前实现未正确处理该规则:

  • NpuNMSWithMask 仅在 iou_threshold 包含 f 字段时解析,显式传入 iou_threshold=0 会被误判为属性缺失并回退到默认值 0.5。
  • PSROIPoolingV2 直接访问 spatial_scale 的 f 以及 output_dim、group_size 的 i 字段,零值场景会触发 JSON 类型异常,导致插件解析失败。

该行为与旧 protobuf 接口中 attr.f()/attr.i() 对零值返回 0 的语义不一致。

Environment / 环境信息 (Mandatory / 必填)

  • 仓库:cann/ops-cv
  • 目标分支:master
  • 基线 commit:30bb9321509df27b06b9ea27e94b12b98b0827cc
  • 验证环境:CANN 9.0.0,Ascend 910B3 构建容器
  • 相关参考:cann/ops-nn PR #10783

Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)

  1. 为 NpuNMSWithMask 构造 GE attribute JSON:

    {"attribute":[{"name":"iou_threshold","type":1}]}
    
  2. 调用 ParseParamsNMSWithMask,读取目标算子的 iou_threshold。

  3. 为 PSROIPoolingV2 构造零值属性 JSON:

    {"attribute":[{"name":"spatial_scale","type":1},{"name":"output_dim","type":2},{"name":"group_size","type":2}]}
    
  4. 调用 ParseOnnxParamsPSROIPoolingV2。

Describe the expected behavior / 预期结果 (Mandatory / 必填)

插件应先依据属性 name 判断属性是否存在;当标量值字段 f/i 被省略时,应按 protobuf 默认语义解析为 0.0/0,而不是回退到算子的其他默认值或抛出 JSON 异常。非零属性、属性缺失和非法 JSON 的既有行为应保持不变。

修复前的可观察结果:

  • NpuNMSWithMask:显式零值被解析为默认值 0.5。
  • PSROIPoolingV2:缺少 f/i 时可能触发 json.exception.type_error.302 并返回 FAILED。

修复分支已增加零值回归测试;远端定向 op_host UT 共 9 个用例全部通过,完整 oponnx_plugin_cv 构建通过。

Special notes for this issue/备注 (Optional / 选填)

修复范围仅涉及 ONNX 插件属性解析与 framework UT,不修改算子 kernel、tiling、接口定义或正常非零属性语义。

likedislike
Cclinglai0517成员
28 天前 添加了label:bug-report
Cclinglai0517成员
28 天前 关联了pull request:[Fix] 修复 ONNX 插件零值属性解析异常
liu-weiliu-wei成员
28 天前 将 clinglai0517 设为负责人
CANN-robotCANN-robot成员
21 天前 关闭了 issue
CANN-robotCANN-robot成员
21 天前 添加了label:resolved