-
Notifications
You must be signed in to change notification settings - Fork 3
Draft: Make codebase ndarray backend agnostic #18
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
base: main
Are you sure you want to change the base?
Conversation
… of fft interface
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #18 +/- ##
==========================================
- Coverage 90.66% 90.56% -0.10%
==========================================
Files 13 14 +1
Lines 525 562 +37
==========================================
+ Hits 476 509 +33
- Misses 49 53 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hey @paulmueller please have a look at this when you have a chance. |
paulmueller
left a comment
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.
Have you read this? https://numpy.org/devdocs/user/basics.interoperability.html#example-cupy-arrays
I think it is not necessary to replace every instance of np with xp, except for initially creating the arrays, since np would automatically realize that the object is a cupy array and call the corresponding cupy methods. Did you test this?
|
|
||
| Since version 0.6.0, you can control the desired ndarray backend. | ||
| An "ndarray backend" is defined as the library used to define the | ||
| ndarrays in qpretrieve during runtime. By default it is set to ``'numpy'``. |
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.
When looking at the new comparison, I think cupy should be the default, if available.
See explanation in #17
Todo:
np.would bexp., withxpbeing eitherimport numpy as xporimport cupy as xp. See example from Cupy's docs here. In our case, we would want to generalisexp = cp.get_array_module(x)._ndarray_backendmodule. Fix was to create a class that contains a__getattr__method.