Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate arguments of FractionalMaxPoolGrad #49680

Merged
merged 1 commit into from
May 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions tensorflow/core/kernels/fractional_max_pool_op.cc
Original file line number Diff line number Diff line change
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