(args: {
inputs: MaxPoolGradInputs,
backend: MathBackendWebGL,
attrs: MaxPoolGradAttrs
})
| 22 | import {assertNotComplex} from '../webgl_util'; |
| 23 | |
| 24 | export function maxPoolGrad(args: { |
| 25 | inputs: MaxPoolGradInputs, |
| 26 | backend: MathBackendWebGL, |
| 27 | attrs: MaxPoolGradAttrs |
| 28 | }): TensorInfo { |
| 29 | const {inputs, backend, attrs} = args; |
| 30 | const {dy, input, output} = inputs; |
| 31 | const x = input; |
| 32 | assertNotComplex([input, output], 'maxPoolGrad'); |
| 33 | const {filterSize, strides, pad, dimRoundingMode} = attrs; |
| 34 | |
| 35 | const convInfo = backend_util.computePool2DInfo( |
| 36 | x.shape as [number, number, number, number], filterSize, strides, |
| 37 | 1 /* dilations */, pad, dimRoundingMode); |
| 38 | const getPositions = true; |
| 39 | const maxPoolPositionsProgram = |
| 40 | new Pool2DProgram(convInfo, 'max', getPositions); |
| 41 | const maxPoolPositions: TensorInfo = |
| 42 | backend.runWebGLProgram(maxPoolPositionsProgram, [x], x.dtype); |
| 43 | |
| 44 | const maxPoolBackPropProgram = new MaxPool2DBackpropProgram(convInfo); |
| 45 | const result = backend.runWebGLProgram( |
| 46 | maxPoolBackPropProgram, [dy, maxPoolPositions], x.dtype); |
| 47 | backend.disposeIntermediateTensorInfo(maxPoolPositions); |
| 48 | return result; |
| 49 | } |
| 50 | |
| 51 | export const maxPoolGradConfig: KernelConfig = { |
| 52 | kernelName: MaxPoolGrad, |
nothing calls this directly
no test coverage detected
searching dependent graphs…