NMS padded op related - Add a note about potential OOM (depending on the system workload) if max_output_size is too large. Also add a test that checks that a proper error is thrown when max_output_size is larger than int32 max.

PiperOrigin-RevId: 349878281
Change-Id: I4a6ca94678912a3074b0b7071610ceac0e72263d
This commit is contained in:
Hye Soo Yang 2021-01-02 16:53:18 -08:00 committed by TensorFlower Gardener
parent 7172b537f1
commit 48aeb820a4
2 changed files with 14 additions and 1 deletions

View File

@ -5237,7 +5237,9 @@ def non_max_suppression_padded(boxes,
Dimensions except the last two are batch dimensions.
scores: a tensor of rank 1 or higher with a shape of [..., num_boxes].
max_output_size: a scalar integer `Tensor` representing the maximum number
of boxes to be selected by non max suppression.
of boxes to be selected by non max suppression. Note that setting this
value to a large number may result in OOM error depending on the system
workload.
iou_threshold: a float representing the threshold for deciding whether boxes
overlap too much with respect to IoU (intersection over union).
score_threshold: a float representing the threshold for box scores. Boxes

View File

@ -5211,6 +5211,17 @@ class NonMaxSuppressionPaddedTest(test_util.TensorFlowTestCase,
self.assertAllClose(selected_indices, [0, 2, 4])
self.assertEqual(self.evaluate(num_valid), 3)
def testInvalidDtype(self):
boxes_np = [[4.0, 6.0, 3.0, 6.0],
[2.0, 1.0, 5.0, 4.0],
[9.0, 0.0, 9.0, 9.0]]
scores = [5.0, 6.0, 5.0]
max_output_size = 2**31
with self.assertRaisesRegex(
(TypeError, ValueError), "type int64 that does not match type int32"):
boxes = constant_op.constant(boxes_np)
image_ops.non_max_suppression_padded(boxes, scores, max_output_size)
class NonMaxSuppressionWithOverlapsTest(test_util.TensorFlowTestCase):