Skip to content

Commit 02037b7

Browse files
authored
Merge branch 'main' into refactor-bitwise-logical-tests
2 parents 63c3a04 + 043c7a0 commit 02037b7

File tree

4 files changed

+86
-45
lines changed

4 files changed

+86
-45
lines changed

backends/arm/operator_support/tosa_supported_operators.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,26 +208,41 @@ def is_node_supported(
208208
class EthosU55NotSupported(OperatorSupportBase):
209209
"""
210210
Certain operators are not supported on U55. These are listed in `unsupported_ops`.
211+
The comment mentions the unsupported TOSA operator that the aten operator maps to where it is not obvious.
212+
For unimplemented operators, this is the anticipated mapping, and it might be incorrect.
211213
"""
212214

213215
unsupported_ops = [
214-
exir_ops.edge.aten.any.default,
215-
exir_ops.edge.aten.any.dim,
216-
exir_ops.edge.aten.any.dims,
216+
exir_ops.edge.aten.any.default, # REDUCE_ANY
217+
exir_ops.edge.aten.any.dim, # REDUCE_ANY
218+
exir_ops.edge.aten.any.dims, # REDUCE_ANY
217219
exir_ops.edge.aten.bitwise_and.Tensor,
218220
exir_ops.edge.aten.bitwise_or.Tensor,
219221
exir_ops.edge.aten.bitwise_xor.Tensor,
222+
exir_ops.edge.aten.bitwise_not,
220223
exir_ops.edge.aten.logical_and.default,
221224
exir_ops.edge.aten.logical_or.default,
222225
exir_ops.edge.aten.logical_xor.default,
223226
exir_ops.edge.aten.logical_not.default,
224-
exir_ops.edge.aten.amax.default,
225-
exir_ops.edge.aten.amin.default,
227+
exir_ops.edge.aten.amax.default, # REDUCE_MAX
228+
exir_ops.edge.aten.amin.default, # REDUCE_MIN
226229
exir_ops.edge.aten.eq.Tensor,
227230
exir_ops.edge.aten.ge.Tensor,
228231
exir_ops.edge.aten.gt.Tensor,
229232
exir_ops.edge.aten.le.Tensor,
230233
exir_ops.edge.aten.lt.Tensor,
234+
exir_ops.edge.aten.flip.default, # REVERSE
235+
exir_ops.edge.aten.grid_sampler_2d, # GATHER
236+
exir_ops.edge.aten.scatter.src,
237+
exir_ops.edge.aten.scatter.value,
238+
exir_ops.edge.aten.select_scatter.default,
239+
exir_ops.edge.aten.scatter_reduce.two,
240+
exir_ops.edge.aten.scatter_add.default,
241+
exir_ops.edge.aten.upsample_nearest2d.vec, # RESIZE
242+
exir_ops.edge.aten.upsample_bilinear2d.vec, # RESIZE
243+
exir_ops.edge.aten.reflection_pad1d.default, # REVERSE
244+
exir_ops.edge.aten.reflection_pad2d.default, # REVERSE
245+
exir_ops.edge.aten.reflection_pad3d.default, # REVERSE
231246
]
232247

233248
def __init__(self, reporter: WhyNoPartitionReporter):

backends/arm/test/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ def parametrize(
231231
arg_name: str,
232232
test_data: dict[str, Any],
233233
xfails: dict[str, xfail_type] | None = None,
234+
strict: bool = True,
234235
):
235236
"""
236237
Custom version of pytest.mark.parametrize with some syntatic sugar and added xfail functionality
@@ -261,7 +262,9 @@ def decorator_func(func):
261262
pytest_param = pytest.param(
262263
test_parameters,
263264
id=id,
264-
marks=pytest.mark.xfail(reason=reason, raises=raises, strict=True),
265+
marks=pytest.mark.xfail(
266+
reason=reason, raises=raises, strict=strict
267+
),
265268
)
266269
else:
267270
pytest_param = pytest.param(test_parameters, id=id)

backends/arm/test/ops/test_sigmoid_16bit.py

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# This source code is licensed under the BSD-style license found in the
44
# LICENSE file in the root directory of this source tree.
55

6+
import pytest
7+
68
import torch
79
from executorch.backends.arm.quantizer.arm_quantizer import (
810
get_symmetric_quantization_config,
@@ -48,12 +50,12 @@ def get_16bit_sigmoid_quantizer(tosa_str: str):
4850

4951
input_t = tuple[torch.Tensor]
5052
test_data_suite = {
51-
"ones": (torch.ones(10, 10, 10),),
52-
"rand": (torch.rand(10, 10) - 0.5,),
53-
"rand_4d": (torch.rand(1, 1, 5, 10),),
54-
"randn_pos": (torch.randn(10) + 10,),
55-
"randn_neg": (torch.randn(10) - 10,),
56-
"ramp": (torch.arange(-16, 16, 0.02),),
53+
"ones": lambda: torch.ones(10, 10, 10),
54+
"rand": lambda: torch.rand(10, 10) - 0.5,
55+
"rand_4d": lambda: torch.rand(1, 1, 5, 10),
56+
"randn_pos": lambda: torch.randn(10) + 10,
57+
"randn_neg": lambda: torch.randn(10) - 10,
58+
"ramp": lambda: torch.arange(-16, 16, 0.02),
5759
}
5860

5961

@@ -79,8 +81,11 @@ def forward(self, x):
7981

8082

8183
@common.parametrize("test_data", test_data_suite)
84+
@pytest.mark.flaky(reruns=5)
8285
def test_sigmoid_tosa_BI(test_data):
83-
pipeline = TosaPipelineBI(Sigmoid(), test_data, Sigmoid.aten_op, Sigmoid.exir_op)
86+
pipeline = TosaPipelineBI(
87+
Sigmoid(), (test_data(),), Sigmoid.aten_op, Sigmoid.exir_op
88+
)
8489
pipeline.change_args("quantize", get_16bit_sigmoid_quantizer("TOSA-0.80+BI"))
8590
pipeline.run()
8691

@@ -89,12 +94,13 @@ def test_sigmoid_tosa_BI(test_data):
8994
"test_data",
9095
test_data_suite,
9196
xfails={
92-
"ramp": "AssertionError: Output 0 does not match reference output. Passes with qtol=2. MLETORCH-787"
97+
"ramp": "AssertionError: Output 0 does not match reference output. MLETORCH-787"
9398
},
9499
)
100+
@pytest.mark.flaky(reruns=5)
95101
def test_sigmoid_add_sigmoid_tosa_BI(test_data):
96102
pipeline = TosaPipelineBI(
97-
SigmoidAddSigmoid(), test_data, Sigmoid.aten_op, Sigmoid.exir_op
103+
SigmoidAddSigmoid(), (test_data(),), Sigmoid.aten_op, Sigmoid.exir_op
98104
)
99105
pipeline.change_args("quantize", get_16bit_sigmoid_quantizer("TOSA-0.80+BI"))
100106
pipeline.run()
@@ -107,13 +113,18 @@ def test_sigmoid_add_sigmoid_tosa_BI(test_data):
107113
"ones": "AssertionError: Output 0 does not match reference output. MLBEDSW-9770",
108114
"rand": "AssertionError: Output 0 does not match reference output. MLBEDSW-9770",
109115
"rand_4d": "AssertionError: Output 0 does not match reference output. MLBEDSW-9770",
116+
"randn_pos": "AssertionError: Output 0 does not match reference output. MLBEDSW-9770",
117+
"randn_neg": "AssertionError: Output 0 does not match reference output. MLBEDSW-9770",
110118
"ramp": "AssertionError: Output 0 does not match reference output. MLBEDSW-9770",
111119
},
120+
# int16 tables are not supported, but some tests happen to pass regardless.
121+
# Set them to xfail but strict=False -> ok if they pass.
122+
strict=False,
112123
)
113124
@common.XfailIfNoCorstone300
114125
def test_sigmoid_tosa_u55(test_data):
115126
pipeline = EthosU55PipelineBI(
116-
Sigmoid(), test_data, Sigmoid.aten_op, Sigmoid.exir_op, run_on_fvp=True
127+
Sigmoid(), (test_data(),), Sigmoid.aten_op, Sigmoid.exir_op, run_on_fvp=True
117128
)
118129
pipeline.change_args("quantize", get_16bit_sigmoid_quantizer("TOSA-0.80+BI+u55"))
119130
pipeline.run()
@@ -127,14 +138,18 @@ def test_sigmoid_tosa_u55(test_data):
127138
"rand": "AssertionError: Output 0 does not match reference output. MLBEDSW-9770",
128139
"rand_4d": "AssertionError: Output 0 does not match reference output. MLBEDSW-9770",
129140
"randn_neg": "AssertionError: Output 0 does not match reference output. MLBEDSW-9770",
130-
"ramp": "AssertionError: Output 0 does not match reference output. MLBEDSW-9770",
141+
"randn_pos": "AssertionError: Output 0 does not match reference output. MLBEDSW-9770",
142+
"ramp": "AsssertionError: Output 0 does not match reference output. MLBEDSW-9770",
131143
},
144+
# int16 tables are not supported, but some tests happen to pass regardless.
145+
# Set them to xfail but strict=False -> ok if they pass.
146+
strict=False,
132147
)
133148
@common.XfailIfNoCorstone300
134149
def test_sigmoid_add_sigmoid_tosa_u55(test_data):
135150
pipeline = EthosU55PipelineBI(
136151
SigmoidAddSigmoid(),
137-
test_data,
152+
(test_data(),),
138153
Sigmoid.aten_op,
139154
Sigmoid.exir_op,
140155
run_on_fvp=True,
@@ -144,10 +159,11 @@ def test_sigmoid_add_sigmoid_tosa_u55(test_data):
144159

145160

146161
@common.parametrize("test_data", test_data_suite)
162+
@pytest.mark.flaky(reruns=5)
147163
@common.XfailIfNoCorstone320
148164
def test_sigmoid_tosa_u85(test_data):
149165
pipeline = EthosU85PipelineBI(
150-
Sigmoid(), test_data, Sigmoid.aten_op, Sigmoid.exir_op, run_on_fvp=True
166+
Sigmoid(), (test_data(),), Sigmoid.aten_op, Sigmoid.exir_op, run_on_fvp=True
151167
)
152168
pipeline.change_args("quantize", get_16bit_sigmoid_quantizer("TOSA-0.80+BI"))
153169
pipeline.run()
@@ -160,11 +176,12 @@ def test_sigmoid_tosa_u85(test_data):
160176
"ramp": "AssertionError: Output 0 does not match reference output.",
161177
},
162178
)
179+
@pytest.mark.flaky(reruns=5)
163180
@common.XfailIfNoCorstone320
164181
def test_sigmoid_add_sigmoid_tosa_u85(test_data):
165182
pipeline = EthosU85PipelineBI(
166183
SigmoidAddSigmoid(),
167-
test_data,
184+
(test_data(),),
168185
Sigmoid.aten_op,
169186
Sigmoid.exir_op,
170187
run_on_fvp=True,

backends/arm/test/ops/test_sigmoid_32bit.py

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# This source code is licensed under the BSD-style license found in the
44
# LICENSE file in the root directory of this source tree.
55

6+
import pytest
67
import torch
78
from executorch.backends.arm.quantizer.arm_quantizer import TOSAQuantizer
89
from executorch.backends.arm.quantizer.quantization_config import QuantizationConfig
@@ -52,7 +53,7 @@ def _get_32_bit_quant_config():
5253
return qconfig
5354

5455

55-
def get_16bit_sigmoid_quantizer(tosa_str: str):
56+
def get_32bit_sigmoid_quantizer(tosa_str: str):
5657
tosa_spec = common.TosaSpecification.create_from_string(tosa_str)
5758
quantizer = TOSAQuantizer(tosa_spec)
5859
quantizer.set_global(_get_32_bit_quant_config())
@@ -65,12 +66,12 @@ def get_16bit_sigmoid_quantizer(tosa_str: str):
6566

6667
input_t = tuple[torch.Tensor]
6768
test_data_suite = {
68-
"ones": (torch.ones(10, 10, 10),),
69-
"rand": (torch.rand(10, 10) - 0.5,),
70-
"rand_4d": (torch.rand(1, 10, 10, 10),),
71-
"randn_pos": (torch.randn(10) + 10,),
72-
"randn_neg": (torch.randn(10) - 10,),
73-
"ramp": (torch.arange(-16, 16, 0.2),),
69+
"ones": lambda: torch.ones(10, 10, 10),
70+
"rand": lambda: torch.rand(10, 10) - 0.5,
71+
"rand_4d": lambda: torch.rand(1, 10, 10, 10),
72+
"randn_pos": lambda: torch.randn(10) + 10,
73+
"randn_neg": lambda: torch.randn(10) - 10,
74+
"ramp": lambda: torch.arange(-16, 16, 0.2),
7475
}
7576

7677

@@ -96,28 +97,28 @@ def forward(self, x):
9697

9798

9899
@common.parametrize("test_data", test_data_suite)
100+
@pytest.mark.flaky(reruns=5)
99101
def test_sigmoid_tosa_BI(test_data):
100102
pipeline = TosaPipelineBI(
101103
Sigmoid(),
102-
test_data,
104+
(test_data(),),
103105
Sigmoid.aten_op,
104106
Sigmoid.exir_op,
105107
)
106-
pipeline.change_args("quantize", get_16bit_sigmoid_quantizer("TOSA-0.80+BI"))
108+
pipeline.change_args("quantize", get_32bit_sigmoid_quantizer("TOSA-0.80+BI"))
107109
pipeline.run()
108110

109111

110112
@common.parametrize("test_data", test_data_suite)
113+
@pytest.mark.flaky(reruns=5)
111114
def test_sigmoid_add_sigmoid_tosa_BI(test_data):
112115
pipeline = TosaPipelineBI(
113116
SigmoidAddSigmoid(),
114-
test_data,
117+
(test_data(),),
115118
Sigmoid.aten_op,
116119
Sigmoid.exir_op,
117120
)
118-
pipeline.change_args("quantize", get_16bit_sigmoid_quantizer("TOSA-0.80+BI"))
119-
pipeline.change_args("run_method_and_compare_outputs", test_data, qtol=1)
120-
121+
pipeline.change_args("quantize", get_32bit_sigmoid_quantizer("TOSA-0.80+BI"))
121122
pipeline.run()
122123

123124

@@ -129,16 +130,19 @@ def test_sigmoid_add_sigmoid_tosa_BI(test_data):
129130
"rand": "AssertionError: Output 0 does not match reference output. MLBEDSW-9770",
130131
"rand_4d": "AssertionError: Output 0 does not match reference output. MLBEDSW-9770",
131132
"randn_pos": "AssertionError: Output 0 does not match reference output. MLBEDSW-9770",
133+
"randn_neg": "AssertionError: Output 0 does not match reference output. MLBEDSW-9770",
132134
"ramp": "AssertionError: Output 0 does not match reference output. MLBEDSW-9770",
133135
},
136+
# int16 tables are not supported, but some tests happen to pass regardless.
137+
# Set them to xfail but strict=False -> ok if they pass.
138+
strict=False,
134139
)
135140
@common.XfailIfNoCorstone300
136141
def test_sigmoid_tosa_u55(test_data):
137142
pipeline = EthosU55PipelineBI(
138-
Sigmoid(), test_data, Sigmoid.aten_op, Sigmoid.exir_op, run_on_fvp=True
143+
Sigmoid(), (test_data(),), Sigmoid.aten_op, Sigmoid.exir_op, run_on_fvp=True
139144
)
140-
pipeline.change_args("quantize", get_16bit_sigmoid_quantizer("TOSA-0.80+BI+u55"))
141-
pipeline.change_args("run_method_and_compare_outputs", test_data, qtol=1)
145+
pipeline.change_args("quantize", get_32bit_sigmoid_quantizer("TOSA-0.80+BI+u55"))
142146
pipeline.run()
143147

144148

@@ -153,29 +157,31 @@ def test_sigmoid_tosa_u55(test_data):
153157
"randn_neg": "AssertionError: Output 0 does not match reference output. MLBEDSW-9770",
154158
"ramp": "AssertionError: Output 0 does not match reference output. MLBEDSW-9770",
155159
},
160+
# int16 tables are not supported, but some tests happen to pass regardless.
161+
# Set them to xfail but strict=False -> ok if they pass.
162+
strict=False,
156163
)
157164
@common.XfailIfNoCorstone300
158165
def test_sigmoid_add_sigmoid_tosa_u55(test_data):
159166
pipeline = EthosU55PipelineBI(
160167
SigmoidAddSigmoid(),
161-
test_data,
168+
(test_data(),),
162169
Sigmoid.aten_op,
163170
Sigmoid.exir_op,
164171
run_on_fvp=True,
165172
)
166-
pipeline.change_args("quantize", get_16bit_sigmoid_quantizer("TOSA-0.80+BI+u55"))
167-
pipeline.change_args("run_method_and_compare_outputs", test_data, qtol=1)
173+
pipeline.change_args("quantize", get_32bit_sigmoid_quantizer("TOSA-0.80+BI+u55"))
168174
pipeline.run()
169175

170176

171177
@common.parametrize("test_data", test_data_suite)
178+
@pytest.mark.flaky(reruns=5)
172179
@common.XfailIfNoCorstone320
173180
def test_sigmoid_tosa_u85(test_data):
174181
pipeline = EthosU85PipelineBI(
175-
Sigmoid(), test_data, Sigmoid.aten_op, Sigmoid.exir_op, run_on_fvp=True
182+
Sigmoid(), (test_data(),), Sigmoid.aten_op, Sigmoid.exir_op, run_on_fvp=True
176183
)
177-
pipeline.change_args("quantize", get_16bit_sigmoid_quantizer("TOSA-0.80+BI"))
178-
pipeline.change_args("run_method_and_compare_outputs", test_data, qtol=1)
184+
pipeline.change_args("quantize", get_32bit_sigmoid_quantizer("TOSA-0.80+BI"))
179185
pipeline.run()
180186

181187

@@ -186,15 +192,15 @@ def test_sigmoid_tosa_u85(test_data):
186192
"ramp": "AssertionError: Output 0 does not match reference output.",
187193
},
188194
)
195+
@pytest.mark.flaky(reruns=5)
189196
@common.XfailIfNoCorstone320
190197
def test_sigmoid_add_sigmoid_tosa_u85(test_data):
191198
pipeline = EthosU85PipelineBI(
192199
SigmoidAddSigmoid(),
193-
test_data,
200+
(test_data(),),
194201
Sigmoid.aten_op,
195202
Sigmoid.exir_op,
196203
run_on_fvp=True,
197204
)
198-
pipeline.change_args("quantize", get_16bit_sigmoid_quantizer("TOSA-0.80+BI"))
199-
pipeline.change_args("run_method_and_compare_outputs", test_data, qtol=1)
205+
pipeline.change_args("quantize", get_32bit_sigmoid_quantizer("TOSA-0.80+BI"))
200206
pipeline.run()

0 commit comments

Comments
 (0)