Remove redundant TF legacy + align corners mode in Resize Bilinear
This mode was never used, and doesn't have any practical application
PiperOrigin-RevId: 312841563
diff --git a/src/indirection.c b/src/indirection.c
index d187c5a..d6c22c1 100644
--- a/src/indirection.c
+++ b/src/indirection.c
@@ -358,7 +358,7 @@
const uint32_t input_y_max = (uint32_t) input_height - 1;
const uint32_t input_x_max = (uint32_t) input_width - 1;
- if (tensorflow_legacy) {
+ if (tensorflow_legacy || align_corners) {
for (size_t output_y = 0; output_y < output_height; output_y++) {
const float input_y = (float) (int32_t) output_y * height_scale;
assert(input_y >= 0.0f);
diff --git a/test/resize-bilinear-nhwc.cc b/test/resize-bilinear-nhwc.cc
index 2f34e8e..7bb3447 100644
--- a/test/resize-bilinear-nhwc.cc
+++ b/test/resize-bilinear-nhwc.cc
@@ -485,175 +485,3 @@
}
}
}
-
-TEST(RESIZE_BILINEAR_NHWC_F32, tf_mode_aligned_corners_upscale_y) {
- for (size_t input_height = 1; input_height <= 3; input_height++) {
- for (size_t output_height = input_height + 1; output_height < 15; output_height *= 3) {
- ResizeBilinearOperatorTester()
- .tf_legacy_mode(true)
- .align_corners(true)
- .input_size(input_height, 1)
- .output_size(output_height, 1)
- .channels(17)
- .iterations(3)
- .TestF32();
- }
- }
-}
-
-TEST(RESIZE_BILINEAR_NHWC_F32, tf_mode_aligned_corners_upscale_x) {
- for (size_t input_width = 1; input_width <= 3; input_width++) {
- for (size_t output_width = input_width + 1; output_width < 15; output_width *= 3) {
- ResizeBilinearOperatorTester()
- .tf_legacy_mode(true)
- .align_corners(true)
- .input_size(1, input_width)
- .output_size(1, output_width)
- .channels(17)
- .iterations(3)
- .TestF32();
- }
- }
-}
-
-TEST(RESIZE_BILINEAR_NHWC_F32, tf_mode_aligned_corners_upscale) {
- for (size_t output_height = 3; output_height <= 5; output_height += 2) {
- for (size_t output_width = 3; output_width <= 5; output_width += 2) {
- ResizeBilinearOperatorTester()
- .tf_legacy_mode(true)
- .align_corners(true)
- .input_size(2, 2)
- .output_size(output_height, output_width)
- .channels(17)
- .iterations(3)
- .TestF32();
- }
- }
-}
-
-TEST(RESIZE_BILINEAR_NHWC_F32, tf_mode_aligned_corners_downscale_y) {
- for (size_t output_height = 2; output_height <= 3; output_height++) {
- for (size_t input_height = output_height + 1; input_height < 15; input_height *= 3) {
- ResizeBilinearOperatorTester()
- .tf_legacy_mode(true)
- .input_size(input_height, 1)
- .output_size(output_height, 1)
- .channels(17)
- .iterations(3)
- .TestF32();
- }
- }
-}
-
-TEST(RESIZE_BILINEAR_NHWC_F32, tf_mode_aligned_corners_downscale_x) {
- for (size_t output_width = 2; output_width <= 3; output_width++) {
- for (size_t input_width = output_width + 1; input_width < 15; input_width *= 3) {
- ResizeBilinearOperatorTester()
- .tf_legacy_mode(true)
- .input_size(1, input_width)
- .output_size(1, output_width)
- .channels(17)
- .iterations(3)
- .TestF32();
- }
- }
-}
-
-TEST(RESIZE_BILINEAR_NHWC_F32, tf_mode_aligned_corners_downscale) {
- for (size_t input_height = 3; input_height <= 5; input_height += 2) {
- for (size_t input_width = 3; input_width <= 5; input_width += 2) {
- ResizeBilinearOperatorTester()
- .tf_legacy_mode(true)
- .input_size(input_height, input_width)
- .output_size(2, 2)
- .channels(17)
- .iterations(3)
- .TestF32();
- }
- }
-}
-
-TEST(RESIZE_BILINEAR_NHWC_F32, tf_mode_aligned_corners_identical_size) {
- for (size_t height = 1; height < 10; height *= 3) {
- for (size_t width = 1; width < 10; width *= 3) {
- ResizeBilinearOperatorTester()
- .tf_legacy_mode(true)
- .align_corners(true)
- .input_size(height, width)
- .output_size(height, width)
- .channels(17)
- .iterations(3)
- .TestF32();
- }
- }
-}
-
-TEST(RESIZE_BILINEAR_NHWC_F32, tf_mode_aligned_corners_varying_channels) {
- for (size_t input_size = 2; input_size <= 6; input_size += 2) {
- for (size_t output_size = 2; output_size <= 6; output_size += 2) {
- for (size_t channels = 15; channels <= 19; channels++) {
- ResizeBilinearOperatorTester()
- .tf_legacy_mode(true)
- .align_corners(true)
- .input_size(output_size, output_size)
- .output_size(output_size, output_size)
- .channels(channels)
- .iterations(3)
- .TestF32();
- }
- }
- }
-}
-
-TEST(RESIZE_BILINEAR_NHWC_F32, tf_mode_aligned_corners_with_input_stride) {
- for (size_t input_size = 2; input_size <= 6; input_size += 2) {
- for (size_t output_size = 2; output_size <= 6; output_size += 2) {
- for (size_t channels = 15; channels <= 19; channels++) {
- ResizeBilinearOperatorTester()
- .tf_legacy_mode(true)
- .align_corners(true)
- .input_size(output_size, output_size)
- .output_size(output_size, output_size)
- .channels(channels)
- .input_pixel_stride(23)
- .iterations(3)
- .TestF32();
- }
- }
- }
-}
-
-TEST(RESIZE_BILINEAR_NHWC_F32, tf_mode_aligned_corners_with_output_stride) {
- for (size_t input_size = 2; input_size <= 6; input_size += 2) {
- for (size_t output_size = 2; output_size <= 6; output_size += 2) {
- for (size_t channels = 15; channels <= 19; channels++) {
- ResizeBilinearOperatorTester()
- .tf_legacy_mode(true)
- .align_corners(true)
- .input_size(output_size, output_size)
- .output_size(output_size, output_size)
- .channels(channels)
- .output_pixel_stride(29)
- .iterations(3)
- .TestF32();
- }
- }
- }
-}
-
-TEST(RESIZE_BILINEAR_NHWC_F32, tf_mode_aligned_corners_varying_batch_size) {
- for (size_t input_size = 2; input_size <= 6; input_size += 2) {
- for (size_t output_size = 2; output_size <= 6; output_size += 2) {
- for (size_t batch_size = 2; batch_size <= 3; batch_size++) {
- ResizeBilinearOperatorTester()
- .tf_legacy_mode(true)
- .align_corners(true)
- .batch_size(batch_size)
- .input_size(output_size, output_size)
- .output_size(output_size, output_size)
- .iterations(3)
- .TestF32();
- }
- }
- }
-}
diff --git a/test/resize-bilinear-operator-tester.h b/test/resize-bilinear-operator-tester.h
index 5aac1c4..a1d2b7c 100644
--- a/test/resize-bilinear-operator-tester.h
+++ b/test/resize-bilinear-operator-tester.h
@@ -221,6 +221,10 @@
}
void TestF32() const {
+ if (align_corners()) {
+ ASSERT_FALSE(tf_legacy_mode());
+ }
+
std::random_device random_device;
auto rng = std::mt19937(random_device());
auto f32rng = std::bind(std::uniform_real_distribution<float>(), rng);
@@ -233,7 +237,7 @@
std::fill(output.begin(), output.end(), std::nanf(""));
// Compute reference results.
- const float offset = tf_legacy_mode() ? 0.0f : 0.5f;
+ const float offset = (tf_legacy_mode() || align_corners()) ? 0.0f : 0.5f;
for (size_t batch_index = 0; batch_index < batch_size(); batch_index++) {
for (size_t output_y = 0; output_y < output_height(); output_y++) {
const float input_y = (float(output_y) + offset) * height_scale() - offset;