MaxPool: at least 5 dimensions are required for input


While using the TensorRT c++ onnx parser I’m getting the following error:

MaxPool_1: at least 5 dimensions are required for input.


TensorRT Version:
GPU Type: Quadro M2000M
Nvidia Driver Version: R451.77
CUDA Version: 11.0
CUDNN Version: 8.0.1
Operating System + Version: Microsoft WIndows 10 Enterprise 2016
Python Version (if applicable): 3.6.8
TensorFlow Version (if applicable): NA
PyTorch Version (if applicable): 1.7
Baremetal or Container (if container which image + tag): Baremetal

Relevant Files

Attached is my onnx model
OnnxMultiDynamicInputsTestDynamicModel.onnx (36.7 KB)

Attched is the TensorRT onnx parse error:
TensorRT_Onnx_Parse_error_report.txt (5.6 KB)

Steps To Reproduce

Just try to parse the model using the TensorRT Onnx parser


Hi @orong13,

Could you please confirm are you able to run successfully using ONNX runtime, and please let us know which method/source you have followed to generate ONNX model.

Thank you.

Hello @spolisetty ,
Thank you for your quick response.

The onnx was generated using this command:

torch.onnx.export(model, (input, input2), "OnnxMultiDynamicInputsTestDynamicModel.onnx", verbose=True,
                      dynamic_axes={'my_input1': {0: 'batch', 1: 'channels', 2: 'rows', 3: 'cols'},
                                    'my_input2': {0: 'batch', 1: 'channels', 2: 'rows', 3: 'cols'},
                                    'my_output': {0: 'batch', 1: 'channels', 2: 'rows', 3: 'cols'}})

Regarding the Onnx runtime:
It was a good point because when I tried to load my Onnx with it I got an error:

[ONNXRuntimeError] : 1 : FAIL : Load model from OnnxMultiDynamicInputsTestStaticModel.onnx failed:Node (MaxPool_1) Op (MaxPool) [ShapeInferenceError] Attribute strides has incorrect size

You can see that the Onnx model includes MaxPool layer which is actually a torch NaxPool3D layer which means the strides has 3 dimensions.

I changed a little bit the model and replace th MaxPool3D with a MaxPool2D and now all works fine the Onnx Runtime and the TensorRT onnx parse operation.

See attached onnx model:
OnnxMultiDynamicInputsTestDynamicModel.onnx (36.7 KB)

Is it means that Onnx runtime and TensorRT Onnx don’t support MaxPool3D and only MaxPool2D?


@orong13, glad to hear that issue has been resolved.
Yes, MaxPool3D operation not supported by TensorRT currently.

Please refer following doc to checkout supported op by TensorRT.