Skip to content

Commit

Permalink
monkey patching
Browse files Browse the repository at this point in the history
  • Loading branch information
akuporos committed Feb 21, 2025
1 parent e4786fc commit c4b636c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/bindings/python/src/openvino/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from openvino._pyopenvino import Shape
from openvino._pyopenvino import Layout
from openvino._pyopenvino import Tensor
from openvino._pyopenvino import Type
from openvino._pyopenvino import OVAny
from openvino._pyopenvino import get_batch
from openvino._pyopenvino import set_batch
Expand All @@ -57,7 +58,6 @@
from openvino._ov_api import InferRequest
from openvino._ov_api import AsyncInferQueue
from openvino._ov_api import Op
from openvino._ov_api import Type

# Import all public modules
from openvino.package_utils import lazy_import
Expand Down
28 changes: 13 additions & 15 deletions src/bindings/python/src/openvino/_ov_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# SPDX-License-Identifier: Apache-2.0

from types import TracebackType
from typing import Any, Iterable, Union, Optional, Dict, Tuple, List
from typing import Type as TypeType
from typing import Any, Iterable, Union, Optional, Dict, Tuple, List, cast
from typing import Type as TypingType
from pathlib import Path


Expand All @@ -14,27 +14,25 @@
from openvino._pyopenvino import AsyncInferQueue as AsyncInferQueueBase
from openvino._pyopenvino import Op as OpBase
from openvino._pyopenvino import Node, Output, Tensor
from openvino._pyopenvino import Type as TypeBase
from openvino._pyopenvino import Type

from openvino.utils.data_helpers import (
OVDict,
_InferRequestWrapper,
_data_dispatch,
tensor_from_file,
)
from openvino.package_utils import deprecatedclassproperty

@deprecatedclassproperty(
name="openvino.Type.undefined", # noqa: N802, N805
version="2026.0",
message="Please use openvino.Type.dynamic instead.",
stacklevel=2,
)
def undefined_deprecated(self):
return Type.dynamic

class Type(TypeBase):
@deprecatedclassproperty(
name="openvino.Type.undefined", # noqa: N802, N805
version="2026.0",
message="Please use openvino.Type.dynamic instead.",
stacklevel=2,
)
def undefined(self):
return super().undefined

Type.undefined = undefined_deprecated

class Op(OpBase):
def __init__(self, py_obj: "Op", inputs: Optional[Union[List[Union[Node, Output]], Tuple[Union[Node, Output, List[Union[Node, Output]]]]]] = None) -> None:
Expand Down Expand Up @@ -90,7 +88,7 @@ def __deepcopy__(self, memo: Dict) -> "Model":
def __enter__(self) -> "Model":
return self

def __exit__(self, exc_type: TypeType[BaseException], exc_value: BaseException, traceback: TracebackType) -> None:
def __exit__(self, exc_type: TypingType[BaseException], exc_value: BaseException, traceback: TracebackType) -> None:
del self.__model
self.__model = None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ void regclass_graph_Type(py::module m) {
:param dtype: numpy dtype
:type dtype: numpy.dtype
:return: OpenVINO type object
:rtype: ov.Type
:rtype: openvino.Type
)");

type.attr("undefined") = ov::element::dynamic;
type.attr("dynamic") = ov::element::dynamic;
type.attr("boolean") = ov::element::boolean;
type.attr("f16") = ov::element::f16;
Expand Down

0 comments on commit c4b636c

Please sign in to comment.