Skip to content

Commit

Permalink
Implement __usm_ndarray__ protocol (#2261)
Browse files Browse the repository at this point in the history
The PR is intended to adopt to dpctl changes implemented in
[dpctl#1959](IntelPython/dpctl#1959).

It implements support of `__usm_ndarray__` protocol for `dpnp.ndarray`
and returns a property with `dpctl.tensor.usm_ndarray` instance
corresponding to the content of the array object.

This property is intended to speed-up conversion from `dpnp.ndarray` to
`dpt.usm_ndarray` in `x=dpt.asarray(dpnp_array_obj)`.
The input object that implements `__usm_ndarray__` is recognized as
owner of USM allocation that is managed by a smart pointer, and
asynchronous deallocation of `x` need not involve GIL. 9ad1bb5
  • Loading branch information
github-actions[bot] committed Jan 20, 2025
1 parent 8b88077 commit c14c922
Show file tree
Hide file tree
Showing 695 changed files with 1,544 additions and 1,525 deletions.
2 changes: 1 addition & 1 deletion .buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 7efca1f7cf0fd12d36cc8c2589bae464
config: 786d33f83216659ff3c12418a10ba431
tags: 645f666f9bcd5a90fca523b33c5a78b7
23 changes: 21 additions & 2 deletions _modules/dpnp/dpnp_array.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_array &mdash; Data Parallel Extension for NumPy 0.17.0dev4+5.g6cc23484bc9 documentation</title>
<title>dpnp.dpnp_array &mdash; Data Parallel Extension for NumPy 0.17.0dev4+6.g9ad1bb5a530 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=6db27343"></script>
<script src="../../_static/documentation_options.js?v=ac9a9b01"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down Expand Up @@ -695,6 +695,25 @@ <h1>Source code for dpnp.dpnp_array</h1><div class="highlight"><pre>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Return ``self/value``.&quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">dpnp</span><span class="o">.</span><span class="n">true_divide</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span>

<span class="nd">@property</span>
<span class="k">def</span><span class="w"> </span><span class="nf">__usm_ndarray__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Property to support `__usm_ndarray__` protocol.</span>

<span class="sd"> It assumes to return :class:`dpctl.tensor.usm_ndarray` instance</span>
<span class="sd"> corresponding to the content of the object.</span>

<span class="sd"> This property is intended to speed-up conversion from</span>
<span class="sd"> :class:`dpnp.ndarray` to :class:`dpctl.tensor.usm_ndarray` passed</span>
<span class="sd"> into `dpctl.tensor.asarray` function. The input object that implements</span>
<span class="sd"> `__usm_ndarray__` protocol is recognized as owner of USM allocation</span>
<span class="sd"> that is managed by a smart pointer, and asynchronous deallocation</span>
<span class="sd"> will not involve GIL.</span>

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

<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_array_obj</span>

<span class="k">def</span><span class="w"> </span><span class="fm">__xor__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Return ``self^value``.&quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">dpnp</span><span class="o">.</span><span class="n">bitwise_xor</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_flatiter.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_flatiter &mdash; Data Parallel Extension for NumPy 0.17.0dev4+5.g6cc23484bc9 documentation</title>
<title>dpnp.dpnp_flatiter &mdash; Data Parallel Extension for NumPy 0.17.0dev4+6.g9ad1bb5a530 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=6db27343"></script>
<script src="../../_static/documentation_options.js?v=ac9a9b01"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_iface.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface &mdash; Data Parallel Extension for NumPy 0.17.0dev4+5.g6cc23484bc9 documentation</title>
<title>dpnp.dpnp_iface &mdash; Data Parallel Extension for NumPy 0.17.0dev4+6.g9ad1bb5a530 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=6db27343"></script>
<script src="../../_static/documentation_options.js?v=ac9a9b01"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_iface_arraycreation.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface_arraycreation &mdash; Data Parallel Extension for NumPy 0.17.0dev4+5.g6cc23484bc9 documentation</title>
<title>dpnp.dpnp_iface_arraycreation &mdash; Data Parallel Extension for NumPy 0.17.0dev4+6.g9ad1bb5a530 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=6db27343"></script>
<script src="../../_static/documentation_options.js?v=ac9a9b01"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_iface_bitwise.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface_bitwise &mdash; Data Parallel Extension for NumPy 0.17.0dev4+5.g6cc23484bc9 documentation</title>
<title>dpnp.dpnp_iface_bitwise &mdash; Data Parallel Extension for NumPy 0.17.0dev4+6.g9ad1bb5a530 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=6db27343"></script>
<script src="../../_static/documentation_options.js?v=ac9a9b01"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_iface_counting.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface_counting &mdash; Data Parallel Extension for NumPy 0.17.0dev4+5.g6cc23484bc9 documentation</title>
<title>dpnp.dpnp_iface_counting &mdash; Data Parallel Extension for NumPy 0.17.0dev4+6.g9ad1bb5a530 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=6db27343"></script>
<script src="../../_static/documentation_options.js?v=ac9a9b01"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_iface_functional.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface_functional &mdash; Data Parallel Extension for NumPy 0.17.0dev4+5.g6cc23484bc9 documentation</title>
<title>dpnp.dpnp_iface_functional &mdash; Data Parallel Extension for NumPy 0.17.0dev4+6.g9ad1bb5a530 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=6db27343"></script>
<script src="../../_static/documentation_options.js?v=ac9a9b01"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_iface_histograms.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface_histograms &mdash; Data Parallel Extension for NumPy 0.17.0dev4+5.g6cc23484bc9 documentation</title>
<title>dpnp.dpnp_iface_histograms &mdash; Data Parallel Extension for NumPy 0.17.0dev4+6.g9ad1bb5a530 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=6db27343"></script>
<script src="../../_static/documentation_options.js?v=ac9a9b01"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_iface_indexing.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface_indexing &mdash; Data Parallel Extension for NumPy 0.17.0dev4+5.g6cc23484bc9 documentation</title>
<title>dpnp.dpnp_iface_indexing &mdash; Data Parallel Extension for NumPy 0.17.0dev4+6.g9ad1bb5a530 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=6db27343"></script>
<script src="../../_static/documentation_options.js?v=ac9a9b01"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_iface_libmath.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface_libmath &mdash; Data Parallel Extension for NumPy 0.17.0dev4+5.g6cc23484bc9 documentation</title>
<title>dpnp.dpnp_iface_libmath &mdash; Data Parallel Extension for NumPy 0.17.0dev4+6.g9ad1bb5a530 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=6db27343"></script>
<script src="../../_static/documentation_options.js?v=ac9a9b01"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_iface_linearalgebra.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface_linearalgebra &mdash; Data Parallel Extension for NumPy 0.17.0dev4+5.g6cc23484bc9 documentation</title>
<title>dpnp.dpnp_iface_linearalgebra &mdash; Data Parallel Extension for NumPy 0.17.0dev4+6.g9ad1bb5a530 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=6db27343"></script>
<script src="../../_static/documentation_options.js?v=ac9a9b01"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_iface_logic.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface_logic &mdash; Data Parallel Extension for NumPy 0.17.0dev4+5.g6cc23484bc9 documentation</title>
<title>dpnp.dpnp_iface_logic &mdash; Data Parallel Extension for NumPy 0.17.0dev4+6.g9ad1bb5a530 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=6db27343"></script>
<script src="../../_static/documentation_options.js?v=ac9a9b01"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_iface_manipulation.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface_manipulation &mdash; Data Parallel Extension for NumPy 0.17.0dev4+5.g6cc23484bc9 documentation</title>
<title>dpnp.dpnp_iface_manipulation &mdash; Data Parallel Extension for NumPy 0.17.0dev4+6.g9ad1bb5a530 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=6db27343"></script>
<script src="../../_static/documentation_options.js?v=ac9a9b01"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_iface_mathematical.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface_mathematical &mdash; Data Parallel Extension for NumPy 0.17.0dev4+5.g6cc23484bc9 documentation</title>
<title>dpnp.dpnp_iface_mathematical &mdash; Data Parallel Extension for NumPy 0.17.0dev4+6.g9ad1bb5a530 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=6db27343"></script>
<script src="../../_static/documentation_options.js?v=ac9a9b01"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_iface_nanfunctions.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface_nanfunctions &mdash; Data Parallel Extension for NumPy 0.17.0dev4+5.g6cc23484bc9 documentation</title>
<title>dpnp.dpnp_iface_nanfunctions &mdash; Data Parallel Extension for NumPy 0.17.0dev4+6.g9ad1bb5a530 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=6db27343"></script>
<script src="../../_static/documentation_options.js?v=ac9a9b01"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dpnp/dpnp_iface_searching.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dpnp.dpnp_iface_searching &mdash; Data Parallel Extension for NumPy 0.17.0dev4+5.g6cc23484bc9 documentation</title>
<title>dpnp.dpnp_iface_searching &mdash; Data Parallel Extension for NumPy 0.17.0dev4+6.g9ad1bb5a530 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=e59714d7" />


<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=6db27343"></script>
<script src="../../_static/documentation_options.js?v=ac9a9b01"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
Expand Down
Loading

0 comments on commit c14c922

Please sign in to comment.