mindspore.ops.argwhere

mindspore.ops.argwhere(input)[source]

Return a Tensor of the positions of all non-zero values.

Parameters

input (Tensor) – The input tensor. The data type is Number or Bool.

Returns

Tensor, a 2-D Tensor whose data type is int64, containing the positions of all non-zero values of the input.

Raises
Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> from mindspore import Tensor, ops
>>> import numpy as np
>>> x = Tensor(np.array([[[1,  0], [-5, 0]]]), mindspore.int32)
>>> output = ops.argwhere(x)
>>> print(output)
[[0 0 0]
 [0 1 0]]