We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e907c78 commit dcc1b37Copy full SHA for dcc1b37
1 file changed
cuda_core/cuda/core/experimental/_memory.pyx
@@ -203,13 +203,14 @@ cdef class Buffer:
203
return capsule
204
205
def __dlpack_device__(self) -> Tuple[int, int]:
206
- d_h = (bool(self.is_device_accessible), bool(self.is_host_accessible))
207
- if d_h == (True, False):
+ cdef bint d = self.is_device_accessible
+ cdef bint h = self.is_host_accessible
208
+ if d and (not h):
209
return (DLDeviceType.kDLCUDA, self.device_id)
- if d_h == (True, True):
210
+ if d and h:
211
# TODO: this can also be kDLCUDAManaged, we need more fine-grained checks
212
return (DLDeviceType.kDLCUDAHost, 0)
- if d_h == (False, True):
213
+ if (not d) and h:
214
return (DLDeviceType.kDLCPU, 0)
215
raise BufferError("buffer is neither device-accessible nor host-accessible")
216
0 commit comments