Skip to content

Commit 4c4bb17

Browse files
committed
restore the contracts for now (the deallocation stream should be fixed)
1 parent 0c64e8e commit 4c4bb17

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

cuda_core/cuda/core/experimental/_memory.pyx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ cdef class Buffer:
9797
"""
9898
if self._ptr and self._mr is not None:
9999
if isinstance(self._mr, _cyMemoryResource):
100+
# FIXME
101+
if stream is None:
102+
stream = Stream.__new__(Stream)
103+
(<cyStream>(stream))._handle = <cydriver.CUstream>(0)
100104
(<_cyMemoryResource>(self._mr))._deallocate(self._ptr, self._size, <cyStream>stream)
101105
else:
102106
self._mr.deallocate(self._ptr, self._size, stream)
@@ -113,7 +117,13 @@ cdef class Buffer:
113117
This handle is a Python object. To get the memory address of the underlying C
114118
handle, call ``int(Buffer.handle)``.
115119
"""
116-
return self._ptr_obj
120+
if self._ptr_obj is not None:
121+
return self._ptr_obj
122+
elif self._ptr:
123+
return self._ptr
124+
else:
125+
# contract: Buffer is closed
126+
return None
117127

118128
@property
119129
def size(self) -> int:

0 commit comments

Comments
 (0)