Skip to content

Commit 8f1a4bc

Browse files
Arm backend: Update vgf ops tests [Part 2] (#16251)
### Summary Updates the remaining vgf op tests to use the quantize flag to VgfTestPipeline instead of passing a tosa_version. Also adds a few vgf tests where we override the default INT+FP TOSA specification to test INT or FP only lowering to vgf. cc @freddan80 @per @zingo @digantdesai --------- Signed-off-by: Oscar Andersson <[email protected]>
1 parent 68ddd80 commit 8f1a4bc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+512
-423
lines changed

backends/arm/test/models/test_nss.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def test_nss_u85_INT():
110110
reason="[MLETORCH-1430]: Double types are not supported in buffers in MSL"
111111
)
112112
@common.SkipIfNoModelConverter
113-
def test_nss_vgf_no_quant():
113+
def test_nss_vgf_FP():
114114
pipeline = VgfPipeline[input_t](
115115
nss().eval(),
116116
example_inputs(),
@@ -119,12 +119,14 @@ def test_nss_vgf_no_quant():
119119
use_to_edge_transform_and_lower=True,
120120
run_on_vulkan_runtime=True,
121121
quantize=False,
122+
# Override tosa version to test FP-only path
123+
tosa_version="TOSA-1.0+FP",
122124
)
123125
pipeline.run()
124126

125127

126128
@common.SkipIfNoModelConverter
127-
def test_nss_vgf_quant():
129+
def test_nss_vgf_INT():
128130
pipeline = VgfPipeline[input_t](
129131
nss().eval(),
130132
example_inputs(),
@@ -134,6 +136,8 @@ def test_nss_vgf_quant():
134136
use_to_edge_transform_and_lower=True,
135137
run_on_vulkan_runtime=True,
136138
quantize=True,
139+
# Override tosa version to test INT-only path
140+
tosa_version="TOSA-1.0+INT",
137141
)
138142
pipeline.run()
139143

backends/arm/test/ops/test_hardsigmoid.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,25 @@ def test_hardsigmoid_u85_INT(test_data: torch.Tensor):
9090

9191
@common.parametrize("test_data", test_data_suite)
9292
@common.SkipIfNoModelConverter
93-
def test_hardsigmoid_vgf_FP(test_data: torch.Tensor):
93+
def test_hardsigmoid_vgf_no_quant(test_data: torch.Tensor):
9494
pipeline = VgfPipeline[input_t1](
95-
Hardsigmoid(), (test_data(),), aten_op, exir_op=[], tosa_version="TOSA-1.0+FP"
95+
Hardsigmoid(),
96+
(test_data(),),
97+
aten_op,
98+
exir_op=[],
99+
quantize=False,
96100
)
97101
pipeline.run()
98102

99103

100104
@common.parametrize("test_data", test_data_suite)
101105
@common.SkipIfNoModelConverter
102-
def test_hardsigmoid_vgf_INT(test_data: torch.Tensor):
106+
def test_hardsigmoid_vgf_quant(test_data: torch.Tensor):
103107
pipeline = VgfPipeline[input_t1](
104108
Hardsigmoid(),
105109
(test_data(),),
106110
aten_op,
107111
exir_op=[],
108-
tosa_version="TOSA-1.0+INT",
112+
quantize=True,
109113
)
110114
pipeline.run()

backends/arm/test/ops/test_hardswish.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,25 @@ def test_hardswish_u85_INT(test_data):
8080

8181
@common.parametrize("test_data", test_data_suite)
8282
@common.SkipIfNoModelConverter
83-
def test_hardswish_vgf_FP(test_data):
83+
def test_hardswish_vgf_no_quant(test_data):
8484
pipeline = VgfPipeline[input_t1](
85-
Hardswish(), (test_data(),), aten_op, exir_op, tosa_version="TOSA-1.0+FP"
85+
Hardswish(),
86+
(test_data(),),
87+
aten_op,
88+
exir_op,
89+
quantize=False,
8690
)
8791
pipeline.run()
8892

8993

9094
@common.parametrize("test_data", test_data_suite)
9195
@common.SkipIfNoModelConverter
92-
def test_hardswish_vgf_INT(test_data):
96+
def test_hardswish_vgf_quant(test_data):
9397
pipeline = VgfPipeline[input_t1](
9498
Hardswish(),
9599
(test_data(),),
96100
aten_op,
97101
exir_op,
98-
tosa_version="TOSA-1.0+INT",
102+
quantize=True,
99103
)
100104
pipeline.run()

backends/arm/test/ops/test_hardtanh.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,21 +89,25 @@ def test_hardtanh_u85_INT(test_data: torch.Tensor):
8989

9090
@common.parametrize("test_data", test_data_suite)
9191
@common.SkipIfNoModelConverter
92-
def test_hardtanh_vgf_FP(test_data: torch.Tensor):
92+
def test_hardtanh_vgf_no_quant(test_data: torch.Tensor):
9393
pipeline = VgfPipeline[input_t](
94-
HardTanh(), (test_data(),), aten_op, exir_op, tosa_version="TOSA-1.0+FP"
94+
HardTanh(),
95+
(test_data(),),
96+
aten_op,
97+
exir_op,
98+
quantize=False,
9599
)
96100
pipeline.run()
97101

98102

99103
@common.parametrize("test_data", test_data_suite)
100104
@common.SkipIfNoModelConverter
101-
def test_hardtanh_vgf_INT(test_data: torch.Tensor):
105+
def test_hardtanh_vgf_quant(test_data: torch.Tensor):
102106
pipeline = VgfPipeline[input_t](
103107
HardTanh(),
104108
(test_data(),),
105109
aten_op,
106110
exir_op,
107-
tosa_version="TOSA-1.0+INT",
111+
quantize=True,
108112
)
109113
pipeline.run()

backends/arm/test/ops/test_index_select.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,41 +137,41 @@ def test_index_select_u55_INT_not_delegated(test_data: input_params):
137137

138138
@pytest.mark.parametrize("test_data", list(test_data.values()))
139139
@common.SkipIfNoModelConverter
140-
def test_index_select_vgf_FP(test_data: input_params):
140+
def test_index_select_vgf_no_quant(test_data: input_params):
141141
op, inp = test_data
142142
pipeline = VgfPipeline[input_params](
143143
op,
144144
inp,
145145
op.aten_op,
146146
op.exir_op,
147-
tosa_version="TOSA-1.0+FP",
147+
quantize=False,
148148
)
149149
pipeline.run()
150150

151151

152152
@pytest.mark.parametrize("test_data", list(test_data.values())[:-1])
153153
@common.SkipIfNoModelConverter
154-
def test_index_select_vgf_INT(test_data: input_params):
154+
def test_index_select_vgf_quant(test_data: input_params):
155155
op, inp = test_data
156156
pipeline = VgfPipeline[input_params](
157157
op,
158158
inp,
159159
op.aten_op,
160160
op.exir_op,
161-
tosa_version="TOSA-1.0+INT",
161+
quantize=True,
162162
)
163163
pipeline.run()
164164

165165

166166
@pytest.mark.parametrize("test_data", list(test_data.values())[-1:])
167167
@common.SkipIfNoModelConverter
168-
def test_index_select_vgf_INT_rand(test_data: input_params):
168+
def test_index_select_vgf_quant_rand(test_data: input_params):
169169
op, inp = test_data
170170
pipeline = VgfPipeline[input_params](
171171
op,
172172
inp,
173173
op.aten_op,
174174
op.exir_op,
175-
tosa_version="TOSA-1.0+INT",
175+
quantize=True,
176176
)
177177
pipeline.run()

backends/arm/test/ops/test_layer_norm.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,26 +115,26 @@ def test_native_layer_norm_u85_INT(test_data):
115115

116116
@common.parametrize("test_data", test_data_suite)
117117
@common.SkipIfNoModelConverter
118-
def test_native_layer_norm_vgf_FP(test_data):
118+
def test_native_layer_norm_vgf_no_quant(test_data):
119119
test_input, model = test_data()
120120
pipeline = VgfPipeline[input_t](
121121
model,
122122
test_input,
123123
"torch.ops.aten.layer_norm.default",
124-
tosa_version="TOSA-1.0+FP",
124+
quantize=False,
125125
)
126126
pipeline.run()
127127

128128

129129
@common.parametrize("test_data", test_data_suite)
130130
@common.SkipIfNoModelConverter
131-
def test_native_layer_norm_vgf_INT(test_data):
131+
def test_native_layer_norm_vgf_quant(test_data):
132132
test_input, model = test_data()
133133
pipeline = VgfPipeline[input_t](
134134
model,
135135
test_input,
136136
"torch.ops.aten.sub.Tensor",
137-
tosa_version="TOSA-1.0+INT",
137+
quantize=True,
138138
)
139139
pipeline.run()
140140

backends/arm/test/ops/test_le.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -246,51 +246,51 @@ def test_le_scalar_16a8w_u85_INT16(test_module):
246246

247247
@common.parametrize("test_module", test_data_tensor)
248248
@common.SkipIfNoModelConverter
249-
def test_le_tensor_vgf_FP(test_module):
249+
def test_le_tensor_vgf_no_quant(test_module):
250250
pipeline = VgfPipeline[input_t](
251251
test_module(),
252252
test_module().get_inputs(),
253253
LessEqual.aten_op_tensor,
254254
LessEqual.exir_op,
255-
tosa_version="TOSA-1.0+FP",
255+
quantize=False,
256256
)
257257
pipeline.run()
258258

259259

260260
@common.parametrize("test_module", test_data_tensor)
261261
@common.SkipIfNoModelConverter
262-
def test_le_tensor_vgf_INT(test_module):
262+
def test_le_tensor_vgf_quant(test_module):
263263
pipeline = VgfPipeline[input_t](
264264
test_module(),
265265
test_module().get_inputs(),
266266
LessEqual.aten_op_tensor,
267267
LessEqual.exir_op,
268-
tosa_version="TOSA-1.0+INT",
268+
quantize=True,
269269
)
270270
pipeline.run()
271271

272272

273273
@common.parametrize("test_module", test_data_scalar)
274274
@common.SkipIfNoModelConverter
275-
def test_le_scalar_vgf_FP(test_module):
275+
def test_le_scalar_vgf_no_quant(test_module):
276276
pipeline = VgfPipeline[input_t](
277277
test_module(),
278278
test_module().get_inputs(),
279279
LessEqual.aten_op_scalar,
280280
LessEqual.exir_op,
281-
tosa_version="TOSA-1.0+FP",
281+
quantize=False,
282282
)
283283
pipeline.run()
284284

285285

286286
@common.parametrize("test_module", test_data_scalar)
287287
@common.SkipIfNoModelConverter
288-
def test_le_scalar_vgf_INT(test_module):
288+
def test_le_scalar_vgf_quant(test_module):
289289
pipeline = VgfPipeline[input_t](
290290
test_module(),
291291
test_module().get_inputs(),
292292
LessEqual.aten_op_tensor,
293293
LessEqual.exir_op,
294-
tosa_version="TOSA-1.0+INT",
294+
quantize=True,
295295
)
296296
pipeline.run()

backends/arm/test/ops/test_leaky_relu.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ def test_leaky_relu_u85_INT(test_data):
9595

9696
@common.parametrize("test_data", LeakyReLU.test_data)
9797
@common.SkipIfNoModelConverter
98-
def test_leaky_relu_vgf_FP(test_data):
98+
def test_leaky_relu_vgf_no_quant(test_data):
9999
data, slope = test_data()
100100
pipeline = VgfPipeline[input_t1](
101101
LeakyReLU(slope),
102102
data,
103103
[],
104104
use_to_edge_transform_and_lower=True,
105-
tosa_version="TOSA-1.0+FP",
105+
quantize=False,
106106
)
107107
pipeline.add_stage_after(
108108
"to_edge_transform_and_lower", pipeline.tester.check_not, [aten_op]
@@ -112,14 +112,14 @@ def test_leaky_relu_vgf_FP(test_data):
112112

113113
@common.parametrize("test_data", LeakyReLU.test_data)
114114
@common.SkipIfNoModelConverter
115-
def test_leaky_relu_vgf_INT(test_data):
115+
def test_leaky_relu_vgf_quant(test_data):
116116
data, slope = test_data()
117117
pipeline = VgfPipeline[input_t1](
118118
LeakyReLU(slope),
119119
data,
120120
[],
121121
use_to_edge_transform_and_lower=True,
122-
tosa_version="TOSA-1.0+INT",
122+
quantize=True,
123123
)
124124
pipeline.add_stage_after("quantize", pipeline.tester.check_not, [aten_op])
125125
pipeline.run()

backends/arm/test/ops/test_linalg_vector_norm.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def test_vector_norm_u85_INT_fvp(test_module):
128128

129129
@common.parametrize("test_module", test_modules)
130130
@common.SkipIfNoModelConverter
131-
def test_vector_norm_vgf_FP(test_module):
131+
def test_vector_norm_vgf_no_quant(test_module):
132132
model, input_tensor = test_module
133133
# FP VGF
134134
aten_op = "torch.ops.aten.linalg_vector_norm.default"
@@ -138,14 +138,14 @@ def test_vector_norm_vgf_FP(test_module):
138138
input_tensor,
139139
aten_op,
140140
exir_op,
141-
tosa_version="TOSA-1.0+FP",
141+
quantize=False,
142142
)
143143
pipeline.run()
144144

145145

146146
@common.parametrize("test_module", test_modules)
147147
@common.SkipIfNoModelConverter
148-
def test_vector_norm_vgf_INT(test_module):
148+
def test_vector_norm_vgf_quant(test_module):
149149
model, input_tensor = test_module
150150
# Should not found this op
151151
exir_op = "executorch_exir_dialects_edge__ops_aten_linalg_vector_norm_default"
@@ -155,6 +155,6 @@ def test_vector_norm_vgf_INT(test_module):
155155
input_tensor,
156156
aten_op_q_decomposed_q,
157157
exir_op,
158-
tosa_version="TOSA-1.0+INT",
158+
quantize=True,
159159
)
160160
pipeline.run()

backends/arm/test/ops/test_linear.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -209,39 +209,31 @@ def test_linear_u85_INT(test_data: torch.Tensor):
209209

210210
@common.parametrize("test_data", test_data_rank1_FP | test_data_rank4_FP)
211211
@common.SkipIfNoModelConverter
212-
def test_linear_vgf_FP(test_data: torch.Tensor):
212+
def test_linear_vgf_no_quant(test_data: torch.Tensor):
213213
test_data, out_features, has_bias = test_data()
214214
in_features = test_data.shape[-1]
215215
pipeline = VgfPipeline[input_t1](
216-
Linear(
217-
in_features=in_features,
218-
out_features=out_features,
219-
bias=has_bias,
220-
),
216+
Linear(in_features=in_features, out_features=out_features, bias=has_bias),
221217
(test_data,),
222218
aten_op=aten_op,
223219
exir_op=[],
224-
tosa_version="TOSA-1.0+FP",
220+
quantize=False,
225221
)
226222
pipeline.run()
227223

228224

229225
@common.parametrize("test_data", test_data_rank1_INT | test_data_rank4_INT)
230226
@common.SkipIfNoModelConverter
231-
def test_linear_vgf_INT(test_data: torch.Tensor):
227+
def test_linear_vgf_quant(test_data: torch.Tensor):
232228
test_data, out_features, has_bias, per_channel_quantization = test_data()
233229
in_features = test_data.shape[-1]
234230
pipeline = VgfPipeline[input_t1](
235-
Linear(
236-
in_features=in_features,
237-
out_features=out_features,
238-
bias=has_bias,
239-
),
231+
Linear(in_features=in_features, out_features=out_features, bias=has_bias),
240232
(test_data,),
241233
aten_op=aten_op,
242234
exir_op=[],
243-
tosa_version="TOSA-1.0+INT",
244235
per_channel_quantization=per_channel_quantization,
236+
quantize=True,
245237
)
246238
pipeline.run()
247239

0 commit comments

Comments
 (0)