license import { AvgPoolGrad , AvgPoolGradAttrs , AvgPoolGradInputs , backend_util , KernelConfig , KernelFunc , TensorInfo } from '@tensorflow/tfjs-core' ; import { AvgPool2DBackpropProgram } from '../avg_pool_backprop_gpu' ; import { MathBackendWebGL } from '../backend_webgl' ; import { assertNotComplex } from '../webgl_util' ; export function avgPoolGrad ( args ) { const { inputs , backend , attrs } = args ; const { dy , input } = inputs ; const x = input ; assertNotComplex ( [ dy , input ] , 'avgPoolGrad' ) ; const { filterSize , strides , pad } = attrs ; const convInfo = backend_util . computePool2DInfo ( x . shape as [ number , number , number , number ] , filterSize , strides , 1 , pad ) ; const avgPoolBackpropProgram = new AvgPool2DBackpropProgram ( convInfo ) ; return backend . runWebGLProgram ( avgPoolBackpropProgram , [ dy ] , x . dtype ) ; } export const avgPoolGradConfig = { kernelName : AvgPoolGrad , backendName : 'webgl' , kernelFunc : avgPoolGrad as { } as KernelFunc } ;