X2Paddle icon indicating copy to clipboard operation
X2Paddle copied to clipboard

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

Open cainiaoPCW opened this issue 2 years ago • 2 comments

问题描述

  • 错误信息 model ir_version: 6, op version: 11 shape inferencing ... Stopping at incomplete shape inference at Div: x2paddle_onnx__Sub_156 node inputs: name: "x2paddle_onnx__Div_152" type { tensor_type { elem_type: 1 shape { dim { dim_param: "NonZero3_o0__d1" } dim { dim_value: 1 } dim { dim_value: 3 } } } }

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.out_mp_) 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.out_mp_) 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

  • 转换模型后用处
    • [ ] 使用 Paddle-Lite 做移动端推理
  • 模型来源 PointPillars:https://github.com/zhulf0804/PointPillars 模型文件链接:https://pan.baidu.com/s/16Ok8S51VsvAbXF0nW1p5SQ,提取码:wtf4
  • 应用场景 用于移动端业务下的检测业务
  • 版本信息 PaddlePaddle => :grey_question: X2Paddle => :grey_question: 来源框架版本(PyTorch/TF/ONNX/Caffe) => :grey_question:
  • 联系方式(邮箱/微信/电话) [email protected]

cainiaoPCW avatar Nov 07 '22 15:11 cainiaoPCW

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

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

git clone develop的X2Paddle代码

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

wjj19950828 avatar Nov 09 '22 11:11 wjj19950828

@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

cainiaoPCW avatar Nov 10 '22 03:11 cainiaoPCW