license import { Fill , FillAttrs , KernelConfig , KernelFunc , TensorInfo , util } from '@tensorflow/tfjs-core' ; import { MathBackendWebGL } from '../backend_webgl' ; import { FillProgram } from '../fill_gpu' ; export function fill ( args ) { const { backend , attrs } = args ; const { shape , value } = attrs ; let { dtype } = attrs ; dtype = dtype || util . inferDtype ( value ) ; if ( dtype === 'string' ) { const values = util . getArrayFromDType ( dtype , util . sizeFromShape ( shape ) ) ; values . fill ( value as string ) ; return backend . makeTensorInfo ( shape , dtype , values ) ; } else { const program = new FillProgram ( shape , value as number ) ; const customValues = [ [ value as number ] ] ; return backend . runWebGLProgram ( program , [ ] , dtype , customValues ) ; } } export const fillConfig = { kernelName : Fill , backendName : 'webgl' , kernelFunc : fill as { } as KernelFunc } ;