[MO] Raise exception for older nncf models (#18890)

* [PT FE] Call strip() for older nncf models

* Raise excception on older nncf models

* Update legacy mo too
This commit is contained in:
Maxim Vafin 2023-08-01 15:00:12 +02:00 committed by GitHub
parent 74a608592a
commit 361367393b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -19,6 +19,17 @@ def get_pytorch_decoder(model, input_shape, example_inputs, args):
except Exception as e:
log.error("PyTorch frontend loading failed")
raise e
try:
import nncf
from nncf.torch.nncf_network import NNCFNetwork
from packaging import version
if isinstance(model, NNCFNetwork):
if version.parse(nncf.__version__) < version.parse("2.6"):
raise RuntimeError(
"NNCF models produced by nncf<2.6 are not supported directly. Please export to ONNX first.")
except:
pass
inputs = prepare_torch_inputs(example_inputs, input_shape, args.get("input"), allow_none=True)
decoder = TorchScriptPythonDecoder(model, example_input=inputs)
args['input_model'] = decoder

View File

@ -19,6 +19,17 @@ def get_pytorch_decoder(model, example_inputs, args):
except Exception as e:
log.error("PyTorch frontend loading failed")
raise e
try:
import nncf
from nncf.torch.nncf_network import NNCFNetwork
from packaging import version
if isinstance(model, NNCFNetwork):
if version.parse(nncf.__version__) <= version.parse("2.6"):
raise RuntimeError(
"NNCF models produced by nncf<2.6 are not supported directly. Please export to ONNX first.")
except:
pass
inputs = prepare_torch_inputs(example_inputs, args.get("input"), allow_none=True)
decoder = TorchScriptPythonDecoder(model, example_input=inputs)
args['input_model'] = decoder