Skip to content

Commit dcc1b37

Browse files
committed
nit: avoid extra tuple
1 parent e907c78 commit dcc1b37

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

cuda_core/cuda/core/experimental/_memory.pyx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,14 @@ cdef class Buffer:
203203
return capsule
204204

205205
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):
206+
cdef bint d = self.is_device_accessible
207+
cdef bint h = self.is_host_accessible
208+
if d and (not h):
208209
return (DLDeviceType.kDLCUDA, self.device_id)
209-
if d_h == (True, True):
210+
if d and h:
210211
# TODO: this can also be kDLCUDAManaged, we need more fine-grained checks
211212
return (DLDeviceType.kDLCUDAHost, 0)
212-
if d_h == (False, True):
213+
if (not d) and h:
213214
return (DLDeviceType.kDLCPU, 0)
214215
raise BufferError("buffer is neither device-accessible nor host-accessible")
215216

0 commit comments

Comments
 (0)