Discrete Fourier Transform (cupy.fft)#
Standard FFTs#
|
Compute the one-dimensional FFT. |
|
Compute the one-dimensional inverse FFT. |
|
Compute the two-dimensional FFT. |
|
Compute the two-dimensional inverse FFT. |
|
Compute the N-dimensional FFT. |
|
Compute the N-dimensional inverse FFT. |
Real FFTs#
|
Compute the one-dimensional FFT for real input. |
|
Compute the one-dimensional inverse FFT for real input. |
|
Compute the two-dimensional FFT for real input. |
|
Compute the two-dimensional inverse FFT for real input. |
|
Compute the N-dimensional FFT for real input. |
|
Compute the N-dimensional inverse FFT for real input. |
Hermitian FFTs#
|
Compute the FFT of a signal that has Hermitian symmetry. |
|
Compute the FFT of a signal that has Hermitian symmetry. |
Helper routines#
|
Return the FFT sample frequencies. |
|
Return the FFT sample frequencies for real input. |
|
Shift the zero-frequency component to the center of the spectrum. |
|
The inverse of |
CuPy-specific APIs#
CuPy has some additional configuration options available:
Normalization#
The default normalization (norm is "backward" or None) has the direct transforms unscaled and the inverse transforms scaled by \(1/n\).
If the keyword argument norm is "forward", it is the exact opposite of "backward":
the direct transforms are scaled by \(1/n\) and the inverse transforms are unscaled.
Finally, if the keyword argument norm is "ortho", both transforms are scaled by \(1/\sqrt{n}\).
Code compatibility features#
FFT functions of NumPy always return numpy.ndarray which type is numpy.complex128 or numpy.float64.
CuPy functions do not follow the behavior, they will return numpy.complex64 or numpy.float32 if the type of the input is numpy.float16, numpy.float32, or numpy.complex64.
Internally, cupy.fft always generates a cuFFT plan (see the cuFFT documentation for detail) corresponding to the desired transform. When possible, an n-dimensional plan will be used, as opposed to applying separate 1D plans for each axis to be transformed. Using n-dimensional planning can provide better performance for multidimensional transforms, but requires more GPU memory than separable 1D planning.
Moreover, the automatic plan generation can be suppressed by using an existing plan returned by cupyx.scipy.fftpack.get_fft_plan() as a context manager. This is again a deviation from NumPy.
Finally, when using the high-level NumPy-like FFT APIs as listed above, internally the cuFFT plans are cached for possible reuse. The plan cache can be retrieved by get_plan_cache(), and its current status can be queried by show_plan_cache_info(). For finer control of the plan cache, see PlanCache.
Multi-GPU FFT#
cupy.fft can use multiple GPUs. To enable (disable) this feature, set cupy.fft::config.use_multi_gpus to True (False). Next, to set the number of GPUs or the participating GPU IDs, use the function config.set_cufft_gpus(). All of the limitations listed in the cuFFT documentation apply here. In particular, using more than one GPU does not guarantee better performance.