Converting Pytorch model to ONNX to Tensorrt


I am trying to convert a ResNet50 based model from Pytorch to Tensorrt,
my first step is converting the model to ONNX using the torch.onnx._export() function
then converting it to TensorRT with the ONNX parser from

now if the Pytorch model has an x=x.view() layer the onnx converter produces Shape and Gather layers. that the Tensorrt parser cant convert.

what is the correct way to convert a network fron pytorch to Tensorrt. or is there a way to by pass this problem ?


1 Like


have you tried convert using the default ONNX parser that’s shipped with TensorRT? Please reference the sampleOnnxMNST sample for details.

I had the same problem (last week). The functions Shape and Gather where recently added to

You should build from source onnx-tensorrt (not that easy because you should also install protobuf)