Skip to content

Conversation

@simonbyrne
Copy link

Description

Adds support for the DFT operator when onesided=True and inverse=True (corresponding to the irfft operation in numpy and pytorch).

Motivation and Context

This addresses issue onnx/onnx#5920, and adds support to the changes in onnx/onnx#7574.

Signed-off-by: Simon Byrne <sbyrne@nvidia.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds CPU EP support for DFT with onesided=True and inverse=True (IRFFT semantics) and expands test coverage for IRFFT and rank-2 inputs.

Changes:

  • Implement IRFFT handling in radix-2 FFT path (conjugate symmetry reconstruction + real-valued output).
  • Implement IRFFT handling in Bluestein path (conjugate symmetry reconstruction + real-valued output).
  • Add new unit tests for IRFFT (radix-2, Bluestein, round-trip) and rank-2 real/complex DFT inputs.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
onnxruntime/core/providers/cpu/signal/dft.cc Adds IRFFT support and adjusts shape/output handling for inverse && onesided.
onnxruntime/test/providers/cpu/signal/signal_ops_test.cc Adds IRFFT test cases and rank-2 DFT/RFFT coverage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Simon Byrne <sbyrne@nvidia.com>
justinchuby pushed a commit to microsoft/onnxscript that referenced this pull request Jan 23, 2026
This fixes the onnxscript export for the irfft function. 

Fixes onnx/onnx#5920, and adds support to the
changes in onnx/onnx#7574 and
microsoft/onnxruntime#27028.

Most of the diff is due to the onnx_opset generated code changes from
onnx/onnx#5920. That can be removed if you
would prefer.

---------

Signed-off-by: Simon Byrne <sbyrne@nvidia.com>
Signed-off-by: Simon Byrne <sbyrne@nvidia.com>
Signed-off-by: Simon Byrne <sbyrne@nvidia.com>
Signed-off-by: Simon Byrne <sbyrne@nvidia.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// For opset 17-19, just pass through
} else {
// For opset 20, pass dft_length and axis to IRFFT
assert(graph_inputs.size() == 3);
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using plain assert(...) here can be compiled out in release builds, which would turn a violated assumption (e.g., unexpected graph_inputs size) into an out-of-bounds access when indexing graph_inputs[1/2]. Prefer ASSERT_*/EXPECT_* (gtest) or ORT_ENFORCE so the check remains active and fails with a clear message.

Suggested change
assert(graph_inputs.size() == 3);
ASSERT_EQ(graph_inputs.size(), static_cast<size_t>(3));

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert is used elsewhere: is there a convention in the codebase?

simonbyrne and others added 2 commits January 23, 2026 16:07
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Simon Byrne <sbyrne@nvidia.com>
@istupakov
Copy link

Hi @simonbyrne!
It's great that irfft is now supported by ONNX. Is there any hope for improving DFT/STFT performance? Currently, they run about 20 times slower than numpy on CPU and are not supported via CUDAExecutionProvider. When applied to ASR, this means that spectrogram calculations can take longer than the speech recognition itself...

@simonbyrne
Copy link
Author

It's great that irfft is now supported by ONNX. Is there any hope for improving DFT/STFT performance? Currently, they run about 20 times slower than numpy on CPU and are not supported via CUDAExecutionProvider. When applied to ASR, this means that spectrogram calculations can take longer than the speech recognition itself...

Yes, you should use an existing optimized FFT library (e.g. FFTW or cuFFT) 😄

If you want a simpler option, you may just be able to call into PocketFFT (which is used by NumPy, and should already included as its a dependency)

@simonbyrne
Copy link
Author

PocketFFT is actually header-only (https://github.com/mreineck/pocketfft), that would be the easiest option by far (FFTW is fast, but it is GPL licensed which might be a sticking point).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants