I am trying to convert a numpy implementation of DFT using numpy.fft.fft2 to all PyTorch. When compairing torch.fft, the results are not the same. Why is this?
Numpy
>>> np.fft.fft2(test_cp, axes=(1,2)).shape
(100, 32, 32, 16)
>>> np.fft.fft2(test_cp, axes=(1,2))[0][0][0]
array([ 121.36078 +0.j,  862.5427  +0.j, -478.19095 +0.j,   -3.937337+0.j,
        124.33441 +0.j,   42.13216 +0.j,  401.703   +0.j,   43.894173+0.j,
       -155.7095  +0.j,  513.4581  +0.j, -119.220665+0.j, -166.82913 +0.j,
       -954.76184 +0.j, -401.38803 +0.j, -189.80426 +0.j, -231.5777  +0.j],
      dtype=complex64)
>>> abs(np.fft.fft2(test_cp, axes=(1,2))[0][0][0])  # to compare directly to real numbers in torch
array([121.36078 , 862.5427  , 478.19095 ,   3.937337, 124.33441 ,
        42.13216 , 401.703   ,  43.894173, 155.7095  , 513.4581  ,
       119.220665, 166.82913 , 954.76184 , 401.38803 , 189.80426 ,
       231.5777  ], dtype=float32)

Pytorch
Looking at the real numbers from the output of (*, 2)
>>> torch.fft(layer_acts, signal_ndim=2).shape
torch.Size([100, 32, 32, 16, 2])
>>> torch.fft(layer_acts, signal_ndim=2)[:, :,:,:,0][0][0][0]
tensor([   6.9696,  -41.5982, -144.1784,  -54.1054,   -2.1185,  -78.1295,
          72.2305,  107.3909,  172.7782,  107.3909,   72.2305,  -78.1295,
          -2.1185,  -54.1054, -144.1784,  -41.5982], grad_fn=<SelectBackward>)

What makes the results different in the way numpy computes compared to torch?
Thanks!