PaddlePaddle / X2Paddle

Deep learning model converter for PaddlePaddle. (『飞桨』深度学习模型转换工具)
http://www.paddlepaddle.org/
Apache License 2.0
727 stars 164 forks source link

Inferred shape and existing shape differ in dimension 2: (4) vs (3) #909

Open cainiaoPCW opened 1 year ago

cainiaoPCW commented 1 year ago

问题描述

name: "x2paddle_onnx__Div_155" type { tensor_type { elem_type: 1 shape { dim { dim_param: "NonZero9_o0__d1" } dim { dim_value: 1 } dim { dim_value: 1 } } } }

node outputs: name: "x2paddle_onnx__Sub_156" type { tensor_type { elem_type: 1 shape { dim { } dim { dim_value: 1 } dim { dim_value: 3 } } } }

!!!!!!!!!! (op_type:Slice, name:x2paddle_onnx__Sub_146): Inferred shape and existing shape differ in dimension 2: (4) vs (3) [WARNING] Incomplete symbolic shape inference (op_type:Slice, name:x2paddle_onnx__Sub_146): Inferred shape and existing shape differ in dimension 2: (4) vs (3) Traceback (most recent call last): File "/usr/local/python3.7.5/lib/python3.7/site-packages/x2paddle/decoder/onnx_shape_inference.py", line 1606, in infer_shapes symbolic_shape_inference.outmp) File "/usr/local/python3.7.5/lib/python3.7/site-packages/onnx/shape_inference.py", line 35, in infer_shapes inferred_model_str = C.infer_shapes(model_str) RuntimeError: Inferred shape and existing shape differ in dimension 2: (4) vs (3)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/python3.7.5/bin/x2paddle", line 8, in sys.exit(main()) File "/usr/local/python3.7.5/lib/python3.7/site-packages/x2paddle/convert.py", line 488, in main enable_onnx_checker=args.enable_onnx_checker) File "/usr/local/python3.7.5/lib/python3.7/site-packages/x2paddle/convert.py", line 295, in onnx2paddle model = ONNXDecoder(model_path, enable_onnx_checker) File "/usr/local/python3.7.5/lib/python3.7/site-packages/x2paddle/decoder/onnx_decoder.py", line 430, in init self.graph = ONNXGraph(onnx_model) File "/usr/local/python3.7.5/lib/python3.7/site-packages/x2paddle/decoder/onnx_decoder.py", line 186, in init onnx_model, fixed_input_shape=self.fixed_input_shape) File "/usr/local/python3.7.5/lib/python3.7/site-packages/x2paddle/decoder/onnx_shape_inference.py", line 1610, in infer_shapes symbolic_shape_inference.outmp) File "/usr/local/python3.7.5/lib/python3.7/site-packages/onnx/shape_inference.py", line 35, in infer_shapes inferred_model_str = C.infer_shapes(model_str) RuntimeError: Inferred shape and existing shape differ in dimension 2: (4) vs (3)

具体信息

模型转换命令: x2paddle \ --framework=onnx \ --model=pointpillars_v2.onnx \ --save_dir=./paddle_models \ --to_lite=True \ --lite_valid_places=x86 \ --lite_model_type=naive_buffer

wjj19950828 commented 1 year ago

@cainiaoPCW 确保一下这个ONNX模型能否用onnxruntime运行,看报错像是onnx包infer_shape报错

另外可以试下develop的X2Paddle,onnx的infer_shape报错规避掉了

git clone develop的X2Paddle代码

pip uninstall x2paddle(确保老版本清干净了)
cd X2Paddle
python setup.py install
cainiaoPCW commented 1 year ago

@cainiaoPCW 确保一下这个ONNX模型能否用onnxruntime运行,看报错像是onnx包infer_shape报错

另外可以试下develop的X2Paddle,onnx的infer_shape报错规避掉了

git clone develop的X2Paddle代码

pip uninstall x2paddle(确保老版本清干净了)
cd X2Paddle
python setup.py install

ONNX模型可以用onnxruntime运行。 按指导安装develop的X2Paddle,出现如下报错: (op_type:Slice, name:x2paddle_onnx__Sub_146): Inferred shape and existing shape differ in dimension 2: (4) vs (3) [WARNING] Incomplete symbolic shape inference (op_type:Slice, name:x2paddle_onnx__Sub_146): Inferred shape and existing shape differ in dimension 2: (4) vs (3) [WARNING] Shape inference by ONNX offical interface. Shape inferenced. Now, onnx2paddle support convert onnx model opset_verison [7, 8, 9, 10, 11, 12, 13, 14, 15], opset_verison of your onnx model is 11. Total nodes: 313 Nodes converting ... Converting node 321 ... Traceback (most recent call last): File "/usr/local/python3.7.5/lib/python3.7/site-packages/x2paddle-1.3.9-py3.7.egg/x2paddle/op_mapper/onnx2paddle/opset_legacy.py", line 110, in run_mapping res = func(*args, **kwargs) File "/usr/local/python3.7.5/lib/python3.7/site-packages/x2paddle-1.3.9-py3.7.egg/x2paddle/op_mapper/onnx2paddle/opset_legacy.py", line 2192, in Conv assert 2 <= convnd <= 3, 'only Conv2D and Conv3D is supported' AssertionError: only Conv2D and Conv3D is supported

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/python3.7.5/bin/x2paddle", line 11, in load_entry_point('x2paddle==1.3.9', 'console_scripts', 'x2paddle')() File "/usr/local/python3.7.5/lib/python3.7/site-packages/x2paddle-1.3.9-py3.7.egg/x2paddle/convert.py", line 497, in main enable_onnx_checker=args.enable_onnx_checker) File "/usr/local/python3.7.5/lib/python3.7/site-packages/x2paddle-1.3.9-py3.7.egg/x2paddle/convert.py", line 304, in onnx2paddle mapper = ONNXOpMapper(model) File "/usr/local/python3.7.5/lib/python3.7/site-packages/x2paddle-1.3.9-py3.7.egg/x2paddle/op_mapper/onnx2paddle/onnx_op_mapper.py", line 52, in init func(node) File "/usr/local/python3.7.5/lib/python3.7/site-packages/x2paddle-1.3.9-py3.7.egg/x2paddle/op_mapper/onnx2paddle/opset_legacy.py", line 113, in run_mapping node.name[9:], node.layer_type)) Exception: convert failed node:onnx__Relu_468, op_type is Conv