From 093b135ad5c60abe35ddac750f24ccf556eda99b Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Mon, 29 Jun 2026 15:58:01 +0200 Subject: [PATCH 1/4] Updated __array_namespace_info__().devices() to return a tuple with Data-API concept of devices --- dpnp/tensor/_array_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dpnp/tensor/_array_api.py b/dpnp/tensor/_array_api.py index a18bc2be1824..dd0ed0007a5c 100644 --- a/dpnp/tensor/_array_api.py +++ b/dpnp/tensor/_array_api.py @@ -239,9 +239,9 @@ def devices(self): """ devices() - Returns a list of supported devices. + Returns a tuple of supported devices. """ - return dpctl.get_devices() + return tuple(dpt.Device.create_device(d) for d in dpctl.get_devices()) def __array_namespace_info__(): From f76b1360ae263d5bc3216c58074b1c5464cd5f70 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Mon, 29 Jun 2026 16:03:54 +0200 Subject: [PATCH 2/4] Update tests --- dpnp/tests/tensor/test_tensor_array_api_inspection.py | 2 +- dpnp/tests/test_array_api_info.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dpnp/tests/tensor/test_tensor_array_api_inspection.py b/dpnp/tests/tensor/test_tensor_array_api_inspection.py index 2eb198944656..7500af5a58ab 100644 --- a/dpnp/tests/tensor/test_tensor_array_api_inspection.py +++ b/dpnp/tests/tensor/test_tensor_array_api_inspection.py @@ -79,7 +79,7 @@ def test_array_api_inspection_devices(): pytest.skip("No default device available") devices1 = dpt.__array_namespace_info__().devices() assert len(devices1) == len(devices2) - assert devices1 == devices2 + assert tuple(dev.sycl_device for dev in devices1) == devices2 def test_array_api_inspection_capabilities(): diff --git a/dpnp/tests/test_array_api_info.py b/dpnp/tests/test_array_api_info.py index 9b1f0cc20108..99325ec338a3 100644 --- a/dpnp/tests/test_array_api_info.py +++ b/dpnp/tests/test_array_api_info.py @@ -130,4 +130,6 @@ def test_dtypes_invalid_device(): def test_devices(): - assert info.devices() == get_devices() + devices = info.devices() + assert isinstance(devices, tuple) + assert tuple(dev.sycl_device for dev in devices) == get_devices() From 0b176280639d4c35b56cbe521268d21bcefcf7a2 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Mon, 29 Jun 2026 16:06:45 +0200 Subject: [PATCH 3/4] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27c8329caa19..9f3fd9516e0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ This release is compatible with NumPy 2.5. * Fixed `dpnp.linalg.svd(..., hermitian=True)` returning a non-unitary `vh` for singular input arrays due to a zero sign appearing [#2954](https://github.com/IntelPython/dpnp/pull/2954) * Fixed scalar conversion of size-one `dpnp.tensor.usm_ndarray` (e.g. `int()`, `float()`, indexing) which failed with NumPy 2.5 after the in-place `ndarray.shape` assignment was deprecated [#2958](https://github.com/IntelPython/dpnp/pull/2958) * Fixed `dpnp.mgrid` and `dpnp.ogrid` to return consistent results between single-slice and tuple-of-slices syntax when the step is a complex number with a non-integer magnitude (e.g. `2.5j`) [#2971](https://github.com/IntelPython/dpnp/pull/2971) +* Fixed `__array_namespace_info__().devices()` to return a tuple of Python array API compatible device objects [#2979](https://github.com/IntelPython/dpnp/pull/2979) ### Security From 7bd7d316b7cc8f5160a7c75e449aeb9098891b5c Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Mon, 29 Jun 2026 16:17:35 +0200 Subject: [PATCH 4/4] Updated __array_namespace_info__().default_device() to return default Data-API device --- CHANGELOG.md | 2 +- dpnp/tensor/_array_api.py | 4 ++-- dpnp/tests/tensor/test_tensor_array_api_inspection.py | 6 +++--- dpnp/tests/test_array_api_info.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f3fd9516e0d..e17cff49cacf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,7 +54,7 @@ This release is compatible with NumPy 2.5. * Fixed `dpnp.linalg.svd(..., hermitian=True)` returning a non-unitary `vh` for singular input arrays due to a zero sign appearing [#2954](https://github.com/IntelPython/dpnp/pull/2954) * Fixed scalar conversion of size-one `dpnp.tensor.usm_ndarray` (e.g. `int()`, `float()`, indexing) which failed with NumPy 2.5 after the in-place `ndarray.shape` assignment was deprecated [#2958](https://github.com/IntelPython/dpnp/pull/2958) * Fixed `dpnp.mgrid` and `dpnp.ogrid` to return consistent results between single-slice and tuple-of-slices syntax when the step is a complex number with a non-integer magnitude (e.g. `2.5j`) [#2971](https://github.com/IntelPython/dpnp/pull/2971) -* Fixed `__array_namespace_info__().devices()` to return a tuple of Python array API compatible device objects [#2979](https://github.com/IntelPython/dpnp/pull/2979) +* Fixed `__array_namespace_info__().devices()` and `.default_device()` to return Python array API compatible device objects [#2979](https://github.com/IntelPython/dpnp/pull/2979) ### Security diff --git a/dpnp/tensor/_array_api.py b/dpnp/tensor/_array_api.py index dd0ed0007a5c..e8ff4fddbedd 100644 --- a/dpnp/tensor/_array_api.py +++ b/dpnp/tensor/_array_api.py @@ -132,9 +132,9 @@ def default_device(self): """ default_device() - Returns the default SYCL device. + Returns the default device. """ - return dpctl.select_default_device() + return dpt.Device.create_device(dpctl.select_default_device()) def default_dtypes(self, *, device=None): """ diff --git a/dpnp/tests/tensor/test_tensor_array_api_inspection.py b/dpnp/tests/tensor/test_tensor_array_api_inspection.py index 7500af5a58ab..a04bccaf5dbe 100644 --- a/dpnp/tests/tensor/test_tensor_array_api_inspection.py +++ b/dpnp/tests/tensor/test_tensor_array_api_inspection.py @@ -69,7 +69,7 @@ def test_array_api_inspection_default_device(): dev = dpctl.select_default_device() except dpctl.SyclDeviceCreationError: pytest.skip("No default device available") - assert dpt.__array_namespace_info__().default_device() == dev + assert dpt.__array_namespace_info__().default_device().sycl_device == dev def test_array_api_inspection_devices(): @@ -142,7 +142,7 @@ def test_array_api_inspection_device_dtypes(): except dpctl.SyclDeviceCreationError: pytest.skip("No default device available") dtypes = _dtypes_no_fp16_fp64.copy() - if dev.has_aspect_fp64: + if dev.sycl_device.has_aspect_fp64: dtypes["float64"] = dpt.float64 dtypes["complex128"] = dpt.complex128 @@ -210,7 +210,7 @@ def test_array_api_inspection_dtype_kind_errors(): def test_array_api_inspection_device_types(): info = dpt.__array_namespace_info__() try: - dev = info.default_device() + dev = info.default_device().sycl_device except dpctl.SyclDeviceCreationError: pytest.skip("No default device available") diff --git a/dpnp/tests/test_array_api_info.py b/dpnp/tests/test_array_api_info.py index 99325ec338a3..60f81c0eddd3 100644 --- a/dpnp/tests/test_array_api_info.py +++ b/dpnp/tests/test_array_api_info.py @@ -22,7 +22,7 @@ def test_capabilities(): def test_default_device(): - assert info.default_device() == default_device + assert info.default_device().sycl_device == default_device def test_default_dtypes():