ONNX Upsampling broken

Provide details on the platforms you are using:
Ubuntu 18.04
Tesla V100
Driver 418.39
CUDA 10.0
Python version 3.6.7
Pytorch 1.0.1.post2

Describe the problem

Importing an ONNX model with an upsampling error raises the following error:

IndexError: Attribute not found: height_scale

I think the reason for this is that ONNX changed the behaviour of the upsampling operator in Operator Set 9 (see https://github.com/onnx/onnx/pull/1467).

Onnx-tensorrt have met the same problem and solved it here: https://github.com/onnx/onnx-tensorrt/pull/80

To reproduce the error, run the following code:

import torch
from torch import nn
import tensorrt as trt

class Model(nn.Module):
    def forward(self, x):
        return nn.functional.interpolate(x, scale_factor=2)

dummy_input = torch.rand(1, 3, 20, 20)
torch.onnx.export(Model(), dummy_input, 'test.onnx')

TRT_LOGGER = trt.Logger(trt.Logger.INFO)

def GiB(val):
    return val * 1 << 30

with trt.Builder(TRT_LOGGER) as builder, \
    builder.create_network() as network, \
    trt.OnnxParser(network, TRT_LOGGER) as parser:
    builder.max_workspace_size = GiB(1)
    # Load the Onnx model and parse it in order to populate the TensorRT network.
    with open('test.onnx', 'rb') as model:
        success = parser.parse(model.read())

hi, did you solved this problem?

I did find a workaround by exporting the ONNX file with pytorch 0.4.1 as that supports an ealier version of the ONNX opset. I haven’t tried newer versions of TensorRT yet, so it might be already fixed