Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TorchFX] Refines for ExecuTorch OpenVINO backend integration #3270

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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