From 0166f49c6b603604d8fbb07018ed164c1b5703b5 Mon Sep 17 00:00:00 2001 From: Eric Lunderberg Date: Tue, 21 Feb 2023 09:30:44 -0600 Subject: [PATCH] Add epsilon offset to avoid depending on floating-point behavior --- tests/python/relay/test_op_level5.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/python/relay/test_op_level5.py b/tests/python/relay/test_op_level5.py index 136668dbde533..47f90647500ba 100644 --- a/tests/python/relay/test_op_level5.py +++ b/tests/python/relay/test_op_level5.py @@ -235,17 +235,23 @@ def test_crop_and_resize(self, target, dev, executor_kind, layout, interpolate_m pytest.xfail("Known failing case for these parameters") extrapolation_value = 0.0 + eps = 1e-4 if layout == "NHWC": img_shape = (10, 224, 224, 3) - boxes = np.array([[0.125, 0.25, 0.8125, 0.71875], [0.25, 0, 1, 0.625]]).astype( - "float32" - ) + boxes = np.array( + [ + [0.125 + eps, 0.25 + eps, 0.8125 - eps, 0.71875 - eps], + [0.25 + eps, 0 + eps, 1 - eps, 0.625 - eps], + ] + ).astype("float32") box_indices = np.array([1, 0]).astype("int32") crop_size = np.array([20, 30]).astype("int32") elif layout == "NCHW": img_shape = (5, 3, 255, 255) - boxes = np.array([[0, 0, 1, 1], [0.25, 0.125, 1, 0.9375]]).astype("float32") + boxes = np.array( + [[0, 0, 1, 1], [0.25 + eps, 0.125 + eps, 1 - eps, 0.9375 - eps]] + ).astype("float32") box_indices = np.array([0, 1]).astype("int32") crop_size = np.array([30, 30]).astype("int32") else: