-
Notifications
You must be signed in to change notification settings - Fork 2
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
ENH: Add Scipy and Cupy as fft interfaces #8
base: main
Are you sure you want to change the base?
Conversation
Hey @paulmueller, let me know if you think this fits in the |
|
||
sphinx | ||
sphinxcontrib.bibtex | ||
sphinx_rtd_theme |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the pinned versions, as some sphinx dependency did not like the old sphinx version.
n_transforms = 100 | ||
|
||
# one transform | ||
results_1 = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to clean this script up a bit to make it simpler
@@ -104,8 +104,10 @@ def get_filter_array(filter_name, filter_size, freq_pos, fft_shape): | |||
# TODO: avoid the np.roll, instead use the indices directly | |||
alpha = 0.1 | |||
rsize = int(min(fx.size, fy.size) * filter_size) * 2 | |||
tukey_window_x = signal.tukey(rsize, alpha=alpha).reshape(-1, 1) | |||
tukey_window_y = signal.tukey(rsize, alpha=alpha).reshape(1, -1) | |||
tukey_window_x = signal.windows.tukey( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scipy's new versions imports tukey from signal.window
, not signal
FFTFilterPyFFTW, | ||
FFTFilterNumpy, | ||
FFTFilterScipy, | ||
FFTFilterCupy, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't necessarily the "perferred order" we want, but I'd like to keep it as is due to old default pipelines.
@@ -70,8 +70,11 @@ def __init__(self, data, subtract_mean=True, padding=2, copy=True): | |||
else: | |||
# convert integer-arrays to floating point arrays | |||
dtype = float | |||
if not copy: | |||
# numpy v2.x behaviour requires asarray with copy=False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
numpy has made copying a bit awkward. When an array can't be copied (with either np.array
or np.asarray
), and the user has copy=False, then it throws an error!
data_gpu = cp.asarray(data) | ||
# likely an inefficiency here, could use `set_global_backend` | ||
with sp.fft.set_backend(cufft): | ||
fft_gpu = sp.fft.fft2(data_gpu) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not ideal, this is something to work on.
"FFTW": "pyfftw>=0.12.0", | ||
# manually install 'cupy-cuda11x' if you have older CUDA. | ||
# See https://cupy.dev/ | ||
"CUPY": "cupy-cuda12x", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will have to check this version.
Hello, This is absolutely in the scope of qpretrieve! It would probably make sense to address all CI issues (GH actions, readthedocs) and dependencies (e.g. I would be fine with bumping numpy to >= 2.0) in a separate PR. I have converted this PR to a draft for now, so you can work on it in stealth mode. |
Sounds good, I will revert the actions changes. However, the docs requirements just don't build on my side because they are too restrictive.
🥇 |
@@ -70,9 +75,13 @@ def __init__(self, data, subtract_mean=True, padding=2, copy=True): | |||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we check and allow complex data. But in the docstring above (originally), we specify real-valued inputs. In what situation would we take complex data?
About
I'd like to be able to use Cupy for Fourier transforms. Cupy is a python package that uses numpy-like syntax for using CUDA and GPU.
To do
FFTFilterCupy3D
, so that the default input of a 2D image is kept by the default FFTFilter classes, and the user has to know what they are doing to useFFTFilterCupy3D
. Combine the functionality with 2d because it uses numpy.run_pipeline
steps should also work with 3D arrays. Seems to fall down at line 86 inif_oah.py
for now, as this is a section that must use 2D arrays.test_qlsi_unwrap_phase_2d_3d