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. |
|
It looks like this is in the Though most of the CuPy 14 items are under the Should we move this under the |
|
I am trying to find someone from NVIDIA to take over this PR and include it in ml_dtypes (jax-ml/ml_dtypes#110 (comment)). I doubt this can be done in v14.0.0.a1, but might be a stretching goal for the v14 a2 or b1 releases, so I think keeping it in the v14 milestone sounds appropriate. |
@seberg will have something ready to upstream soon (jax-ml/ml_dtypes#110 (comment)), but it may not land by v14.0.0. In the meanwhile, the scalar infra is being set up in #9494 and once |
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.complex64andcupy.complex128are 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.complex32inherits 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.