Skip to content

Commit

Permalink
Merge branch 'master' into mod-as-an-alias
Browse files Browse the repository at this point in the history
  • Loading branch information
antonwolfy authored Jun 15, 2024
2 parents 6715865 + de71047 commit eb73440
Show file tree
Hide file tree
Showing 25 changed files with 463 additions and 225 deletions.
21 changes: 19 additions & 2 deletions dpnp/dpnp_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,15 @@ def asnumpy(self):

return dpt.asnumpy(self._array_obj)

def astype(self, dtype, order="K", casting="unsafe", subok=True, copy=True):
def astype(
self,
dtype,
order="K",
casting="unsafe",
subok=True,
copy=True,
device=None,
):
"""
Copy the array with data type casting.
Expand Down Expand Up @@ -597,6 +605,13 @@ def astype(self, dtype, order="K", casting="unsafe", subok=True, copy=True):
this is set to ``False``, and the `dtype`, `order`, and `subok`
requirements are satisfied, the input array is returned instead of
a copy.
device : {None, string, SyclDevice, SyclQueue}, optional
An array API concept of device where the output array is created.
The `device` can be ``None`` (the default), an OneAPI filter selector
string, an instance of :class:`dpctl.SyclDevice` corresponding to
a non-partitioned SYCL device, an instance of :class:`dpctl.SyclQueue`,
or a `Device` object returned by
:obj:`dpnp.dpnp_array.dpnp_array.device` property. Default: ``None``.
Returns
-------
Expand Down Expand Up @@ -626,7 +641,9 @@ def astype(self, dtype, order="K", casting="unsafe", subok=True, copy=True):
f"subok={subok} is currently not supported"
)

return dpnp.astype(self, dtype, order=order, casting=casting, copy=copy)
return dpnp.astype(
self, dtype, order=order, casting=casting, copy=copy, device=device
)

# 'base',
# 'byteswap',
Expand Down
11 changes: 9 additions & 2 deletions dpnp/dpnp_iface.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def asnumpy(a, order="C"):


# pylint: disable=redefined-outer-name
def astype(x1, dtype, order="K", casting="unsafe", copy=True):
def astype(x1, dtype, order="K", casting="unsafe", copy=True, device=None):
"""
Copy the array with data type casting.
Expand Down Expand Up @@ -213,6 +213,13 @@ def astype(x1, dtype, order="K", casting="unsafe", copy=True):
By default, ``astype`` always returns a newly allocated array. If this
is set to ``False``, and the `dtype`, `order`, and `subok` requirements
are satisfied, the input array is returned instead of a copy.
device : {None, string, SyclDevice, SyclQueue}, optional
An array API concept of device where the output array is created.
The `device` can be ``None`` (the default), an OneAPI filter selector
string, an instance of :class:`dpctl.SyclDevice` corresponding to
a non-partitioned SYCL device, an instance of :class:`dpctl.SyclQueue`,
or a `Device` object returned by
:obj:`dpnp.dpnp_array.dpnp_array.device` property. Default: ``None``.
Returns
-------
Expand All @@ -228,7 +235,7 @@ def astype(x1, dtype, order="K", casting="unsafe", copy=True):

x1_obj = dpnp.get_usm_ndarray(x1)
array_obj = dpt.astype(
x1_obj, dtype, order=order, casting=casting, copy=copy
x1_obj, dtype, order=order, casting=casting, copy=copy, device=device
)

# return x1 if dpctl returns a zero copy of x1_obj
Expand Down
24 changes: 12 additions & 12 deletions dpnp/dpnp_iface_bitwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@
x2 : {dpnp.ndarray, usm_ndarray}
Second input array, also expected to have integer or boolean data
type.
out : {None, dpnp.ndarray}, optional
out : {None, dpnp.ndarray, usm_ndarray}, optional
Output array to populate.
Array must have the correct shape and the expected data type.
order : {"C", "F", "A", "K"}, optional
Memory layout of the newly output array, if parameter `out` is ``None``.
Default: "K".
Default: ``"K"``.
Returns
-------
Expand Down Expand Up @@ -137,12 +137,12 @@
x2 : {dpnp.ndarray, usm_ndarray}
Second input array, also expected to have integer or boolean data
type.
out : {None, dpnp.ndarray}, optional
out : {None, dpnp.ndarray, usm_ndarray}, optional
Output array to populate.
Array must have the correct shape and the expected data type.
order : {"C", "F", "A", "K"}, optional
Memory layout of the newly output array, if parameter `out` is ``None``.
Default: "K".
Default: ``"K"``.
Returns
-------
Expand Down Expand Up @@ -199,12 +199,12 @@
x2 : {dpnp.ndarray, usm_ndarray}
Second input array, also expected to have integer or boolean data
type.
out : {None, dpnp.ndarray}, optional
out : {None, dpnp.ndarray, usm_ndarray}, optional
Output array to populate.
Array must have the correct shape and the expected data type.
order : {"C", "F", "A", "K"}, optional
Memory layout of the newly output array, if parameter `out` is ``None``.
Default: "K".
Default: ``"K"``.
Returns
-------
Expand Down Expand Up @@ -261,12 +261,12 @@
----------
x : {dpnp.ndarray, usm_ndarray}
Input array, expected to have integer or boolean data type.
out : {None, dpnp.ndarray}, optional
out : {None, dpnp.ndarray, usm_ndarray}, optional
Output array to populate.
Array must have the correct shape and the expected data type.
order : {"C", "F", "A", "K"}, optional
Memory layout of the newly output array, if parameter `out` is ``None``.
Default: "K".
Default: ``"K"``.
Returns
-------
Expand Down Expand Up @@ -331,12 +331,12 @@
x2 : {dpnp.ndarray, usm_ndarray}
Second input array, also expected to have integer data type.
Each element must be greater than or equal to 0.
out : {None, dpnp.ndarray}, optional
out : {None, dpnp.ndarray, usm_ndarray}, optional
Output array to populate.
Array must have the correct shape and the expected data type.
order : {"C", "F", "A", "K"}, optional
Memory layout of the newly output array, if parameter `out` is ``None``.
Default: "K".
Default: ``"K"``.
Returns
-------
out : dpnp.ndarray
Expand Down Expand Up @@ -389,12 +389,12 @@
x2 : {dpnp.ndarray, usm_ndarray}
Second input array, also expected to have integer data type.
Each element must be greater than or equal to 0.
out : {None, dpnp.ndarray}, optional
out : {None, dpnp.ndarray, usm_ndarray}, optional
Output array to populate.
Array must have the correct shape and the expected data type.
order : {"C", "F", "A", "K"}, optional
Memory layout of the newly output array, if parameter `out` is ``None``.
Default: "K".
Default: ``"K"``.
Returns
-------
Expand Down
1 change: 0 additions & 1 deletion dpnp/dpnp_iface_linearalgebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,6 @@ def matmul(
"""

dpnp.check_supported_arrays_type(x1, x2)
if subok is False:
raise NotImplementedError(
"subok keyword argument is only supported by its default value."
Expand Down
53 changes: 27 additions & 26 deletions dpnp/dpnp_iface_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,12 @@ def any(x, /, axis=None, out=None, keepdims=False, *, where=True):
First input array, expected to have numeric data type.
x2 : {dpnp.ndarray, usm_ndarray}
Second input array, also expected to have numeric data type.
out : {None, dpnp.ndarray}, optional
out : {None, dpnp.ndarray, usm_ndarray}, optional
Output array to populate.
Array have the correct shape and the expected data type.
order : {"C", "F", "A", "K"}, optional
Memory layout of the newly output array, if parameter `out` is ``None``.
Default: "K".
Default: ``"K"``.
Returns
-------
Expand Down Expand Up @@ -386,12 +386,12 @@ def any(x, /, axis=None, out=None, keepdims=False, *, where=True):
First input array, expected to have numeric data type.
x2 : {dpnp.ndarray, usm_ndarray}
Second input array, also expected to have numeric data type.
out : {None, dpnp.ndarray}, optional
out : {None, dpnp.ndarray, usm_ndarray}, optional
Output array to populate.
Array must have the correct shape and the expected data type.
order : {"C", "F", "A", "K"}, optional
Memory layout of the newly output array, if parameter `out` is ``None``.
Default: "K".
Default: ``"K"``.
Returns
-------
Expand Down Expand Up @@ -449,12 +449,12 @@ def any(x, /, axis=None, out=None, keepdims=False, *, where=True):
First input array, expected to have numeric data type.
x2 : {dpnp.ndarray, usm_ndarray}
Second input array, also expected to have numeric data type.
out : {None, dpnp.ndarray}, optional
out : {None, dpnp.ndarray, usm_ndarray}, optional
Output array to populate.
Array must have the correct shape and the expected data type.
order : {"C", "F", "A", "K"}, optional
Memory layout of the newly output array, if parameter `out` is ``None``.
Default: "K".
Default: ``"K"``.
Returns
-------
Expand Down Expand Up @@ -553,12 +553,12 @@ def isclose(x1, x2, rtol=1e-05, atol=1e-08, equal_nan=False):
----------
x : {dpnp.ndarray, usm_ndarray}
Input array, expected to have numeric data type.
out : {None, dpnp.ndarray}, optional
out : {None, dpnp.ndarray, usm_ndarray}, optional
Output array to populate.
Array must have the correct shape and the expected data type.
order : {"C", "F", "A", "K"}, optional
Memory layout of the newly output array, if parameter `out` is ``None``.
Default: "K".
Default: ``"K"``.
Returns
-------
Expand Down Expand Up @@ -612,12 +612,12 @@ def isclose(x1, x2, rtol=1e-05, atol=1e-08, equal_nan=False):
----------
x : {dpnp.ndarray, usm_ndarray}
Input array, expected to have numeric data type.
out : {None, dpnp.ndarray}, optional
out : {None, dpnp.ndarray, usm_ndarray}, optional
Output array to populate.
Array must have the correct shape and the expected data type.
order : {"C", "F", "A", "K"}, optional
Memory layout of the newly output array, if parameter `out` is ``None``.
Default: "K".
Default: ``"K"``.
Returns
-------
Expand Down Expand Up @@ -665,12 +665,12 @@ def isclose(x1, x2, rtol=1e-05, atol=1e-08, equal_nan=False):
----------
x : {dpnp.ndarray, usm_ndarray}
Input array, expected to have numeric data type.
out : {None, dpnp.ndarray}, optional
out : {None, dpnp.ndarray, usm_ndarray}, optional
Output array to populate.
Array must have the correct shape and the expected data type.
order : {"C", "F", "A", "K"}, optional
Memory layout of the newly output array, if parameter `out` is ``None``.
Default: "K".
Default: ``"K"``.
Returns
-------
Expand Down Expand Up @@ -722,12 +722,12 @@ def isclose(x1, x2, rtol=1e-05, atol=1e-08, equal_nan=False):
First input array, expected to have numeric data type.
x2 : {dpnp.ndarray, usm_ndarray}
Second input array, also expected to have numeric data type.
out : {None, dpnp.ndarray}, optional
out : {None, dpnp.ndarray, usm_ndarray}, optional
Output array to populate.
Array must have the correct shape and the expected data type.
order : {"C", "F", "A", "K"}, optional
Memory layout of the newly output array, if parameter `out` is ``None``.
Default: "K".
Default: ``"K"``.
Returns
-------
Expand All @@ -739,6 +739,7 @@ def isclose(x1, x2, rtol=1e-05, atol=1e-08, equal_nan=False):
-----------
Parameters `where` and `subok` are supported with their default values.
Otherwise ``NotImplementedError`` exception will be raised.
See Also
--------
:obj:`dpnp.greater` : Return the truth value of (x1 > x2) element-wise.
Expand Down Expand Up @@ -784,12 +785,12 @@ def isclose(x1, x2, rtol=1e-05, atol=1e-08, equal_nan=False):
First input array, expected to have numeric data type.
x2 : {dpnp.ndarray, usm_ndarray}
Second input array, also expected to have numeric data type.
out : {None, dpnp.ndarray}, optional
out : {None, dpnp.ndarray, usm_ndarray}, optional
Output array to populate.
Array must have the correct shape and the expected data type.
order : {"C", "F", "A", "K"}, optional
Memory layout of the newly output array, if parameter `out` is ``None``.
Default: "K".
Default: ``"K"``.
Returns
-------
Expand Down Expand Up @@ -847,12 +848,12 @@ def isclose(x1, x2, rtol=1e-05, atol=1e-08, equal_nan=False):
First input array.
x2 : {dpnp.ndarray, usm_ndarray}
Second input array.
out : {None, dpnp.ndarray}, optional
out : {None, dpnp.ndarray, usm_ndarray}, optional
Output array to populate.
Array must have the correct shape and the expected data type.
order : {"C", "F", "A", "K"}, optional
Memory layout of the newly output array, if parameter `out` is ``None``.
Default: "K".
Default: ``"K"``.
Returns
-------
Expand Down Expand Up @@ -909,12 +910,12 @@ def isclose(x1, x2, rtol=1e-05, atol=1e-08, equal_nan=False):
----------
x : {dpnp.ndarray, usm_ndarray}
Input array.
out : {None, dpnp.ndarray}, optional
out : {None, dpnp.ndarray, usm_ndarray}, optional
Output array to populate.
Array must have the correct shape and the expected data type.
order : {"C", "F", "A", "K"}, optional
Memory layout of the newly output array, if parameter `out` is ``None``.
Default: "K".
Default: ``"K"``.
Returns
-------
Expand Down Expand Up @@ -964,12 +965,12 @@ def isclose(x1, x2, rtol=1e-05, atol=1e-08, equal_nan=False):
First input array.
x2 : {dpnp.ndarray, usm_ndarray}
Second input array.
out : {None, dpnp.ndarray}, optional
out : {None, dpnp.ndarray, usm_ndarray}, optional
Output array to populate.
Array must have the correct shape and the expected data type.
order : {"C", "F", "A", "K"}, optional
Memory layout of the newly output array, if parameter `out` is ``None``.
Default: "K".
Default: ``"K"``.
Returns
-------
Expand Down Expand Up @@ -1029,12 +1030,12 @@ def isclose(x1, x2, rtol=1e-05, atol=1e-08, equal_nan=False):
First input array.
x2 : {dpnp.ndarray, usm_ndarray}
Second input array.
out : {None, dpnp.ndarray}, optional
out : {None, dpnp.ndarray, usm_ndarray}, optional
Output array to populate.
Array must have the correct shape and the expected data type.
order : {"C", "F", "A", "K"}, optional
Memory layout of the newly output array, if parameter `out` is ``None``.
Default: "K".
Default: ``"K"``.
Returns
-------
Expand Down Expand Up @@ -1092,12 +1093,12 @@ def isclose(x1, x2, rtol=1e-05, atol=1e-08, equal_nan=False):
First input array, expected to have numeric data type.
x2 : {dpnp.ndarray, usm_ndarray}
Second input array, also expected to have numeric data type.
out : {None, dpnp.ndarray}, optional
out : {None, dpnp.ndarray, usm_ndarray}, optional
Output array to populate.
Array must have the correct shape and the expected data type.
order : {"C", "F", "A", "K"}, optional
Memory layout of the newly output array, if parameter `out` is ``None``.
Default: "K".
Default: ``"K"``.
Returns
-------
Expand Down
Loading

0 comments on commit eb73440

Please sign in to comment.