Skip to content

Commit

Permalink
Reverted python API non BW compatible changes (#28190)
Browse files Browse the repository at this point in the history
### Reverted:
- #28062 (Guilty one)
- #28085 (Relies on
Guilty one)
- #28166 (Relies on
Guilty one)
  • Loading branch information
ilya-lavrenov authored Dec 24, 2024
1 parent 4a450d5 commit 68b1f54
Show file tree
Hide file tree
Showing 60 changed files with 326 additions and 529 deletions.
73 changes: 29 additions & 44 deletions src/bindings/python/src/openvino/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Required for Windows OS platforms
# Note: always top-level
try:
from openvino.package_utils import _add_openvino_libs_to_search_path
from openvino.utils import _add_openvino_libs_to_search_path
_add_openvino_libs_to_search_path()
except ImportError:
pass
Expand All @@ -17,47 +17,6 @@
# # This __init__.py forces checking of runtime modules to propagate errors.
# # It is not compared with init files from openvino-dev package.
# #

# Openvino pybind bindings
from openvino._pyopenvino import AxisSet
from openvino._pyopenvino import AxisVector
from openvino._pyopenvino import ConstOutput
from openvino._pyopenvino import Coordinate
from openvino._pyopenvino import CoordinateDiff
from openvino._pyopenvino import DiscreteTypeInfo
from openvino._pyopenvino import Extension
from openvino._pyopenvino import ProfilingInfo
from openvino._pyopenvino import RTMap
from openvino._pyopenvino import Version
from openvino._pyopenvino import Symbol
from openvino._pyopenvino import Dimension
from openvino._pyopenvino import Input
from openvino._pyopenvino import Output
from openvino._pyopenvino import Node
from openvino._pyopenvino import Strides
from openvino._pyopenvino import PartialShape
from openvino._pyopenvino import Shape
from openvino._pyopenvino import Layout
from openvino._pyopenvino import Type
from openvino._pyopenvino import Tensor
from openvino._pyopenvino import OVAny
from openvino._pyopenvino import get_batch
from openvino._pyopenvino import set_batch
from openvino._pyopenvino import serialize
from openvino._pyopenvino import shutdown
from openvino._pyopenvino import save_model
from openvino._pyopenvino import layout_helpers
from openvino._pyopenvino import RemoteContext
from openvino._pyopenvino import RemoteTensor
from openvino._pyopenvino import Op

# Import public classes from _ov_api
from openvino._ov_api import Model
from openvino._ov_api import Core
from openvino._ov_api import CompiledModel
from openvino._ov_api import InferRequest
from openvino._ov_api import AsyncInferQueue

# Import all public modules
from openvino import runtime as runtime
from openvino import frontend as frontend
Expand All @@ -67,10 +26,36 @@
from openvino import utils as utils
from openvino import properties as properties

# Import most important classes and functions from openvino.runtime
from openvino._ov_api import Model
from openvino._ov_api import Core
from openvino._ov_api import CompiledModel
from openvino._ov_api import InferRequest
from openvino._ov_api import AsyncInferQueue

from openvino.runtime import Symbol
from openvino.runtime import Dimension
from openvino.runtime import Strides
from openvino.runtime import PartialShape
from openvino.runtime import Shape
from openvino.runtime import Layout
from openvino.runtime import Type
from openvino.runtime import Tensor
from openvino.runtime import OVAny

# Helper functions for openvino module
from openvino.utils.data_helpers import tensor_from_file
from openvino.runtime.utils.data_helpers import tensor_from_file
from openvino._ov_api import compile_model
from openvino.runtime import get_batch
from openvino.runtime import set_batch
from openvino.runtime import serialize
from openvino.runtime import shutdown
from openvino.runtime import save_model
from openvino.runtime import layout_helpers

from openvino._pyopenvino import RemoteContext
from openvino._pyopenvino import RemoteTensor
from openvino._pyopenvino import Op

# Import opsets
from openvino import opset1
Expand All @@ -95,7 +80,7 @@
from openvino._pyopenvino import VASurfaceTensor

# Set version for openvino package
from openvino._pyopenvino import get_version
from openvino.runtime import get_version
__version__ = get_version()

# Tools
Expand Down
4 changes: 3 additions & 1 deletion src/bindings/python/src/openvino/_ov_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
from types import TracebackType
from typing import Any, Iterable, Union, Optional, Dict, Type
from pathlib import Path
import warnings

import numpy as np

from openvino._pyopenvino import Model as ModelBase
from openvino._pyopenvino import Core as CoreBase
Expand All @@ -14,7 +16,7 @@
from openvino._pyopenvino import Tensor
from openvino._pyopenvino import Node

from openvino.utils.data_helpers import (
from openvino.runtime.utils.data_helpers import (
OVDict,
_InferRequestWrapper,
_data_dispatch,
Expand Down
2 changes: 1 addition & 1 deletion src/bindings/python/src/openvino/frontend/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from openvino._pyopenvino import FrontEnd as FrontEndBase
from openvino._pyopenvino import FrontEndManager as FrontEndManagerBase
from openvino._pyopenvino import InputModel
from openvino import Model
from openvino.runtime import Model


class FrontEnd(FrontEndBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import jax.core
from openvino.frontend.jax.py_jax_frontend import _FrontEndJaxDecoder as Decoder
from openvino import PartialShape, Type as OVType, OVAny
from openvino.runtime import PartialShape, Type as OVType, OVAny
from openvino.frontend.jax.utils import jax_array_to_ov_const, get_ov_type_for_value, \
ivalue_to_constant, param_to_constants

Expand Down
2 changes: 1 addition & 1 deletion src/bindings/python/src/openvino/frontend/jax/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import jax.numpy as jnp
import numpy as np
from openvino.frontend.jax.passes import filter_element, filter_ivalue, filter_param
from openvino import op, Type as OVType, Shape, OVAny
from openvino.runtime import op, Type as OVType, Shape, OVAny

numpy_to_ov_type_map = {
np.float32: OVType.f32,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from openvino.frontend.pytorch.py_pytorch_frontend import _FrontEndPytorchDecoder as Decoder
from openvino.frontend.pytorch.py_pytorch_frontend import _Type as DecoderType
from openvino import PartialShape, Type as OVType, OVAny, Shape
from openvino.runtime import PartialShape, Type as OVType, OVAny, Shape
from openvino.frontend.pytorch.utils import make_constant, fetch_attr, pt_to_ov_type_map, torch_tensor_to_ov_const

logger = logging.getLogger(__name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from torch._decomp import decomposition_table, get_decompositions

from openvino.frontend import FrontEndManager
from openvino import Core, Type, PartialShape
from openvino.runtime import Core, Type, PartialShape
from openvino.frontend.pytorch.ts_decoder import TorchScriptPythonDecoder
from openvino.frontend.pytorch.torchdynamo import decompositions
from openvino.frontend.pytorch.torchdynamo.decompositions import get_aot_decomposition_list, get_inf_decomposition_list
Expand All @@ -27,7 +27,7 @@
from openvino.frontend.pytorch.torchdynamo.compile import cached_model_name, openvino_compile_cached_model
from openvino.frontend.pytorch.torchdynamo.backend_utils import _get_cache_dir, _get_device, _get_model_caching, _get_decompositions, _get_aot_autograd

from openvino import Core, Type, PartialShape
from openvino.runtime import Core, Type, PartialShape

logger = logging.getLogger(__name__)
logger.setLevel(logging.WARNING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# mypy: ignore-errors

from typing import Optional, Any
from openvino import Core
from openvino.runtime import Core


def _get_device(options) -> Optional[Any]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from openvino.frontend import FrontEndManager
from openvino.frontend.pytorch.fx_decoder import TorchFXPythonDecoder
from openvino import Core, Type, PartialShape, serialize
from openvino.runtime import Core, Type, PartialShape, serialize
from openvino.frontend.pytorch.torchdynamo.backend_utils import _get_cache_dir, _get_device, _get_config, _is_cache_dir_in_config

from typing import Callable, Optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from openvino.frontend.pytorch.fx_decoder import TorchFXPythonDecoder
from openvino.frontend.pytorch.torchdynamo.partition import Partitioner
from openvino.frontend.pytorch.torchdynamo.compile import openvino_compile
from openvino import Core, Type, PartialShape
from openvino.runtime import Core, Type, PartialShape
from openvino.frontend.pytorch.torchdynamo.backend_utils import _get_cache_dir, _get_device, _get_aot_autograd

from typing import Callable, Optional, Any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from openvino.frontend.pytorch.py_pytorch_frontend import _FrontEndPytorchDecoder as Decoder
from openvino.frontend.pytorch.py_pytorch_frontend import _Type as DecoderType
from openvino import op, PartialShape, Type as OVType, OVAny
from openvino.runtime import op, PartialShape, Type as OVType, OVAny
from openvino.frontend.pytorch.utils import (
ivalue_to_constant,
get_value_from_getattr,
Expand All @@ -15,7 +15,7 @@
convert_quantized_tensor,
graph_has_ops,
)
from openvino import opset11 as ops
from openvino.runtime import opset11 as ops
from openvino.frontend.pytorch import quantized, patch_model
from openvino.frontend.pytorch.module_extension import ModuleExtension

Expand Down
4 changes: 2 additions & 2 deletions src/bindings/python/src/openvino/frontend/pytorch/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import torch
import numpy as np

from openvino import op, Type as OVType, Shape, Tensor
from openvino import opset11 as ops
from openvino.runtime import op, Type as OVType, Shape, Tensor
from openvino.runtime import opset11 as ops


def make_constant(*args, **kwargs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import numpy as np
import tensorflow as tf
from openvino.frontend.tensorflow.py_tensorflow_frontend import _FrontEndDecoderBase as DecoderBase
from openvino import PartialShape, Type, OVAny, Tensor
from openvino.runtime import PartialShape, Type, OVAny, Tensor


def tf_type_to_ov_type(tf_type_int):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import logging as log
import numpy as np
import sys
from openvino import PartialShape, Dimension, Type
from openvino.runtime import PartialShape, Dimension, Type
from packaging.version import parse, Version
from typing import List, Dict, Union

Expand Down
2 changes: 1 addition & 1 deletion src/bindings/python/src/openvino/helpers/packing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import numpy as np
from typing import Union
from openvino import Type, Shape
from openvino.runtime import Type, Shape


def pack_data(array: np.ndarray, type: Type) -> np.ndarray:
Expand Down
12 changes: 6 additions & 6 deletions src/bindings/python/src/openvino/opset1/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
import numpy as np
from functools import partial

from openvino import Node, PartialShape, Type
from openvino.runtime import Node, PartialShape, Type
from openvino.op import Constant, Parameter, tensor_iterator
from openvino.utils.node_factory import _get_node_factory
from openvino.utils.decorators import binary_op, nameable_op, unary_op
from openvino.utils.input_validation import (
from openvino.runtime.opset_utils import _get_node_factory
from openvino.runtime.utils.decorators import binary_op, nameable_op, unary_op
from openvino.runtime.utils.input_validation import (
check_valid_attributes,
is_non_negative_value,
is_positive_value,
)
from openvino.utils.node_factory import NodeFactory
from openvino.utils.types import (
from openvino.runtime.utils.node_factory import NodeFactory
from openvino.runtime.utils.types import (
NodeInput,
NumericData,
NumericType,
Expand Down
8 changes: 4 additions & 4 deletions src/bindings/python/src/openvino/opset10/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from functools import partial
from typing import List, Optional

from openvino import Node
from openvino.utils.node_factory import _get_node_factory
from openvino.utils.decorators import nameable_op
from openvino.utils.types import (
from openvino.runtime import Node
from openvino.runtime.opset_utils import _get_node_factory
from openvino.runtime.utils.decorators import nameable_op
from openvino.runtime.utils.types import (
NodeInput,
as_nodes,
as_node,
Expand Down
8 changes: 4 additions & 4 deletions src/bindings/python/src/openvino/opset11/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from functools import partial
from typing import List, Optional

from openvino import Node
from openvino.utils.node_factory import _get_node_factory
from openvino.utils.decorators import nameable_op
from openvino.utils.types import (
from openvino.runtime import Node
from openvino.runtime.opset_utils import _get_node_factory
from openvino.runtime.utils.decorators import nameable_op
from openvino.runtime.utils.types import (
NodeInput,
as_nodes,
)
Expand Down
8 changes: 4 additions & 4 deletions src/bindings/python/src/openvino/opset12/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from functools import partial
from typing import Optional

from openvino import Node
from openvino.utils.node_factory import _get_node_factory
from openvino.utils.decorators import nameable_op
from openvino.utils.types import (
from openvino.runtime import Node
from openvino.runtime.opset_utils import _get_node_factory
from openvino.runtime.utils.decorators import nameable_op
from openvino.runtime.utils.types import (
NodeInput,
as_nodes,
as_node,
Expand Down
8 changes: 4 additions & 4 deletions src/bindings/python/src/openvino/opset13/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

log = logging.getLogger(__name__)

from openvino import Node, Shape, Type, Output, Tensor
from openvino.runtime import Node, Shape, Type, Output, Tensor
from openvino.op import Constant, Result
from openvino.opset1 import convert_like
from openvino.utils.node_factory import _get_node_factory
from openvino.utils.decorators import binary_op, nameable_op, unary_op, overloading
from openvino.utils.types import (
from openvino.runtime.opset_utils import _get_node_factory
from openvino.runtime.utils.decorators import binary_op, nameable_op, unary_op, overloading
from openvino.runtime.utils.types import (
NumericData,
NodeInput,
NumericType,
Expand Down
10 changes: 5 additions & 5 deletions src/bindings/python/src/openvino/opset14/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

from typing import Union, Optional, List

from openvino import Node, Type
from openvino.utils.node_factory import _get_node_factory
from openvino.utils.types import TensorShape
from openvino.utils.decorators import nameable_op
from openvino.utils.types import NodeInput, as_node, as_nodes
from openvino.runtime import Node, Type
from openvino.runtime.opset_utils import _get_node_factory
from openvino.runtime.utils.types import TensorShape
from openvino.runtime.utils.decorators import nameable_op
from openvino.runtime.utils.types import NodeInput, as_node, as_nodes

_get_node_factory_opset14 = partial(_get_node_factory, "opset14")

Expand Down
8 changes: 4 additions & 4 deletions src/bindings/python/src/openvino/opset15/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
from typing import List, Literal, Optional

import numpy as np
from openvino import Node, Type
from openvino.runtime import Node, Type
from openvino.opset1 import convert_like
from openvino.opset14 import constant
from openvino.utils.node_factory import _get_node_factory
from openvino.utils.decorators import binary_op, nameable_op
from openvino.utils.types import NodeInput, as_nodes
from openvino.runtime.opset_utils import _get_node_factory
from openvino.runtime.utils.decorators import binary_op, nameable_op
from openvino.runtime.utils.types import NodeInput, as_nodes

_get_node_factory_opset15 = partial(_get_node_factory, "opset15")

Expand Down
8 changes: 4 additions & 4 deletions src/bindings/python/src/openvino/opset16/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from functools import partial
from typing import Optional

from openvino import Node
from openvino.utils.decorators import nameable_op
from openvino.utils.node_factory import _get_node_factory
from openvino.utils.types import NodeInput, as_nodes
from openvino.runtime import Node
from openvino.runtime.utils.decorators import nameable_op
from openvino.runtime.opset_utils import _get_node_factory
from openvino.runtime.utils.types import NodeInput, as_nodes

_get_node_factory_opset16 = partial(_get_node_factory, "opset16")

Expand Down
Loading

0 comments on commit 68b1f54

Please sign in to comment.