Skip to content
Permalink
Browse files Browse the repository at this point in the history
Fix issues in Conv2DBackpropFilter.
PiperOrigin-RevId: 369772454
Change-Id: I49b465f2ae2ce91def61b56cea8000197d5177d8
  • Loading branch information
mihaimaruseac authored and tensorflower-gardener committed Apr 22, 2021
1 parent 1b0296c commit c570e2e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tensorflow/core/kernels/conv_grad_filter_ops.cc
Expand Up @@ -495,6 +495,14 @@ class Conv2DCustomBackpropFilterOp : public OpKernel {
const int filter_total_size = dims.spatial_dims[0].filter_size *
dims.spatial_dims[1].filter_size *
dims.in_depth;
OP_REQUIRES(
context,
filter_total_size * dims.out_depth == filter_backprop->NumElements(),
errors::InvalidArgument(
"filter_size does not have enough elements, requested ",
filter_total_size * dims.out_depth, ", got ",
filter_backprop->NumElements()));

// The output image size is the spatial size of the output.
const int output_image_size =
dims.spatial_dims[0].output_size * dims.spatial_dims[1].output_size;
Expand All @@ -518,6 +526,11 @@ class Conv2DCustomBackpropFilterOp : public OpKernel {

const size_t work_unit_size = size_A + size_B + size_C;

OP_REQUIRES(
context, work_unit_size != 0,
errors::InvalidArgument(
"Work size for convolution would be 0, which is not acceptable"));

const size_t shard_size =
(target_working_set_size + work_unit_size - 1) / work_unit_size;

Expand Down

0 comments on commit c570e2e

Please sign in to comment.