FFT Functions

Standard FFTs

cupy.fft.fft

Compute the one-dimensional FFT.

cupy.fft.ifft

Compute the one-dimensional inverse FFT.

cupy.fft.fft2

Compute the two-dimensional FFT.

cupy.fft.ifft2

Compute the two-dimensional inverse FFT.

cupy.fft.fftn

Compute the N-dimensional FFT.

cupy.fft.ifftn

Compute the N-dimensional inverse FFT.

Real FFTs

cupy.fft.rfft

Compute the one-dimensional FFT for real input.

cupy.fft.irfft

Compute the one-dimensional inverse FFT for real input.

cupy.fft.rfft2

Compute the two-dimensional FFT for real input.

cupy.fft.irfft2

Compute the two-dimensional inverse FFT for real input.

cupy.fft.rfftn

Compute the N-dimensional FFT for real input.

cupy.fft.irfftn

Compute the N-dimensional inverse FFT for real input.

Hermitian FFTs

cupy.fft.hfft

Compute the FFT of a signal that has Hermitian symmetry.

cupy.fft.ihfft

Compute the FFT of a signal that has Hermitian symmetry.

Helper routines

cupy.fft.fftfreq

Return the FFT sample frequencies.

cupy.fft.rfftfreq

Return the FFT sample frequencies for real input.

cupy.fft.fftshift

Shift the zero-frequency component to the center of the spectrum.

cupy.fft.ifftshift

The inverse of fftshift().

cupy.fft._cache.PlanCache

A per-thread, per-device, least recently used (LRU) cache for cuFFT plans.

cupy.fft.config.set_cufft_gpus

Set the GPUs to be used in multi-GPU FFT.

cupy.fft.config.get_plan_cache

Get the per-thread, per-device plan cache, or create one if not found.

cupy.fft.config.show_plan_cache_info

Show all of the plan caches’ info on this thread.

Normalization

The default normalization has the direct transforms unscaled and the inverse transforms are scaled by \(1/n\). If the ketyword argument norm is "ortho", both transforms will be scaled by \(1/\sqrt{n}\).

Code compatibility features

FFT functions of NumPy alway 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. The user can disable n-dimensional planning by setting cupy.fft.config.enable_nd_planning = False. This ability to adjust the planning type is a deviation from the NumPy API, which does not use precomputed FFT plans.

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.

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 cupy.fft.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.