Skip to content

Commit 6ad7adb

Browse files
ru-m8facebook-github-bot
authored andcommitted
Adding tests old lowering flow for op_abs.py
Summary: Added tests with the legacy mode. Differential Revision: D65542758
1 parent 17ad8d3 commit 6ad7adb

File tree

1 file changed

+36
-0
lines changed
  • backends/xnnpack/test/ops

1 file changed

+36
-0
lines changed

backends/xnnpack/test/ops/abs.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ def _test_abs(self, inputs):
3232
.run_method_and_compare_outputs()
3333
)
3434

35+
def _test_abs_legacy_mode(self, inputs):
36+
(
37+
Tester(self.Abs(), inputs)
38+
.export()
39+
.check_count({"torch.ops.aten.abs.default": 1})
40+
.to_edge()
41+
.partition()
42+
.check_count({"torch.ops.higher_order.executorch_call_delegate": 1})
43+
.check_not(["executorch_exir_dialects_edge__ops_aten_abs_default"])
44+
.to_executorch()
45+
.serialize()
46+
.run_method_and_compare_outputs()
47+
)
48+
3549
def test_fp16_abs(self):
3650
inputs = (
3751
torch.Tensor(
@@ -43,6 +57,17 @@ def test_fp16_abs(self):
4357
)
4458
self._test_abs(inputs)
4559

60+
def test_fp16_abs_legacy_mode(self):
61+
inputs = (
62+
torch.Tensor(
63+
[
64+
[0.0, 0.1, 0.5, 0.499],
65+
[-0.6, -0.4, 100.1, -1000.1],
66+
],
67+
).to(torch.float16),
68+
)
69+
self._test_abs_legacy_mode(inputs)
70+
4671
def test_fp32_abs(self):
4772
inputs = (
4873
torch.Tensor(
@@ -53,3 +78,14 @@ def test_fp32_abs(self):
5378
),
5479
)
5580
self._test_abs(inputs)
81+
82+
def test_fp32_abs_legacy_mode(self):
83+
inputs = (
84+
torch.Tensor(
85+
[
86+
[0.0, 0.1, 0.5, 0.499],
87+
[-0.6, -0.4, 100.1, -1000.1],
88+
],
89+
),
90+
)
91+
self._test_abs_legacy_mode(inputs)

0 commit comments

Comments
 (0)