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

Function maxPool3DGrad

tfjs-backend-webgpu/src/kernels/MaxPool3DGrad.ts:24–96  ·  view source on GitHub ↗
(args: {
  inputs: MaxPool3DGradInputs,
  backend: WebGPUBackend,
  attrs: MaxPool3DGradAttrs
})

Source from the content-addressed store, hash-verified

22import {Pool3DProgram} from '../pool_webgpu';
23
24export function maxPool3DGrad(args: {
25 inputs: MaxPool3DGradInputs,
26 backend: WebGPUBackend,
27 attrs: MaxPool3DGradAttrs
28}): TensorInfo {
29 const {inputs, backend, attrs} = args;
30 const {dy, input} = inputs;
31 const x = input;
32 const {filterSize, strides, pad, dimRoundingMode} = attrs;
33 const dilations: [number, number, number] = [1, 1, 1];
34
35 const convInfo = backend_util.computePool3DInfo(
36 x.shape as [number, number, number, number, number], filterSize, strides,
37 dilations, pad, dimRoundingMode);
38
39 const maxPool3dPositionsProgram =
40 new Pool3DProgram(convInfo, 'max', true /* get positions */);
41 let uniformData = [
42 {
43 type: 'int32',
44 data: [convInfo.strideDepth, convInfo.strideHeight, convInfo.strideWidth]
45 },
46 {
47 type: 'int32',
48 data:
49 [convInfo.padInfo.front, convInfo.padInfo.top, convInfo.padInfo.left]
50 },
51 {
52 type: 'int32',
53 data: [convInfo.inDepth, convInfo.inHeight, convInfo.inWidth]
54 },
55 {
56 type: 'int32',
57 data: [
58 convInfo.effectiveFilterDepth, convInfo.effectiveFilterHeight,
59 convInfo.effectiveFilterWidth
60 ]
61 }
62 ];
63 const maxPool3dPositions = backend.runWebGPUProgram(
64 maxPool3dPositionsProgram, [x], 'int32', uniformData);
65
66 const maxPool3dBackpropProgram = new MaxPool3DBackpropProgram(convInfo);
67 uniformData = [
68 {
69 type: 'int32',
70 data: [convInfo.strideDepth, convInfo.strideHeight, convInfo.strideWidth]
71 },
72 {
73 type: 'int32',
74 data: [
75 convInfo.effectiveFilterDepth - 1 - convInfo.padInfo.front,
76 convInfo.effectiveFilterHeight - 1 - convInfo.padInfo.top,
77 convInfo.effectiveFilterWidth - 1 - convInfo.padInfo.left
78 ]
79 },
80 {
81 type: 'int32',

Callers

nothing calls this directly

Calls 2

runWebGPUProgramMethod · 0.80
disposeDataMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…