bigdl-core-npu 2.6.0b20250114__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.
Files changed (234) hide show
  1. bigdl-core-npu/__init__.py +0 -0
  2. bigdl-core-npu/include/common.h +96 -0
  3. bigdl-core-npu/include/npu_llm.h +74 -0
  4. bigdl-core-npu/npu_llm.dll +0 -0
  5. bigdl-core-npu/npu_llm.lib +0 -0
  6. bigdl_core_npu-2.6.0b20250114.dist-info/METADATA +44 -0
  7. bigdl_core_npu-2.6.0b20250114.dist-info/RECORD +234 -0
  8. bigdl_core_npu-2.6.0b20250114.dist-info/WHEEL +5 -0
  9. bigdl_core_npu-2.6.0b20250114.dist-info/top_level.txt +2 -0
  10. intel_npu_acceleration_library/__init__.py +24 -0
  11. intel_npu_acceleration_library/_version.py +6 -0
  12. intel_npu_acceleration_library/backend/__init__.py +37 -0
  13. intel_npu_acceleration_library/backend/base.py +250 -0
  14. intel_npu_acceleration_library/backend/bindings.py +383 -0
  15. intel_npu_acceleration_library/backend/compression.py +24 -0
  16. intel_npu_acceleration_library/backend/convolution.py +58 -0
  17. intel_npu_acceleration_library/backend/factory.py +1161 -0
  18. intel_npu_acceleration_library/backend/linear.py +60 -0
  19. intel_npu_acceleration_library/backend/matmul.py +59 -0
  20. intel_npu_acceleration_library/backend/mlp.py +58 -0
  21. intel_npu_acceleration_library/backend/ops.py +142 -0
  22. intel_npu_acceleration_library/backend/qlinear.py +75 -0
  23. intel_npu_acceleration_library/backend/qmatmul.py +66 -0
  24. intel_npu_acceleration_library/backend/runtime.py +215 -0
  25. intel_npu_acceleration_library/backend/sdpa.py +107 -0
  26. intel_npu_acceleration_library/backend/tensor.py +1120 -0
  27. intel_npu_acceleration_library/backend/utils.py +70 -0
  28. intel_npu_acceleration_library/compiler.py +194 -0
  29. intel_npu_acceleration_library/device.py +230 -0
  30. intel_npu_acceleration_library/dtypes.py +155 -0
  31. intel_npu_acceleration_library/external/openvino/__init__.py +72 -0
  32. intel_npu_acceleration_library/external/openvino/_offline_transformations/__init__.py +21 -0
  33. intel_npu_acceleration_library/external/openvino/_pyopenvino.cp310-win_amd64.pyd +0 -0
  34. intel_npu_acceleration_library/external/openvino/_pyopenvino.cp311-win_amd64.pyd +0 -0
  35. intel_npu_acceleration_library/external/openvino/_pyopenvino.cp312-win_amd64.pyd +0 -0
  36. intel_npu_acceleration_library/external/openvino/_pyopenvino.cp38-win_amd64.pyd +0 -0
  37. intel_npu_acceleration_library/external/openvino/_pyopenvino.cp39-win_amd64.pyd +0 -0
  38. intel_npu_acceleration_library/external/openvino/experimental/__init__.py +14 -0
  39. intel_npu_acceleration_library/external/openvino/frontend/__init__.py +34 -0
  40. intel_npu_acceleration_library/external/openvino/frontend/frontend.py +44 -0
  41. intel_npu_acceleration_library/external/openvino/frontend/jax/__init__.py +15 -0
  42. intel_npu_acceleration_library/external/openvino/frontend/jax/jaxpr_decoder.py +293 -0
  43. intel_npu_acceleration_library/external/openvino/frontend/jax/passes.py +65 -0
  44. intel_npu_acceleration_library/external/openvino/frontend/jax/utils.py +182 -0
  45. intel_npu_acceleration_library/external/openvino/frontend/onnx/__init__.py +15 -0
  46. intel_npu_acceleration_library/external/openvino/frontend/onnx/py_onnx_frontend.cp310-win_amd64.pyd +0 -0
  47. intel_npu_acceleration_library/external/openvino/frontend/onnx/py_onnx_frontend.cp311-win_amd64.pyd +0 -0
  48. intel_npu_acceleration_library/external/openvino/frontend/onnx/py_onnx_frontend.cp312-win_amd64.pyd +0 -0
  49. intel_npu_acceleration_library/external/openvino/frontend/onnx/py_onnx_frontend.cp38-win_amd64.pyd +0 -0
  50. intel_npu_acceleration_library/external/openvino/frontend/onnx/py_onnx_frontend.cp39-win_amd64.pyd +0 -0
  51. intel_npu_acceleration_library/external/openvino/frontend/paddle/__init__.py +15 -0
  52. intel_npu_acceleration_library/external/openvino/frontend/paddle/py_paddle_frontend.cp310-win_amd64.pyd +0 -0
  53. intel_npu_acceleration_library/external/openvino/frontend/paddle/py_paddle_frontend.cp311-win_amd64.pyd +0 -0
  54. intel_npu_acceleration_library/external/openvino/frontend/paddle/py_paddle_frontend.cp312-win_amd64.pyd +0 -0
  55. intel_npu_acceleration_library/external/openvino/frontend/paddle/py_paddle_frontend.cp38-win_amd64.pyd +0 -0
  56. intel_npu_acceleration_library/external/openvino/frontend/paddle/py_paddle_frontend.cp39-win_amd64.pyd +0 -0
  57. intel_npu_acceleration_library/external/openvino/frontend/pytorch/__init__.py +19 -0
  58. intel_npu_acceleration_library/external/openvino/frontend/pytorch/fx_decoder.py +370 -0
  59. intel_npu_acceleration_library/external/openvino/frontend/pytorch/gptq.py +180 -0
  60. intel_npu_acceleration_library/external/openvino/frontend/pytorch/module_extension.py +39 -0
  61. intel_npu_acceleration_library/external/openvino/frontend/pytorch/patch_model.py +118 -0
  62. intel_npu_acceleration_library/external/openvino/frontend/pytorch/py_pytorch_frontend.cp310-win_amd64.pyd +0 -0
  63. intel_npu_acceleration_library/external/openvino/frontend/pytorch/py_pytorch_frontend.cp311-win_amd64.pyd +0 -0
  64. intel_npu_acceleration_library/external/openvino/frontend/pytorch/py_pytorch_frontend.cp312-win_amd64.pyd +0 -0
  65. intel_npu_acceleration_library/external/openvino/frontend/pytorch/py_pytorch_frontend.cp38-win_amd64.pyd +0 -0
  66. intel_npu_acceleration_library/external/openvino/frontend/pytorch/py_pytorch_frontend.cp39-win_amd64.pyd +0 -0
  67. intel_npu_acceleration_library/external/openvino/frontend/pytorch/torchdynamo/backend.py +131 -0
  68. intel_npu_acceleration_library/external/openvino/frontend/pytorch/torchdynamo/backend_utils.py +85 -0
  69. intel_npu_acceleration_library/external/openvino/frontend/pytorch/torchdynamo/compile.py +141 -0
  70. intel_npu_acceleration_library/external/openvino/frontend/pytorch/torchdynamo/decompositions.py +116 -0
  71. intel_npu_acceleration_library/external/openvino/frontend/pytorch/torchdynamo/execute.py +189 -0
  72. intel_npu_acceleration_library/external/openvino/frontend/pytorch/torchdynamo/op_support.py +290 -0
  73. intel_npu_acceleration_library/external/openvino/frontend/pytorch/torchdynamo/partition.py +126 -0
  74. intel_npu_acceleration_library/external/openvino/frontend/pytorch/ts_decoder.py +568 -0
  75. intel_npu_acceleration_library/external/openvino/frontend/pytorch/utils.py +258 -0
  76. intel_npu_acceleration_library/external/openvino/frontend/tensorflow/__init__.py +16 -0
  77. intel_npu_acceleration_library/external/openvino/frontend/tensorflow/graph_iterator.py +116 -0
  78. intel_npu_acceleration_library/external/openvino/frontend/tensorflow/node_decoder.py +219 -0
  79. intel_npu_acceleration_library/external/openvino/frontend/tensorflow/py_tensorflow_frontend.cp310-win_amd64.pyd +0 -0
  80. intel_npu_acceleration_library/external/openvino/frontend/tensorflow/py_tensorflow_frontend.cp311-win_amd64.pyd +0 -0
  81. intel_npu_acceleration_library/external/openvino/frontend/tensorflow/py_tensorflow_frontend.cp312-win_amd64.pyd +0 -0
  82. intel_npu_acceleration_library/external/openvino/frontend/tensorflow/py_tensorflow_frontend.cp38-win_amd64.pyd +0 -0
  83. intel_npu_acceleration_library/external/openvino/frontend/tensorflow/py_tensorflow_frontend.cp39-win_amd64.pyd +0 -0
  84. intel_npu_acceleration_library/external/openvino/frontend/tensorflow/utils.py +481 -0
  85. intel_npu_acceleration_library/external/openvino/helpers/__init__.py +6 -0
  86. intel_npu_acceleration_library/external/openvino/helpers/packing.py +87 -0
  87. intel_npu_acceleration_library/external/openvino/preprocess/README.md +60 -0
  88. intel_npu_acceleration_library/external/openvino/preprocess/__init__.py +28 -0
  89. intel_npu_acceleration_library/external/openvino/preprocess/torchvision/__init__.py +15 -0
  90. intel_npu_acceleration_library/external/openvino/preprocess/torchvision/preprocess_converter.py +47 -0
  91. intel_npu_acceleration_library/external/openvino/preprocess/torchvision/requirements.txt +5 -0
  92. intel_npu_acceleration_library/external/openvino/preprocess/torchvision/torchvision_preprocessing.py +347 -0
  93. intel_npu_acceleration_library/external/openvino/properties/__init__.py +22 -0
  94. intel_npu_acceleration_library/external/openvino/properties/_properties.py +55 -0
  95. intel_npu_acceleration_library/external/openvino/properties/device/__init__.py +14 -0
  96. intel_npu_acceleration_library/external/openvino/properties/hint/__init__.py +15 -0
  97. intel_npu_acceleration_library/external/openvino/properties/intel_auto/__init__.py +12 -0
  98. intel_npu_acceleration_library/external/openvino/properties/intel_cpu/__init__.py +8 -0
  99. intel_npu_acceleration_library/external/openvino/properties/intel_gpu/__init__.py +12 -0
  100. intel_npu_acceleration_library/external/openvino/properties/intel_gpu/hint/__init__.py +11 -0
  101. intel_npu_acceleration_library/external/openvino/properties/log/__init__.py +11 -0
  102. intel_npu_acceleration_library/external/openvino/properties/streams/__init__.py +11 -0
  103. intel_npu_acceleration_library/external/openvino/runtime/__init__.py +85 -0
  104. intel_npu_acceleration_library/external/openvino/runtime/exceptions.py +17 -0
  105. intel_npu_acceleration_library/external/openvino/runtime/ie_api.py +631 -0
  106. intel_npu_acceleration_library/external/openvino/runtime/op/__init__.py +19 -0
  107. intel_npu_acceleration_library/external/openvino/runtime/op/util/__init__.py +22 -0
  108. intel_npu_acceleration_library/external/openvino/runtime/opset1/__init__.py +112 -0
  109. intel_npu_acceleration_library/external/openvino/runtime/opset1/ops.py +3068 -0
  110. intel_npu_acceleration_library/external/openvino/runtime/opset10/__init__.py +179 -0
  111. intel_npu_acceleration_library/external/openvino/runtime/opset10/ops.py +173 -0
  112. intel_npu_acceleration_library/external/openvino/runtime/opset11/__init__.py +179 -0
  113. intel_npu_acceleration_library/external/openvino/runtime/opset11/ops.py +107 -0
  114. intel_npu_acceleration_library/external/openvino/runtime/opset12/__init__.py +180 -0
  115. intel_npu_acceleration_library/external/openvino/runtime/opset12/ops.py +120 -0
  116. intel_npu_acceleration_library/external/openvino/runtime/opset13/__init__.py +188 -0
  117. intel_npu_acceleration_library/external/openvino/runtime/opset13/ops.py +398 -0
  118. intel_npu_acceleration_library/external/openvino/runtime/opset14/__init__.py +190 -0
  119. intel_npu_acceleration_library/external/openvino/runtime/opset14/ops.py +171 -0
  120. intel_npu_acceleration_library/external/openvino/runtime/opset15/__init__.py +17 -0
  121. intel_npu_acceleration_library/external/openvino/runtime/opset15/ops.py +276 -0
  122. intel_npu_acceleration_library/external/openvino/runtime/opset2/__init__.py +118 -0
  123. intel_npu_acceleration_library/external/openvino/runtime/opset2/ops.py +216 -0
  124. intel_npu_acceleration_library/external/openvino/runtime/opset3/__init__.py +134 -0
  125. intel_npu_acceleration_library/external/openvino/runtime/opset3/ops.py +638 -0
  126. intel_npu_acceleration_library/external/openvino/runtime/opset4/__init__.py +145 -0
  127. intel_npu_acceleration_library/external/openvino/runtime/opset4/ops.py +464 -0
  128. intel_npu_acceleration_library/external/openvino/runtime/opset5/__init__.py +152 -0
  129. intel_npu_acceleration_library/external/openvino/runtime/opset5/ops.py +372 -0
  130. intel_npu_acceleration_library/external/openvino/runtime/opset6/__init__.py +154 -0
  131. intel_npu_acceleration_library/external/openvino/runtime/opset6/ops.py +215 -0
  132. intel_npu_acceleration_library/external/openvino/runtime/opset7/__init__.py +158 -0
  133. intel_npu_acceleration_library/external/openvino/runtime/opset7/ops.py +169 -0
  134. intel_npu_acceleration_library/external/openvino/runtime/opset8/__init__.py +169 -0
  135. intel_npu_acceleration_library/external/openvino/runtime/opset8/ops.py +787 -0
  136. intel_npu_acceleration_library/external/openvino/runtime/opset9/__init__.py +175 -0
  137. intel_npu_acceleration_library/external/openvino/runtime/opset9/ops.py +341 -0
  138. intel_npu_acceleration_library/external/openvino/runtime/opset_utils.py +22 -0
  139. intel_npu_acceleration_library/external/openvino/runtime/passes/__init__.py +19 -0
  140. intel_npu_acceleration_library/external/openvino/runtime/passes/graph_rewrite.py +33 -0
  141. intel_npu_acceleration_library/external/openvino/runtime/passes/manager.py +26 -0
  142. intel_npu_acceleration_library/external/openvino/runtime/properties/__init__.py +40 -0
  143. intel_npu_acceleration_library/external/openvino/runtime/properties/hint/__init__.py +25 -0
  144. intel_npu_acceleration_library/external/openvino/runtime/utils/__init__.py +7 -0
  145. intel_npu_acceleration_library/external/openvino/runtime/utils/broadcasting.py +44 -0
  146. intel_npu_acceleration_library/external/openvino/runtime/utils/data_helpers/__init__.py +8 -0
  147. intel_npu_acceleration_library/external/openvino/runtime/utils/data_helpers/data_dispatcher.py +447 -0
  148. intel_npu_acceleration_library/external/openvino/runtime/utils/data_helpers/wrappers.py +148 -0
  149. intel_npu_acceleration_library/external/openvino/runtime/utils/decorators.py +156 -0
  150. intel_npu_acceleration_library/external/openvino/runtime/utils/input_validation.py +133 -0
  151. intel_npu_acceleration_library/external/openvino/runtime/utils/node_factory.py +127 -0
  152. intel_npu_acceleration_library/external/openvino/runtime/utils/reduction.py +25 -0
  153. intel_npu_acceleration_library/external/openvino/runtime/utils/types.py +175 -0
  154. intel_npu_acceleration_library/external/openvino/tools/__init__.py +4 -0
  155. intel_npu_acceleration_library/external/openvino/tools/benchmark/__init__.py +3 -0
  156. intel_npu_acceleration_library/external/openvino/tools/benchmark/benchmark.py +186 -0
  157. intel_npu_acceleration_library/external/openvino/tools/benchmark/main.py +695 -0
  158. intel_npu_acceleration_library/external/openvino/tools/benchmark/parameters.py +199 -0
  159. intel_npu_acceleration_library/external/openvino/tools/benchmark/utils/__init__.py +3 -0
  160. intel_npu_acceleration_library/external/openvino/tools/benchmark/utils/constants.py +26 -0
  161. intel_npu_acceleration_library/external/openvino/tools/benchmark/utils/inputs_filling.py +482 -0
  162. intel_npu_acceleration_library/external/openvino/tools/benchmark/utils/logging.py +8 -0
  163. intel_npu_acceleration_library/external/openvino/tools/benchmark/utils/statistics_report.py +296 -0
  164. intel_npu_acceleration_library/external/openvino/tools/benchmark/utils/utils.py +836 -0
  165. intel_npu_acceleration_library/external/openvino/tools/ovc/__init__.py +20 -0
  166. intel_npu_acceleration_library/external/openvino/tools/ovc/__main__.py +10 -0
  167. intel_npu_acceleration_library/external/openvino/tools/ovc/cli_parser.py +633 -0
  168. intel_npu_acceleration_library/external/openvino/tools/ovc/convert.py +102 -0
  169. intel_npu_acceleration_library/external/openvino/tools/ovc/convert_data_type.py +82 -0
  170. intel_npu_acceleration_library/external/openvino/tools/ovc/convert_impl.py +550 -0
  171. intel_npu_acceleration_library/external/openvino/tools/ovc/environment_setup_utils.py +50 -0
  172. intel_npu_acceleration_library/external/openvino/tools/ovc/error.py +49 -0
  173. intel_npu_acceleration_library/external/openvino/tools/ovc/get_ov_update_message.py +16 -0
  174. intel_npu_acceleration_library/external/openvino/tools/ovc/help.py +45 -0
  175. intel_npu_acceleration_library/external/openvino/tools/ovc/logger.py +91 -0
  176. intel_npu_acceleration_library/external/openvino/tools/ovc/main.py +40 -0
  177. intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/__init__.py +2 -0
  178. intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/analysis.py +46 -0
  179. intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/check_config.py +57 -0
  180. intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/extractor.py +447 -0
  181. intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/jax_frontend_utils.py +19 -0
  182. intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/layout_utils.py +73 -0
  183. intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/moc_emit_ir.py +32 -0
  184. intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/offline_transformations.py +107 -0
  185. intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/paddle_frontend_utils.py +83 -0
  186. intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/pipeline.py +298 -0
  187. intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/preprocessing.py +220 -0
  188. intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/pytorch_frontend_utils.py +214 -0
  189. intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/shape_utils.py +109 -0
  190. intel_npu_acceleration_library/external/openvino/tools/ovc/moc_frontend/type_utils.py +82 -0
  191. intel_npu_acceleration_library/external/openvino/tools/ovc/ovc.py +13 -0
  192. intel_npu_acceleration_library/external/openvino/tools/ovc/telemetry_params.py +6 -0
  193. intel_npu_acceleration_library/external/openvino/tools/ovc/telemetry_stub.py +28 -0
  194. intel_npu_acceleration_library/external/openvino/tools/ovc/telemetry_utils.py +118 -0
  195. intel_npu_acceleration_library/external/openvino/tools/ovc/utils.py +196 -0
  196. intel_npu_acceleration_library/external/openvino/tools/ovc/version.py +80 -0
  197. intel_npu_acceleration_library/external/openvino/torch/__init__.py +5 -0
  198. intel_npu_acceleration_library/external/openvino/utils.py +115 -0
  199. intel_npu_acceleration_library/functional/__init__.py +8 -0
  200. intel_npu_acceleration_library/functional/scaled_dot_product_attention.py +47 -0
  201. intel_npu_acceleration_library/lib/Release/cache.json +113732 -0
  202. intel_npu_acceleration_library/lib/Release/intel_npu_acceleration_library.dll +0 -0
  203. intel_npu_acceleration_library/lib/Release/openvino.dll +0 -0
  204. intel_npu_acceleration_library/lib/Release/openvino_auto_batch_plugin.dll +0 -0
  205. intel_npu_acceleration_library/lib/Release/openvino_auto_plugin.dll +0 -0
  206. intel_npu_acceleration_library/lib/Release/openvino_c.dll +0 -0
  207. intel_npu_acceleration_library/lib/Release/openvino_hetero_plugin.dll +0 -0
  208. intel_npu_acceleration_library/lib/Release/openvino_intel_cpu_plugin.dll +0 -0
  209. intel_npu_acceleration_library/lib/Release/openvino_intel_gpu_plugin.dll +0 -0
  210. intel_npu_acceleration_library/lib/Release/openvino_intel_npu_plugin.dll +0 -0
  211. intel_npu_acceleration_library/lib/Release/openvino_ir_frontend.dll +0 -0
  212. intel_npu_acceleration_library/lib/Release/openvino_onnx_frontend.dll +0 -0
  213. intel_npu_acceleration_library/lib/Release/openvino_paddle_frontend.dll +0 -0
  214. intel_npu_acceleration_library/lib/Release/openvino_pytorch_frontend.dll +0 -0
  215. intel_npu_acceleration_library/lib/Release/openvino_tensorflow_frontend.dll +0 -0
  216. intel_npu_acceleration_library/lib/Release/openvino_tensorflow_lite_frontend.dll +0 -0
  217. intel_npu_acceleration_library/lib/Release/tbb12.dll +0 -0
  218. intel_npu_acceleration_library/lib/Release/tbb12_debug.dll +0 -0
  219. intel_npu_acceleration_library/lib/Release/tbbbind_2_5.dll +0 -0
  220. intel_npu_acceleration_library/lib/Release/tbbbind_2_5_debug.dll +0 -0
  221. intel_npu_acceleration_library/lib/Release/tbbmalloc.dll +0 -0
  222. intel_npu_acceleration_library/lib/Release/tbbmalloc_debug.dll +0 -0
  223. intel_npu_acceleration_library/lib/Release/tbbmalloc_proxy.dll +0 -0
  224. intel_npu_acceleration_library/lib/Release/tbbmalloc_proxy_debug.dll +0 -0
  225. intel_npu_acceleration_library/modelling.py +150 -0
  226. intel_npu_acceleration_library/nn/__init__.py +20 -0
  227. intel_npu_acceleration_library/nn/autograd.py +68 -0
  228. intel_npu_acceleration_library/nn/conv.py +257 -0
  229. intel_npu_acceleration_library/nn/functional.py +1207 -0
  230. intel_npu_acceleration_library/nn/linear.py +162 -0
  231. intel_npu_acceleration_library/nn/llm.py +417 -0
  232. intel_npu_acceleration_library/nn/module.py +393 -0
  233. intel_npu_acceleration_library/optimizations.py +157 -0
  234. intel_npu_acceleration_library/quantization.py +174 -0
@@ -0,0 +1,787 @@
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 functools import partial
7
+ from typing import List, Optional, Tuple
8
+
9
+ import numpy as np
10
+ from openvino.runtime.exceptions import UserInputError
11
+ from openvino.runtime.op import Constant, Parameter, if_op
12
+ from openvino.runtime import Node
13
+ from openvino.runtime.opset_utils import _get_node_factory
14
+ from openvino.runtime.utils.decorators import nameable_op
15
+ from openvino.runtime.utils.input_validation import (
16
+ check_valid_attributes,
17
+ is_non_negative_value,
18
+ is_positive_value,
19
+ )
20
+ from openvino.runtime.utils.types import (
21
+ NodeInput,
22
+ TensorShape,
23
+ as_node,
24
+ as_nodes,
25
+ )
26
+
27
+ _get_node_factory_opset8 = partial(_get_node_factory, "opset8")
28
+
29
+
30
+ # -------------------------------------------- ops ------------------------------------------------
31
+
32
+
33
+ @nameable_op
34
+ def deformable_convolution(
35
+ data: NodeInput,
36
+ offsets: NodeInput,
37
+ filters: NodeInput,
38
+ strides: List[int],
39
+ pads_begin: List[int],
40
+ pads_end: List[int],
41
+ dilations: List[int],
42
+ mask: Optional[NodeInput] = None,
43
+ auto_pad: str = "EXPLICIT",
44
+ group: int = 1,
45
+ deformable_group: int = 1,
46
+ bilinear_interpolation_pad: bool = False,
47
+ name: Optional[str] = None,
48
+ ) -> Node:
49
+ """Return a node which performs deformable convolution operation.
50
+
51
+ :param data: The node providing data batch tensor.
52
+ :param offsets: The node providing offset tensor.
53
+ :param filters: The node providing filters tensor.
54
+ :param strides: The distance (in pixels) to slide the filter on the feature map over the axes.
55
+ :param pads_begin: The number of pixels to add to the beginning along each axis.
56
+ :param pads_end: The number of pixels to add to the end along each axis.
57
+ :param dilations: The distance in width and height between elements (weights) in the filter.
58
+ :param mask: The node providing modulation scalar (mask) tensor.
59
+ :param auto_pad: The type of padding. Range of values: explicit, same_upper, same_lower, valid.
60
+ :param group: The number of groups which both output and input should be split into.
61
+ :param deformable_group: The number of groups which deformable values and output should be split
62
+ into along the channel axis.
63
+ :param bilinear_interpolation_pad: The flag that determines the mode of bilinear interpolation
64
+ execution.
65
+ :param name: The optional new name for output node.
66
+ :return: New node performing deformable convolution operation.
67
+ """
68
+ if mask is None:
69
+ inputs = as_nodes(data, offsets, filters, name=name)
70
+ else:
71
+ inputs = as_nodes(data, offsets, filters, mask, name=name)
72
+
73
+ return _get_node_factory_opset8().create(
74
+ "DeformableConvolution",
75
+ inputs,
76
+ {
77
+ "strides": strides,
78
+ "pads_begin": pads_begin,
79
+ "pads_end": pads_end,
80
+ "dilations": dilations,
81
+ "auto_pad": auto_pad,
82
+ "group": group,
83
+ "deformable_group": deformable_group,
84
+ "bilinear_interpolation_pad": bilinear_interpolation_pad,
85
+ },
86
+ )
87
+
88
+
89
+ @nameable_op
90
+ def adaptive_avg_pool(
91
+ data: NodeInput,
92
+ output_shape: NodeInput,
93
+ name: Optional[str] = None,
94
+ ) -> Node:
95
+ """Return a node which performs AdaptiveAvgPool operation.
96
+
97
+ :param data: The list of input nodes
98
+ :param output_shape: the shape of spatial dimentions after operation
99
+ :param name: Optional output node name.
100
+ :return: The new node performing AdaptiveAvgPool operation on the data
101
+ """
102
+ inputs = as_nodes(data, output_shape, name=name)
103
+ return _get_node_factory_opset8().create("AdaptiveAvgPool", inputs)
104
+
105
+
106
+ @nameable_op
107
+ def adaptive_max_pool(
108
+ data: NodeInput,
109
+ output_shape: NodeInput,
110
+ index_element_type: str = "i64",
111
+ name: Optional[str] = None,
112
+ ) -> Node:
113
+ """Return a node which performs AdaptiveMaxPool operation.
114
+
115
+ :param data: The list of input nodes
116
+ :param output_shape: the shape of spatial dimentions after operation
117
+ :param index_element_type: Type of indices output.
118
+ :param name: Optional output node name.
119
+ :return: The new node performing AdaptiveMaxPool operation on the data
120
+ """
121
+ inputs = as_nodes(data, output_shape, name=name)
122
+
123
+ attributes = {
124
+ "index_element_type": index_element_type,
125
+ }
126
+
127
+ return _get_node_factory_opset8().create("AdaptiveMaxPool", inputs, attributes)
128
+
129
+
130
+ @nameable_op
131
+ def multiclass_nms(
132
+ boxes: NodeInput,
133
+ scores: NodeInput,
134
+ sort_result_type: str = "none",
135
+ sort_result_across_batch: bool = False,
136
+ output_type: str = "i64",
137
+ iou_threshold: float = 0.0,
138
+ score_threshold: float = 0.0,
139
+ nms_top_k: int = -1,
140
+ keep_top_k: int = -1,
141
+ background_class: int = -1,
142
+ nms_eta: float = 1.0,
143
+ normalized: bool = True,
144
+ name: Optional[str] = None,
145
+ ) -> Node:
146
+ """Return a node which performs MulticlassNms.
147
+
148
+ :param boxes: Tensor with box coordinates.
149
+ :param scores: Tensor with box scores.
150
+ :param sort_result_type: Specifies order of output elements, possible values:
151
+ 'class': sort selected boxes by class id (ascending)
152
+ 'score': sort selected boxes by score (descending)
153
+ 'none': do not guarantee the order.
154
+ :param sort_result_across_batch: Specifies whenever it is necessary to sort selected boxes
155
+ across batches or not
156
+ :param output_type: Specifies the output tensor type, possible values:
157
+ 'i64', 'i32'
158
+ :param iou_threshold: Specifies intersection over union threshold
159
+ :param score_threshold: Specifies minimum score to consider box for the processing
160
+ :param nms_top_k: Specifies maximum number of boxes to be selected per class, -1 meaning
161
+ to keep all boxes
162
+ :param keep_top_k: Specifies maximum number of boxes to be selected per batch element, -1
163
+ meaning to keep all boxes
164
+ :param background_class: Specifies the background class id, -1 meaning to keep all classes
165
+ :param nms_eta: Specifies eta parameter for adpative NMS, in close range [0, 1.0]
166
+ :param normalized: Specifies whether boxes are normalized or not
167
+ :param name: Optional output node name.
168
+ :return: The new node which performs MuticlassNms
169
+ """
170
+ inputs = as_nodes(boxes, scores, name=name)
171
+
172
+ attributes = {
173
+ "sort_result_type": sort_result_type,
174
+ "sort_result_across_batch": sort_result_across_batch,
175
+ "output_type": output_type,
176
+ "iou_threshold": iou_threshold,
177
+ "score_threshold": score_threshold,
178
+ "nms_top_k": nms_top_k,
179
+ "keep_top_k": keep_top_k,
180
+ "background_class": background_class,
181
+ "nms_eta": nms_eta,
182
+ "normalized": normalized,
183
+ }
184
+
185
+ return _get_node_factory_opset8().create("MulticlassNms", inputs, attributes)
186
+
187
+
188
+ @nameable_op
189
+ def matrix_nms(
190
+ boxes: NodeInput,
191
+ scores: NodeInput,
192
+ sort_result_type: str = "none",
193
+ sort_result_across_batch: bool = False,
194
+ output_type: str = "i64",
195
+ score_threshold: float = 0.0,
196
+ nms_top_k: int = -1,
197
+ keep_top_k: int = -1,
198
+ background_class: int = -1,
199
+ decay_function: str = "linear",
200
+ gaussian_sigma: float = 2.0,
201
+ post_threshold: float = 0.0,
202
+ normalized: bool = True,
203
+ name: Optional[str] = None,
204
+ ) -> Node:
205
+ """Return a node which performs MatrixNms.
206
+
207
+ :param boxes: Tensor with box coordinates.
208
+ :param scores: Tensor with box scores.
209
+ :param sort_result_type: Specifies order of output elements, possible values:
210
+ 'class': sort selected boxes by class id (ascending)
211
+ 'score': sort selected boxes by score (descending)
212
+ 'none': do not guarantee the order.
213
+ :param sort_result_across_batch: Specifies whenever it is necessary to sort selected boxes
214
+ across batches or not
215
+ :param output_type: Specifies the output tensor type, possible values:
216
+ 'i64', 'i32'
217
+ :param score_threshold: Specifies minimum score to consider box for the processing
218
+ :param nms_top_k: Specifies maximum number of boxes to be selected per class, -1 meaning
219
+ to keep all boxes
220
+ :param keep_top_k: Specifies maximum number of boxes to be selected per batch element, -1
221
+ meaning to keep all boxes
222
+ :param background_class: Specifies the background class id, -1 meaning to keep all classes
223
+ :param decay_function: Specifies decay function used to decay scores, possible values:
224
+ 'gaussian', 'linear'
225
+ :param gaussian_sigma: Specifies gaussian_sigma parameter for gaussian decay_function
226
+ :param post_threshold: Specifies threshold to filter out boxes with low confidence score
227
+ after decaying
228
+ :param normalized: Specifies whether boxes are normalized or not
229
+ :param name: Optional output node name.
230
+ :return: The new node which performs MatrixNms
231
+ """
232
+ inputs = as_nodes(boxes, scores, name=name)
233
+
234
+ attributes = {
235
+ "sort_result_type": sort_result_type,
236
+ "sort_result_across_batch": sort_result_across_batch,
237
+ "output_type": output_type,
238
+ "score_threshold": score_threshold,
239
+ "nms_top_k": nms_top_k,
240
+ "keep_top_k": keep_top_k,
241
+ "background_class": background_class,
242
+ "decay_function": decay_function,
243
+ "gaussian_sigma": gaussian_sigma,
244
+ "post_threshold": post_threshold,
245
+ "normalized": normalized,
246
+ }
247
+
248
+ return _get_node_factory_opset8().create("MatrixNms", inputs, attributes)
249
+
250
+
251
+ @nameable_op
252
+ def gather(
253
+ data: NodeInput,
254
+ indices: NodeInput,
255
+ axis: NodeInput,
256
+ batch_dims: Optional[int] = 0,
257
+ name: Optional[str] = None,
258
+ ) -> Node:
259
+ """Return a node which performs Gather with support of negative indices.
260
+
261
+ :param data: N-D tensor with data for gathering
262
+ :param indices: N-D tensor with indices by which data is gathered. Negative indices
263
+ indicate reverse indexing from the end
264
+ :param axis: axis along which elements are gathered
265
+ :param batch_dims: number of batch dimensions
266
+ :param name: Optional output node name.
267
+ :return: The new node which performs Gather
268
+ """
269
+ inputs = as_nodes(data, indices, axis, name=name)
270
+ attributes = {
271
+ "batch_dims": batch_dims,
272
+ }
273
+ return _get_node_factory_opset8().create("Gather", inputs, attributes)
274
+
275
+
276
+ @nameable_op
277
+ def max_pool(
278
+ data: NodeInput,
279
+ strides: List[int],
280
+ dilations: List[int],
281
+ pads_begin: List[int],
282
+ pads_end: List[int],
283
+ kernel_shape: TensorShape,
284
+ rounding_type: str = "floor",
285
+ auto_pad: Optional[str] = None,
286
+ index_element_type: Optional[str] = "i64",
287
+ axis: Optional[int] = 0,
288
+ name: Optional[str] = None,
289
+ ) -> Node:
290
+ """Perform max pooling operation and return both values and indices of the selected elements.
291
+
292
+ :param data: The node providing input data.
293
+ :param strides: The distance (in pixels) to slide the filter on the feature map
294
+ over the axes.
295
+ :param dilations: The dilation of filter elements(distance between elements).
296
+ :param pads_begin: The number of pixels to add at the beginning along each axis.
297
+ :param pads_end: The number of pixels to add at the end along each axis.
298
+ :param kernel_shape: The pooling operation kernel shape.
299
+ :param rounding_type: Determines used rounding schema when computing output shape.
300
+ Acceptable values are: ['floor', 'ceil']. Defaults to 'floor'.
301
+ :param auto_pad: Determines how the padding is calculated. Acceptable values:
302
+ [None, 'same_upper', 'same_lower', 'valid']. Defaults to None.
303
+ :param index_element_type: The data type used for the indices output of this operator.
304
+ Defaults to i64.
305
+ :param axis: The first dimension in the data shape used to determine the maximum
306
+ returned index value. The value is the product of all dimensions
307
+ starting at the provided axis. Defaults to 0.
308
+ :param name: The optional name for the created output node.
309
+
310
+ :return: The new node performing max pooling operation.
311
+ """
312
+ if auto_pad is None:
313
+ auto_pad = "explicit"
314
+ return _get_node_factory_opset8().create(
315
+ "MaxPool",
316
+ [as_node(data, name=name)],
317
+ {
318
+ "strides": strides,
319
+ "dilations": dilations,
320
+ "pads_begin": pads_begin,
321
+ "pads_end": pads_end,
322
+ "kernel": kernel_shape,
323
+ "rounding_type": rounding_type.upper(),
324
+ "auto_pad": auto_pad.upper(),
325
+ "index_element_type": index_element_type,
326
+ "axis": axis,
327
+ },
328
+ )
329
+
330
+
331
+ @nameable_op
332
+ def random_uniform(
333
+ output_shape: NodeInput,
334
+ min_val: NodeInput,
335
+ max_val: NodeInput,
336
+ output_type: str,
337
+ global_seed: int = 0,
338
+ op_seed: int = 0,
339
+ alignment: str = "tensorflow",
340
+ name: Optional[str] = None,
341
+ ) -> Node:
342
+ """Return a node which generates sequence of random values from uniform distribution.
343
+
344
+ :param output_shape: Tensor with shape of the output tensor.
345
+ :param min_val: Tensor with the lower bound on the range of random values to generate.
346
+ :param max_val: Tensor with the upper bound on the range of random values to generate.
347
+ :param output_type: Specifies the output tensor type, possible values:
348
+ 'i64', 'i32', 'f64', 'f32', 'f16', 'bf16'.
349
+ :param global_seed: Specifies global seed value. Required to be a positive integer or 0.
350
+ :param op_seed: Specifies operational seed value. Required to be a positive integer or 0.
351
+ :param alignment: Specifies alignment of the randomly generated numbers to a given framework.
352
+ Possible values: 'tensorflow', 'pytorch'. Default is 'tensorflow'.
353
+ :param name: Optional output node name.
354
+
355
+ :return: The new node which performs generation of random values from uniform distribution.
356
+ """
357
+ inputs = as_nodes(output_shape, min_val, max_val, name=name)
358
+
359
+ if global_seed < 0:
360
+ raise RuntimeError(f"global_seed should be positive or 0. Got: {global_seed}")
361
+
362
+ if op_seed < 0:
363
+ raise RuntimeError(f"op_seed should be positive or 0. Got: {op_seed}")
364
+
365
+ attributes = {
366
+ "output_type": output_type,
367
+ "global_seed": global_seed,
368
+ "op_seed": op_seed,
369
+ "alignment": alignment.lower(),
370
+ }
371
+ return _get_node_factory_opset8().create("RandomUniform", inputs, attributes)
372
+
373
+
374
+ @nameable_op
375
+ def slice(
376
+ data: NodeInput,
377
+ start: NodeInput,
378
+ stop: NodeInput,
379
+ step: NodeInput,
380
+ axes: Optional[NodeInput] = None,
381
+ name: Optional[str] = None,
382
+ ) -> Node:
383
+ """Return a node which generates Slice operation.
384
+
385
+ :param data: The node providing input data.
386
+ :param start: The node providing start indices (inclusively).
387
+ :param stop: The node providing stop indices (exclusively).
388
+ :param step: The node providing step values.
389
+ :param axes: The optional node providing axes to slice, default [0, 1, ..., len(start)-1].
390
+ :param name: The optional name for the created output node.
391
+ :return: The new node performing Slice operation.
392
+ """
393
+ if axes is None:
394
+ inputs = as_nodes(data, start, stop, step, name=name)
395
+ else:
396
+ inputs = as_nodes(data, start, stop, step, axes, name=name)
397
+
398
+ return _get_node_factory_opset8().create("Slice", inputs)
399
+
400
+
401
+ @nameable_op
402
+ def gather_nd(
403
+ data: NodeInput,
404
+ indices: NodeInput,
405
+ batch_dims: Optional[int] = 0,
406
+ name: Optional[str] = None,
407
+ ) -> Node:
408
+ """Return a node which performs GatherND.
409
+
410
+ :param data: N-D tensor with data for gathering
411
+ :param indices: K-D tensor of tuples with indices by which data is gathered
412
+ :param batch_dims: Scalar value of batch dimensions
413
+ :return: The new node which performs GatherND
414
+ """
415
+ inputs = as_nodes(data, indices, name=name)
416
+
417
+ attributes = {
418
+ "batch_dims": batch_dims,
419
+ }
420
+
421
+ return _get_node_factory_opset8().create("GatherND", inputs, attributes)
422
+
423
+
424
+ @nameable_op
425
+ def prior_box(
426
+ layer_shape: Node,
427
+ image_shape: NodeInput,
428
+ attrs: dict,
429
+ name: Optional[str] = None,
430
+ ) -> Node:
431
+ """Generate prior boxes of specified sizes and aspect ratios across all dimensions.
432
+
433
+ :param layer_shape: Shape of layer for which prior boxes are computed.
434
+ :param image_shape: Shape of image to which prior boxes are scaled.
435
+ :param attrs: The dictionary containing key, value pairs for attributes.
436
+ :param name: Optional name for the output node.
437
+ :return: Node representing prior box operation.
438
+
439
+ Available attributes are:
440
+ * min_size The minimum box size (in pixels).
441
+ Range of values: positive floating point numbers
442
+ Default value: []
443
+ Required: no
444
+
445
+ * max_size The maximum box size (in pixels).
446
+ Range of values: positive floating point numbers
447
+ Default value: []
448
+ Required: no
449
+ * aspect_ratio Aspect ratios of prior boxes.
450
+ Range of values: set of positive floating point numbers
451
+ Default value: []
452
+ Required: no
453
+ * flip The flag that denotes that each aspect_ratio is duplicated and flipped.
454
+ Range of values: {True, False}
455
+ Default value: False
456
+ Required: no
457
+ * clip The flag that denotes if each value in the output tensor should be clipped
458
+ to [0,1] interval.
459
+ Range of values: {True, False}
460
+ Default value: False
461
+ Required: no
462
+ * step The distance between box centers.
463
+ Range of values: floating point non-negative number
464
+ Default value: 0
465
+ Required: no
466
+ * offset This is a shift of box respectively to top left corner.
467
+ Range of values: floating point non-negative number
468
+ Default value: None
469
+ Required: yes
470
+ * variance The variance denotes a variance of adjusting bounding boxes. The attribute
471
+ could contain 0, 1 or 4 elements.
472
+ Range of values: floating point positive numbers
473
+ Default value: []
474
+ Required: no
475
+ * scale_all_sizes The flag that denotes type of inference.
476
+ Range of values: False - max_size is ignored
477
+ True - max_size is used
478
+
479
+ Default value: True
480
+ Required: no
481
+ * fixed_ratio This is an aspect ratio of a box.
482
+ Range of values: a list of positive floating-point numbers
483
+ Default value: None
484
+ Required: no
485
+ * fixed_size This is an initial box size (in pixels).
486
+ Range of values: a list of positive floating-point numbers
487
+ Default value: None
488
+ Required: no
489
+ * density This is the square root of the number of boxes of each type.
490
+ Range of values: a list of positive floating-point numbers
491
+ Default value: None
492
+ Required: no
493
+ * min_max_aspect_ratios_order The flag that denotes the order of output prior box.
494
+ Range of values: False - the output prior box is in order of
495
+ [min, aspect_ratios, max]
496
+
497
+ True - the output prior box is in order of
498
+ [min, max, aspect_ratios]
499
+
500
+ Default value: True
501
+ Required: no
502
+
503
+ Example of attribute dictionary:
504
+
505
+ .. code-block:: python
506
+
507
+ # just required ones
508
+ attrs = {
509
+ 'offset': 85,
510
+ }
511
+ attrs = {
512
+ 'offset': 85,
513
+ 'flip': True,
514
+ 'clip': True,
515
+ 'fixed_size': [32, 64, 128]
516
+ }
517
+
518
+ Optional attributes which are absent from dictionary will be set with corresponding default.
519
+ """
520
+ requirements = [
521
+ ("offset", True, np.floating, is_non_negative_value),
522
+ ("min_size", False, np.floating, is_positive_value),
523
+ ("max_size", False, np.floating, is_positive_value),
524
+ ("aspect_ratio", False, np.floating, is_positive_value),
525
+ ("flip", False, np.bool_, None),
526
+ ("clip", False, np.bool_, None),
527
+ ("step", False, np.floating, is_non_negative_value),
528
+ ("variance", False, np.floating, is_positive_value),
529
+ ("scale_all_sizes", False, np.bool_, None),
530
+ ("fixed_ratio", False, np.floating, is_positive_value),
531
+ ("fixed_size", False, np.floating, is_positive_value),
532
+ ("density", False, np.floating, is_positive_value),
533
+ ("min_max_aspect_ratios_order", False, np.bool_, None),
534
+ ]
535
+
536
+ check_valid_attributes("PriorBox", attrs, requirements)
537
+
538
+ return _get_node_factory_opset8().create("PriorBox", [layer_shape, as_node(image_shape, name=name)], attrs)
539
+
540
+
541
+ @nameable_op
542
+ def i420_to_bgr(
543
+ arg: NodeInput,
544
+ arg_u: Optional[NodeInput] = None,
545
+ arg_v: Optional[NodeInput] = None,
546
+ name: Optional[str] = None,
547
+ ) -> Node:
548
+ """Return a node which performs I420toBGR operation.
549
+
550
+ :param arg: The node providing single or Y plane data.
551
+ :param arg_u: The node providing U plane data. Required for separate planes.
552
+ :param arg_v: The node providing V plane data. Required for separate planes.
553
+ :param name: The optional name for the created output node.
554
+ :return: The new node performing I420toBGR operation.
555
+ """
556
+ if arg_u is None and arg_v is None:
557
+ inputs = as_nodes(arg, name=name)
558
+ elif arg_u is not None and arg_v is not None:
559
+ inputs = as_nodes(arg, arg_u, arg_v, name=name)
560
+ else:
561
+ raise UserInputError(
562
+ "Operation I420toBGR must have one (single plane) or three (separate planes) inputs provided.",
563
+ )
564
+
565
+ return _get_node_factory_opset8().create("I420toBGR", inputs)
566
+
567
+
568
+ @nameable_op
569
+ def i420_to_rgb(
570
+ arg: NodeInput,
571
+ arg_u: Optional[NodeInput] = None,
572
+ arg_v: Optional[NodeInput] = None,
573
+ name: Optional[str] = None,
574
+ ) -> Node:
575
+ """Return a node which performs I420toRGB operation.
576
+
577
+ :param arg: The node providing single or Y plane data.
578
+ :param arg_u: The node providing U plane data. Required for separate planes.
579
+ :param arg_v: The node providing V plane data. Required for separate planes.
580
+ :param name: The optional name for the created output node.
581
+ :return: The new node performing I420toRGB operation.
582
+ """
583
+ if arg_u is None and arg_v is None:
584
+ inputs = as_nodes(arg, name=name)
585
+ elif arg_u is not None and arg_v is not None:
586
+ inputs = as_nodes(arg, arg_u, arg_v, name=name)
587
+ else:
588
+ raise UserInputError(
589
+ "Operation I420toRGB must have one (single plane) or three (separate planes) inputs provided.",
590
+ )
591
+
592
+ return _get_node_factory_opset8().create("I420toRGB", inputs)
593
+
594
+
595
+ @nameable_op
596
+ def nv12_to_bgr(
597
+ arg: NodeInput,
598
+ arg_uv: Optional[NodeInput] = None,
599
+ name: Optional[str] = None,
600
+ ) -> Node:
601
+ """Return a node which performs NV12toBGR operation.
602
+
603
+ :param arg: The node providing single or Y plane data.
604
+ :param arg_uv: The node providing UV plane data. Required for separate planes.
605
+ :param name: The optional name for the created output node.
606
+ :return: The new node performing NV12toBGR operation.
607
+ """
608
+ if arg_uv is None:
609
+ inputs = as_nodes(arg, name=name)
610
+ else:
611
+ inputs = as_nodes(arg, arg_uv, name=name)
612
+
613
+ return _get_node_factory_opset8().create("NV12toBGR", inputs)
614
+
615
+
616
+ @nameable_op
617
+ def nv12_to_rgb(
618
+ arg: NodeInput,
619
+ arg_uv: Optional[NodeInput] = None,
620
+ name: Optional[str] = None,
621
+ ) -> Node:
622
+ """Return a node which performs NV12toRGB operation.
623
+
624
+ :param arg: The node providing single or Y plane data.
625
+ :param arg_uv: The node providing UV plane data. Required for separate planes.
626
+ :param name: The optional name for the created output node.
627
+ :return: The new node performing NV12toRGB operation.
628
+ """
629
+ if arg_uv is None:
630
+ inputs = as_nodes(arg, name=name)
631
+ else:
632
+ inputs = as_nodes(arg, arg_uv, name=name)
633
+
634
+ return _get_node_factory_opset8().create("NV12toRGB", inputs)
635
+
636
+
637
+ @nameable_op
638
+ def detection_output(
639
+ box_logits: NodeInput,
640
+ class_preds: NodeInput,
641
+ proposals: NodeInput,
642
+ attrs: dict,
643
+ aux_class_preds: Optional[NodeInput] = None,
644
+ aux_box_preds: Optional[NodeInput] = None,
645
+ name: Optional[str] = None,
646
+ ) -> Node:
647
+ """Generate the detection output using information on location and confidence predictions.
648
+
649
+ :param box_logits: The 2D input tensor with box logits.
650
+ :param class_preds: The 2D input tensor with class predictions.
651
+ :param proposals: The 3D input tensor with proposals.
652
+ :param attrs: The dictionary containing key, value pairs for attributes.
653
+ :param aux_class_preds: The 2D input tensor with additional class predictions information.
654
+ :param aux_box_preds: The 2D input tensor with additional box predictions information.
655
+ :param name: Optional name for the output node.
656
+ :return: Node representing DetectionOutput operation.
657
+ Available attributes are:
658
+
659
+ * background_label_id The background label id.
660
+ Range of values: integer value
661
+ Default value: 0
662
+ Required: no
663
+ * top_k Maximum number of results to be kept per batch after NMS step.
664
+ Range of values: integer value
665
+ Default value: -1
666
+ Required: no
667
+ * variance_encoded_in_target The flag that denotes if variance is encoded in target.
668
+ Range of values: {False, True}
669
+ Default value: False
670
+ Required: no
671
+ * keep_top_k Maximum number of bounding boxes per batch to be kept after NMS step.
672
+ Range of values: integer values
673
+ Default value: None
674
+ Required: yes
675
+ * code_type The type of coding method for bounding boxes.
676
+ Range of values: {'caffe.PriorBoxParameter.CENTER_SIZE',
677
+ 'caffe.PriorBoxParameter.CORNER'}
678
+
679
+ Default value: 'caffe.PriorBoxParameter.CORNER'
680
+ Required: no
681
+ * share_location The flag that denotes if bounding boxes are shared among different
682
+ classes.
683
+ Range of values: {True, False}
684
+ Default value: True
685
+ Required: no
686
+ * nms_threshold The threshold to be used in the NMS stage.
687
+ Range of values: floating point value
688
+ Default value: None
689
+ Required: yes
690
+ * confidence_threshold Specifies the minimum confidence threshold for detection boxes to be
691
+ considered.
692
+ Range of values: floating point value
693
+ Default value: 0
694
+ Required: no
695
+ * clip_after_nms The flag that denotes whether to perform clip bounding boxes after
696
+ non-maximum suppression or not.
697
+ Range of values: {True, False}
698
+ Default value: False
699
+ Required: no
700
+ * clip_before_nms The flag that denotes whether to perform clip bounding boxes before
701
+ non-maximum suppression or not.
702
+ Range of values: {True, False}
703
+ Default value: False
704
+ Required: no
705
+ * decrease_label_id The flag that denotes how to perform NMS.
706
+ Range of values: False - perform NMS like in Caffe*.
707
+ True - perform NMS like in MxNet*.
708
+
709
+ Default value: False
710
+ Required: no
711
+ * normalized The flag that denotes whether input tensors with boxes are normalized.
712
+ Range of values: {True, False}
713
+ Default value: False
714
+ Required: no
715
+ * input_height The input image height.
716
+ Range of values: positive integer number
717
+ Default value: 1
718
+ Required: no
719
+ * input_width The input image width.
720
+ Range of values: positive integer number
721
+ Default value: 1
722
+ Required: no
723
+ * objectness_score The threshold to sort out confidence predictions.
724
+ Range of values: non-negative float number
725
+ Default value: 0
726
+ Required: no
727
+
728
+ Example of attribute dictionary:
729
+
730
+ .. code-block:: python
731
+
732
+ # just required ones
733
+ attrs = {
734
+ 'keep_top_k': [1, 2, 3],
735
+ 'nms_threshold': 0.645,
736
+ }
737
+ attrs = {
738
+ 'keep_top_k': [1, 2, 3],
739
+ 'nms_threshold': 0.645,
740
+ 'normalized': True,
741
+ 'clip_before_nms': True,
742
+ 'input_height': [32],
743
+ 'input_width': [32],
744
+ }
745
+
746
+ Optional attributes which are absent from dictionary will be set with corresponding default.
747
+ """
748
+ requirements = [
749
+ ("background_label_id", False, np.integer, None),
750
+ ("top_k", False, np.integer, None),
751
+ ("variance_encoded_in_target", False, np.bool_, None),
752
+ ("keep_top_k", True, np.integer, None),
753
+ ("code_type", False, np.str_, None),
754
+ ("share_location", False, np.bool_, None),
755
+ ("nms_threshold", True, np.floating, None),
756
+ ("confidence_threshold", False, np.floating, None),
757
+ ("clip_after_nms", False, np.bool_, None),
758
+ ("clip_before_nms", False, np.bool_, None),
759
+ ("decrease_label_id", False, np.bool_, None),
760
+ ("normalized", False, np.bool_, None),
761
+ ("input_height", False, np.integer, is_positive_value),
762
+ ("input_width", False, np.integer, is_positive_value),
763
+ ("objectness_score", False, np.floating, is_non_negative_value),
764
+ ]
765
+
766
+ check_valid_attributes("DetectionOutput", attrs, requirements)
767
+
768
+ inputs = [box_logits, class_preds, proposals]
769
+ if aux_class_preds is not None:
770
+ inputs.append(aux_class_preds)
771
+ if aux_box_preds is not None:
772
+ inputs.append(aux_box_preds)
773
+ inputs = as_nodes(*inputs, name=name)
774
+
775
+ return _get_node_factory_opset8().create("DetectionOutput", inputs, attrs)
776
+
777
+
778
+ @nameable_op
779
+ def softmax(data: NodeInput, axis: int, name: Optional[str] = None) -> Node:
780
+ """Apply softmax operation on each element of input tensor.
781
+
782
+ :param data: The tensor providing input data.
783
+ :param axis: An axis along which Softmax should be calculated. Can be positive or negative.
784
+ :param name: Optional name for the node.
785
+ :return: The new node with softmax operation applied on each element.
786
+ """
787
+ return _get_node_factory_opset8().create("Softmax", [as_node(data, name=name)], {"axis": axis})