Skip to content

Commit

Permalink
[TorchFX] Refines for ExecuTorch OpenVINO backend integration (#3270)
Browse files Browse the repository at this point in the history
### Changes
Refines for ExecuTorch OpenVINO backend integration

### Reason for changes

To enable the OpenVINOQuantizer and quantize_pt2e exectutorch
integration
### Related tickets
  • Loading branch information
daniil-lyakhov authored Feb 12, 2025
1 parent 99f0c44 commit 77ef40c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion nncf/experimental/torch/fx/quantization/quantize_pt2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def quantize_pt2e(
model = deepcopy(model)

_fuse_conv_bn_(model)
if isinstance(quantizer, OpenVINOQuantizer):
if isinstance(quantizer, OpenVINOQuantizer) or hasattr(quantizer, "get_nncf_quantization_setup"):
quantizer = OpenVINOQuantizerAdapter(quantizer)
else:
quantizer = TorchAOQuantizerAdapter(quantizer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ def transform_prior_quantization(self, model: torch.fx.GraphModule) -> torch.fx.
return self._quantizer.transform_for_annotation(model)

def get_quantization_setup(self, model: torch.fx.GraphModule, nncf_graph: NNCFGraph) -> SingleConfigQuantizerSetup:
return self._quantizer.get_quantization_setup(model, nncf_graph)
return self._quantizer.get_nncf_quantization_setup(model, nncf_graph)
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,15 @@ def __init__(
quantizer_propagation_rule=quantizer_propagation_rule,
)

def get_quantization_setup(self, model: torch.fx.GraphModule, nncf_graph: NNCFGraph) -> SingleConfigQuantizerSetup:
def get_nncf_quantization_setup(
self, model: torch.fx.GraphModule, nncf_graph: NNCFGraph
) -> SingleConfigQuantizerSetup:
self._min_max_algo._set_backend_entity(model)
return self._min_max_algo.find_quantization_setup(model, nncf_graph)

def annotate(self, model: torch.fx.GraphModule) -> torch.fx.GraphModule:
nncf_graph = GraphConverter.create_nncf_graph(model)
quantization_setup = self.get_quantization_setup(model, nncf_graph)
quantization_setup = self.get_nncf_quantization_setup(model, nncf_graph)

graph = model.graph
node_vs_torch_annotation = defaultdict(TorchAOQuantizationAnnotation)
Expand Down

0 comments on commit 77ef40c

Please sign in to comment.