license import { KernelConfig , Sum , SumAttrs , SumInputs , tensor1d , util } from '@tensorflow/tfjs' ; import { NodeJSKernelBackend } from '../nodejs_kernel_backend' ; export const sumConfig = { kernelName : Sum , backendName : 'tensorflow' , kernelFunc : ( args ) => { const { x } = args . inputs as SumInputs ; const backend = args . backend as NodeJSKernelBackend ; const { axis , keepDims } = args . attrs as { } as SumAttrs ; const axes = util . parseAxisParam ( axis , x . shape ) ; const axisTensor = tensor1d ( axes , 'int32' ) ; const res = backend . executeSingleOutput ( Sum , backend . createReductionOpAttrs ( x , keepDims ) , [ x , axisTensor ] ) ; axisTensor . dispose ( ) ; return res ; } } ;