Skip to content

Commit

Permalink
Add epsilon offset to avoid depending on floating-point behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunderberg committed Feb 21, 2023
1 parent 70aaff7 commit 0166f49
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tests/python/relay/test_op_level5.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 0166f49

Please sign in to comment.