def test_mix_argtype(offload_device, input_arrays): usm_type = "device" a, b, expected = input_arrays got = np.ones_like(a) device = dpctl.SyclDevice(offload_device) queue = dpctl.SyclQueue(device) da = dpt.usm_ndarray( a.shape, dtype=a.dtype, buffer=usm_type, buffer_ctor_kwargs={"queue": queue}, ) da.usm_data.copy_from_host(a.reshape((-1)).view("|u1")) dc = dpt.usm_ndarray( got.shape, dtype=got.dtype, buffer=usm_type, buffer_ctor_kwargs={"queue": queue}, ) with pytest.raises(TypeError) as error_msg: sum_kernel[global_size, local_size](da, b, dc) assert mix_datatype_err_msg in error_msg
def main(): global_size = 10 N = global_size print("N", N) a = np.array(np.random.random(N), dtype=np.float32) b = np.array(np.random.random(N), dtype=np.float32) c = np.ones_like(a) # Use the environment variable SYCL_DEVICE_FILTER to change the default device. # See https://github.com/intel/llvm/blob/sycl/sycl/doc/EnvironmentVariables.md#sycl_device_filter. device = dpctl.select_default_device() print("Using device ...") device.print_device_info() with dpctl.device_context(device): da = dpt.usm_ndarray(a.shape, dtype=a.dtype, buffer="shared") da.usm_data.copy_from_host(a.reshape((-1)).view("|u1")) db = dpt.usm_ndarray(b.shape, dtype=b.dtype, buffer="shared") db.usm_data.copy_from_host(b.reshape((-1)).view("|u1")) dc = dpt.usm_ndarray(c.shape, dtype=c.dtype, buffer="shared") driver(da, db, dc, global_size) print("Done...")
def gen_data_usm(nopt, dims): X, Y, D = gen_data(nopt, dims) with dpctl.device_context(get_device_selector()) as gpu_queue: X_usm = dpt.usm_ndarray( X.shape, dtype=X.dtype, buffer="device", buffer_ctor_kwargs={"queue": gpu_queue}, ) Y_usm = dpt.usm_ndarray( Y.shape, dtype=Y.dtype, buffer="device", buffer_ctor_kwargs={"queue": gpu_queue}, ) D_usm = dpt.usm_ndarray( D.shape, dtype=D.dtype, buffer="device", buffer_ctor_kwargs={"queue": gpu_queue}, ) X_usm.usm_data.copy_from_host(X.reshape((-1)).view("u1")) Y_usm.usm_data.copy_from_host(Y.reshape((-1)).view("u1")) return (X_usm, Y_usm, D_usm)
def allocate_SUAI_data(a, b, got, usm_type, queue): da = dpt.usm_ndarray( a.shape, dtype=a.dtype, buffer=usm_type, buffer_ctor_kwargs={"queue": queue}, ) da.usm_data.copy_from_host(a.reshape((-1)).view("|u1")) db = dpt.usm_ndarray( b.shape, dtype=b.dtype, buffer=usm_type, buffer_ctor_kwargs={"queue": queue}, ) db.usm_data.copy_from_host(b.reshape((-1)).view("|u1")) dc = dpt.usm_ndarray( got.shape, dtype=got.dtype, buffer=usm_type, buffer_ctor_kwargs={"queue": queue}, ) return da, db, dc
def test_with_usm_ndarray_data(queue, memtype): from dpctl.tensor import usm_ndarray device_name = device_type_to_str(queue) X = usm_ndarray((5, 3), buffer=memtype(5 * 3 * 8, queue=queue)) y = usm_ndarray((3, ), buffer=memtype(3 * 8, queue=queue)) assert _get_policy(None, X, y).get_device_name() == device_name
def test_ctor_invalid(): m = dpm.MemoryUSMShared(12) with pytest.raises(ValueError): dpt.usm_ndarray((4, ), dtype="i4", buffer=m) m = dpm.MemoryUSMShared(64) with pytest.raises(ValueError): dpt.usm_ndarray((4, ), dtype="u1", buffer=m, strides={"not": "valid"})
def copy(usm_ary, order="K"): """ Creates a copy of given instance of `usm_ndarray`. Memory layour of the copy is controlled by `order` keyword, following NumPy's conventions. The `order` keywords can be one of the following: "C": C-contiguous memory layout "F": Fotrant-contiguous memory layout "A": Fotrant-contiguous if the input array is F-contiguous, and C-contiguous otherwise "K": match the layout of `usm_ary` as closely as possible. """ if not isinstance(usm_ary, dpt.usm_ndarray): return TypeError( "Expected object of type dpt.usm_ndarray, got {}".format( type(usm_ary))) copy_order = "C" if order == "C": pass elif order == "F": copy_order = order elif order == "A": if usm_ary.flags & 2: copy_order = "F" elif order == "K": if usm_ary.flags & 2: copy_order = "F" else: raise ValueError("Unrecognized value of the order keyword. " "Recognized values are 'A', 'C', 'F', or 'K'") c_contig = usm_ary.flags & 1 f_contig = usm_ary.flags & 2 R = dpt.usm_ndarray( usm_ary.shape, dtype=usm_ary.dtype, buffer=usm_ary.usm_type, order=copy_order, buffer_ctor_kwargs={"queue": usm_ary.sycl_queue}, ) if order == "K" and (not c_contig and not f_contig): original_strides = usm_ary.strides ind = sorted( range(usm_ary.ndim), key=lambda i: abs(original_strides[i]), reverse=True, ) new_strides = tuple(R.strides[ind[i]] for i in ind) R = dpt.usm_ndarray( usm_ary.shape, dtype=usm_ary.dtype, buffer=R.usm_data, strides=new_strides, ) copy_same_dtype(R, usm_ary) return R
def test_len(): X = dpt.usm_ndarray(1, "i4") assert len(X) == 1 X = dpt.usm_ndarray((2, 1), "i4") assert len(X) == 2 X = dpt.usm_ndarray(tuple(), "i4") with pytest.raises(TypeError): len(X)
def test_setitem_errors(): X = dpt.usm_ndarray((4, ), dtype="u1") Y = dpt.usm_ndarray((4, 2), dtype="u1") with pytest.raises(ValueError): X[:] = Y with pytest.raises(ValueError): X[:] = Y[:, 0:1] X[:] = Y[None, :, 0]
def reshape(X, newshape, order="C"): """ reshape(X: usm_ndarray, newshape: tuple, order="C") -> usm_ndarray Reshapes given usm_ndarray into new shape. Returns a view, if possible, a copy otherwise. Memory layout of the copy is controlled by order keyword. """ if type(X) is not dpt.usm_ndarray: raise TypeError if not isinstance(newshape, (list, tuple)): newshape = (newshape,) if order not in ["C", "F"]: raise ValueError( f"Keyword 'order' not recognized. Expecting 'C' or 'F', got {order}" ) newshape = [operator.index(d) for d in newshape] negative_ones_count = 0 for i in range(len(newshape)): if newshape[i] == -1: negative_ones_count = negative_ones_count + 1 if (newshape[i] < -1) or negative_ones_count > 1: raise ValueError( "Target shape should have at most 1 negative " "value which can only be -1" ) if negative_ones_count: v = X.size // (-np.prod(newshape)) newshape = [v if d == -1 else d for d in newshape] if X.size != np.prod(newshape): raise ValueError("Can not reshape into {}".format(newshape)) newsts = reshaped_strides(X.shape, X.strides, newshape, order=order) if newsts is None: # must perform a copy flat_res = dpt.usm_ndarray( (X.size,), dtype=X.dtype, buffer=X.usm_type, buffer_ctor_kwargs={"queue": X.sycl_queue}, order=order, ) for i in range(X.size): copy_same_dtype( flat_res[i], X[np.unravel_index(i, X.shape, order=order)] ) return dpt.usm_ndarray( tuple(newshape), dtype=X.dtype, buffer=flat_res, order=order ) else: # can form a view return dpt.usm_ndarray( newshape, dtype=X.dtype, buffer=X, strides=tuple(newsts), offset=X.__sycl_usm_array_interface__.get("offset", 0), )
def test_setitem_scalar(dtype, usm_type): X = dpt.usm_ndarray((6, 6), dtype=dtype, buffer=usm_type) for i in range(X.size): X[np.unravel_index(i, X.shape)] = np.asarray(i, dtype=dtype) assert np.array_equal(dpt.to_numpy(X), np.arange(X.size).astype(dtype).reshape(X.shape)) Y = dpt.usm_ndarray((2, 3), dtype=dtype, buffer=usm_type) for i in range(Y.size): Y[np.unravel_index(i, Y.shape)] = i assert np.array_equal(dpt.to_numpy(Y), np.arange(Y.size).astype(dtype).reshape(Y.shape))
def test_equivalent_usm_ndarray(input_arrays): usm_type = "device" a, b, expected = input_arrays got = np.ones_like(a) device1 = dpctl.SyclDevice("level_zero:gpu") queue1 = dpctl.SyclQueue(device1) device2 = dpctl.SyclDevice("opencl:gpu") queue2 = dpctl.SyclQueue(device2) da = dpt.usm_ndarray( a.shape, dtype=a.dtype, buffer=usm_type, buffer_ctor_kwargs={"queue": queue1}, ) da.usm_data.copy_from_host(a.reshape((-1)).view("|u1")) not_equivalent_db = dpt.usm_ndarray( b.shape, dtype=b.dtype, buffer=usm_type, buffer_ctor_kwargs={"queue": queue2}, ) not_equivalent_db.usm_data.copy_from_host(b.reshape((-1)).view("|u1")) equivalent_db = dpt.usm_ndarray( b.shape, dtype=b.dtype, buffer=usm_type, buffer_ctor_kwargs={"queue": queue1}, ) equivalent_db.usm_data.copy_from_host(b.reshape((-1)).view("|u1")) dc = dpt.usm_ndarray( got.shape, dtype=got.dtype, buffer=usm_type, buffer_ctor_kwargs={"queue": queue1}, ) with pytest.raises(IndeterminateExecutionQueueError) as error_msg: sum_kernel[global_size, local_size](da, not_equivalent_db, dc) assert IndeterminateExecutionQueueError_msg in str(error_msg.value) sum_kernel[global_size, local_size](da, equivalent_db, dc) dc.usm_data.copy_to_host(got.reshape((-1)).view("|u1")) expected = a + b assert np.array_equal(got, expected)
def _asarray_from_numpy_ndarray(ary, dtype=None, usm_type=None, sycl_queue=None, order="K"): if not isinstance(ary, np.ndarray): raise TypeError(f"Expected numpy.ndarray, got {type(ary)}") if usm_type is None: usm_type = "device" if dtype is None: dtype = ary.dtype copy_q = _normalize_queue_device(q=None, d=sycl_queue) f_contig = ary.flags["F"] c_contig = ary.flags["C"] fc_contig = f_contig or c_contig if order == "A": order = "F" if f_contig and not c_contig else "C" if order == "K" and fc_contig: order = "C" if c_contig else "F" if order == "K": # new USM allocation res = dpt.usm_ndarray( ary.shape, dtype=dtype, buffer=usm_type, order="C", buffer_ctor_kwargs={"queue": copy_q}, ) original_strides = ary.strides ind = sorted( range(ary.ndim), key=lambda i: abs(original_strides[i]), reverse=True, ) new_strides = tuple(res.strides[ind[i]] for i in ind) # reuse previously made USM allocation res = dpt.usm_ndarray(res.shape, dtype=res.dtype, buffer=res.usm_data, strides=new_strides) else: res = dpt.usm_ndarray( ary.shape, dtype=dtype, buffer=usm_type, order=order, buffer_ctor_kwargs={"queue": copy_q}, ) # FIXME: call copy_to when implemented res[(slice(None, None, None), ) * res.ndim] = ary return res
def test_consuming_usm_ndarray(offload_device, dtype, usm_type): if skip_test(offload_device): pytest.skip() @dppy.kernel def data_parallel_sum(a, b, c): """ Vector addition using the ``kernel`` decorator. """ i = dppy.get_global_id(0) c[i] = a[i] + b[i] global_size = 1021 N = global_size a = np.array(np.random.random(N), dtype=dtype) b = np.array(np.random.random(N), dtype=dtype) got = np.ones_like(a) with dppy.offload_to_sycl_device(offload_device) as gpu_queue: da = dpt.usm_ndarray( a.shape, dtype=a.dtype, buffer=usm_type, buffer_ctor_kwargs={"queue": gpu_queue}, ) da.usm_data.copy_from_host(a.reshape((-1)).view("|u1")) db = dpt.usm_ndarray( b.shape, dtype=b.dtype, buffer=usm_type, buffer_ctor_kwargs={"queue": gpu_queue}, ) db.usm_data.copy_from_host(b.reshape((-1)).view("|u1")) dc = dpt.usm_ndarray( got.shape, dtype=got.dtype, buffer=usm_type, buffer_ctor_kwargs={"queue": gpu_queue}, ) data_parallel_sum[global_size, dppy.DEFAULT_LOCAL_SIZE](da, db, dc) dc.usm_data.copy_to_host(got.reshape((-1)).view("|u1")) expected = a + b assert np.array_equal(got, expected)
def gen_data_usm(nopt): # init numpy obj price_buf, strike_buf, t_buf = gen_rand_data(nopt) call_buf = np.zeros(nopt, dtype=np.float64) put_buf = -np.ones(nopt, dtype=np.float64) with dpctl.device_context(get_device_selector()) as cpu_queue: # init usmdevice memory # price_usm = dpmem.MemoryUSMDevice(nopt*np.dtype('f8').itemsize) # strike_usm = dpmem.MemoryUSMDevice(nopt*np.dtype('f8').itemsize) # t_usm = dpmem.MemoryUSMDevice(nopt*np.dtype('f8').itemsize) # call_usm = dpmem.MemoryUSMDevice(nopt*np.dtype('f8').itemsize) # put_usm = dpmem.MemoryUSMDevice(nopt*np.dtype('f8').itemsize) price_usm = dpt.usm_ndarray( price_buf.shape, dtype=price_buf.dtype, buffer="device", buffer_ctor_kwargs={"queue": cpu_queue}, ) strike_usm = dpt.usm_ndarray( strike_buf.shape, dtype=strike_buf.dtype, buffer="device", buffer_ctor_kwargs={"queue": cpu_queue}, ) t_usm = dpt.usm_ndarray( t_buf.shape, dtype=t_buf.dtype, buffer="device", buffer_ctor_kwargs={"queue": cpu_queue}, ) call_usm = dpt.usm_ndarray( call_buf.shape, dtype=call_buf.dtype, buffer="device", buffer_ctor_kwargs={"queue": cpu_queue}, ) put_usm = dpt.usm_ndarray( put_buf.shape, dtype=put_buf.dtype, buffer="device", buffer_ctor_kwargs={"queue": cpu_queue}, ) price_usm.usm_data.copy_from_host(price_buf.view("u1")) strike_usm.usm_data.copy_from_host(strike_buf.view("u1")) t_usm.usm_data.copy_from_host(t_buf.view("u1")) call_usm.usm_data.copy_from_host(call_buf.view("u1")) put_usm.usm_data.copy_from_host(put_buf.view("u1")) return (price_usm, strike_usm, t_usm, call_usm, put_usm)
def test_consuming_usm_ndarray(filter_str, dtype, usm_type): @dppy.kernel def data_parallel_sum(a, b, c): """ Vector addition using the ``kernel`` decorator. """ i = dppy.get_global_id(0) j = dppy.get_global_id(1) c[i, j] = a[i, j] + b[i, j] N = 1021 global_size = N * N a = np.array(np.random.random(global_size), dtype=dtype).reshape(N, N) b = np.array(np.random.random(global_size), dtype=dtype).reshape(N, N) got = np.ones_like(a) with dpctl.device_context(filter_str) as gpu_queue: da = dpt.usm_ndarray( a.shape, dtype=a.dtype, buffer=usm_type, buffer_ctor_kwargs={"queue": gpu_queue}, ) da.usm_data.copy_from_host(a.reshape((-1)).view("|u1")) db = dpt.usm_ndarray( b.shape, dtype=b.dtype, buffer=usm_type, buffer_ctor_kwargs={"queue": gpu_queue}, ) db.usm_data.copy_from_host(b.reshape((-1)).view("|u1")) dc = dpt.usm_ndarray( got.shape, dtype=got.dtype, buffer=usm_type, buffer_ctor_kwargs={"queue": gpu_queue}, ) data_parallel_sum[(N, N), dppy.DEFAULT_LOCAL_SIZE](da, db, dc) dc.usm_data.copy_to_host(got.reshape((-1)).view("|u1")) expected = a + b assert np.array_equal(got, expected)
def test_transpose(): n, m = 2, 3 X = dpt.usm_ndarray((n, m), "f4") Xnp = np.arange(n * m, dtype="f4").reshape((n, m)) X[:] = Xnp assert np.array_equal(dpt.to_numpy(X.T), Xnp.T) assert np.array_equal(dpt.to_numpy(X[1:].T), Xnp[1:].T)
def test_setitem_different_dtypes(): X = dpt.from_numpy(np.ones(10, "f4")) Y = dpt.from_numpy(np.zeros(10, "f4")) Z = dpt.usm_ndarray((20, ), "d") Z[::2] = X Z[1::2] = Y assert np.allclose(dpt.asnumpy(Z), np.tile(np.array([1, 0], "d"), 10))
def copy_from_usm_ndarray_to_usm_ndarray(dst, src): if type(dst) is not dpt.usm_ndarray or type(src) is not dpt.usm_ndarray: raise TypeError if dst.ndim == src.ndim and dst.shape == src.shape: copy_same_shape(dst, src) try: common_shape = np.broadcast_shapes(dst.shape, src.shape) except ValueError: raise ValueError if dst.size < src.size: raise ValueError if len(common_shape) > dst.ndim: ones_count = len(common_shape) - dst.ndim for k in range(ones_count): if common_shape[k] != 1: raise ValueError common_shape = common_shape[ones_count:] if src.ndim < len(common_shape): new_src_strides = (0, ) * (len(common_shape) - src.ndim) + src.strides src_same_shape = dpt.usm_ndarray(common_shape, dtype=src.dtype, buffer=src, strides=new_src_strides) else: src_same_shape = src src_same_shape.shape = common_shape copy_same_shape(dst, src_same_shape)
def _copy_to_usm(queue, array): if not dpctl_available: raise RuntimeError("dpctl need to be installed to work " "with __sycl_usm_array_interface__") mem = MemoryUSMDevice(array.nbytes, queue=queue) mem.copy_from_host(array.tobytes()) return usm_ndarray(array.shape, array.dtype, buffer=mem)
def __init__(self, shape, dtype="f8", buffer=None, offset=0, strides=None, order="C", device=None, usm_type="device", sycl_queue=None): if buffer is not None: if not isinstance(buffer, dpt.usm_ndarray): raise TypeError("Expected dpctl.tensor.usm_ndarray, got {}" "".format(type(buffer))) if buffer.shape != shape: raise ValueError("Expected buffer.shape={}, got {}" "".format(shape, buffer.shape)) self._array_obj = dpt.asarray(buffer, dtype=buffer.dtype, copy=False, order=order, device=buffer.sycl_device, usm_type=buffer.usm_type, sycl_queue=buffer.sycl_queue) else: sycl_queue_normalized = normalize_queue_device( sycl_queue=sycl_queue, device=device) self._array_obj = dpt.usm_ndarray( shape, dtype=dtype, strides=strides, buffer=usm_type, offset=offset, order=order, buffer_ctor_kwargs={"queue": sycl_queue_normalized})
def test_basic_slice(ind): X = dpt.usm_ndarray((2 * 3, 2 * 4, 3 * 5, 2 * 7), dtype="u1") Xnp = np.empty(X.shape, dtype=X.dtype) S = X[ind] Snp = Xnp[ind] assert S.shape == Snp.shape assert S.strides == Snp.strides assert S.dtype == X.dtype
def test_ctor_buffer_kwarg(): dpt.usm_ndarray(10, buffer=b"device") with pytest.raises(ValueError): dpt.usm_ndarray(10, buffer="invalid_param") Xusm = dpt.usm_ndarray((10, 5), dtype="c16") X2 = dpt.usm_ndarray(Xusm.shape, buffer=Xusm, dtype=Xusm.dtype) assert np.array_equal(Xusm.usm_data.copy_to_host(), X2.usm_data.copy_to_host()) with pytest.raises(ValueError): dpt.usm_ndarray(10, buffer=dict())
def test_context_manager_with_usm_ndarray(offload_device, input_arrays): usm_type = "device" a, b, expected = input_arrays got = np.ones_like(a) device = dpctl.SyclDevice(offload_device) queue = dpctl.SyclQueue(device) da = dpt.usm_ndarray( a.shape, dtype=a.dtype, buffer=usm_type, buffer_ctor_kwargs={"queue": queue}, ) da.usm_data.copy_from_host(a.reshape((-1)).view("|u1")) db = dpt.usm_ndarray( b.shape, dtype=b.dtype, buffer=usm_type, buffer_ctor_kwargs={"queue": queue}, ) db.usm_data.copy_from_host(b.reshape((-1)).view("|u1")) dc = dpt.usm_ndarray( got.shape, dtype=got.dtype, buffer=usm_type, buffer_ctor_kwargs={"queue": queue}, ) with pytest.warns(Warning) as warning: with numba_dppy.offload_to_sycl_device(offload_device): sum_kernel[global_size, local_size](da, db, dc) if not warning: pytest.fail("Warning expected!") sum_kernel[global_size, local_size](da, db, dc) dc.usm_data.copy_to_host(got.reshape((-1)).view("|u1")) expected = a + b assert np.array_equal(got, expected)
def test_astype(): X = dpt.usm_ndarray((5, 5), "i4") X[:] = np.full((5, 5), 7, dtype="i4") Y = dpt.astype(X, "c16", order="C") assert np.allclose(dpt.to_numpy(Y), np.full((5, 5), 7, dtype="c16")) Y = dpt.astype(X, "f2", order="K") assert np.allclose(dpt.to_numpy(Y), np.full((5, 5), 7, dtype="f2")) Y = dpt.astype(X, "i4", order="K", copy=False) assert Y.usm_data is X.usm_data
def test_usm_ndarray_type(offload_device, dtype, usm_type): if skip_test(offload_device): pytest.skip() a = np.array(np.random.random(10), dtype) da = dpt.usm_ndarray(a.shape, dtype=a.dtype, buffer=usm_type) assert isinstance(typeof(da), USMNdArrayType) assert da.usm_type == usm_type
def test_queue_parameter_with_usm_ndarray(memtype): from dpctl import SyclQueue from dpctl.tensor import usm_ndarray q1 = SyclQueue('cpu') q2 = SyclQueue('gpu') X = usm_ndarray((5, 3), buffer=memtype(5 * 3 * 8, queue=q1)) assert _get_policy(q2, X).get_device_name() == device_type_to_str(q2)
def test_pyx_capi_get_ndim(): X = dpt.usm_ndarray(17)[1::2] get_ndim_fn = _pyx_capi_fnptr_to_callable( X, "usm_ndarray_get_ndim", b"int (struct PyUSMArrayObject *)", fn_restype=ctypes.c_int, ) assert get_ndim_fn(X) == X.ndim
def gen_data_usm(nopt): X, arrayPclusters, arrayC, arrayCsum, arrayCnumpoint = gen_rand_data( nopt, dtype=np.float32) with dpctl.device_context(get_device_selector()) as gpu_queue: X_usm = dpt.usm_ndarray( X.shape, dtype=X.dtype, buffer="device", buffer_ctor_kwargs={"queue": gpu_queue}, ) arrayPclusters_usm = dpt.usm_ndarray( arrayPclusters.shape, dtype=arrayPclusters.dtype, buffer="device", buffer_ctor_kwargs={"queue": gpu_queue}, ) arrayC_usm = dpt.usm_ndarray( arrayC.shape, dtype=arrayC.dtype, buffer="device", buffer_ctor_kwargs={"queue": gpu_queue}, ) arrayCsum_usm = dpt.usm_ndarray( arrayCsum.shape, dtype=arrayCsum.dtype, buffer="device", buffer_ctor_kwargs={"queue": gpu_queue}, ) arrayCnumpoint_usm = dpt.usm_ndarray( arrayCnumpoint.shape, dtype=arrayCnumpoint.dtype, buffer="device", buffer_ctor_kwargs={"queue": gpu_queue}, ) X_usm.usm_data.copy_from_host(X.reshape((-1)).view("u1")) arrayPclusters_usm.usm_data.copy_from_host(arrayPclusters.view("u1")) arrayC_usm.usm_data.copy_from_host(arrayC.reshape((-1)).view("u1")) arrayCsum_usm.usm_data.copy_from_host(arrayCsum.reshape((-1)).view("u1")) arrayCnumpoint_usm.usm_data.copy_from_host(arrayCnumpoint.view("u1")) return (X_usm, arrayPclusters_usm, arrayC_usm, arrayCsum_usm, arrayCnumpoint_usm)
def test_pyx_capi_get_queue_ref(): X = dpt.usm_ndarray(17)[1::2] get_queue_ref_fn = _pyx_capi_fnptr_to_callable( X, "usm_ndarray_get_queue_ref", b"DPCTLSyclQueueRef (struct PyUSMArrayObject *)", fn_restype=ctypes.c_void_p, ) queue_ref = get_queue_ref_fn(X) # address of a copy, should be unequal assert queue_ref != X.sycl_queue.addressof_ref()