Skip to content

Clarify DFT behavior when inverse=True and onesided=True (irfft)#7574

Merged
justinchuby merged 4 commits intoonnx:mainfrom
simonbyrne:sb/dft-irfft
Jan 26, 2026
Merged

Clarify DFT behavior when inverse=True and onesided=True (irfft)#7574
justinchuby merged 4 commits intoonnx:mainfrom
simonbyrne:sb/dft-irfft

Conversation

@simonbyrne
Copy link
Copy Markdown
Contributor

Motivation and Context

Fixes #5920.

This adds some clarity around the behavior of DFT inverse operations, and fully specifies the behavior when inverse=True and onesided=True (corresponding to the irfft operation in numpy and pytorch).

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 15, 2026

Codecov Report

❌ Patch coverage is 55.00000% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.24%. Comparing base (2eb3d99) to head (45763d7).
⚠️ Report is 13 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
onnx/backend/test/case/node/dft.py 0.00% 26 Missing ⚠️
onnx/reference/ops/op_dft.py 94.44% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7574      +/-   ##
==========================================
- Coverage   55.24%   55.24%   -0.01%     
==========================================
  Files         515      515              
  Lines       32356    32400      +44     
  Branches     2894     2896       +2     
==========================================
+ Hits        17876    17898      +22     
- Misses      13690    13713      +23     
+ Partials      790      789       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@justinchuby
Copy link
Copy Markdown
Member

@onnx/sig-operators

Copy link
Copy Markdown
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

This PR clarifies the behavior of the DFT operator when both inverse=True and onesided=True are set, which corresponds to the inverse real FFT (IRFFT) operation. Previously, this combination was prohibited, but it's now properly supported with appropriate validation and documentation.

Changes:

  • Removes the restriction preventing onesided=1 and inverse=1 from being used together
  • Adds input validation to ensure RFFT requires real input and IRFFT requires complex input
  • Updates documentation and output shape descriptions for all three DFT modes: standard DFT, RFFT, and IRFFT
  • Adds comprehensive test coverage for IRFFT functionality

Reviewed changes

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

Show a summary per file
File Description
onnx/defs/math/old.cc Updates DFT v17 operator schema with IRFFT support, input validation, and corrected shape inference
onnx/defs/math/defs.cc Updates DFT v20 operator schema with IRFFT support, input validation, and corrected shape inference
onnx/reference/ops/op_dft.py Implements IRFFT functionality with proper default dft_length calculation
onnx/test/shape_inference_test.py Adds IRFFT shape inference tests and input validation tests, removes invalid test case
onnx/backend/test/case/node/dft.py Adds end-to-end RFFT and IRFFT test cases for both opset 19 and 20

Comment thread onnx/backend/test/case/node/dft.py
Comment thread onnx/backend/test/case/node/dft.py
Comment thread onnx/backend/test/case/node/dft.py
Comment thread onnx/backend/test/case/node/dft.py
@justinchuby justinchuby added this to the 1.21 milestone Jan 21, 2026
@justinchuby
Copy link
Copy Markdown
Member

@simonbyrne could you please check CI errors and help update the shape inference code?

@justinchuby justinchuby changed the title clarify DFT behavior when inverse=True and onesided=True (irfft) Clarify DFT behavior when inverse=True and onesided=True (irfft) Jan 21, 2026
@simonbyrne
Copy link
Copy Markdown
Contributor Author

Okay, I think I fixed it.

I deleted a few tests which were invalid (they were testing the onesided=true case with complex inputs, which doesn't make any sense). I'm not sure if that counts as a breaking change (it will now error at the shape inference stage, instead of returning a nonsensical result)

Comment thread onnx/defs/math/old.cc
Copy link
Copy Markdown
Member

@justinchuby justinchuby left a comment

Choose a reason for hiding this comment

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

LGTM in general. A few nitpicking comments

@github-project-automation github-project-automation Bot moved this from In progress to Reviewer approved in PR Tracker Jan 22, 2026
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
Copy Markdown
Member

@justinchuby justinchuby left a comment

Choose a reason for hiding this comment

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

LGTM thanks!

@justinchuby
Copy link
Copy Markdown
Member

@gramalingam for a second review.

@justinchuby justinchuby added the auto update doc Generate md/proto files automatically using the CI pipeline label Jan 23, 2026
@github-project-automation github-project-automation Bot moved this from Reviewer approved to Done in PR Tracker Jan 23, 2026
@justinchuby justinchuby reopened this Jan 23, 2026
@github-project-automation github-project-automation Bot moved this from Done to In progress in PR Tracker Jan 23, 2026
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@justinchuby justinchuby reopened this Jan 23, 2026
@github-project-automation github-project-automation Bot moved this from In progress to Done in PR Tracker Jan 23, 2026
@github-project-automation github-project-automation Bot moved this from Done to In progress in PR Tracker Jan 23, 2026
@justinchuby justinchuby removed the auto update doc Generate md/proto files automatically using the CI pipeline label Jan 23, 2026
@justinchuby justinchuby requested a review from Copilot January 23, 2026 02:00
Copy link
Copy Markdown
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 9 out of 23 changed files in this pull request and generated no new comments.

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>
Comment thread onnx/defs/math/old.cc
@justinchuby justinchuby enabled auto-merge (squash) January 26, 2026 19:56
@justinchuby justinchuby merged commit ee910d0 into onnx:main Jan 26, 2026
52 of 53 checks passed
@github-project-automation github-project-automation Bot moved this from In progress to Done in PR Tracker Jan 26, 2026
@simonbyrne simonbyrne deleted the sb/dft-irfft branch January 26, 2026 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review needed: operators approvers Require reviews from members of operators-approvers topic: operator Issues related to ONNX operators

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Clarify DFT behavior when inverse=True

4 participants