Skip to content

Commit 4bb03ff

Browse files
mcr229facebook-github-bot
authored andcommitted
fix quantized ic3/ic4/edsr examples (#574)
Summary: Pull Request resolved: #574 The fix for quantized ic3/ic4/edsr requires runnign the pass `convert_scalars_to_attrs` after capturing_pre_autograd_graph and before preparing and converting We add using this pass in the examples to fix the quantized ic3/ic4/edsr Reviewed By: digantdesai, guangy10 Differential Revision: D49850155 fbshipit-source-id: 36dca32611a53e27582c7a34eea178a65dc384f7
1 parent 81a302a commit 4bb03ff

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

examples/xnnpack/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ class XNNPackOptions(object):
1818
"add": XNNPackOptions(True, True),
1919
"add_mul": XNNPackOptions(True, True),
2020
"dl3": XNNPackOptions(True, True),
21-
"ic3": XNNPackOptions(True, False),
22-
"ic4": XNNPackOptions(True, False),
21+
"ic3": XNNPackOptions(True, True),
22+
"ic4": XNNPackOptions(True, True),
2323
"mv2": XNNPackOptions(True, True),
2424
"mv3": XNNPackOptions(True, True),
2525
"resnet18": XNNPackOptions(True, True),
2626
"resnet50": XNNPackOptions(True, True),
2727
"vit": XNNPackOptions(False, True),
2828
"w2l": XNNPackOptions(False, True),
29-
"edsr": XNNPackOptions(True, False),
29+
"edsr": XNNPackOptions(True, True),
3030
"mobilebert": XNNPackOptions(True, False),
3131
}
3232

examples/xnnpack/aot_compiler.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
from executorch.backends.xnnpack.partition.xnnpack_partitioner import XnnpackPartitioner
1515
from executorch.exir import EdgeCompileConfig
16+
from torch.ao.quantization.quantizer.xnnpack_quantizer_utils import (
17+
convert_scalars_to_attrs,
18+
)
1619

1720
from ..models import MODEL_NAME_TO_MODEL
1821
from ..models.model_factory import EagerModelFactory
@@ -75,6 +78,8 @@
7578

7679
if args.quantize:
7780
logging.info("Quantizing Model...")
81+
# TODO(T165162973): This pass shall eventually be folded into quantizer
82+
model = convert_scalars_to_attrs(model)
7883
model = quantize(model, example_inputs)
7984

8085
edge = export_to_edge(

0 commit comments

Comments
 (0)