[MO] Fix issue in nncf version verification (#19347)
* Return deleted nncf import * Remove try-except, it hides exception * Get version visout importing nncf module
This commit is contained in:
parent
1d0d00bf22
commit
e11e8ede1b
@ -17,17 +17,20 @@ def get_pytorch_decoder(model, input_shape, example_inputs, args):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.error("PyTorch frontend loading failed")
|
log.error("PyTorch frontend loading failed")
|
||||||
raise e
|
raise e
|
||||||
try:
|
if 'nncf' in sys.modules:
|
||||||
if 'nncf' in sys.modules:
|
is_good_version = True
|
||||||
from nncf.torch.nncf_network import NNCFNetwork # pylint: disable=undefined-variable
|
try:
|
||||||
from packaging import version
|
from nncf.torch.nncf_network import NNCFNetwork
|
||||||
|
|
||||||
if isinstance(model, NNCFNetwork):
|
if isinstance(model, NNCFNetwork):
|
||||||
if version.parse(nncf.__version__) < version.parse("2.6"): # pylint: disable=undefined-variable
|
from packaging import version
|
||||||
raise RuntimeError(
|
if version.parse(sys.modules['nncf'].__version__) < version.parse("2.6"):
|
||||||
"NNCF models produced by nncf<2.6 are not supported directly. Please upgrade nncf or export to ONNX first.")
|
is_good_version = False
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
if not is_good_version:
|
||||||
|
raise RuntimeError(
|
||||||
|
"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)
|
inputs = prepare_torch_inputs(example_inputs)
|
||||||
decoder = TorchScriptPythonDecoder(model, example_input=inputs, shared_memory=args.get("share_weights", True))
|
decoder = TorchScriptPythonDecoder(model, example_input=inputs, shared_memory=args.get("share_weights", True))
|
||||||
args['input_model'] = decoder
|
args['input_model'] = decoder
|
||||||
|
@ -17,17 +17,20 @@ def get_pytorch_decoder(model, example_inputs, args):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.error("PyTorch frontend loading failed")
|
log.error("PyTorch frontend loading failed")
|
||||||
raise e
|
raise e
|
||||||
try:
|
if 'nncf' in sys.modules:
|
||||||
if 'nncf' in sys.modules:
|
is_good_version = True
|
||||||
from nncf.torch.nncf_network import NNCFNetwork # pylint: disable=undefined-variable
|
try:
|
||||||
from packaging import version
|
from nncf.torch.nncf_network import NNCFNetwork
|
||||||
|
|
||||||
if isinstance(model, NNCFNetwork):
|
if isinstance(model, NNCFNetwork):
|
||||||
if version.parse(nncf.__version__) <= version.parse("2.6"): # pylint: disable=undefined-variable
|
from packaging import version
|
||||||
raise RuntimeError(
|
if version.parse(sys.modules['nncf'].__version__) < version.parse("2.6"):
|
||||||
"NNCF models produced by nncf<2.6 are not supported directly. Please upgrade nncf or export to ONNX first.")
|
is_good_version = False
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
if not is_good_version:
|
||||||
|
raise RuntimeError(
|
||||||
|
"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)
|
inputs = prepare_torch_inputs(example_inputs)
|
||||||
decoder = TorchScriptPythonDecoder(model, example_input=inputs, shared_memory=args.get("share_weights", True))
|
decoder = TorchScriptPythonDecoder(model, example_input=inputs, shared_memory=args.get("share_weights", True))
|
||||||
args['input_model'] = decoder
|
args['input_model'] = decoder
|
||||||
|
Loading…
Reference in New Issue
Block a user