Skip to content

Commit

Permalink
Fix issue with older torch (openvinotoolkit#22592)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvafin authored Feb 1, 2024
1 parent eb9228c commit c47ded6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tools/ovc/openvino/tools/ovc/convert_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def check_model_object(argv):
return "tf"
if 'torch' in sys.modules:
import torch
if isinstance(model, (torch.nn.Module, torch.jit.ScriptFunction, torch.export.ExportedProgram)):
if isinstance(model, (torch.nn.Module, torch.jit.ScriptFunction)) or (hasattr(torch, "export") and isinstance(model, (torch.export.ExportedProgram))):
return "pytorch"
try:
from openvino.frontend.pytorch.ts_decoder import TorchScriptPythonDecoder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_pytorch_decoder(model, example_inputs, args):
"NNCF models produced by nncf<2.6 are not supported directly. Please upgrade nncf or export to ONNX first.")
inputs = prepare_torch_inputs(example_inputs)
if not isinstance(model, (TorchScriptPythonDecoder, TorchFXPythonDecoder)):
if isinstance(model, torch.export.ExportedProgram):
if hasattr(torch, "export") and isinstance(model, (torch.export.ExportedProgram)):
raise RuntimeError("Models received from torch.export are not yet supported by convert_model.")
else:
decoder = TorchScriptPythonDecoder(model, example_input=inputs, shared_memory=args.get("share_weights", True))
Expand Down

0 comments on commit c47ded6

Please sign in to comment.