Skip to content

Remove deprecated spectral ops from torch namespace#48594

Closed
peterbell10 wants to merge 2 commits intopytorch:masterfrom
peterbell10:remove-torch-fft-function
Closed

Remove deprecated spectral ops from torch namespace#48594
peterbell10 wants to merge 2 commits intopytorch:masterfrom
peterbell10:remove-torch-fft-function

Conversation

@peterbell10
Copy link
Copy Markdown
Collaborator

@peterbell10 peterbell10 commented Nov 30, 2020

BC-breaking change:

This PR, as the PR summary states, removes the deprecated torch.{fft,rfft,ifft,irfft} and their corresponding methods on torch.Tensor. PyTorch programs using these functions must now update to use the torch.fft namespace.

Original PR Summary:

Ref #42175

This removes the 4 deprecated spectral functions: torch.{fft,rfft,ifft,irfft}. torch.fft is also now imported by by default.

The actual at::native functions are still used in torch.stft so can't be full removed yet. But will once #47601 has been merged.

@dr-ci
Copy link
Copy Markdown

dr-ci Bot commented Nov 30, 2020

💊 CI failures summary and remediations

As of commit 99ff080 (more details on the Dr. CI page):


💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group.

See how this bot performed.

This comment has been revised 12 times.

@mruberry
Copy link
Copy Markdown
Collaborator

mruberry commented Nov 30, 2020

Hey @peterbell10! This is great. Just a couple more places to cleanup:

overrides

File "/opt/conda/lib/python3.6/site-packages/torch/overrides.py", line 397, in get_testing_overrides
Nov 30 20:30:18     torch.ifft: lambda input, signal_ndim, normalized=False: -1,

docs has issues like this:

Nov 30 19:56:55 /opt/conda/lib/python3.6/site-packages/torch/distributed/distributed_c10d.py:142: UserWarning: torch.distributed.reduce_op is deprecated, please use torch.distributed.ReduceOp instead
Nov 30 19:56:55   warnings.warn("torch.distributed.reduce_op is deprecated, please use "
Nov 30 19:57:17 WARNING: autodoc: failed to import method 'Tensor.fft' from module 'torch'; the following exception was raised:
Nov 30 19:57:17 Traceback (most recent call last):
Nov 30 19:57:17   File "/opt/conda/lib/python3.6/site-packages/sphinx/util/inspect.py", line 251, in safe_getattr
Nov 30 19:57:17     return getattr(obj, name, *defargs)
Nov 30 19:57:17 AttributeError: type object 'Tensor' has no attribute 'fft'

back compat needs an update, too:

Nov 30 19:55:46 Broken ops: [
Nov 30 19:55:46 	aten::fft(Tensor self, int signal_ndim, bool normalized=False) -> (Tensor)
Nov 30 19:55:46 	aten::irfft(Tensor self, int signal_ndim, bool normalized=False, bool onesided=True, int[] signal_sizes=[]) -> (Tensor)
Nov 30 19:55:46 	aten::rfft(Tensor self, int signal_ndim, bool normalized=False, bool onesided=True) -> (Tensor)
Nov 30 19:55:46 	aten::ifft(Tensor self, int signal_ndim, bool normalized=False) -> (Tensor)
Nov 30 19:55:46 ]

back compat needs entries here:

("__caffe2::RoIAlignRotated", datetime.date(2020, 11, 30)),

Comment thread test/cpp/api/fft.cpp Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Does fft.h need updates to prevent calling these functions from the C++ API, too?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

fft.h only deals with the fft module, the torch::fft functions was just generated by codegen so is gone completely. And actually as you point to this include, it's not needed any more since torch.h automatically includes the fft namespace as well now.

@peterbell10 peterbell10 force-pushed the remove-torch-fft-function branch from 0da6321 to 7052251 Compare November 30, 2020 21:58
@peterbell10 peterbell10 force-pushed the remove-torch-fft-function branch from 7052251 to 99ff080 Compare November 30, 2020 22:05
@ejguan ejguan added module: complex Related to complex number support in PyTorch triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Nov 30, 2020
"The function torch.fft is deprecated and will be removed in PyTorch 1.8. "
"Use the new torch.fft module functions, instead, by importing torch.fft "
"and calling torch.fft.fft or torch.fft.fftn.");
static Tensor fft(const Tensor& self, const int64_t signal_ndim, const bool normalized) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One question here. Why we need static? Is that because we want internal linkage for these functions so they are visible in this file only? (fft, ifft, rfft, irfft).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, the only remaining users (stft and istft) are in the same file. Marked static so we know for sure it isn't in the public API, or even used elsewhere internally.

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 1, 2020

Codecov Report

Merging #48594 (99ff080) into master (bdf360f) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master   #48594      +/-   ##
==========================================
- Coverage   80.91%   80.90%   -0.02%     
==========================================
  Files        1855     1855              
  Lines      200241   200225      -16     
==========================================
- Hits       162023   161988      -35     
- Misses      38218    38237      +19     

@mruberry
Copy link
Copy Markdown
Collaborator

mruberry commented Dec 2, 2020

Remember to ping when this is ready for another review ;)

@peterbell10
Copy link
Copy Markdown
Collaborator Author

Oh sorry, @mruberry PTAL.

Copy link
Copy Markdown
Collaborator

@mruberry mruberry left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks @peterbell10!

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@mruberry has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@mruberry
Copy link
Copy Markdown
Collaborator

mruberry commented Dec 3, 2020

FYI @peterbell10 this won't land immediately because some libraries will need time to update their deprecated code.

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@mruberry merged this pull request in 5180cae.

@mruberry
Copy link
Copy Markdown
Collaborator

mruberry commented Dec 6, 2020

@Balandat's cornellius-gp/linear_operator#11 unblocked this. Thanks again, @Balandat!

@peterbell10 peterbell10 mentioned this pull request Dec 16, 2020
37 tasks
@mruberry mruberry added the module: bc-breaking Related to a BC-breaking change label Jan 25, 2021
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
Summary:
Ref pytorch#42175

This removes the 4 deprecated spectral functions: `torch.{fft,rfft,ifft,irfft}`. `torch.fft` is also now imported by by default.

The actual `at::native` functions are still used in `torch.stft` so can't be full removed yet. But will once pytorch#47601 has been merged.

Pull Request resolved: pytorch#48594

Reviewed By: heitorschueroff

Differential Revision: D25298929

Pulled By: mruberry

fbshipit-source-id: e36737fe8192fcd16f7e6310f8b49de478e63bf0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed Merged module: bc-breaking Related to a BC-breaking change module: complex Related to complex number support in PyTorch module: fft open source triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants