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

Function conv2DBackpropInputImpl

tfjs-node/src/kernels/Conv2DBackpropInput.ts:40–69  ·  view source on GitHub ↗
(
    dy: TensorInfo, filter: TensorInfo, convInfo: backend_util.Conv2DInfo,
    backend: NodeJSKernelBackend)

Source from the content-addressed store, hash-verified

38};
39
40function conv2DBackpropInputImpl(
41 dy: TensorInfo, filter: TensorInfo, convInfo: backend_util.Conv2DInfo,
42 backend: NodeJSKernelBackend): Tensor4D {
43 if (convInfo.padInfo.type !== 'VALID' && convInfo.padInfo.type !== 'SAME') {
44 throw new Error(
45 `TF Backend supports only 'valid' and 'same' padding ` +
46 `while padding was ${convInfo.padInfo.type}`);
47 }
48 const strides = [1, convInfo.strideHeight, convInfo.strideWidth, 1];
49 const padding = convInfo.padInfo.type;
50 const dataFormat = convInfo.dataFormat === 'channelsLast' ? 'NHWC' : 'NCHW';
51 const dilations = [1, convInfo.dilationHeight, convInfo.dilationWidth, 1];
52 const opAttrs = [
53 createTensorsTypeOpAttr('T', 'float32'),
54 {name: 'strides', type: backend.binding.TF_ATTR_INT, value: strides},
55 {name: 'padding', type: backend.binding.TF_ATTR_STRING, value: padding}, {
56 name: 'data_format',
57 type: backend.binding.TF_ATTR_STRING,
58 value: dataFormat
59 },
60 {name: 'use_cudnn_on_gpu', type: backend.binding.TF_ATTR_BOOL, value: true},
61 {name: 'dilations', type: backend.binding.TF_ATTR_INT, value: dilations}
62 ];
63 const inputSizes = tensor1d(convInfo.inShape, 'int32');
64 const res =
65 backend.executeSingleOutput(
66 Conv2DBackpropInput, opAttrs, [inputSizes, filter, dy]) as Tensor4D;
67 inputSizes.dispose();
68 return res;
69}

Callers 1

Calls 4

createTensorsTypeOpAttrFunction · 0.90
tensor1dFunction · 0.90
executeSingleOutputMethod · 0.80
disposeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…