Skip to content
Permalink
Browse files Browse the repository at this point in the history
Validate arguments of FractionalMaxPoolGrad
PiperOrigin-RevId: 372274982
Change-Id: If46b0c442efa4eaef635ce6a476717060420122c
  • Loading branch information
mihaimaruseac authored and tensorflower-gardener committed May 6, 2021
1 parent 1690548 commit 32fdcbf
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tensorflow/core/kernels/fractional_max_pool_op.cc
Expand Up @@ -235,6 +235,20 @@ class FractionalMaxPoolGradOp : public OpKernel {

// Just to make it similar to FractionalMaxPoolOp.
constexpr int tensor_in_and_out_dims = 4;
OP_REQUIRES(
context, tensor_in.dims() == tensor_in_and_out_dims,
errors::InvalidArgument("orig_input should be a tensor of rank 4, got ",
tensor_in.DebugString()));
OP_REQUIRES(context, tensor_in.NumElements() > 0,
errors::InvalidArgument("orig_input must not be empty, got ",
tensor_in.DebugString()));
OP_REQUIRES(context, tensor_out.dims() == tensor_in_and_out_dims,
errors::InvalidArgument(
"orig_output should be a tensor of rank 4, got ",
tensor_out.DebugString()));
OP_REQUIRES(context, tensor_out.NumElements() > 0,
errors::InvalidArgument("orig_output must not be empty, got ",
tensor_out.DebugString()));
std::vector<int64> input_size(tensor_in_and_out_dims);
std::vector<int64> output_size(tensor_in_and_out_dims);
for (int i = 0; i < tensor_in_and_out_dims; ++i) {
Expand Down

0 comments on commit 32fdcbf

Please sign in to comment.