pytorch / pytorch

Tensors and Dynamic neural networks in Python with strong GPU acceleration
https://pytorch.org
Other
82.53k stars 22.21k forks source link

[onnx-caffe2] Caffe2 only supports padding 2D Tensor #9411

Open pengwa opened 6 years ago

pengwa commented 6 years ago

Issue description

I run resnetv1-152 ONNX model with onnx-caffe2 backend, failed with below message:

ONNX FATAL: [enforce fail at backend.cc:653] . Caffe2 only supports padding 2D Tensor, whereas padding is [0, 3, 3, 0, 0, 3, 3, 0, ] ONNX FATAL: [enforce fail at backend.cc:653] . Caffe2 only supports padding 2D Tensor, whereas padding is [0, 1, 1, 0, 0, 1, 1, 0, ] ONNX FATAL: [enforce fail at backend.cc:653] . Caffe2 only supports padding 2D Tensor, whereas padding is [0, 1, 1, 0, 0, 1, 1, 0, ] ONNX FATAL: [enforce fail at backend.cc:653] . Caffe2 only supports padding 2D Tensor, whereas padding is [0, 1, 1, 0, 0, 1, 1, 0, ]

errors thrown file https://github.com/pytorch/pytorch/blob/master/caffe2/onnx/backend.cc, seems the conversion for Pad is limited in current implementation.

Code example

The ONNX operator for Pad is:

 node {
    input: "input:0"
    output: "resnet_v1_152/Pad:0"
    name: "resnet_v1_152/Pad"
    op_type: "Pad"
    attribute {
      name: "pads"
      ints: 0
      ints: 3
      ints: 3
      ints: 0
      ints: 0
      ints: 3
      ints: 3
      ints: 0
      type: INTS
    }
  }

System Info

Please copy and paste the output from our environment collection script (or fill out the checklist below manually).

You can get the script and run it with:


# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py

cmake .. -DPYTHON_INCLUDE_DIR=/usr/include/python3.5 -DPYTHON_LIBRARY=$(python3 -c "import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var('LIBDIR'))") -DPYTHON_EXECUTABLE=/usr/bin/python3

make install

garymm commented 3 years ago

Doesn't seem related to torch.onnx so removing module: onnx.