OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[PT FE] Allow setting kwargs for tracing in TS decoder (#28328)
Maxim Vafincacc03291ef8
diff --git a/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py b/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.pyindex 37b938491a6..1006666374e 100644--- a/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py+++ b/src/bindings/python/src/openvino/frontend/pytorch/ts_decoder.py@@ -38,6 +38,7 @@ class TorchScriptPythonDecoder(Decoder):skip_freeze=False,constant_cache=None,module_extensions=None,+ trace_kwargs=None,):super().__init__()# We store every decoder created by this decoder so that all them are not deleted until the first decoder is deleted@@ -57,7 +58,7 @@ class TorchScriptPythonDecoder(Decoder):self.config = pt_module.config.to_dict()try:pt_module = self._get_scripted_model(- pt_module, example_input, skip_freeze)+ pt_module, example_input, skip_freeze, trace_kwargs)except Exception as e:if example_input is not None:msg = "tracing"@@ -109,7 +110,7 @@ class TorchScriptPythonDecoder(Decoder):preserved_attributes.append(name)return preserved_attributes- def _get_scripted_model(self, pt_module, example_inputs=None, skip_freeze=False):+ def _get_scripted_model(self, pt_module, example_inputs=None, skip_freeze=False, trace_kwargs=None):freeze_by_default = Falseif isinstance(pt_module, torch.nn.Module):pt_module.eval()@@ -154,9 +155,11 @@ class TorchScriptPythonDecoder(Decoder):quantized.unpatch_quantized(pt_module)patched = False+ if trace_kwargs is None:+ trace_kwargs = {}try:scripted = torch.jit.trace(- pt_module, **input_parameters, strict=False)+ pt_module, **input_parameters, strict=False, **trace_kwargs)finally:if patched:quantized.unpatch_quantized(pt_module)