Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace openvino.runtime with openvino #3264

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ The NNCF PTQ is the simplest way to apply 8-bit quantization. To run the algorit

```python
import nncf
import openvino.runtime as ov
import openvino as ov
import torch
from torchvision import datasets, transforms

Expand Down
12 changes: 6 additions & 6 deletions nncf/common/utils/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,25 +106,25 @@ def is_onnx_model(model: Any) -> bool:
@result_verifier
def is_openvino_model(model: Any) -> bool:
"""
Returns True if the model is an instance of openvino.runtime.Model, otherwise False.
Returns True if the model is an instance of openvino.Model, otherwise False.

:param model: A target model.
:return: True if the model is an instance of openvino.runtime.Model, otherwise False.
:return: True if the model is an instance of openvino.Model, otherwise False.
"""
import openvino.runtime as ov # type: ignore
import openvino as ov

return isinstance(model, ov.Model)


@result_verifier
def is_openvino_compiled_model(model: Any) -> bool:
"""
Returns True if the model is an instance of openvino.runtime.CompiledModel, otherwise False.
Returns True if the model is an instance of openvino.CompiledModel, otherwise False.

:param model: A target model.
:return: True if the model is an instance of openvino.runtime.CompiledModel, otherwise False.
:return: True if the model is an instance of openvino.CompiledModel, otherwise False.
"""
import openvino.runtime as ov
import openvino as ov

return isinstance(model, ov.CompiledModel)

Expand Down
2 changes: 1 addition & 1 deletion nncf/openvino/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from typing import Dict, List, Tuple, Union

import numpy as np
import openvino.runtime as ov
import openvino as ov
from openvino import Type
from openvino.properties.hint import inference_precision

Expand Down
2 changes: 1 addition & 1 deletion nncf/openvino/graph/metatypes/openvino_metatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from collections import deque
from typing import List, Optional, Type

import openvino.runtime as ov
import openvino as ov

import nncf
from nncf.common.graph.operator_metatypes import INPUT_NOOP_METATYPES
Expand Down
14 changes: 7 additions & 7 deletions nncf/openvino/graph/model_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
from collections import deque
from typing import Dict, List, Tuple

import openvino.runtime as ov
from openvino.runtime import opset13 as opset
from openvino.runtime.utils.node_factory import NodeFactory
import openvino as ov
from openvino import opset13 as opset
from openvino.utils.node_factory import NodeFactory

from nncf.openvino.graph.model_transformer import OVModelTransformer
from nncf.openvino.graph.node_utils import get_parameter_node_name
Expand Down Expand Up @@ -59,14 +59,14 @@ def _collect_graph_nodes(
output_ids: List[Tuple[str, int]],
node_mapping: Dict[str, ov.Node],
) -> List[ov.Node]:
"""
r"""
A method for aggregating layers to be further cloned.
Aggregation is designed in such a way that layers are listed from right to left,
as they pass from bottom to top. This is done in order to find all constants in the model and
to start graph creation from them (as well as Parameter layers), because
OpenVINO graph is created from top-down and cannot be created otherwise.

Legend: w - weigths, c - convert, il/ih - input low/high, ol/oh - output low/high
Legend: w - weights, c - convert, il/ih - input low/high, ol/oh - output low/high
(w)
|
(c) (il) (ih) (ol) (oh)
Expand Down Expand Up @@ -115,11 +115,11 @@ def build(
output_ids: List[Tuple[str, int]],
node_mapping: Dict[str, ov.Node],
) -> ov.Model:
"""
r"""
The basic method of the algorithm. This method uses an aggregated list of layers to be recreated.
Let us take a graph of this kind as an example:

Legend: w - weigths, c - convert, il/ih - input low/high, ol/oh - output low/high
Legend: w - weights, c - convert, il/ih - input low/high, ol/oh - output low/high
(w)
|
(c) (il) (ih) (ol) (oh)
Expand Down
4 changes: 2 additions & 2 deletions nncf/openvino/graph/model_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
from typing import Callable, Dict, List, Tuple

import numpy as np
import openvino.runtime as ov
import openvino as ov
from openvino import opset13 as opset
from openvino._pyopenvino import DescriptorTensor
from openvino.runtime import opset13 as opset

import nncf
from nncf.common.graph.model_transformer import ModelTransformer
Expand Down
2 changes: 1 addition & 1 deletion nncf/openvino/graph/model_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from collections import deque
from typing import List

import openvino.runtime as ov
import openvino as ov

from nncf.common.factory import ModelTransformerFactory
from nncf.common.graph.graph import NNCFGraph
Expand Down
2 changes: 1 addition & 1 deletion nncf/openvino/graph/nncf_graph_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from collections import defaultdict
from typing import List, Type

import openvino.runtime as ov
import openvino as ov

from nncf.common.graph import NNCFGraph
from nncf.common.graph.layer_attributes import Dtype
Expand Down
6 changes: 3 additions & 3 deletions nncf/openvino/graph/node_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
from typing import Any, Callable, Dict, List, Optional, Tuple, Type

import numpy as np
import openvino.runtime as ov
import openvino.runtime.op as op
import openvino.runtime.opset13 as opset
import openvino as ov
import openvino.op as op
import openvino.opset13 as opset

import nncf
from nncf.common.graph.graph import NNCFGraph
Expand Down
2 changes: 1 addition & 1 deletion nncf/openvino/graph/transformations/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from typing import List, Optional, Tuple

import numpy as np
import openvino.runtime as ov
import openvino as ov

from nncf.common.graph.transformations.commands import Command
from nncf.common.graph.transformations.commands import TargetPoint
Expand Down
4 changes: 2 additions & 2 deletions nncf/openvino/optimized_functions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

import numpy as np
import openvino as ov
from openvino import Node
from openvino import opset13 as opset
from openvino._pyopenvino.op import Parameter
from openvino._pyopenvino.properties.hint import inference_precision
from openvino.runtime import Node
from openvino.runtime import opset13 as opset

from nncf.common.utils.backend import is_openvino_at_least
from nncf.common.utils.caching import ResultsCache
Expand Down
2 changes: 1 addition & 1 deletion nncf/openvino/quantization/quantize_ifmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from itertools import islice
from typing import Dict, List, Optional, Tuple

import openvino.runtime as ov
import openvino as ov

from nncf import Dataset
from nncf.common import factory
Expand Down
2 changes: 1 addition & 1 deletion nncf/openvino/quantization/quantize_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pathlib import Path
from typing import Any, Callable, Iterable, List, Optional, Tuple, TypeVar, Union

import openvino.runtime as ov
import openvino as ov
from openvino._offline_transformations import compress_quantize_weights_transformation

from nncf.common.factory import NNCFGraphFactory
Expand Down
2 changes: 1 addition & 1 deletion nncf/openvino/rt_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from dataclasses import asdict
from typing import Any, Dict, List, Optional

import openvino.runtime as ov
import openvino as ov

from nncf.common.logging import nncf_logger
from nncf.scopes import IgnoredScope
Expand Down
2 changes: 1 addition & 1 deletion nncf/openvino/statistics/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from typing import Dict

import numpy as np
import openvino.runtime as ov
import openvino as ov

from nncf.common.graph.graph import NNCFGraph
from nncf.common.graph.transformations.commands import TargetType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from typing import List, Optional

import numpy as np
import openvino.runtime as ov
import openvino as ov
from openvino import Type
from openvino.properties.hint import inference_precision

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from typing import Dict, Optional, Set, Tuple

import openvino.runtime as ov
import openvino as ov

from nncf.common.graph import NNCFGraph
from nncf.common.graph import NNCFNode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from typing import Any, Tuple

import numpy as np
import openvino.runtime as ov
import openvino as ov

import nncf
from nncf.common.graph import NNCFGraph
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from typing import Dict, List, Optional, Tuple

import numpy as np
import openvino.runtime as ov
import openvino as ov

from nncf.common.graph import NNCFGraph
from nncf.common.graph import NNCFNode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from typing import Dict, List, Optional

import openvino.runtime as ov
import openvino as ov

from nncf.common.graph import NNCFGraph
from nncf.common.graph.transformations.commands import TargetType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from itertools import islice
from typing import Dict, List, Optional, Tuple

import openvino.runtime as ov
import openvino as ov

from nncf.common.graph import NNCFGraph
from nncf.common.graph import NNCFNode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from typing import Callable, List, Tuple

import numpy as np
import openvino.runtime as ov
import openvino as ov

import nncf
from nncf.common.graph import NNCFGraph
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from typing import Callable, Dict, Iterable, List, Optional, Tuple

import openvino as ov
from openvino.runtime import opset13 as opset
from openvino import opset13 as opset

import nncf
from nncf.common.graph import NNCFGraph
Expand Down
2 changes: 1 addition & 1 deletion tests/cross_fw/sdl/fuzz/quantize_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from random import randint
from random import seed

import openvino.runtime as ov
import openvino as ov
import torch
from torchvision import datasets
from torchvision import transforms
Expand Down
4 changes: 2 additions & 2 deletions tests/onnx/quantization/test_ptq_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@

import numpy as np
import onnx
import openvino.runtime as ov
import openvino as ov
import pytest
import torch
from fastdownload import FastDownload
from onnx import version_converter
from openvino.runtime import Core
from openvino import Core
from sklearn.metrics import accuracy_score
from torchvision import datasets
from torchvision import transforms
Expand Down
4 changes: 2 additions & 2 deletions tests/openvino/native/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
from typing import Callable, Optional, Tuple

import numpy as np
import openvino.runtime as ov
from openvino.runtime import opset13 as opset
import openvino as ov
from openvino import opset13 as opset

from nncf.common.utils.registry import Registry
from tests.torch.test_models.inceptionv3 import inception_v3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# limitations under the License.

import numpy as np
import openvino.runtime as ov
import openvino as ov
import pytest

import nncf
Expand Down
10 changes: 5 additions & 5 deletions tests/openvino/native/quantization/test_quantize_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
from openvino.runtime import Model
from openvino.runtime import Shape
from openvino.runtime import Type
from openvino.runtime import op
from openvino.runtime import opset13 as opset
from openvino import Model
from openvino import Shape
from openvino import Type
from openvino import op
from openvino import opset13 as opset

import nncf
from nncf import Dataset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from dataclasses import dataclass
from typing import List

import openvino.runtime as ov
import openvino as ov
import pytest

from nncf.common.factory import NNCFGraphFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import numpy as np
import openvino as ov
import openvino.runtime.opset13 as opset
import openvino.opset13 as opset
import pytest

from nncf.common.graph.layer_attributes import Dtype
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
from typing import Callable, List

import numpy as np
import openvino.runtime as ov
import openvino as ov
import pandas as pd
import pytest
from attr import dataclass
from openvino.runtime import opset13 as opset
from openvino import opset13 as opset

import nncf
from nncf import CompressWeightsMode
Expand Down
4 changes: 2 additions & 2 deletions tests/openvino/native/test_layer_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
from typing import Callable, Tuple

import numpy as np
import openvino.runtime as ov
import openvino as ov
import pytest
from openvino.runtime import opset13 as opset
from openvino import opset13 as opset

from nncf.common.graph.layer_attributes import ConvolutionLayerAttributes
from nncf.common.graph.layer_attributes import GenericWeightedLayerAttributes
Expand Down
2 changes: 1 addition & 1 deletion tests/openvino/native/test_model_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from pathlib import Path

import openvino.runtime as ov
import openvino as ov
import pytest

from nncf.openvino.graph.model_builder import OVModelBuilder
Expand Down
Loading