license import { backend_util , KernelConfig , KernelFunc , MaxPool3DGrad , MaxPool3DGradAttrs , MaxPool3DGradInputs , TensorInfo } from '@tensorflow/tfjs-core' ; import { MathBackendWebGL } from '../backend_webgl' ; import { MaxPool3DBackpropProgram } from '../max_pool_backprop_gpu' ; import { Pool3DProgram } from '../pool_gpu' ; export function maxPool3DGrad ( args ) { const { inputs , backend , attrs } = args ; const { dy , input } = inputs ; const x = input ; const { filterSize , strides , pad , dimRoundingMode } = attrs ; const dilations = [ 1 , 1 , 1 ] ; const convInfo = backend_util . computePool3DInfo ( x . shape as [ number , number , number , number , number ] , filterSize , strides , dilations , pad , dimRoundingMode ) ; const maxPool3dPositionsProgram = new Pool3DProgram ( convInfo , 'max' , true ) ; const maxPool3dPositions = backend . runWebGLProgram ( maxPool3dPositionsProgram , [ x ] , x . dtype ) ; const maxPoolBackpropProgram = new MaxPool3DBackpropProgram ( convInfo ) ; const result = backend . runWebGLProgram ( maxPoolBackpropProgram , [ dy , maxPool3dPositions ] , x . dtype ) ; backend . disposeIntermediateTensorInfo ( maxPool3dPositions ) ; return result ; } export const maxPool3DGradConfig = { kernelName : MaxPool3DGrad , backendName : 'webgl' , kernelFunc : maxPool3DGrad as { } as KernelFunc } ;