Skip to content

Commit 77ef40c

Browse files
[TorchFX] Refines for ExecuTorch OpenVINO backend integration (#3270)
### Changes Refines for ExecuTorch OpenVINO backend integration ### Reason for changes To enable the OpenVINOQuantizer and quantize_pt2e exectutorch integration ### Related tickets
1 parent 99f0c44 commit 77ef40c

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

nncf/experimental/torch/fx/quantization/quantize_pt2e.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def quantize_pt2e(
9494
model = deepcopy(model)
9595

9696
_fuse_conv_bn_(model)
97-
if isinstance(quantizer, OpenVINOQuantizer):
97+
if isinstance(quantizer, OpenVINOQuantizer) or hasattr(quantizer, "get_nncf_quantization_setup"):
9898
quantizer = OpenVINOQuantizerAdapter(quantizer)
9999
else:
100100
quantizer = TorchAOQuantizerAdapter(quantizer)

nncf/experimental/torch/fx/quantization/quantizer/openvino_adapter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ def transform_prior_quantization(self, model: torch.fx.GraphModule) -> torch.fx.
2929
return self._quantizer.transform_for_annotation(model)
3030

3131
def get_quantization_setup(self, model: torch.fx.GraphModule, nncf_graph: NNCFGraph) -> SingleConfigQuantizerSetup:
32-
return self._quantizer.get_quantization_setup(model, nncf_graph)
32+
return self._quantizer.get_nncf_quantization_setup(model, nncf_graph)

nncf/experimental/torch/fx/quantization/quantizer/openvino_quantizer.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,15 @@ def __init__(
104104
quantizer_propagation_rule=quantizer_propagation_rule,
105105
)
106106

107-
def get_quantization_setup(self, model: torch.fx.GraphModule, nncf_graph: NNCFGraph) -> SingleConfigQuantizerSetup:
107+
def get_nncf_quantization_setup(
108+
self, model: torch.fx.GraphModule, nncf_graph: NNCFGraph
109+
) -> SingleConfigQuantizerSetup:
108110
self._min_max_algo._set_backend_entity(model)
109111
return self._min_max_algo.find_quantization_setup(model, nncf_graph)
110112

111113
def annotate(self, model: torch.fx.GraphModule) -> torch.fx.GraphModule:
112114
nncf_graph = GraphConverter.create_nncf_graph(model)
113-
quantization_setup = self.get_quantization_setup(model, nncf_graph)
115+
quantization_setup = self.get_nncf_quantization_setup(model, nncf_graph)
114116

115117
graph = model.graph
116118
node_vs_torch_annotation = defaultdict(TorchAOQuantizationAnnotation)

0 commit comments

Comments
 (0)