MCPcopy
hub / github.com/tensorflow/tfjs / unique_

Function unique_

tfjs-core/src/ops/unique.ts:78–89  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

76 * @doc {heading: 'Operations', subheading: 'Evaluation'}
77 */
78function 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
91export const unique = /* @__PURE__ */ op({unique_});

Callers

nothing calls this directly

Calls 3

convertToTensorFunction · 0.90
assertFunction · 0.90
runKernelMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…