bigdl-core-npu 2.6.0b20250114__cp311-cp311-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bigdl-core-npu/__init__.py +0 -0
- bigdl-core-npu/include/common.h +96 -0
- bigdl-core-npu/include/npu_llm.h +74 -0
- bigdl-core-npu/npu_llm.dll +0 -0
- bigdl-core-npu/npu_llm.lib +0 -0
- bigdl_core_npu-2.6.0b20250114.dist-info/METADATA +44 -0
- bigdl_core_npu-2.6.0b20250114.dist-info/RECORD +234 -0
- bigdl_core_npu-2.6.0b20250114.dist-info/WHEEL +5 -0
- bigdl_core_npu-2.6.0b20250114.dist-info/top_level.txt +2 -0
- intel_npu_acceleration_library/__init__.py +24 -0
- intel_npu_acceleration_library/_version.py +6 -0
- intel_npu_acceleration_library/backend/__init__.py +37 -0
- intel_npu_acceleration_library/backend/base.py +250 -0
- intel_npu_acceleration_library/backend/bindings.py +383 -0
- intel_npu_acceleration_library/backend/compression.py +24 -0
- intel_npu_acceleration_library/backend/convolution.py +58 -0
- intel_npu_acceleration_library/backend/factory.py +1161 -0
- intel_npu_acceleration_library/backend/linear.py +60 -0
- intel_npu_acceleration_library/backend/matmul.py +59 -0
- intel_npu_acceleration_library/backend/mlp.py +58 -0
- intel_npu_acceleration_library/backend/ops.py +142 -0
- intel_npu_acceleration_library/backend/qlinear.py +75 -0
- intel_npu_acceleration_library/backend/qmatmul.py +66 -0
- intel_npu_acceleration_library/backend/runtime.py +215 -0
- intel_npu_acceleration_library/backend/sdpa.py +107 -0
- intel_npu_acceleration_library/backend/tensor.py +1120 -0
- intel_npu_acceleration_library/backend/utils.py +70 -0
- intel_npu_acceleration_library/compiler.py +194 -0
- intel_npu_acceleration_library/device.py +230 -0
- intel_npu_acceleration_library/dtypes.py +155 -0
- intel_npu_acceleration_library/external/openvino/__init__.py +72 -0
- intel_npu_acceleration_library/external/openvino/_offline_transformations/__init__.py +21 -0
- intel_npu_acceleration_library/external/openvino/_pyopenvino.cp310-win_amd64.pyd +0 -0
- intel_npu_acceleration_library/external/openvino/_pyopenvino.cp311-win_amd64.pyd +0 -0
- intel_npu_acceleration_library/external/openvino/_pyopenvino.cp312-win_amd64.pyd +0 -0
- intel_npu_acceleration_library/external/openvino/_pyopenvino.cp38-win_amd64.pyd +0 -0
- intel_npu_acceleration_library/external/openvino/_pyopenvino.cp39-win_amd64.pyd +0 -0
- intel_npu_acceleration_library/external/openvino/experimental/__init__.py +14 -0
- intel_npu_acceleration_library/external/openvino/frontend/__init__.py +34 -0
- intel_npu_acceleration_library/external/openvino/frontend/frontend.py +44 -0
- intel_npu_acceleration_library/external/openvino/frontend/jax/__init__.py +15 -0
- intel_npu_acceleration_library/external/openvino/frontend/jax/jaxpr_decoder.py +293 -0
- intel_npu_acceleration_library/external/openvino/frontend/jax/passes.py +65 -0
- intel_npu_acceleration_library/external/openvino/frontend/jax/utils.py +182 -0
- intel_npu_acceleration_library/external/openvino/frontend/onnx/__init__.py +15 -0
- intel_npu_acceleration_library/external/openvino/frontend/onnx/py_onnx_frontend.cp310-win_amd64.pyd +0 -0
- intel_npu_acceleration_library/external/openvino/frontend/onnx/py_onnx_frontend.cp311-win_amd64.pyd +0 -0
- intel_npu_acceleration_library/external/openvino/frontend/onnx/py_onnx_frontend.cp312-win_amd64.pyd +0 -0
- intel_npu_acceleration_library/external/openvino/frontend/onnx/py_onnx_frontend.cp38-win_amd64.pyd +0 -0
- intel_npu_acceleration_library/external/openvino/frontend/onnx/py_onnx_frontend.cp39-win_amd64.pyd +0 -0
- intel_npu_acceleration_library/external/openvino/frontend/paddle/__init__.py +15 -0
- intel_npu_acceleration_library/external/openvino/frontend/paddle/py_paddle_frontend.cp310-win_amd64.pyd +0 -0
- intel_npu_acceleration_library/external/openvino/frontend/paddle/py_paddle_frontend.cp311-win_amd64.pyd +0 -0
- intel_npu_acceleration_library/external/openvino/frontend/paddle/py_paddle_frontend.cp312-win_amd64.pyd +0 -0
- intel_npu_acceleration_library/external/openvino/frontend/paddle/py_paddle_frontend.cp38-win_amd64.pyd +0 -0
- intel_npu_acceleration_library/external/openvino/frontend/paddle/py_paddle_frontend.cp39-win_amd64.pyd +0 -0
- intel_npu_acceleration_library/external/openvino/frontend/pytorch/__init__.py +19 -0
- intel_npu_acceleration_library/external/openvino/frontend/pytorch/fx_decoder.py +370 -0
- intel_npu_acceleration_library/external/openvino/frontend/pytorch/gptq.py +180 -0
- intel_npu_acceleration_library/external/openvino/frontend/pytorch/module_extension.py +39 -0
- intel_npu_acceleration_library/external/openvino/frontend/pytorch/patch_model.py +118 -0
- intel_npu_acceleration_library/external/openvino/frontend/pytorch/py_pytorch_frontend.cp310-win_amd64.pyd +0 -0
- intel_npu_acceleration_library/external/openvino/frontend/pytorch/py_pytorch_frontend.cp311-win_amd64.pyd +0 -0
- intel_npu_acceleration_library/external/openvino/frontend/pytorch/py_pytorch_frontend.cp312-win_amd64.pyd +0 -0
- intel_npu_acceleration_library/external/openvino/frontend/pytorch/py_pytorch_frontend.cp38-win_amd64.pyd +0 -0
- intel_npu_acceleration_library/external/openvino/frontend/pytorch/py_pytorch_frontend.cp39-win_amd64.pyd +0 -0
- intel_npu_acceleration_library/external/openvino/frontend/pytorch/torchdynamo/backend.py +131 -0
- intel_npu_acceleration_library/external/openvino/frontend/pytorch/torchdynamo/backend_utils.py +85 -0
- intel_npu_acceleration_library/external/openvino/frontend/pytorch/torchdynamo/compile.py +141 -0
- intel_npu_acceleration_library/external/openvino/frontend/pytorch/torchdynamo/decompositions.py +116 -0
- intel_npu_acceleration_library/external/openvino/frontend/pytorch/torchdynamo/execute.py +189 -0
- intel_npu_acceleration_library/external/openvino/frontend/pytorch/torchdynamo/op_support.py +290 -0
- intel_npu_acceleration_library/external/openvino/frontend/pytorch/torchdynamo/partition.py +126 -0
- intel_npu_acceleration_library/external/openvino/frontend/pytorch/ts_decoder.py +568 -0
- intel_npu_acceleration_library/external/openvino/frontend/pytorch/utils.py +258 -0
- intel_npu_acceleration_library/external/openvino/frontend/tensorflow/__init__.py +16 -0
- intel_npu_acceleration_library/external/openvino/frontend/tensorflow/graph_iterator.py +116 -0
- intel_npu_acceleration_library/external/openvino/frontend/tensorflow/node_decoder.py +219 -0
- intel_npu_acceleration_library/external/openvino/frontend/tensorflow/py_tensorflow_frontend.cp310-win_amd64.pyd +0 -0
- intel_npu_acceleration_library/external/openvino/frontend/tensorflow/py_tensorflow_frontend.cp311-win_amd64.pyd +0 -0
- intel_npu_acceleration_library/external/openvino/frontend/tensorflow/py_tensorflow_frontend.cp312-win_amd64.pyd +0 -0
- intel_npu_acceleration_library/external/openvino/frontend/tensorflow/py_tensorflow_frontend.cp38-win_amd64.pyd +0 -0
- intel_npu_acceleration_library/external/openvino/frontend/tensorflow/py_tensorflow_frontend.cp39-win_amd64.pyd +0 -0
- intel_npu_acceleration_library/external/openvino/frontend/tensorflow/utils.py +481 -0
- intel_npu_acceleration_library/external/openvino/helpers/__init__.py +6 -0
- intel_npu_acceleration_library/external/openvino/helpers/packing.py +87 -0
- intel_npu_acceleration_library/external/openvino/preprocess/README.md +60 -0
- intel_npu_acceleration_library/external/openvino/preprocess/__init__.py +28 -0
- intel_npu_acceleration_library/external/openvino/preprocess/torchvision/__init__.py +15 -0
- intel_npu_acceleration_library/external/openvino/preprocess/torchvision/preprocess_converter.py +47 -0
- intel_npu_acceleration_library/external/openvino/preprocess/torchvision/requirements.txt +5 -0
- intel_npu_acceleration_library/external/openvino/preprocess/torchvision/torchvision_preprocessing.py +347 -0
- intel_npu_acceleration_library/external/openvino/properties/__init__.py +22 -0
- intel_npu_acceleration_library/external/openvino/properties/_properties.py +55 -0
- intel_npu_acceleration_library/external/openvino/properties/device/__init__.py +14 -0
- intel_npu_acceleration_library/external/openvino/properties/hint/__init__.py +15 -0
- intel_npu_acceleration_library/external/openvino/properties/intel_auto/__init__.py +12 -0
- intel_npu_acceleration_library/external/openvino/properties/intel_cpu/__init__.py +8 -0
- intel_npu_acceleration_library/external/openvino/properties/intel_gpu/__init__.py +12 -0
- intel_npu_acceleration_library/external/openvino/properties/intel_gpu/hint/__init__.py +11 -0
- intel_npu_acceleration_library/external/openvino/properties/log/__init__.py +11 -0
- intel_npu_acceleration_library/external/openvino/properties/streams/__init__.py +11 -0
- intel_npu_acceleration_library/external/openvino/runtime/__init__.py +85 -0
- intel_npu_acceleration_library/external/openvino/runtime/exceptions.py +17 -0
- intel_npu_acceleration_library/external/openvino/runtime/ie_api.py +631 -0
- intel_npu_acceleration_library/external/openvino/runtime/op/__init__.py +19 -0
- intel_npu_acceleration_library/external/openvino/runtime/op/util/__init__.py +22 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset1/__init__.py +112 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset1/ops.py +3068 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset10/__init__.py +179 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset10/ops.py +173 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset11/__init__.py +179 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset11/ops.py +107 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset12/__init__.py +180 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset12/ops.py +120 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset13/__init__.py +188 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset13/ops.py +398 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset14/__init__.py +190 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset14/ops.py +171 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset15/__init__.py +17 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset15/ops.py +276 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset2/__init__.py +118 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset2/ops.py +216 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset3/__init__.py +134 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset3/ops.py +638 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset4/__init__.py +145 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset4/ops.py +464 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset5/__init__.py +152 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset5/ops.py +372 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset6/__init__.py +154 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset6/ops.py +215 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset7/__init__.py +158 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset7/ops.py +169 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset8/__init__.py +169 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset8/ops.py +787 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset9/__init__.py +175 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset9/ops.py +341 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset_utils.py +22 -0
- intel_npu_acceleration_library/external/openvino/runtime/passes/__init__.py +19 -0
- intel_npu_acceleration_library/external/openvino/runtime/passes/graph_rewrite.py +33 -0
- intel_npu_acceleration_library/external/openvino/runtime/passes/manager.py +26 -0
- intel_npu_acceleration_library/external/openvino/runtime/properties/__init__.py +40 -0
- intel_npu_acceleration_library/external/openvino/runtime/properties/hint/__init__.py +25 -0
- intel_npu_acceleration_library/external/openvino/runtime/utils/__init__.py +7 -0
- intel_npu_acceleration_library/external/openvino/runtime/utils/broadcasting.py +44 -0
- intel_npu_acceleration_library/external/openvino/runtime/utils/data_helpers/__init__.py +8 -0
- intel_npu_acceleration_library/external/openvino/runtime/utils/data_helpers/data_dispatcher.py +447 -0
- intel_npu_acceleration_library/external/openvino/runtime/utils/data_helpers/wrappers.py +148 -0
- intel_npu_acceleration_library/external/openvino/runtime/utils/decorators.py +156 -0
- intel_npu_acceleration_library/external/openvino/runtime/utils/input_validation.py +133 -0
- intel_npu_acceleration_library/external/openvino/runtime/utils/node_factory.py +127 -0
- intel_npu_acceleration_library/external/openvino/runtime/utils/reduction.py +25 -0
- intel_npu_acceleration_library/external/openvino/runtime/utils/types.py +175 -0
- intel_npu_acceleration_library/external/openvino/tools/__init__.py +4 -0
- intel_npu_acceleration_library/external/openvino/tools/benchmark/__init__.py +3 -0
- intel_npu_acceleration_library/external/openvino/tools/benchmark/benchmark.py +186 -0
- intel_npu_acceleration_library/external/openvino/tools/benchmark/main.py +695 -0
- intel_npu_acceleration_library/external/openvino/tools/benchmark/parameters.py +199 -0
- intel_npu_acceleration_library/external/openvino/tools/benchmark/utils/__init__.py +3 -0
- intel_npu_acceleration_library/external/openvino/tools/benchmark/utils/constants.py +26 -0
- intel_npu_acceleration_library/external/openvino/tools/benchmark/utils/inputs_filling.py +482 -0
- intel_npu_acceleration_library/external/openvino/tools/benchmark/utils/logging.py +8 -0
- intel_npu_acceleration_library/external/openvino/tools/benchmark/utils/statistics_report.py +296 -0
- intel_npu_acceleration_library/external/openvino/tools/benchmark/utils/utils.py +836 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/__init__.py +20 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/__main__.py +10 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/cli_parser.py +633 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/convert.py +102 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/convert_data_type.py +82 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/convert_impl.py +550 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/environment_setup_utils.py +50 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/error.py +49 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/get_ov_update_message.py +16 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/help.py +45 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/logger.py +91 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/main.py +40 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/__init__.py +2 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/analysis.py +46 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/check_config.py +57 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/extractor.py +447 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/jax_frontend_utils.py +19 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/layout_utils.py +73 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/moc_emit_ir.py +32 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/offline_transformations.py +107 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/paddle_frontend_utils.py +83 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/pipeline.py +298 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/preprocessing.py +220 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/pytorch_frontend_utils.py +214 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/shape_utils.py +109 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/type_utils.py +82 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/ovc.py +13 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/telemetry_params.py +6 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/telemetry_stub.py +28 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/telemetry_utils.py +118 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/utils.py +196 -0
- intel_npu_acceleration_library/external/openvino/tools/ovc/version.py +80 -0
- intel_npu_acceleration_library/external/openvino/torch/__init__.py +5 -0
- intel_npu_acceleration_library/external/openvino/utils.py +115 -0
- intel_npu_acceleration_library/functional/__init__.py +8 -0
- intel_npu_acceleration_library/functional/scaled_dot_product_attention.py +47 -0
- intel_npu_acceleration_library/lib/Release/cache.json +113732 -0
- intel_npu_acceleration_library/lib/Release/intel_npu_acceleration_library.dll +0 -0
- intel_npu_acceleration_library/lib/Release/openvino.dll +0 -0
- intel_npu_acceleration_library/lib/Release/openvino_auto_batch_plugin.dll +0 -0
- intel_npu_acceleration_library/lib/Release/openvino_auto_plugin.dll +0 -0
- intel_npu_acceleration_library/lib/Release/openvino_c.dll +0 -0
- intel_npu_acceleration_library/lib/Release/openvino_hetero_plugin.dll +0 -0
- intel_npu_acceleration_library/lib/Release/openvino_intel_cpu_plugin.dll +0 -0
- intel_npu_acceleration_library/lib/Release/openvino_intel_gpu_plugin.dll +0 -0
- intel_npu_acceleration_library/lib/Release/openvino_intel_npu_plugin.dll +0 -0
- intel_npu_acceleration_library/lib/Release/openvino_ir_frontend.dll +0 -0
- intel_npu_acceleration_library/lib/Release/openvino_onnx_frontend.dll +0 -0
- intel_npu_acceleration_library/lib/Release/openvino_paddle_frontend.dll +0 -0
- intel_npu_acceleration_library/lib/Release/openvino_pytorch_frontend.dll +0 -0
- intel_npu_acceleration_library/lib/Release/openvino_tensorflow_frontend.dll +0 -0
- intel_npu_acceleration_library/lib/Release/openvino_tensorflow_lite_frontend.dll +0 -0
- intel_npu_acceleration_library/lib/Release/tbb12.dll +0 -0
- intel_npu_acceleration_library/lib/Release/tbb12_debug.dll +0 -0
- intel_npu_acceleration_library/lib/Release/tbbbind_2_5.dll +0 -0
- intel_npu_acceleration_library/lib/Release/tbbbind_2_5_debug.dll +0 -0
- intel_npu_acceleration_library/lib/Release/tbbmalloc.dll +0 -0
- intel_npu_acceleration_library/lib/Release/tbbmalloc_debug.dll +0 -0
- intel_npu_acceleration_library/lib/Release/tbbmalloc_proxy.dll +0 -0
- intel_npu_acceleration_library/lib/Release/tbbmalloc_proxy_debug.dll +0 -0
- intel_npu_acceleration_library/modelling.py +150 -0
- intel_npu_acceleration_library/nn/__init__.py +20 -0
- intel_npu_acceleration_library/nn/autograd.py +68 -0
- intel_npu_acceleration_library/nn/conv.py +257 -0
- intel_npu_acceleration_library/nn/functional.py +1207 -0
- intel_npu_acceleration_library/nn/linear.py +162 -0
- intel_npu_acceleration_library/nn/llm.py +417 -0
- intel_npu_acceleration_library/nn/module.py +393 -0
- intel_npu_acceleration_library/optimizations.py +157 -0
- intel_npu_acceleration_library/quantization.py +174 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2018-2024 Intel Corporation
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
4
|
+
|
5
|
+
"""openvino exceptions hierarchy. All exceptions are descendants of OVError."""
|
6
|
+
|
7
|
+
|
8
|
+
class OVError(Exception):
|
9
|
+
"""Base class for OV exceptions."""
|
10
|
+
|
11
|
+
|
12
|
+
class UserInputError(OVError):
|
13
|
+
"""User provided unexpected input."""
|
14
|
+
|
15
|
+
|
16
|
+
class OVTypeError(OVError, TypeError):
|
17
|
+
"""Type mismatch error."""
|
@@ -0,0 +1,631 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2018-2024 Intel Corporation
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
4
|
+
|
5
|
+
from typing import Any, Iterable, Union, Optional, Dict
|
6
|
+
from pathlib import Path
|
7
|
+
import warnings
|
8
|
+
|
9
|
+
import numpy as np
|
10
|
+
|
11
|
+
from openvino._pyopenvino import Model as ModelBase
|
12
|
+
from openvino._pyopenvino import Core as CoreBase
|
13
|
+
from openvino._pyopenvino import CompiledModel as CompiledModelBase
|
14
|
+
from openvino._pyopenvino import AsyncInferQueue as AsyncInferQueueBase
|
15
|
+
from openvino._pyopenvino import Tensor
|
16
|
+
from openvino._pyopenvino import Node
|
17
|
+
|
18
|
+
from openvino.runtime.utils.data_helpers import (
|
19
|
+
OVDict,
|
20
|
+
_InferRequestWrapper,
|
21
|
+
_data_dispatch,
|
22
|
+
tensor_from_file,
|
23
|
+
)
|
24
|
+
|
25
|
+
|
26
|
+
class Model(ModelBase):
|
27
|
+
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
28
|
+
if args and not kwargs:
|
29
|
+
if isinstance(args[0], ModelBase):
|
30
|
+
super().__init__(args[0])
|
31
|
+
elif isinstance(args[0], Node):
|
32
|
+
super().__init__(*args)
|
33
|
+
else:
|
34
|
+
super().__init__(*args)
|
35
|
+
if args and kwargs:
|
36
|
+
super().__init__(*args, **kwargs)
|
37
|
+
if kwargs and not args:
|
38
|
+
super().__init__(**kwargs)
|
39
|
+
|
40
|
+
def clone(self) -> "Model":
|
41
|
+
return Model(super().clone())
|
42
|
+
|
43
|
+
def __deepcopy__(self, memo: Dict) -> "Model":
|
44
|
+
"""Returns a deepcopy of Model.
|
45
|
+
|
46
|
+
:return: A copy of Model.
|
47
|
+
:rtype: openvino.runtime.Model
|
48
|
+
"""
|
49
|
+
return Model(super().clone())
|
50
|
+
|
51
|
+
|
52
|
+
class InferRequest(_InferRequestWrapper):
|
53
|
+
"""InferRequest class represents infer request which can be run in asynchronous or synchronous manners."""
|
54
|
+
|
55
|
+
def infer(
|
56
|
+
self,
|
57
|
+
inputs: Any = None,
|
58
|
+
share_inputs: bool = False,
|
59
|
+
share_outputs: bool = False,
|
60
|
+
*,
|
61
|
+
decode_strings: bool = True,
|
62
|
+
) -> OVDict:
|
63
|
+
"""Infers specified input(s) in synchronous mode.
|
64
|
+
|
65
|
+
Blocks all methods of InferRequest while request is running.
|
66
|
+
Calling any method will lead to throwing exceptions.
|
67
|
+
|
68
|
+
The allowed types of keys in the `inputs` dictionary are:
|
69
|
+
|
70
|
+
(1) `int`
|
71
|
+
(2) `str`
|
72
|
+
(3) `openvino.runtime.ConstOutput`
|
73
|
+
|
74
|
+
The allowed types of values in the `inputs` are:
|
75
|
+
|
76
|
+
(1) `numpy.ndarray` and all the types that are castable to it, e.g. `torch.Tensor`
|
77
|
+
(2) `openvino.runtime.Tensor`
|
78
|
+
|
79
|
+
Can be called with only one `openvino.runtime.Tensor` or `numpy.ndarray`,
|
80
|
+
it will work only with one-input models. When model has more inputs,
|
81
|
+
function throws error.
|
82
|
+
|
83
|
+
:param inputs: Data to be set on input tensors.
|
84
|
+
:type inputs: Any, optional
|
85
|
+
:param share_inputs: Enables `share_inputs` mode. Controls memory usage on inference's inputs.
|
86
|
+
|
87
|
+
If set to `False` inputs the data dispatcher will safely copy data
|
88
|
+
to existing Tensors (including up- or down-casting according to data type,
|
89
|
+
resizing of the input Tensor). Keeps Tensor inputs "as-is".
|
90
|
+
|
91
|
+
If set to `True` the data dispatcher tries to provide "zero-copy"
|
92
|
+
Tensors for every input in form of:
|
93
|
+
* `numpy.ndarray` and all the types that are castable to it, e.g. `torch.Tensor`
|
94
|
+
Data that is going to be copied:
|
95
|
+
* `numpy.ndarray` which are not C contiguous and/or not writable (WRITEABLE flag is set to False)
|
96
|
+
* inputs which data types are mismatched from Infer Request's inputs
|
97
|
+
* inputs that should be in `BF16` data type
|
98
|
+
* scalar inputs (i.e. `np.float_`/`str`/`bytes`/`int`/`float`)
|
99
|
+
* lists of simple data types (i.e. `str`/`bytes`/`int`/`float`)
|
100
|
+
Keeps Tensor inputs "as-is".
|
101
|
+
|
102
|
+
Note: Use with extra care, shared data can be modified during runtime!
|
103
|
+
Note: Using `share_inputs` may result in extra memory overhead.
|
104
|
+
|
105
|
+
Default value: False
|
106
|
+
:type share_inputs: bool, optional
|
107
|
+
:param share_outputs: Enables `share_outputs` mode. Controls memory usage on inference's outputs.
|
108
|
+
|
109
|
+
If set to `False` outputs will safely copy data to numpy arrays.
|
110
|
+
|
111
|
+
If set to `True` the data will be returned in form of views of output Tensors.
|
112
|
+
This mode still returns the data in format of numpy arrays but lifetime of the data
|
113
|
+
is connected to OpenVINO objects.
|
114
|
+
|
115
|
+
Note: Use with extra care, shared data can be modified or lost during runtime!
|
116
|
+
Note: String/textual data will always be copied!
|
117
|
+
|
118
|
+
Default value: False
|
119
|
+
:type share_outputs: bool, optional
|
120
|
+
:param decode_strings: Controls decoding outputs of textual based data.
|
121
|
+
|
122
|
+
If set to `True` string outputs will be returned as numpy arrays of `U` kind.
|
123
|
+
|
124
|
+
If set to `False` string outputs will be returned as numpy arrays of `S` kind.
|
125
|
+
|
126
|
+
Default value: True
|
127
|
+
:type decode_strings: bool, optional, keyword-only
|
128
|
+
|
129
|
+
:return: Dictionary of results from output tensors with port/int/str keys.
|
130
|
+
:rtype: OVDict
|
131
|
+
"""
|
132
|
+
return OVDict(super().infer(_data_dispatch(
|
133
|
+
self,
|
134
|
+
inputs,
|
135
|
+
is_shared=share_inputs,
|
136
|
+
), share_outputs=share_outputs, decode_strings=decode_strings))
|
137
|
+
|
138
|
+
def start_async(
|
139
|
+
self,
|
140
|
+
inputs: Any = None,
|
141
|
+
userdata: Any = None,
|
142
|
+
share_inputs: bool = False,
|
143
|
+
) -> None:
|
144
|
+
"""Starts inference of specified input(s) in asynchronous mode.
|
145
|
+
|
146
|
+
Returns immediately. Inference starts also immediately.
|
147
|
+
Calling any method on the `InferRequest` object while the request is running
|
148
|
+
will lead to throwing exceptions.
|
149
|
+
|
150
|
+
The allowed types of keys in the `inputs` dictionary are:
|
151
|
+
|
152
|
+
(1) `int`
|
153
|
+
(2) `str`
|
154
|
+
(3) `openvino.runtime.ConstOutput`
|
155
|
+
|
156
|
+
The allowed types of values in the `inputs` are:
|
157
|
+
|
158
|
+
(1) `numpy.ndarray` and all the types that are castable to it, e.g. `torch.Tensor`
|
159
|
+
(2) `openvino.runtime.Tensor`
|
160
|
+
|
161
|
+
Can be called with only one `openvino.runtime.Tensor` or `numpy.ndarray`,
|
162
|
+
it will work only with one-input models. When model has more inputs,
|
163
|
+
function throws error.
|
164
|
+
|
165
|
+
:param inputs: Data to be set on input tensors.
|
166
|
+
:type inputs: Any, optional
|
167
|
+
:param userdata: Any data that will be passed inside the callback.
|
168
|
+
:type userdata: Any
|
169
|
+
:param share_inputs: Enables `share_inputs` mode. Controls memory usage on inference's inputs.
|
170
|
+
|
171
|
+
If set to `False` inputs the data dispatcher will safely copy data
|
172
|
+
to existing Tensors (including up- or down-casting according to data type,
|
173
|
+
resizing of the input Tensor). Keeps Tensor inputs "as-is".
|
174
|
+
|
175
|
+
If set to `True` the data dispatcher tries to provide "zero-copy"
|
176
|
+
Tensors for every input in form of:
|
177
|
+
* `numpy.ndarray` and all the types that are castable to it, e.g. `torch.Tensor`
|
178
|
+
Data that is going to be copied:
|
179
|
+
* `numpy.ndarray` which are not C contiguous and/or not writable (WRITEABLE flag is set to False)
|
180
|
+
* inputs which data types are mismatched from Infer Request's inputs
|
181
|
+
* inputs that should be in `BF16` data type
|
182
|
+
* scalar inputs (i.e. `np.float_`/`str`/`bytes`/`int`/`float`)
|
183
|
+
* lists of simple data types (i.e. `str`/`bytes`/`int`/`float`)
|
184
|
+
Keeps Tensor inputs "as-is".
|
185
|
+
|
186
|
+
Note: Use with extra care, shared data can be modified during runtime!
|
187
|
+
Note: Using `share_inputs` may result in extra memory overhead.
|
188
|
+
|
189
|
+
Default value: False
|
190
|
+
:type share_inputs: bool, optional
|
191
|
+
"""
|
192
|
+
super().start_async(
|
193
|
+
_data_dispatch(
|
194
|
+
self,
|
195
|
+
inputs,
|
196
|
+
is_shared=share_inputs,
|
197
|
+
),
|
198
|
+
userdata,
|
199
|
+
)
|
200
|
+
|
201
|
+
def get_compiled_model(self) -> "CompiledModel":
|
202
|
+
"""Gets the compiled model this InferRequest is using.
|
203
|
+
|
204
|
+
:return: a CompiledModel object
|
205
|
+
:rtype: openvino.runtime.ie_api.CompiledModel
|
206
|
+
"""
|
207
|
+
return CompiledModel(super().get_compiled_model())
|
208
|
+
|
209
|
+
@property
|
210
|
+
def results(self) -> OVDict:
|
211
|
+
"""Gets all outputs tensors of this InferRequest.
|
212
|
+
|
213
|
+
:return: Dictionary of results from output tensors with ports as keys.
|
214
|
+
:rtype: Dict[openvino.runtime.ConstOutput, numpy.array]
|
215
|
+
"""
|
216
|
+
return OVDict(super().results)
|
217
|
+
|
218
|
+
|
219
|
+
class CompiledModel(CompiledModelBase):
|
220
|
+
"""CompiledModel class.
|
221
|
+
|
222
|
+
CompiledModel represents Model that is compiled for a specific device by applying
|
223
|
+
multiple optimization transformations, then mapping to compute kernels.
|
224
|
+
"""
|
225
|
+
|
226
|
+
def __init__(self, other: CompiledModelBase, weights: Optional[bytes] = None) -> None:
|
227
|
+
# Private memeber to store already created InferRequest
|
228
|
+
self._infer_request: Optional[InferRequest] = None
|
229
|
+
self._weights = weights
|
230
|
+
super().__init__(other)
|
231
|
+
|
232
|
+
def get_runtime_model(self) -> Model:
|
233
|
+
return Model(super().get_runtime_model())
|
234
|
+
|
235
|
+
def create_infer_request(self) -> InferRequest:
|
236
|
+
"""Creates an inference request object used to infer the compiled model.
|
237
|
+
|
238
|
+
The created request has allocated input and output tensors.
|
239
|
+
|
240
|
+
:return: New InferRequest object.
|
241
|
+
:rtype: openvino.runtime.InferRequest
|
242
|
+
"""
|
243
|
+
return InferRequest(super().create_infer_request())
|
244
|
+
|
245
|
+
def query_state(self) -> None:
|
246
|
+
"""Gets state control interface for the underlaying infer request.
|
247
|
+
|
248
|
+
:return: List of VariableState objects.
|
249
|
+
:rtype: List[openvino.runtime.VariableState]
|
250
|
+
"""
|
251
|
+
if self._infer_request is None:
|
252
|
+
self._infer_request = self.create_infer_request()
|
253
|
+
|
254
|
+
return self._infer_request.query_state()
|
255
|
+
|
256
|
+
def reset_state(self) -> None:
|
257
|
+
"""Resets all internal variable states of the underlaying infer request.
|
258
|
+
|
259
|
+
Resets all internal variable states to a value specified as default for
|
260
|
+
the corresponding `ReadValue` node.
|
261
|
+
"""
|
262
|
+
if self._infer_request is None:
|
263
|
+
self._infer_request = self.create_infer_request()
|
264
|
+
|
265
|
+
return self._infer_request.reset_state()
|
266
|
+
|
267
|
+
def infer_new_request(self, inputs: Any = None) -> OVDict:
|
268
|
+
"""Infers specified input(s) in synchronous mode.
|
269
|
+
|
270
|
+
Blocks all methods of CompiledModel while request is running.
|
271
|
+
|
272
|
+
Method creates new temporary InferRequest and run inference on it.
|
273
|
+
It is advised to use a dedicated InferRequest class for performance,
|
274
|
+
optimizing workflows, and creating advanced pipelines.
|
275
|
+
|
276
|
+
The allowed types of keys in the `inputs` dictionary are:
|
277
|
+
|
278
|
+
(1) `int`
|
279
|
+
(2) `str`
|
280
|
+
(3) `openvino.runtime.ConstOutput`
|
281
|
+
|
282
|
+
The allowed types of values in the `inputs` are:
|
283
|
+
|
284
|
+
(1) `numpy.ndarray` and all the types that are castable to it, e.g. `torch.Tensor`
|
285
|
+
(2) `openvino.runtime.Tensor`
|
286
|
+
|
287
|
+
Can be called with only one `openvino.runtime.Tensor` or `numpy.ndarray`,
|
288
|
+
it will work only with one-input models. When model has more inputs,
|
289
|
+
function throws error.
|
290
|
+
|
291
|
+
:param inputs: Data to be set on input tensors.
|
292
|
+
:type inputs: Any, optional
|
293
|
+
:return: Dictionary of results from output tensors with port/int/str keys.
|
294
|
+
:rtype: OVDict
|
295
|
+
"""
|
296
|
+
# It returns wrapped python InferReqeust and then call upon
|
297
|
+
# overloaded functions of InferRequest class
|
298
|
+
return self.create_infer_request().infer(inputs)
|
299
|
+
|
300
|
+
def __call__(
|
301
|
+
self,
|
302
|
+
inputs: Any = None,
|
303
|
+
share_inputs: bool = True,
|
304
|
+
share_outputs: bool = False,
|
305
|
+
*,
|
306
|
+
decode_strings: bool = True,
|
307
|
+
) -> OVDict:
|
308
|
+
"""Callable infer wrapper for CompiledModel.
|
309
|
+
|
310
|
+
Infers specified input(s) in synchronous mode.
|
311
|
+
|
312
|
+
Blocks all methods of CompiledModel while request is running.
|
313
|
+
|
314
|
+
Method creates new temporary InferRequest and run inference on it.
|
315
|
+
It is advised to use a dedicated InferRequest class for performance,
|
316
|
+
optimizing workflows, and creating advanced pipelines.
|
317
|
+
|
318
|
+
This method stores created `InferRequest` inside `CompiledModel` object,
|
319
|
+
which can be later reused in consecutive calls.
|
320
|
+
|
321
|
+
The allowed types of keys in the `inputs` dictionary are:
|
322
|
+
|
323
|
+
(1) `int`
|
324
|
+
(2) `str`
|
325
|
+
(3) `openvino.runtime.ConstOutput`
|
326
|
+
|
327
|
+
The allowed types of values in the `inputs` are:
|
328
|
+
|
329
|
+
(1) `numpy.ndarray` and all the types that are castable to it, e.g. `torch.Tensor`
|
330
|
+
(2) `openvino.runtime.Tensor`
|
331
|
+
|
332
|
+
Can be called with only one `openvino.runtime.Tensor` or `numpy.ndarray`,
|
333
|
+
it will work only with one-input models. When model has more inputs,
|
334
|
+
function throws error.
|
335
|
+
|
336
|
+
:param inputs: Data to be set on input tensors.
|
337
|
+
:type inputs: Any, optional
|
338
|
+
:param share_inputs: Enables `share_inputs` mode. Controls memory usage on inference's inputs.
|
339
|
+
|
340
|
+
If set to `False` inputs the data dispatcher will safely copy data
|
341
|
+
to existing Tensors (including up- or down-casting according to data type,
|
342
|
+
resizing of the input Tensor). Keeps Tensor inputs "as-is".
|
343
|
+
|
344
|
+
If set to `True` the data dispatcher tries to provide "zero-copy"
|
345
|
+
Tensors for every input in form of:
|
346
|
+
* `numpy.ndarray` and all the types that are castable to it, e.g. `torch.Tensor`
|
347
|
+
Data that is going to be copied:
|
348
|
+
* `numpy.ndarray` which are not C contiguous and/or not writable (WRITEABLE flag is set to False)
|
349
|
+
* inputs which data types are mismatched from Infer Request's inputs
|
350
|
+
* inputs that should be in `BF16` data type
|
351
|
+
* scalar inputs (i.e. `np.float_`/`str`/`bytes`/`int`/`float`)
|
352
|
+
* lists of simple data types (i.e. `str`/`bytes`/`int`/`float`)
|
353
|
+
Keeps Tensor inputs "as-is".
|
354
|
+
|
355
|
+
Note: Use with extra care, shared data can be modified during runtime!
|
356
|
+
Note: Using `share_inputs` may result in extra memory overhead.
|
357
|
+
|
358
|
+
Default value: True
|
359
|
+
:type share_inputs: bool, optional
|
360
|
+
:param share_outputs: Enables `share_outputs` mode. Controls memory usage on inference's outputs.
|
361
|
+
|
362
|
+
If set to `False` outputs will safely copy data to numpy arrays.
|
363
|
+
|
364
|
+
If set to `True` the data will be returned in form of views of output Tensors.
|
365
|
+
This mode still returns the data in format of numpy arrays but lifetime of the data
|
366
|
+
is connected to OpenVINO objects.
|
367
|
+
|
368
|
+
Note: Use with extra care, shared data can be modified or lost during runtime!
|
369
|
+
Note: String/textual data will always be copied!
|
370
|
+
|
371
|
+
Default value: False
|
372
|
+
:type share_outputs: bool, optional
|
373
|
+
:param decode_strings: Controls decoding outputs of textual based data.
|
374
|
+
|
375
|
+
If set to `True` string outputs will be returned as numpy arrays of `U` kind.
|
376
|
+
|
377
|
+
If set to `False` string outputs will be returned as numpy arrays of `S` kind.
|
378
|
+
|
379
|
+
Default value: True
|
380
|
+
:type decode_strings: bool, optional, keyword-only
|
381
|
+
|
382
|
+
:return: Dictionary of results from output tensors with port/int/str as keys.
|
383
|
+
:rtype: OVDict
|
384
|
+
"""
|
385
|
+
if self._infer_request is None:
|
386
|
+
self._infer_request = self.create_infer_request()
|
387
|
+
|
388
|
+
return self._infer_request.infer(
|
389
|
+
inputs,
|
390
|
+
share_inputs=share_inputs,
|
391
|
+
share_outputs=share_outputs,
|
392
|
+
decode_strings=decode_strings,
|
393
|
+
)
|
394
|
+
|
395
|
+
|
396
|
+
class AsyncInferQueue(AsyncInferQueueBase):
|
397
|
+
"""AsyncInferQueue with a pool of asynchronous requests.
|
398
|
+
|
399
|
+
AsyncInferQueue represents a helper that creates a pool of asynchronous
|
400
|
+
InferRequests and provides synchronization functions to control flow of
|
401
|
+
a simple pipeline.
|
402
|
+
"""
|
403
|
+
|
404
|
+
def __iter__(self) -> Iterable[InferRequest]:
|
405
|
+
"""Allows to iterate over AsyncInferQueue.
|
406
|
+
|
407
|
+
Resulting objects are guaranteed to work with read-only methods like getting tensors.
|
408
|
+
Any mutating methods (e.g. start_async, set_callback) of a single request
|
409
|
+
will put the parent AsyncInferQueue object in an invalid state.
|
410
|
+
|
411
|
+
:return: a generator that yields InferRequests.
|
412
|
+
:rtype: Iterable[openvino.runtime.InferRequest]
|
413
|
+
"""
|
414
|
+
return (InferRequest(x) for x in super().__iter__())
|
415
|
+
|
416
|
+
def __getitem__(self, i: int) -> InferRequest:
|
417
|
+
"""Gets InferRequest from the pool with given i id.
|
418
|
+
|
419
|
+
Resulting object is guaranteed to work with read-only methods like getting tensors.
|
420
|
+
Any mutating methods (e.g. start_async, set_callback) of a request
|
421
|
+
will put the parent AsyncInferQueue object in an invalid state.
|
422
|
+
|
423
|
+
:param i: InferRequest id.
|
424
|
+
:type i: int
|
425
|
+
:return: InferRequests from the pool with given id.
|
426
|
+
:rtype: openvino.runtime.InferRequest
|
427
|
+
"""
|
428
|
+
return InferRequest(super().__getitem__(i))
|
429
|
+
|
430
|
+
def start_async(
|
431
|
+
self,
|
432
|
+
inputs: Any = None,
|
433
|
+
userdata: Any = None,
|
434
|
+
share_inputs: bool = False,
|
435
|
+
) -> None:
|
436
|
+
"""Run asynchronous inference using the next available InferRequest from the pool.
|
437
|
+
|
438
|
+
The allowed types of keys in the `inputs` dictionary are:
|
439
|
+
|
440
|
+
(1) `int`
|
441
|
+
(2) `str`
|
442
|
+
(3) `openvino.runtime.ConstOutput`
|
443
|
+
|
444
|
+
The allowed types of values in the `inputs` are:
|
445
|
+
|
446
|
+
(1) `numpy.ndarray` and all the types that are castable to it, e.g. `torch.Tensor`
|
447
|
+
(2) `openvino.runtime.Tensor`
|
448
|
+
|
449
|
+
Can be called with only one `openvino.runtime.Tensor` or `numpy.ndarray`,
|
450
|
+
it will work only with one-input models. When model has more inputs,
|
451
|
+
function throws error.
|
452
|
+
|
453
|
+
:param inputs: Data to be set on input tensors of the next available InferRequest.
|
454
|
+
:type inputs: Any, optional
|
455
|
+
:param userdata: Any data that will be passed to a callback.
|
456
|
+
:type userdata: Any, optional
|
457
|
+
:param share_inputs: Enables `share_inputs` mode. Controls memory usage on inference's inputs.
|
458
|
+
|
459
|
+
If set to `False` inputs the data dispatcher will safely copy data
|
460
|
+
to existing Tensors (including up- or down-casting according to data type,
|
461
|
+
resizing of the input Tensor). Keeps Tensor inputs "as-is".
|
462
|
+
|
463
|
+
If set to `True` the data dispatcher tries to provide "zero-copy"
|
464
|
+
Tensors for every input in form of:
|
465
|
+
* `numpy.ndarray` and all the types that are castable to it, e.g. `torch.Tensor`
|
466
|
+
Data that is going to be copied:
|
467
|
+
* `numpy.ndarray` which are not C contiguous and/or not writable (WRITEABLE flag is set to False)
|
468
|
+
* inputs which data types are mismatched from Infer Request's inputs
|
469
|
+
* inputs that should be in `BF16` data type
|
470
|
+
* scalar inputs (i.e. `np.float_`/`str`/`bytes`/`int`/`float`)
|
471
|
+
* lists of simple data types (i.e. `str`/`bytes`/`int`/`float`)
|
472
|
+
Keeps Tensor inputs "as-is".
|
473
|
+
|
474
|
+
Note: Use with extra care, shared data can be modified during runtime!
|
475
|
+
Note: Using `share_inputs` may result in extra memory overhead.
|
476
|
+
|
477
|
+
Default value: False
|
478
|
+
:type share_inputs: bool, optional
|
479
|
+
"""
|
480
|
+
super().start_async(
|
481
|
+
_data_dispatch(
|
482
|
+
self[self.get_idle_request_id()],
|
483
|
+
inputs,
|
484
|
+
is_shared=share_inputs,
|
485
|
+
),
|
486
|
+
userdata,
|
487
|
+
)
|
488
|
+
|
489
|
+
|
490
|
+
class Core(CoreBase):
|
491
|
+
"""Core class represents OpenVINO runtime Core entity.
|
492
|
+
|
493
|
+
User applications can create several Core class instances, but in this
|
494
|
+
case, the underlying plugins are created multiple times and not shared
|
495
|
+
between several Core instances. The recommended way is to have a single
|
496
|
+
Core instance per application.
|
497
|
+
"""
|
498
|
+
def read_model(self, model: Union[str, bytes, object], weights: Union[object, str, bytes, Tensor] = None) -> Model:
|
499
|
+
if weights is not None:
|
500
|
+
return Model(super().read_model(model, weights))
|
501
|
+
else:
|
502
|
+
return Model(super().read_model(model))
|
503
|
+
|
504
|
+
def compile_model(
|
505
|
+
self,
|
506
|
+
model: Union[Model, str, Path],
|
507
|
+
device_name: Optional[str] = None,
|
508
|
+
config: Optional[dict] = None,
|
509
|
+
*,
|
510
|
+
weights: Optional[bytes] = None,
|
511
|
+
) -> CompiledModel:
|
512
|
+
"""Creates a compiled model.
|
513
|
+
|
514
|
+
Creates a compiled model from a source Model object or
|
515
|
+
reads model and creates a compiled model from IR / ONNX / PDPD / TF and TFLite file or
|
516
|
+
creates a compiled model from a IR xml and weights in memory.
|
517
|
+
This can be more efficient than using read_model + compile_model(model_in_memory_object) flow,
|
518
|
+
especially for cases when caching is enabled and cached model is available.
|
519
|
+
If device_name is not specified, the default OpenVINO device will be selected by AUTO plugin.
|
520
|
+
Users can create as many compiled models as they need, and use them simultaneously
|
521
|
+
(up to the limitation of the hardware resources).
|
522
|
+
|
523
|
+
:param model: Model acquired from read_model function or a path to a model in IR / ONNX / PDPD /
|
524
|
+
TF and TFLite format.
|
525
|
+
:type model: Union[openvino.runtime.Model, str, pathlib.Path]
|
526
|
+
:param device_name: Optional. Name of the device to load the model to. If not specified,
|
527
|
+
the default OpenVINO device will be selected by AUTO plugin.
|
528
|
+
:type device_name: str
|
529
|
+
:param config: Optional dict of pairs:
|
530
|
+
(property name, property value) relevant only for this load operation.
|
531
|
+
:type config: dict, optional
|
532
|
+
:param weights: Optional. Weights of model in memory to be loaded to the model.
|
533
|
+
:type weights: bytes, optional, keyword-only
|
534
|
+
:return: A compiled model.
|
535
|
+
:rtype: openvino.runtime.CompiledModel
|
536
|
+
"""
|
537
|
+
if weights is None:
|
538
|
+
if device_name is None:
|
539
|
+
return CompiledModel(
|
540
|
+
super().compile_model(model, {} if config is None else config),
|
541
|
+
)
|
542
|
+
return CompiledModel(
|
543
|
+
super().compile_model(model, device_name, {} if config is None else config),
|
544
|
+
)
|
545
|
+
else:
|
546
|
+
if device_name is None:
|
547
|
+
return CompiledModel(
|
548
|
+
super().compile_model(model, weights, {} if config is None else config),
|
549
|
+
weights=weights,
|
550
|
+
)
|
551
|
+
return CompiledModel(
|
552
|
+
super().compile_model(model, weights, device_name, {} if config is None else config),
|
553
|
+
weights=weights,
|
554
|
+
)
|
555
|
+
|
556
|
+
def import_model(
|
557
|
+
self,
|
558
|
+
model_stream: bytes,
|
559
|
+
device_name: str,
|
560
|
+
config: Optional[dict] = None,
|
561
|
+
) -> CompiledModel:
|
562
|
+
"""Imports a compiled model from a previously exported one.
|
563
|
+
|
564
|
+
:param model_stream: Input stream, containing a model previously exported, using export_model method.
|
565
|
+
:type model_stream: bytes
|
566
|
+
:param device_name: Name of device to which compiled model is imported.
|
567
|
+
Note: if device_name is not used to compile the original model,
|
568
|
+
an exception is thrown.
|
569
|
+
:type device_name: str
|
570
|
+
:param config: Optional dict of pairs:
|
571
|
+
(property name, property value) relevant only for this load operation.
|
572
|
+
:type config: dict, optional
|
573
|
+
:return: A compiled model.
|
574
|
+
:rtype: openvino.runtime.CompiledModel
|
575
|
+
|
576
|
+
:Example:
|
577
|
+
|
578
|
+
.. code-block:: python
|
579
|
+
|
580
|
+
user_stream = compiled.export_model()
|
581
|
+
|
582
|
+
with open('./my_model', 'wb') as f:
|
583
|
+
f.write(user_stream)
|
584
|
+
|
585
|
+
# ...
|
586
|
+
|
587
|
+
new_compiled = core.import_model(user_stream, "CPU")
|
588
|
+
|
589
|
+
.. code-block:: python
|
590
|
+
|
591
|
+
user_stream = io.BytesIO()
|
592
|
+
compiled.export_model(user_stream)
|
593
|
+
|
594
|
+
with open('./my_model', 'wb') as f:
|
595
|
+
f.write(user_stream.getvalue()) # or read() if seek(0) was applied before
|
596
|
+
|
597
|
+
# ...
|
598
|
+
|
599
|
+
new_compiled = core.import_model(user_stream, "CPU")
|
600
|
+
"""
|
601
|
+
return CompiledModel(
|
602
|
+
super().import_model(
|
603
|
+
model_stream,
|
604
|
+
device_name,
|
605
|
+
{} if config is None else config,
|
606
|
+
),
|
607
|
+
)
|
608
|
+
|
609
|
+
|
610
|
+
def compile_model(
|
611
|
+
model: Union[Model, str, Path],
|
612
|
+
device_name: Optional[str] = "AUTO",
|
613
|
+
config: Optional[dict] = None,
|
614
|
+
) -> CompiledModel:
|
615
|
+
"""Compact method to compile model with AUTO plugin.
|
616
|
+
|
617
|
+
:param model: Model acquired from read_model function or a path to a model in IR / ONNX / PDPD /
|
618
|
+
TF and TFLite format.
|
619
|
+
:type model: Union[openvino.runtime.Model, str, pathlib.Path]
|
620
|
+
:param device_name: Optional. Name of the device to load the model to. If not specified,
|
621
|
+
the default OpenVINO device will be selected by AUTO plugin.
|
622
|
+
:type device_name: str
|
623
|
+
:param config: Optional dict of pairs:
|
624
|
+
(property name, property value) relevant only for this load operation.
|
625
|
+
:type config: dict, optional
|
626
|
+
:return: A compiled model.
|
627
|
+
:rtype: openvino.runtime.CompiledModel
|
628
|
+
|
629
|
+
"""
|
630
|
+
core = Core()
|
631
|
+
return core.compile_model(model, device_name, {} if config is None else config)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Copyright (C) 2018-2024 Intel Corporation
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
3
|
+
|
4
|
+
"""
|
5
|
+
Package: openvino.op
|
6
|
+
Low level wrappers for the c++ api in ov::op.
|
7
|
+
"""
|
8
|
+
|
9
|
+
# flake8: noqa
|
10
|
+
|
11
|
+
from openvino._pyopenvino.op import Constant
|
12
|
+
from openvino._pyopenvino.op import assign
|
13
|
+
from openvino._pyopenvino.op import _PagedAttentionExtension
|
14
|
+
from openvino._pyopenvino.op import Parameter
|
15
|
+
from openvino._pyopenvino.op import if_op
|
16
|
+
from openvino._pyopenvino.op import loop
|
17
|
+
from openvino._pyopenvino.op import tensor_iterator
|
18
|
+
from openvino._pyopenvino.op import read_value
|
19
|
+
from openvino._pyopenvino.op import Result
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Copyright (C) 2018-2024 Intel Corporation
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
3
|
+
|
4
|
+
"""
|
5
|
+
Package: openvino.op.util
|
6
|
+
Low level wrappers for the c++ api in ov::op::util.
|
7
|
+
"""
|
8
|
+
# flake8: noqa
|
9
|
+
|
10
|
+
from openvino._pyopenvino.op.util import UnaryElementwiseArithmetic
|
11
|
+
from openvino._pyopenvino.op.util import BinaryElementwiseComparison
|
12
|
+
from openvino._pyopenvino.op.util import BinaryElementwiseArithmetic
|
13
|
+
from openvino._pyopenvino.op.util import BinaryElementwiseLogical
|
14
|
+
from openvino._pyopenvino.op.util import ArithmeticReduction
|
15
|
+
from openvino._pyopenvino.op.util import IndexReduction
|
16
|
+
from openvino._pyopenvino.op.util import VariableInfo
|
17
|
+
from openvino._pyopenvino.op.util import Variable
|
18
|
+
from openvino._pyopenvino.op.util import MergedInputDescription
|
19
|
+
from openvino._pyopenvino.op.util import InvariantInputDescription
|
20
|
+
from openvino._pyopenvino.op.util import SliceInputDescription
|
21
|
+
from openvino._pyopenvino.op.util import ConcatOutputDescription
|
22
|
+
from openvino._pyopenvino.op.util import BodyOutputDescription
|