Clarify DFT behavior when inverse=True and onesided=True (irfft)#7574
Clarify DFT behavior when inverse=True and onesided=True (irfft)#7574justinchuby merged 4 commits intoonnx:mainfrom
Conversation
4231816 to
9e3ed06
Compare
Codecov Report❌ Patch coverage is
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. |
|
@onnx/sig-operators |
There was a problem hiding this comment.
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=1andinverse=1from 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 |
|
@simonbyrne could you please check CI errors and help update the shape inference code? |
|
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) |
justinchuby
left a comment
There was a problem hiding this comment.
LGTM in general. A few nitpicking comments
74e681f to
98b353f
Compare
Signed-off-by: Simon Byrne <sbyrne@nvidia.com>
Signed-off-by: Simon Byrne <sbyrne@nvidia.com>
Signed-off-by: Simon Byrne <sbyrne@nvidia.com>
98b353f to
ccf022b
Compare
|
@gramalingam for a second review. |
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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>
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).