Skip to content

Commit c47ded6

Browse files
authored
Fix issue with older torch (openvinotoolkit#22592)
1 parent eb9228c commit c47ded6

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

tools/ovc/openvino/tools/ovc/convert_impl.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def check_model_object(argv):
190190
return "tf"
191191
if 'torch' in sys.modules:
192192
import torch
193-
if isinstance(model, (torch.nn.Module, torch.jit.ScriptFunction, torch.export.ExportedProgram)):
193+
if isinstance(model, (torch.nn.Module, torch.jit.ScriptFunction)) or (hasattr(torch, "export") and isinstance(model, (torch.export.ExportedProgram))):
194194
return "pytorch"
195195
try:
196196
from openvino.frontend.pytorch.ts_decoder import TorchScriptPythonDecoder

tools/ovc/openvino/tools/ovc/moc_frontend/pytorch_frontend_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def get_pytorch_decoder(model, example_inputs, args):
3434
"NNCF models produced by nncf<2.6 are not supported directly. Please upgrade nncf or export to ONNX first.")
3535
inputs = prepare_torch_inputs(example_inputs)
3636
if not isinstance(model, (TorchScriptPythonDecoder, TorchFXPythonDecoder)):
37-
if isinstance(model, torch.export.ExportedProgram):
37+
if hasattr(torch, "export") and isinstance(model, (torch.export.ExportedProgram)):
3838
raise RuntimeError("Models received from torch.export are not yet supported by convert_model.")
3939
else:
4040
decoder = TorchScriptPythonDecoder(model, example_input=inputs, shared_memory=args.get("share_weights", True))

0 commit comments

Comments
 (0)