license import { DataType , DataValues , Fill , FillAttrs , KernelConfig , KernelFunc , TensorInfo , TypedArray , util } from '@tensorflow/tfjs-core' ; import { MathBackendCPU } from '../backend_cpu' ; export function fill ( args ) { const { backend , attrs } = args ; const { shape , value , dtype } = attrs ; const $dtype = dtype || util . inferDtype ( value ) ; const values = util . getArrayFromDType ( $dtype , util . sizeFromShape ( shape ) ) ; fillValues ( values , value , $dtype ) ; return backend . makeTensorInfo ( shape , $dtype , values ) ; } export const fillConfig = { kernelName : Fill , backendName : 'cpu' , kernelFunc : fill as { } as KernelFunc } ; function fillValues ( values , value , dtype ) { if ( dtype === 'string' ) { ( values as string [ ] ) . fill ( value as string ) ; } else { ( values as TypedArray ) . fill ( value as number ) ; } }