Skip to content

Commit 5c27045

Browse files
authored
Test new partitioner on all models
Differential Revision: D60492337 Pull Request resolved: #4576
1 parent f863fe4 commit 5c27045

File tree

15 files changed

+52
-87
lines changed

15 files changed

+52
-87
lines changed

backends/xnnpack/partition/config/__init__.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,44 +55,41 @@
5555
)
5656

5757
ALL_PARTITIONER_CONFIGS: List[Type[XNNPartitionerConfig]] = [
58-
# GEMM-like Configs
59-
AddmmConfig,
60-
LinearConfig,
61-
ConstantPadConfig,
62-
ConvolutionConfig,
63-
# BatchNorm Config
64-
BatchNormConfig,
65-
# Single Node Configs
6658
AbsConfig,
67-
AvgPoolingConfig,
6859
AddConfig,
60+
AddmmConfig,
61+
AvgPoolingConfig,
62+
BatchNormConfig,
6963
CatConfig,
7064
CeilConfig,
65+
ConstantPadConfig,
66+
ConvolutionConfig,
7167
ClampConfig,
7268
DivConfig,
69+
# EluConfig, # Waiting for PyTorch Pin Update
7370
FloorConfig,
7471
HardtanhConfig,
7572
HardswishConfig,
7673
LeakyReLUConfig,
74+
LinearConfig,
7775
MaxDimConfig,
7876
MaximumConfig,
7977
MaxPool2dConfig,
8078
MeanDimConfig,
8179
MinimumConfig,
8280
MulConfig,
8381
NegConfig,
82+
PermuteConfig,
8483
PowConfig,
8584
PreluConfig,
86-
SoftmaxConfig,
85+
ReLUConfig,
8786
SigmoidConfig,
8887
SliceCopyConfig,
88+
SoftmaxConfig,
8989
SquareRootConfig,
9090
SubConfig,
91-
PermuteConfig,
92-
# EluConfig, # Waiting for PyTorch Pin Update
93-
ReLUConfig,
9491
UpsampleBilinear2dConfig,
95-
# Quantization Op Configs
92+
# Quant/Dequant Op Configs
9693
QuantizedPerTensorConfig,
9794
DeQuantizedPerTensorConfig,
9895
]

backends/xnnpack/partition/configs.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,16 @@
101101
exir_ops.edge.aten.addmm.default, # TODO(T163877189) add constraint for addmm
102102
]
103103

104+
# This set is used to determine if an op is a supported Quantized Op. This is
105+
# used to determine whether a quantization op is implicit or explicit.
104106
SUPPORTED_IMPLICIT_Q_DQ_OP_NAMES_SET = {
105107
op.name()
106108
for op in (
107109
SUPPORTED_QUANT_OPS
108110
+ [
109111
exir_ops.edge.aten._to_copy.default,
110112
exir_ops.edge.aten.linear.default,
113+
exir_ops.edge.aten.convolution.default,
111114
]
112115
)
113116
}

backends/xnnpack/test/models/deeplab_v3.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ def test_fp32_dl3(self):
3232
(
3333
Tester(self.dl3, self.model_inputs)
3434
.export()
35-
.to_edge()
36-
.partition()
35+
.to_edge_transform_and_lower()
3736
.to_executorch()
3837
.serialize()
3938
.run_method_and_compare_outputs()

backends/xnnpack/test/models/edsr.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ def test_fp32_edsr(self):
2121
(
2222
Tester(self.edsr, self.model_inputs)
2323
.export()
24-
.to_edge()
25-
.partition()
24+
.to_edge_transform_and_lower()
2625
.to_executorch()
2726
.serialize()
2827
.run_method_and_compare_outputs()
@@ -34,8 +33,7 @@ def _test_qs8_edsr(self):
3433
Tester(self.edsr, self.model_inputs)
3534
.quantize()
3635
.export()
37-
.to_edge()
38-
.partition()
36+
.to_edge_transform_and_lower()
3937
.to_executorch()
4038
.serialize()
4139
.run_method_and_compare_outputs()
@@ -47,8 +45,7 @@ def test_qs8_edsr_no_calibrate(self):
4745
Tester(self.edsr, self.model_inputs)
4846
.quantize(Quantize(calibrate=False))
4947
.export()
50-
.to_edge()
51-
.partition()
48+
.to_edge_transform_and_lower()
5249
.to_executorch()
5350
.serialize()
5451
.run_method_and_compare_outputs()

backends/xnnpack/test/models/emformer_rnnt.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ def test_fp32_emformer_joiner(self):
3838
(
3939
Tester(joiner, joiner.get_example_inputs())
4040
.export()
41-
.to_edge()
42-
.partition()
41+
.to_edge_transform_and_lower()
4342
.check(["torch.ops.higher_order.executorch_call_delegate"])
4443
.to_executorch()
4544
.serialize()
@@ -65,8 +64,7 @@ def _test_fp32_emformer_predictor(self):
6564
(
6665
Tester(predictor, predictor.get_example_inputs())
6766
.export()
68-
.to_edge()
69-
.partition()
67+
.to_edge_transform_and_lower()
7068
.check(["torch.ops.higher_order.executorch_call_delegate"])
7169
.to_executorch()
7270
.serialize()
@@ -89,8 +87,7 @@ def test_fp32_emformer_transcriber(self):
8987
(
9088
Tester(transcriber, transcriber.get_example_inputs())
9189
.export()
92-
.to_edge()
93-
.partition()
90+
.to_edge_transform_and_lower()
9491
.check(["torch.ops.higher_order.executorch_call_delegate"])
9592
.to_executorch()
9693
.serialize()

backends/xnnpack/test/models/inception_v3.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ def test_fp32_ic3(self):
3434
(
3535
Tester(self.ic3, self.model_inputs)
3636
.export()
37-
.to_edge()
38-
.check(list(self.all_operators))
39-
.partition()
37+
.to_edge_transform_and_lower()
4038
.check(["torch.ops.higher_order.executorch_call_delegate"])
4139
.check_not(list(self.all_operators))
4240
.to_executorch()
@@ -55,9 +53,7 @@ def _test_qs8_ic3(self):
5553
Tester(self.ic3, self.model_inputs)
5654
.quantize()
5755
.export()
58-
.to_edge()
59-
.check(list(ops_after_quantization))
60-
.partition()
56+
.to_edge_transform_and_lower()
6157
.check(["torch.ops.higher_order.executorch_call_delegate"])
6258
.check_not(list(ops_after_quantization))
6359
.to_executorch()
@@ -76,9 +72,7 @@ def test_qs8_ic3_no_calibration(self):
7672
Tester(self.ic3, self.model_inputs)
7773
.quantize(Quantize(calibrate=False))
7874
.export()
79-
.to_edge()
80-
.check(list(ops_after_quantization))
81-
.partition()
75+
.to_edge_transform_and_lower()
8276
.check(["torch.ops.higher_order.executorch_call_delegate"])
8377
.check_not(list(ops_after_quantization))
8478
.to_executorch()

backends/xnnpack/test/models/inception_v4.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ def test_fp32_ic4(self):
3232
(
3333
Tester(self.ic4, self.model_inputs)
3434
.export()
35-
.to_edge()
36-
.check(list(self.all_operators))
37-
.partition()
35+
.to_edge_transform_and_lower()
3836
.check(["torch.ops.higher_order.executorch_call_delegate"])
3937
.check_not(list(self.all_operators))
4038
.to_executorch()
@@ -52,9 +50,7 @@ def test_qs8_ic4(self):
5250
Tester(self.ic4, self.model_inputs)
5351
.quantize()
5452
.export()
55-
.to_edge()
56-
.check(list(ops_after_quantization))
57-
.partition()
53+
.to_edge_transform_and_lower()
5854
.check(["torch.ops.higher_order.executorch_call_delegate"])
5955
.check_not(list(ops_after_quantization))
6056
.to_executorch()

backends/xnnpack/test/models/llama2_et_example.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ def _test(self, dtype: torch.dtype = torch.float):
3939
(
4040
Tester(model, example_inputs)
4141
.export()
42-
.to_edge()
43-
.dump_artifact()
44-
.partition()
45-
.dump_artifact()
42+
.to_edge_transform_and_lower()
4643
.to_executorch()
4744
.serialize()
4845
.run_method_and_compare_outputs(atol=5e-2, inputs=example_inputs)

backends/xnnpack/test/models/mobilebert.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import unittest
88

99
import torch
10-
from executorch.backends.xnnpack.test.tester import Tester
10+
from executorch.backends.xnnpack.test.tester import Quantize, Tester
1111
from transformers import MobileBertConfig, MobileBertModel # @manual
1212

1313

@@ -32,9 +32,19 @@ def test_fp32_mobilebert(self):
3232
(
3333
Tester(self.mobilebert, self.example_inputs)
3434
.export()
35-
.to_edge()
36-
.check(list(self.supported_ops))
37-
.partition()
35+
.to_edge_transform_and_lower()
36+
.check_not(list(self.supported_ops))
37+
.to_executorch()
38+
.serialize()
39+
.run_method_and_compare_outputs(inputs=self.example_inputs)
40+
)
41+
42+
def test_qs8_mobilebert(self):
43+
(
44+
Tester(self.mobilebert, self.example_inputs)
45+
.quantize(Quantize(calibrate=False))
46+
.export()
47+
.to_edge_transform_and_lower()
3848
.check_not(list(self.supported_ops))
3949
.to_executorch()
4050
.serialize()

backends/xnnpack/test/models/mobilenet_v2.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ def test_fp32_mv2(self):
3939
(
4040
Tester(self.mv2, self.model_inputs, dynamic_shapes=dynamic_shapes)
4141
.export()
42-
.to_edge()
43-
.check(list(self.all_operators))
44-
.partition()
42+
.to_edge_transform_and_lower()
4543
.check(["torch.ops.higher_order.executorch_call_delegate"])
4644
.check_not(list(self.all_operators))
4745
.to_executorch()
@@ -67,9 +65,7 @@ def _test_qs8_mv2(self):
6765
Tester(self.mv2, self.model_inputs, dynamic_shapes=dynamic_shapes)
6866
.quantize()
6967
.export()
70-
.to_edge()
71-
.check(list(ops_after_quantization))
72-
.partition()
68+
.to_edge_transform_and_lower()
7369
.check(["torch.ops.higher_order.executorch_call_delegate"])
7470
.check_not(list(ops_after_quantization))
7571
.to_executorch()
@@ -95,9 +91,7 @@ def test_qs8_mv2_no_calibration(self):
9591
Tester(self.mv2, self.model_inputs, dynamic_shapes=dynamic_shapes)
9692
.quantize(Quantize(calibrate=False))
9793
.export()
98-
.to_edge()
99-
.check(list(ops_after_quantization))
100-
.partition()
94+
.to_edge_transform_and_lower()
10195
.check(["torch.ops.higher_order.executorch_call_delegate"])
10296
.check_not(list(ops_after_quantization))
10397
.to_executorch()

backends/xnnpack/test/models/mobilenet_v3.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class TestMobileNetV3(unittest.TestCase):
2828
"executorch_exir_dialects_edge__ops_aten_clamp_default",
2929
"executorch_exir_dialects_edge__ops_aten_permute_copy_default",
3030
"executorch_exir_dialects_edge__ops_aten_addmm_default",
31-
"executorch_exir_dialects_edge__ops_aten__to_copy_default",
3231
"executorch_exir_dialects_edge__ops_aten_convolution_default",
3332
"executorch_exir_dialects_edge__ops_aten_relu_default",
3433
"executorch_exir_dialects_edge__ops_aten_add_Tensor",
@@ -41,9 +40,7 @@ def test_fp32_mv3(self):
4140
(
4241
Tester(self.mv3, self.model_inputs, dynamic_shapes=self.dynamic_shapes)
4342
.export()
44-
.to_edge()
45-
.check(list(self.all_operators))
46-
.partition()
43+
.to_edge_transform_and_lower()
4744
.check(["torch.ops.higher_order.executorch_call_delegate"])
4845
.check_not(list(self.all_operators))
4946
.to_executorch()
@@ -53,18 +50,13 @@ def test_fp32_mv3(self):
5350

5451
@unittest.skip("T187799178: Debugging Numerical Issues with Calibration")
5552
def _test_qs8_mv3(self):
56-
ops_after_quantization = self.all_operators - {
57-
"executorch_exir_dialects_edge__ops_aten__native_batch_norm_legit_no_training_default",
58-
}
5953
ops_after_lowering = self.all_operators
6054

6155
(
6256
Tester(self.mv3, self.model_inputs, dynamic_shapes=self.dynamic_shapes)
6357
.quantize()
6458
.export()
65-
.to_edge()
66-
.check(list(ops_after_quantization))
67-
.partition()
59+
.to_edge_tranform_and_lower()
6860
.check(["torch.ops.higher_order.executorch_call_delegate"])
6961
.check_not(list(ops_after_lowering))
7062
.to_executorch()
@@ -74,18 +66,13 @@ def _test_qs8_mv3(self):
7466

7567
# TODO: Delete and only used calibrated test after T187799178
7668
def test_qs8_mv3_no_calibration(self):
77-
ops_after_quantization = self.all_operators - {
78-
"executorch_exir_dialects_edge__ops_aten__native_batch_norm_legit_no_training_default",
79-
}
8069
ops_after_lowering = self.all_operators
8170

8271
(
8372
Tester(self.mv3, self.model_inputs, dynamic_shapes=self.dynamic_shapes)
8473
.quantize(Quantize(calibrate=False))
8574
.export()
86-
.to_edge()
87-
.check(list(ops_after_quantization))
88-
.partition()
75+
.to_edge_transform_and_lower()
8976
.check(["torch.ops.higher_order.executorch_call_delegate"])
9077
.check_not(list(ops_after_lowering))
9178
.to_executorch()

backends/xnnpack/test/models/resnet.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ def forward(self, x):
3939
def _test_exported_resnet(self, tester):
4040
(
4141
tester.export()
42-
.to_edge()
43-
.partition()
42+
.to_edge_transform_and_lower()
4443
.check_not(
4544
[
4645
"executorch_exir_dialects_edge__ops_aten_convolution_default",

backends/xnnpack/test/models/torchvision_vit.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ def _test_exported_vit(self, tester, check_nots=None):
7373
}
7474
(
7575
tester.export()
76-
.to_edge()
77-
.check(list(self.all_operators))
78-
.partition()
76+
.to_edge_transform_and_lower()
7977
.check(["torch.ops.higher_order.executorch_call_delegate"])
8078
.check_not(list(lowerable_xnn_operators))
8179
.check_not(check_nots)

backends/xnnpack/test/models/very_big_model.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ def _test_very_big_model(self):
3434
(
3535
Tester(self.BigModel(), (torch.randn(1, 5000),))
3636
.export()
37-
.to_edge()
38-
.partition()
37+
.to_edge_transform_and_lower()
3938
.check(["torch.ops.higher_order.executorch_call_delegate"])
4039
.to_executorch()
4140
.serialize()

backends/xnnpack/test/models/w2l.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ def test_fp32_w2l(self):
2525
(
2626
Tester(self.wav2letter, self.model_inputs, self.dynamic_shape)
2727
.export()
28-
.to_edge()
29-
.partition()
28+
.to_edge_transform_and_lower()
3029
.check_not(
3130
[
3231
"executorch_exir_dialectes_edge__ops_aten_convolution_default",
@@ -44,8 +43,7 @@ def test_qs8_w2l(self):
4443
Tester(self.wav2letter.eval(), self.model_inputs, self.dynamic_shape)
4544
.quantize()
4645
.export()
47-
.to_edge()
48-
.partition()
46+
.to_edge_transform_and_lower()
4947
.check_not(
5048
[
5149
"executorch_exir_dialectes_edge__ops_aten_convolution_default",

0 commit comments

Comments
 (0)