Skip to content

Commit c70bb27

Browse files
Matthias Cremonfacebook-github-bot
authored andcommitted
Propagate dump_graphs to print quantization graphs. (#4167)
Summary: Pull Request resolved: #4167 As titled. Also fixed a pyre-fixme along the way. Differential Revision: D59438228 Reviewed By: zonglinpengmeta
1 parent 561c035 commit c70bb27

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

backends/cadence/aot/TARGETS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ python_library(
2828
"compiler.py",
2929
],
3030
deps = [
31+
"fbsource//third-party/pypi/pyre-extensions:pyre-extensions",
3132
":passes",
3233
":utils",
3334
"//caffe2:torch",

backends/cadence/aot/compiler.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@
1818
ReplaceSqueezeAndUnsqueezeWithViewPass,
1919
)
2020
from executorch.backends.cadence.aot.quantizer.fusion_pass import QuantFusion
21-
from executorch.backends.cadence.aot.quantizer.quantizer import CadenceQuantizer
21+
from executorch.backends.cadence.aot.quantizer.quantizer import (
22+
CadenceGenericQuantizer,
23+
CadenceQuantizer,
24+
)
2225
from executorch.backends.cadence.aot.utils import model_is_quantized
2326
from executorch.exir import EdgeCompileConfig, EdgeProgramManager, to_edge
27+
from pyre_extensions import assert_is_instance
2428
from torch._export import capture_pre_autograd_graph
2529
from torch.ao.quantization.pt2e.export_utils import model_is_exported
2630
from torch.ao.quantization.quantize_pt2e import convert_pt2e, prepare_pt2e
@@ -53,8 +57,10 @@ def quantize_pt2(
5357
converted_model = convert_pt2e(prepared_model)
5458

5559
# Get patterns and apply fusion of dq -> op -> q to qop
56-
# pyre-fixme[16]: Pyre doesn't get that CadenceQuantizer has a patterns attribute
57-
patterns = [q.pattern for q in quantizer.quantizers]
60+
patterns = [
61+
assert_is_instance(q, CadenceGenericQuantizer).pattern
62+
for q in quantizer.quantizers
63+
]
5864
QuantFusion(patterns)(converted_model)
5965

6066
return converted_model

0 commit comments

Comments
 (0)