ONNX export: no bilinear interpolation support?

Hello,
It looks the ONNX exported model use ‘nearest’ interpolation although I exported a network with ‘bilinear’ interpolation. The code I tested is:

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

class TestNet(nn.Module):
    def __init__(self):
        super().__init__()

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

net = TestNet()

batch_size = 8
x = torch.tensor([[[[0.0, 1.0, 2.0], [1, 2, 3]]]])

print('net(x):', net(x))
torch_out = torch.onnx._export(net, x, 'net.onnx', export_params=True, verbose=False)
print('onnx export output:', torch_out.data)



#
import onnx

model = onnx.load("net.onnx")
onnx.checker.check_model(model)

import caffe2.python.onnx.backend as backend

rep = backend.prepare(model, device="CPU") # or "CPU"
outputs = rep.run(x.data.numpy())
print('caffe2:', outputs[0])

The output is:

net(x): tensor([[[[0.0000, 0.6250, 1.3750, 2.0000],
          [1.0000, 1.6250, 2.3750, 3.0000]]]])
onnx export output: tensor([[[[0.0000, 0.6250, 1.3750, 2.0000],
          [1.0000, 1.6250, 2.3750, 3.0000]]]])
caffe2: [[[[0. 0. 1. 2.]
   [1. 1. 2. 3.]]]]

Is it a known issue?
Thank you.

I’ve updated the codes. The previous one I uploaded was incorrect to show the issue.

Hello,Have you solved the problem yet?

This should be supported, did you try latest PyTorch?

Oh, I think it is supported now. The original question was out-dated :slight_smile:
Thank you.