15
15
TosaPipelineMI ,
16
16
)
17
17
18
- aten_op = "torch.ops.aten.le.Tensor"
19
- exir_op = "executorch_exir_dialects_edge__ops_aten_le_Tensor"
20
18
21
19
input_t = Tuple [torch .Tensor ]
22
20
23
21
24
- class GreaterEqual (torch .nn .Module ):
22
+ class LessEqual (torch .nn .Module ):
23
+ aten_op_tensor = "torch.ops.aten.le.Tensor"
24
+ aten_op_scalar = "torch.ops.aten.le.Scalar"
25
+ exir_op = "executorch_exir_dialects_edge__ops_aten_le_Tensor"
26
+
25
27
def __init__ (self , input , other ):
26
28
super ().__init__ ()
27
29
self .input_ = input
@@ -38,72 +40,151 @@ def get_inputs(self):
38
40
return (self .input_ , self .other_ )
39
41
40
42
41
- op_le_rank1_ones = GreaterEqual (
43
+ op_le_tensor_rank1_ones = LessEqual (
42
44
torch .ones (5 ),
43
45
torch .ones (5 ),
44
46
)
45
- op_le_rank2_rand = GreaterEqual (
47
+ op_le_tensor_rank2_rand = LessEqual (
46
48
torch .rand (4 , 5 ),
47
49
torch .rand (1 , 5 ),
48
50
)
49
- op_le_rank3_randn = GreaterEqual (
51
+ op_le_tensor_rank3_randn = LessEqual (
50
52
torch .randn (10 , 5 , 2 ),
51
53
torch .randn (10 , 5 , 2 ),
52
54
)
53
- op_le_rank4_randn = GreaterEqual (
55
+ op_le_tensor_rank4_randn = LessEqual (
54
56
torch .randn (3 , 2 , 2 , 2 ),
55
57
torch .randn (3 , 2 , 2 , 2 ),
56
58
)
57
59
58
- test_data_common = {
59
- "le_rank1_ones" : lambda : op_le_rank1_ones ,
60
- "le_rank2_rand" : lambda : op_le_rank2_rand ,
61
- "le_rank3_randn" : lambda : op_le_rank3_randn ,
62
- "le_rank4_randn" : lambda : op_le_rank4_randn ,
60
+ op_le_scalar_rank1_ones = LessEqual (torch .ones (5 ), 1.0 )
61
+ op_le_scalar_rank2_rand = LessEqual (torch .rand (4 , 5 ), 0.2 )
62
+ op_le_scalar_rank3_randn = LessEqual (torch .randn (10 , 5 , 2 ), - 0.1 )
63
+ op_le_scalar_rank4_randn = LessEqual (torch .randn (3 , 2 , 2 , 2 ), 0.3 )
64
+
65
+ test_data_tensor = {
66
+ "le_tensor_rank1_ones" : lambda : op_le_tensor_rank1_ones ,
67
+ "le_tensor_rank2_rand" : lambda : op_le_tensor_rank2_rand ,
68
+ "le_tensor_rank3_randn" : lambda : op_le_tensor_rank3_randn ,
69
+ "le_tensor_rank4_randn" : lambda : op_le_tensor_rank4_randn ,
70
+ }
71
+
72
+ test_data_scalar = {
73
+ "le_scalar_rank1_ones" : lambda : op_le_scalar_rank1_ones ,
74
+ "le_scalar_rank2_rand" : lambda : op_le_scalar_rank2_rand ,
75
+ "le_scalar_rank3_randn" : lambda : op_le_scalar_rank3_randn ,
76
+ "le_scalar_rank4_randn" : lambda : op_le_scalar_rank4_randn ,
63
77
}
64
78
65
79
66
- @common .parametrize ("test_module" , test_data_common )
80
+ @common .parametrize ("test_module" , test_data_tensor )
67
81
def test_le_tensor_tosa_MI (test_module ):
68
82
pipeline = TosaPipelineMI [input_t ](
69
- test_module (), test_module ().get_inputs (), aten_op , exir_op
83
+ test_module (),
84
+ test_module ().get_inputs (),
85
+ LessEqual .aten_op_tensor ,
86
+ LessEqual .exir_op ,
70
87
)
71
88
pipeline .run ()
72
89
73
90
74
- @common .parametrize ("test_module" , test_data_common )
91
+ @common .parametrize ("test_module" , test_data_scalar )
92
+ def test_le_scalar_tosa_MI (test_module ):
93
+ pipeline = TosaPipelineMI [input_t ](
94
+ test_module (),
95
+ test_module ().get_inputs (),
96
+ LessEqual .aten_op_scalar ,
97
+ LessEqual .exir_op ,
98
+ )
99
+ pipeline .run ()
100
+
101
+
102
+ @common .parametrize ("test_module" , test_data_tensor )
75
103
def test_le_tensor_tosa_BI (test_module ):
76
104
pipeline = TosaPipelineBI [input_t ](
77
- test_module (), test_module ().get_inputs (), aten_op , exir_op
105
+ test_module (),
106
+ test_module ().get_inputs (),
107
+ LessEqual .aten_op_tensor ,
108
+ LessEqual .exir_op ,
78
109
)
79
110
pipeline .run ()
80
111
81
112
82
- @common .parametrize ("test_module" , test_data_common )
113
+ @common .parametrize ("test_module" , test_data_scalar )
114
+ def test_le_scalar_tosa_BI (test_module ):
115
+ pipeline = TosaPipelineBI [input_t ](
116
+ test_module (),
117
+ test_module ().get_inputs (),
118
+ LessEqual .aten_op_tensor ,
119
+ LessEqual .exir_op ,
120
+ )
121
+ pipeline .run ()
122
+
123
+
124
+ @common .parametrize ("test_module" , test_data_tensor )
125
+ @common .XfailIfNoCorstone300
83
126
def test_le_tensor_u55_BI_not_delegated (test_module ):
84
127
# GREATER_EQUAL is not supported on U55. LE uses the GREATER_EQUAL Tosa operator.
85
128
pipeline = OpNotSupportedPipeline [input_t ](
86
129
test_module (),
87
130
test_module ().get_inputs (),
88
- {exir_op : 1 },
131
+ {LessEqual . exir_op : 1 },
89
132
quantize = True ,
90
133
u55_subset = True ,
91
134
)
92
135
pipeline .run ()
93
136
94
137
138
+ @common .parametrize ("test_module" , test_data_scalar )
139
+ @common .XfailIfNoCorstone300
140
+ def test_le_scalar_u55_BI_not_delegated (test_module ):
141
+ # GREATER_EQUAL is not supported on U55. LE uses the GREATER_EQUAL Tosa operator.
142
+ pipeline = OpNotSupportedPipeline [input_t ](
143
+ test_module (),
144
+ test_module ().get_inputs (),
145
+ {LessEqual .exir_op : 1 },
146
+ n_expected_delegates = 1 ,
147
+ quantize = True ,
148
+ u55_subset = True ,
149
+ )
150
+ pipeline .dump_operator_distribution ("export" )
151
+ pipeline .run ()
152
+
153
+
95
154
@common .parametrize (
96
155
"test_module" ,
97
- test_data_common ,
98
- xfails = {"le_rank4_randn" : "4D fails because boolean Tensors can't be subtracted" },
156
+ test_data_tensor ,
157
+ xfails = {
158
+ "le_tensor_rank4_randn" : "4D fails because boolean Tensors can't be subtracted"
159
+ },
99
160
)
100
161
@common .XfailIfNoCorstone320
101
162
def test_le_tensor_u85_BI (test_module ):
102
163
pipeline = EthosU85PipelineBI [input_t ](
103
164
test_module (),
104
165
test_module ().get_inputs (),
105
- aten_op ,
106
- exir_op ,
166
+ LessEqual .aten_op_tensor ,
167
+ LessEqual .exir_op ,
168
+ run_on_fvp = True ,
169
+ use_to_edge_transform_and_lower = True ,
170
+ )
171
+ pipeline .run ()
172
+
173
+
174
+ @common .parametrize (
175
+ "test_module" ,
176
+ test_data_scalar ,
177
+ xfails = {
178
+ "le_scalar_rank4_randn" : "4D fails because boolean Tensors can't be subtracted"
179
+ },
180
+ )
181
+ @common .XfailIfNoCorstone320
182
+ def test_le_scalar_u85_BI (test_module ):
183
+ pipeline = EthosU85PipelineBI [input_t ](
184
+ test_module (),
185
+ test_module ().get_inputs (),
186
+ LessEqual .aten_op_tensor ,
187
+ LessEqual .exir_op ,
107
188
run_on_fvp = True ,
108
189
use_to_edge_transform_and_lower = True ,
109
190
)
0 commit comments