torch.fft.fft — PyTorch 2.7 documentation (original) (raw)

torch.fft.fft(input, n=None, dim=-1, norm=None, *, out=None) → Tensor

Computes the one dimensional discrete Fourier transform of input.

Note

The Fourier domain representation of any real signal satisfies the Hermitian property: X[i] = conj(X[-i]). This function always returns both the positive and negative frequency terms even though, for real inputs, the negative frequencies are redundant. rfft() returns the more compact one-sided representation where only the positive frequencies are returned.

Note

Supports torch.half and torch.chalf on CUDA with GPU Architecture SM53 or greater. However it only supports powers of 2 signal length in every transformed dimension.

Parameters

Keyword Arguments

out (Tensor, optional) – the output tensor.

Example

t = torch.arange(4) t tensor([0, 1, 2, 3]) torch.fft.fft(t) tensor([ 6.+0.j, -2.+2.j, -2.+0.j, -2.-2.j])

t = torch.tensor([0.+1.j, 2.+3.j, 4.+5.j, 6.+7.j]) torch.fft.fft(t) tensor([12.+16.j, -8.+0.j, -4.-4.j, 0.-8.j])