license import { cast , KernelConfig , Mean , MeanAttrs , MeanInputs , Tensor , tensor1d , util } from '@tensorflow/tfjs' ; import { NodeJSKernelBackend } from '../nodejs_kernel_backend' ; export const meanConfig = { kernelName : Mean , backendName : 'tensorflow' , kernelFunc : ( args ) => { const { x } = args . inputs as MeanInputs ; const backend = args . backend as NodeJSKernelBackend ; const { axis , keepDims } = args . attrs as { } as MeanAttrs ; const axes = util . parseAxisParam ( axis , x . shape ) ; const axesTensor = tensor1d ( axes , 'int32' ) ; const asFloat32 = cast ( x as Tensor , 'float32' ) ; const res = backend . executeSingleOutput ( Mean , backend . createReductionOpAttrs ( x , keepDims ) , [ asFloat32 , axesTensor ] ) ; asFloat32 . dispose ( ) ; axesTensor . dispose ( ) ; return res ; } } ;