mindspore.ops.unique
- mindspore.ops.unique(input)[source]
Remove duplicate elements from the input tensor.
Warning
Non-backward-compatible change after version 2.9.0: the current default return (output, indices) will be changed so that only output is returned by default.
- Parameters
input (Tensor) – The input tensor.
- Returns
Tuple(output, indices) of 2 tensors.
output (Tensor) - The deduplicated output tensor.
indices (Tensor) - The indices of the elements of the input tensor in the output .
- Supported Platforms:
AscendGPUCPU
Examples
>>> import mindspore >>> x = mindspore.tensor([1, 2, 5, 2], mindspore.int32) >>> output, indices = mindspore.ops.unique(x) >>> print(output) [1 2 5] >>> print(indices) [0 1 2 1]