license import { FusedConv2D , FusedConv2DAttrs , FusedConv2DInputs , KernelConfig , KernelFunc , TensorInfo } from '@tensorflow/tfjs-core' ; import { MathBackendCPU } from '../backend_cpu' ; import { applyActivation } from '../utils/fused_utils' ; import { add } from './Add' ; import { conv2D } from './Conv2D' ; export function fusedConv2D ( args ) { const { inputs , backend , attrs } = args ; const { x , filter , bias , preluActivationWeights } = inputs ; const { strides , pad , dataFormat , dilations , dimRoundingMode , activation , leakyreluAlpha } = attrs ; let result = conv2D ( { inputs : { x , filter } , backend , attrs : { strides , pad , dataFormat , dilations , dimRoundingMode } } ) ; if ( bias ) { const resultOld = result ; result = add ( { inputs : { a : result , b : bias } , backend } ) as TensorInfo ; backend . disposeIntermediateTensorInfo ( resultOld ) ; } if ( activation ) { const resultOld = result ; result = applyActivation ( backend , result , activation , preluActivationWeights , leakyreluAlpha ) ; backend . disposeIntermediateTensorInfo ( resultOld ) ; } return result ; } export const fusedConv2DConfig = { kernelName : FusedConv2D , backendName : 'cpu' , kernelFunc : fusedConv2D as { } as KernelFunc } ;