Skip to content

Add FFT extension to the spec - #189

Merged
leofang merged 37 commits into
data-apis:mainfrom
steff456:add-fft-extension
Oct 20, 2022
Merged

Add FFT extension to the spec#189
leofang merged 37 commits into
data-apis:mainfrom
steff456:add-fft-extension

Conversation

@steff456

@steff456steff456 commented Jun 4, 2021

Copy link
Copy Markdown
Member

This PR focuses on adding the FFT as an extension to the array spec.

The current APIs added in this PR are:

  • Standard FFT: fft, ifft, fftn, ifftn
  • Real FFT: rfft, irfft, rfftn, irfftn
  • Hermitian FFT: hfft, ihfft
  • Helper Routines: fftfreq, rfftfreq, fftshift, ifftshift
  • Update to rst and create function stubs

They follow the summary available at #159. Close#476.

@steff456steff456 self-assigned this Jun 4, 2021
@rgommersrgommers added the API extension Adds new functions or objects to the API. label Jun 7, 2021

@rgommersrgommers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @steff456, this looks good overall, just some small comments.

Comment threadspec/extensions/index.rst Outdated
Comment threadspec/extensions/fast_fourier_transform_functions.md Outdated
Comment threadspec/extensions/fast_fourier_transform_functions.md Outdated
Comment threadspec/extensions/fast_fourier_transform_functions.md Outdated
@steff456
steff456 marked this pull request as ready for review June 8, 2021 19:22
@steff456
steff456 requested a review from kgryteJune 8, 2021 19:42

@leofangleofang left a comment

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.

Great work @steff456! Thanks for putting these together. Based on the recent discussion summarized in #159 (comment), could you remove all *fft2 APIs? Thanks.

@leofangleofang left a comment

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.

Sorry for my late response @steff456...I just reviewed {i}fft and {i}fftn and left some comments. We should reorder the list so that each pair of transforms appears together (see my comment below). I'll try to resume tomorrow...😅

Comment threadspec/extensions/fourier_transform_functions.md Outdated
Comment threadspec/extensions/fourier_transform_functions.md Outdated
Comment threadspec/extensions/fourier_transform_functions.md Outdated
Comment threadspec/extensions/fourier_transform_functions.md Outdated
Comment threadspec/extensions/fourier_transform_functions.md Outdated
Comment threadspec/extensions/fourier_transform_functions.md Outdated
Comment threadspec/extensions/fourier_transform_functions.md Outdated
Comment threadspec/extensions/fourier_transform_functions.md Outdated
Comment threadspec/extensions/fourier_transform_functions.md Outdated
Comment threadspec/extensions/fourier_transform_functions.md Outdated
@steff456

Copy link
Copy Markdown
MemberAuthor

@leofang I already made the changes, please let me know if there's something else we can improve here :)

@leofangleofang mentioned this pull request Jul 22, 2021

@leofangleofang left a comment

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.

Thank you, @steff456! I have reviewed fft/ifft/fftn/ifftn/rfft/irfft/rfftn/irfftn. I think C2C transforms (fft/ifft/fftn/ifftn) are in good shape now, but more work is needed for R2C/C2R transforms as the behavior is a bit messy and confusing. I hope we could find another pair of eyes to go over these.

I will try to finish the rest of reviews (hfft, fftfreq, etc) asap...

Comment threadspec/extensions/fourier_transform_functions.md Outdated
Comment threadspec/extensions/fourier_transform_functions.md Outdated
Comment threadspec/extensions/fourier_transform_functions.md Outdated
Comment threadspec/extensions/fourier_transform_functions.md Outdated
Comment threadspec/extensions/fourier_transform_functions.md Outdated
Comment threadspec/extensions/fourier_transform_functions.md Outdated
Comment threadspec/extensions/fourier_transform_functions.md Outdated
Comment threadspec/extensions/fourier_transform_functions.md Outdated
Comment threadspec/extensions/fourier_transform_functions.md Outdated
Comment threadspec/extensions/fourier_transform_functions.md Outdated
Comment threadspec/extensions/fourier_transform_functions.md Outdated
@kgryte

Copy link
Copy Markdown
Contributor

@steff456 The table looks correct. Thanks for putting that together.

@leofangleofang left a comment

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.

Sorry for delay. I reviewed all functions but rfftn and irfftn, as there are still errors to be ironed out in the R2C/C2R(-like) transforms. I also have a few proposals to simplify the standard, see my comments below.

Note that the input/output data types should be taken care, as noted in previous rounds of review, including:

  1. input data type promotion when applicable (pending #478)
  2. reject inconsistent input data types in R2C/C2R transforms

Comment threadspec/API_specification/array_api/fourier_transform_functions.py Outdated
Comment threadspec/API_specification/array_api/fourier_transform_functions.py Outdated
Comment threadspec/API_specification/array_api/fourier_transform_functions.py Outdated
Comment threadspec/API_specification/array_api/fourier_transform_functions.py Outdated
Comment threadspec/API_specification/array_api/fourier_transform_functions.py Outdated
Comment threadspec/API_specification/array_api/fourier_transform_functions.py Outdated
Comment threadspec/API_specification/array_api/fourier_transform_functions.py Outdated
Comment threadspec/API_specification/array_api/fourier_transform_functions.py Outdated
Comment threadspec/API_specification/array_api/fourier_transform_functions.py Outdated
Comment threadspec/API_specification/array_api/fourier_transform_functions.py Outdated
@leofang

Copy link
Copy Markdown
Contributor

Another note: As discussed in a prior meeting it is preferable to add a note that the output dtype will be consistent with the input dtype (ex: we don't always promote to complex128 as NumPy currently does even if the input is in single precision), but I think if we word it correctly when addressing #478 this need should be automatically resolved.

@leofang

Copy link
Copy Markdown
Contributor

Hi @steff456 Do you have local changes that you have not pushed? If not, may I edit in your branch directly?

@steff456

Copy link
Copy Markdown
MemberAuthor

Hi @leofang, go ahead and make changes! Thanks a lot 😬

@leofang
leofang self-requested a review October 5, 2022 17:58
@leofang

leofang commented Oct 15, 2022

Copy link
Copy Markdown
Contributor

@kgryte@rgommers@peterbell10@toslunar@steff456@oleksandr-pavlyk This should be ready now. Any chance any of you can take a look? Otherwise, I'll self-merge before the next Array API meeting (Oct 20).

@rgommers

Copy link
Copy Markdown
Member

Thanks @leofang! I had a quick browse, it looks like it is in good shape. I'll defer to @kgryte for a last in-depth look if he wants to.

Comment threadspec/API_specification/array_api/fourier_transform_functions.py Outdated
@leofangleofang self-assigned this Oct 17, 2022

@steff456steff456 left a comment

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

This looks good to me! Thanks a lot for helping me with this PR @leofang and @kgryte 🎉

@leofang

Copy link
Copy Markdown
Contributor

Announced in the meeting, let's merge. We can follow up with additional PRs if needed.

@leofang
leofang merged commit 8949817 into data-apis:mainOct 20, 2022
@rgommersrgommers added the topic: FFT Fast Fourier transforms. label Jan 11, 2024
kgryte added a commit that referenced this pull request Feb 8, 2024
PR-URL: #720Closes: #717Closes: #718
Ref: #189
Co-authored-by: Leo Fang <leo80042@gmail.com>
Co-authored-by: Athan Reines <kgryte@gmail.com>
Reviewed-by: Leo Fang <leo80042@gmail.com>
Reviewed-by: Athan Reines <kgryte@gmail.com>
Reviewed-by: Ralf Gommers <ralf.gommers@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API extensionAdds new functions or objects to the API.topic: FFTFast Fourier transforms.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFC: specifying the shape of the transformed output in n-dimensional FFT APIs

6 participants

@steff456@rgommers@kgryte@leofang@asmeurer@toslunar