Skip to content

Commit 54899fe

Browse files
authored
Adding tests old lowering flow for op_abs.py
Differential Revision: D65542758 Pull Request resolved: #6696
1 parent 041b7d6 commit 54899fe

File tree

1 file changed

+35
-6
lines changed
  • backends/xnnpack/test/ops

1 file changed

+35
-6
lines changed

backends/xnnpack/test/ops/abs.py

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,20 @@ def forward(self, x):
1919
z = torch.abs(x)
2020
return z
2121

22-
def _test_abs(self, inputs):
23-
(
22+
def _test_abs(self, inputs, legacy_mode: bool = False):
23+
tester = (
2424
Tester(self.Abs(), inputs)
2525
.export()
2626
.check_count({"torch.ops.aten.abs.default": 1})
27-
.to_edge_transform_and_lower()
28-
.check_count({"torch.ops.higher_order.executorch_call_delegate": 1})
27+
)
28+
29+
if legacy_mode:
30+
tester = tester.to_edge().partition()
31+
else:
32+
tester = tester.to_edge_transform_and_lower()
33+
34+
(
35+
tester.check_count({"torch.ops.higher_order.executorch_call_delegate": 1})
2936
.check_not(["executorch_exir_dialects_edge__ops_aten_abs_default"])
3037
.to_executorch()
3138
.serialize()
@@ -41,7 +48,18 @@ def test_fp16_abs(self):
4148
],
4249
).to(torch.float16),
4350
)
44-
self._test_abs(inputs)
51+
self._test_abs(inputs, legacy_mode=False)
52+
53+
def test_fp16_abs_legacy_mode(self):
54+
inputs = (
55+
torch.Tensor(
56+
[
57+
[0.0, 0.1, 0.5, 0.499],
58+
[-0.6, -0.4, 100.1, -1000.1],
59+
],
60+
).to(torch.float16),
61+
)
62+
self._test_abs(inputs, legacy_mode=True)
4563

4664
def test_fp32_abs(self):
4765
inputs = (
@@ -52,4 +70,15 @@ def test_fp32_abs(self):
5270
],
5371
),
5472
)
55-
self._test_abs(inputs)
73+
self._test_abs(inputs, legacy_mode=False)
74+
75+
def test_fp32_abs_legacy_mode(self):
76+
inputs = (
77+
torch.Tensor(
78+
[
79+
[0.0, 0.1, 0.5, 0.499],
80+
[-0.6, -0.4, 100.1, -1000.1],
81+
],
82+
),
83+
)
84+
self._test_abs(inputs, legacy_mode=True)

0 commit comments

Comments
 (0)