license import { KernelConfig , KernelFunc , StringNGrams , StringNGramsAttrs , StringNGramsInputs , TensorInfo } from '@tensorflow/tfjs-core' ; import { MathBackendWebGL } from '../backend_webgl' ; import { stringNGramsImplCPU } from '../kernel_utils/shared' ; export function stringNGrams ( args ) { const { inputs , backend , attrs } = args ; const { separator , nGramWidths , leftPad , rightPad , padWidth , preserveShortSequences } = attrs ; const { data , dataSplits } = inputs ; const $data = backend . readSync ( data . dataId ) as Uint8Array [ ] ; const $dataSplits = backend . readSync ( dataSplits . dataId ) as Int32Array ; const [ nGrams , nGramsSplits ] = stringNGramsImplCPU ( $data , $dataSplits , separator , nGramWidths , leftPad , rightPad , padWidth , preserveShortSequences ) ; return [ backend . makeTensorInfo ( [ nGrams . length ] , 'string' , nGrams ) , backend . makeTensorInfo ( dataSplits . shape , 'int32' , nGramsSplits ) , ] ; } export const stringNGramsConfig = { kernelName : StringNGrams , backendName : 'webgl' , kernelFunc : stringNGrams as { } as KernelFunc , } ;