|
5 | 5 | import dpctl.tensor._tensor_impl as ti
|
6 | 6 |
|
7 | 7 |
|
8 |
| -# can be refactored later into general reduction |
9 | 8 | def _boolean_reduction(x, axis, keepdims, func):
|
10 | 9 | if not isinstance(x, dpt.usm_ndarray):
|
11 | 10 | raise TypeError(f"Expected dpctl.tensor.usm_ndarray, got {type(x)}")
|
@@ -64,9 +63,57 @@ def _boolean_reduction(x, axis, keepdims, func):
|
64 | 63 | return res
|
65 | 64 |
|
66 | 65 |
|
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 | + """ |
68 | 91 | return _boolean_reduction(x, axis, keepdims, ti._all)
|
69 | 92 |
|
70 | 93 |
|
71 | 94 | 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 | + """ |
72 | 119 | return _boolean_reduction(x, axis, keepdims, ti._any)
|
0 commit comments