Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
85d4a3a
Add StridedLayout
stiepan Nov 21, 2025
23b35fe
Support wrapping ptr in Buffer, create SMV from buffer and layout, dl…
stiepan Nov 17, 2025
2470617
Documentation, linting, minor fixes
stiepan Nov 18, 2025
cf7eff5
Add NotImplemented copy_from/copy_to
stiepan Nov 21, 2025
79010b8
Adjust flattening scalars to numpy/cupy behavior, fix shape validatio…
stiepan Nov 26, 2025
4ca3567
Add StridedLayout tests
stiepan Nov 26, 2025
acdd6f8
Use explicit int32_t instead of int in integer fused type
stiepan Nov 26, 2025
60a0d66
Disable (for now) exporting the SMV via dlpack
stiepan Nov 26, 2025
1fa43d4
Revert dlpack changes
stiepan Nov 26, 2025
67c6c5e
Support layouts up to 64 dims
stiepan Nov 27, 2025
a96bec5
Use cydriver to query memory attributes, fix managed memory handling,…
stiepan Nov 27, 2025
91387b0
Test owner and mr cannot be specified together
stiepan Nov 27, 2025
91c0af9
Test Buffer.close with owner
stiepan Nov 27, 2025
b74ef2c
Add envelope checks (rquires_size_in_bytes, offset_bounds)
stiepan Nov 27, 2025
2c0343f
Docs, annotation fixes, remove dlpack export mentions
stiepan Nov 27, 2025
598a2f1
Add SMV.from_buffer/view tests
stiepan Nov 27, 2025
bbb227b
Layout tests for SMV created from CAI
stiepan Nov 28, 2025
26dfe3b
Fix missing host unregister call in buffer test
stiepan Dec 1, 2025
3adae5c
Fix num attrib on re-try
stiepan Dec 1, 2025
7554164
Call int on the buffer.handle
stiepan Dec 1, 2025
68b7a79
Merge branch 'main' into introduce_strided_layout_memview
stiepan Dec 3, 2025
edace66
Don't enforce Buffer having an owner when creating SMV
stiepan Dec 3, 2025
9f86322
Use np._s instead of a custom helper in the tests
stiepan Dec 3, 2025
4335b2e
Take lanes into account when computing the itemsize
stiepan Dec 3, 2025
6568e27
Merge branch 'main' into introduce_strided_layout_memview
stiepan Dec 4, 2025
cbf1d17
Move layout validation out of get_data_ptr helper
stiepan Dec 4, 2025
4767fbb
Disambiguate all_axes mask for layout flattening, add range flattenin…
stiepan Dec 4, 2025
5765a22
Bring back the intptr_t in SMV
stiepan Dec 8, 2025
7ec8961
Merge branch 'main' into introduce_strided_layout_memview
stiepan Dec 8, 2025
db75aa0
Reorder methods, adjust SMV tests to from_dlpack/form_cai methods
stiepan Dec 8, 2025
639ee5f
Move the Device import to top-level imports
stiepan Dec 8, 2025
9fb5dfb
Merge branch 'main' into introduce_strided_layout_memview
stiepan Dec 8, 2025
3375b4d
Merge branch 'main' into introduce_strided_layout_memview
stiepan Dec 9, 2025
66fc6e8
Merge branch 'main' into introduce_strided_layout_memview
leofang Dec 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions cuda_core/cuda/core/experimental/_memoryview.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -615,20 +615,13 @@ cdef StridedLayout layout_from_cai(object metadata):


cdef inline uintptr_t _get_data_ptr(object buffer, StridedLayout layout) except? 0:
cdef bint is_allocated = buffer.owner is None
if is_allocated:
if buffer.memory_resource is None:
raise ValueError(
"Ambiguous buffer instance. The buffer must either hold an allocation "
"(coming from MemoryResource, e.g. Device().memory_resource.allocate()) "
"or wrap external data and specify the owner "
"(`Buffer.from_handle(ptr, size, owner=...)`)."
)
# For external buffers, we may not know the size. Even if we did, the size
# alone is not enough if the layout can map to negative offsets, i.e.:
# the valid range is not the [ptr, ptr + size - 1], but
# [ptr - offset, ptr + size - offset - 1]. The offset is not reported
# by the packages.
cdef bint is_allocated = buffer.memory_resource is not None
# Check the layout's offset range [min_offset, max_offset] fits
# within the [0, buffer.size - 1] range.
# The required_size_in_bytes fails if min_offset < 0.
# NB. For external memory, both positive and negative offsets can be valid,
# but for a proper check we'd need to know both size and data offset,
# while neither is reported by the packages.
if is_allocated and buffer.size < layout.get_required_size_in_bytes():
raise ValueError(
f"Buffer size is too small for the layout. "
Expand Down