Torch.rfft in old PyTorch and torch.fft.rfft in new PyTorch

Hello,

I have a code in old version Pytorch (1.4) which works fine. I want to use new version of Pytorch(1/9), however, I can not get the same result using torch.fft.rfft()

The code in Pytorch 1.4:

import torch 
X = torch.Tensor([[1,2,3,0], [4,5,6,1],[7,8,9,2] , [10,11,12,3]])
fftfull = torch.rfft(X,2)
print("fftful {}".format(fftfull))

The result:

fftful tensor([[[ 84.,   0.],
         [ -8., -20.],
         [ 20.,   0.]],

        [[-20.,  20.],
         [  4.,   4.],
         [ -4.,   4.]],

        [[-20.,   0.],
         [  0.,   4.],
         [ -4.,   0.]],

        [[-20., -20.],
         [ -4.,   4.],
         [ -4.,  -4.]]]

The code in Pytorch 1.9:

import torch 
import torch.fft
X = torch.Tensor([[1,2,3,0], [4,5,6,1],[7,8,9,2] , [10,11,12,3]])
fftfull = torch.fft.rfft(X, dim=-1)
print("fftful {}".format(fftfull))

The result:

fftful tensor([[ 6.+0.j, -2.-2.j,  2.+0.j],
        [16.+0.j, -2.-4.j,  4.+0.j],
        [26.+0.j, -2.-6.j,  6.+0.j],
        [36.+0.j, -2.-8.j,  8.+0.j]])

Why the results are not the same. How can I get the same values in Pytorch 1.9?
Thank you for your help in advance.

The problem solved by fftfull = torch.fft.rfft2(X) in PyTorch v1.9.

The 2 in fftful = torch.rfft(X,2) in PyTorch 1.4 shows that we want to take 2-dimensional fft of X, therefore the equivalent in PyTorch 1.9 will be fftfull = torch.fft.rfft2(X) , and fftfull = torch.fft.rfft(X, dim=-1) is 1d fft of last dimension of input.