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

Merge pull request #51717 from yongtang:46890-tf.image.pad_to_boundin… #52785

Merged
merged 1 commit into from Oct 28, 2021
Merged
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions tensorflow/core/kernels/pad_op.cc
Expand Up @@ -84,8 +84,10 @@ class PadOp : public OpKernel {
OP_REQUIRES(context, before_d >= 0 && after_d >= 0,
errors::InvalidArgument("Paddings must be non-negative: ",
before_d, " ", after_d));
const int64 size_d = in0.dim_size(d);
output_shape.AddDim(before_d + size_d + after_d);
const int64_t size_d = in0.dim_size(d);
OP_REQUIRES_OK(
context, output_shape.AddDimWithStatus(before_d + size_d + after_d));

}

// If there is no padding to be done, forward the input to output.
Expand Down
15 changes: 15 additions & 0 deletions tensorflow/python/ops/image_ops_test.py
Expand Up @@ -2254,6 +2254,21 @@ def testNameScope(self):
y = image_ops.pad_to_bounding_box(image, 0, 0, 55, 66)
self.assertTrue(y.op.name.startswith("pad_to_bounding_box"))

def testInvalidInput(self):
# Test case for GitHub issue 46890.
if test_util.is_xla_enabled():
# TODO(b/200850176): test fails with XLA.
return
with self.session():
with self.assertRaises(errors_impl.InternalError):
v = image_ops.pad_to_bounding_box(
image=np.ones((1, 1, 1)),
target_height=5191549470,
target_width=5191549470,
offset_height=1,
offset_width=1)
self.evaluate(v)


class SelectDistortedCropBoxTest(test_util.TensorFlowTestCase):

Expand Down