Skip to content

Commit 400e437

Browse files
committed
Added docstrings for dpctl.tensor.all and dpctl.tensor.any
1 parent 0b8b875 commit 400e437

File tree

1 file changed

+49
-2
lines changed

1 file changed

+49
-2
lines changed

dpctl/tensor/_utility_functions.py

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import dpctl.tensor._tensor_impl as ti
66

77

8-
# can be refactored later into general reduction
98
def _boolean_reduction(x, axis, keepdims, func):
109
if not isinstance(x, dpt.usm_ndarray):
1110
raise TypeError(f"Expected dpctl.tensor.usm_ndarray, got {type(x)}")
@@ -64,9 +63,57 @@ def _boolean_reduction(x, axis, keepdims, func):
6463
return res
6564

6665

67-
def all(x, axis=None, out=None, keepdims=False):
66+
def all(x, axis=None, keepdims=False):
67+
"""all(x, axis=None, keepdims=False)
68+
69+
Tests whether all input array elements evaluate to True along a given axis.
70+
71+
Args:
72+
x (usm_ndarray): Input array.
73+
axis (Optional[Union[int, Tuple[int,...]]]): Axis (or axes)
74+
along which to perform a logical AND reduction.
75+
When `axis` is `None`, a logical AND reduction
76+
is performed over all dimensions of `x`.
77+
If `axis` is negative, the axis is counted from
78+
the last dimension to the first.
79+
Default: `None`.
80+
keepdims (bool, optional): If `True`, the reduced axes are included
81+
in the result as singleton dimensions, and the result is
82+
broadcastable to the input array shape.
83+
If `False`, the reduced axes are not included in the result.
84+
Default: `False`.
85+
86+
Returns:
87+
usm_ndarray:
88+
An array with a data type of `bool`
89+
containing the results of the logical AND reduction.
90+
"""
6891
return _boolean_reduction(x, axis, keepdims, ti._all)
6992

7093

7194
def any(x, axis=None, keepdims=False):
95+
"""any(x, axis=None, keepdims=False)
96+
97+
Tests whether any input array elements evaluate to True along a given axis.
98+
99+
Args:
100+
x (usm_ndarray): Input array.
101+
axis (Optional[Union[int, Tuple[int,...]]]): Axis (or axes)
102+
along which to perform a logical OR reduction.
103+
When `axis` is `None`, a logical OR reduction
104+
is performed over all dimensions of `x`.
105+
If `axis` is negative, the axis is counted from
106+
the last dimension to the first.
107+
Default: `None`.
108+
keepdims (bool, optional): If `True`, the reduced axes are included
109+
in the result as singleton dimensions, and the result is
110+
broadcastable to the input array shape.
111+
If `False`, the reduced axes are not included in the result.
112+
Default: `False`.
113+
114+
Returns:
115+
usm_ndarray:
116+
An array with a data type of `bool`
117+
containing the results of the logical OR reduction.
118+
"""
72119
return _boolean_reduction(x, axis, keepdims, ti._any)

0 commit comments

Comments
 (0)