* Finds unique elements along an axis of a tensor. * * It returns a tensor `values` containing all of the unique elements along the * `axis` of the given tensor `x` in the same order that they occur along the * `axis` in `x`; `x` does not need to be sorted. It also returns a tensor * `indices`
(
x: T|TensorLike, axis = 0)
| 76 | * @doc {heading: 'Operations', subheading: 'Evaluation'} |
| 77 | */ |
| 78 | function unique_<T extends Tensor>( |
| 79 | x: T|TensorLike, axis = 0): {values: T, indices: Tensor1D} { |
| 80 | const $x = convertToTensor(x, 'x', 'unique', 'string_or_numeric'); |
| 81 | assert($x.rank > 0, () => 'The input tensor must be at least 1D'); |
| 82 | |
| 83 | const inputs: UniqueInputs = {x: $x}; |
| 84 | const attrs: UniqueAttrs = {axis}; |
| 85 | const [values, indices] = ENGINE.runKernel( |
| 86 | Unique, inputs as unknown as NamedTensorMap, |
| 87 | attrs as unknown as NamedAttrMap) as [T, Tensor1D]; |
| 88 | return {values, indices}; |
| 89 | } |
| 90 | |
| 91 | export const unique = /* @__PURE__ */ op({unique_}); |
nothing calls this directly
no test coverage detected
searching dependent graphs…