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
[WIP] Add cupy.complex32
#4454
base: main
Are you sure you want to change the base?
[WIP] Add cupy.complex32
#4454
Conversation
can get PyTypeObject* to a cdef class, but cannot make inheritance right: Complex32 is not inheriting from numpy.complexfloating
The discussion is ongoing in numpy/numpy#14753! |
We have been talking offline, maybe it's better to postpone this until NumPy implements complex32. |
So let me quickly summarize the discussion in numpy/numpy#14753 so far. It's doable and the Numpy core devs generally support it. We agree that this dtype will be called |
I'd like to note, though, that if CuPy would just alias |
We discussed this, we can implement it once it is released in NumPy master branch, as we always support the latest released NumPy version during development. However, we will need to disable it for older NumPy versions. |
Let me close this to clean up my PR queue 😁 I'll leave the branch alive for reference. This need is already tracked in #3370. |
Hmmm I can't reopen because the target branch ( |
Sorry for delay. @seberg has kindly taken a look at this PR, and agreed I was on the right track. What I'll do is to clean up/polish the code, hook it up with the build system, and add tests. I'll ping Sebastian and the team once it's ready. |
Milestone removed. |
Yeah unfortunately I can't make it for v13. |
First step toward #3370. Related to #4407. DECISION NEEDED BEFORE ANY CODE REVIEW
This is a working prototype to demonstrate that we can define a new Python type (
cupy.complex32
) and the associated NumPy dtype (np.dtype(cupy.complex32)
) so that this type object can be used to hint that the input array consists of half-precision complex numbers, to be used internally wherever its siblingscupy.complex64
andcupy.complex128
are applicable. The subsequent GPU operations is out of scope in this PR and will be addressed when this is merged.Currently it works for:
cupy.complex32
inherits fromnumpy.complexfloating
, same as other complex types)'c'
for complex)'E'
for 2 float16 as complex, as oppose to lowercase'e'
for 1 float16 as real)Critical decision to make before moving on: I incline to consider it acceptable that it has very limited functionality when used as a dtype. In particular, I do not wish to support all kinds of CPU ufuncs or array funcs (as defined in this section) when manipulated as a NumPy complex32 array, because it would then be more suitable for a PR to NumPy, not to CuPy, and as far as I know NumPy folks do not want to add more new built-in types (numpy/numpy#14753), nor do I have the bandwidth to do so. I think having this type object defined is already enough for GPU needs. If it's acceptable then I will work on polishing this.