license import { Fill , FillAttrs , KernelConfig , scalar , tensor1d } from '@tensorflow/tfjs' ; import { NodeJSKernelBackend } from '../nodejs_kernel_backend' ; export const fillConfig = { kernelName : Fill , backendName : 'tensorflow' , kernelFunc : ( args ) => { const backend = args . backend as NodeJSKernelBackend ; const { shape , value } = args . attrs as { } as FillAttrs ; let { dtype } = args . attrs as { } as FillAttrs ; if ( dtype == null ) { if ( typeof value === 'number' ) { dtype = 'float32' ; } else { dtype = 'string' ; } } const shapeTensor = tensor1d ( shape , 'int32' ) ; const valueTensor = scalar ( value , dtype ) ; const opAttrs = [ { name : 'T' , type : backend . binding . TF_ATTR_TYPE , value : backend . getDTypeInteger ( dtype ) } , { name : 'index_type' , type : backend . binding . TF_ATTR_TYPE , value : backend . binding . TF_INT32 } ] ; const res = backend . executeSingleOutput ( Fill , opAttrs , [ shapeTensor , valueTensor ] ) ; shapeTensor . dispose ( ) ; valueTensor . dispose ( ) ; return res ; } } ;