[MERGE] Fixes wrong shape and stack allocation in BufferRegion#144
[MERGE] Fixes wrong shape and stack allocation in BufferRegion#144quasiben merged 9 commits intorapidsai:develfrom
Conversation
Very interesting! When is that not true? |
On my installation :P |
|
@madsbk is it possible to add something which can explicitly test this ? Or are the tests in buffer_region.py enough ? |
Ah right! Yeah sometimes C code will allocate a buffer larger than the needed shape. Good catch. Sorry forgot about this. |
|
These tests pass for me -- @Akshay-Venkatesh should we merge ? |
|
Also, can someone ELI5 what was the problem exactly and what this PR is doing? |
|
@Akshay-Venkatesh I can try but I am not as familiar with buffer protocols as @jakirkham / @madsbk @kkraus14 . On my machine (and @madsbk as well)
@jakirkham suggested that, " C code will allocate a buffer larger than the needed shape" . The only reference I could find about this is in the numpy docs (look at the shape definition). The cython docs recommend simply handling the 1st dimension of shape:
For reference in a python session we see the following: I confirmed the large buffer size by putting a print statement in the |
|
If there are no objects can we/I merge this tomorrow ? |
|
The shape is now a tuple instead of a list. |
|
Apologies for hastily rushing this along. I tested this PR with In various functions inside the buffer helper, ucx-py is assigning shape and this fails if shape is a tuple. ucx-py/ucp/_libs/ucp_py_buffer_helper.pyx Lines 229 to 240 in c70ccd0 @madsbk @Akshay-Venkatesh what are you're thoughts here ? Should this be fixed in a follow on PR or continued to be worked in this PR ? |
|
@quasiben, It should be fixed now; can you confirm? |
|
Thank you @madsbk ! The tests for buffer and send_recv are passing now. I'm going to merge and continue cleaning up tests |
len(memoryview.shape)might not equalmemoryview.ndimAll tests in
tests/test_buffer_region.pynow passes on my installationUpdate: the returned shape and strides in
__buffer__is now allocated on the heap.