OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[Layer tests] Remove legacy code and use of deprecated modules (#30076)
Roman Kazantsev06a09d252e94
diff --git a/tests/layer_tests/common/layer_utils.py b/tests/layer_tests/common/layer_utils.pyindex ec817b925a2..e4826d7d8d3 100644--- a/tests/layer_tests/common/layer_utils.py+++ b/tests/layer_tests/common/layer_utils.py@@ -5,7 +5,7 @@ import subprocessimport sysfrom common.utils.multiprocessing_utils import multiprocessing_run-from openvino.runtime import Core, get_version as ie2_get_version+from openvino import Core, get_version as ie2_get_version# Not all layer tests use openvino_tokenizerstry:diff --git a/tests/layer_tests/common/mo_convert_test_class.py b/tests/layer_tests/common/mo_convert_test_class.pyindex 3cc3160a252..b09514a02d5 100644--- a/tests/layer_tests/common/mo_convert_test_class.py+++ b/tests/layer_tests/common/mo_convert_test_class.py@@ -37,22 +37,14 @@ class CommonMOConvertTest:model_name = kwargs['model_name']del kwargs['output_dir']del kwargs['model_name']- if 'use_legacy_frontend' in kwargs or 'use_convert_model_from_mo' in kwargs:- from openvino.tools.mo import convert_model as legacy_convert_model- from openvino.runtime import serialize- if 'use_convert_model_from_mo' in kwargs:- del kwargs['use_convert_model_from_mo']- model = legacy_convert_model(**kwargs)- serialize(model, str(Path(output_dir, model_name + '.xml')))- else:- from openvino import convert_model, save_model- # ovc.convert_model does not have 'compress_to_fp16' arg, it's moved into save model- compress_to_fp16 = True- if 'compress_to_fp16' in kwargs:- compress_to_fp16 = kwargs['compress_to_fp16']- del kwargs['compress_to_fp16']- model = convert_model(**kwargs)- save_model(model, str(Path(output_dir, model_name + '.xml')), compress_to_fp16)+ from openvino import convert_model, save_model+ # ovc.convert_model does not have 'compress_to_fp16' arg, it's moved into save model+ compress_to_fp16 = True+ if 'compress_to_fp16' in kwargs:+ compress_to_fp16 = kwargs['compress_to_fp16']+ del kwargs['compress_to_fp16']+ model = convert_model(**kwargs)+ save_model(model, str(Path(output_dir, model_name + '.xml')), compress_to_fp16)def _test(self, temp_dir, test_params, ref_params):"""diff --git a/tests/layer_tests/common/utils/common_utils.py b/tests/layer_tests/common/utils/common_utils.pyindex 5e3a73ffedb..3345f642719 100644--- a/tests/layer_tests/common/utils/common_utils.py+++ b/tests/layer_tests/common/utils/common_utils.py@@ -37,27 +37,20 @@ def generate_ir(coverage=False, **kwargs):def generate_ir_python_api(coverage=False, **kwargs):out_dir = kwargs['output_dir'] + os.sep + "model.xml"- if 'use_legacy_frontend' in kwargs and kwargs['use_legacy_frontend']:- from openvino.runtime import serialize- from openvino.tools.mo import convert_model+ from openvino import convert_model, save_model- ov_model = convert_model(**kwargs)- serialize(ov_model, out_dir)- else:- from openvino import convert_model, save_model-- # cleanup parameters for convert- if 'output_dir' in kwargs:- del kwargs['output_dir']+ # cleanup parameters for convert+ if 'output_dir' in kwargs:+ del kwargs['output_dir']- compress_to_fp16 = False- if 'compress_to_fp16' in kwargs:- # TODO 132871: fix error with no tensor name in case of compression- # compress_to_fp16 = kwargs['compress_to_fp16']- del kwargs['compress_to_fp16']+ compress_to_fp16 = False+ if 'compress_to_fp16' in kwargs:+ # TODO 132871: fix error with no tensor name in case of compression+ # compress_to_fp16 = kwargs['compress_to_fp16']+ del kwargs['compress_to_fp16']- ov_model = convert_model(**kwargs)- save_model(ov_model, out_dir, compress_to_fp16)+ ov_model = convert_model(**kwargs)+ save_model(ov_model, out_dir, compress_to_fp16)return 0, ""diff --git a/tests/layer_tests/jax_tests/jax_layer_test_class.py b/tests/layer_tests/jax_tests/jax_layer_test_class.pyindex b99211aed3f..8b006e28321 100644--- a/tests/layer_tests/jax_tests/jax_layer_test_class.py+++ b/tests/layer_tests/jax_tests/jax_layer_test_class.py@@ -7,7 +7,7 @@ import numpy as npimport osfrom common.constants import test_device, test_precisionfrom copy import deepcopy-from openvino.runtime import Core+from openvino import Coreclass JaxLayerTest:diff --git a/tests/layer_tests/ovc_python_api_tests/test_complex_params.py b/tests/layer_tests/ovc_python_api_tests/test_complex_params.pyindex 282970dc0b0..f1b166b8534 100644--- a/tests/layer_tests/ovc_python_api_tests/test_complex_params.py+++ b/tests/layer_tests/ovc_python_api_tests/test_complex_params.py@@ -6,9 +6,9 @@ import tempfileimport unittestimport numpy as np-import openvino.runtime as ov+import openvino as ovimport pytest-from openvino.runtime import PartialShape, Type, Dimension+from openvino import PartialShape, Type, Dimensionfrom common.mo_convert_test_class import CommonMOConvertTestfrom common.utils.tf_utils import save_to_pb@@ -140,8 +140,8 @@ class TestComplexParams(CommonMOConvertTest):@staticmethoddef create_ref_graph_with_comma_in_names():- from openvino.runtime.opset12 import relu, concat- from openvino.runtime.op import Parameter+ from openvino.opset12 import relu, concat+ from openvino.op import Parameterimport openvino as ovparameter1 = Parameter(ov.Type.f32, ov.Shape([1, 3, 2, 2]))diff --git a/tests/layer_tests/ovc_python_api_tests/test_extensions.py b/tests/layer_tests/ovc_python_api_tests/test_extensions.pyindex fd19ce842f2..c16916a81b2 100644--- a/tests/layer_tests/ovc_python_api_tests/test_extensions.py+++ b/tests/layer_tests/ovc_python_api_tests/test_extensions.py@@ -7,8 +7,8 @@ import numpy as npfrom common.mo_convert_test_class import CommonMOConvertTestfrom common.onnx_layer_test_class import save_to_onnx-import openvino.runtime as ov-from openvino.runtime import PartialShape, Model+import openvino as ov+from openvino import PartialShape, Modelclass TestExtensions(CommonMOConvertTest):@@ -57,7 +57,7 @@ class TestExtensions(CommonMOConvertTest):# replaces LeakyRelu with Relufrom openvino.frontend import ConversionExtensionfrom openvino.frontend import NodeContext- import openvino.runtime.opset8 as ops+ import openvino.opset8 as opsdef custom_converter(node: NodeContext):input = node.get_input(0)@@ -70,7 +70,7 @@ class TestExtensions(CommonMOConvertTest):# replaces Elu with Sigmoidfrom openvino.frontend import ConversionExtensionfrom openvino.frontend import NodeContext- import openvino.runtime.opset8 as ops+ import openvino.opset8 as opsdef custom_converter(node: NodeContext):input = node.get_input(0)diff --git a/tests/layer_tests/ovc_python_api_tests/test_onnx.py b/tests/layer_tests/ovc_python_api_tests/test_onnx.pyindex 521f5df0ffb..77e80b188e9 100644--- a/tests/layer_tests/ovc_python_api_tests/test_onnx.py+++ b/tests/layer_tests/ovc_python_api_tests/test_onnx.py@@ -6,9 +6,9 @@ import tempfileimport unittestimport numpy as np-import openvino.runtime as ov+import openvino as ovimport pytest-from openvino.runtime import Model+from openvino import Modelfrom openvino.test_utils import compare_functionsfrom common.mo_convert_test_class import CommonMOConvertTestdiff --git a/tests/layer_tests/ovc_python_api_tests/test_ovc_cli_tool.py b/tests/layer_tests/ovc_python_api_tests/test_ovc_cli_tool.pyindex 027087c8f98..8a2716e9f3d 100644--- a/tests/layer_tests/ovc_python_api_tests/test_ovc_cli_tool.py+++ b/tests/layer_tests/ovc_python_api_tests/test_ovc_cli_tool.py@@ -9,8 +9,8 @@ import unittestfrom pathlib import Pathimport numpy as np-import openvino.runtime as ov-from openvino.runtime import PartialShape, Model+import openvino as ov+from openvino import PartialShape, Modelfrom openvino.test_utils import compare_functionsfrom openvino.tools.ovc import ovc@@ -112,7 +112,7 @@ class TestOVCTool(unittest.TestCase):def test_ovc_tool(self):- from openvino.runtime import Core+ from openvino import Coremodel_path = self.create_tf_model(self.tmp_dir)@@ -127,7 +127,7 @@ class TestOVCTool(unittest.TestCase):assert flag, msgdef test_ovc_tool_output_dir(self):- from openvino.runtime import Core+ from openvino import Coremodel_path = self.create_tf_model(self.tmp_dir)@@ -146,7 +146,7 @@ class TestOVCTool(unittest.TestCase):'Ticket: 152216')def test_ovc_tool_saved_model_dir(self):- from openvino.runtime import Core+ from openvino import Corecore = Core()model_dir, ref_model = self.create_tf_saved_model_dir(self.tmp_dir)@@ -163,7 +163,7 @@ class TestOVCTool(unittest.TestCase):'Ticket: 152216')def test_ovc_tool_saved_model_dir_with_sep_at_path_end(self):- from openvino.runtime import Core+ from openvino import Corecore = Core()model_dir, ref_model = self.create_tf_saved_model_dir(self.tmp_dir)@@ -180,7 +180,7 @@ class TestOVCTool(unittest.TestCase):'Ticket: 152216')def test_ovc_tool_non_existng_output_dir(self):- from openvino.runtime import Core+ from openvino import Corecore = Core()model_dir, ref_model = self.create_tf_saved_model_dir(self.tmp_dir)@@ -197,7 +197,7 @@ class TestOVCTool(unittest.TestCase):'Ticket: 152216')def test_ovc_tool_verbose(self):- from openvino.runtime import Core+ from openvino import Corecore = Core()model_dir, ref_model = self.create_tf_saved_model_dir(self.tmp_dir)diff --git a/tests/layer_tests/ovc_python_api_tests/test_paddle.py b/tests/layer_tests/ovc_python_api_tests/test_paddle.pyindex 6a3a5f5f836..c7c4d0843c7 100644--- a/tests/layer_tests/ovc_python_api_tests/test_paddle.py+++ b/tests/layer_tests/ovc_python_api_tests/test_paddle.py@@ -5,9 +5,9 @@ import tempfileimport unittestimport numpy as np-import openvino.runtime as ov+import openvino as ovimport pytest-from openvino.runtime import PartialShape, Model+from openvino import PartialShape, Modelfrom openvino.test_utils import compare_functionsfrom common.mo_convert_test_class import CommonMOConvertTestdiff --git a/tests/layer_tests/ovc_python_api_tests/test_pytorch.py b/tests/layer_tests/ovc_python_api_tests/test_pytorch.pyindex 365fc883a05..f6440d924fc 100644--- a/tests/layer_tests/ovc_python_api_tests/test_pytorch.py+++ b/tests/layer_tests/ovc_python_api_tests/test_pytorch.py@@ -11,8 +11,8 @@ import pytestimport torchfrom common.mo_convert_test_class import CommonMOConvertTest-import openvino.runtime as ov-from openvino.runtime import PartialShape, Dimension, Model, Type+import openvino as ov+from openvino import PartialShape, Dimension, Model, Typeclass MyTorchOp(torch.autograd.Function):diff --git a/tests/layer_tests/ovc_python_api_tests/test_tf.py b/tests/layer_tests/ovc_python_api_tests/test_tf.pyindex d1a875751da..d31a7e98315 100644--- a/tests/layer_tests/ovc_python_api_tests/test_tf.py+++ b/tests/layer_tests/ovc_python_api_tests/test_tf.py@@ -1,7 +1,7 @@# Copyright (C) 2018-2025 Intel Corporation# SPDX-License-Identifier: Apache-2.0import numpy as np-import openvino.runtime as ov+import openvino as ovimport osimport sysimport pytest@@ -12,7 +12,7 @@ from common import constantsfrom common.layer_test_class import CommonLayerTestfrom common.mo_convert_test_class import CommonMOConvertTestfrom common.utils.tf_utils import save_to_pb-from openvino.runtime import PartialShape, Model, Dimension+from openvino import PartialShape, Model, Dimensionfrom openvino.test_utils import compare_functionsfrom pathlib import Path@@ -747,7 +747,7 @@ class TestMoConvertTF(CommonMOConvertTest):def test_zero_copy(self, ie_device, precision, ir_version, temp_dir):from openvino.tools.ovc import convert_model- from openvino.runtime import compile_model+ from openvino import compile_modelclass LayerModel(tf.Module):def __init__(self):super(LayerModel, self).__init__()@@ -794,7 +794,7 @@ class TestMoConvertTF(CommonMOConvertTest):def test_turn_off_sharing(self, ie_device, precision, ir_version, temp_dir):from openvino.tools.ovc import convert_model- from openvino.runtime import compile_model+ from openvino import compile_modelclass LayerModel(tf.Module):def __init__(self):super(LayerModel, self).__init__()@@ -845,7 +845,7 @@ class TestMoConvertTF(CommonMOConvertTest):tf.compat.v1.reset_default_graph()from openvino.tools.ovc import convert_model- from openvino.runtime import compile_model+ from openvino import compile_modelimport gcwith tf.compat.v1.Session() as sess:@@ -896,7 +896,7 @@ class TestMoConvertTF(CommonMOConvertTest):tf.compat.v1.reset_default_graph()from openvino.tools.ovc import convert_model- from openvino.runtime import compile_model+ from openvino import compile_modelclass LayerModel(tf.Module):def __init__(self):@@ -935,7 +935,7 @@ class TestMoConvertTF(CommonMOConvertTest):tf.compat.v1.reset_default_graph()from openvino.tools.ovc import convert_model- from openvino.runtime import compile_model+ from openvino import compile_modelclass LayerModel(tf.Module):def __init__(self):diff --git a/tests/layer_tests/py_frontend_tests/test_paddle_frontend.py b/tests/layer_tests/py_frontend_tests/test_paddle_frontend.pyindex a4793280931..107692db53b 100644--- a/tests/layer_tests/py_frontend_tests/test_paddle_frontend.py+++ b/tests/layer_tests/py_frontend_tests/test_paddle_frontend.py@@ -15,7 +15,7 @@ import sysimport pytestfrom openvino.frontend import FrontEndManager-from openvino.runtime import shutdown+from openvino import shutdownPADDLE_FRONTEND_NAME = "paddle"paddle_relu6_model_basename = "relu6"@@ -69,7 +69,7 @@ def test_paddle_conversion_extension():# use specific (openvino.frontend.onnx) import herefrom openvino.frontend.paddle import ConversionExtensionfrom openvino.frontend import NodeContext- import openvino.runtime.opset8 as ops+ import openvino.opset8 as opsfe = fem.load_by_model(paddle_relu6_model_filename)assert fe@@ -99,7 +99,7 @@ def test_op_extension_via_paddle_extension_set_attrs_values():# use specific (openvino.frontend.paddle) import herefrom openvino.frontend.paddle import OpExtension- from openvino.runtime import Core+ from openvino import Coreie = Core()@@ -120,7 +120,7 @@ def test_op_extension_via_frontend_extension_set_attrs_values():# use common (openvino.frontend) import herefrom openvino.frontend import OpExtension- from openvino.runtime import Core+ from openvino import Coreie = Core()# check the model is validdiff --git a/tests/layer_tests/pytorch_tests/pytorch_layer_test_class.py b/tests/layer_tests/pytorch_tests/pytorch_layer_test_class.pyindex 466842603fa..f3c7f8d8f6f 100644--- a/tests/layer_tests/pytorch_tests/pytorch_layer_test_class.py+++ b/tests/layer_tests/pytorch_tests/pytorch_layer_test_class.py@@ -13,7 +13,7 @@ import numpy as npfrom common.constants import test_device, test_precisionfrom openvino.frontend.pytorch.ts_decoder import TorchScriptPythonDecoderfrom openvino.frontend import FrontEndManager-from openvino.runtime import Core, Type, PartialShape+from openvino import Core, Type, PartialShapeimport openvino.properties.hint as hintslogging.basicConfig(level=logging.DEBUG)diff --git a/tests/layer_tests/tensorflow2_keras_tests/conftest.py b/tests/layer_tests/tensorflow2_keras_tests/conftest.pyindex 39816f8d2e8..130c19fdd2c 100644--- a/tests/layer_tests/tensorflow2_keras_tests/conftest.py+++ b/tests/layer_tests/tensorflow2_keras_tests/conftest.py@@ -19,7 +19,7 @@ def pytest_generate_tests(metafunc):@pytest.fixture(scope='session', autouse=True)def rename_tf_fe_libs(request):try:- import openvino.runtime as rt+ import openvino as rt# path below is built considering the use of wheelsopenvino_lib_path = Path(rt.__file__).parent.parent / 'libs'except ImportError as err:diff --git a/tests/layer_tests/tensorflow_tests/conftest.py b/tests/layer_tests/tensorflow_tests/conftest.pyindex fe2c0b6916f..9fb46cc954c 100644--- a/tests/layer_tests/tensorflow_tests/conftest.py+++ b/tests/layer_tests/tensorflow_tests/conftest.py@@ -19,7 +19,7 @@ def pytest_generate_tests(metafunc):@pytest.fixture(scope='session', autouse=True)def rename_tf_fe_libs(request):try:- import openvino.runtime as rt+ import openvino as rt# path below is built considering the use of wheelsopenvino_lib_path = Path(rt.__file__).parent.parent / 'libs'except ImportError as err:diff --git a/tests/model_hub_tests/models_hub_common/test_convert_model.py b/tests/model_hub_tests/models_hub_common/test_convert_model.pyindex 192f32d8474..65a4f39ab3f 100644--- a/tests/model_hub_tests/models_hub_common/test_convert_model.py+++ b/tests/model_hub_tests/models_hub_common/test_convert_model.py@@ -11,7 +11,7 @@ except:from models_hub_common.multiprocessing_utils import multiprocessing_runfrom models_hub_common.utils import compare_two_tensorsfrom openvino import convert_model-from openvino.runtime import Core+from openvino import Core# set seed to have deterministic input data generation# to avoid sporadic issues in inference resultsdiff --git a/tests/model_hub_tests/models_hub_common/test_performance_model.py b/tests/model_hub_tests/models_hub_common/test_performance_model.pyindex 7cbbaec6327..95c4c19ac6c 100644--- a/tests/model_hub_tests/models_hub_common/test_performance_model.py+++ b/tests/model_hub_tests/models_hub_common/test_performance_model.py@@ -7,7 +7,7 @@ import tracebackimport timefrom enum import Enumimport pytest-from openvino.runtime.utils.types import openvino_to_numpy_types_map+from openvino.utils.types import openvino_to_numpy_types_mapimport models_hub_common.utils as utilsimport models_hub_common.constants as const@@ -16,7 +16,7 @@ import numpy as npimport openvino as ovimport pytestfrom models_hub_common.multiprocessing_utils import multiprocessing_run-from openvino.runtime.utils.types import openvino_to_numpy_types_map+from openvino.utils.types import openvino_to_numpy_types_map# set seed to have deterministic input data generation# to avoid sporadic issues in inference resultsdiff --git a/tests/model_hub_tests/pytorch/test_aliked.py b/tests/model_hub_tests/pytorch/test_aliked.pyindex 87c18303c91..7536f91d2e7 100644--- a/tests/model_hub_tests/pytorch/test_aliked.py+++ b/tests/model_hub_tests/pytorch/test_aliked.py@@ -8,7 +8,7 @@ import sysimport tempfileimport numpy as np-import openvino.runtime.opset12 as ops+import openvino.opset12 as opsimport pytestimport torchfrom openvino import convert_model, Model, PartialShape, Typediff --git a/tests/samples_tests/smoke_tests/common/samples_common_test_class.py b/tests/samples_tests/smoke_tests/common/samples_common_test_class.pyindex c5a87251425..7860d7a5be7 100644--- a/tests/samples_tests/smoke_tests/common/samples_common_test_class.py+++ b/tests/samples_tests/smoke_tests/common/samples_common_test_class.py@@ -26,7 +26,7 @@ import zipfileimport logging as logfrom common.common_utils import shellfrom shutil import which-import openvino.runtime as ov+import openvino as ovlog.basicConfig(format="[ %(levelname)s ] %(message)s", level=log.INFO, stream=sys.stdout)@@ -79,7 +79,7 @@ def download(test_data_dir, file_path):def prepend(cache, inp='', model='', tmp_path=None):test_data_dir = cache.mkdir('test_data')if model:- if type(model) is ov.ie_api.Model:+ if type(model) is ov.Model:model_sv_path = tmp_path / "model_with_4bit_input.xml"ov.save_model(model, model_sv_path)model = '-m', model_sv_pathdiff --git a/tests/samples_tests/smoke_tests/test_benchmark_app.py b/tests/samples_tests/smoke_tests/test_benchmark_app.pyindex 463f2184624..4699d6276d0 100755--- a/tests/samples_tests/smoke_tests/test_benchmark_app.py+++ b/tests/samples_tests/smoke_tests/test_benchmark_app.py@@ -17,8 +17,8 @@ import numpy as npimport pathlibimport pytestfrom common.samples_common_test_class import get_devices, get_cmd_output, prepend-from openvino.runtime import opset8 as opset-import openvino.runtime as ov+from openvino import opset8 as opset+import openvino as ovdef get_executable(sample_language):executable = 'benchmark_app'