You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from a Python object <codeclass="docutils literal notranslate"><spanclass="pre">x</span></code> that implements <codeclass="docutils literal notranslate"><spanclass="pre">__dlpack__</span></code> protocol.</p>
<li><p><strong>device</strong> (Optional[str, <aclass="reference internal" href="dpctl.SyclDevice.html#dpctl.SyclDevice" title="dpctl.SyclDevice"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">dpctl.SyclDevice</span></code></a>, <aclass="reference internal" href="dpctl.SyclQueue.html#dpctl.SyclQueue" title="dpctl.SyclQueue"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">dpctl.SyclQueue</span></code></a>, <aclass="reference internal" href="../tensor.utility_functions.html#dpctl.tensor.Device" title="dpctl.tensor.Device"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">dpctl.tensor.Device</span></code></a>, tuple([<aclass="reference external" href="https://docs.python.org/3/library/enum.html#enum.IntEnum" title="(in Python v3.13)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">enum.IntEnum</span></code></a>, int])])) – Array API concept of a device where the output array is to be placed.
832
-
<codeclass="docutils literal notranslate"><spanclass="pre">device</span></code> can be <codeclass="docutils literal notranslate"><spanclass="pre">None</span></code>, a oneAPI filter selector
833
-
string, an instance of <aclass="reference internal" href="dpctl.SyclDevice.html#dpctl.SyclDevice" title="dpctl.SyclDevice"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">dpctl.SyclDevice</span></code></a> corresponding to
returned by <aclass="reference internal" href="generated/dpctl.tensor.usm_ndarray.device.html#dpctl.tensor.usm_ndarray.device" title="dpctl.tensor.usm_ndarray.device"><codeclass="xref py py-attr docutils literal notranslate"><spanclass="pre">dpctl.tensor.usm_ndarray.device</span></code></a>, or a
837
-
2-tuple matching the format of the output of the <codeclass="docutils literal notranslate"><spanclass="pre">__dlpack_device__</span></code>
838
-
method, an integer enumerator representing the device type followed by
839
-
an integer representing the index of the device. The only supported
840
-
<aclass="reference internal" href="../tensor.constants.html#dpctl.tensor.DLDeviceType" title="dpctl.tensor.DLDeviceType"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">dpctl.tensor.DLDeviceType</span></code></a> types are “kDLCPU” and
<li><p><strong>copy</strong> (<aclass="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.13)"><em>bool</em></a><em>, </em><em>optional</em>) – <p>Boolean indicating whether or not to copy the input.</p>
831
+
<li><p><strong>device</strong> (Optional[str, <aclass="reference internal" href="dpctl.SyclDevice.html#dpctl.SyclDevice" title="dpctl.SyclDevice"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">dpctl.SyclDevice</span></code></a>, <aclass="reference internal" href="dpctl.SyclQueue.html#dpctl.SyclQueue" title="dpctl.SyclQueue"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">dpctl.SyclQueue</span></code></a>, <aclass="reference internal" href="../tensor.utility_functions.html#dpctl.tensor.Device" title="dpctl.tensor.Device"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">dpctl.tensor.Device</span></code></a>, tuple([<aclass="reference external" href="https://docs.python.org/3/library/enum.html#enum.IntEnum" title="(in Python v3.13)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">enum.IntEnum</span></code></a>, int])])) – <p>Device where the output array is to be placed. <codeclass="docutils literal notranslate"><spanclass="pre">device</span></code> keyword values can be:</p>
844
832
<ul>
845
833
<li><dlclass="simple">
846
-
<dt>If <codeclass="docutils literal notranslate"><spanclass="pre">copy</span></code> is <codeclass="docutils literal notranslate"><spanclass="pre">True</span></code>, the input will always be</dt><dd><p>copied.</p>
834
+
<dt><codeclass="docutils literal notranslate"><spanclass="pre">None</span></code></dt><dd><p>The data remains on the same device.</p>
<dt>If <codeclass="docutils literal notranslate"><spanclass="pre">False</span></code>, a <codeclass="docutils literal notranslate"><spanclass="pre">BufferError</span></code> will be raised if a</dt><dd><p>copy is deemed necessary.</p>
844
+
<dt><aclass="reference internal" href="dpctl.SyclDevice.html#dpctl.SyclDevice" title="dpctl.SyclDevice"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">dpctl.SyclDevice</span></code></a></dt><dd><p>explicit SYCL device that must correspond to
845
+
a non-partitioned SYCL device.</p>
852
846
</dd>
853
847
</dl>
854
848
</li>
855
849
<li><dlclass="simple">
856
-
<dt>If <codeclass="docutils literal notranslate"><spanclass="pre">None</span></code>, a copy will be made only if deemed</dt><dd><p>necessary, otherwise, the existing memory buffer will
857
-
be reused.</p>
850
+
<dt><aclass="reference internal" href="dpctl.SyclQueue.html#dpctl.SyclQueue" title="dpctl.SyclQueue"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">dpctl.SyclQueue</span></code></a></dt><dd><p>implies SYCL device targeted by the SYCL queue.</p>
is obtained via <aclass="reference internal" href="generated/dpctl.tensor.usm_ndarray.device.html#dpctl.tensor.usm_ndarray.device" title="dpctl.tensor.usm_ndarray.device"><codeclass="xref py py-attr docutils literal notranslate"><spanclass="pre">dpctl.tensor.usm_ndarray.device</span></code></a>.</p>
857
+
</dd>
858
+
</dl>
859
+
</li>
860
+
<li><dlclass="simple">
861
+
<dt><codeclass="docutils literal notranslate"><spanclass="pre">(device_type,</span><spanclass="pre">device_id)</span></code></dt><dd><p>2-tuple matching the format of the output of the <codeclass="docutils literal notranslate"><spanclass="pre">__dlpack_device__</span></code>
862
+
method: an integer enumerator representing the device type followed by
863
+
an integer representing the index of the device.
864
+
The only supported <aclass="reference internal" href="../tensor.constants.html#dpctl.tensor.DLDeviceType" title="dpctl.tensor.DLDeviceType"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">dpctl.tensor.DLDeviceType</span></code></a> device types
865
+
are <codeclass="docutils literal notranslate"><spanclass="pre">"kDLCPU"</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">"kDLOneAPI"</span></code>.</p>
<li><p><strong>copy</strong> (<aclass="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.13)"><em>bool</em></a><em>, </em><em>optional</em>) – <p>Boolean indicating whether or not to copy the input.</p>
873
+
<ul>
874
+
<li><p>If <codeclass="docutils literal notranslate"><spanclass="pre">copy</span></code> is <codeclass="docutils literal notranslate"><spanclass="pre">True</span></code>, the input will always be
875
+
copied.</p></li>
876
+
<li><p>If <codeclass="docutils literal notranslate"><spanclass="pre">False</span></code>, a <codeclass="docutils literal notranslate"><spanclass="pre">BufferError</span></code> will be raised if a
877
+
copy is deemed necessary.</p></li>
878
+
<li><p>If <codeclass="docutils literal notranslate"><spanclass="pre">None</span></code>, a copy will be made only if deemed
879
+
necessary, otherwise, the existing memory buffer will
<ddclass="field-even"><p>An array containing the data in <codeclass="docutils literal notranslate"><spanclass="pre">x</span></code>. When <codeclass="docutils literal notranslate"><spanclass="pre">copy</span></code> is
887
+
<ddclass="field-even"><p><p>An array containing the data in <codeclass="docutils literal notranslate"><spanclass="pre">x</span></code>. When <codeclass="docutils literal notranslate"><spanclass="pre">copy</span></code> is
868
888
<codeclass="docutils literal notranslate"><spanclass="pre">None</span></code> or <codeclass="docutils literal notranslate"><spanclass="pre">False</span></code>, this may be a view into the original
869
889
memory.</p>
890
+
<p>The type of the returned object
891
+
depends on where the data backing up input object <codeclass="docutils literal notranslate"><spanclass="pre">x</span></code> resides.
892
+
If it resides in a USM allocation on a SYCL device, the
893
+
type <aclass="reference internal" href="dpctl.tensor.usm_ndarray.html#dpctl.tensor.usm_ndarray" title="dpctl.tensor.usm_ndarray"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">dpctl.tensor.usm_ndarray</span></code></a> is returned, otherwise if it resides
894
+
on <codeclass="docutils literal notranslate"><spanclass="pre">"kDLCPU"</span></code> device the type is <aclass="reference external" href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="(in NumPy v2.1)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">numpy.ndarray</span></code></a>, and otherwise
895
+
an exception is raised.</p>
896
+
<divclass="admonition note">
897
+
<pclass="admonition-title">Note</p>
898
+
<p>If the return type is <aclass="reference internal" href="dpctl.tensor.usm_ndarray.html#dpctl.tensor.usm_ndarray" title="dpctl.tensor.usm_ndarray"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">dpctl.tensor.usm_ndarray</span></code></a>, the associated
899
+
SYCL queue is derived from the <codeclass="docutils literal notranslate"><spanclass="pre">device</span></code> keyword. When <codeclass="docutils literal notranslate"><spanclass="pre">device</span></code>
900
+
keyword value has type <aclass="reference internal" href="dpctl.SyclQueue.html#dpctl.SyclQueue" title="dpctl.SyclQueue"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">dpctl.SyclQueue</span></code></a>, the explicit queue
901
+
instance is used, when <codeclass="docutils literal notranslate"><spanclass="pre">device</span></code> keyword value has type <aclass="reference internal" href="../tensor.utility_functions.html#dpctl.tensor.Device" title="dpctl.tensor.Device"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">dpctl.tensor.Device</span></code></a>,
902
+
the <codeclass="docutils literal notranslate"><spanclass="pre">device.sycl_queue</span></code> is used. In all other cases, the cached
903
+
SYCL queue corresponding to the implied SYCL device is used.</p>
<li><p><aclass="reference external" href="https://docs.python.org/3/library/exceptions.html#TypeError" title="(in Python v3.13)"><strong>TypeError</strong></a> – if <codeclass="docutils literal notranslate"><spanclass="pre">x</span></code> does not implement <codeclass="docutils literal notranslate"><spanclass="pre">__dlpack__</span></code> method</p></li>
877
-
<li><p><aclass="reference external" href="https://docs.python.org/3/library/exceptions.html#ValueError" title="(in Python v3.13)"><strong>ValueError</strong></a> – if the input array resides on an unsupported device</p></li>
913
+
<li><p><aclass="reference external" href="https://docs.python.org/3/library/exceptions.html#ValueError" title="(in Python v3.13)"><strong>ValueError</strong></a> – if data of the input object resides on an unsupported device</p></li>
0 commit comments