oneflow.all(input, dim=None, keepdim=False)Tensor

For each row of input in the given dimension dim, returns True if all element in the row evaluate to True and False otherwise. If the dimension is None, compute if all elements in the input tensor to true.

If keepdim is True, the output tensor is of the same size as input except in the dimension(s) dim where it is of size 1. Otherwise, dim is squeezed oneflow.squeeze(), resulting in the output tensor having 1 (or len(dim)) fewer dimension(s).

  • 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

For example:

>>> import oneflow as flow

>>> input = flow.Tensor([[1, 2, 3], [4, 5, 6]]) < 4
>>> input
tensor([[ True,  True,  True],
        [False, False, False]], dtype=oneflow.bool)
>>> flow.all(input)
tensor(False, dtype=oneflow.bool)
>>> flow.all(input, 1)
tensor([ True, False], dtype=oneflow.bool)
>>> flow.all(input, 1, True)
tensor([[ True],
        [False]], dtype=oneflow.bool)