mindspore.ops.all
- mindspore.ops.all(input, axis=None, keep_dims=False)[源代码]
检查指定轴上是否所有元素均为 True。
警告
从2.9.0(不含)之后版本开始,该接口将发生非兼容性变更:
参数 axis 将重命名为 dim 。
参数 keep_dims 将重命名为 keepdim 。
变更后的接口签名为
mindspore.ops.all(input, dim=None, keepdim=False)。- 参数:
input (Tensor) - 输入tensor。
axis (Union[int, tuple(int), list(int), Tensor], 可选) - 指定轴。如果为
None,检查所有元素。默认None。2.9.0(不含)之后版本将重命名为 dim 。keep_dims (bool, 可选) - 输出tensor是否保留维度。默认
False。2.9.0(不含)之后版本将重命名为 keepdim 。
- 返回:
Tensor
- 支持平台:
AscendGPUCPU
样例:
>>> import mindspore >>> input = mindspore.tensor([[True, False], [True, True]]) >>> >>> # case 1: By default, mindspore.ops.all tests along all the axes. >>> mindspore.ops.all(input) Tensor(shape=[], dtype=Bool, value= False) >>> >>> # case 2: Reduces a dimension along axis 1, with keep_dims False. >>> mindspore.ops.all(input, axis=1) Tensor(shape=[2], dtype=Bool, value= [False, True]) >>> >>> # case 3: Reduces a dimension along axis (0,1), with keep_dims False. >>> mindspore.ops.all(input, axis=(0,1)) Tensor(shape=[], dtype=Bool, value= False) >>> >>> # case 4: Reduces a dimension along axis [0,1], with keep_dims True. >>> mindspore.ops.all(input, axis=[0,1], keep_dims=True) Tensor(shape=[1, 1], dtype=Bool, value= [[False]])