Skip to content

fft

torch_to_nnef.op.aten.fft

Aten FFT/STFT/ISTFT handlers mapping to NNEF ops.

Contains helpers for complex layout handling and tract-core FFT glue.

fft_fft

fft_fft(g, node, name_to_tensor, inference_target, **kwargs)

Map PyTorch: 'aten:fft_fft' to NNEF.

fft_fftfreq

fft_fftfreq(g, node, name_to_tensor, **kwargs)

Map aten::fft_fftfreq(n, d, ...) to a NNEF constant.

torch.fft.fftfreq(n, d) is fully determined by n and d; the common trace-time path already sees both as Python constants.

fft_fftn

fft_fftn(g, node, name_to_tensor, inference_target, **kwargs)

Map PyTorch: 'aten:fft_fftn' to NNEF (forward N-dim FFT).

fft_ifft

fft_ifft(g, node, name_to_tensor, inference_target, **kwargs)

Map PyTorch: 'aten:fft_ifft' to NNEF.

fft_ifftn

fft_ifftn(g, node, name_to_tensor, inference_target, **kwargs)

Map PyTorch: 'aten:fft_ifftn' to NNEF (inverse N-dim FFT).

fft_irfft

fft_irfft(g, node, name_to_tensor, inference_target, **kwargs)

Map PyTorch: 'aten:fft_irfft' to NNEF.

One-sided complex spectrum -> real signal of length n (defaults to 2 * (K - 1) where K = input.shape[dim]). Reconstruct the Hermitian-symmetric full spectrum: take the slice [1, K-1), reverse it on dim, conjugate (negate imag), concat after the input -> (..., n, 2); run an inverse FFT; divide by n; drop the imaginary part.

fft_rfft

fft_rfft(g, node, name_to_tensor, inference_target, **kwargs)

Map PyTorch: 'aten:fft_rfft' to NNEF.

Real input -> one-sided complex spectrum on dim. Mirrors fft_fft (pad to complex, run tract_core_fft) then slices the FFT axis to the first N // 2 + 1 bins.

fft_rfftfreq

fft_rfftfreq(g, node, name_to_tensor, **kwargs)

Map aten::fft_rfftfreq(n, d, ...) to a NNEF constant.

istft

istft(g, node, name_to_tensor, inference_target, **kwargs)

Map PyTorch: 'aten:istft' to NNEF.

Implements torch.istft for the common case (onesided=True, normalized=False, return_complex=False, length=None). Decomposition:

  1. Build the Hermitian-symmetric full spectrum on the freq axis.
  2. Inverse FFT on the freq axis, divide by n_fft.
  3. Take the real part (slice the complex axis to [0:1] then squeeze).
  4. Multiply by window (broadcast on the freq/time-of-frame axis).
  5. Overlap-add via deconv with an identity kernel of size (n_fft, 1, n_fft) and stride=hop_length.
  6. Divide by the precomputed OLA of window**2 to undo the per-sample window-weight accumulation.
  7. If center=True, slice off n_fft // 2 samples from each end.

stft

stft(g, node, name_to_tensor, inference_target, **kwargs)

Map PyTorch: 'aten:stft' to NNEF.