fn

unique

Tensor
unique(input: Tensor)
source

Return the sorted unique elements of input.

Duplicate values are removed and the output is sorted in ascending order. By default the input is flattened — pass a dim argument via the underlying implementation to operate axis-wise.

Parameters

inputTensor
Source tensor.

Returns

Tensor

1-D tensor of unique values in ascending order.

Notes

Because the output size is data-dependent this op forces a host round-trip on accelerator backends.

Examples

>>> import lucid
>>> x = lucid.tensor([3, 1, 2, 3, 1, 4])
>>> lucid.unique(x)
Tensor([1, 2, 3, 4])