Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Is it possible to convert "interpolation with align_corners=True" from Pytorch to TensorRt #422

Closed
ycchanau opened this issue Mar 9, 2020 · 3 comments
Assignees
Labels

Comments

@ycchanau
Copy link

ycchanau commented Mar 9, 2020

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
@rmccorm4
Copy link
Collaborator

Hi @ycchanau ,

  1. 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

  2. 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.

  3. It also seems like another user contributed a PR to torch2trt with support for interpolate, you could check this out as well: A whole lot of extra operations (including interpolate, 3d convs/deconvs/pooling) NVIDIA-AI-IOT/torch2trt#249

Please share your results if any of these options work for you.

@WIll-Xu35
Copy link

@rmccorm4 Thank you so much for your information. Your first solution solved my problem.

@rajeevsrao rajeevsrao self-assigned this Sep 1, 2020
@rajeevsrao
Copy link
Collaborator

To be closed pending onnx/onnx-tensorrt#418

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants