license import { KernelConfig , Prod , ProdAttrs , ProdInputs , tensor1d , util } from '@tensorflow/tfjs' ; import { createTensorsTypeOpAttr , NodeJSKernelBackend } from '../nodejs_kernel_backend' ; export const prodConfig = { kernelName : Prod , backendName : 'tensorflow' , kernelFunc : ( args ) => { const { x } = args . inputs as ProdInputs ; const backend = args . backend as NodeJSKernelBackend ; const { axis , keepDims } = args . attrs as { } as ProdAttrs ; const axes = util . parseAxisParam ( axis , x . shape ) ; const axesTensor = tensor1d ( axes , 'int32' ) ; const opAttrs = [ { name : 'keep_dims' , type : backend . binding . TF_ATTR_BOOL , value : keepDims } , createTensorsTypeOpAttr ( 'T' , x . dtype ) , createTensorsTypeOpAttr ( 'Tidx' , 'int32' ) ] ; const res = backend . executeSingleOutput ( Prod , opAttrs , [ x , axesTensor ] ) ; axesTensor . dispose ( ) ; return res ; } } ;