I used the code below to export interpolation operation to onnx file.
repeat = torch.nn.UpsamplingNearest2d(scale_factor=2)
repeat.eval()
torch.onnx.export(repeat, torch.ones((1, 3, 4, 4)), “repeat.onnx”)
And the console output is:
torch.onnx.export(repeat, torch.ones((1, 3, 4, 4)), “repeat.onnx”)
File “D:\ProgramData\Anaconda3\lib\site-packages\torch\onnx_init_.py”, line 25, in export
return utils.export(*args, **kwargs)
File “D:\ProgramData\Anaconda3\lib\site-packages\torch\onnx\utils.py”, line 131, in export
strip_doc_string=strip_doc_string)
File “D:\ProgramData\Anaconda3\lib\site-packages\torch\onnx\utils.py”, line 363, in _export
_retain_param_name, do_constant_folding)
File “D:\ProgramData\Anaconda3\lib\site-packages\torch\onnx\utils.py”, line 278, in _model_to_graph
_disable_torch_constant_prop=_disable_torch_constant_prop)
File “D:\ProgramData\Anaconda3\lib\site-packages\torch\onnx\utils.py”, line 188, in _optimize_graph
graph = torch._C._jit_pass_onnx(graph, operator_export_type)
File “D:\ProgramData\Anaconda3\lib\site-packages\torch\onnx_init_.py”, line 50, in _run_symbolic_function
return utils._run_symbolic_function(*args, **kwargs)
File “D:\ProgramData\Anaconda3\lib\site-packages\torch\onnx\utils.py”, line 589, in _run_symbolic_function
return fn(g, *inputs, **attrs)
File “D:\ProgramData\Anaconda3\lib\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 “D:\ProgramData\Anaconda3\lib\site-packages\torch\onnx\symbolic.py”, line 130, in 
args = [_parse_arg(arg, arg_desc) for arg, arg_desc in zip(args, arg_descriptors)]
File “D:\ProgramData\Anaconda3\lib\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
My pytorch version is 1.1.0, py3.6_cuda90_cudnn7_1.