已合并
fix: onnx插件解析属性时零值字段被GE省略导致回退默认值 #10783
clinglai0517创建于 9月18日
fix: onnx插件解析属性时零值字段被GE省略导致回退默认值 #10783
已合并
clinglai0517创建于 9月18日
clinglai0517成员
9月18日

描述

GE 序列化 ONNX 算子属性为 JSON 时,会省略值为 0 的标量字段(float 的 "f"、int 的 "i")。部分插件用 attr.contains("f"/"i") 判断属性是否存在,或直接访问 attr["f"/"i"],导致属性传 0 时被错误回退到算子默认值,或直接抛异常使转换失败。

修复方式:先按 name 判断属性是否存在,值字段缺失时按该类型的 protobuf 默认值 0 处理,而不是回退默认值或抛异常。

涉及算子:

  • Elu(alpha)
  • LeakyRelu(alpha)
  • HardMax(axis)
  • AdaCast(pixel)
  • GroupNormRelu(eps / num_groups)
  • BoundingBoxDecode(wh_ratio_clip)
  • AscendAntiQuantV2(dst_dtype)

关联的Issue

Issue #6004

测试

  • 编译:bash build.sh --onnxplugin -j16 通过(7 个修复源文件全部编译通过)。
  • 单测:bash build.sh -u --ophost --ops=elu,leaky_relu,hardmax,ada_cast,14 个用例全部 PASSED(含各算子新增的「零值字段缺失」用例)。
  • 端到端 NPU(Ascend 910B3 / CANN 9.0.0):ELU alpha=0 负半轴输出 [0,0,0,0],alpha=3.0 回归无影响。

文档更新

不涉及

类型标签

AI/Agent生成声明

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 clinglai0517 的贡献)
Cclinglai0517成员
9月18日 创建了 pull request,commit 2f303416
Cclinglai0517成员
9月18日 关联了issue:[Bug-Report|缺陷反馈]: onnx插件属性值为0时字段被GE省略导致回退默认值
CANN-robotCANN-robot成员
9月18日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
9月18日 评论:

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
activation ✅ 刘杰, 唐超, 刘波 (3/2) ✅ 刘杰 (1/1)
common ✅ 刘波, 唐超 (2/2) ✅ 刘波 (1/1)
quant ✅ 唐超, 刘波, 刘杰 (3/2) ✅ 刘杰 (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

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

likedislike
CANN-robotCANN-robot成员
9月18日 将zengjuan,u010470851,sxb154714,chenfeng61,chaotang233,kevin_huang1234,crystalhu,yangyang016,fanqirui,wangrui_,renruhai,su-yueming,zhajianqing123,yourealize,chenqi317,LinPX,wang-xing001,liubo75,tangweiwei2,wangzitao_leo,xubinglin,chenxingyu18,liujie12345678,pingchuantang,Chen_HaoWen,qianzehong,liuyang_806设为评审人
此处折叠了64条消息 查看更多
liubo75成员
9月20日 评论:

/lgtm
/approve

likedislike
CANN-robot
CANN-robot成员
9月20日 评论:

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

likedislike
CANN-robotCANN-robot成员
9月20日 添加了label:lgtmapproved
CANN-robotCANN-robot成员
9月20日 关闭了关联的issue
CANN-robotCANN-robot成员
9月20日 合入了pull request