license import { KernelConfig , KernelFunc , TensorInfo , Unique , UniqueAttrs , UniqueInputs } from '@tensorflow/tfjs-core' ; import { MathBackendWebGL } from '../backend_webgl' ; import { uniqueImplCPU } from '../kernel_utils/shared' ; import { assertNotComplex } from '../webgl_util' ; export function unique ( args ) { const { inputs , attrs , backend } = args ; const { axis } = attrs ; const { x } = inputs ; assertNotComplex ( x , 'unique' ) ; console . warn ( 'WARNING: ' , 'UI might be locked temporarily as data is being downloaded' ) ; const values = backend . readSync ( x . dataId ) ; const { outputValues , outputShape , indices } = uniqueImplCPU ( values , axis , x . shape , x . dtype ) ; return [ backend . makeTensorInfo ( outputShape , x . dtype , outputValues ) , backend . makeTensorInfo ( [ indices . length ] , 'int32' , indices ) , ] ; } export const uniqueConfig = { kernelName : Unique , backendName : 'webgl' , kernelFunc : unique as { } as KernelFunc , } ;