Repository navigation
Support complex numbers in DLPack - #58
Merged
Merged
Conversation
tqchen
requested changes
Feb 6, 2021
| kDLUInt = 1U, | ||
| kDLFloat = 2U, | ||
| kDLBfloat = 4U, | ||
| kDLComplex = 8U, // C/C++/Python layout (compact struct per complex number) |
Member
There was a problem hiding this comment.
do do not need to assign bitmasking. the number 3U was reserved for opaque handle, we can directly assign 5 here
Collaborator
Author
tqchen
reviewed
Feb 6, 2021
| kDLComplex = 8U, // C/C++/Python layout (compact struct per complex number) | ||
| kDLComplexS = 16U, // alternative layout (a struct with two pointers to real & imag arrays) | ||
| kDLComplex = 5U, // C/C++/Python layout (compact struct per complex number) | ||
| kDLComplexS = 6U, // alternative layout (a struct with two pointers to real & imag arrays) |
Member
There was a problem hiding this comment.
Given that the Struct of Array is less conventionally defined(we need to define how the layout is, right now seems only well defined for compact array), let us first start with Complex(which is easier to agree on) then discuss the SOA case later.
Collaborator
Author
Collaborator
Author
|
btw @tqchen Should I bump the DLPack version in this PR? |
Collaborator
Author
|
@tqchen I noticed there appeared a conflict with the main branch. I just fixed it. |
tqchen
approved these changes
Feb 8, 2021
Collaborator
Author
|
Thanks, @tqchen! I still need to know when the DLPack version will be bumped, though. |
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.
Close #50.
This PR adds the last missing piece IMHO to DLPack, namely to support complex numbers commonly used in scientific computing and also increasingly in certain machine learning tasks.
As discussed in #50, there seems to be a need to support two different kinds of formats, namely structs of arrays (SoA) and arrays of structs (AoS). The latter (AoS) is the standard choice in C/C++/CUDA/HIP/Python/Numpy/CuPy/etc, so I took the liberty of simply calling it
kDLComplex. We haven't converged on naming in #50, though, and I'm open to suggestions 🙂UPDATE: this PR is merged for supporting AoS (
kDLComplex); the support of SoA is to be discussed in #60.QUESTION: Should I bump the DLPack version in this PR, or we can wait until the actual release?
cc: @rgommers @tqchen @hawkinsp