(
dy: TensorInfo, filter: TensorInfo, convInfo: backend_util.Conv2DInfo,
backend: NodeJSKernelBackend)
| 38 | }; |
| 39 | |
| 40 | function 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 | } |
no test coverage detected
searching dependent graphs…