From e34a311ca5d766a429d514f4a83ae4446c91a268 Mon Sep 17 00:00:00 2001 From: Alicja Miloszewska Date: Fri, 13 Dec 2024 10:04:52 +0100 Subject: [PATCH 01/10] Move utils/ and change utils.py to utils/package_utils.py Signed-off-by: Alicja Miloszewska --- .../src/openvino/runtime/utils/__init__.py | 2 +- .../runtime/utils/broadcasting/__init__.py | 13 ++++++++++ .../runtime/utils/data_helpers/__init__.py | 8 +++---- .../data_helpers/data_dispatcher/__init__.py | 22 +++++++++++++++++ .../utils/data_helpers/wrappers/__init__.py | 10 ++++++++ .../runtime/utils/decorators/__init__.py | 16 +++++++++++++ .../utils/input_validation/__init__.py | 10 ++++++++ .../runtime/utils/node_factory/__init__.py | 8 +++++++ .../runtime/utils/reduction/__init__.py | 6 +++++ .../openvino/runtime/utils/types/__init__.py | 24 +++++++++++++++++++ .../python/src/openvino/utils/__init__.py | 14 +++++++++++ .../{runtime => }/utils/broadcasting.py | 2 +- .../openvino/utils/data_helpers/__init__.py | 8 +++++++ .../utils/data_helpers/data_dispatcher.py | 2 +- .../utils/data_helpers/wrappers.py | 0 .../{runtime => }/utils/decorators.py | 2 +- .../{runtime => }/utils/input_validation.py | 0 .../{runtime => }/utils/node_factory.py | 0 .../{utils.py => utils/package_utils.py} | 0 .../openvino/{runtime => }/utils/reduction.py | 0 .../src/openvino/{runtime => }/utils/types.py | 2 +- 21 files changed, 140 insertions(+), 9 deletions(-) create mode 100644 src/bindings/python/src/openvino/runtime/utils/broadcasting/__init__.py create mode 100644 src/bindings/python/src/openvino/runtime/utils/data_helpers/data_dispatcher/__init__.py create mode 100644 src/bindings/python/src/openvino/runtime/utils/data_helpers/wrappers/__init__.py create mode 100644 src/bindings/python/src/openvino/runtime/utils/decorators/__init__.py create mode 100644 src/bindings/python/src/openvino/runtime/utils/input_validation/__init__.py create mode 100644 src/bindings/python/src/openvino/runtime/utils/node_factory/__init__.py create mode 100644 src/bindings/python/src/openvino/runtime/utils/reduction/__init__.py create mode 100644 src/bindings/python/src/openvino/runtime/utils/types/__init__.py create mode 100644 src/bindings/python/src/openvino/utils/__init__.py rename src/bindings/python/src/openvino/{runtime => }/utils/broadcasting.py (96%) create mode 100644 src/bindings/python/src/openvino/utils/data_helpers/__init__.py rename src/bindings/python/src/openvino/{runtime => }/utils/data_helpers/data_dispatcher.py (99%) rename src/bindings/python/src/openvino/{runtime => }/utils/data_helpers/wrappers.py (100%) rename src/bindings/python/src/openvino/{runtime => }/utils/decorators.py (98%) rename src/bindings/python/src/openvino/{runtime => }/utils/input_validation.py (100%) rename src/bindings/python/src/openvino/{runtime => }/utils/node_factory.py (100%) rename src/bindings/python/src/openvino/{utils.py => utils/package_utils.py} (100%) rename src/bindings/python/src/openvino/{runtime => }/utils/reduction.py (100%) rename src/bindings/python/src/openvino/{runtime => }/utils/types.py (99%) diff --git a/src/bindings/python/src/openvino/runtime/utils/__init__.py b/src/bindings/python/src/openvino/runtime/utils/__init__.py index 73399ccbed2598..8447e93a907277 100644 --- a/src/bindings/python/src/openvino/runtime/utils/__init__.py +++ b/src/bindings/python/src/openvino/runtime/utils/__init__.py @@ -4,4 +4,4 @@ """Generic utilities. Factor related functions out to separate files.""" -from openvino._pyopenvino.util import numpy_to_c, replace_node, replace_output_update_name +from openvino.utils import numpy_to_c, replace_node, replace_output_update_name diff --git a/src/bindings/python/src/openvino/runtime/utils/broadcasting/__init__.py b/src/bindings/python/src/openvino/runtime/utils/broadcasting/__init__.py new file mode 100644 index 00000000000000..5375748ead83a3 --- /dev/null +++ b/src/bindings/python/src/openvino/runtime/utils/broadcasting/__init__.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2018-2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +from openvino.runtime import AxisSet, Node +from openvino.runtime.utils.types import ( + NodeInput, + TensorShape, + get_dtype, + make_constant_node, +) + +from openvino.utils.broadcasting import get_broadcast_axes diff --git a/src/bindings/python/src/openvino/runtime/utils/data_helpers/__init__.py b/src/bindings/python/src/openvino/runtime/utils/data_helpers/__init__.py index a46105efaaeadb..282547dd9df79a 100644 --- a/src/bindings/python/src/openvino/runtime/utils/data_helpers/__init__.py +++ b/src/bindings/python/src/openvino/runtime/utils/data_helpers/__init__.py @@ -2,7 +2,7 @@ # Copyright (C) 2018-2024 Intel Corporation # SPDX-License-Identifier: Apache-2.0 -from openvino.runtime.utils.data_helpers.data_dispatcher import _data_dispatch -from openvino.runtime.utils.data_helpers.wrappers import tensor_from_file -from openvino.runtime.utils.data_helpers.wrappers import _InferRequestWrapper -from openvino.runtime.utils.data_helpers.wrappers import OVDict +from openvino.utils.data_helpers.data_dispatcher import _data_dispatch +from openvino.utils.data_helpers.wrappers import tensor_from_file +from openvino.utils.data_helpers.wrappers import _InferRequestWrapper +from openvino.utils.data_helpers.wrappers import OVDict diff --git a/src/bindings/python/src/openvino/runtime/utils/data_helpers/data_dispatcher/__init__.py b/src/bindings/python/src/openvino/runtime/utils/data_helpers/data_dispatcher/__init__.py new file mode 100644 index 00000000000000..ad4f6a24c2267a --- /dev/null +++ b/src/bindings/python/src/openvino/runtime/utils/data_helpers/data_dispatcher/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2018-2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +from openvino._pyopenvino import ConstOutput, Tensor, Type, RemoteTensor +from openvino.utils.data_helpers.wrappers import _InferRequestWrapper, OVDict + +from openvino.utils.data_helpers.data_dispatcher import ContainerTypes +from openvino.utils.data_helpers.data_dispatcher import ScalarTypes +from openvino.utils.data_helpers.data_dispatcher import ValidKeys + +from openvino.utils.data_helpers.data_dispatcher import is_list_simple_type +from openvino.utils.data_helpers.data_dispatcher import get_request_tensor +from openvino.utils.data_helpers.data_dispatcher import value_to_tensor +from openvino.utils.data_helpers.data_dispatcher import to_c_style +from openvino.utils.data_helpers.data_dispatcher import normalize_arrays +from openvino.utils.data_helpers.data_dispatcher import create_shared +from openvino.utils.data_helpers.data_dispatcher import set_request_tensor +from openvino.utils.data_helpers.data_dispatcher import update_tensor +from openvino.utils.data_helpers.data_dispatcher import update_inputs +from openvino.utils.data_helpers.data_dispatcher import create_copied +from openvino.utils.data_helpers.data_dispatcher import _data_dispatch diff --git a/src/bindings/python/src/openvino/runtime/utils/data_helpers/wrappers/__init__.py b/src/bindings/python/src/openvino/runtime/utils/data_helpers/wrappers/__init__.py new file mode 100644 index 00000000000000..5459dce3e25d9d --- /dev/null +++ b/src/bindings/python/src/openvino/runtime/utils/data_helpers/wrappers/__init__.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2018-2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +from openvino._pyopenvino import Tensor, ConstOutput +from openvino._pyopenvino import InferRequest as InferRequestBase + +from openvino.utils.data_helpers.wrappers import tensor_from_file +from openvino.utils.data_helpers.wrappers import _InferRequestWrapper +from openvino.utils.data_helpers.wrappers import OVDict diff --git a/src/bindings/python/src/openvino/runtime/utils/decorators/__init__.py b/src/bindings/python/src/openvino/runtime/utils/decorators/__init__.py new file mode 100644 index 00000000000000..67d9f5c460ae17 --- /dev/null +++ b/src/bindings/python/src/openvino/runtime/utils/decorators/__init__.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2018-2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +from openvino.runtime import Node, Output +from openvino.runtime.utils.types import NodeInput, as_node, as_nodes + +from openvino.utils.decorators import _get_name +from openvino.utils.decorators import _set_node_friendly_name +from openvino.utils.decorators import nameable_op +from openvino.utils.decorators import unary_op +from openvino.utils.decorators import binary_op +from openvino.utils.decorators import custom_preprocess_function +from openvino.utils.decorators import MultiMethod +from openvino.utils.decorators import registry +from openvino.utils.decorators import overloading diff --git a/src/bindings/python/src/openvino/runtime/utils/input_validation/__init__.py b/src/bindings/python/src/openvino/runtime/utils/input_validation/__init__.py new file mode 100644 index 00000000000000..0b49e9ea33c40d --- /dev/null +++ b/src/bindings/python/src/openvino/runtime/utils/input_validation/__init__.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2018-2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +from openvino.utils.input_validation import assert_list_of_ints +from openvino.utils.input_validation import _check_value +from openvino.utils.input_validation import check_valid_attribute +from openvino.utils.input_validation import check_valid_attributes +from openvino.utils.input_validation import is_positive_value +from openvino.utils.input_validation import is_non_negative_value diff --git a/src/bindings/python/src/openvino/runtime/utils/node_factory/__init__.py b/src/bindings/python/src/openvino/runtime/utils/node_factory/__init__.py new file mode 100644 index 00000000000000..35389576999bd1 --- /dev/null +++ b/src/bindings/python/src/openvino/runtime/utils/node_factory/__init__.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2018-2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +from openvino._pyopenvino import NodeFactory as _NodeFactory + +from openvino.runtime import Node, Output, Extension +from openvino.utils.node_factory import NodeFactory diff --git a/src/bindings/python/src/openvino/runtime/utils/reduction/__init__.py b/src/bindings/python/src/openvino/runtime/utils/reduction/__init__.py new file mode 100644 index 00000000000000..03f0bb801c1cfe --- /dev/null +++ b/src/bindings/python/src/openvino/runtime/utils/reduction/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2018-2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +from openvino.runtime import Node +from openvino.utils.reduction import get_reduction_axes diff --git a/src/bindings/python/src/openvino/runtime/utils/types/__init__.py b/src/bindings/python/src/openvino/runtime/utils/types/__init__.py new file mode 100644 index 00000000000000..03d9ca7eb8d917 --- /dev/null +++ b/src/bindings/python/src/openvino/runtime/utils/types/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2018-2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +from openvino.runtime import Node, Shape, Output, Type +from openvino.op import Constant + +from openvino.utils.types import TensorShape +from openvino.utils.types import NumericData +from openvino.utils.types import NumericType +from openvino.utils.types import ScalarData +from openvino.utils.types import NodeInput + +from openvino.utils.types import openvino_to_numpy_types_map +from openvino.utils.types import openvino_to_numpy_types_str_map +from openvino.utils.types import get_element_type +from openvino.utils.types import get_element_type_str +from openvino.utils.types import get_dtype +from openvino.utils.types import get_numpy_ctype +from openvino.utils.types import get_ndarray +from openvino.utils.types import get_shape +from openvino.utils.types import make_constant_node +from openvino.utils.types import as_node +from openvino.utils.types import as_nodes diff --git a/src/bindings/python/src/openvino/utils/__init__.py b/src/bindings/python/src/openvino/utils/__init__.py new file mode 100644 index 00000000000000..7cec47f587a81d --- /dev/null +++ b/src/bindings/python/src/openvino/utils/__init__.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2018-2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +"""Generic utilities. Factor related functions out to separate files.""" + +from openvino._pyopenvino.util import numpy_to_c, replace_node, replace_output_update_name + +from openvino.utils.package_utils import _add_openvino_libs_to_search_path +from openvino.utils.package_utils import get_cmake_path +from openvino.utils.package_utils import deprecated +from openvino.utils.package_utils import _ClassPropertyDescriptor +from openvino.utils.package_utils import classproperty +from openvino.utils.package_utils import deprecatedclassproperty diff --git a/src/bindings/python/src/openvino/runtime/utils/broadcasting.py b/src/bindings/python/src/openvino/utils/broadcasting.py similarity index 96% rename from src/bindings/python/src/openvino/runtime/utils/broadcasting.py rename to src/bindings/python/src/openvino/utils/broadcasting.py index 9fd13da7728e29..b5161e1cfcc650 100644 --- a/src/bindings/python/src/openvino/runtime/utils/broadcasting.py +++ b/src/bindings/python/src/openvino/utils/broadcasting.py @@ -6,7 +6,7 @@ from typing import List, Optional from openvino.runtime import AxisSet, Node -from openvino.runtime.utils.types import ( +from openvino.utils.types import ( NodeInput, TensorShape, get_dtype, diff --git a/src/bindings/python/src/openvino/utils/data_helpers/__init__.py b/src/bindings/python/src/openvino/utils/data_helpers/__init__.py new file mode 100644 index 00000000000000..282547dd9df79a --- /dev/null +++ b/src/bindings/python/src/openvino/utils/data_helpers/__init__.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2018-2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +from openvino.utils.data_helpers.data_dispatcher import _data_dispatch +from openvino.utils.data_helpers.wrappers import tensor_from_file +from openvino.utils.data_helpers.wrappers import _InferRequestWrapper +from openvino.utils.data_helpers.wrappers import OVDict diff --git a/src/bindings/python/src/openvino/runtime/utils/data_helpers/data_dispatcher.py b/src/bindings/python/src/openvino/utils/data_helpers/data_dispatcher.py similarity index 99% rename from src/bindings/python/src/openvino/runtime/utils/data_helpers/data_dispatcher.py rename to src/bindings/python/src/openvino/utils/data_helpers/data_dispatcher.py index bce10c9c3774ef..d4db7cb07b629c 100644 --- a/src/bindings/python/src/openvino/runtime/utils/data_helpers/data_dispatcher.py +++ b/src/bindings/python/src/openvino/utils/data_helpers/data_dispatcher.py @@ -8,7 +8,7 @@ import numpy as np from openvino._pyopenvino import ConstOutput, Tensor, Type, RemoteTensor -from openvino.runtime.utils.data_helpers.wrappers import _InferRequestWrapper, OVDict +from openvino.utils.data_helpers.wrappers import _InferRequestWrapper, OVDict ContainerTypes = Union[dict, list, tuple, OVDict] ScalarTypes = Union[np.number, int, float] diff --git a/src/bindings/python/src/openvino/runtime/utils/data_helpers/wrappers.py b/src/bindings/python/src/openvino/utils/data_helpers/wrappers.py similarity index 100% rename from src/bindings/python/src/openvino/runtime/utils/data_helpers/wrappers.py rename to src/bindings/python/src/openvino/utils/data_helpers/wrappers.py diff --git a/src/bindings/python/src/openvino/runtime/utils/decorators.py b/src/bindings/python/src/openvino/utils/decorators.py similarity index 98% rename from src/bindings/python/src/openvino/runtime/utils/decorators.py rename to src/bindings/python/src/openvino/utils/decorators.py index 98da1ba4389ef7..604c0745860bf6 100644 --- a/src/bindings/python/src/openvino/runtime/utils/decorators.py +++ b/src/bindings/python/src/openvino/utils/decorators.py @@ -7,7 +7,7 @@ from typing import Any, Callable, Dict, Optional, Union, get_origin, get_args from openvino.runtime import Node, Output -from openvino.runtime.utils.types import NodeInput, as_node, as_nodes +from openvino.utils.types import NodeInput, as_node, as_nodes def _get_name(**kwargs: Any) -> Node: diff --git a/src/bindings/python/src/openvino/runtime/utils/input_validation.py b/src/bindings/python/src/openvino/utils/input_validation.py similarity index 100% rename from src/bindings/python/src/openvino/runtime/utils/input_validation.py rename to src/bindings/python/src/openvino/utils/input_validation.py diff --git a/src/bindings/python/src/openvino/runtime/utils/node_factory.py b/src/bindings/python/src/openvino/utils/node_factory.py similarity index 100% rename from src/bindings/python/src/openvino/runtime/utils/node_factory.py rename to src/bindings/python/src/openvino/utils/node_factory.py diff --git a/src/bindings/python/src/openvino/utils.py b/src/bindings/python/src/openvino/utils/package_utils.py similarity index 100% rename from src/bindings/python/src/openvino/utils.py rename to src/bindings/python/src/openvino/utils/package_utils.py diff --git a/src/bindings/python/src/openvino/runtime/utils/reduction.py b/src/bindings/python/src/openvino/utils/reduction.py similarity index 100% rename from src/bindings/python/src/openvino/runtime/utils/reduction.py rename to src/bindings/python/src/openvino/utils/reduction.py diff --git a/src/bindings/python/src/openvino/runtime/utils/types.py b/src/bindings/python/src/openvino/utils/types.py similarity index 99% rename from src/bindings/python/src/openvino/runtime/utils/types.py rename to src/bindings/python/src/openvino/utils/types.py index 52f1faf8e1e839..854cc0c7f6411d 100644 --- a/src/bindings/python/src/openvino/runtime/utils/types.py +++ b/src/bindings/python/src/openvino/utils/types.py @@ -11,7 +11,7 @@ from openvino.runtime.exceptions import OVTypeError from openvino.runtime import Node, Shape, Output, Type -from openvino.runtime.op import Constant +from openvino.op import Constant log = logging.getLogger(__name__) From 339a1fdb42f744aedff00f694cfb291a8c6593b8 Mon Sep 17 00:00:00 2001 From: Alicja Miloszewska Date: Fri, 13 Dec 2024 11:52:16 +0100 Subject: [PATCH 02/10] Fix relative paths for windows Signed-off-by: Alicja Miloszewska --- .../python/src/openvino/utils/package_utils.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/bindings/python/src/openvino/utils/package_utils.py b/src/bindings/python/src/openvino/utils/package_utils.py index 9890ae9b3e6460..d0046bc5e4c5f8 100644 --- a/src/bindings/python/src/openvino/utils/package_utils.py +++ b/src/bindings/python/src/openvino/utils/package_utils.py @@ -18,12 +18,12 @@ def _add_openvino_libs_to_search_path() -> None: # If you're using a custom installation of openvino, # add the location of openvino dlls to your system PATH. openvino_libs = [] - if os.path.isdir(os.path.join(os.path.dirname(__file__), "libs")): + if os.path.isdir(os.path.join(os.path.dirname(__file__), os.pardir, "libs")): # looking for the libs in the pip installation path. - openvino_libs.append(os.path.join(os.path.dirname(__file__), "libs")) - elif os.path.isdir(os.path.join(os.path.dirname(__file__), "..", "..", "..", "Library", "bin")): + openvino_libs.append(os.path.join(os.path.dirname(__file__), os.pardir, "libs")) + elif os.path.isdir(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, os.pardir, "Library", "bin")): # looking for the libs in the conda installation path - openvino_libs.append(os.path.join(os.path.dirname(__file__), "..", "..", "..", "Library", "bin")) + openvino_libs.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, os.pardir, "Library", "bin")) else: # setupvars.bat script set all libs paths to OPENVINO_LIB_PATHS environment variable. openvino_libs_installer = os.getenv("OPENVINO_LIB_PATHS") @@ -33,7 +33,7 @@ def _add_openvino_libs_to_search_path() -> None: sys.exit("Error: Please set the OPENVINO_LIB_PATHS environment variable. " "If you use an install package, please, run setupvars.bat") for lib in openvino_libs: - lib_path = os.path.join(os.path.dirname(__file__), lib) + lib_path = os.path.join(os.path.dirname(__file__), os.pardir, lib) if os.path.isdir(lib_path): # On Windows, with Python >= 3.8, DLLs are no longer imported from the PATH. os.add_dll_directory(os.path.abspath(lib_path)) @@ -45,7 +45,7 @@ def get_cmake_path() -> str: :return: The path to the directory containing CMake files, if found. Otherwise, returns empty string. :rtype: str """ - package_path = Path(__file__).parent + package_path = Path(__file__).parent.parent cmake_file = "OpenVINOConfig.cmake" for dirpath, _, filenames in os.walk(package_path): From 217d76490325c5380f3bdc17c1281fad08519081 Mon Sep 17 00:00:00 2001 From: Alicja Miloszewska Date: Fri, 13 Dec 2024 12:40:51 +0100 Subject: [PATCH 03/10] Fix flake. Signed-off-by: Alicja Miloszewska --- .../python/src/openvino/runtime/utils/decorators/__init__.py | 2 +- .../python/src/openvino/runtime/utils/node_factory/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bindings/python/src/openvino/runtime/utils/decorators/__init__.py b/src/bindings/python/src/openvino/runtime/utils/decorators/__init__.py index 67d9f5c460ae17..ea7b19a2a553a0 100644 --- a/src/bindings/python/src/openvino/runtime/utils/decorators/__init__.py +++ b/src/bindings/python/src/openvino/runtime/utils/decorators/__init__.py @@ -5,7 +5,7 @@ from openvino.runtime import Node, Output from openvino.runtime.utils.types import NodeInput, as_node, as_nodes -from openvino.utils.decorators import _get_name +from openvino.utils.decorators import _get_name from openvino.utils.decorators import _set_node_friendly_name from openvino.utils.decorators import nameable_op from openvino.utils.decorators import unary_op diff --git a/src/bindings/python/src/openvino/runtime/utils/node_factory/__init__.py b/src/bindings/python/src/openvino/runtime/utils/node_factory/__init__.py index 35389576999bd1..f468bc28b2c25d 100644 --- a/src/bindings/python/src/openvino/runtime/utils/node_factory/__init__.py +++ b/src/bindings/python/src/openvino/runtime/utils/node_factory/__init__.py @@ -5,4 +5,4 @@ from openvino._pyopenvino import NodeFactory as _NodeFactory from openvino.runtime import Node, Output, Extension -from openvino.utils.node_factory import NodeFactory +from openvino.utils.node_factory import NodeFactory From e3dfef46dd1b22c837ac32b857298aae561d258d Mon Sep 17 00:00:00 2001 From: Alicja Miloszewska Date: Fri, 13 Dec 2024 20:53:01 +0100 Subject: [PATCH 04/10] Move opset_utils.py Signed-off-by: Alicja Miloszewska --- .../src/openvino/runtime/opset_utils.py | 22 ------------------- .../openvino/runtime/opset_utils/__init__.py | 13 +++++++++++ .../python/src/openvino/utils/node_factory.py | 8 +++++++ 3 files changed, 21 insertions(+), 22 deletions(-) delete mode 100644 src/bindings/python/src/openvino/runtime/opset_utils.py create mode 100644 src/bindings/python/src/openvino/runtime/opset_utils/__init__.py diff --git a/src/bindings/python/src/openvino/runtime/opset_utils.py b/src/bindings/python/src/openvino/runtime/opset_utils.py deleted file mode 100644 index 475750e71f87c5..00000000000000 --- a/src/bindings/python/src/openvino/runtime/opset_utils.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2018-2024 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 - -from typing import Optional -import numpy as np - -from openvino.runtime import Node -from openvino.runtime.utils.decorators import nameable_op -from openvino.runtime.utils.node_factory import NodeFactory -from openvino.runtime.utils.types import ( - as_node, - NodeInput, -) - - -def _get_node_factory(opset_version: Optional[str] = None) -> NodeFactory: - """Return NodeFactory configured to create operators from specified opset version.""" - if opset_version: - return NodeFactory(opset_version) - else: - return NodeFactory() diff --git a/src/bindings/python/src/openvino/runtime/opset_utils/__init__.py b/src/bindings/python/src/openvino/runtime/opset_utils/__init__.py new file mode 100644 index 00000000000000..5852d347e0b8d1 --- /dev/null +++ b/src/bindings/python/src/openvino/runtime/opset_utils/__init__.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2018-2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +from openvino.runtime import Node +from openvino.utils.decorators import nameable_op +from openvino.utils.node_factory import NodeFactory +from openvino.utils.types import ( + as_node, + NodeInput, +) + +from openvino.utils.node_factory import _get_node_factory diff --git a/src/bindings/python/src/openvino/utils/node_factory.py b/src/bindings/python/src/openvino/utils/node_factory.py index 25daf739223dba..70dd96d7519e68 100644 --- a/src/bindings/python/src/openvino/utils/node_factory.py +++ b/src/bindings/python/src/openvino/utils/node_factory.py @@ -125,3 +125,11 @@ def _arguments_as_outputs(arguments: List[Union[Node, Output]]) -> List[Output]: else: outputs.extend(argument.outputs()) return outputs + + +def _get_node_factory(opset_version: Optional[str] = None) -> NodeFactory: + """Return NodeFactory configured to create operators from specified opset version.""" + if opset_version: + return NodeFactory(opset_version) + else: + return NodeFactory() From bf4244cbe0c9c3638a2b4c2a59187edbd60f21e4 Mon Sep 17 00:00:00 2001 From: Alicja Miloszewska Date: Fri, 13 Dec 2024 21:26:00 +0100 Subject: [PATCH 05/10] Fix _add_openvino_libs_to_search_path Signed-off-by: Alicja Miloszewska --- src/bindings/python/src/openvino/__init__.py | 2 +- .../python/src/openvino/{utils => }/package_utils.py | 12 ++++++------ src/bindings/python/src/openvino/utils/__init__.py | 10 ++++------ tools/benchmark_tool/openvino/__init__.py | 2 +- tools/ovc/openvino/__init__.py | 2 +- 5 files changed, 13 insertions(+), 15 deletions(-) rename src/bindings/python/src/openvino/{utils => }/package_utils.py (93%) diff --git a/src/bindings/python/src/openvino/__init__.py b/src/bindings/python/src/openvino/__init__.py index e4d1a247520332..c3f6dece338c70 100644 --- a/src/bindings/python/src/openvino/__init__.py +++ b/src/bindings/python/src/openvino/__init__.py @@ -7,7 +7,7 @@ # Required for Windows OS platforms # Note: always top-level try: - from openvino.utils import _add_openvino_libs_to_search_path + from openvino.package_utils import _add_openvino_libs_to_search_path _add_openvino_libs_to_search_path() except ImportError: pass diff --git a/src/bindings/python/src/openvino/utils/package_utils.py b/src/bindings/python/src/openvino/package_utils.py similarity index 93% rename from src/bindings/python/src/openvino/utils/package_utils.py rename to src/bindings/python/src/openvino/package_utils.py index d0046bc5e4c5f8..6aa3f3ed39b556 100644 --- a/src/bindings/python/src/openvino/utils/package_utils.py +++ b/src/bindings/python/src/openvino/package_utils.py @@ -18,12 +18,12 @@ def _add_openvino_libs_to_search_path() -> None: # If you're using a custom installation of openvino, # add the location of openvino dlls to your system PATH. openvino_libs = [] - if os.path.isdir(os.path.join(os.path.dirname(__file__), os.pardir, "libs")): + if os.path.isdir(os.path.join(os.path.dirname(__file__), "libs")): # looking for the libs in the pip installation path. - openvino_libs.append(os.path.join(os.path.dirname(__file__), os.pardir, "libs")) - elif os.path.isdir(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, os.pardir, "Library", "bin")): + openvino_libs.append(os.path.join(os.path.dirname(__file__), "libs")) + elif os.path.isdir(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, "Library", "bin")): # looking for the libs in the conda installation path - openvino_libs.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, os.pardir, "Library", "bin")) + openvino_libs.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, "Library", "bin")) else: # setupvars.bat script set all libs paths to OPENVINO_LIB_PATHS environment variable. openvino_libs_installer = os.getenv("OPENVINO_LIB_PATHS") @@ -33,7 +33,7 @@ def _add_openvino_libs_to_search_path() -> None: sys.exit("Error: Please set the OPENVINO_LIB_PATHS environment variable. " "If you use an install package, please, run setupvars.bat") for lib in openvino_libs: - lib_path = os.path.join(os.path.dirname(__file__), os.pardir, lib) + lib_path = os.path.join(os.path.dirname(__file__), lib) if os.path.isdir(lib_path): # On Windows, with Python >= 3.8, DLLs are no longer imported from the PATH. os.add_dll_directory(os.path.abspath(lib_path)) @@ -45,7 +45,7 @@ def get_cmake_path() -> str: :return: The path to the directory containing CMake files, if found. Otherwise, returns empty string. :rtype: str """ - package_path = Path(__file__).parent.parent + package_path = Path(__file__).parent cmake_file = "OpenVINOConfig.cmake" for dirpath, _, filenames in os.walk(package_path): diff --git a/src/bindings/python/src/openvino/utils/__init__.py b/src/bindings/python/src/openvino/utils/__init__.py index 7cec47f587a81d..2ccc79d20cce84 100644 --- a/src/bindings/python/src/openvino/utils/__init__.py +++ b/src/bindings/python/src/openvino/utils/__init__.py @@ -6,9 +6,7 @@ from openvino._pyopenvino.util import numpy_to_c, replace_node, replace_output_update_name -from openvino.utils.package_utils import _add_openvino_libs_to_search_path -from openvino.utils.package_utils import get_cmake_path -from openvino.utils.package_utils import deprecated -from openvino.utils.package_utils import _ClassPropertyDescriptor -from openvino.utils.package_utils import classproperty -from openvino.utils.package_utils import deprecatedclassproperty +from openvino.package_utils import get_cmake_path +from openvino.package_utils import deprecated +from openvino.package_utils import classproperty +from openvino.package_utils import deprecatedclassproperty diff --git a/tools/benchmark_tool/openvino/__init__.py b/tools/benchmark_tool/openvino/__init__.py index e4d1a247520332..c3f6dece338c70 100644 --- a/tools/benchmark_tool/openvino/__init__.py +++ b/tools/benchmark_tool/openvino/__init__.py @@ -7,7 +7,7 @@ # Required for Windows OS platforms # Note: always top-level try: - from openvino.utils import _add_openvino_libs_to_search_path + from openvino.package_utils import _add_openvino_libs_to_search_path _add_openvino_libs_to_search_path() except ImportError: pass diff --git a/tools/ovc/openvino/__init__.py b/tools/ovc/openvino/__init__.py index e4d1a247520332..c3f6dece338c70 100644 --- a/tools/ovc/openvino/__init__.py +++ b/tools/ovc/openvino/__init__.py @@ -7,7 +7,7 @@ # Required for Windows OS platforms # Note: always top-level try: - from openvino.utils import _add_openvino_libs_to_search_path + from openvino.package_utils import _add_openvino_libs_to_search_path _add_openvino_libs_to_search_path() except ImportError: pass From 29144435413e660a6ce2617e6ee61e45992bb8ba Mon Sep 17 00:00:00 2001 From: Alicja Miloszewska Date: Sat, 14 Dec 2024 10:50:37 +0100 Subject: [PATCH 06/10] Fix wheels_windows_vs2019_release Signed-off-by: Alicja Miloszewska --- tools/mo/openvino/__init__.py | 2 +- tools/openvino_dev/src/openvino/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/mo/openvino/__init__.py b/tools/mo/openvino/__init__.py index b015570964c520..46e35babdc9fad 100644 --- a/tools/mo/openvino/__init__.py +++ b/tools/mo/openvino/__init__.py @@ -7,7 +7,7 @@ # Required for Windows OS platforms # Note: always top-level try: - from openvino.utils import _add_openvino_libs_to_search_path + from openvino.package_utils import _add_openvino_libs_to_search_path _add_openvino_libs_to_search_path() except ImportError: pass diff --git a/tools/openvino_dev/src/openvino/__init__.py b/tools/openvino_dev/src/openvino/__init__.py index b015570964c520..46e35babdc9fad 100644 --- a/tools/openvino_dev/src/openvino/__init__.py +++ b/tools/openvino_dev/src/openvino/__init__.py @@ -7,7 +7,7 @@ # Required for Windows OS platforms # Note: always top-level try: - from openvino.utils import _add_openvino_libs_to_search_path + from openvino.package_utils import _add_openvino_libs_to_search_path _add_openvino_libs_to_search_path() except ImportError: pass From 144262a9c0bec98f6033f08f4e8411dbe1047817 Mon Sep 17 00:00:00 2001 From: Alicja Miloszewska Date: Mon, 16 Dec 2024 08:18:50 +0100 Subject: [PATCH 07/10] Apply suggestions Co-authored-by: Anastasia Kuporosova --- .../python/src/openvino/runtime/opset_utils/__init__.py | 7 ------- .../runtime/utils/data_helpers/data_dispatcher/__init__.py | 2 -- .../runtime/utils/data_helpers/wrappers/__init__.py | 2 -- .../src/openvino/runtime/utils/node_factory/__init__.py | 3 --- .../src/openvino/runtime/utils/reduction/__init__.py | 1 - 5 files changed, 15 deletions(-) diff --git a/src/bindings/python/src/openvino/runtime/opset_utils/__init__.py b/src/bindings/python/src/openvino/runtime/opset_utils/__init__.py index 5852d347e0b8d1..6fb3e5f6f0c950 100644 --- a/src/bindings/python/src/openvino/runtime/opset_utils/__init__.py +++ b/src/bindings/python/src/openvino/runtime/opset_utils/__init__.py @@ -2,12 +2,5 @@ # Copyright (C) 2018-2024 Intel Corporation # SPDX-License-Identifier: Apache-2.0 -from openvino.runtime import Node -from openvino.utils.decorators import nameable_op -from openvino.utils.node_factory import NodeFactory -from openvino.utils.types import ( - as_node, - NodeInput, -) from openvino.utils.node_factory import _get_node_factory diff --git a/src/bindings/python/src/openvino/runtime/utils/data_helpers/data_dispatcher/__init__.py b/src/bindings/python/src/openvino/runtime/utils/data_helpers/data_dispatcher/__init__.py index ad4f6a24c2267a..e0a2d022660dd3 100644 --- a/src/bindings/python/src/openvino/runtime/utils/data_helpers/data_dispatcher/__init__.py +++ b/src/bindings/python/src/openvino/runtime/utils/data_helpers/data_dispatcher/__init__.py @@ -2,8 +2,6 @@ # Copyright (C) 2018-2024 Intel Corporation # SPDX-License-Identifier: Apache-2.0 -from openvino._pyopenvino import ConstOutput, Tensor, Type, RemoteTensor -from openvino.utils.data_helpers.wrappers import _InferRequestWrapper, OVDict from openvino.utils.data_helpers.data_dispatcher import ContainerTypes from openvino.utils.data_helpers.data_dispatcher import ScalarTypes diff --git a/src/bindings/python/src/openvino/runtime/utils/data_helpers/wrappers/__init__.py b/src/bindings/python/src/openvino/runtime/utils/data_helpers/wrappers/__init__.py index 5459dce3e25d9d..22214fd24682da 100644 --- a/src/bindings/python/src/openvino/runtime/utils/data_helpers/wrappers/__init__.py +++ b/src/bindings/python/src/openvino/runtime/utils/data_helpers/wrappers/__init__.py @@ -2,8 +2,6 @@ # Copyright (C) 2018-2024 Intel Corporation # SPDX-License-Identifier: Apache-2.0 -from openvino._pyopenvino import Tensor, ConstOutput -from openvino._pyopenvino import InferRequest as InferRequestBase from openvino.utils.data_helpers.wrappers import tensor_from_file from openvino.utils.data_helpers.wrappers import _InferRequestWrapper diff --git a/src/bindings/python/src/openvino/runtime/utils/node_factory/__init__.py b/src/bindings/python/src/openvino/runtime/utils/node_factory/__init__.py index f468bc28b2c25d..945ea8deb7863c 100644 --- a/src/bindings/python/src/openvino/runtime/utils/node_factory/__init__.py +++ b/src/bindings/python/src/openvino/runtime/utils/node_factory/__init__.py @@ -2,7 +2,4 @@ # Copyright (C) 2018-2024 Intel Corporation # SPDX-License-Identifier: Apache-2.0 -from openvino._pyopenvino import NodeFactory as _NodeFactory - -from openvino.runtime import Node, Output, Extension from openvino.utils.node_factory import NodeFactory diff --git a/src/bindings/python/src/openvino/runtime/utils/reduction/__init__.py b/src/bindings/python/src/openvino/runtime/utils/reduction/__init__.py index 03f0bb801c1cfe..a2fbff9e793dca 100644 --- a/src/bindings/python/src/openvino/runtime/utils/reduction/__init__.py +++ b/src/bindings/python/src/openvino/runtime/utils/reduction/__init__.py @@ -2,5 +2,4 @@ # Copyright (C) 2018-2024 Intel Corporation # SPDX-License-Identifier: Apache-2.0 -from openvino.runtime import Node from openvino.utils.reduction import get_reduction_axes From b979661dcfec2a8d6561a5ade28ac250e86da020 Mon Sep 17 00:00:00 2001 From: Alicja Miloszewska Date: Mon, 16 Dec 2024 08:22:28 +0100 Subject: [PATCH 08/10] Remove unused/internal imports from proxies Signed-off-by: Alicja Miloszewska --- .../src/openvino/runtime/utils/broadcasting/__init__.py | 8 -------- .../src/openvino/runtime/utils/decorators/__init__.py | 3 --- .../python/src/openvino/runtime/utils/types/__init__.py | 3 --- 3 files changed, 14 deletions(-) diff --git a/src/bindings/python/src/openvino/runtime/utils/broadcasting/__init__.py b/src/bindings/python/src/openvino/runtime/utils/broadcasting/__init__.py index 5375748ead83a3..3219f239f0ab44 100644 --- a/src/bindings/python/src/openvino/runtime/utils/broadcasting/__init__.py +++ b/src/bindings/python/src/openvino/runtime/utils/broadcasting/__init__.py @@ -2,12 +2,4 @@ # Copyright (C) 2018-2024 Intel Corporation # SPDX-License-Identifier: Apache-2.0 -from openvino.runtime import AxisSet, Node -from openvino.runtime.utils.types import ( - NodeInput, - TensorShape, - get_dtype, - make_constant_node, -) - from openvino.utils.broadcasting import get_broadcast_axes diff --git a/src/bindings/python/src/openvino/runtime/utils/decorators/__init__.py b/src/bindings/python/src/openvino/runtime/utils/decorators/__init__.py index ea7b19a2a553a0..bb0bac112d2c5f 100644 --- a/src/bindings/python/src/openvino/runtime/utils/decorators/__init__.py +++ b/src/bindings/python/src/openvino/runtime/utils/decorators/__init__.py @@ -2,9 +2,6 @@ # Copyright (C) 2018-2024 Intel Corporation # SPDX-License-Identifier: Apache-2.0 -from openvino.runtime import Node, Output -from openvino.runtime.utils.types import NodeInput, as_node, as_nodes - from openvino.utils.decorators import _get_name from openvino.utils.decorators import _set_node_friendly_name from openvino.utils.decorators import nameable_op diff --git a/src/bindings/python/src/openvino/runtime/utils/types/__init__.py b/src/bindings/python/src/openvino/runtime/utils/types/__init__.py index 03d9ca7eb8d917..4f88d609988e8d 100644 --- a/src/bindings/python/src/openvino/runtime/utils/types/__init__.py +++ b/src/bindings/python/src/openvino/runtime/utils/types/__init__.py @@ -2,9 +2,6 @@ # Copyright (C) 2018-2024 Intel Corporation # SPDX-License-Identifier: Apache-2.0 -from openvino.runtime import Node, Shape, Output, Type -from openvino.op import Constant - from openvino.utils.types import TensorShape from openvino.utils.types import NumericData from openvino.utils.types import NumericType From 78c4040560c00a086589d9461bd13d0368ef977d Mon Sep 17 00:00:00 2001 From: Alicja Miloszewska Date: Mon, 16 Dec 2024 08:28:44 +0100 Subject: [PATCH 09/10] Remove unused imports from broadcasting.py and node_factory,py Signed-off-by: Alicja Miloszewska --- src/bindings/python/src/openvino/utils/broadcasting.py | 7 ++----- src/bindings/python/src/openvino/utils/node_factory.py | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/bindings/python/src/openvino/utils/broadcasting.py b/src/bindings/python/src/openvino/utils/broadcasting.py index b5161e1cfcc650..a950aea9bba820 100644 --- a/src/bindings/python/src/openvino/utils/broadcasting.py +++ b/src/bindings/python/src/openvino/utils/broadcasting.py @@ -3,14 +3,11 @@ # SPDX-License-Identifier: Apache-2.0 import logging -from typing import List, Optional +from typing import Optional -from openvino.runtime import AxisSet, Node +from openvino.runtime import AxisSet from openvino.utils.types import ( - NodeInput, TensorShape, - get_dtype, - make_constant_node, ) log = logging.getLogger(__name__) diff --git a/src/bindings/python/src/openvino/utils/node_factory.py b/src/bindings/python/src/openvino/utils/node_factory.py index 70dd96d7519e68..ee781a216b3c1c 100644 --- a/src/bindings/python/src/openvino/utils/node_factory.py +++ b/src/bindings/python/src/openvino/utils/node_factory.py @@ -4,7 +4,7 @@ import logging as log -from functools import partial, singledispatchmethod +from functools import singledispatchmethod from typing import Any, Dict, List, Optional, Union from pathlib import Path From 2a538d39d6c1f25cdb50cbf0aa4187e69442d138 Mon Sep 17 00:00:00 2001 From: Alicja Miloszewska Date: Mon, 16 Dec 2024 08:43:45 +0100 Subject: [PATCH 10/10] Update src/bindings/python/src/openvino/utils/node_factory.py Co-authored-by: Anastasia Kuporosova --- src/bindings/python/src/openvino/utils/node_factory.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/bindings/python/src/openvino/utils/node_factory.py b/src/bindings/python/src/openvino/utils/node_factory.py index ee781a216b3c1c..9841daaea4e818 100644 --- a/src/bindings/python/src/openvino/utils/node_factory.py +++ b/src/bindings/python/src/openvino/utils/node_factory.py @@ -2,7 +2,6 @@ # Copyright (C) 2018-2024 Intel Corporation # SPDX-License-Identifier: Apache-2.0 -import logging as log from functools import singledispatchmethod from typing import Any, Dict, List, Optional, Union