Skip to content

Commit b0d1ef6

Browse files
Leverage on dpctl.tensor implementation in dpnp.count_nonzero (#1962)
* Leverage on dpctl.tensor implementation of count_nonzero * Extend dpnp.get_result_array() to accept dpt.usm_ndarray * Updated dpnp.mean() per review comment * Add more dpnp tests to cover different use cases cb56101
1 parent ac94765 commit b0d1ef6

File tree

502 files changed

+1575
-1558
lines changed

Some content is hidden

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

502 files changed

+1575
-1558
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: 87fcd98015705c959dfb3d670f4dfc1d
3+
config: 4cff48b2f81f644229cb2ad19fa3b056
44
tags: 645f666f9bcd5a90fca523b33c5a78b7

_modules/dpnp/dpnp_array.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_array &mdash; Data Parallel Extension for NumPy 0.16.0dev0+98.gd2c623b084 documentation</title>
15+
<title>dpnp.dpnp_array &mdash; Data Parallel Extension for NumPy 0.16.0dev0+99.gcb56101780 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=9459a11b"></script>
26+
<script src="../../_static/documentation_options.js?v=4778e5b8"></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+98.gd2c623b084
46+
0.16.0dev0+99.gcb56101780
4747
</div>
4848
<div role="search">
4949
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">

_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+98.gd2c623b084 documentation</title>
15+
<title>dpnp.dpnp_flatiter &mdash; Data Parallel Extension for NumPy 0.16.0dev0+99.gcb56101780 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=9459a11b"></script>
26+
<script src="../../_static/documentation_options.js?v=4778e5b8"></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+98.gd2c623b084
46+
0.16.0dev0+99.gcb56101780
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: 6 additions & 4 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+98.gd2c623b084 documentation</title>
15+
<title>dpnp.dpnp_iface &mdash; Data Parallel Extension for NumPy 0.16.0dev0+99.gcb56101780 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=9459a11b"></script>
26+
<script src="../../_static/documentation_options.js?v=4778e5b8"></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+98.gd2c623b084
46+
0.16.0dev0+99.gcb56101780
4747
</div>
4848
<div role="search">
4949
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
@@ -759,7 +759,7 @@ <h1>Source code for dpnp.dpnp_iface</h1><div class="highlight"><pre>
759759

760760
<span class="sd"> Parameters</span>
761761
<span class="sd"> ----------</span>
762-
<span class="sd"> a : {dpnp_array}</span>
762+
<span class="sd"> a : {dpnp.ndarray, usm_ndarray}</span>
763763
<span class="sd"> Input array.</span>
764764
<span class="sd"> out : {dpnp.ndarray, usm_ndarray}</span>
765765
<span class="sd"> If provided, value of `a` array will be copied into it</span>
@@ -776,6 +776,8 @@ <h1>Source code for dpnp.dpnp_iface</h1><div class="highlight"><pre>
776776
<span class="sd"> &quot;&quot;&quot;</span>
777777

778778
<span class="k">if</span> <span class="n">out</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
779+
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">dpt</span><span class="o">.</span><span class="n">usm_ndarray</span><span class="p">):</span>
780+
<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">a</span><span class="p">)</span>
779781
<span class="k">return</span> <span class="n">a</span>
780782

781783
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">out</span><span class="p">,</span> <span class="n">dpt</span><span class="o">.</span><span class="n">usm_ndarray</span><span class="p">):</span>

_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+98.gd2c623b084 documentation</title>
15+
<title>dpnp.dpnp_iface_arraycreation &mdash; Data Parallel Extension for NumPy 0.16.0dev0+99.gcb56101780 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=9459a11b"></script>
26+
<script src="../../_static/documentation_options.js?v=4778e5b8"></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+98.gd2c623b084
46+
0.16.0dev0+99.gcb56101780
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: 32 additions & 17 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+98.gd2c623b084 documentation</title>
15+
<title>dpnp.dpnp_iface_counting &mdash; Data Parallel Extension for NumPy 0.16.0dev0+99.gcb56101780 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=9459a11b"></script>
26+
<script src="../../_static/documentation_options.js?v=4778e5b8"></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+98.gd2c623b084
46+
0.16.0dev0+99.gcb56101780
4747
</div>
4848
<div role="search">
4949
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
@@ -136,25 +136,38 @@ <h1>Source code for dpnp.dpnp_iface_counting</h1><div class="highlight"><pre>
136136

137137
<div class="viewcode-block" id="count_nonzero">
138138
<a class="viewcode-back" href="../../reference/generated/dpnp.count_nonzero.html#dpnp.count_nonzero">[docs]</a>
139-
<span class="k">def</span> <span class="nf">count_nonzero</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">keepdims</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
139+
<span class="k">def</span> <span class="nf">count_nonzero</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">keepdims</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">out</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
140140
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
141141
<span class="sd"> Counts the number of non-zero values in the array `a`.</span>
142142

143143
<span class="sd"> For full documentation refer to :obj:`numpy.count_nonzero`.</span>
144144

145+
<span class="sd"> Parameters</span>
146+
<span class="sd"> ----------</span>
147+
<span class="sd"> a : {dpnp.ndarray, usm_ndarray}</span>
148+
<span class="sd"> The array for which to count non-zeros.</span>
149+
<span class="sd"> axis : {None, int, tuple}, optional</span>
150+
<span class="sd"> Axis or tuple of axes along which to count non-zeros.</span>
151+
<span class="sd"> Default value means that non-zeros will be counted along a flattened</span>
152+
<span class="sd"> version of `a`.</span>
153+
<span class="sd"> Default: ``None``.</span>
154+
<span class="sd"> keepdims : bool, optional</span>
155+
<span class="sd"> If this is set to ``True``, the axes that are counted are left in the</span>
156+
<span class="sd"> result as dimensions with size one. With this option, the result will</span>
157+
<span class="sd"> broadcast correctly against the input array.</span>
158+
<span class="sd"> Default: ``False``.</span>
159+
<span class="sd"> out : {None, dpnp.ndarray, usm_ndarray}, optional</span>
160+
<span class="sd"> The array into which the result is written. The data type of `out` must</span>
161+
<span class="sd"> match the expected shape and the expected data type of the result.</span>
162+
<span class="sd"> If ``None`` then a new array is returned.</span>
163+
<span class="sd"> Default: ``None``.</span>
164+
145165
<span class="sd"> Returns</span>
146166
<span class="sd"> -------</span>
147167
<span class="sd"> out : dpnp.ndarray</span>
148168
<span class="sd"> Number of non-zero values in the array along a given axis.</span>
149-
<span class="sd"> Otherwise, a zero-dimensional array with the total number of</span>
150-
<span class="sd"> non-zero values in the array is returned.</span>
151-
152-
<span class="sd"> Limitations</span>
153-
<span class="sd"> -----------</span>
154-
<span class="sd"> Parameters `a` is supported as either :class:`dpnp.ndarray`</span>
155-
<span class="sd"> or :class:`dpctl.tensor.usm_ndarray`.</span>
156-
<span class="sd"> Otherwise ``TypeError`` exception will be raised.</span>
157-
<span class="sd"> Input array data types are limited by supported DPNP :ref:`Data types`.</span>
169+
<span class="sd"> Otherwise, a zero-dimensional array with the total number of non-zero</span>
170+
<span class="sd"> values in the array is returned.</span>
158171

159172
<span class="sd"> See Also</span>
160173
<span class="sd"> --------</span>
@@ -179,11 +192,13 @@ <h1>Source code for dpnp.dpnp_iface_counting</h1><div class="highlight"><pre>
179192

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

182-
<span class="c1"># TODO: might be improved by implementing an extension</span>
183-
<span class="c1"># with `count_nonzero` kernel</span>
184195
<span class="n">usm_a</span> <span class="o">=</span> <span class="n">dpnp</span><span class="o">.</span><span class="n">get_usm_ndarray</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>
185-
<span class="n">usm_a</span> <span class="o">=</span> <span class="n">dpt</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="n">usm_a</span><span class="p">,</span> <span class="n">dpnp</span><span class="o">.</span><span class="n">bool</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
186-
<span class="k">return</span> <span class="n">dpnp</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">usm_a</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="n">axis</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">dpnp</span><span class="o">.</span><span class="n">intp</span><span class="p">,</span> <span class="n">keepdims</span><span class="o">=</span><span class="n">keepdims</span><span class="p">)</span></div>
196+
<span class="n">usm_out</span> <span class="o">=</span> <span class="kc">None</span> <span class="k">if</span> <span class="n">out</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">dpnp</span><span class="o">.</span><span class="n">get_usm_ndarray</span><span class="p">(</span><span class="n">out</span><span class="p">)</span>
197+
198+
<span class="n">usm_res</span> <span class="o">=</span> <span class="n">dpt</span><span class="o">.</span><span class="n">count_nonzero</span><span class="p">(</span>
199+
<span class="n">usm_a</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="n">axis</span><span class="p">,</span> <span class="n">keepdims</span><span class="o">=</span><span class="n">keepdims</span><span class="p">,</span> <span class="n">out</span><span class="o">=</span><span class="n">usm_out</span>
200+
<span class="p">)</span>
201+
<span class="k">return</span> <span class="n">dpnp</span><span class="o">.</span><span class="n">get_result_array</span><span class="p">(</span><span class="n">usm_res</span><span class="p">,</span> <span class="n">out</span><span class="p">)</span></div>
187202

188203
</pre></div>
189204

_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+98.gd2c623b084 documentation</title>
15+
<title>dpnp.dpnp_iface_histograms &mdash; Data Parallel Extension for NumPy 0.16.0dev0+99.gcb56101780 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=9459a11b"></script>
26+
<script src="../../_static/documentation_options.js?v=4778e5b8"></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+98.gd2c623b084
46+
0.16.0dev0+99.gcb56101780
4747
</div>
4848
<div role="search">
4949
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">

_modules/dpnp/dpnp_iface_indexing.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_indexing &mdash; Data Parallel Extension for NumPy 0.16.0dev0+98.gd2c623b084 documentation</title>
15+
<title>dpnp.dpnp_iface_indexing &mdash; Data Parallel Extension for NumPy 0.16.0dev0+99.gcb56101780 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=9459a11b"></script>
26+
<script src="../../_static/documentation_options.js?v=4778e5b8"></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+98.gd2c623b084
46+
0.16.0dev0+99.gcb56101780
4747
</div>
4848
<div role="search">
4949
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">

_modules/dpnp/dpnp_iface_libmath.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_libmath &mdash; Data Parallel Extension for NumPy 0.16.0dev0+98.gd2c623b084 documentation</title>
15+
<title>dpnp.dpnp_iface_libmath &mdash; Data Parallel Extension for NumPy 0.16.0dev0+99.gcb56101780 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=9459a11b"></script>
26+
<script src="../../_static/documentation_options.js?v=4778e5b8"></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+98.gd2c623b084
46+
0.16.0dev0+99.gcb56101780
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)