unique(input: Tensor, sorted: _bool = ..., return_inverse: _bool = ..., return_counts: _bool = ..., dim: _int | None = ...)Implementing kernel
C++ engine symbols that back this Python API.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; with dim the unique
values are whole slices along that dim.
Parameters
inputTensorSource tensor.
sortedbool= TrueAccepted for compatibility; the values always come back sorted.
return_inversebool= FalseAlso return, for every element (or slice along
dim), the
position of its value in the output — in input's shape, or
one entry per slice.return_countsbool= FalseAlso return how many times each unique value occurs.
dimint= ...Dim whose slices are compared;
None flattens input.Returns
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])