Skip to content

Commit a92d35f

Browse files
Align with dpctl changes for DLPack v1.0 support (#1980)
* Adopt dpnp to DLPack v1.0 * Add more tests to cover different use cases 7c8e83f
1 parent b72553b commit a92d35f

File tree

509 files changed

+1645
-1533
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

509 files changed

+1645
-1533
lines changed

.buildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: 5a2aabf17785544d6749f88a18e15dfe
3+
config: 89cb4a5b0282510d312a9965fa4fed0d
44
tags: 645f666f9bcd5a90fca523b33c5a78b7

_modules/dpnp/dpnp_array.html

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</script>
1313

1414
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
15-
<title>dpnp.dpnp_array &mdash; Data Parallel Extension for NumPy 0.16.0dev0+158.gef4a310502e documentation</title>
15+
<title>dpnp.dpnp_array &mdash; Data Parallel Extension for NumPy 0.16.0dev0+159.g7c8e83f7ada documentation</title>
1616
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
1717
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=19f00094" />
1818

@@ -23,7 +23,7 @@
2323

2424
<script src="../../_static/jquery.js?v=5d32c60e"></script>
2525
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
26-
<script src="../../_static/documentation_options.js?v=3ddceb5c"></script>
26+
<script src="../../_static/documentation_options.js?v=cc63d5c7"></script>
2727
<script src="../../_static/doctools.js?v=9a2dae69"></script>
2828
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
2929
<script src="../../_static/js/theme.js"></script>
@@ -43,7 +43,7 @@
4343
Data Parallel Extension for NumPy
4444
</a>
4545
<div class="version">
46-
0.16.0dev0+158.gef4a310502e
46+
0.16.0dev0+159.g7c8e83f7ada
4747
</div>
4848
<div role="search">
4949
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
@@ -282,27 +282,61 @@ <h1>Source code for dpnp.dpnp_array</h1><div class="highlight"><pre>
282282
<span class="c1"># &#39;__divmod__&#39;,</span>
283283
<span class="c1"># &#39;__doc__&#39;,</span>
284284

285-
<span class="k">def</span> <span class="nf">__dlpack__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">stream</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
285+
<span class="k">def</span> <span class="nf">__dlpack__</span><span class="p">(</span>
286+
<span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">stream</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">max_version</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">dl_device</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">None</span>
287+
<span class="p">):</span>
286288
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
287289
<span class="sd"> Produces DLPack capsule.</span>
288290

289291
<span class="sd"> Parameters</span>
290292
<span class="sd"> ----------</span>
291293
<span class="sd"> stream : {:class:`dpctl.SyclQueue`, None}, optional</span>
292-
<span class="sd"> Execution queue to synchronize with. If ``None``,</span>
293-
<span class="sd"> synchronization is not performed.</span>
294+
<span class="sd"> Execution queue to synchronize with. If ``None``, synchronization</span>
295+
<span class="sd"> is not performed.</span>
296+
<span class="sd"> Default: ``None``.</span>
297+
<span class="sd"> max_version {tuple of ints, None}, optional</span>
298+
<span class="sd"> The maximum DLPack version the consumer (caller of ``__dlpack__``)</span>
299+
<span class="sd"> supports. As ``__dlpack__`` may not always return a DLPack capsule</span>
300+
<span class="sd"> with version `max_version`, the consumer must verify the version</span>
301+
<span class="sd"> even if this argument is passed.</span>
302+
<span class="sd"> Default: ``None``.</span>
303+
<span class="sd"> dl_device {tuple, None}, optional:</span>
304+
<span class="sd"> The device the returned DLPack capsule will be placed on. The</span>
305+
<span class="sd"> device must be a 2-tuple matching the format of</span>
306+
<span class="sd"> ``__dlpack_device__`` method, an integer enumerator representing</span>
307+
<span class="sd"> the device type followed by an integer representing the index of</span>
308+
<span class="sd"> the device.</span>
309+
<span class="sd"> Default: ``None``.</span>
310+
<span class="sd"> copy {bool, None}, optional:</span>
311+
<span class="sd"> Boolean indicating whether or not to copy the input.</span>
312+
313+
<span class="sd"> * If `copy` is ``True``, the input will always be copied.</span>
314+
<span class="sd"> * If ``False``, a ``BufferError`` will be raised if a copy is</span>
315+
<span class="sd"> deemed necessary.</span>
316+
<span class="sd"> * If ``None``, a copy will be made only if deemed necessary,</span>
317+
<span class="sd"> otherwise, the existing memory buffer will be reused.</span>
318+
319+
<span class="sd"> Default: ``None``.</span>
294320

295321
<span class="sd"> Raises</span>
296322
<span class="sd"> ------</span>
297-
<span class="sd"> MemoryError</span>
323+
<span class="sd"> MemoryError:</span>
298324
<span class="sd"> when host memory can not be allocated.</span>
299-
<span class="sd"> DLPackCreationError</span>
300-
<span class="sd"> when array is allocated on a partitioned</span>
301-
<span class="sd"> SYCL device, or with a non-default context.</span>
325+
<span class="sd"> DLPackCreationError:</span>
326+
<span class="sd"> when array is allocated on a partitioned SYCL device, or with</span>
327+
<span class="sd"> a non-default context.</span>
328+
<span class="sd"> BufferError:</span>
329+
<span class="sd"> when a copy is deemed necessary but `copy` is ``False`` or when</span>
330+
<span class="sd"> the provided `dl_device` cannot be handled.</span>
302331

303332
<span class="sd"> &quot;&quot;&quot;</span>
304333

305-
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_array_obj</span><span class="o">.</span><span class="n">__dlpack__</span><span class="p">(</span><span class="n">stream</span><span class="o">=</span><span class="n">stream</span><span class="p">)</span>
334+
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_array_obj</span><span class="o">.</span><span class="n">__dlpack__</span><span class="p">(</span>
335+
<span class="n">stream</span><span class="o">=</span><span class="n">stream</span><span class="p">,</span>
336+
<span class="n">max_version</span><span class="o">=</span><span class="n">max_version</span><span class="p">,</span>
337+
<span class="n">dl_device</span><span class="o">=</span><span class="n">dl_device</span><span class="p">,</span>
338+
<span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span>
339+
<span class="p">)</span>
306340

307341
<span class="k">def</span> <span class="nf">__dlpack_device__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
308342
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>

_modules/dpnp/dpnp_flatiter.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</script>
1313

1414
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
15-
<title>dpnp.dpnp_flatiter &mdash; Data Parallel Extension for NumPy 0.16.0dev0+158.gef4a310502e documentation</title>
15+
<title>dpnp.dpnp_flatiter &mdash; Data Parallel Extension for NumPy 0.16.0dev0+159.g7c8e83f7ada documentation</title>
1616
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
1717
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=19f00094" />
1818

@@ -23,7 +23,7 @@
2323

2424
<script src="../../_static/jquery.js?v=5d32c60e"></script>
2525
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
26-
<script src="../../_static/documentation_options.js?v=3ddceb5c"></script>
26+
<script src="../../_static/documentation_options.js?v=cc63d5c7"></script>
2727
<script src="../../_static/doctools.js?v=9a2dae69"></script>
2828
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
2929
<script src="../../_static/js/theme.js"></script>
@@ -43,7 +43,7 @@
4343
Data Parallel Extension for NumPy
4444
</a>
4545
<div class="version">
46-
0.16.0dev0+158.gef4a310502e
46+
0.16.0dev0+159.g7c8e83f7ada
4747
</div>
4848
<div role="search">
4949
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">

_modules/dpnp/dpnp_iface.html

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</script>
1313

1414
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
15-
<title>dpnp.dpnp_iface &mdash; Data Parallel Extension for NumPy 0.16.0dev0+158.gef4a310502e documentation</title>
15+
<title>dpnp.dpnp_iface &mdash; Data Parallel Extension for NumPy 0.16.0dev0+159.g7c8e83f7ada documentation</title>
1616
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
1717
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=19f00094" />
1818

@@ -23,7 +23,7 @@
2323

2424
<script src="../../_static/jquery.js?v=5d32c60e"></script>
2525
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
26-
<script src="../../_static/documentation_options.js?v=3ddceb5c"></script>
26+
<script src="../../_static/documentation_options.js?v=cc63d5c7"></script>
2727
<script src="../../_static/doctools.js?v=9a2dae69"></script>
2828
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
2929
<script src="../../_static/js/theme.js"></script>
@@ -43,7 +43,7 @@
4343
Data Parallel Extension for NumPy
4444
</a>
4545
<div class="version">
46-
0.16.0dev0+158.gef4a310502e
46+
0.16.0dev0+159.g7c8e83f7ada
4747
</div>
4848
<div role="search">
4949
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
@@ -562,7 +562,7 @@ <h1>Source code for dpnp.dpnp_iface</h1><div class="highlight"><pre>
562562

563563
<div class="viewcode-block" id="from_dlpack">
564564
<a class="viewcode-back" href="../../reference/generated/dpnp.from_dlpack.html#dpnp.from_dlpack">[docs]</a>
565-
<span class="k">def</span> <span class="nf">from_dlpack</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="o">/</span><span class="p">):</span>
565+
<span class="k">def</span> <span class="nf">from_dlpack</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="o">/</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">device</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
566566
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
567567
<span class="sd"> Create a dpnp array from a Python object implementing the ``__dlpack__``</span>
568568
<span class="sd"> protocol.</span>
@@ -574,17 +574,46 @@ <h1>Source code for dpnp.dpnp_iface</h1><div class="highlight"><pre>
574574
<span class="sd"> obj : object</span>
575575
<span class="sd"> A Python object representing an array that implements the ``__dlpack__``</span>
576576
<span class="sd"> and ``__dlpack_device__`` methods.</span>
577+
<span class="sd"> device : {:class:`dpctl.SyclDevice`, :class:`dpctl.SyclQueue`,</span>
578+
<span class="sd"> :class:`dpctl.tensor.Device`, tuple, None}, optional</span>
579+
<span class="sd"> Array API concept of a device where the output array is to be placed.</span>
580+
<span class="sd"> ``device`` can be ``None``, an oneAPI filter selector string,</span>
581+
<span class="sd"> an instance of :class:`dpctl.SyclDevice` corresponding to</span>
582+
<span class="sd"> a non-partitioned SYCL device, an instance of :class:`dpctl.SyclQueue`,</span>
583+
<span class="sd"> a :class:`dpctl.tensor.Device` object returned by</span>
584+
<span class="sd"> :attr:`dpctl.tensor.usm_ndarray.device`, or a 2-tuple matching</span>
585+
<span class="sd"> the format of the output of the ``__dlpack_device__`` method,</span>
586+
<span class="sd"> an integer enumerator representing the device type followed by</span>
587+
<span class="sd"> an integer representing the index of the device.</span>
588+
<span class="sd"> Default: ``None``.</span>
589+
<span class="sd"> copy {bool, None}, optional</span>
590+
<span class="sd"> Boolean indicating whether or not to copy the input.</span>
591+
592+
<span class="sd"> * If `copy``is ``True``, the input will always be copied.</span>
593+
<span class="sd"> * If ``False``, a ``BufferError`` will be raised if a copy is deemed</span>
594+
<span class="sd"> necessary.</span>
595+
<span class="sd"> * If ``None``, a copy will be made only if deemed necessary, otherwise,</span>
596+
<span class="sd"> the existing memory buffer will be reused.</span>
597+
598+
<span class="sd"> Default: ``None``.</span>
577599

578600
<span class="sd"> Returns</span>
579601
<span class="sd"> -------</span>
580602
<span class="sd"> out : dpnp_array</span>
581603
<span class="sd"> Returns a new dpnp array containing the data from another array</span>
582604
<span class="sd"> (obj) with the ``__dlpack__`` method on the same device as object.</span>
583605

606+
<span class="sd"> Raises</span>
607+
<span class="sd"> ------</span>
608+
<span class="sd"> TypeError:</span>
609+
<span class="sd"> if `obj` does not implement ``__dlpack__`` method</span>
610+
<span class="sd"> ValueError:</span>
611+
<span class="sd"> if the input array resides on an unsupported device</span>
612+
584613
<span class="sd"> &quot;&quot;&quot;</span>
585614

586-
<span class="n">usm_ary</span> <span class="o">=</span> <span class="n">dpt</span><span class="o">.</span><span class="n">from_dlpack</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span>
587-
<span class="k">return</span> <span class="n">dpnp_array</span><span class="o">.</span><span class="n">_create_from_usm_ndarray</span><span class="p">(</span><span class="n">usm_ary</span><span class="p">)</span></div>
615+
<span class="n">usm_res</span> <span class="o">=</span> <span class="n">dpt</span><span class="o">.</span><span class="n">from_dlpack</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="n">device</span><span class="o">=</span><span class="n">device</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span>
616+
<span class="k">return</span> <span class="n">dpnp_array</span><span class="o">.</span><span class="n">_create_from_usm_ndarray</span><span class="p">(</span><span class="n">usm_res</span><span class="p">)</span></div>
588617

589618

590619

_modules/dpnp/dpnp_iface_arraycreation.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</script>
1313

1414
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
15-
<title>dpnp.dpnp_iface_arraycreation &mdash; Data Parallel Extension for NumPy 0.16.0dev0+158.gef4a310502e documentation</title>
15+
<title>dpnp.dpnp_iface_arraycreation &mdash; Data Parallel Extension for NumPy 0.16.0dev0+159.g7c8e83f7ada documentation</title>
1616
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
1717
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=19f00094" />
1818

@@ -23,7 +23,7 @@
2323

2424
<script src="../../_static/jquery.js?v=5d32c60e"></script>
2525
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
26-
<script src="../../_static/documentation_options.js?v=3ddceb5c"></script>
26+
<script src="../../_static/documentation_options.js?v=cc63d5c7"></script>
2727
<script src="../../_static/doctools.js?v=9a2dae69"></script>
2828
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
2929
<script src="../../_static/js/theme.js"></script>
@@ -43,7 +43,7 @@
4343
Data Parallel Extension for NumPy
4444
</a>
4545
<div class="version">
46-
0.16.0dev0+158.gef4a310502e
46+
0.16.0dev0+159.g7c8e83f7ada
4747
</div>
4848
<div role="search">
4949
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">

_modules/dpnp/dpnp_iface_counting.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</script>
1313

1414
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
15-
<title>dpnp.dpnp_iface_counting &mdash; Data Parallel Extension for NumPy 0.16.0dev0+158.gef4a310502e documentation</title>
15+
<title>dpnp.dpnp_iface_counting &mdash; Data Parallel Extension for NumPy 0.16.0dev0+159.g7c8e83f7ada documentation</title>
1616
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
1717
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=19f00094" />
1818

@@ -23,7 +23,7 @@
2323

2424
<script src="../../_static/jquery.js?v=5d32c60e"></script>
2525
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
26-
<script src="../../_static/documentation_options.js?v=3ddceb5c"></script>
26+
<script src="../../_static/documentation_options.js?v=cc63d5c7"></script>
2727
<script src="../../_static/doctools.js?v=9a2dae69"></script>
2828
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
2929
<script src="../../_static/js/theme.js"></script>
@@ -43,7 +43,7 @@
4343
Data Parallel Extension for NumPy
4444
</a>
4545
<div class="version">
46-
0.16.0dev0+158.gef4a310502e
46+
0.16.0dev0+159.g7c8e83f7ada
4747
</div>
4848
<div role="search">
4949
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">

_modules/dpnp/dpnp_iface_histograms.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</script>
1313

1414
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
15-
<title>dpnp.dpnp_iface_histograms &mdash; Data Parallel Extension for NumPy 0.16.0dev0+158.gef4a310502e documentation</title>
15+
<title>dpnp.dpnp_iface_histograms &mdash; Data Parallel Extension for NumPy 0.16.0dev0+159.g7c8e83f7ada documentation</title>
1616
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=fa44fd50" />
1717
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=19f00094" />
1818

@@ -23,7 +23,7 @@
2323

2424
<script src="../../_static/jquery.js?v=5d32c60e"></script>
2525
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
26-
<script src="../../_static/documentation_options.js?v=3ddceb5c"></script>
26+
<script src="../../_static/documentation_options.js?v=cc63d5c7"></script>
2727
<script src="../../_static/doctools.js?v=9a2dae69"></script>
2828
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
2929
<script src="../../_static/js/theme.js"></script>
@@ -43,7 +43,7 @@
4343
Data Parallel Extension for NumPy
4444
</a>
4545
<div class="version">
46-
0.16.0dev0+158.gef4a310502e
46+
0.16.0dev0+159.g7c8e83f7ada
4747
</div>
4848
<div role="search">
4949
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">

0 commit comments

Comments
 (0)