Skip to content

Commit 03429b6

Browse files
mcr229facebook-github-bot
authored andcommitted
remove short-term quant
Differential Revision: D48761858 fbshipit-source-id: 374766e873a9c48f5fe63851d2c603681fe0db6c
1 parent a07832d commit 03429b6

File tree

4 files changed

+11
-58
lines changed

4 files changed

+11
-58
lines changed

backends/xnnpack/test/models/mobilenet_v2.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from torchvision.models.mobilenetv2 import MobileNet_V2_Weights
1818

1919

20-
class TestXNNPACKMobileNetV2(unittest.TestCase):
20+
class TestMobileNetV2(unittest.TestCase):
2121
mv2 = models.mobilenetv2.mobilenet_v2(weights=MobileNet_V2_Weights)
2222
mv2 = mv2.eval()
2323
model_inputs = (torch.ones(1, 3, 224, 244),)
@@ -32,7 +32,7 @@ class TestXNNPACKMobileNetV2(unittest.TestCase):
3232
"executorch_exir_dialects_edge__ops_aten_convolution_default",
3333
}
3434

35-
def test_mv2_fp32(self):
35+
def test_fp32_mv2(self):
3636

3737
(
3838
Tester(self.mv2, self.model_inputs)
@@ -48,15 +48,15 @@ def test_mv2_fp32(self):
4848
.compare_outputs()
4949
)
5050

51-
def test_mv2_qs8_pt2e(self):
51+
def test_qs8_mv2(self):
5252
# Quantization fuses away batchnorm, so it is no longer in the graph
5353
ops_after_quantization = self.all_operators - {
5454
"executorch_exir_dialects_edge__ops_aten__native_batch_norm_legit_no_training_default",
5555
}
5656

5757
(
5858
Tester(self.mv2, self.model_inputs)
59-
.quantize2()
59+
.quantize()
6060
.export(Export(CaptureConfig(enable_aot=True)))
6161
.to_edge()
6262
.check(list(ops_after_quantization))

backends/xnnpack/test/models/mobilenet_v3.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from executorch.exir import CaptureConfig
1717

1818

19-
class TestXNNPACKMobileNetV3(unittest.TestCase):
19+
class TestMobileNetV3(unittest.TestCase):
2020
mv3 = models.mobilenetv3.mobilenet_v3_small(pretrained=True)
2121
mv3 = mv3.eval()
2222
model_inputs = (torch.ones(1, 3, 224, 244),)
@@ -35,7 +35,7 @@ class TestXNNPACKMobileNetV3(unittest.TestCase):
3535
"executorch_exir_dialects_edge__ops_aten_mean_dim",
3636
}
3737

38-
def test_mv3_fp32(self):
38+
def test_fp32_mv3(self):
3939
(
4040
Tester(self.mv3, self.model_inputs)
4141
.export(Export(CaptureConfig(enable_aot=True)))
@@ -50,7 +50,7 @@ def test_mv3_fp32(self):
5050
.compare_outputs()
5151
)
5252

53-
def test_mv3_qs8_pt2e(self):
53+
def test_qs8_mv3(self):
5454
ops_after_quantization = self.all_operators - {
5555
"executorch_exir_dialects_edge__ops_aten__native_batch_norm_legit_no_training_default",
5656
}
@@ -66,7 +66,7 @@ def test_mv3_qs8_pt2e(self):
6666

6767
(
6868
Tester(self.mv3, self.model_inputs)
69-
.quantize2()
69+
.quantize()
7070
.export(Export(CaptureConfig(enable_aot=True)))
7171
.to_edge()
7272
.check(list(ops_after_quantization))

backends/xnnpack/test/ops/add.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_qs8_add(self):
4646
inputs = (torch.ones(1), torch.ones(1))
4747
(
4848
Tester(self.Add(), inputs)
49-
.quantize2()
49+
.quantize()
5050
.export()
5151
.check_count({"torch.ops.aten.add.Tensor": 4})
5252
.check(["torch.ops.quantized_decomposed"])
@@ -91,7 +91,7 @@ def test_qs8_add_relu(self):
9191
inputs = (torch.randn(1, 1, 4, 4), torch.randn(1, 1, 4, 4))
9292
(
9393
Tester(self.AddRelu(), inputs)
94-
.quantize2()
94+
.quantize()
9595
.export()
9696
.check_count({"torch.ops.aten.add.Tensor": 1})
9797
.check_count({"torch.ops.aten.relu.default": 1})

backends/xnnpack/test/tester/tester.py

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,9 @@
3030
from executorch.exir.backend.partitioner import Partitioner
3131
from executorch.exir.passes.spec_prop_pass import SpecPropPass
3232

33-
from executorch.extension.pybindings.portable_lib import (
33+
from executorch.extension.pybindings.portable_lib import ( # @manual
3434
_load_for_executorch_from_buffer,
3535
)
36-
from torch.ao.quantization.backend_config import BackendConfig
37-
from torch.ao.quantization.backend_config.executorch import (
38-
get_executorch_backend_config,
39-
)
40-
from torch.ao.quantization.qconfig_mapping import (
41-
_get_symmetric_qnnpack_qconfig_mapping,
42-
QConfigMapping,
43-
)
44-
45-
from torch.ao.quantization.quantize_fx import (
46-
_convert_to_reference_decomposed_fx,
47-
prepare_fx,
48-
)
4936
from torch.ao.quantization.quantize_pt2e import convert_pt2e, prepare_pt2e
5037
from torch.ao.quantization.quantizer.quantizer import Quantizer
5138
from torch.ao.quantization.quantizer.xnnpack_quantizer import (
@@ -103,36 +90,6 @@ def register_stage(stage: Stage):
10390

10491
@register_stage
10592
class Quantize(Stage):
106-
def __init__(
107-
self,
108-
qconfig_mapping: Optional[QConfigMapping] = None,
109-
backend_config: Optional[BackendConfig] = None,
110-
):
111-
self.qconfig_mapping = (
112-
qconfig_mapping or _get_symmetric_qnnpack_qconfig_mapping()
113-
)
114-
self.backend_config = backend_config or get_executorch_backend_config()
115-
self.converted = None
116-
117-
def run(self, artifact: torch.nn.Module, inputs: Tuple[torch.Tensor]) -> None:
118-
prepared = prepare_fx(
119-
artifact, self.qconfig_mapping, inputs, backend_config=self.backend_config
120-
)
121-
self.converted = _convert_to_reference_decomposed_fx(
122-
prepared, backend_config=self.backend_config
123-
)
124-
125-
@property
126-
def artifact(self) -> torch.fx.GraphModule:
127-
return self.converted
128-
129-
@property
130-
def graph_module(self) -> str:
131-
return self.converted
132-
133-
134-
@register_stage
135-
class Quantize2(Stage):
13693
def __init__(
13794
self,
13895
quantizer: Optional[Quantizer] = None,
@@ -278,7 +235,6 @@ def __init__(
278235
self.inputs = inputs
279236
self.stages: Dict[str, Stage] = OrderedDict.fromkeys(list(_stages_.keys()))
280237
self.pipeline = {
281-
self._stage_name(Quantize2): [self._stage_name(Export)],
282238
self._stage_name(Quantize): [self._stage_name(Export)],
283239
self._stage_name(Export): [
284240
self._stage_name(ToEdge),
@@ -339,9 +295,6 @@ def quantize(self, quantize_stage: Optional[Quantize] = None):
339295
def export(self, export_stage: Optional[Export] = None):
340296
return self._run_stage(export_stage or Export(), self.inputs)
341297

342-
def quantize2(self, quantize_stage: Optional[Quantize2] = None):
343-
return self._run_stage(quantize_stage or Quantize2(), self.inputs)
344-
345298
def to_edge(self, to_edge_stage: Optional[ToEdge] = None):
346299
return self._run_stage(to_edge_stage or ToEdge())
347300

0 commit comments

Comments
 (0)