Skip to content

Commit

Permalink
Replace openvino.runtime imports with openvino (#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
helena-intel authored Jan 17, 2025
1 parent 09c7005 commit c6d8b7e
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion benchmark/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import pandas as pd
import seaborn as sns
from openvino import AsyncInferQueue, CompiledModel, InferRequest
from openvino.runtime import ProfilingInfo, properties
from openvino import ProfilingInfo, properties
from openvino_tokenizers import convert_tokenizer
from tqdm.auto import tqdm
from transformers import AutoTokenizer, PreTrainedTokenizerBase
Expand Down
10 changes: 5 additions & 5 deletions python/openvino_tokenizers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from typing import Callable, Optional

import openvino
from openvino.runtime.utils.node_factory import NodeFactory
from openvino.utils.node_factory import NodeFactory


_ext_name = "openvino_tokenizers"
Expand Down Expand Up @@ -42,8 +42,8 @@
del _ext_name

# patching openvino
old_core_init = openvino.runtime.Core.__init__
old_factory_init = openvino.runtime.utils.node_factory.NodeFactory.__init__
old_core_init = openvino.Core.__init__
old_factory_init = openvino.utils.node_factory.NodeFactory.__init__
old_fe_init = openvino.frontend.frontend.FrontEnd.__init__


Expand All @@ -65,8 +65,8 @@ def new_fe_init(self, *args, **kwargs):
self.add_extension(str(_ext_path))


openvino.runtime.Core.__init__ = new_core_init
openvino.runtime.utils.node_factory.NodeFactory.__init__ = new_factory_init
openvino.Core.__init__ = new_core_init
openvino.utils.node_factory.NodeFactory.__init__ = new_factory_init
openvino.frontend.frontend.FrontEnd.__init__ = new_fe_init


Expand Down
6 changes: 3 additions & 3 deletions python/openvino_tokenizers/build_tokenizer.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import Iterable, Tuple

from openvino import Model, PartialShape, Type
from openvino.runtime import op
from openvino.runtime import opset12 as opset
from openvino.runtime.utils.types import make_constant_node
from openvino import op
from openvino import opset12 as opset
from openvino.utils.types import make_constant_node

from openvino_tokenizers.constants import DETOKENIZER_NAME, STRING_OUTPUT_NAME, TOKEN_IDS_INPUT_NAME, TOKENIZER_NAME
from openvino_tokenizers.tokenizer_pipeline import (
Expand Down
4 changes: 2 additions & 2 deletions python/openvino_tokenizers/convert_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from functools import wraps
from typing import Any, Optional, Tuple, Union

from openvino.runtime import Model, Type
from openvino.runtime.exceptions import OVTypeError
from openvino import Model, Type
from openvino.exceptions import OVTypeError

from openvino_tokenizers.constants import UTF8ReplaceMode
from openvino_tokenizers.utils import (
Expand Down
8 changes: 4 additions & 4 deletions python/openvino_tokenizers/hf_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
from typing import Any, Callable, Dict, List, Optional, Tuple, Union

import numpy as np
import openvino.runtime.opset14 as opset
import openvino.opset14 as opset
from openvino import Model, PartialShape, Type
from openvino.runtime import Node, op
from openvino.runtime.exceptions import OVTypeError
from openvino.runtime.utils.types import as_node, make_constant_node
from openvino import Node, op
from openvino.exceptions import OVTypeError
from openvino.utils.types import as_node, make_constant_node
from transformers import PreTrainedTokenizerBase, PreTrainedTokenizerFast
from transformers.convert_slow_tokenizer import import_protobuf

Expand Down
8 changes: 4 additions & 4 deletions python/openvino_tokenizers/tokenizer_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
from typing import Any, Dict, Iterable, List, Optional, Tuple, Union

import numpy as np
from openvino.runtime import Model, Output, PartialShape, Shape, Type, op
from openvino.runtime import opset12 as opset
from openvino.runtime.exceptions import OVTypeError, UserInputError
from openvino.runtime.utils.types import as_node, make_constant_node
from openvino import Model, Output, PartialShape, Shape, Type, op
from openvino import opset12 as opset
from openvino.exceptions import OVTypeError, UserInputError
from openvino.utils.types import as_node, make_constant_node

from . import _get_factory
from .constants import (
Expand Down
2 changes: 1 addition & 1 deletion python/openvino_tokenizers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from openvino import Model, Type
from openvino.preprocess import PrePostProcessor
from openvino.runtime import opset12 as opset
from openvino import opset12 as opset

from .constants import (
LOGITS_OUTPUT_NAME,
Expand Down
2 changes: 1 addition & 1 deletion tests/layer_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import openvino as ov
import pytest
from openvino import Model, PartialShape, Type
from openvino.runtime import op
from openvino import op
from openvino_tokenizers import _get_factory
from openvino_tokenizers.constants import UTF8ReplaceMode
from openvino_tokenizers.tokenizer_pipeline import (
Expand Down

0 comments on commit c6d8b7e

Please sign in to comment.