nvmath.fft.FFTOptions

class nvmath.fft.FFTOptions(fft_type: Literal['C2C', 'C2R', 'R2C'] | None = None, inplace: bool = False, last_axis_size: Literal['even', 'odd'] | None = 'even', result_layout: Literal['natural', 'optimized'] | None = 'optimized', device_id: int | None = None, logger: Logger | None = None, blocking: Literal[True, 'auto'] = 'auto', allocator: BaseCUDAMemoryManager | None = None)[source]

A data class for providing options to the FFT object and the family of wrapper functions fft(), ifft(), rfft(), and irfft().

fft_type

The type of FFT to perform, available options include 'C2C', 'C2R', and 'R2C'. The default is 'C2C' for complex input and 'R2C' for real input.

Type:

Literal[‘C2C’, ‘C2R’, ‘R2C’] | None

inplace

Specify if the operation is in-place (True or False). The operand is overwritten by the result if inplace is True. The default is False.

Type:

bool

last_axis_size

For complex-to-real FFT (corresponding to fft_type='C2R'), specify whether the size of the last axis in the result should be even or odd. The even size is calculated as \(2 * (m - 1)\), where \(m\) is the the size of the last axis of the operand, and the odd size is calculated as \(2 * (m - 1) + 1\). The specified value should be either 'even' or 'odd', with the default being 'even'.

Type:

Literal[‘even’, ‘odd’] | None

result_layout

The layout to use for the result, either 'natural' or 'optimized'. For the 'natural' option, the result layout is the same as that of the operand. The default is 'optimized', which generally provides much better performance and should be used if the user doesn’t care about the result layout matching the operand layout. However in rare cases, depending on the device type, shape and strides of the operand, and the FFT dimensions, the 'natural' layout may perform better. This option is ignored if inplace is specified to be True.

Type:

Literal[‘natural’, ‘optimized’] | None

device_id

CUDA device ordinal (used if the operand resides on the CPU). Device 0 will be used if not specified.

Type:

int | None

logger

Python Logger object. The root logger will be used if a logger object is not provided.

Type:

logging.Logger

executor

Specify the execution policy (single-gpu, CPU). Currently not supported.

blocking

A flag specifying the behavior of the execution functions and methods, such as fft() and FFT.execute(). When blocking is True, the execution methods do not return until the operation is complete. When blocking is "auto", the methods return immediately when the input tensor is on the GPU. The execution methods always block when the input tensor is on the CPU to ensure that the user doesn’t inadvertently use the result before it becomes available. The default is "auto".

Type:

Literal[True, ‘auto’]

allocator

An object that supports the BaseCUDAMemoryManager protocol, used to draw device memory. If an allocator is not provided, a memory allocator from the library package will be used (torch.cuda.caching_allocator_alloc() for PyTorch operands, cupy.cuda.alloc() otherwise).

Type:

nvmath.memory.BaseCUDAMemoryManager | None

See also

FFT, fft(), ifft(), rfft(), and irfft()