mindspore.mint.any

View Source On Gitee
mindspore.mint.any(input, dim=None, keepdim=False)[source]

Tests if any element in input evaluates to True along the given axes.

Parameters
  • input (Tensor) – The input tensor.

  • dim (Union[int, tuple(int), list(int), Tensor], optional) – The dimensions to reduce. If None , all dimensions are reduced. Default None .

  • keepdim (bool, optional) – Whether the output tensor has dim retained or not. Default False .

Returns

Tensor

Supported Platforms:

Ascend

Examples

>>> import mindspore
>>> input = mindspore.tensor([[True, False], [True, True]])
>>>
>>> # case 1:  By default, mindspore.mint.any tests along all the axes.
>>> mindspore.mint.any(input)
Tensor(shape=[], dtype=Bool, value= True)
>>>
>>> # case 2: Reduces a dimension along dim 1, with keepdim False.
>>> mindspore.mint.any(input, dim=1)
Tensor(shape=[2], dtype=Bool, value= [ True,  True])
>>>
>>> # case 3: Reduces a dimension along dim (0, 1), with keepdim False.
>>> mindspore.mint.any(input, dim=(0,1))
Tensor(shape=[], dtype=Bool, value= True)
>>>
>>> # case 4: Reduces a dimension along dim [0, 1], with keepdim True.
>>> mindspore.mint.any(input, dim=[0,1], keepdim=True)
Tensor(shape=[1, 1], dtype=Bool, value=
[[ True]])