@@ -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