mindspore.ops.UniqueWithPad¶
-
class
mindspore.ops.
UniqueWithPad
(*args, **kwargs)[source]¶ Returns unique elements and relative indexes in 1-D tensor, filled with padding num.
- Inputs:
x (Tensor) - The tensor need to be unique. Must be 1-D vector with types: int32, int64.
pad_num (int) - Pad num.
- Outputs:
tuple(Tensor), tuple of 2 tensors, y and idx. - y (Tensor) - The unique elements filled with pad_num, the shape and type same as x. - idx (Tensor) - The index of each value of x in the unique output y, the shape and type same as x.
- Raises
TypeError – If dtype of x is neither int32 nor int64.
ValueError – If length of shape of x is not equal to 1.
- Supported Platforms:
Ascend
CPU
Examples
>>> x = Tensor(np.array([1, 1, 5, 5, 4, 4, 3, 3, 2, 2,]), mindspore.int32) >>> pad_num = 8 >>> output = ops.UniqueWithPad()(x, pad_num) >>> print(output) (Tensor(shape=[10], dtype=Int32, value= [1, 5, 4, 3, 2, 8, 8, 8, 8, 8]), Tensor(shape=[10], dtype=Int32, value= [0, 0, 1, 1, 2, 2, 3, 3, 4, 4]))