Fix of confusing logs in convert_model(). (#19157)
* Added check that nncf was imported. * Added check that nncf was imported in MO. * Added check that nncf was imported in MO. * Apply suggestions from code review Co-authored-by: Sergey Lyalin <sergey.lyalin@intel.com> * Removed not needed import. * Pylint fix. --------- Co-authored-by: Sergey Lyalin <sergey.lyalin@intel.com>
This commit is contained in:
parent
014691de4c
commit
cabb40638a
@ -2,15 +2,13 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import logging as log
|
||||
import sys
|
||||
|
||||
import numpy as np
|
||||
# pylint: disable=no-name-in-module,import-error
|
||||
from openvino.runtime import Tensor, Type, PartialShape
|
||||
from openvino.runtime.utils.types import get_element_type_str
|
||||
from openvino.runtime import Tensor, PartialShape
|
||||
|
||||
from openvino.tools.mo.utils.cli_parser import input_to_input_cut_info, input_shape_to_input_cut_info
|
||||
from openvino.tools.mo.utils.error import Error
|
||||
from openvino.tools.mo.moc_frontend.shape_utils import get_static_shape
|
||||
|
||||
|
||||
def get_pytorch_decoder(model, input_shape, example_inputs, args):
|
||||
@ -20,14 +18,14 @@ def get_pytorch_decoder(model, input_shape, example_inputs, args):
|
||||
log.error("PyTorch frontend loading failed")
|
||||
raise e
|
||||
try:
|
||||
import nncf
|
||||
from nncf.torch.nncf_network import NNCFNetwork
|
||||
if 'nncf' in sys.modules:
|
||||
from nncf.torch.nncf_network import NNCFNetwork # pylint: disable=undefined-variable
|
||||
from packaging import version
|
||||
|
||||
if isinstance(model, NNCFNetwork):
|
||||
if version.parse(nncf.__version__) < version.parse("2.6"):
|
||||
if version.parse(nncf.__version__) < version.parse("2.6"): # pylint: disable=undefined-variable
|
||||
raise RuntimeError(
|
||||
"NNCF models produced by nncf<2.6 are not supported directly. Please export to ONNX first.")
|
||||
"NNCF models produced by nncf<2.6 are not supported directly. Please upgrade nncf or export to ONNX first.")
|
||||
except:
|
||||
pass
|
||||
inputs = prepare_torch_inputs(example_inputs)
|
||||
|
@ -2,15 +2,13 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import logging as log
|
||||
import sys
|
||||
|
||||
import numpy as np
|
||||
# pylint: disable=no-name-in-module,import-error
|
||||
from openvino.runtime import Tensor, Type, PartialShape
|
||||
from openvino.runtime.utils.types import get_element_type_str
|
||||
from openvino.runtime import Tensor, PartialShape
|
||||
|
||||
from openvino.tools.ovc.cli_parser import input_to_input_cut_info
|
||||
from openvino.tools.ovc.error import Error
|
||||
from openvino.tools.ovc.moc_frontend.shape_utils import get_static_shape
|
||||
|
||||
|
||||
def get_pytorch_decoder(model, example_inputs, args):
|
||||
@ -20,14 +18,14 @@ def get_pytorch_decoder(model, example_inputs, args):
|
||||
log.error("PyTorch frontend loading failed")
|
||||
raise e
|
||||
try:
|
||||
import nncf
|
||||
from nncf.torch.nncf_network import NNCFNetwork
|
||||
if 'nncf' in sys.modules:
|
||||
from nncf.torch.nncf_network import NNCFNetwork # pylint: disable=undefined-variable
|
||||
from packaging import version
|
||||
|
||||
if isinstance(model, NNCFNetwork):
|
||||
if version.parse(nncf.__version__) <= version.parse("2.6"):
|
||||
if version.parse(nncf.__version__) <= version.parse("2.6"): # pylint: disable=undefined-variable
|
||||
raise RuntimeError(
|
||||
"NNCF models produced by nncf<2.6 are not supported directly. Please export to ONNX first.")
|
||||
"NNCF models produced by nncf<2.6 are not supported directly. Please upgrade nncf or export to ONNX first.")
|
||||
except:
|
||||
pass
|
||||
inputs = prepare_torch_inputs(example_inputs)
|
||||
|
Loading…
Reference in New Issue
Block a user