ai.onnx.DFT

ai.onnx · standard ONNX operator · ONNX opset ≥ 20

Description

Computes the discrete Fourier Transform (DFT) of the input along a specified axis. For a signal of length N, output bin k is sum_{n=0}^{N-1} exp(-2*pi*j*k*n/N) * x[n]; the inverse divides by N and negates the exponent sign. Supports forward/inverse, real-to-complex (RFFT), and complex-to-real (IRFFT) modes via the onesided and inverse attributes.

See the ONNX DFT spec for the reference semantics.

Inputs

Name Bind key Logical dtype WebGPU storage Rank Shape Description Presence
input input T same as logical dtype Input signal tensor; the last dimension is 1 for real values or 2 for complex (real, imaginary) pairs. required
dft_length dft_length L same as logical dtype 0 Optional int32 scalar controlling the signal length used for the transform; input is zero-padded or truncated to this length. optional
axis axis I int32 0 Optional logical int64 scalar specifying the dimension over which to compute the DFT (the last axis is reserved for the real/imaginary component and is excluded); signed axes use int32 WebGPU storage and default to -2 when omitted. optional

Outputs

Name Bind key Logical dtype Rank Shape Description Presence
output output T same as input DFT result tensor; last dimension is 2 (complex) for forward DFT and RFFT, or 1 (real) for IRFFT. required

Attributes

Default values (overridable per request):

Attribute Default Description
inverse 0 When set to 1, computes the inverse DFT (IDFT/IRFFT) instead of the forward transform; default is 0 (forward).
onesided 0 When set to 1, exploits conjugate symmetry to return only the non-redundant half of the spectrum (RFFT for forward, IRFFT for inverse); default is 0 (full spectrum).

Type constraints

Variable Allowed dtypes
T float32
L int32
I int64

Files

Use with @huggingface/kernels

The loader automatically allocates outputs whose metadata it can derive from the manifest contract and this call.

The explicit outputs entries provide shape and logical dtype metadata for the results listed below:

  • output

Each entry either requests an optional result or supplies metadata that cannot be inferred from the inputs.

The version: 1 option selects the published kernel contract; it is independent of any operator opset, contrib since_version, or model version.

Replace each *Data placeholder with a typed array containing the corresponding input data.

import { getKernel } from "@huggingface/kernels";

const kernel = await getKernel("webgpu-kernels/ai.onnx.DFT", { version: 1 });
// Explicit destinations request optional results or supply metadata that cannot be inferred.
const { output } = await kernel({ input: { data: inputData, shape: [1, 1, 1, 1, 1, 1, 2, 1] } }, {
  outputs: { output: { shape: [1, 1, 1, 1, 1, 1, 2, 2], dtype: "float32" } },
});
Downloads last month
-
kernel
webgpu
wgsl
apache-2.0
WebGPU

Requires WebGPU support. See the compatibility table.