onnx使用atc 模型转换
收藏回复举报
onnx使用atc 模型转换
t('forum.solved') 已解决
发表于2025-05-23 11:22:17
0 查看

工具版本如下:

Version=7.2.0.1.235 

version_dir=8.0.RC1 

required_opp_abi_version=">=6.3, <=7.2"

操作系统:

ubuntu20.04

命令如下(根据torch.export.onnx的dynamic_axes确定):

静态输入:

atc --model onnx_models/backbone.onnx --output onnx_model/backbone --framework=5 --soc_version=Ascend310P3

动态输入:

atc --model onnx_models/backbone.onnx --output onnx_model/backbone --framework=5 --soc_version=Ascend310P3 --input_shape_range="images:[1,3,300~1400,500~1400]"

模型文件链接如下:
链接: https://pan.baidu.com/s/1aWZ9KcXYyUGyV2T7Sb1-Ow?pwd=ky37 提取码: ky37 

无论是动态还是静态输入都会报下面的错误,我查询了一下该阶段的形状推理,没发现什么异常,而且onnx的精度结果也与原模型进行了对比正常。

静态:

E10042: 2025-05-23-10:47:21.612.975 GenerateOfflineModel execute failed. 

        TraceBack (most recent call last): 

        op[/Concat], the input shape dims should be equal except merge axis,shapes:[[1, ], [1, 1, ], ]axis:0[FUNC:ConcatInferShapeCommon][FILE:split_combination_ops.cc][LINE:1213] 

        Call InferShapeAndType for node:/Concat(ConcatD) failed[FUNC:Infer][FILE:infershape_pass.cc][LINE:120] 

        process pass InferShapePass on node:/Concat failed, ret:4294967295[FUNC:RunPassesOnNode][FILE:base_pass.cc][LINE:570] 

        build graph failed, graph id:0, ret:1343242270[FUNC:BuildModelWithGraphId][FILE:ge_generator.cc][LINE:1615] 

        GenerateOfflineModel execute failed.

精度检查:

output_0:
  MSE: 0.000000
  Cosine Similarity: 1.000000
  Max Difference: 0.000008

output_2:
  MSE: 0.000000
  Cosine Similarity: 1.000000
  Max Difference: 0.000000

动态:

ATC run failed, Please check the detail log, Try 'atc --help' for more information E10042: 2025-05-22-18:28:34.244.716 GenerateOfflineModel execute failed. TraceBack (most recent call last): op[/Concat_3], the input shape dims should be equal except merge axis,shapes:[[1, ], [1, 1, ], ]axis:0[FUNC:ConcatInferShapeCommon][FILE:split_combination_ops.cc][LINE:1213] Call InferShapeAndType for node:/Concat_3(ConcatD) failed[FUNC:Infer][FILE:infershape_pass.cc][LINE:120] process pass InferShapePass on node:/Concat_3 failed, ret:4294967295[FUNC:RunPassesOnNode][FILE:base_pass.cc][LINE:570] build graph failed, graph id:0, ret:1343242270[FUNC:BuildModelWithGraphId][FILE:ge_generator.cc][LINE:1615] GenerateOfflineModel execute failed.

节点分析结果:

节点名称: /Concat_3
输入名称列表: ['/Constant_6_output_0', '/Unsqueeze_3_output_0', '/Constant_7_output_0', '/Unsqueeze_4_output_0', '/Constant_8_output_0', '/Unsqueeze_5_output_0']
中间结果 /Constant_6_output_0 形状: [1]
中间结果 /Unsqueeze_3_output_0 形状: [1]
中间结果 /Constant_7_output_0 形状: [1]
中间结果 /Unsqueeze_4_output_0 形状: [1]
中间结果 /Constant_8_output_0 形状: [1]
中间结果 /Unsqueeze_5_output_0 形状: [1]

我要发帖子