@@ -80,36 +80,37 @@ cdef tuple _coerce_batch_buffers(object buffers, str what):
8080
8181
8282cdef tuple _broadcast_locations(object location, Py_ssize_t n, bint allow_none, str what):
83- cdef object coerced
8483 if isinstance (location, Sequence):
8584 if len (location) != n:
8685 raise ValueError (
8786 f" {what}: location length {len(location)} does not match "
8887 f" targets length {n}"
8988 )
9089 return tuple (_coerce_location(loc, allow_none = allow_none) for loc in location)
91- coerced = _coerce_location(location, allow_none = allow_none)
90+ cdef object coerced = _coerce_location(location, allow_none = allow_none)
9291 return tuple ([coerced] * n)
9392
9493
9594IF CUDA_CORE_BUILD_MAJOR >= 13 :
9695 # Convert a _LocSpec dataclass to a cydriver.CUmemLocation struct.
9796 cdef inline cydriver.CUmemLocation _to_cumemlocation(object loc):
98- cdef cydriver.CUmemLocation out
9997 cdef str kind = loc.kind
10098 if kind == " device" :
101- out.type = cydriver.CUmemLocationType.CU_MEM_LOCATION_TYPE_DEVICE
102- out.id = < int > loc.id
99+ return cydriver.CUmemLocation(
100+ type = cydriver.CUmemLocationType.CU_MEM_LOCATION_TYPE_DEVICE,
101+ id = < int > loc.id)
103102 elif kind == " host" :
104- out.type = cydriver.CUmemLocationType.CU_MEM_LOCATION_TYPE_HOST
105- out.id = 0
103+ return cydriver.CUmemLocation(
104+ type = cydriver.CUmemLocationType.CU_MEM_LOCATION_TYPE_HOST,
105+ id = 0 )
106106 elif kind == " host_numa" :
107- out.type = cydriver.CUmemLocationType.CU_MEM_LOCATION_TYPE_HOST_NUMA
108- out.id = < int > loc.id
107+ return cydriver.CUmemLocation(
108+ type = cydriver.CUmemLocationType.CU_MEM_LOCATION_TYPE_HOST_NUMA,
109+ id = < int > loc.id)
109110 else : # host_numa_current
110- out.type = cydriver.CUmemLocationType.CU_MEM_LOCATION_TYPE_HOST_NUMA_CURRENT
111- out.id = 0
112- return out
111+ return cydriver.CUmemLocation(
112+ type = cydriver.CUmemLocationType.CU_MEM_LOCATION_TYPE_HOST_NUMA_CURRENT,
113+ id = 0 )
113114ELSE :
114115 # CUDA 12 cuMemPrefetchAsync takes a device ordinal (-1 = host).
115116 cdef inline int _to_legacy_device(object loc) except ? - 2 :
@@ -223,8 +224,9 @@ cdef void _do_single_advise(Buffer buf, object advice_value, object loc, bint al
223224 # Driver ignores location for read_mostly / unset_preferred_location
224225 # advice values but still validates the CUmemLocation; pass a
225226 # host placeholder.
226- cu_loc.type = cydriver.CUmemLocationType.CU_MEM_LOCATION_TYPE_HOST
227- cu_loc.id = 0
227+ cu_loc = cydriver.CUmemLocation(
228+ type = cydriver.CUmemLocationType.CU_MEM_LOCATION_TYPE_HOST,
229+ id = 0 )
228230 else :
229231 cu_loc = _to_cumemlocation(loc)
230232 with nogil:
0 commit comments