Skip to content

Commit 14b2d68

Browse files
author
Sachin Joglekar
authored
Merge pull request tensorflow#41140 from srjoglekar246/cherrypicks_5EM5L
r2.3 cherry-pick request: Shift padded NMS compat window forward to fix TFLite conversion
2 parents 6dc322f + bf61dd6 commit 14b2d68

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

tensorflow/compiler/tests/image_ops_test.py

+16
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from tensorflow.compiler.tests import xla_test
3131
from tensorflow.python.framework import dtypes
3232
from tensorflow.python.framework import ops
33+
from tensorflow.python.framework import test_util
3334
from tensorflow.python.ops import array_ops
3435
from tensorflow.python.ops import gen_image_ops
3536
from tensorflow.python.ops import image_ops
@@ -774,6 +775,7 @@ def testNonAlignCorners3x2To6x4Batch2(self):
774775

775776
class NonMaxSuppressionTest(xla_test.XLATestCase):
776777

778+
@test_util.disable_mlir_bridge("%1")
777779
def testNMS128From1024(self):
778780
num_boxes = 1024
779781
boxes_np = np.random.normal(50, 10, (num_boxes, 4)).astype("f4")
@@ -808,6 +810,7 @@ def testNMS128From1024(self):
808810

809811
self.assertEqual(indices_tf.size, max_output_size)
810812

813+
@test_util.disable_mlir_bridge("%1")
811814
def testNMS3From6Boxes(self):
812815
# Three boxes are selected based on IOU.
813816
boxes_data = [[0, 0, 1, 1], [0, 0.1, 1, 1.1], [0, -0.1, 1, 0.9],
@@ -849,6 +852,7 @@ def testNMS3From6Boxes(self):
849852
self.assertEqual(num_valid, 3)
850853
self.assertAllClose(indices_tf[:num_valid], [3, 0, 5])
851854

855+
@test_util.disable_mlir_bridge("%1")
852856
def testNMS3Then2WithScoreThresh(self):
853857
# Three boxes are selected based on IOU.
854858
# One is filtered out by score threshold.
@@ -891,6 +895,7 @@ def testNMS3Then2WithScoreThresh(self):
891895
self.assertEqual(num_valid, 2)
892896
self.assertAllClose(indices_tf[:num_valid], [3, 0])
893897

898+
@test_util.disable_mlir_bridge("%1")
894899
def testNMS3Then1WithScoreMaxThresh(self):
895900
# Three boxes are selected based on IOU.
896901
# One is filtered out by score threshold.
@@ -934,6 +939,7 @@ def testNMS3Then1WithScoreMaxThresh(self):
934939
self.assertEqual(num_valid, 1)
935940
self.assertAllClose(indices_tf[:num_valid], [3])
936941

942+
@test_util.disable_mlir_bridge("%1")
937943
def testSelectFromContinuousOverLap(self):
938944
# Tests that a suppressed box does not itself suppress other boxes.
939945

@@ -978,6 +984,7 @@ def testSelectFromContinuousOverLap(self):
978984

979985
class BatchedNonMaxSuppressionCorrectnessTest(xla_test.XLATestCase):
980986

987+
@test_util.disable_mlir_bridge("%1")
981988
def testBatchedNMSFrom6(self):
982989
boxes_data = [[[0, 0, 1, 1], [3, 3, 4, 4], [0, 0.4, 1, 1.4],
983990
[0, 0.6, 1, 1.6], [0, 0.8, 1, 1.8], [0, 2, 1, 2]],
@@ -1015,6 +1022,7 @@ def testBatchedNMSFrom6(self):
10151022
indices_output)
10161023
self.assertAllEqual([5, 4], num_valid_output)
10171024

1025+
@test_util.disable_mlir_bridge("%1")
10181026
def testBatchedNMSFrom6Max3(self):
10191027
boxes_data = [[[0, 0, 1, 1], [3, 3, 4, 4], [0, 0.4, 1, 1.4],
10201028
[0, 0.6, 1, 1.6], [0, 0.8, 1, 1.8], [0, 2, 1, 2]],
@@ -1048,6 +1056,7 @@ def testBatchedNMSFrom6Max3(self):
10481056
self.assertAllEqual([[0, 1, 2], [0, 1, 3]], indices_output)
10491057
self.assertAllEqual([3, 3], num_valid_output)
10501058

1059+
@test_util.disable_mlir_bridge("%1")
10511060
def testBatchedNMSSingleFrom6Max3(self):
10521061
boxes_data = [[0, 0, 1, 1], [3, 3, 4, 4], [0, 0.4, 1, 1.4],
10531062
[0, 0.6, 1, 1.6], [0, 0.8, 1, 1.8], [0, 2, 1, 2]]
@@ -1078,6 +1087,7 @@ def testBatchedNMSSingleFrom6Max3(self):
10781087
self.assertAllEqual([0, 1, 2], indices_output)
10791088
self.assertAllEqual(3, num_valid_output)
10801089

1090+
@test_util.disable_mlir_bridge("%1")
10811091
def testBatchedNMSSingleFrom6NoPad(self):
10821092
boxes_data = [[0, 0, 1, 1], [3, 3, 4, 4], [0, 0.4, 1, 1.4],
10831093
[0, 0.6, 1, 1.6], [0, 0.8, 1, 1.8], [0, 2, 1, 2]]
@@ -1107,6 +1117,7 @@ def testBatchedNMSSingleFrom6NoPad(self):
11071117
self.assertAllEqual([0, 1, 2, 4, 5], indices_output)
11081118
self.assertAllEqual(5, num_valid_output)
11091119

1120+
@test_util.disable_mlir_bridge("%1")
11101121
def testBatchedNMSBatchDimsFrom6Max3(self):
11111122
boxes_data = [[[[0, 0, 1, 1], [3, 3, 4, 4], [0, 0.4, 1, 1.4],
11121123
[0, 0.6, 1, 1.6], [0, 0.8, 1, 1.8], [0, 2, 1, 2]],
@@ -1140,6 +1151,7 @@ def testBatchedNMSBatchDimsFrom6Max3(self):
11401151
self.assertAllEqual([[[0, 1, 2], [0, 1, 3]]], indices_output)
11411152
self.assertAllEqual([[3, 3]], num_valid_output)
11421153

1154+
@test_util.disable_mlir_bridge("%1")
11431155
def testBatchedNMSScoreThresholdFrom6Max3(self):
11441156
boxes_data = [[[0, 0, 1, 1], [3, 3, 4, 4], [0, 0.4, 1, 1.4],
11451157
[0, 0.6, 1, 1.6], [0, 0.8, 1, 1.8], [0, 2, 1, 2]],
@@ -1175,6 +1187,7 @@ def testBatchedNMSScoreThresholdFrom6Max3(self):
11751187
self.assertAllEqual([3, 2], num_valid_output)
11761188
self.assertAllEqual([[0, 1, 2], [0, 1, invalid_index]], indices_output)
11771189

1190+
@test_util.disable_mlir_bridge("%1")
11781191
def testBatchedNMSUnsortedInputFrom6(self):
11791192
boxes_data = [[[0, 2, 1, 2], [3, 3, 4, 4], [0, 0, 1, 1],
11801193
[0, 0.4, 1, 1.4], [0, 0.6, 1, 1.6], [0, 0.8, 1, 1.8]],
@@ -1211,6 +1224,7 @@ def testBatchedNMSUnsortedInputFrom6(self):
12111224
indices_output)
12121225
self.assertAllEqual([5, 4], num_valid_output)
12131226

1227+
@test_util.disable_mlir_bridge("%1")
12141228
def testBatchedNMSNoncanonicalizedInputFrom6(self):
12151229
boxes_data = [[[1, 0, 0, 1], [4, 3, 3, 4], [1, 0.4, 0, 1.4],
12161230
[1, 0.6, 0, 1.6], [1, 0.8, 0, 1.8], [1, 2, 0, 2]],
@@ -1248,6 +1262,7 @@ def testBatchedNMSNoncanonicalizedInputFrom6(self):
12481262
indices_output)
12491263
self.assertAllEqual([5, 4], num_valid_output)
12501264

1265+
@test_util.disable_mlir_bridge("%1")
12511266
def testBatchedNMSScoreThresholdCanInputsFrom6Max3(self):
12521267
boxes_data = [[[0, 0, 1, 1], [3, 3, 4, 4], [0, 0.4, 1, 1.4],
12531268
[0, 0.6, 1, 1.6], [0, 0.8, 1, 1.8], [0, 2, 1, 2]],
@@ -1283,6 +1298,7 @@ def testBatchedNMSScoreThresholdCanInputsFrom6Max3(self):
12831298
self.assertAllEqual([3, 2], num_valid_output)
12841299
self.assertAllEqual([[0, 1, 2], [0, 1, invalid_index]], indices_output)
12851300

1301+
@test_util.disable_mlir_bridge("%1")
12861302
def testBatchedNMSFrom6DynamicInput(self):
12871303
boxes_data = [[[0, 0, 1, 1], [3, 3, 4, 4], [0, 0.4, 1, 1.4],
12881304
[0, 0.6, 1, 1.6], [0, 0.8, 1, 1.8], [0, 2, 1, 2]],

tensorflow/python/ops/image_ops_impl.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4579,11 +4579,11 @@ def non_max_suppression_padded(boxes,
45794579
Raises:
45804580
ValueError: When set pad_to_max_output_size to False for batched input.
45814581
"""
4582-
# if no new arguments are used and no later than 2020/4/20, use the old
4583-
# version to give us time to fix TFLite conversion
4582+
# if no new arguments are used and no later than 2020/6/23, use the old
4583+
# version to give us time to fix TFLite conversion after the TF 2.3 release.
45844584
if (not sorted_input) and \
45854585
(not canonicalized_coordinates) and \
4586-
tile_size == 512 and not compat.forward_compatible(2020, 4, 20):
4586+
tile_size == 512 and not compat.forward_compatible(2020, 6, 23):
45874587
return non_max_suppression_padded_v1(
45884588
boxes, scores, max_output_size, iou_threshold, score_threshold,
45894589
pad_to_max_output_size, name)

0 commit comments

Comments
 (0)