Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[torchlib] Fix _fft_c2r #1844

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

justinchuby
Copy link
Collaborator

@justinchuby justinchuby commented Sep 3, 2024

Fix #1271

Copy link

codecov bot commented Sep 3, 2024

Codecov Report

Attention: Patch coverage is 10.81081% with 33 lines in your changes missing coverage. Please review.

Project coverage is 74.92%. Comparing base (2e45a32) to head (af7a47c).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
onnxscript/function_libs/torch_lib/ops/fft.py 10.81% 33 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1844      +/-   ##
==========================================
- Coverage   75.07%   74.92%   -0.15%     
==========================================
  Files         249      249              
  Lines       27046    27060      +14     
  Branches     4943     4945       +2     
==========================================
- Hits        20304    20276      -28     
- Misses       5797     5839      +42     
  Partials      945      945              

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

@justinchuby
Copy link
Collaborator Author

@justinchuby
Copy link
Collaborator Author

@justinchuby
Copy link
Collaborator Author

Just specify dft_length

@@ -1,7 +1,5 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation.

Check warning

Code scanning / lintrunner

RUFF-FORMAT/format Warning

Run lintrunner -a to apply this patch.
@@ -1,7 +1,5 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Copyright (c) Microsoft Corporation.

Check warning

Code scanning / lintrunner

RUFF/format Warning

Run lintrunner -a to apply this patch.
@@ -12,7 +10,7 @@

from __future__ import annotations

from typing import Optional, Sequence
from typing import Literal, Optional, Sequence

Check warning

Code scanning / lintrunner

PYLINT/W0611 Warning

Unused Literal imported from typing (unused-import)
See unused-import. To disable, use # pylint: disable=unused-import
@@ -12,7 +10,7 @@

from __future__ import annotations

from typing import Optional, Sequence
from typing import Literal, Optional, Sequence

Check warning

Code scanning / lintrunner

RUFF/F401 Warning

typing.Literal imported but unused.
See https://docs.astral.sh/ruff/rules/unused-import
dims: Sequence[int],
forward: bool,

Check warning

Code scanning / lintrunner

PYLINT/W0613 Warning

Unused argument 'forward' (unused-argument)
See unused-argument. To disable, use # pylint: disable=unused-argument
result = transformed
transformed = self

signal_size = _compute_signal_size(self, dims, last_dim_size)

Check warning

Code scanning / lintrunner

PYLINT/W0612 Warning

Unused variable 'signal_size' (unused-variable)
See unused-variable. To disable, use # pylint: disable=unused-variable
# If normalization is 1/n and we are in backward mode, we use the inverse
# mode in ONNX to get the 1/n normalization.
inverse = normalization == 2 and not forward
ortho = normalization == 1

Check warning

Code scanning / lintrunner

RUFF/F841 Warning

Local variable ortho is assigned to but never used.
See https://docs.astral.sh/ruff/rules/unused-variable

# Remove the batch dimension
transformed = op.Squeeze(transformed, axes=[0])
normalized = _fftn_onnx_normalization(

Check failure

Code scanning / lintrunner

PYLINT/E0602 Error

Undefined variable '_fftn_onnx_normalization' (undefined-variable)
See undefined-variable. To disable, use # pylint: disable=undefined-variable

# Remove the batch dimension
transformed = op.Squeeze(transformed, axes=[0])
normalized = _fftn_onnx_normalization(

Check failure

Code scanning / lintrunner

RUFF/F821 Error

Undefined name \_fftn\_onnx\_normalization.
See https://docs.astral.sh/ruff/rules/undefined-name
self_rank = len(self.shape)
# ONNX DFT input assumes the last dimension is the complex dimension.
# Thus dim=-1 in PyTorch is dim=-2 in ONNX.
dim = [(d - 1) + self_rank if d < 0 else d for d in dim]
transformed = _fftn_onnx(self, dim, normalization, inverse=True, onesided=False)
transformed = _fftn_onnx(

Check failure

Code scanning / lintrunner

PYLINT/E1123 Error

Unexpected keyword argument 'inverse' in function call (unexpected-keyword-arg)
See unexpected-keyword-arg. To disable, use # pylint: disable=unexpected-keyword-arg
self_rank = len(self.shape)
# ONNX DFT input assumes the last dimension is the complex dimension.
# Thus dim=-1 in PyTorch is dim=-2 in ONNX.
dim = [(d - 1) + self_rank if d < 0 else d for d in dim]
transformed = _fftn_onnx(self, dim, normalization, inverse=True, onesided=False)
transformed = _fftn_onnx(

Check failure

Code scanning / lintrunner

PYLINT/E1120 Error

No value for argument 'forward' in function call (no-value-for-parameter)
See no-value-for-parameter. To disable, use # pylint: disable=no-value-for-parameter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

[torchlib] IRFFT implementation is not correct
2 participants