From f02862ba0268366f433d161e32cdc632b4acc672 Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlyk Date: Fri, 11 Aug 2023 13:18:11 -0500 Subject: [PATCH] Fixed test_from_dlpack and test_from_dlpack_strided for USM-host allocations Since USM-host allocation, unlike USM-device and USM-shared allocations, is not associated with any particular device, only with the host, it is unreasonable to expect that sycl::get_pointer_device(ptr, ctx) will return the same device that is stored in the sycl_queue associated with the dpctl.tensor.usm_ndarray. The tests are adjusted to bypass that check for USM-host allocations. --- dpctl/tests/test_usm_ndarray_dlpack.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dpctl/tests/test_usm_ndarray_dlpack.py b/dpctl/tests/test_usm_ndarray_dlpack.py index c82a27807c..a6d7eab975 100644 --- a/dpctl/tests/test_usm_ndarray_dlpack.py +++ b/dpctl/tests/test_usm_ndarray_dlpack.py @@ -127,9 +127,11 @@ def test_from_dlpack(shape, typestr, usm_type): Y = dpt.from_dlpack(X) assert X.shape == Y.shape assert X.dtype == Y.dtype - assert X.sycl_device == Y.sycl_device assert X.usm_type == Y.usm_type assert X._pointer == Y._pointer + # we can only expect device to round-trip for USM-device and + # USM-shared allocations, which are made for specific device + assert (Y.usm_type == "host") or (X.sycl_device == Y.sycl_device) if Y.ndim: V = Y[::-1] W = dpt.from_dlpack(V) @@ -149,9 +151,11 @@ def test_from_dlpack_strides(mod, typestr, usm_type): Y = dpt.from_dlpack(X) assert X.shape == Y.shape assert X.dtype == Y.dtype - assert X.sycl_device == Y.sycl_device assert X.usm_type == Y.usm_type assert X._pointer == Y._pointer + # we can only expect device to round-trip for USM-device and + # USM-shared allocations, which are made for specific device + assert (Y.usm_type == "host") or (X.sycl_device == Y.sycl_device) if Y.ndim: V = Y[::-1] W = dpt.from_dlpack(V)