license import { KernelConfig , KernelFunc , StringToHashBucketFast , StringToHashBucketFastAttrs , StringToHashBucketFastInputs , TensorInfo } from '@tensorflow/tfjs-core' ; import { MathBackendCPU } from '../backend_cpu' ; import { stringToHashBucketFastImpl } from './StringToHashBucketFast_impl' ; 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 . data . get ( input . dataId ) . values as Uint8Array [ ] ; const output = stringToHashBucketFastImpl ( $input , numBuckets ) ; return backend . makeTensorInfo ( input . shape , 'int32' , output ) ; } export const stringToHashBucketFastConfig = { kernelName : StringToHashBucketFast , backendName : 'cpu' , kernelFunc : stringToHashBucketFast as { } as KernelFunc , } ;