コード例 #1
0
ファイル: reduce_ops.py プロジェクト: zzk0/oneflow
def all_op(input, dim=None, keepdim=False):
    """Computes if all elements in the input tensor to true.
    
    Args:
        input (oneflow.Tensor): the Input Tensor
        dim (int, optional): the dimension to reduce. Default: `None`
        keepdim (bool, optional): whether the output tensor has dim retained or not. Default: `False`

    Returns:
        Tensor(oneflow.Tensor(dtype=int8)): If :attr:`dim` is `None`, returns 
        the logical all value of all elements in the `input` tensor.
    
    For example:

    .. code-block:: python

        >>> import oneflow as flow
        >>> input = flow.arange(0, 3)
        >>> flow.all(input)
        tensor(False, dtype=oneflow.bool)

    """

    axis_checked = _check_axis(dim, input.shape)
    if len(axis_checked) == 0:
        return input
    return flow._C.reduce_all(input, axis=axis_checked, keepdims=keepdim)
コード例 #2
0
ファイル: reduce_ops.py プロジェクト: zzk0/oneflow
def min_op(input, dim=None, keepdim=False):
    axis_checked = _check_axis(dim, input.shape)
    if len(axis_checked) == 0:
        return input
    if dim == None:
        return flow._C.reduce_min(input, axis=axis_checked, keepdims=keepdim)
    else:
        return (
            flow._C.reduce_min(input, axis=axis_checked, keepdims=keepdim),
            input.argmin(dim=dim, keepdim=keepdim),
        )
コード例 #3
0
ファイル: reduce_ops.py プロジェクト: zzk0/oneflow
def prod_op(input, dim=None, keepdim=False):
    axis_checked = _check_axis(dim, input.shape)
    if len(axis_checked) == 0:
        return input
    return flow._C.reduce_prod(input, axis_checked, keepdim)
コード例 #4
0
ファイル: reduce_ops.py プロジェクト: zzk0/oneflow
def mean_op(input, dim=None, keepdim=False):
    axis_checked = _check_axis(dim, input.shape)
    if len(axis_checked) == 0:
        return input
    return flow._C.reduce_mean(input, axis=axis_checked, keepdims=keepdim)