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
Map PyTorch: 'aten:fft_fft' to NNEF.
fft_fftfreq
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
Map PyTorch: 'aten:fft_fftn' to NNEF (forward N-dim FFT).
fft_ifft
Map PyTorch: 'aten:fft_ifft' to NNEF.
fft_ifftn
Map PyTorch: 'aten:fft_ifftn' to NNEF (inverse N-dim FFT).
fft_irfft
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
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
Map aten::fft_rfftfreq(n, d, ...) to a NNEF constant.
istft
Map PyTorch: 'aten:istft' to NNEF.
Implements torch.istft for the common case (onesided=True,
normalized=False, return_complex=False, length=None). Decomposition:
- Build the Hermitian-symmetric full spectrum on the freq axis.
- Inverse FFT on the freq axis, divide by n_fft.
- Take the real part (slice the complex axis to [0:1] then squeeze).
- Multiply by
window(broadcast on the freq/time-of-frame axis). - Overlap-add via
deconvwith an identity kernel of size (n_fft, 1, n_fft) and stride=hop_length. - Divide by the precomputed OLA of
window**2to undo the per-sample window-weight accumulation. - If
center=True, slice offn_fft // 2samples from each end.