Skip to content

Commit

Permalink
Merge pull request #182 from leofang/exporting_obj
Browse files Browse the repository at this point in the history
Rename `StridedMemoryView.obj` to `StridedMemoryView.exporting_obj`
  • Loading branch information
leofang authored Oct 17, 2024
2 parents 8c841cd + edf0bb7 commit 39a86fd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cuda_core/cuda/core/experimental/_memoryview.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ cdef class StridedMemoryView:
device_id: int = None # -1 for CPU
device_accessible: bool = None
readonly: bool = None
obj: Any = None
exporting_obj: Any = None

def __init__(self, obj=None, stream_ptr=None):
if obj is not None:
Expand All @@ -50,7 +50,7 @@ cdef class StridedMemoryView:
+ f" device_id={self.device_id},\n"
+ f" device_accessible={self.device_accessible},\n"
+ f" readonly={self.readonly},\n"
+ f" obj={get_simple_repr(self.obj)})")
+ f" exporting_obj={get_simple_repr(self.exporting_obj)})")


cdef str get_simple_repr(obj):
Expand Down Expand Up @@ -173,7 +173,7 @@ cdef StridedMemoryView view_as_dlpack(obj, stream_ptr, view=None):
buf.device_id = device_id
buf.device_accessible = device_accessible
buf.readonly = is_readonly
buf.obj = obj
buf.exporting_obj = obj

cdef const char* used_name = (
DLPACK_VERSIONED_TENSOR_USED_NAME if versioned else DLPACK_TENSOR_USED_NAME)
Expand Down Expand Up @@ -252,7 +252,7 @@ cdef StridedMemoryView view_as_cai(obj, stream_ptr, view=None):
raise BufferError("stream=None is ambiguous with view()")

cdef StridedMemoryView buf = StridedMemoryView() if view is None else view
buf.obj = obj
buf.exporting_obj = obj
buf.ptr, buf.readonly = cai_data["data"]
buf.shape = cai_data["shape"]
# TODO: this only works for built-in numeric types
Expand Down

0 comments on commit 39a86fd

Please sign in to comment.