Skip to content

Commit 48ba0a6

Browse files
authored
[Backend Tester] Skip inf and nan operator tests (#13990)
Skip tests that validate inf and nan edge cases. In hindsight, it's not reasonable to validate these on backends, with varying quantization and precision. I've marked them as skip to allow for manually running as they might have some conceptual value to backend authors.
1 parent e0dda90 commit 48ba0a6

23 files changed

+64
-0
lines changed

backends/test/suite/operators/test_abs.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
# pyre-unsafe
88

99

10+
import unittest
11+
1012
import torch
1113
from executorch.backends.test.suite.flow import TestFlow
1214

@@ -45,6 +47,7 @@ def test_abs_shapes(self, flow: TestFlow) -> None:
4547
# 3D tensor
4648
self._test_op(AbsModel(), (torch.randn(3, 4, 5),), flow)
4749

50+
@unittest.skip("NaN and Inf are not enforced for backends.")
4851
def test_abs_edge_cases(self, flow: TestFlow) -> None:
4952
# Test edge cases
5053

backends/test/suite/operators/test_amax.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
# pyre-unsafe
88

9+
import unittest
910
from typing import List, Optional, Tuple, Union
1011

1112
import torch
@@ -201,6 +202,7 @@ def test_amax_shapes(self, flow: TestFlow) -> None:
201202
flow,
202203
)
203204

205+
@unittest.skip("NaN and Inf are not enforced for backends.")
204206
def test_amax_edge_cases(self, flow: TestFlow) -> None:
205207
x = torch.tensor([[1.0, float("inf"), 3.0], [4.0, 5.0, float("inf")]])
206208
self._test_op(

backends/test/suite/operators/test_amin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
# pyre-unsafe
88

9+
import unittest
910
from typing import List, Optional, Tuple, Union
1011

1112
import torch
@@ -203,6 +204,7 @@ def test_amin_shapes(self, flow: TestFlow) -> None:
203204
flow,
204205
)
205206

207+
@unittest.skip("NaN and Inf are not enforced for backends.")
206208
def test_amin_edge_cases(self, flow: TestFlow) -> None:
207209
x = torch.tensor([[1.0, float("-inf"), 3.0], [4.0, 5.0, float("-inf")]])
208210
self._test_op(

backends/test/suite/operators/test_argmax.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
# pyre-unsafe
88

9+
import unittest
910
from typing import Optional
1011

1112
import torch
@@ -143,6 +144,7 @@ def test_argmax_shapes(self, flow: TestFlow) -> None:
143144
flow,
144145
)
145146

147+
@unittest.skip("NaN and Inf are not enforced for backends.")
146148
def test_argmax_edge_cases(self, flow: TestFlow) -> None:
147149
x = torch.tensor([[1.0, float("inf"), 3.0], [4.0, 5.0, float("inf")]])
148150
self._test_op(

backends/test/suite/operators/test_argmin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
# pyre-unsafe
88

9+
import unittest
910
from typing import Optional
1011

1112
import torch
@@ -143,6 +144,7 @@ def test_argmin_shapes(self, flow: TestFlow) -> None:
143144
flow,
144145
)
145146

147+
@unittest.skip("NaN and Inf are not enforced for backends.")
146148
def test_argmin_edge_cases(self, flow: TestFlow) -> None:
147149
x = torch.tensor([[1.0, float("-inf"), 3.0], [4.0, 5.0, float("-inf")]])
148150
self._test_op(

backends/test/suite/operators/test_ceil.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
# pyre-unsafe
88

99

10+
import unittest
11+
1012
import torch
1113
from executorch.backends.test.suite.flow import TestFlow
1214

@@ -45,6 +47,7 @@ def test_ceil_shapes(self, flow: TestFlow) -> None:
4547
# 3D tensor
4648
self._test_op(CeilModel(), (torch.randn(3, 4, 5),), flow)
4749

50+
@unittest.skip("NaN and Inf are not enforced for backends.")
4851
def test_ceil_edge_cases(self, flow: TestFlow) -> None:
4952
# Test edge cases
5053

backends/test/suite/operators/test_clamp.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
# pyre-unsafe
88

99

10+
import unittest
11+
1012
import torch
1113
from executorch.backends.test.suite.flow import TestFlow
1214

@@ -56,6 +58,7 @@ def test_clamp_shapes(self, flow: TestFlow) -> None:
5658
# 3D tensor
5759
self._test_op(model, (torch.randn(3, 4, 5),), flow)
5860

61+
@unittest.skip("NaN and Inf are not enforced for backends.")
5962
def test_clamp_edge_cases(self, flow: TestFlow) -> None:
6063
# Test edge cases
6164

backends/test/suite/operators/test_exp.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
# pyre-unsafe
88

99

10+
import unittest
11+
1012
import torch
1113
from executorch.backends.test.suite.flow import TestFlow
1214

@@ -46,6 +48,7 @@ def test_exp_shapes(self, flow: TestFlow) -> None:
4648
# 3D tensor
4749
self._test_op(ExpModel(), (torch.randn(3, 4, 5),), flow)
4850

51+
@unittest.skip("NaN and Inf are not enforced for backends.")
4952
def test_exp_edge_cases(self, flow: TestFlow) -> None:
5053
# Test edge cases
5154

backends/test/suite/operators/test_floor.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
# pyre-unsafe
88

99

10+
import unittest
11+
1012
import torch
1113
from executorch.backends.test.suite.flow import TestFlow
1214

@@ -42,6 +44,7 @@ def test_floor_shapes(self, flow: TestFlow) -> None:
4244
# 3D tensor
4345
self._test_op(FloorModel(), (torch.randn(3, 4, 5),), flow)
4446

47+
@unittest.skip("NaN and Inf are not enforced for backends.")
4548
def test_floor_edge_cases(self, flow: TestFlow) -> None:
4649
# Test edge cases
4750

backends/test/suite/operators/test_floor_divide.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
# pyre-unsafe
88

9+
import unittest
10+
911
import torch
1012
from executorch.backends.test.suite.flow import TestFlow
1113

@@ -178,6 +180,7 @@ def test_floor_divide_values(self, flow: TestFlow) -> None:
178180
y = torch.tensor([-2.0]).expand_as(x).clone()
179181
self._test_op(model, (x, y), flow, generate_random_test_inputs=False)
180182

183+
@unittest.skip("NaN and Inf are not enforced for backends.")
181184
def test_floor_divide_edge_cases(self, flow: TestFlow) -> None:
182185
# Test edge cases
183186
model = FloorDivideModel()

0 commit comments

Comments
 (0)