Support partial-dimension FFTs - #615
Open
michel2323 wants to merge 1 commit into
Open
Conversation
fft/bfft plans (in-place and out-of-place) and rfft/irfft/brfft now accept any contiguous region of dimensions, e.g. fft(A, 1) or fft(A, (2, 3)) for a 3D array. Regions are expressed through the oneMKL DFT descriptor using explicit strides plus NUMBER_OF_TRANSFORMS and distances; regions with batch dimensions on both sides are handled by repeated executions at shifted pointer offsets, since a descriptor only has a single batch distance. Non-contiguous regions (e.g. (1, 3)) throw an informative error. Also fixes two silently-wrong paths: multi-dimensional brfft was routed to a non-batched 1D descriptor and only transformed the first column, and the complex-based inverse real FFT zero-padded the spectrum instead of reconstructing conjugate symmetry.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #615 +/- ##
==========================================
+ Coverage 79.97% 80.90% +0.92%
==========================================
Files 50 50
Lines 3496 3488 -8
==========================================
+ Hits 2796 2822 +26
+ Misses 700 666 -34 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The oneMKL FFT wrapper previously rejected any transform region that wasn't all dimensions ("Partial dimension FFT not yet supported"). This was purely a wrapper limitation: the oneMKL DFT descriptor can express these via
FWD/BWD_STRIDES,NUMBER_OF_TRANSFORMS, andFWD/BWD_DISTANCE, all of which the support library already exposes.With this PR,
plan_fft/plan_bfft(in-place and out-of-place) andrfft/irfft/brfftaccept any contiguous region of dimensions, e.g.fft(A, 1),fft(A, 2), orfft(A, (2, 3))for a 3D array:_plan_cfft, which programs a regionj:kas an R-dimensional transform with explicit column-major strides.NUMBER_OF_TRANSFORMSwith the block length as distance; leading dimensions as interleaved transforms with distance 1. When batch dimensions exist on both sides (a "middle" region like dim 2 of a 3D array), the trailing side becomes repeated executions at shifted pointer offsets, since a descriptor has only one distance parameter.(1, 3)) throw an informative error instead of the previous blanket rejection.Two silently-wrong pre-existing paths are also fixed:
brfftwas routed to a non-batched 1D descriptor, so only the first column was transformed and the rest of the output was garbage. It now goes through the complex path.ComplexBasedRealIFFTPlan) zero-padded the missing half of the spectrum instead of reconstructing it by conjugate symmetry, giving inaccurate results. It now performs a proper Hermitian reconstruction (using negative-step range indexing, sinceBase.reverse(A; dims)falls back to scalar indexing foroneArray).Tests cover partial regions for even/odd sizes in 2D/3D (complex forward/inverse, in-place, real forward/inverse) against FFTW, plus N-D
irfft/brfftwhich was previously only tested in 1D. The fft testsuite passes 188/188 on an Arc A750.