aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/kernels/depthwise_conv_grad_op.cc
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2016-06-20 10:40:18 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-06-20 12:00:45 -0700
commit84f4e8f39e6480294bf27a481ebf17b9ab245a14 (patch)
tree58e1301c7b33d325902a3620c4c2cba786012091 /tensorflow/core/kernels/depthwise_conv_grad_op.cc
parent6a830d140fa034289faef0313caf32ccc05bf9c8 (diff)
Refactor Get2dOutputSizes/Get2dOutputSizesVerbose/Get3dOutputSizes to share a common 1-dimensional GetWindowedOutputSize/GetWindowedOutputSizeVerbose.
The output sizes and padding of each dimension of a windowed operation (such as convolution or pooling) are orthogonal and can be computed independently. We can simplify the code by providing a 1D size computation and calling it for each dimension. Also remove special cases for 1x1 spatial convolutions in dimension calculations; they add complexity and are a case that the general code handles correctly. In general, 2D convolutions and their gradients have a lot of shape calculation code that is duplicated for each spatial dimension. This CL is a step in the direction of treating spatial dimensions the same so we can share more code. Change: 125360639
Diffstat (limited to 'tensorflow/core/kernels/depthwise_conv_grad_op.cc')
-rw-r--r--tensorflow/core/kernels/depthwise_conv_grad_op.cc17
1 files changed, 7 insertions, 10 deletions
diff --git a/tensorflow/core/kernels/depthwise_conv_grad_op.cc b/tensorflow/core/kernels/depthwise_conv_grad_op.cc
index 161c88d814..f9076cb903 100644
--- a/tensorflow/core/kernels/depthwise_conv_grad_op.cc
+++ b/tensorflow/core/kernels/depthwise_conv_grad_op.cc
@@ -79,16 +79,13 @@ typedef Eigen::GpuDevice GPUDevice;
errors::InvalidArgument( \
label, ": depth_multiplier * in_depth not equal to out_depth")); \
const auto stride = strides_[1]; \
- int out_rows = 0, out_cols = 0, pad_rows = 0, pad_cols = 0; \
- if (filter_cols == filter_rows && filter_rows == 1 && stride == 1) { \
- out_rows = input_rows; \
- out_cols = input_cols; \
- } else { \
- OP_REQUIRES_OK( \
- context, Get2dOutputSize(input_rows, input_cols, filter_rows, \
- filter_cols, stride, stride, padding_, \
- &out_rows, &out_cols, &pad_rows, &pad_cols)); \
- } \
+ int64 out_rows = 0, out_cols = 0, pad_rows = 0, pad_cols = 0; \
+ OP_REQUIRES_OK(context, \
+ GetWindowedOutputSize(input_rows, filter_rows, stride, \
+ padding_, &out_rows, &pad_rows)); \
+ OP_REQUIRES_OK(context, \
+ GetWindowedOutputSize(input_cols, filter_cols, stride, \
+ padding_, &out_cols, &pad_cols)); \
OP_REQUIRES( \
context, output_rows == out_rows, \
errors::InvalidArgument( \