MCPcopy Create free account
hub / github.com/tensorflow/tfjs / maxPoolGrad

Function maxPoolGrad

tfjs-backend-webgl/src/kernels/MaxPoolGrad.ts:24–49  ·  view source on GitHub ↗
(args: {
  inputs: MaxPoolGradInputs,
  backend: MathBackendWebGL,
  attrs: MaxPoolGradAttrs
})

Source from the content-addressed store, hash-verified

22import {assertNotComplex} from '../webgl_util';
23
24export 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
51export const maxPoolGradConfig: KernelConfig = {
52 kernelName: MaxPoolGrad,

Callers

nothing calls this directly

Calls 3

assertNotComplexFunction · 0.90
runWebGLProgramMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…