Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leverage on out keyword in reduction and where functions of dpctl.tensor #1808

Merged
merged 11 commits into from
May 6, 2024
2 changes: 2 additions & 0 deletions .github/workflows/conda-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ env:
test_logic.py
test_manipulation.py
test_mathematical.py
test_nanfunctions.py
test_product.py
test_random_state.py
test_sort.py
test_special.py
test_statistics.py
test_sum.py
test_sycl_queue.py
test_umath.py
test_usm_type.py
Expand Down
1 change: 1 addition & 0 deletions doc/known_words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Hadamard
Hypergeometric
iinfo
Infs
intp
iterable
Lomax
Mersenne
Expand Down
2 changes: 1 addition & 1 deletion dpnp/dpnp_algo/dpnp_arraycreation.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ class dpnp_nd_grid:

Parameters
----------
sparse : bool, optional
sparse : {bool}, optional
Whether the grid is sparse or not. Default is False.

"""
Expand Down
44 changes: 34 additions & 10 deletions dpnp/dpnp_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,8 @@ def argmax(self, axis=None, out=None, *, keepdims=False):
Refer to :obj:`dpnp.argmax` for full documentation.

"""
return dpnp.argmax(self, axis, out, keepdims=keepdims)

return dpnp.argmax(self, axis=axis, out=out, keepdims=keepdims)

def argmin(self, axis=None, out=None, *, keepdims=False):
"""
Expand All @@ -534,7 +535,8 @@ def argmin(self, axis=None, out=None, *, keepdims=False):
Refer to :obj:`dpnp.argmin` for full documentation.

"""
return dpnp.argmin(self, axis, out, keepdims=keepdims)

return dpnp.argmin(self, axis=axis, out=out, keepdims=keepdims)

# 'argpartition',

Expand Down Expand Up @@ -582,13 +584,15 @@ def astype(self, dtype, order="K", casting="unsafe", subok=True, copy=True):
casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional
Controls what kind of data casting may occur.
Defaults to ``'unsafe'`` for backwards compatibility.

- 'no' means the data types should not be cast at all.
- 'equiv' means only byte-order changes are allowed.
- 'safe' means only casts which can preserve values are allowed.
- 'same_kind' means only safe casts or casts within a kind, like
float64 to float32, are allowed.
- 'unsafe' means any data conversions may be done.
copy : bool, optional

copy : {bool}, optional
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
Expand Down Expand Up @@ -951,7 +955,14 @@ def max(

"""

return dpnp.max(self, axis, out, keepdims, initial, where)
return dpnp.max(
self,
axis=axis,
out=out,
keepdims=keepdims,
initial=initial,
where=where,
)

def mean(
self, axis=None, dtype=None, out=None, keepdims=False, *, where=True
Expand Down Expand Up @@ -980,7 +991,14 @@ def min(

"""

return dpnp.min(self, axis, out, keepdims, initial, where)
return dpnp.min(
self,
axis=axis,
out=out,
keepdims=keepdims,
initial=initial,
where=where,
)

@property
def nbytes(self):
Expand Down Expand Up @@ -1054,7 +1072,15 @@ def prod(

"""

return dpnp.prod(self, axis, dtype, out, keepdims, initial, where)
return dpnp.prod(
self,
axis=axis,
dtype=dtype,
out=out,
keepdims=keepdims,
initial=initial,
where=where,
)

def put(self, indices, vals, /, *, axis=None, mode="wrap"):
"""
Expand Down Expand Up @@ -1295,13 +1321,11 @@ def strides(self):

def sum(
self,
/,
*,
axis=None,
dtype=None,
keepdims=False,
out=None,
initial=0,
keepdims=False,
initial=None,
where=True,
):
"""
Expand Down
2 changes: 1 addition & 1 deletion dpnp/dpnp_iface.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def astype(x1, dtype, order="K", casting="unsafe", copy=True):
float64 to float32, are allowed.
- 'unsafe' means any data conversions may be done.

copy : bool, optional
copy : {bool}, optional
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.
Expand Down
64 changes: 32 additions & 32 deletions dpnp/dpnp_iface_arraycreation.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def arange(
step : {int, real}, optional
Spacing between values. The default `step` size is 1. If `step`
is specified as a position argument, `start` must also be given.
dtype : dtype, optional
dtype : {None, dtype}, optional
The desired dtype for the array. If not given, a default dtype will be
used that can represent the values (by considering Promotion Type Rule
and device capabilities when necessary).
Expand Down Expand Up @@ -227,11 +227,11 @@ def array(
Input data, in any form that can be converted to an array. This
includes scalars, lists, lists of tuples, tuples, tuples of tuples,
tuples of lists, and ndarrays.
dtype : dtype, optional
dtype : {None, dtype}, optional
The desired dtype for the array. If not given, a default dtype will be
used that can represent the values (by considering Promotion Type Rule
and device capabilities when necessary).
copy : bool, optional
copy : {bool}, optional
If ``True`` (default), then the object is copied.
order : {"C", "F", "A", "K"}, optional
Memory layout of the newly output array. Default: "K".
Expand Down Expand Up @@ -353,7 +353,7 @@ def asanyarray(
Input data, in any form that can be converted to an array. This
includes scalars, lists, lists of tuples, tuples, tuples of tuples,
tuples of lists, and ndarrays.
dtype : dtype, optional
dtype : {None, dtype}, optional
The desired dtype for the array. If not given, a default dtype will be
used that can represent the values (by considering Promotion Type Rule
and device capabilities when necessary).
Expand Down Expand Up @@ -449,7 +449,7 @@ def asarray(
Input data, in any form that can be converted to an array. This
includes scalars, lists, lists of tuples, tuples, tuples of tuples,
tuples of lists, and ndarrays.
dtype : dtype, optional
dtype : {None, dtype}, optional
The desired dtype for the array. If not given, a default dtype will be
used that can represent the values (by considering Promotion Type Rule
and device capabilities when necessary).
Expand Down Expand Up @@ -540,7 +540,7 @@ def ascontiguousarray(
Input data, in any form that can be converted to an array. This
includes scalars, lists, lists of tuples, tuples, tuples of tuples,
tuples of lists, and ndarrays.
dtype : dtype, optional
dtype : {None, dtype}, optional
The desired dtype for the array. If not given, a default dtype will be
used that can represent the values (by considering Promotion Type Rule
and device capabilities when necessary).
Expand Down Expand Up @@ -650,7 +650,7 @@ def asfortranarray(
Input data, in any form that can be converted to an array. This
includes scalars, lists, lists of tuples, tuples, tuples of tuples,
tuples of lists, and ndarrays.
dtype : dtype, optional
dtype : {None, dtype}, optional
The desired dtype for the array. If not given, a default dtype will be
used that can represent the values (by considering Promotion Type Rule
and device capabilities when necessary).
Expand Down Expand Up @@ -1081,7 +1081,7 @@ def empty(
----------
shape : {int, sequence of ints}
Shape of the new array, e.g., (2, 3) or 2.
dtype : dtype, optional
dtype : {None, dtype}, optional
The desired dtype for the array, e.g., dpnp.int32.
Default is the default floating point data type for the device where
input array is allocated.
Expand Down Expand Up @@ -1179,7 +1179,7 @@ def empty_like(
a : {dpnp_array, usm_ndarray}
The shape and dtype of `a` define these same attributes
of the returned array.
dtype : dtype, optional
dtype : {None, dtype}, optional
The desired dtype for the array, e.g., dpnp.int32.
Default is the default floating point data type for the device where
input array is allocated.
Expand Down Expand Up @@ -1292,7 +1292,7 @@ def eye(
Index of the diagonal: 0 (the default) refers to the main diagonal,
a positive value refers to an upper diagonal, and a negative value to
a lower diagonal.
dtype : dtype, optional
dtype : {None, dtype}, optional
The desired dtype for the array, e.g., dpnp.int32.
Default is the default floating point data type for the device where
input array is allocated.
Expand Down Expand Up @@ -1902,7 +1902,7 @@ def full(
Fill value, in any form that can be converted to an array. This
includes scalars, lists, lists of tuples, tuples, tuples of tuples,
tuples of lists, and ndarrays.
dtype : dtype, optional
dtype : {None, dtype}, optional
The desired dtype for the array, e.g., dpnp.int32.
Default is the default floating point data type for the device where
input array is allocated.
Expand Down Expand Up @@ -2003,7 +2003,7 @@ def full_like(
Fill value, in any form that can be converted to an array. This
includes scalars, lists, lists of tuples, tuples, tuples of tuples,
tuples of lists, and ndarrays.
dtype : dtype, optional
dtype : {None, dtype}, optional
The desired dtype for the array, e.g., dpnp.int32.
Default is the default floating point data type for the device where
input array is allocated.
Expand Down Expand Up @@ -2121,7 +2121,7 @@ def geomspace(
all but the last (a sequence of length `num`) are returned.
num : int, optional
Number of samples to generate. Default is 50.
dtype : dtype, optional
dtype : {None, dtype}, optional
The desired dtype for the array. If not given, a default dtype will be
used that can represent the values (by considering Promotion Type Rule
and device capabilities when necessary).
Expand All @@ -2137,10 +2137,10 @@ def geomspace(
Default is ``None``.
sycl_queue : {None, SyclQueue}, optional
A SYCL queue to use for output array allocation and copying.
endpoint : bool, optional
endpoint : {bool}, optional
If ``True``, `stop` is the last sample. Otherwise, it is not included.
Default is ``True``.
axis : int, optional
axis : {int}, optional
The axis in the result to store the samples. Relevant only if start or
stop are array-like. By default (0), the samples will be along a new
axis inserted at the beginning. Use -1 to get an axis at the end.
Expand Down Expand Up @@ -2231,7 +2231,7 @@ def identity(
----------
n : int
Number of rows (and columns) in `n` x `n` output.
dtype : dtype, optional
dtype : {None, dtype}, optional
The desired dtype for the array, e.g., dpnp.int32.
Default is the default floating point data type for the device where
input array is allocated.
Expand Down Expand Up @@ -2342,7 +2342,7 @@ def linspace(
of tuples, tuples of lists, and ndarrays. If `endpoint` is set to
``False`` the sequence consists of all but the last of ``num + 1``
evenly spaced samples, so that `stop` is excluded.
dtype : dtype, optional
dtype : {None, dtype}, optional
The desired dtype for the array. If not given, a default dtype will be
used that can represent the values (by considering Promotion Type Rule
and device capabilities when necessary).
Expand All @@ -2358,13 +2358,13 @@ def linspace(
Default is ``None``.
sycl_queue : {None, SyclQueue}, optional
A SYCL queue to use for output array allocation and copying.
endpoint : bool, optional
endpoint : {bool}, optional
If ``True``, `stop` is the last sample. Otherwise, it is not included.
Default is ``True``.
retstep : bool, optional
retstep : {bool}, optional
If ``True``, return (samples, step), where step is the spacing between
samples.
axis : int, optional
axis : {int}, optional
The axis in the result to store the samples. Relevant only if start or
stop are array-like. By default (0), the samples will be along a new
axis inserted at the beginning. Use -1 to get an axis at the end.
Expand Down Expand Up @@ -2576,22 +2576,22 @@ def logspace(
Default is ``None``.
sycl_queue : {None, SyclQueue}, optional
A SYCL queue to use for output array allocation and copying.
endpoint : bool, optional
endpoint : {bool}, optional
If ``True``, stop is the last sample. Otherwise, it is not included.
Default is ``True``.
base : array_like, optional
base : {array_like}, optional
Input data, in any form that can be converted to an array. This
includes scalars, lists, lists of tuples, tuples, tuples of tuples,
tuples of lists, and ndarrays. The base of the log space, in any form
that can be converted to an array.This includes scalars, lists, lists
of tuples, tuples, tuples of tuples, tuples of lists, and ndarrays.
The `step` size between the elements in ``ln(samples) / ln(base)``
(or log_base(samples)) is uniform. Default is 10.0.
dtype : dtype, optional
dtype : {None, dtype}, optional
The desired dtype for the array. If not given, a default dtype will be
used that can represent the values (by considering Promotion Type Rule
and device capabilities when necessary).
axis : int, optional
axis : {int}, optional
The axis in the result to store the samples. Relevant only if start,
stop, or base are array-like. By default (0), the samples will be along
a new axis inserted at the beginning. Use -1 to get an axis at the end.
Expand Down Expand Up @@ -2674,11 +2674,11 @@ def meshgrid(*xi, copy=True, sparse=False, indexing="xy"):
1-D arrays representing the coordinates of a grid.
indexing : {'xy', 'ij'}, optional
Cartesian (``'xy'``, default) or matrix (``'ij'``) indexing of output.
sparse : bool, optional
sparse : {bool}, optional
If True the shape of the returned coordinate array for dimension `i`
is reduced from ``(N1, ..., Ni, ... Nn)`` to
``(1, ..., 1, Ni, 1, ..., 1)``. Default is False.
copy : bool, optional
copy : {bool}, optional
If False, a view into the original arrays are returned in order to
conserve memory. Default is True.

Expand Down Expand Up @@ -2908,7 +2908,7 @@ def ones(
----------
shape : {int, sequence of ints}
Shape of the new array, e.g., (2, 3) or 2.
dtype : dtype, optional
dtype : {None, dtype}, optional
The desired dtype for the array, e.g., dpnp.int32.
Default is the default floating point data type for the device where
input array is allocated.
Expand Down Expand Up @@ -3012,7 +3012,7 @@ def ones_like(
a : {dpnp_array, usm_ndarray}
The shape and dtype of `a` define these same attributes
of the returned array.
dtype : dtype, optional
dtype : {None, dtype}, optional
The desired dtype for the array, e.g., dpnp.int32.
Default is the default floating point data type for the device where
input array is allocated.
Expand Down Expand Up @@ -3158,7 +3158,7 @@ def tri(
The sub-diagonal at and below which the array is filled. k = 0 is
the main diagonal, while k < 0 is below it, and k > 0 is above.
The default is 0.
dtype : dtype, optional
dtype : {None, dtype}, optional
The desired dtype for the array, e.g., dpnp.int32.
Default is the default floating point data type for the device where
input array is allocated.
Expand Down Expand Up @@ -3385,7 +3385,7 @@ def vander(
N : int, optional
Number of columns in the output. If `N` is not specified, a square
array is returned ``(N = len(x))``.
increasing : bool, optional
increasing : {bool}, optional
Order of the powers of the columns. If ``True,`` the powers increase
from left to right, if ``False`` (the default) they are reversed.
device : {None, string, SyclDevice, SyclQueue}, optional
Expand Down Expand Up @@ -3499,7 +3499,7 @@ def zeros(
----------
shape : {int, sequence of ints}
Shape of the new array, e.g., (2, 3) or 2.
dtype : dtype, optional
dtype : {None, dtype}, optional
The desired dtype for the array, e.g., dpnp.int32.
Default is the default floating point data type for the device where
input array is allocated.
Expand Down Expand Up @@ -3603,7 +3603,7 @@ def zeros_like(
a : {dpnp_array, usm_ndarray}
The shape and dtype of `a` define these same attributes
of the returned array.
dtype : dtype, optional
dtype : {None, dtype}, optional
The desired dtype for the array, e.g., dpnp.int32.
Default is the default floating point data type for the device where
input array is allocated.
Expand Down
Loading
Loading