Skip to content

Commit eda845b

Browse files
Return Python array API compatible device objects from inspection namespace (#2979)
The array API inspection namespace (`__array_namespace_info__()`) returned raw `dpctl.SyclDevice` objects from `devices()` and `default_device()`, while an array's `.device` attribute is a `dpnp.tensor.Device` wrapper. Because `Device.__eq__` does not consider a bare `SyclDevice` equal, the objects returned by the inspection API did **not** compare equal to `x.device`, which the Python array API standard requires: ```python import dpnp as np devices = np.__array_namespace_info__().devices() devices # Out: # (<dpctl.SyclDevice [backend_type.level_zero, device_type.gpu, Intel(R) Graphics [0x7d41]] at 0x74bb28198030>, # <dpctl.SyclDevice [backend_type.opencl, device_type.cpu, Intel(R) Core(TM) Ultra 7 265U] at 0x74bb28198d30>, # <dpctl.SyclDevice [backend_type.opencl, device_type.gpu, Intel(R) Graphics [0x7d41]] at 0x74bb2a117870>) x = np.ones(10) y = np.from_dlpack(x, device=devices[1]) y.device == devices[1] # Out: False y.device.sycl_device == devices[1] # Out: True ``` ## Changes This PR updates `Info.devices()` to return a **tuple** of `dpnp.tensor.Device` wrappers (built via `Device.create_device`), instead of a list of raw `dpctl.SyclDevice` objects. The wrappers carry the default cached queues for each root device, which is sufficient for the common cases. Additionally `Info.default_device()` likewise now returns a `Device` wrapper for consistency, so `x.device`, `default_device()`, and the elements of `devices()` all compare equal for the default device. 576a07b
1 parent b876fd6 commit eda845b

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

reference/comparison.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@
10401040
<h1>Comparison Table NumPy/ DPNP/ CuPy<a class="headerlink" href="#comparison-table-numpy-dpnp-cupy" title="Link to this heading">¶</a></h1>
10411041
<p>Here is a list of NumPy and CuPy APIs and its corresponding DPNP implementations.</p>
10421042
<p><code class="docutils literal notranslate"><span class="pre">-</span></code> in DPNP column means that DPNP implementation is not provided yet.</p>
1043-
<p><strong>NumPy(v2.5.1) / DPNP(v0.21.0dev2+13.gb9b515e3711) / CuPy(v14.1.1) APIs</strong></p>
1043+
<p><strong>NumPy(v2.5.1) / DPNP(v0.21.0dev2+14.g576a07b9cff) / CuPy(v14.1.1) APIs</strong></p>
10441044
<section id="summary">
10451045
<h2>Summary<a class="headerlink" href="#summary" title="Link to this heading">¶</a></h2>
10461046
<div class="table-wrapper docutils container">

searchindex.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)