Pytorch equilvalent for Fourier based upsampling like scipy.signal.resample

I’ve been looking for a way to upsample time series arrays using pytorch. Currently I use scipy.signal.resample() which works great but there is a cost to transferring my data from device -> cpu to run this function.

  1. Is there a native pytorch function that does this? (note nn.functional.interpolate is linear as far as I can tell after plotting outputs).

  2. If not, is there a way to use scipy without transferring my arrays from device->cpu?

Thanks so much!

  1. I’m not sure how scipy implements resample, but maybe you can use the PyTorch Spectral OPs to mimic the function.

  2. Unfortunately not, since scipy uses numpy internally which only operates on the CPU.

Ok, thanks. I ended up calling on the expertise of one of our colleagues and he wrote a cuda function that does Bspline interpolation. If there is time/interest, perhaps that could eventually be developed to be shared with the community.

1 Like

Hey @catubc , I’m having the exact same problem, any chance you could share the interpolation code? Thanks!

Hi Kiran. I’m not sure you will find the interpolation code as useful as it has become quite complex and has been over-adapted to our specific problem which is not requires precomputation of bspline coefficients using scipy. In other words, this will be very slow for most problems. It’s also proprietary by the code-developer, but I can ask him to see if he’ll share it.

May be its too late, but I wrote a code for the same
The code can be found at My GitHub Code and also I wrote a small article for the same on PyTorch Discuss