From d0b4cae2f891033906165a0b7df6b9550610580c Mon Sep 17 00:00:00 2001 From: Anastasia Kuporosova Date: Mon, 14 Mar 2022 14:40:28 +0300 Subject: [PATCH] [Python API] move util under utils (#10923) * [Python API] move util under utils * fix importing Co-authored-by: Ilya Lavrenov --- src/bindings/python/src/openvino/runtime/__init__.py | 1 - .../python/src/openvino/runtime/utils/__init__.py | 3 +++ src/bindings/python/src/pyopenvino/graph/util.cpp | 2 +- src/bindings/python/src/pyopenvino/graph/util.py | 8 -------- src/bindings/python/tests/test_ngraph/test_utils.py | 4 ++-- 5 files changed, 6 insertions(+), 12 deletions(-) delete mode 100644 src/bindings/python/src/pyopenvino/graph/util.py diff --git a/src/bindings/python/src/openvino/runtime/__init__.py b/src/bindings/python/src/openvino/runtime/__init__.py index b14c460d0b6..2628fb17b2a 100644 --- a/src/bindings/python/src/openvino/runtime/__init__.py +++ b/src/bindings/python/src/openvino/runtime/__init__.py @@ -31,7 +31,6 @@ from openvino.pyopenvino import AxisVector from openvino.pyopenvino import Coordinate from openvino.pyopenvino import Layout from openvino.pyopenvino import ConstOutput -from openvino.pyopenvino import util from openvino.pyopenvino import layout_helpers from openvino.pyopenvino import RTMap diff --git a/src/bindings/python/src/openvino/runtime/utils/__init__.py b/src/bindings/python/src/openvino/runtime/utils/__init__.py index 95a08b7ef7b..2f77dab83ca 100644 --- a/src/bindings/python/src/openvino/runtime/utils/__init__.py +++ b/src/bindings/python/src/openvino/runtime/utils/__init__.py @@ -2,3 +2,6 @@ # SPDX-License-Identifier: Apache-2.0 """Generic utilities. Factor related functions out to separate files.""" + +from openvino.pyopenvino.util import numpy_to_c +from openvino.pyopenvino.util import get_constant_from_source diff --git a/src/bindings/python/src/pyopenvino/graph/util.cpp b/src/bindings/python/src/pyopenvino/graph/util.cpp index 497cbe52fde..b35bc1c5cbd 100644 --- a/src/bindings/python/src/pyopenvino/graph/util.cpp +++ b/src/bindings/python/src/pyopenvino/graph/util.cpp @@ -16,7 +16,7 @@ void* numpy_to_c(py::array a) { } void regmodule_graph_util(py::module m) { - py::module mod = m.def_submodule("util", "openvino.runtime.util"); + py::module mod = m.def_submodule("util", "openvino.runtime.utils"); mod.def("numpy_to_c", &numpy_to_c); mod.def("get_constant_from_source", &ov::get_constant_from_source, diff --git a/src/bindings/python/src/pyopenvino/graph/util.py b/src/bindings/python/src/pyopenvino/graph/util.py deleted file mode 100644 index ecc73a2a6d1..00000000000 --- a/src/bindings/python/src/pyopenvino/graph/util.py +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright (C) 2018-2022 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 - -# flake8: noqa - -from openvino.pyopenvino import util - -numpy_to_c = util.numpy_to_c diff --git a/src/bindings/python/tests/test_ngraph/test_utils.py b/src/bindings/python/tests/test_ngraph/test_utils.py index a1e62eca3af..07d31ffc5f2 100644 --- a/src/bindings/python/tests/test_ngraph/test_utils.py +++ b/src/bindings/python/tests/test_ngraph/test_utils.py @@ -12,7 +12,7 @@ def test_get_constant_from_source_success(): input2 = ov.opset8.parameter(Shape([25]), dtype=dtype, name="input_2") shape_of = ov.opset8.shape_of(input2, name="shape_of") reshape = ov.opset8.reshape(input1, shape_of, special_zero=True) - folded_const = ov.util.get_constant_from_source(reshape.input(1).get_source_output()) + folded_const = ov.utils.get_constant_from_source(reshape.input(1).get_source_output()) assert folded_const is not None assert folded_const.get_vector() == [25] @@ -23,6 +23,6 @@ def test_get_constant_from_source_failed(): input1 = ov.opset8.parameter(Shape([5, 5]), dtype=dtype, name="input_1") input2 = ov.opset8.parameter(Shape([1]), dtype=dtype, name="input_2") reshape = ov.opset8.reshape(input1, input2, special_zero=True) - folded_const = ov.util.get_constant_from_source(reshape.input(1).get_source_output()) + folded_const = ov.utils.get_constant_from_source(reshape.input(1).get_source_output()) assert folded_const is None