@@ -31,17 +31,20 @@ def forward(self, x):
31
31
return z
32
32
33
33
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 ()
45
48
46
49
def test_fp16_div (self ):
47
50
# Adding 4 to move distribution away from 0, 4 Std Dev should be far enough
@@ -59,14 +62,17 @@ def test_fp32_div(self):
59
62
def test_fp32_div_single_input (self ):
60
63
# Adding 4 to move distribution away from 0, 4 Std Dev should be far enough
61
64
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