(args: {
inputs: MaxPoolGradInputs,
attrs: MaxPoolGradAttrs,
backend: BackendWasm,
})
| 50 | } |
| 51 | |
| 52 | export function maxPoolGrad(args: { |
| 53 | inputs: MaxPoolGradInputs, |
| 54 | attrs: MaxPoolGradAttrs, |
| 55 | backend: BackendWasm, |
| 56 | }): TensorInfo { |
| 57 | const {inputs, backend, attrs} = args; |
| 58 | const {dy, input} = inputs; |
| 59 | const {filterSize, strides, pad, dimRoundingMode} = attrs; |
| 60 | |
| 61 | const convInfo = backend_util.computePool2DInfo( |
| 62 | input.shape as [number, number, number, number], filterSize, strides, |
| 63 | /*dilations=*/1, pad, dimRoundingMode); |
| 64 | const dx = backend.makeOutput(input.shape, input.dtype); |
| 65 | |
| 66 | wasmMaxPoolGrad( |
| 67 | backend.dataIdMap.get(input.dataId).id, |
| 68 | backend.dataIdMap.get(dy.dataId).id, |
| 69 | backend.dataIdMap.get(dx.dataId).id, |
| 70 | convInfo.batchSize, |
| 71 | // Since Pool ops (MaxPool and MaxPool) support 2D filter only, in |
| 72 | // channels should always equal to out channels. |
| 73 | /*channelSize=*/convInfo.inChannels, |
| 74 | convInfo.inHeight, |
| 75 | convInfo.inWidth, |
| 76 | convInfo.outHeight, |
| 77 | convInfo.outWidth, |
| 78 | convInfo.strideHeight, |
| 79 | convInfo.strideWidth, |
| 80 | convInfo.dilationHeight, |
| 81 | convInfo.dilationWidth, |
| 82 | convInfo.effectiveFilterHeight, |
| 83 | convInfo.effectiveFilterWidth, |
| 84 | convInfo.padInfo.top, |
| 85 | convInfo.padInfo.left, |
| 86 | ); |
| 87 | return dx; |
| 88 | } |
| 89 | |
| 90 | export const maxPoolGradConfig: KernelConfig = { |
| 91 | kernelName: MaxPoolGrad, |
nothing calls this directly
no test coverage detected
searching dependent graphs…