onnx-tensorrt: Pad opset 11 not supported

Hi there,

Apparently ‘Pad’ had changes for opset 11.

I use the the tensorflow -> onnx generator.

I use zero padding at some point of my network (not followed by a Conv).

With opset 10, I get

node {
    input: "model_3/conv2d_3/Sigmoid:0"
    output: "model_3/zero_padding2d_1/Pad:0"
    name: "model_3/zero_padding2d_1/Pad"
    op_type: "Pad"
    attribute {
      name: "pads"
      ints: 0
      ints: 8
      ints: 8
      ints: 0
      ints: 0
      ints: 8
      ints: 8
      ints: 0
      type: INTS
    }
  }

With opset 11, I get

 node {
    input: "model_3/conv2d_3/Sigmoid:0"
    input: "model_3/zero_padding2d_2/Pad__188:0"
    output: "model_3/zero_padding2d_1/Pad:0"
    name: "model_3/zero_padding2d_1/Pad"
    op_type: "Pad"
  }
[....]
initializer {
    dims: 8
    data_type: 7
    name: "model_3/zero_padding2d_2/Pad__188:0"
    raw_data: "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000"
  }

As onnx-tensorrt expects the “pads” field to be present, the import fails with IndexError: Attribute not found: pads

Unfortunately I need that to use opset 11 as I use an op that needs at least opset 10, and my network is buggy with opset 10 (no idea whether it is tensorflow conversion or tensorrt). Opset 11 without the padding is ok.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 52

Most upvoted comments

After update the code, I get another error using onnx opset 11

 UNSUPPORTED_NODE: Assertion failed: inputs.at(1).is_weights()

It seems pad is not a weight but a tensor in here

Having the same issue. opset_version=12 .

After update to opset_version=13, new problem accurs: IndexError: Attribute not found: axes

Any help !!!

In node -1 (importPad): UNSUPPORTED_NODE: Assertion failed: inputs.at(1).is_weights()

I got this resolved by using onnx-simplifier

@kevinch-nv HWC is the default format used in tensorflow/keras. Is that input format not supported here? I have not had this issue using any other layers in this format.

Typically ONNX models are in CHW format, and TRT parses the model assuming CHW order. It sounds like transposing the input and the corresponding pad operator to CHW will solve your issue.

Thanks @amrit110, seems this can be closed then.

Looks like this padding opset11 support was just added to master here: #408

@amrit110 can you see if this works for your model?

@rmccorm4, checked and it works fine! thanks.