-
Notifications
You must be signed in to change notification settings - Fork 21
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
Fix strides for 0-sized empty arrays #36
Conversation
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.
Thanks! I think this is fine, but I'd like better comments! :) And code duplication is bad (sorry!).
9b5449f
to
0c3bdcf
Compare
0c3bdcf
to
dfa7a46
Compare
LGTM! |
Can you pull this into the pyopencl change (inducer/pyopencl#514)? I'll pull it into pycuda and loopy. |
Super random, but NumPy indeed "ignores" size 1 dimensions when computing strides. However, NumPy will also when deciding whether strides are f or c-contiguous. So internally, numpy would consider the strides you had as valid f-contiguous strides (and will only sanitize this when exporting using the buffer protocol, which was necessary for cython at some point). EDIT: To be clear, checking for contiguity, numpy completely ignores the stride value, and any stride value if the array is empty. In that sense |
Thanks for the heads-up! I've recorded this in #37. |
For 0-sized arrays, this returned
which messes up
cl.array.empty(queue, (18, 0), np.float64).strides
. On the other hand,numpy
givesNot sure this is the right general fix, but it does the trick for this little example.
xref: inducer/arraycontext#91.