license import { KernelConfig , KernelFunc , StringToHashBucketFast , StringToHashBucketFastAttrs , StringToHashBucketFastInputs , TensorInfo } from '@tensorflow/tfjs-core' ; import { MathBackendWebGL } from '../backend_webgl' ; import { stringToHashBucketFastImplCPU } from '../kernel_utils/shared' ; export function stringToHashBucketFast ( args ) { const { inputs , backend , attrs } = args ; const { numBuckets } = attrs ; const { input } = inputs ; if ( input . dtype !== 'string' ) { throw new Error ( 'Input must be of datatype string' ) ; } if ( numBuckets <= 0 ) { throw new Error ( `Number of buckets must be at least 1` ) ; } const $input = backend . readSync ( input . dataId ) as Uint8Array [ ] ; const output = stringToHashBucketFastImplCPU ( $input , numBuckets ) ; return backend . makeTensorInfo ( input . shape , 'int32' , output ) ; } export const stringToHashBucketFastConfig = { kernelName : StringToHashBucketFast , backendName : 'webgl' , kernelFunc : stringToHashBucketFast as { } as KernelFunc , } ;