[Question] Is it possible to convert "interpolation with align_corners=True" from Pytorch to TensorRt
ycchanau opened this issue · 3 comments
Description
When I convert a PyTorch model to onnx and then use TensorRT to parse it, I get this error.
[8] Assertion failed: (transformationMode == "asymmetric") && "This version of TensorRT only supports asymmetric resize!"
From this issue #273, I notice that tensorRt has an IResizeLayer with align_coerners and gives the same output as Pytorch when align_corners=True. I just wonder if it is possible to convert "interpolation with align_corners=True" from Pytorch to TensorRt
Environment
TensorRT Version: 7.0
GPU Type: T4
Nvidia Driver Version:
CUDA Version: 10.2
CUDNN Version: 7.6.5
Operating System + Version: ubuntu 18.04
Python Version (if applicable): 3.6
TensorFlow Version (if applicable):
PyTorch Version (if applicable): 1.4.0
Baremetal or Container (if container which image + tag): TensorRT Release 20.02
Relevant Files
Steps To Reproduce
The code of the model
class Resize_Test(nn.Module):
def __init__(self):
super(Resize_Test, self).__init__()
def forward(self, x):
x = F.interpolate(x, size=(128, 128), mode='bilinear', align_corners=True)
return x
Hi @ycchanau ,
-
You could try editing the ONNX parser source like this PR, building it, and seeing if it parses your model successfully: https://github.com/onnx/onnx-tensorrt/pull/418/files
-
It seems like torch2trt might support interpolate since this directory exists: https://github.com/NVIDIA-AI-IOT/torch2trt/tree/master/torch2trt/converters/interpolate, you could try to use that.
-
It also seems like another user contributed a PR to torch2trt with support for interpolate, you could check this out as well: NVIDIA-AI-IOT/torch2trt#249
Please share your results if any of these options work for you.
@rmccorm4 Thank you so much for your information. Your first solution solved my problem.
To be closed pending onnx/onnx-tensorrt#418