bigdl-core-npu 2.5.0__cp310-cp310-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-2.5.0.dist-info/METADATA +35 -0
- bigdl_core_npu-2.5.0.dist-info/RECORD +223 -0
- bigdl_core_npu-2.5.0.dist-info/WHEEL +5 -0
- bigdl_core_npu-2.5.0.dist-info/top_level.txt +1 -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 +215 -0
- intel_npu_acceleration_library/backend/bindings.py +279 -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 +944 -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 +141 -0
- intel_npu_acceleration_library/backend/qlinear.py +71 -0
- intel_npu_acceleration_library/backend/qmatmul.py +66 -0
- intel_npu_acceleration_library/backend/runtime.py +210 -0
- intel_npu_acceleration_library/backend/sdpa.py +107 -0
- intel_npu_acceleration_library/backend/tensor.py +1050 -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 +122 -0
- intel_npu_acceleration_library/external/openvino/__init__.py +71 -0
- intel_npu_acceleration_library/external/openvino/_offline_transformations/__init__.py +20 -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/frontend/__init__.py +34 -0
- intel_npu_acceleration_library/external/openvino/frontend/frontend.py +44 -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 +352 -0
- intel_npu_acceleration_library/external/openvino/frontend/pytorch/gptq.py +139 -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 +98 -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 +119 -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 +289 -0
- intel_npu_acceleration_library/external/openvino/frontend/pytorch/torchdynamo/partition.py +118 -0
- intel_npu_acceleration_library/external/openvino/frontend/pytorch/ts_decoder.py +536 -0
- intel_npu_acceleration_library/external/openvino/frontend/pytorch/utils.py +256 -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 +460 -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 +26 -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 +4 -0
- intel_npu_acceleration_library/external/openvino/preprocess/torchvision/torchvision_preprocessing.py +347 -0
- intel_npu_acceleration_library/external/openvino/properties/__init__.py +21 -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 +18 -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 +3067 -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 +399 -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 +10 -0
- intel_npu_acceleration_library/external/openvino/runtime/opset15/ops.py +85 -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 +189 -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 +783 -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 +38 -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 +429 -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 +70 -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 +536 -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 +35 -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/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 +246 -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 +205 -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 +109 -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 +98 -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,171 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2018-2024 Intel Corporation
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
4
|
+
|
5
|
+
"""Factory functions for ops added to openvino opset14."""
|
6
|
+
from functools import partial
|
7
|
+
|
8
|
+
from typing import Union, Optional, List
|
9
|
+
|
10
|
+
from openvino.runtime import Node, Type
|
11
|
+
from openvino.runtime.opset_utils import _get_node_factory
|
12
|
+
from openvino.runtime.utils.types import TensorShape
|
13
|
+
from openvino.runtime.utils.decorators import nameable_op
|
14
|
+
from openvino.runtime.utils.types import NodeInput, as_node, as_nodes
|
15
|
+
|
16
|
+
_get_node_factory_opset14 = partial(_get_node_factory, "opset14")
|
17
|
+
|
18
|
+
|
19
|
+
# -------------------------------------------- ops ------------------------------------------------
|
20
|
+
|
21
|
+
@nameable_op
|
22
|
+
def convert_promote_types(
|
23
|
+
left_node: NodeInput,
|
24
|
+
right_node: NodeInput,
|
25
|
+
promote_unsafe: bool = False,
|
26
|
+
pytorch_scalar_promotion: bool = False,
|
27
|
+
u64_integer_promotion_target: Union[str, Type] = "f32",
|
28
|
+
name: Optional[str] = None,
|
29
|
+
) -> Node:
|
30
|
+
"""Return a node performing conversion to common type based on promotion rules.
|
31
|
+
|
32
|
+
:param left_node: input node with type to be promoted to common one.
|
33
|
+
:param right_node: input node with type to be promoted to common one.
|
34
|
+
:param promote_unsafe: Bool attribute whether to allow promotions that might result in bit-widening, precision loss and undefined behaviors.
|
35
|
+
:param pytorch_scalar_promotion: Bool attribute whether to promote scalar input to type provided by non-scalar input when number format is matching.
|
36
|
+
:param u64_integer_promotion_target: Element type attribute to select promotion result when inputs are u64 and signed integer.
|
37
|
+
:param name: Optional name for the new output node.
|
38
|
+
|
39
|
+
:return: The new node performing ConvertPromoteTypes operation.
|
40
|
+
"""
|
41
|
+
inputs = as_nodes(left_node, right_node, name=name)
|
42
|
+
|
43
|
+
attributes = {
|
44
|
+
"promote_unsafe": promote_unsafe,
|
45
|
+
"pytorch_scalar_promotion": pytorch_scalar_promotion,
|
46
|
+
"u64_integer_promotion_target": u64_integer_promotion_target,
|
47
|
+
}
|
48
|
+
return _get_node_factory_opset14().create("ConvertPromoteTypes", inputs, attributes)
|
49
|
+
|
50
|
+
|
51
|
+
@nameable_op
|
52
|
+
def inverse(
|
53
|
+
data: NodeInput,
|
54
|
+
adjoint: bool = False,
|
55
|
+
name: Optional[str] = None,
|
56
|
+
) -> Node:
|
57
|
+
"""Return a node with inverse matrices of the input.
|
58
|
+
|
59
|
+
:param data: Tensor with matrices to invert. Last two dimensions must be of the same size.
|
60
|
+
:param adjoint: Whether to return adjoint instead of inverse matrices. Defaults to false.
|
61
|
+
:param name: Optional name for the new output node.
|
62
|
+
|
63
|
+
:return: The new node performing Inverse operation.
|
64
|
+
"""
|
65
|
+
inputs = as_nodes(data, name=name)
|
66
|
+
|
67
|
+
attributes = {
|
68
|
+
"adjoint": adjoint,
|
69
|
+
}
|
70
|
+
|
71
|
+
return _get_node_factory_opset14().create("Inverse", inputs, attributes)
|
72
|
+
|
73
|
+
|
74
|
+
@nameable_op
|
75
|
+
def max_pool(
|
76
|
+
data: NodeInput,
|
77
|
+
strides: List[int],
|
78
|
+
dilations: List[int],
|
79
|
+
pads_begin: List[int],
|
80
|
+
pads_end: List[int],
|
81
|
+
kernel_shape: TensorShape,
|
82
|
+
rounding_type: str = "floor",
|
83
|
+
auto_pad: Optional[str] = None,
|
84
|
+
index_element_type: Optional[Union[str, Type]] = "i64",
|
85
|
+
axis: Optional[int] = 0,
|
86
|
+
name: Optional[str] = None,
|
87
|
+
) -> Node:
|
88
|
+
"""Perform max pooling operation and return both values and indices of the selected elements.
|
89
|
+
|
90
|
+
:param data: The node providing input data.
|
91
|
+
:param strides: The distance (in pixels) to slide the filter on the feature map
|
92
|
+
over the axes.
|
93
|
+
:param dilations: The dilation of filter elements(distance between elements).
|
94
|
+
:param pads_begin: The number of pixels to add at the beginning along each axis.
|
95
|
+
:param pads_end: The number of pixels to add at the end along each axis.
|
96
|
+
:param kernel_shape: The pooling operation kernel shape.
|
97
|
+
:param rounding_type: Determines used rounding schema when computing output shape.
|
98
|
+
Acceptable values are: ['floor', 'ceil', 'ceil_torch']. Defaults to 'floor'.
|
99
|
+
:param auto_pad: Determines how the padding is calculated. Acceptable values:
|
100
|
+
[None, 'same_upper', 'same_lower', 'valid']. Defaults to None.
|
101
|
+
:param index_element_type: The data type used for the indices output of this operator.
|
102
|
+
Defaults to i64.
|
103
|
+
:param axis: The first dimension in the data shape used to determine the maximum
|
104
|
+
returned index value. The value is the product of all dimensions
|
105
|
+
starting at the provided axis. Defaults to 0.
|
106
|
+
:param name: The optional name for the created output node.
|
107
|
+
|
108
|
+
:return: The new node performing max pooling operation.
|
109
|
+
"""
|
110
|
+
if auto_pad is None:
|
111
|
+
auto_pad = "explicit"
|
112
|
+
return _get_node_factory_opset14().create(
|
113
|
+
"MaxPool",
|
114
|
+
[as_node(data, name=name)],
|
115
|
+
{
|
116
|
+
"strides": strides,
|
117
|
+
"dilations": dilations,
|
118
|
+
"pads_begin": pads_begin,
|
119
|
+
"pads_end": pads_end,
|
120
|
+
"kernel": kernel_shape,
|
121
|
+
"rounding_type": rounding_type.upper(),
|
122
|
+
"auto_pad": auto_pad.upper(),
|
123
|
+
"index_element_type": index_element_type,
|
124
|
+
"axis": axis,
|
125
|
+
},
|
126
|
+
)
|
127
|
+
|
128
|
+
|
129
|
+
@nameable_op
|
130
|
+
def avg_pool(
|
131
|
+
data_batch: NodeInput,
|
132
|
+
strides: List[int],
|
133
|
+
pads_begin: TensorShape,
|
134
|
+
pads_end: TensorShape,
|
135
|
+
kernel_shape: TensorShape,
|
136
|
+
exclude_pad: bool,
|
137
|
+
rounding_type: str = "floor",
|
138
|
+
auto_pad: Optional[str] = None,
|
139
|
+
name: Optional[str] = None,
|
140
|
+
) -> Node:
|
141
|
+
"""Return average pooling node.
|
142
|
+
|
143
|
+
:param data_batch: The input node providing data.
|
144
|
+
:param strides: The window movement strides.
|
145
|
+
:param pads_begin: The number of pixels to add at the beginning along each axis.
|
146
|
+
:param pads_end: The number of pixels to add at the end along each axis.
|
147
|
+
:param kernel_shape: The pooling window shape.
|
148
|
+
:param exclude_pad: Whether or not to include zero padding in average computations.
|
149
|
+
:param rounding_type: Determines used rounding schema when computing output shape. Acceptable
|
150
|
+
values are: ['floor', 'ceil', 'ceil_torch']. Defaults to 'floor'.
|
151
|
+
:param auto_pad: Determines how the padding is calculated. Acceptable values:
|
152
|
+
[None, 'same_upper', 'same_lower', 'valid']. Defaults to None.
|
153
|
+
:param name: Optional name for the new output node.
|
154
|
+
|
155
|
+
:return: New node with AvgPool operation applied on its data.
|
156
|
+
"""
|
157
|
+
if auto_pad is None:
|
158
|
+
auto_pad = "explicit"
|
159
|
+
return _get_node_factory_opset14().create(
|
160
|
+
"AvgPool",
|
161
|
+
[as_node(data_batch, name=name)],
|
162
|
+
{
|
163
|
+
"strides": strides,
|
164
|
+
"pads_begin": pads_begin,
|
165
|
+
"pads_end": pads_end,
|
166
|
+
"kernel": kernel_shape,
|
167
|
+
"exclude-pad": exclude_pad,
|
168
|
+
"rounding_type": rounding_type.upper(),
|
169
|
+
"auto_pad": auto_pad.upper(),
|
170
|
+
},
|
171
|
+
)
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2018-2024 Intel Corporation
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
4
|
+
|
5
|
+
# Inlcudes new operators added in Opset15
|
6
|
+
|
7
|
+
# TODO (ticket 138273): Add previous opset operators at the end of opset15 development
|
8
|
+
from openvino.runtime.opset1.ops import parameter
|
9
|
+
from openvino.runtime.opset15.ops import col2im
|
10
|
+
from openvino.runtime.opset15.ops import scatter_nd_update
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2018-2024 Intel Corporation
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
4
|
+
|
5
|
+
"""Factory functions for ops added to openvino opset15."""
|
6
|
+
from functools import partial
|
7
|
+
from typing import Optional, Literal, List
|
8
|
+
|
9
|
+
from openvino.runtime import Node, Type
|
10
|
+
from openvino.runtime.opset_utils import _get_node_factory
|
11
|
+
from openvino.runtime.utils.decorators import nameable_op
|
12
|
+
from openvino.runtime.utils.types import NodeInput, as_nodes
|
13
|
+
|
14
|
+
_get_node_factory_opset15 = partial(_get_node_factory, "opset15")
|
15
|
+
|
16
|
+
# -------------------------------------------- ops ------------------------------------------------
|
17
|
+
|
18
|
+
|
19
|
+
@nameable_op
|
20
|
+
def scatter_nd_update(
|
21
|
+
data: NodeInput,
|
22
|
+
indices: NodeInput,
|
23
|
+
updates: NodeInput,
|
24
|
+
reduction: Optional[Literal["none", "sum", "sub", "prod", "min", "max"]] = None,
|
25
|
+
name: Optional[str] = None,
|
26
|
+
) -> Node:
|
27
|
+
"""Return a node which performs ScatterNDUpdate.
|
28
|
+
|
29
|
+
:param data: Node input representing the tensor to be updated.
|
30
|
+
:param indices: Node input representing the indices at which updates will be applied.
|
31
|
+
:param updates: Node input representing the updates to be applied.
|
32
|
+
:param reduction: The type of operation to perform on the inputs. One of "none", "sum",
|
33
|
+
"sub", "prod", "min", "max".
|
34
|
+
:param name: Optional name for the output node.
|
35
|
+
:return: New node performing the ScatterNDUpdate.
|
36
|
+
"""
|
37
|
+
inputs = as_nodes(data, indices, updates, name=name)
|
38
|
+
attributes = {}
|
39
|
+
if reduction:
|
40
|
+
attributes["reduction"] = reduction
|
41
|
+
return _get_node_factory_opset15().create("ScatterNDUpdate", inputs, attributes)
|
42
|
+
|
43
|
+
|
44
|
+
@nameable_op
|
45
|
+
def col2im(
|
46
|
+
data: NodeInput,
|
47
|
+
output_size: NodeInput,
|
48
|
+
kernel_size: NodeInput,
|
49
|
+
strides: Optional[List[int]] = None,
|
50
|
+
dilations: Optional[List[int]] = None,
|
51
|
+
pads_begin: Optional[List[int]] = None,
|
52
|
+
pads_end: Optional[List[int]] = None,
|
53
|
+
name: Optional[str] = None,
|
54
|
+
) -> Node:
|
55
|
+
"""Perform data movement operation which combines sliding blocks into an image tensor.
|
56
|
+
|
57
|
+
:param data: The node providing input data.
|
58
|
+
:param output_size: Shape of the spatial dimensions of the output image.
|
59
|
+
:param kernel_size: Size of the sliding blocks.
|
60
|
+
:param strides: Stride on the sliding blocks in the input spatial dimensions. Defaults to [1, 1].
|
61
|
+
:param dilations: The dilation of filter elements (distance between elements). Defaults to [1, 1].
|
62
|
+
:param pads_begin: The number of pixels added at the beginning along each axis. Defaults to [0, 0].
|
63
|
+
:param pads_end: The number of pixels added at the end along each axis. Defaults to [0, 0].
|
64
|
+
:param name: The optional name for the created output node.
|
65
|
+
|
66
|
+
:return: The new node performing Col2Im operation.
|
67
|
+
"""
|
68
|
+
if strides is None:
|
69
|
+
strides = [1, 1]
|
70
|
+
if dilations is None:
|
71
|
+
dilations = [1, 1]
|
72
|
+
if pads_begin is None:
|
73
|
+
pads_begin = [0, 0]
|
74
|
+
if pads_end is None:
|
75
|
+
pads_end = [0, 0]
|
76
|
+
return _get_node_factory_opset15().create(
|
77
|
+
"Col2Im",
|
78
|
+
as_nodes(data, output_size, kernel_size, name=name),
|
79
|
+
{
|
80
|
+
"strides": strides,
|
81
|
+
"dilations": dilations,
|
82
|
+
"pads_begin": pads_begin,
|
83
|
+
"pads_end": pads_end,
|
84
|
+
},
|
85
|
+
)
|
@@ -0,0 +1,118 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2018-2024 Intel Corporation
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
4
|
+
|
5
|
+
from openvino.runtime.opset1.ops import absolute
|
6
|
+
from openvino.runtime.opset1.ops import absolute as abs
|
7
|
+
from openvino.runtime.opset1.ops import acos
|
8
|
+
from openvino.runtime.opset1.ops import add
|
9
|
+
from openvino.runtime.opset1.ops import asin
|
10
|
+
from openvino.runtime.opset1.ops import atan
|
11
|
+
from openvino.runtime.opset1.ops import avg_pool
|
12
|
+
from openvino.runtime.opset1.ops import batch_norm_inference
|
13
|
+
from openvino.runtime.opset2.ops import batch_to_space
|
14
|
+
from openvino.runtime.opset1.ops import binary_convolution
|
15
|
+
from openvino.runtime.opset1.ops import broadcast
|
16
|
+
from openvino.runtime.opset1.ops import ceiling
|
17
|
+
from openvino.runtime.opset1.ops import ceiling as ceil
|
18
|
+
from openvino.runtime.opset1.ops import clamp
|
19
|
+
from openvino.runtime.opset1.ops import concat
|
20
|
+
from openvino.runtime.opset1.ops import constant
|
21
|
+
from openvino.runtime.opset1.ops import convert
|
22
|
+
from openvino.runtime.opset1.ops import convert_like
|
23
|
+
from openvino.runtime.opset1.ops import convolution
|
24
|
+
from openvino.runtime.opset1.ops import convolution_backprop_data
|
25
|
+
from openvino.runtime.opset1.ops import cos
|
26
|
+
from openvino.runtime.opset1.ops import cosh
|
27
|
+
from openvino.runtime.opset1.ops import ctc_greedy_decoder
|
28
|
+
from openvino.runtime.opset1.ops import deformable_convolution
|
29
|
+
from openvino.runtime.opset1.ops import deformable_psroi_pooling
|
30
|
+
from openvino.runtime.opset1.ops import depth_to_space
|
31
|
+
from openvino.runtime.opset1.ops import detection_output
|
32
|
+
from openvino.runtime.opset1.ops import divide
|
33
|
+
from openvino.runtime.opset1.ops import elu
|
34
|
+
from openvino.runtime.opset1.ops import equal
|
35
|
+
from openvino.runtime.opset1.ops import erf
|
36
|
+
from openvino.runtime.opset1.ops import exp
|
37
|
+
from openvino.runtime.opset1.ops import fake_quantize
|
38
|
+
from openvino.runtime.opset1.ops import floor
|
39
|
+
from openvino.runtime.opset1.ops import floor_mod
|
40
|
+
from openvino.runtime.opset1.ops import gather
|
41
|
+
from openvino.runtime.opset1.ops import gather_tree
|
42
|
+
from openvino.runtime.opset2.ops import gelu
|
43
|
+
from openvino.runtime.opset1.ops import greater
|
44
|
+
from openvino.runtime.opset1.ops import greater_equal
|
45
|
+
from openvino.runtime.opset1.ops import grn
|
46
|
+
from openvino.runtime.opset1.ops import group_convolution
|
47
|
+
from openvino.runtime.opset1.ops import group_convolution_backprop_data
|
48
|
+
from openvino.runtime.opset1.ops import hard_sigmoid
|
49
|
+
from openvino.runtime.opset1.ops import interpolate
|
50
|
+
from openvino.runtime.opset1.ops import less
|
51
|
+
from openvino.runtime.opset1.ops import less_equal
|
52
|
+
from openvino.runtime.opset1.ops import log
|
53
|
+
from openvino.runtime.opset1.ops import logical_and
|
54
|
+
from openvino.runtime.opset1.ops import logical_not
|
55
|
+
from openvino.runtime.opset1.ops import logical_or
|
56
|
+
from openvino.runtime.opset1.ops import logical_xor
|
57
|
+
from openvino.runtime.opset1.ops import lrn
|
58
|
+
from openvino.runtime.opset1.ops import lstm_cell
|
59
|
+
from openvino.runtime.opset1.ops import lstm_sequence
|
60
|
+
from openvino.runtime.opset1.ops import matmul
|
61
|
+
from openvino.runtime.opset1.ops import max_pool
|
62
|
+
from openvino.runtime.opset1.ops import maximum
|
63
|
+
from openvino.runtime.opset1.ops import minimum
|
64
|
+
from openvino.runtime.opset1.ops import mod
|
65
|
+
from openvino.runtime.opset1.ops import multiply
|
66
|
+
from openvino.runtime.opset2.ops import mvn
|
67
|
+
from openvino.runtime.opset1.ops import negative
|
68
|
+
from openvino.runtime.opset1.ops import non_max_suppression
|
69
|
+
from openvino.runtime.opset1.ops import normalize_l2
|
70
|
+
from openvino.runtime.opset1.ops import not_equal
|
71
|
+
from openvino.runtime.opset1.ops import one_hot
|
72
|
+
from openvino.runtime.opset1.ops import pad
|
73
|
+
from openvino.runtime.opset1.ops import parameter
|
74
|
+
from openvino.runtime.opset1.ops import power
|
75
|
+
from openvino.runtime.opset1.ops import prelu
|
76
|
+
from openvino.runtime.opset1.ops import prior_box
|
77
|
+
from openvino.runtime.opset1.ops import prior_box_clustered
|
78
|
+
from openvino.runtime.opset1.ops import psroi_pooling
|
79
|
+
from openvino.runtime.opset1.ops import proposal
|
80
|
+
from openvino.runtime.opset1.ops import range
|
81
|
+
from openvino.runtime.opset1.ops import reduce_logical_and
|
82
|
+
from openvino.runtime.opset1.ops import reduce_logical_or
|
83
|
+
from openvino.runtime.opset1.ops import reduce_max
|
84
|
+
from openvino.runtime.opset1.ops import reduce_mean
|
85
|
+
from openvino.runtime.opset1.ops import reduce_min
|
86
|
+
from openvino.runtime.opset1.ops import reduce_prod
|
87
|
+
from openvino.runtime.opset1.ops import reduce_sum
|
88
|
+
from openvino.runtime.opset1.ops import region_yolo
|
89
|
+
from openvino.runtime.opset2.ops import reorg_yolo
|
90
|
+
from openvino.runtime.opset1.ops import relu
|
91
|
+
from openvino.runtime.opset1.ops import reshape
|
92
|
+
from openvino.runtime.opset1.ops import result
|
93
|
+
from openvino.runtime.opset1.ops import reverse_sequence
|
94
|
+
from openvino.runtime.opset2.ops import roi_pooling
|
95
|
+
from openvino.runtime.opset1.ops import select
|
96
|
+
from openvino.runtime.opset1.ops import selu
|
97
|
+
from openvino.runtime.opset1.ops import shape_of
|
98
|
+
from openvino.runtime.opset1.ops import sigmoid
|
99
|
+
from openvino.runtime.opset1.ops import sign
|
100
|
+
from openvino.runtime.opset1.ops import sin
|
101
|
+
from openvino.runtime.opset1.ops import sinh
|
102
|
+
from openvino.runtime.opset1.ops import softmax
|
103
|
+
from openvino.runtime.opset2.ops import space_to_batch
|
104
|
+
from openvino.runtime.opset1.ops import space_to_depth
|
105
|
+
from openvino.runtime.opset1.ops import split
|
106
|
+
from openvino.runtime.opset1.ops import sqrt
|
107
|
+
from openvino.runtime.opset1.ops import squared_difference
|
108
|
+
from openvino.runtime.opset1.ops import squeeze
|
109
|
+
from openvino.runtime.opset1.ops import strided_slice
|
110
|
+
from openvino.runtime.opset1.ops import subtract
|
111
|
+
from openvino.runtime.opset1.ops import tan
|
112
|
+
from openvino.runtime.opset1.ops import tanh
|
113
|
+
from openvino.runtime.opset1.ops import tensor_iterator
|
114
|
+
from openvino.runtime.opset1.ops import tile
|
115
|
+
from openvino.runtime.opset1.ops import topk
|
116
|
+
from openvino.runtime.opset1.ops import transpose
|
117
|
+
from openvino.runtime.opset1.ops import unsqueeze
|
118
|
+
from openvino.runtime.opset1.ops import variadic_split
|
@@ -0,0 +1,216 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2018-2024 Intel Corporation
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
4
|
+
|
5
|
+
"""Factory functions for all openvino ops."""
|
6
|
+
from typing import Callable, Iterable, List, Optional, Set, Union
|
7
|
+
|
8
|
+
import numpy as np
|
9
|
+
from functools import partial
|
10
|
+
import warnings
|
11
|
+
|
12
|
+
from openvino.runtime import Node, Shape
|
13
|
+
from openvino.runtime.op import Constant, Parameter
|
14
|
+
from openvino.runtime.opset_utils import _get_node_factory
|
15
|
+
from openvino.runtime.utils.decorators import binary_op, nameable_op, unary_op
|
16
|
+
from openvino.runtime.utils.input_validation import (
|
17
|
+
assert_list_of_ints,
|
18
|
+
check_valid_attributes,
|
19
|
+
is_non_negative_value,
|
20
|
+
is_positive_value,
|
21
|
+
)
|
22
|
+
from openvino.runtime.utils.node_factory import NodeFactory
|
23
|
+
from openvino.runtime.utils.types import (
|
24
|
+
NodeInput,
|
25
|
+
NumericData,
|
26
|
+
NumericType,
|
27
|
+
ScalarData,
|
28
|
+
TensorShape,
|
29
|
+
as_node,
|
30
|
+
as_nodes,
|
31
|
+
get_dtype,
|
32
|
+
get_element_type,
|
33
|
+
get_element_type_str,
|
34
|
+
make_constant_node,
|
35
|
+
)
|
36
|
+
|
37
|
+
_get_node_factory_opset2 = partial(_get_node_factory, "opset2")
|
38
|
+
|
39
|
+
# -------------------------------------------- ops ------------------------------------------------
|
40
|
+
|
41
|
+
|
42
|
+
@nameable_op
|
43
|
+
def batch_to_space(
|
44
|
+
data: NodeInput,
|
45
|
+
block_shape: NodeInput,
|
46
|
+
crops_begin: NodeInput,
|
47
|
+
crops_end: NodeInput,
|
48
|
+
name: Optional[str] = None,
|
49
|
+
) -> Node:
|
50
|
+
"""Perform BatchToSpace operation on the input tensor.
|
51
|
+
|
52
|
+
BatchToSpace permutes data from the batch dimension of the data tensor into spatial dimensions.
|
53
|
+
|
54
|
+
:param data: Node producing the data tensor.
|
55
|
+
:param block_shape: The sizes of the block of values to be moved.
|
56
|
+
:param crops_begin: Specifies the amount to crop from the beginning along each axis of `data`.
|
57
|
+
:param crops_end: Specifies the amount to crop from the end along each axis of `data`.
|
58
|
+
:param name: Optional output node name.
|
59
|
+
:return: The new node performing a BatchToSpace operation.
|
60
|
+
"""
|
61
|
+
return _get_node_factory_opset2().create(
|
62
|
+
"BatchToSpace",
|
63
|
+
as_nodes(data, block_shape, crops_begin, crops_end, name=name),
|
64
|
+
)
|
65
|
+
|
66
|
+
|
67
|
+
@unary_op
|
68
|
+
def gelu(node: NodeInput, name: Optional[str] = None) -> Node:
|
69
|
+
r"""Perform Gaussian Error Linear Unit operation element-wise on data from input node.
|
70
|
+
|
71
|
+
Computes GELU function:
|
72
|
+
|
73
|
+
\f[ f(x) = 0.5\cdot x\cdot(1 + erf( \dfrac{x}{\sqrt{2}}) \f]
|
74
|
+
|
75
|
+
For more information refer to [Gaussian Error Linear Unit (GELU)](https://arxiv.org/pdf/1606.08415.pdf>)
|
76
|
+
|
77
|
+
:param node: Input tensor. One of: input node, array or scalar.
|
78
|
+
:param name: Optional output node name.
|
79
|
+
:return: The new node performing a GELU operation on its input data element-wise.
|
80
|
+
"""
|
81
|
+
return _get_node_factory_opset2().create("Gelu", [node])
|
82
|
+
|
83
|
+
|
84
|
+
@nameable_op
|
85
|
+
def mvn(
|
86
|
+
data: Node,
|
87
|
+
across_channels: bool = False,
|
88
|
+
normalize_variance: bool = False,
|
89
|
+
eps: float = 1e-9,
|
90
|
+
name: Optional[str] = None,
|
91
|
+
) -> Node:
|
92
|
+
r"""Perform Mean Variance Normalization operation on data from input node.
|
93
|
+
|
94
|
+
Computes MVN on the input tensor `data` (called `X`) using formula:
|
95
|
+
|
96
|
+
\f[ Y = \dfrac{X-EX}{\sqrt{E(X-EX)^2}} \f]
|
97
|
+
|
98
|
+
:param data: The node with data tensor.
|
99
|
+
:param across_channels: Denotes if mean values are shared across channels.
|
100
|
+
:param normalize_variance: Denotes whether to perform variance normalization.
|
101
|
+
:param eps: The number added to the variance to avoid division by zero
|
102
|
+
when normalizing the value. Scalar value.
|
103
|
+
:param name: Optional output node name.
|
104
|
+
:return: The new node performing a MVN operation on input tensor.
|
105
|
+
"""
|
106
|
+
return _get_node_factory_opset2().create(
|
107
|
+
"MVN",
|
108
|
+
[data],
|
109
|
+
{
|
110
|
+
"across_channels": across_channels,
|
111
|
+
"normalize_variance": normalize_variance,
|
112
|
+
"eps": eps,
|
113
|
+
},
|
114
|
+
)
|
115
|
+
|
116
|
+
|
117
|
+
@nameable_op
|
118
|
+
def reorg_yolo(input: Node, stride: List[int], name: Optional[str] = None) -> Node:
|
119
|
+
"""Return a node which produces the ReorgYolo operation.
|
120
|
+
|
121
|
+
:param input: Input data.
|
122
|
+
:param stride: Stride to reorganize input by.
|
123
|
+
:param name: Optional name for output node.
|
124
|
+
:return: ReorgYolo node.
|
125
|
+
"""
|
126
|
+
return _get_node_factory_opset2().create("ReorgYolo", [input], {"stride": stride})
|
127
|
+
|
128
|
+
|
129
|
+
@nameable_op
|
130
|
+
def roi_pooling(
|
131
|
+
input: NodeInput,
|
132
|
+
coords: NodeInput,
|
133
|
+
output_roi: Optional[TensorShape] = None,
|
134
|
+
spatial_scale: Optional[NumericData] = None,
|
135
|
+
method: str = "max",
|
136
|
+
name: Optional[str] = None,
|
137
|
+
*,
|
138
|
+
output_size: Optional[TensorShape] = None,
|
139
|
+
) -> Node:
|
140
|
+
"""Return a node which produces an ROIPooling operation.
|
141
|
+
|
142
|
+
:param input: Input feature map `{N, C, ...}`.
|
143
|
+
:param coords: Coordinates of bounding boxes.
|
144
|
+
:param output_roi: Height/Width of ROI output features (shape).
|
145
|
+
:param spatial_scale: Ratio of input feature map over input image size (float).
|
146
|
+
:param method: Method of pooling - string: "max" or "bilinear". Default: "max"
|
147
|
+
:param output_size: (DEPRECATED!) Height/Width of ROI output features (shape).
|
148
|
+
Will override `output_roi` if used and change behavior of the operator.
|
149
|
+
:return: ROIPooling node.
|
150
|
+
"""
|
151
|
+
# Allow either one of these attributes to be passed.
|
152
|
+
if output_roi is None and output_size is None:
|
153
|
+
raise AttributeError("One of the following arguments must be defined: `output_roi`, `output_size`!")
|
154
|
+
# Force checking of spatial_scale.
|
155
|
+
if spatial_scale is None:
|
156
|
+
raise AttributeError("The following arguments must be defined: `spatial_scale`!")
|
157
|
+
|
158
|
+
def _deprecated_output_size_arg(output_roi: Optional[TensorShape], output_size: Optional[TensorShape]) -> Optional[TensorShape]:
|
159
|
+
if output_size is not None:
|
160
|
+
warnings.warn(
|
161
|
+
"`output_size` is deprecated and will be removed in future. "
|
162
|
+
"Value of `output_size` is going to override `output_roi` value and "
|
163
|
+
"`get_output_size` will behave like `get_output_roi` function."
|
164
|
+
"Please use only `output_roi` explicitly.",
|
165
|
+
DeprecationWarning,
|
166
|
+
stacklevel=3,
|
167
|
+
)
|
168
|
+
return output_size
|
169
|
+
return output_roi
|
170
|
+
|
171
|
+
method = method.lower()
|
172
|
+
roi_shape = _deprecated_output_size_arg(output_roi, output_size)
|
173
|
+
node = _get_node_factory_opset2().create(
|
174
|
+
"ROIPooling",
|
175
|
+
as_nodes(input, coords, name=name),
|
176
|
+
{
|
177
|
+
"output_size": Shape(roi_shape),
|
178
|
+
"output_roi": Shape(roi_shape),
|
179
|
+
"spatial_scale": spatial_scale,
|
180
|
+
"method": method,
|
181
|
+
},
|
182
|
+
)
|
183
|
+
|
184
|
+
# Override behavior when deprecated value was used.
|
185
|
+
if output_size is not None:
|
186
|
+
node.get_output_size = node.get_output_roi
|
187
|
+
node.set_output_size = node.set_output_roi
|
188
|
+
|
189
|
+
return node
|
190
|
+
|
191
|
+
|
192
|
+
@nameable_op
|
193
|
+
def space_to_batch(
|
194
|
+
data: NodeInput,
|
195
|
+
block_shape: NodeInput,
|
196
|
+
pads_begin: NodeInput,
|
197
|
+
pads_end: NodeInput,
|
198
|
+
name: Optional[str] = None,
|
199
|
+
) -> Node:
|
200
|
+
"""Perform SpaceToBatch operation on the input tensor.
|
201
|
+
|
202
|
+
SpaceToBatch permutes data tensor blocks of spatial data into batch dimension.
|
203
|
+
The operator returns a copy of the input tensor where values from spatial blocks dimensions
|
204
|
+
are moved in the batch dimension
|
205
|
+
|
206
|
+
:param data: Node producing the data tensor.
|
207
|
+
:param block_shape: The sizes of the block of values to be moved.
|
208
|
+
:param pads_begin: Specifies the padding for the beginning along each axis of `data`.
|
209
|
+
:param pads_end: Specifies the padding for the ending along each axis of `data`.
|
210
|
+
:param name: Optional output node name.
|
211
|
+
:return: The new node performing a SpaceToBatch operation.
|
212
|
+
"""
|
213
|
+
return _get_node_factory_opset2().create(
|
214
|
+
"SpaceToBatch",
|
215
|
+
as_nodes(data, block_shape, pads_begin, pads_end, name=name),
|
216
|
+
)
|