-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Sub-byte custom element types #63
Comments
Well, there was always the issue of ABI. Now, we can change ABI for the DType at least in 2.0 and I am planning to do it to make additions easier. So representing a bit-sized dtype should be relatively straight forward with that. Maybe as:
The bigger problem is how you actually work with it. We pass in dtypes and some state to ufuncs/cast, etc. would a dtype indicating bit-sized always get passed bit pointers and bit-strides? Right now, we pass around pointers such as So a lot of questions, and I don't have all the answer:
I also don't think you could update all of NumPy functionality on a reasonable timeline without hiring 1-2 people dedicated to it. So we could do additions to the array object to allow it in principle and even get it to work with most things. But I doubt you will get it to work with everything quickly (which is fine by me, you could just add a Anyway, questions... The interesting part might be if we can formulate anything that affects the array object or the inner-loop signatures for ufuncs/casts. |
jax-ml/ml_dtypes#71 is a prototype of adding a padded This is good enough for my use case, although the padding makes me a little bit sad. |
I'm wondering if anyone has considered sub-byte user types as part of the API design. The assumption that types have element sizes that are integer numbers of bytes seems to be baked into current user dtypes design.
For example, consider a packed
int4
type, whose elements are nibbles (half-bytes). It doesn't seem possible to express such a type in the user dtype API, e.g., the type descriptor requires a byte size for each element, and ufuncs require byte strides. I was toying with the idea of trying to write such a type, but it doesn't seem to be possible without API changes.I see this was mentioned briefly in NEP 41 (
int2
) but there is no further discussion I can see. Has there been any more thinking along those lines?The text was updated successfully, but these errors were encountered: