@@ -31,17 +31,20 @@ def forward(self, x):
3131 return z
3232
3333 def _test_div (self , inputs ):
34- (
35- Tester (self .Div (), inputs )
36- .export ()
37- .check_count ({"torch.ops.aten.div.Tensor" : 1 })
38- .to_edge_transform_and_lower ()
39- .check_count ({"torch.ops.higher_order.executorch_call_delegate" : 1 })
40- .check_not (["executorch_exir_dialects_edge__ops_aten_div_Tensor" ])
41- .to_executorch ()
42- .serialize ()
43- .run_method_and_compare_outputs ()
44- )
34+ for legacy_mode in (True , False ):
35+ tester = Tester (self .Div (), inputs )
36+ tester .export ()
37+ tester .check_count ({"torch.ops.aten.div.Tensor" : 1 })
38+ if legacy_mode :
39+ tester .to_edge ()
40+ tester .partition ()
41+ else :
42+ tester .to_edge_transform_and_lower ()
43+ tester .check_count ({"torch.ops.higher_order.executorch_call_delegate" : 1 })
44+ tester .check_not (["executorch_exir_dialects_edge__ops_aten_div_Tensor" ])
45+ tester .to_executorch ()
46+ tester .serialize ()
47+ tester .run_method_and_compare_outputs ()
4548
4649 def test_fp16_div (self ):
4750 # Adding 4 to move distribution away from 0, 4 Std Dev should be far enough
@@ -59,14 +62,17 @@ def test_fp32_div(self):
5962 def test_fp32_div_single_input (self ):
6063 # Adding 4 to move distribution away from 0, 4 Std Dev should be far enough
6164 inputs = (torch .randn (1 ) + 4 ,)
62- (
63- Tester (self .DivSingleInput (), inputs )
64- .export ()
65- .check_count ({"torch.ops.aten.div.Tensor" : 1 })
66- .to_edge_transform_and_lower ()
67- .check_count ({"torch.ops.higher_order.executorch_call_delegate" : 1 })
68- .check_not (["executorch_exir_dialects_edge__ops_aten_div_Tensor" ])
69- .to_executorch ()
70- .serialize ()
71- .run_method_and_compare_outputs ()
72- )
65+ for legacy_mode in (True , False ):
66+ tester = Tester (self .DivSingleInput (), inputs )
67+ tester .export ()
68+ tester .check_count ({"torch.ops.aten.div.Tensor" : 1 })
69+ if legacy_mode :
70+ tester .to_edge ()
71+ tester .partition ()
72+ else :
73+ tester .to_edge_transform_and_lower ()
74+ tester .check_count ({"torch.ops.higher_order.executorch_call_delegate" : 1 })
75+ tester .check_not (["executorch_exir_dialects_edge__ops_aten_div_Tensor" ])
76+ tester .to_executorch ()
77+ tester .serialize ()
78+ tester .run_method_and_compare_outputs ()
0 commit comments