def all(a, axis=None, out=None, keepdims=False): """Tests whether all array elements along a given axis evaluate to True. Args: a (cupy.ndarray): Input array. axis (int or tuple of ints): Along which axis to compute all. The flattened array is used by default. out (cupy.ndarray): Output array. keepdims (bool): If ``True``, the axis is remained as an axis of size one. Returns: cupy.ndarray: An array reduced of the input array along the axis. .. seealso:: :func:`numpy.all` """ if _fusion_thread_local.is_fusing(): if keepdims: raise NotImplementedError( 'cupy.all does not support `keepdims` in fusion yet.') return _fusion_thread_local.call_reduction( _logic.all, a, axis=axis, out=out) _util.check_array(a, arg_name='a') return a.all(axis=axis, out=out, keepdims=keepdims)
def all(a, axis=None, out=None, keepdims=False): """Tests whether all array elements along a given axis evaluate to True. Parameters ---------- a : cupy.ndarray Input array. axis : int or tuple of ints Along which axis to compute all. The flattened array is used by default. out : cupy.ndarray Output array. keepdims : bool If ``True``, the axis is remained as an axis of size one. Returns ------- y : cupy.ndarray An array reduced of the input array along the axis. See Also -------- numpy.all """ if _fusion_thread_local.is_fusing(): if keepdims: raise NotImplementedError( 'cupy.all does not support `keepdims` in fusion yet.') return _fusion_thread_local.call_reduction( _logic.all, a, axis=axis, out=out) _util.check_array(a, arg_name='a') return a.all(axis=axis, out=out, keepdims=keepdims)
def argwhere(a): """Return the indices of the elements that are non-zero. Returns a (N, ndim) dimantional array containing the indices of the non-zero elements. Where `N` is number of non-zero elements and `ndim` is dimension of the given array. Args: a (cupy.ndarray): array Returns: cupy.ndarray: Indices of elements that are non-zero. .. seealso:: :func:`numpy.argwhere` """ _util.check_array(a, arg_name='a') return _indexing._ndarray_argwhere(a)
def flatnonzero(a): """Return indices that are non-zero in the flattened version of a. This is equivalent to a.ravel().nonzero()[0]. Args: a (cupy.ndarray): input array Returns: cupy.ndarray: Output array, containing the indices of the elements of a.ravel() that are non-zero. .. warning:: This function may synchronize the device. .. seealso:: :func:`numpy.flatnonzero` """ _util.check_array(a, arg_name='a') return a.ravel().nonzero()[0]
def nonzero(a): """Return the indices of the elements that are non-zero. Returns a tuple of arrays, one for each dimension of a, containing the indices of the non-zero elements in that dimension. Args: a (cupy.ndarray): array Returns: tuple of arrays: Indices of elements that are non-zero. .. warning:: This function may synchronize the device. .. seealso:: :func:`numpy.nonzero` """ _util.check_array(a, arg_name='a') return a.nonzero()