Issue 1:
🐛 Bug

When I use torch.onnx.export , I met opset support problem:

/export/liuxiao/local/anaconda3/lib/python3.7/site-packages/torch/onnx/utils.py:562: UserWarning: ONNX export failed on ATen operator upsample_bilinear2d because torch.onnx.symbolic_opset9.upsample_bilinear2d does not exist
.format(op_name, opset_version, op_name))
Traceback (most recent call last):
File "convertPytorch2ONNX.py", line 54, in <module>
torch_out = torch.onnx.export(senetModel, input_var, sys.argv[4], export_params=True, verbose=True, input_names=input_names, output_names=output_names)
File "/export/liuxiao/local/anaconda3/lib/python3.7/site-packages/torch/onnx/__init__.py", line 132, in export
strip_doc_string, dynamic_axes)
File "/export/liuxiao/local/anaconda3/lib/python3.7/site-packages/torch/onnx/utils.py", line 64, in export
example_outputs=example_outputs, strip_doc_string=strip_doc_string, dynamic_axes=dynamic_axes)
File "/export/liuxiao/local/anaconda3/lib/python3.7/site-packages/torch/onnx/utils.py", line 329, in _export
_retain_param_name, do_constant_folding)
File "/export/liuxiao/local/anaconda3/lib/python3.7/site-packages/torch/onnx/utils.py", line 225, in _model_to_graph
_disable_torch_constant_prop=_disable_torch_constant_prop)
File "/export/liuxiao/local/anaconda3/lib/python3.7/site-packages/torch/onnx/utils.py", line 127, in _optimize_graph
graph = torch._C._jit_pass_onnx(graph, operator_export_type)
File "/export/liuxiao/local/anaconda3/lib/python3.7/site-packages/torch/onnx/__init__.py", line 163, in _run_symbolic_function
return utils._run_symbolic_function(*args, **kwargs)
File "/export/liuxiao/local/anaconda3/lib/python3.7/site-packages/torch/onnx/utils.py", line 563, in _run_symbolic_function
op_fn = sym_registry.get_registered_op(op_name, '', opset_version)
File "/export/liuxiao/local/anaconda3/lib/python3.7/site-packages/torch/onnx/symbolic_registry.py", line 91, in get_registered_op
return _registry[(domain, version)][opname]
KeyError: 'upsample_bilinear2d'

To Reproduce

Steps to reproduce the behavior:

pytorch inference file

change the output to onnx.export

Environment

PyTorch Version (e.g., 1.0): 1.2

OS (e.g., Linux): Centos

How you installed PyTorch (conda, pip, source): Conda

Build command you used (if compiling from source):

Python version: 3.7.3

CUDA/cuDNN version: 10/7.6

Any other relevant information: pytorch model is trained by pytorch 1.0.0

Issue 2:
🐛 Bug

This issue is related to #20116 and #10942 and has to deal with upsample_bilinear2d

To Reproduce

Steps to reproduce the behavior:

This snippet can be used to reproduce behavior

import torch
import torch.nn as nn
import torch.nn.functional as F

class TestModel(nn.Module):
def __init__(self):
super(TestModel, self).__init__()

def forward(self, x):
x = F.interpolate(x, scale_factor=2, mode='bilinear', align_corners=False)
return x

torch_model = TestModel()
dummy_input = torch.randn(1, 3, 256, 256)

torch_out = torch.onnx.export(torch_model, dummy_input, 'test_model.onnx', verbose=True)

Expected behavior

That snippet is working under torch.__version__ : 1.0.1.post2, installed in a conda env, it seems that there it's able to parse to onnx since the output is:

graph(%input : Float(1, 3, 256, 256)) {
%1 : Tensor = onnx::Constant[value= 1 1 2 2 [ CPUFloatType{4} ]](), scope: TestModel
%2 : Float(1, 3, 512, 512) = onnx::Upsample[mode="linear"](%input, %1), scope: TestModel
return (%2);
}

Under torch.__version__ : 1.1.0 the error would be this one:

Traceback (most recent call last):
File "test.py", line 16, in <module>
torch_out = torch.onnx.export(torch_model, dummy_input, 'test_model.onnx', verbose=True)
File "/home/bpinaya/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/onnx/__init__.py", line 25, in export
return utils.export(*args, **kwargs)
File "/home/bpinaya/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/onnx/utils.py", line 131, in export
strip_doc_string=strip_doc_string)
File "/home/bpinaya/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/onnx/utils.py", line 363, in _export
_retain_param_name, do_constant_folding)
File "/home/bpinaya/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/onnx/utils.py", line 278, in _model_to_graph
_disable_torch_constant_prop=_disable_torch_constant_prop)
File "/home/bpinaya/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/onnx/utils.py", line 188, in _optimize_graph
graph = torch._C._jit_pass_onnx(graph, operator_export_type)
File "/home/bpinaya/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/onnx/__init__.py", line 50, in _run_symbolic_function
return utils._run_symbolic_function(*args, **kwargs)
File "/home/bpinaya/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/onnx/utils.py", line 589, in _run_symbolic_function
return fn(g, *inputs, **attrs)
File "/home/bpinaya/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/onnx/symbolic.py", line 130, in wrapper
args = [_parse_arg(arg, arg_desc) for arg, arg_desc in zip(args, arg_descriptors)]
File "/home/bpinaya/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/onnx/symbolic.py", line 130, in <listcomp>
args = [_parse_arg(arg, arg_desc) for arg, arg_desc in zip(args, arg_descriptors)]
File "/home/bpinaya/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/onnx/symbolic.py", line 90, in _parse_arg
raise RuntimeError("Failed to export an ONNX attribute, "
RuntimeError: Failed to export an ONNX attribute, since it's not constant, please try to make things (e.g., kernel size) static if possible

And in a fresh conda env with pytoch installed from master with commit 3b1c3996e1c82ca8f43af9efa196b33e36efee37 and torch.__version__ : 1.2.0a0+3b1c399 the error for the upsample_bilinear2d is:

/home/bpinaya/anaconda3/envs/pytorch-edge/lib/python3.7/site-packages/torch/onnx/utils.py:662: UserWarning: ONNX export failed on ATen operator upsample_bilinear2d because torch.onnx.symbolic_opset9.upsample_bil
inear2d does not exist
.format(op_name, opset_version, op_name))
Traceback (most recent call last):
File "convert_to_onnx.py", line 36, in <module>
output_names=output_layer_names))
File "/home/bpinaya/anaconda3/envs/pytorch-edge/lib/python3.7/site-packages/torch/onnx/__init__.py", line 32, in export
return utils.export(*args, **kwargs)
File "/home/bpinaya/anaconda3/envs/pytorch-edge/lib/python3.7/site-packages/torch/onnx/utils.py", line 170, in export
example_outputs=example_outputs, strip_doc_string=strip_doc_string, dynamic_axes=dynamic_axes)
File "/home/bpinaya/anaconda3/envs/pytorch-edge/lib/python3.7/site-packages/torch/onnx/utils.py", line 429, in _export
_retain_param_name, do_constant_folding)
File "/home/bpinaya/anaconda3/envs/pytorch-edge/lib/python3.7/site-packages/torch/onnx/utils.py", line 330, in _model_to_graph
_disable_torch_constant_prop=_disable_torch_constant_prop)
File "/home/bpinaya/anaconda3/envs/pytorch-edge/lib/python3.7/site-packages/torch/onnx/utils.py", line 232, in _optimize_graph
graph = torch._C._jit_pass_onnx(graph, operator_export_type)
File "/home/bpinaya/anaconda3/envs/pytorch-edge/lib/python3.7/site-packages/torch/onnx/__init__.py", line 57, in _run_symbolic_function
return utils._run_symbolic_function(*args, **kwargs)
File "/home/bpinaya/anaconda3/envs/pytorch-edge/lib/python3.7/site-packages/torch/onnx/utils.py", line 663, in _run_symbolic_function
op_fn = sym_registry.get_registered_op(op_name, '', opset_version)
File "/home/bpinaya/anaconda3/envs/pytorch-edge/lib/python3.7/site-packages/torch/onnx/symbolic_registry.py", line 91, in get_registered_op
return _registry[(domain, version)][opname]
KeyError: 'upsample_bilinear2d'

And according to #20116 the error should be fixed on master

Environment

The output of collect_env:

Collecting environment information...

PyTorch version: 1.1.0

Is debug build: No

CUDA used to build PyTorch: 10.0.130

OS: Ubuntu 18.04.2 LTS

GCC version: (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0

CMake version: version 3.10.2

Python version: 3.7

Is CUDA available: Yes

CUDA runtime version: 10.0.130

GPU models and configuration:

GPU 0: GeForce GTX 1080 Ti

GPU 1: GeForce GTX 1080 Ti

Nvidia driver version: 418.56

cuDNN version: /usr/lib/x86_64-linux-gnu/libcudnn.so.7.5.0

Versions of relevant libraries:

[pip] numpy==1.16.2

[pip] numpydoc==0.8.0

[pip] torch==1.1.0

[pip] torchvision==0.3.0

[conda] blas 1.0 mkl

[conda] mkl 2019.3 199

[conda] mkl-service 1.1.2 py37he904b0f_5

[conda] mkl_fft 1.0.10 py37ha843d7b_0

[conda] mkl_random 1.0.2 py37hd81dba3_0

[conda] pytorch 1.1.0 py3.7_cuda10.0.130_cudnn7.5.1_0 pytorch

[conda] torchvision 0.3.0 py37_cu10.0.130_1 pytorch

Bear in mind that I tried on pytorch 1.0.1, 1.1.0 and master.

Additional context

If I were to use something like:

import torch
import torch.nn as nn
import torch.nn.functional as F

class TestModel(nn.Module):
def __init__(self):
super(TestModel, self).__init__()

def forward(self, x):
x = F.interpolate(x, x.size()[2:], mode='bilinear', align_corners=False)
return x

torch_model = TestModel()
dummy_input = torch.randn(1, 3, 256, 256)

torch_out = torch.onnx.export(torch_model, dummy_input, 'test_model.onnx', verbose=True)

without manually specifying the sizes, the issue still remains and now also appears on version 1.0.1 of course.

Any insights are appreciated, thanks for the hard work guys!