Skip to content

Commit

Permalink
Merge pull request #51717 from yongtang:46890-tf.image.pad_to_boundin…
Browse files Browse the repository at this point in the history
…g_box

PiperOrigin-RevId: 398351034
Change-Id: Ia11abe3ab57683ca2efea786fd095338d0c8c3b7
  • Loading branch information
tensorflower-gardener committed Sep 22, 2021
2 parents 289a8c8 + 8a0c82f commit d81b135
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tensorflow/core/kernels/pad_op.cc
Expand Up @@ -85,7 +85,8 @@ class PadOp : public OpKernel {
errors::InvalidArgument("Paddings must be non-negative: ",
before_d, " ", after_d));
const int64_t size_d = in0.dim_size(d);
output_shape.AddDim(before_d + size_d + after_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 @@ -2293,6 +2293,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

0 comments on commit d81b135

Please sign in to comment.