-
Notifications
You must be signed in to change notification settings - Fork 242
feat: improve structured dtype array support in StridedMemoryView
#1425
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
feat: improve structured dtype array support in StridedMemoryView
#1425
Conversation
|
Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
/ok to test |
This comment has been minimized.
This comment has been minimized.
mdboom
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.
LGTM, other than improving the test a bit.
Leaning on Numpy for the conversion, as this now does, feels more future-proof as well.
3236804 to
9d37149
Compare
|
/ok to test |
|
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin release/cuda-core-v0.5.1
git worktree add -d .worktree/backport-1425-to-release/cuda-core-v0.5.1 origin/release/cuda-core-v0.5.1
cd .worktree/backport-1425-to-release/cuda-core-v0.5.1
git switch --create backport-1425-to-release/cuda-core-v0.5.1
git cherry-pick -x 36742ddc5b91ed388f55d5ec7ade8d245835fb35 |
|
Successfully created backport PR for |
Improve Support for Structured Dtype Arrays in StridedMemoryView
Summary
Extends
StridedMemoryViewto handle NumPy structured dtypes (e.g.,dtype([("field1", float64), ("field2", int64)])) instead of only built-in numeric types.Changes
cuda/core/_memoryview.pyx(30 lines, +20 -10)_typestr2dtypefrom static dict to function with lazy caching_typestr2itemsizefrom static dict to function with lazy cachingnumpy.dtype(typestr)for non-builtin types (e.g., structured dtypes)_typestr2dtype→_TYPESTR_TO_DTYPE,_typestr2itemsize→_TYPESTR_TO_ITEMSIZEtests/test_utils.py(+17 lines)test_struct_array()validating structured dtype handlingdtype=[("array1", np.float64), ("array2", np.int64)]Key Behavior
Structured dtypes now work but are represented as void types (e.g.,
V16) due to inherent lossiness in typestr encoding (dtype([("a", "int")]).str == "V8").