DFT

DFT - 20

Version

  • name: DFT (GitHub)

  • domain: main

  • since_version: 20

  • function: False

  • support_level: SupportType.COMMON

  • shape inference: True

This version of the operator has been available since version 20.

Summary

Computes the discrete Fourier Transform (DFT) of the input.

Assuming the input has shape [M, N], where N is the dimension over which the DFT is computed and M denotes the conceptual “all other dimensions,” the DFT y[m, k] of shape [M, N] is defined as

\[y[m, k] = \sum_{n=0}^{N-1} e^{-2 \pi j \frac{k n}{N} } x[m, n] ,\]

and the inverse transform is defined as

\[x[m, n] = \frac{1}{N} \sum_{k=0}^{N-1} e^{2 \pi j \frac{k n}{N} } y[m, k] ,\]

where \(j\) is the imaginary unit.

The actual shape of the output is specified in the “output” section.

Reference: https://docs.scipy.org/doc/scipy/tutorial/fft.html

Attributes

  • inverse - INT (default is '0'):

    Whether to perform the inverse discrete Fourier Transform. Default is 0, which corresponds to false.

  • onesided - INT (default is '0'):

    If onesided is 1 and input is real, only values for k in [0, 1, 2, ..., floor(n_fft/2) + 1] are returned because the real-to-complex Fourier transform satisfies the conjugate symmetry, i.e., X[m, k] = X[m, n_fft-k]*, where m denotes “all other dimensions” DFT was not applied on. If the input tensor is complex, onesided output is not possible. Value can be 0 or 1. Default is 0.

Inputs

Between 1 and 3 inputs.

  • input (heterogeneous) - T1:

    For real input, the following shape is expected: [signal_dim0][signal_dim1][signal_dim2]...[signal_dimN][1]. For complex input, the following shape is expected: [signal_dim0][signal_dim1][signal_dim2]...[signal_dimN][2]. The final dimension represents the real and imaginary parts of the value in that order.

  • dft_length (optional, heterogeneous) - T2:

    The length of the signal as a scalar. If greater than the axis dimension, the signal will be zero-padded up to dft_length. If less than the axis dimension, only the first dft_length values will be used as the signal.

  • axis (optional, heterogeneous) - tensor(int64):

    The axis as a scalar on which to perform the DFT. Default is -2 (last signal axis). Negative value means counting dimensions from the back. Accepted range is \([-r, -2] \cup [0, r-2]\) where r = rank(input). The last dimension is for representing complex numbers and thus is an invalid axis.

Outputs

  • output (heterogeneous) - T1:

    The Fourier Transform of the input vector. If onesided is 0, the following shape is expected: [signal_dim0][signal_dim1][signal_dim2]...[signal_dimN][2]. If axis=0 and onesided is 1, the following shape is expected: [floor(signal_dim0/2)+1][signal_dim1][signal_dim2]...[signal_dimN][2]. If axis=1 and onesided is 1, the following shape is expected: [signal_dim0][floor(signal_dim1/2)+1][signal_dim2]...[signal_dimN][2]. If axis=N and onesided is 1, the following shape is expected: [signal_dim0][signal_dim1][signal_dim2]...[floor(signal_dimN/2)+1][2]. The signal_dim at the specified axis is equal to the dft_length.

Type Constraints

  • T1 in ( tensor(bfloat16), tensor(double), tensor(float), tensor(float16) ):

    Constrain input and output types to float tensors.

  • T2 in ( tensor(int32), tensor(int64) ):

    Constrain scalar length types to integers.

DFT - 17

Version

  • name: DFT (GitHub)

  • domain: main

  • since_version: 17

  • function: False

  • support_level: SupportType.COMMON

  • shape inference: True

This version of the operator has been available since version 17.

Summary

Computes the discrete Fourier transform of input.

Attributes

  • axis - INT (default is '1'):

    The axis on which to perform the DFT. By default this value is set to 1, which corresponds to the first dimension after the batch index. Negative value means counting dimensions from the back. Accepted range is \([-r, -2] \cup [0, r-2]\) where r = rank(input). The last dimension is for representing complex numbers and thus is an invalid axis.

  • inverse - INT (default is '0'):

    Whether to perform the inverse discrete fourier transform. By default this value is set to 0, which corresponds to false.

  • onesided - INT (default is '0'):

    If onesided is 1, only values for w in [0, 1, 2, …, floor(n_fft/2) + 1] are returned because the real-to-complex Fourier transform satisfies the conjugate symmetry, i.e., X[m, w] = X[m, n_fft-w]*. Note if the input or window tensors are complex, then onesided output is not possible. Enabling onesided with real inputs performs a Real-valued fast Fourier transform (RFFT). When invoked with real or complex valued input, the default value is 0. Values can be 0 or 1.

Inputs

Between 1 and 2 inputs.

  • input (heterogeneous) - T1:

    For real input, the following shape is expected: [batch_idx][signal_dim1][signal_dim2]…[signal_dimN][1]. For complex input, the following shape is expected: [batch_idx][signal_dim1][signal_dim2]…[signal_dimN][2]. The first dimension is the batch dimension. The following N dimensions correspond to the signal’s dimensions. The final dimension represents the real and imaginary parts of the value in that order.

  • dft_length (optional, heterogeneous) - T2:

    The length of the signal as a scalar. If greater than the axis dimension, the signal will be zero-padded up to dft_length. If less than the axis dimension, only the first dft_length values will be used as the signal. It’s an optional value.

Outputs

  • output (heterogeneous) - T1:

    The Fourier Transform of the input vector. If onesided is 0, the following shape is expected: [batch_idx][signal_dim1][signal_dim2]…[signal_dimN][2]. If axis=1 and onesided is 1, the following shape is expected: [batch_idx][floor(signal_dim1/2)+1][signal_dim2]…[signal_dimN][2]. If axis=2 and onesided is 1, the following shape is expected: [batch_idx][signal_dim1][floor(signal_dim2/2)+1]…[signal_dimN][2]. If axis=N and onesided is 1, the following shape is expected: [batch_idx][signal_dim1][signal_dim2]…[floor(signal_dimN/2)+1][2]. The signal_dim at the specified axis is equal to the dft_length.

Type Constraints

  • T1 in ( tensor(bfloat16), tensor(double), tensor(float), tensor(float16) ):

    Constrain input and output types to float tensors.

  • T2 in ( tensor(int32), tensor(int64) ):

    Constrain scalar length types to int64_t.