torch.rfft has been moved
THasthika opened this issue · comments
torch.rfft
should be ported to torch.fft.rfft
nnAudio/Installation/nnAudio/Spectrogram.py
Line 566 in bf7a639
nnAudio/Installation/nnAudio/Spectrogram.py
Line 2254 in bf7a639
nnAudio/Installation/nnAudio/Spectrogram.py
Line 2257 in bf7a639
nnAudio/Installation/nnAudio/Spectrogram.py
Line 2443 in bf7a639
Hi THasthika, thanks for pointing it out! Indeed torch.rfft is not longer available since PyTorch 1.8. But it is better to keep the support for older versions, since torch.fft.rfft is not available before version 1.7.
One solution I can think of is to import rfft
functions differently based on the PyTorch version the user is using. Something similar to this stackoverflow post.
In our case it would be like
if torch.__version__<1.7:
import torch.rfft as rfft
else:
import torch.fft.rfft as rfft
Then in the main code, we replace torch.rfft
by rfft
.
Would you like to make a pull request? I am a little busy recently, so it might took me a while to check and do it myself.
@KinWaiCheuk It was not as simple as that since PyTorch has adopted the Complex data type for fft functions. I had to use the torch.fft.fft
to compute the equivalent in the newer versions. I've created a simple helper function rfft_fn
to determine the function to run.
Thanks for the quick pull request! The workflow you added is really helpful too.