Fix strides for 0-sized empty arrays#36
Conversation
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,numpygivesNot sure this is the right general fix, but it does the trick for this little example.
xref: inducer/arraycontext#91.