Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Steve Yoo 2021-07-22 14:58:56 +09:00
commit 4880bd11d4
1071 changed files with 18595 additions and 7788 deletions

View File

@ -109,7 +109,6 @@ jobs:
-DENABLE_WHEEL=ON
-DENABLE_TESTS=ON
-DNGRAPH_ONNX_IMPORT_ENABLE=ON
-DNGRAPH_ONNX_EDITOR_ENABLE=ON
-DENABLE_FASTER_BUILD=ON
-DENABLE_STRICT_DEPENDENCIES=OFF
-DIE_EXTRA_MODULES=$(OPENVINO_CONTRIB_REPO_DIR)/modules

View File

@ -95,7 +95,6 @@ jobs:
-DENABLE_SAMPLES=OFF
-DENABLE_SPEECH_DEMO=OFF
-DNGRAPH_ONNX_IMPORT_ENABLE=ON
-DNGRAPH_ONNX_EDITOR_ENABLE=ON
-DNGRAPH_DEBUG_ENABLE=OFF
$(REPO_DIR)
workingDirectory: $(BUILD_DIR)

View File

@ -87,9 +87,6 @@ jobs:
export PATH="/usr/local/opt/cython/bin:$PATH"
export CC=gcc
export CXX=g++
# Disable errors with Ninja
export CXXFLAGS="-Wno-error=unused-command-line-argument"
export CFLAGS="-Wno-error=unused-command-line-argument"
cmake -GNinja -DVERBOSE_BUILD=ON -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DENABLE_PYTHON=ON -DENABLE_TESTS=ON -DENABLE_STRICT_DEPENDENCIES=OFF -DIE_EXTRA_MODULES=$(OPENVINO_CONTRIB_REPO_DIR)/modules $(REPO_DIR)
workingDirectory: $(BUILD_DIR)
displayName: 'CMake'

View File

@ -69,7 +69,6 @@ RUN cmake .. \
-DENABLE_PYTHON=ON \
-DPYTHON_EXECUTABLE=/usr/bin/python3 \
-DNGRAPH_ONNX_IMPORT_ENABLE=ON \
-DNGRAPH_ONNX_EDITOR_ENABLE=ON \
-DNGRAPH_DEBUG_ENABLE=OFF \
-DCMAKE_INSTALL_PREFIX=/openvino/dist \
-DNGRAPH_USE_PROTOBUF_LITE=${PROTOBUF_LITE}

View File

@ -25,7 +25,7 @@ jobs:
run: |
mkdir build
cd build
cmake -DENABLE_PYTHON=ON -DENABLE_PROFILING_ITT=ON -DSELECTIVE_BUILD=COLLECT ..
cmake -DENABLE_PYTHON=ON -DENABLE_TESTS=ON -DENABLE_PROFILING_ITT=ON -DSELECTIVE_BUILD=COLLECT ..
- name: Check code style
run: cmake --build build --target clang_format_check_all

View File

@ -42,50 +42,6 @@ endforeach()
# Build
#
function(build_ngraph)
function(ngraph_set option value)
if(NOT DEFINED ${option})
set(${option} ${value} CACHE BOOL "" FORCE)
endif()
endfunction()
if(ENABLE_TESTS AND NOT ANDROID)
ngraph_set(NGRAPH_UNIT_TEST_ENABLE ON)
else()
ngraph_set(NGRAPH_UNIT_TEST_ENABLE OFF)
endif()
if(NOT (ANDROID OR WINDOWS_STORE OR (MSVC AND (ARM OR AARCH64)) ))
ngraph_set(NGRAPH_ONNX_IMPORT_ENABLE ON)
ngraph_set(NGRAPH_PDPD_FRONTEND_ENABLE ON)
else()
ngraph_set(NGRAPH_ONNX_IMPORT_ENABLE OFF)
ngraph_set(NGRAPH_PDPD_FRONTEND_ENABLE OFF)
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$")
ie_add_compiler_flags(-Wno-error=uninitialized -Wno-error=literal-conversion)
elseif(UNIX)
ie_add_compiler_flags(-Wno-error=maybe-uninitialized -Wno-error=return-type)
endif()
# WA for GCC 7.0
if (UNIX)
ie_add_compiler_flags(-Wno-error=return-type -Wno-undef)
elseif(WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4308 /wd4146 /wd4703 /wd4244 /wd4819")
endif()
if(ENABLE_LTO)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON)
endif()
ie_cpack_add_component(ngraph REQUIRED)
ie_cpack_add_component(ngraph_dev REQUIRED DEPENDS ngraph)
add_subdirectory(ngraph)
endfunction()
function(openvino_developer_export_targets)
cmake_parse_arguments(EXPORT "" "COMPONENT" "TARGETS" ${ARGN})
@ -118,9 +74,12 @@ function(openvino_developer_export_targets)
"A list of OpenVINO exported components" FORCE)
endfunction()
ie_cpack_add_component(ngraph REQUIRED)
ie_cpack_add_component(ngraph_dev REQUIRED DEPENDS ngraph)
add_subdirectory(thirdparty)
add_subdirectory(openvino)
build_ngraph()
add_subdirectory(ngraph)
add_subdirectory(inference-engine)
# for Template plugin

View File

@ -93,15 +93,8 @@ ie_coverage_genhtml(INFO_FILE "ngraph"
if(NGRAPH_ONNX_IMPORT_ENABLE)
ie_coverage_extract(INPUT "openvino" OUTPUT "onnx_importer"
PATTERNS "${OV_COVERAGE_BASE_DIRECTORY}/ngraph/frontend/onnx_common*"
"${OV_COVERAGE_BASE_DIRECTORY}/ngraph/frontend/onnx_editor*"
"${OV_COVERAGE_BASE_DIRECTORY}/ngraph/frontend/onnx_import*")
ie_coverage_genhtml(INFO_FILE "onnx_importer"
PREFIX "${OV_COVERAGE_BASE_DIRECTORY}")
endif()
if(NGRAPH_ONNX_EDITOR_ENABLE)
ie_coverage_extract(INPUT "openvino" OUTPUT "onnx_editor"
PATTERNS "${OV_COVERAGE_BASE_DIRECTORY}/ngraph/frontend/onnx_editor*")
ie_coverage_genhtml(INFO_FILE "onnx_editor"
PREFIX "${OV_COVERAGE_BASE_DIRECTORY}")
endif()

View File

@ -3,6 +3,7 @@
#
include(ProcessorCount)
include(CheckCXXCompilerFlag)
#
# Disables deprecated warnings generation
@ -292,9 +293,14 @@ else()
elseif(UNIX)
ie_add_compiler_flags(-Wuninitialized -Winit-self)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
ie_add_compiler_flags(-Wno-error=switch)
ie_add_compiler_flags(-Wno-error=switch
-Winconsistent-missing-override)
else()
ie_add_compiler_flags(-Wmaybe-uninitialized)
check_cxx_compiler_flag("-Wsuggest-override" SUGGEST_OVERRIDE_SUPPORTED)
if(SUGGEST_OVERRIDE_SUPPORTED)
set(CMAKE_CXX_FLAGS "-Wsuggest-override ${CMAKE_CXX_FLAGS}")
endif()
endif()
endif()
@ -315,3 +321,27 @@ else()
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--gc-sections -Wl,--exclude-libs,ALL")
endif()
endif()
# Links provided libraries and include their INTERFACE_INCLUDE_DIRECTORIES as SYSTEM
function(link_system_libraries TARGET_NAME)
set(MODE PRIVATE)
foreach(arg IN LISTS ARGN)
if(arg MATCHES "(PRIVATE|PUBLIC|INTERFACE)")
set(MODE ${arg})
else()
if(TARGET "${arg}")
target_include_directories(${TARGET_NAME}
SYSTEM ${MODE}
$<TARGET_PROPERTY:${arg},INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:${arg},INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>
)
endif()
target_link_libraries(${TARGET_NAME}
${MODE}
${arg}
)
endif()
endforeach()
endfunction()

View File

@ -6,7 +6,7 @@ include(CheckCXXCompilerFlag)
if (ENABLE_SANITIZER)
set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize=address")
CHECK_CXX_COMPILER_FLAG("-fsanitize-recover=address" SANITIZE_RECOVER_ADDRESS_SUPPORTED)
check_cxx_compiler_flag("-fsanitize-recover=address" SANITIZE_RECOVER_ADDRESS_SUPPORTED)
if (SANITIZE_RECOVER_ADDRESS_SUPPORTED)
set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize-recover=address")
endif()
@ -18,7 +18,7 @@ if (ENABLE_UB_SANITIZER)
# TODO: Remove -fno-sanitize=null as thirdparty/ocl/clhpp_headers UBSAN compatibility resolved:
# https://github.com/KhronosGroup/OpenCL-CLHPP/issues/17
set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize=undefined -fno-sanitize=null")
CHECK_CXX_COMPILER_FLAG("-fsanitize-recover=undefined" SANITIZE_RECOVER_UNDEFINED_SUPPORTED)
check_cxx_compiler_flag("-fsanitize-recover=undefined" SANITIZE_RECOVER_UNDEFINED_SUPPORTED)
if (SANITIZE_RECOVER_UNDEFINED_SUPPORTED)
set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize-recover=undefined")
endif()
@ -40,7 +40,7 @@ if (DEFINED SANITIZER_COMPILER_FLAGS)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fuse-ld=gold")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$" AND NOT WIN32)
elseif(OV_COMPILER_IS_CLANG AND NOT WIN32)
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fuse-ld=lld")
endif()

View File

@ -23,7 +23,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "Release")
if (NOT ENABLE_SANITIZER)
set(IE_C_CXX_FLAGS "${IE_C_CXX_FLAGS} -s")
endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$")
elseif(OV_COMPILER_IS_CLANG)
set(IE_C_CXX_FLAGS "${IE_C_CXX_FLAGS} -fstack-protector-all")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
if (NOT ENABLE_SANITIZER)

View File

@ -58,7 +58,7 @@ ie_option (VERBOSE_BUILD "shows extra information about build" OFF)
ie_option (ENABLE_UNSAFE_LOCATIONS "skip check for MD5 for dependency" OFF)
ie_dependent_option (ENABLE_FUZZING "instrument build for fuzzing" OFF "CMAKE_CXX_COMPILER_ID MATCHES ^(Apple)?Clang$; NOT WIN32" OFF)
ie_dependent_option (ENABLE_FUZZING "instrument build for fuzzing" OFF "OV_COMPILER_IS_CLANG; NOT WIN32" OFF)
#
# Check features

View File

@ -53,7 +53,9 @@ macro(ie_cpack)
set(CPACK_PACKAGE_VENDOR "Intel Corporation")
set(CPACK_VERBATIM_VARIABLES ON)
set(CPACK_COMPONENTS_ALL ${ARGN})
set(CPACK_STRIP_FILES ON)
if (NOT DEFINED CPACK_STRIP_FILES)
set(CPACK_STRIP_FILES ON)
endif()
set(CPACK_THREADS 8)
string(REPLACE "/" "_" CPACK_PACKAGE_VERSION "${CI_BUILD_NUMBER}")

View File

@ -55,3 +55,9 @@ endif()
if(UNIX AND NOT APPLE)
set(LINUX ON)
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$")
set(OV_COMPILER_IS_CLANG ON)
else()
set(OV_COMPILER_IS_CLANG OFF)
endif()

View File

@ -114,6 +114,24 @@ ie_option (ENABLE_SYSTEM_PUGIXML "use the system copy of pugixml" OFF)
ie_option (ENABLE_CPU_DEBUG_CAPS "enable CPU debug capabilities at runtime" OFF)
if(ANDROID OR WINDOWS_STORE OR (MSVC AND (ARM OR AARCH64)))
set(protoc_available OFF)
else()
set(protoc_available ON)
endif()
ie_dependent_option(NGRAPH_ONNX_IMPORT_ENABLE "Enable ONNX importer" ON "protoc_available" OFF)
ie_dependent_option(NGRAPH_PDPD_FRONTEND_ENABLE "Enable PaddlePaddle FrontEnd" ON "protoc_available" OFF)
ie_dependent_option(NGRAPH_USE_PROTOBUF_LITE "Compiles and links with protobuf-lite" OFF
"NGRAPH_ONNX_IMPORT_ENABLE OR NGRAPH_PDPD_FRONTEND_ENABLE" OFF)
ie_dependent_option(NGRAPH_UNIT_TEST_ENABLE "Enables ngraph unit tests" ON "ENABLE_TESTS;NOT ANDROID" OFF)
ie_dependent_option(NGRAPH_UNIT_TEST_BACKENDS_ENABLE "Control the building of unit tests using backends" ON
"NGRAPH_UNIT_TEST_ENABLE" OFF)
option(NGRAPH_DEBUG_ENABLE "Enable output for NGRAPH_DEBUG statements" OFF)
# WA for ngraph python build on Windows debug
list(REMOVE_ITEM IE_OPTIONS NGRAPH_UNIT_TEST_ENABLE NGRAPH_UNIT_TEST_BACKENDS_ENABLE)
#
# Process featues
#

View File

@ -73,6 +73,10 @@ function(_ie_target_no_deprecation_error)
else()
set(flags "-Wno-error=deprecated-declarations")
endif()
if(CMAKE_CROSSCOMPILING)
set_target_properties(${ARGV} PROPERTIES
INTERFACE_LINK_OPTIONS "-Wl,--allow-shlib-undefined")
endif()
set_target_properties(${ARGV} PROPERTIES INTERFACE_COMPILE_OPTIONS ${flags})
endif()

View File

@ -13,7 +13,7 @@ set_and_check(IE_MAIN_SOURCE_DIR "@IE_MAIN_SOURCE_DIR@") # HDDL
# Variables to export in plugin's projects
set(ie_options "@IE_OPTIONS@;CMAKE_BUILD_TYPE;CMAKE_SKIP_RPATH;")
set(ie_options "@IE_OPTIONS@;CMAKE_BUILD_TYPE;CMAKE_SKIP_RPATH")
list(APPEND ie_options CMAKE_CXX_COMPILER_LAUNCHER CMAKE_C_COMPILER_LAUNCHER)
file(TO_CMAKE_PATH "${CMAKE_CURRENT_LIST_DIR}" cache_path)
@ -73,6 +73,9 @@ if(NOT MSVC)
ie_add_compiler_flags(-Wno-error=unused-variable)
if(CMAKE_COMPILER_IS_GNUCXX)
ie_add_compiler_flags(-Wno-error=unused-but-set-variable)
if(SUGGEST_OVERRIDE_SUPPORTED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-suggest-override")
endif()
endif()
endif()

View File

@ -0,0 +1,15 @@
# Converting RetinaNet Model from TensorFlow* to the Intermediate Representation {#openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_RetinaNet_From_Tensorflow}
This tutorial explains how to convert RetinaNet model to the Intermediate Representation (IR).
[Public RetinaNet model](https://github.com/fizyr/keras-retinanet) does not contain pretrained TensorFlow\* weights.
To convert this model to the TensorFlow\* format, you can use [Reproduce Keras* to TensorFlow* Conversion tutorial](https://docs.openvinotoolkit.org/latest/omz_models_model_retinanet_tf.html).
After you convert the model to TensorFlow* format, run the Model Optimizer command below:
```sh
python mo.py --input "input_1[1 1333 1333 3]" --input_model retinanet_resnet50_coco_best_v2.1.0.pb --data_type FP32 --transformations_config ./extensions/front/tf/retinanet.json
```
Where `transformations_config` command-line parameter specifies the configuration json file containing model conversion hints for the Model Optimizer.
The json file contains some parameters that need to be changed if you train the model yourself. It also contains information on how to match endpoints
to replace the subgraph nodes. After the model is converted to IR, the output nodes will be replaced with DetectionOutput layer.

View File

@ -34,6 +34,7 @@ limitations under the License.
<tab type="user" title="Converting DeepSpeech Model from TensorFlow" url="@ref openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_DeepSpeech_From_Tensorflow"/>
<tab type="user" title="Converting Language Model on One Billion Word Benchmark from TensorFlow" url="@ref openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_lm_1b_From_Tensorflow"/>
<tab type="user" title="Converting TensorFlow* Object Detection API Models" url="@ref openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_Object_Detection_API_Models"/>
<tab type="user" title="Converting RetinaNet Model from TensorFlow" url="@ref openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_RetinaNet_From_Tensorflow"/>
<tab type="user" title="Converting TensorFlow*-Slim Image Classification Model Library Models" url="@ref openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_Slim_Library_Models"/>
<tab type="user" title="Converting CRNN Model from TensorFlow" url="@ref openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_CRNN_From_Tensorflow"/>
<tab type="user" title="Converting GNMT from TensorFlow" url="@ref openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_GNMT_From_Tensorflow"/>
@ -176,6 +177,7 @@ limitations under the License.
<tab type="user" title="HSigmoid-5" url="@ref openvino_docs_ops_activation_HSigmoid_5"/>
<tab type="user" title="HSwish-4" url="@ref openvino_docs_ops_activation_HSwish_4"/>
<tab type="user" title="IDFT-7" url="@ref openvino_docs_ops_signals_IDFT_7"/>
<tab type="user" title="If-8" url="@ref openvino_docs_ops_condition_If_8"/>
<tab type="user" title="Interpolate-1" url="@ref openvino_docs_ops_image_Interpolate_1"/>
<tab type="user" title="Interpolate-4" url="@ref openvino_docs_ops_image_Interpolate_4"/>
<tab type="user" title="LRN-1" url="@ref openvino_docs_ops_normalization_LRN_1"/>

View File

@ -23,14 +23,14 @@ clamp( x_{i} )=\min\big( \max\left( x_{i}, min\_value \right), max\_value \big)
* *min*
* **Description**: *min* is the lower bound of values in the output.
* **Range of values**: arbitrary floating point number
* **Range of values**: arbitrary floating-point number
* **Type**: `float`
* **Required**: *yes*
* *max*
* **Description**: *max* is the upper bound of values in the output.
* **Range of values**: arbitrary floating point number
* **Range of values**: arbitrary floating-point number
* **Type**: `float`
* **Required**: *yes*

View File

@ -27,7 +27,7 @@ The HSigmoid operation is introduced in the following [article](https://arxiv.or
**Types**
* *T*: any floating point type.
* *T*: any floating-point type.
**Examples**

View File

@ -27,7 +27,7 @@ The HSwish operation is introduced in the following [article](https://arxiv.org/
**Types**
* *T*: arbitrary supported floating point type.
* *T*: arbitrary supported floating-point type.
**Example**

View File

@ -30,7 +30,7 @@ For each element from the input tensor calculates corresponding
**Types**
* *T*: any floating point type.
* *T*: any floating-point type.
**Examples**

View File

@ -32,7 +32,7 @@ LogSoftmax(x, axis) = t - Log(ReduceSum(Exp(t), axis))
**Types**
* *T*: any floating point type.
* *T*: any floating-point type.
**Mathematical Formulation**

View File

@ -20,11 +20,11 @@ sigmoid( x ) = \frac{1}{1+e^{-x}}
**Inputs**:
* **1**: Input tensor *x* of any floating point type. **Required.**
* **1**: Input tensor *x* of any floating-point type. **Required.**
**Outputs**:
* **1**: Result of Sigmoid function applied to the input tensor *x*. Floating point tensor with shape and type matching the input tensor.
* **1**: Result of Sigmoid function applied to the input tensor *x*. Floating-point tensor with shape and type matching the input tensor.
**Example**

View File

@ -6,31 +6,27 @@
**Short description**: *Acosh* performs element-wise hyperbolic inverse cosine (arccosh) operation with given tensor.
**Attributes**:
No attributes available.
**Inputs**
* **1**: A tensor of type *T*. **Required.**
**Outputs**
* **1**: The result of element-wise acosh operation. A tensor of type *T*.
**Types**
* *T*: any floating point type.
*Acosh* does the following with the input tensor *a*:
**Detailed description**: Operation takes one input tensor and performs the element-wise hyperbolic inverse cosine operation on a given input tensor, based on the following mathematical formula:
\f[
a_{i} = acosh(a_{i})
\f]
**Examples**
**Attributes**: *Acosh* operation has no attributes.
*Example 1*
**Inputs**
* **1**: A tensor of type *T* and arbitrary shape. **Required.**
**Outputs**
* **1**: The result of element-wise *Acosh* operation. A tensor of type *T* and the same shape as the input tensor.
**Types**
* *T*: any numeric type.
**Examples**
```xml
<layer ... type="Acosh">

View File

@ -20,7 +20,7 @@
**Types**
* *T*: any floating point type.
* *T*: any floating-point type.
*Atanh* does the following with the input tensor *a*:

View File

@ -27,7 +27,7 @@ erf(x) = \pi^{-1} \int_{-x}^{x} e^{-t^2} dt
**Types**
* *T*: any supported floating point type.
* *T*: any supported floating-point type.
**Examples**

View File

@ -4,33 +4,30 @@
**Category**: Arithmetic unary operation
**Short description**: *Sign* performs element-wise sign operation with given tensor.
**Short description**: *Sign* performs element-wise sign operation on a given input tensor.
**Attributes**:
No attributes available.
**Inputs**
* **1**: An tensor of type *T*. **Required.**
**Outputs**
* **1**: The result of element-wise sign operation. A tensor of type *T* with mapped elements of the input tensor to -1 (if it is negative), 0 (if it is zero), or 1 (if it is positive).
**Types**
* *T*: any numeric type.
*Sign* does the following with the input tensor *a*:
**Detailed description**: *Sign* performs element-wise sign operation on a given input tensor, based on the following mathematical formula:
\f[
a_{i} = sign(a_{i})
\f]
**Examples**
**Attributes**: *Sign* operation has no attributes.
*Example 1*
**Inputs**
* **1**: A tensor of type *T* and arbitrary shape. **Required.**
**Outputs**
* **1**: The result of element-wise *Sign* operation. A tensor of type *T* with mapped elements of the input tensor to -1 (if it is negative), 0 (if it is zero), or 1 (if it is positive).
**Types**
* *T*: any numeric type.
**Example**
```xml
<layer ... type="Sign">

226
docs/ops/condition/If_8.md Normal file
View File

@ -0,0 +1,226 @@
## If <a name="If"></a> {#openvino_docs_ops_infrastructure_If_8}
**Versioned name**: *If-8*
**Category**: Infrastructure
**Short description**: *If* operation contains two internal networks(subgraphs) such as `then_body` and `else_body`,
and performs one of them depending on `cond` value. If `cond` is `True`, `then_body` is executed. If `cond` is `False`,
the operation executes the `else_body` subgraph.
**Detailed description**
*If* must not contain empty subgraphs. Each of them must have at least one operation `Result`.
Also the number of outputs from *If* always must be greater than zero and equal to the number of outputs from each subgraph.
**If attributes**:
* **Subgraphs**:
`then_body`/`else_body` are subgraphs that are executed depending on the `cond` value.
The subgraph is described operation by operation as a typical IR network.
The subgraph has inputs (`Parameter` operations) and outputs (`Result` operations).
* **Subgraph's inputs** - inputs to the subgraph which associated with *If* inputs via *port_map*.
The subgraph can have any number of inputs (even zero).
* **Subgraph's outputs** - outputs from the subgraph which associated with *If* outputs via *port_map*.
The subgraph must contain at least one output. Each *If* output is associated with one output from the subgraph.
Therefore the number of `then_body` outputs is equal to the number of outputs from *If* and
the number of `else_body` outputs.
The type of the subgraph output and the type of the associated output from *If* must be equal.
* **Port maps**:
*port_map* is a set of rules to map input or output data tensors of *If* operation onto the subgraph data tensors.
The `port_map` entries can be `input` and `output`. Each entry describes a corresponding mapping rule.
*If* has two *port_maps*: `then_port_map` for `then_body` and `else_port_map` for `else_body`.
* **Port map attributes**:
* *external_port_id*
* **Description**: *external_port_id* is a port ID of *If* operation.
* **Range of values**: IDs of the *If* inputs and outputs
* **Type**: `unsigned int`
* **Default value**: None
* **Required**: *yes*
* *internal_layer_id*
* **Description**: *internal_layer_id* is a `Parameter` or `Result` operation ID inside
the subgraph to map to.
* **Range of values**: IDs of the `Parameter` or `Result` operations in the subgraph
* **Type**: `unsigned int`
* **Default value**: None
* **Required**: *yes*
**If Inputs**
* **cond**: A scalar or 1D tensor with 1 element of `boolean` type specifying which subgraph to execute.
`True` value means to execute the `then_body`, `False` - `else_body`. *Required*.
* **Multiple other inputs**: Tensors of different types and shapes. *Optional*.
**If Outputs**
* **Multiple outputs**: Results of execution of one of the subgraph. Tensors of any type and shape.
**Body Inputs**
* **Multiple inputs**: Tensors of different types and shapes. *Optional*.
**Body Outputs**
* **Multiple outputs**: Results of execution of the subgraph. Tensors of any type and shape.
**Examples**
*Example 1: a typical If structure*
```xml
<layer id="6" name="if/cond" type="If" version="opset8">
<input>
<port id="0"/>
<port id="1">
<dim>2</dim>
<dim>4</dim>
</port>
<port id="2">
<dim>2</dim>
<dim>4</dim>
</port>
<port id="3">
<dim>2</dim>
<dim>4</dim>
</port>
</input>
<output>
<port id="4" names="if/cond/Identity:0,if/cond:0" precision="FP32">
<dim>2</dim>
<dim>4</dim>
</port>
</output>
<then_port_map>
<input external_port_id="1" internal_layer_id="0"/>
<input external_port_id="2" internal_layer_id="1"/>
<output external_port_id="0" internal_layer_id="3"/>
</then_port_map>
<else_port_map>
<input external_port_id="1" internal_layer_id="0"/>
<input external_port_id="3" internal_layer_id="1"/>
<output external_port_id="0" internal_layer_id="3"/>
</else_port_map>
<then_body>
<layers>
<layer id="0" name="add_x" type="Parameter" version="opset1">
<data element_type="f32" shape="2,4"/>
<output>
<port id="0" names="add_x:0" precision="FP32">
<dim>2</dim>
<dim>4</dim>
</port>
</output>
</layer>
<layer id="1" name="add_z" type="Parameter" version="opset1">
<data element_type="f32" shape="2,4"/>
<output>
<port id="0" names="add_z:0" precision="FP32">
<dim>2</dim>
<dim>4</dim>
</port>
</output>
</layer>
<layer id="2" name="Add" type="Add" version="opset1">
<data auto_broadcast="numpy"/>
<input>
<port id="0">
<dim>2</dim>
<dim>4</dim>
</port>
<port id="1">
<dim>2</dim>
<dim>4</dim>
</port>
</input>
<output>
<port id="2" names="Add:0" precision="FP32">
<dim>2</dim>
<dim>4</dim>
</port>
</output>
</layer>
<layer id="3" name="Identity/sink_port_0" type="Result" version="opset1">
<input>
<port id="0">
<dim>2</dim>
<dim>4</dim>
</port>
</input>
</layer>
</layers>
<edges>
<edge from-layer="0" from-port="0" to-layer="2" to-port="0"/>
<edge from-layer="1" from-port="0" to-layer="2" to-port="1"/>
<edge from-layer="2" from-port="2" to-layer="3" to-port="0"/>
</edges>
</then_body>
<else_body>
<layers>
<layer id="0" name="add_x" type="Parameter" version="opset1">
<data element_type="f32" shape="2,4"/>
<output>
<port id="0" names="add_x:0" precision="FP32">
<dim>2</dim>
<dim>4</dim>
</port>
</output>
</layer>
<layer id="1" name="add_w" type="Parameter" version="opset1">
<data element_type="f32" shape="2,4"/>
<output>
<port id="0" names="add_w:0" precision="FP32">
<dim>2</dim>
<dim>4</dim>
</port>
</output>
</layer>
<layer id="2" name="Add" type="Add" version="opset1">
<data auto_broadcast="numpy"/>
<input>
<port id="0">
<dim>2</dim>
<dim>4</dim>
</port>
<port id="1">
<dim>2</dim>
<dim>4</dim>
</port>
</input>
<output>
<port id="2" names="Add:0" precision="FP32">
<dim>2</dim>
<dim>4</dim>
</port>
</output>
</layer>
<layer id="3" name="Identity/sink_port_0" type="Result" version="opset1">
<input>
<port id="0">
<dim>2</dim>
<dim>4</dim>
</port>
</input>
</layer>
</layers>
<edges>
<edge from-layer="0" from-port="0" to-layer="2" to-port="0"/>
<edge from-layer="1" from-port="0" to-layer="2" to-port="1"/>
<edge from-layer="2" from-port="2" to-layer="3" to-port="0"/>
</edges>
</else_body>
</layer>
```

View File

@ -17,26 +17,31 @@
* **Description**: specifies rules used for auto-broadcasting of input tensors.
* **Range of values**:
* *none* - no auto-broadcasting is allowed, all input shapes should match
* *numpy* - numpy broadcasting rules, aligned with ONNX Broadcasting. Description is available in <a href="https://github.com/onnx/onnx/blob/master/docs/Broadcasting.md">ONNX docs</a>.
* **Type**: string
* *none* - no auto-broadcasting is allowed, all input shapes must match
* *numpy* - numpy broadcasting rules, description is available in [Broadcast Rules For Elementwise Operations](../broadcast_rules.md)
* *pdpd* - PaddlePaddle-style implicit broadcasting, description is available in [Broadcast Rules For Elementwise Operations](../broadcast_rules.md)
* **Type**: `string`
* **Default value**: "numpy"
* **Required**: *no*
**Inputs**:
* **1**: `cond` tensor with selection mask of type `boolean`. The tensor can be 0D.
* **1**: `cond` - tensor of type *T_COND* and arbitrary shape with selection mask. **Required**.
* **2**: `then` the tensor with elements to take where the corresponding element in `cond` is true. Arbitrary type that should match type of `else` input tensor.
* **2**: `then` - tensor of type *T* and arbitrary shape with elements to take where the corresponding element in `cond` is `true`. **Required**.
* **3**: `else` the tensor with elements to take where the corresponding element in `cond` is false. Arbitrary type that should match type of `then` input tensor.
* **3**: `else` - tensor of type *T* and arbitrary shape with elements to take where the corresponding element in `cond` is `false`. **Required**.
**Outputs**:
* **1**: blended output tensor that is tailored from values of inputs tensors `then` and `else` based on `cond` and broadcasting rules. It has the same type of elements as `then` and `else`.
**Types**
* *T_COND*: `boolean` type.
* *T*: any supported numeric type.
**Example**

View File

@ -66,7 +66,7 @@ This operation is compatible with [MXNet DeformablePSROIPooling](https://mxnet.a
* *trans_std*
* **Description**: *trans_std* is the value that all third input values (offests) are multiplied with to modulate the magnitude of the offsets.
* **Range of values**: floating point number
* **Range of values**: floating-point number
* **Type**: `float`
* **Default value**: 1
* **Required**: *no*
@ -93,7 +93,7 @@ Batch indices must be in the range of `[0, N_in-1]`.
**Types**:
* *T*: Any floating point type.
* *T*: Any floating-point type.
**Example**

View File

@ -69,14 +69,14 @@ At each feature map cell, *DetectionOutput* predicts the offsets relative to the
* *nms_threshold*
* **Description**: threshold to be used in the NMS stage
* **Range of values**: floating point values
* **Range of values**: floating-point values
* **Type**: float
* **Required**: *yes*
* *confidence_threshold*
* **Description**: only consider detections whose confidences are larger than a threshold. If not provided, consider all boxes.
* **Range of values**: floating point values
* **Range of values**: floating-point values
* **Type**: float
* **Default value**: 0
* **Required**: *no*
@ -145,7 +145,7 @@ At each feature map cell, *DetectionOutput* predicts the offsets relative to the
**Types**
* *T*: any supported floating point type.
* *T*: any supported floating-point type.
**Example**

View File

@ -58,7 +58,7 @@ tensor elements.
* **Description**: The *score_threshold* attribute specifies a threshold to consider only detections whose score are
larger than the threshold.
* **Range of values**: non-negative floating point number
* **Range of values**: non-negative floating-point number
* **Type**: float
* **Default value**: None
* **Required**: *yes*
@ -66,7 +66,7 @@ tensor elements.
* *nms_threshold*
* **Description**: The *nms_threshold* attribute specifies a threshold to be used in the NMS stage.
* **Range of values**: non-negative floating point number
* **Range of values**: non-negative floating-point number
* **Type**: float
* **Default value**: None
* **Required**: *yes*
@ -109,7 +109,7 @@ tensor elements.
* *max_delta_log_wh*
* **Description**: The *max_delta_log_wh* attribute specifies maximal delta of logarithms for width and height.
* **Range of values**: floating point number
* **Range of values**: floating-point number
* **Type**: float
* **Default value**: None
* **Required**: *yes*
@ -117,7 +117,7 @@ tensor elements.
* *deltas_weights*
* **Description**: The *deltas_weights* attribute specifies weights for bounding boxes sizes deltas.
* **Range of values**: a list of non-negative floating point numbers
* **Range of values**: a list of non-negative floating-point numbers
* **Type**: float[]
* **Default value**: None
* **Required**: *yes*
@ -146,7 +146,7 @@ should be the same. **Required.**
**Types**
* *T*: any supported floating point type.
* *T*: any supported floating-point type.
* *T_IND*: `int64` or `int32`.

View File

@ -23,7 +23,7 @@ is less than *post_nms_count* returns output tensors filled with zeroes.
* *min_size*
* **Description**: The *min_size* attribute specifies minimum box width and height.
* **Range of values**: non-negative floating point number
* **Range of values**: non-negative floating-point number
* **Type**: float
* **Default value**: None
* **Required**: *yes*
@ -31,7 +31,7 @@ is less than *post_nms_count* returns output tensors filled with zeroes.
* *nms_threshold*
* **Description**: The *nms_threshold* attribute specifies threshold to be used in the NMS stage.
* **Range of values**: non-negative floating point number
* **Range of values**: non-negative floating-point number
* **Type**: float
* **Default value**: None
* **Required**: *yes*
@ -73,7 +73,7 @@ Height and width for third and fourth inputs should be equal. **Required.**
**Types**
* *T*: any supported floating point type.
* *T*: any supported floating-point type.
**Example**

View File

@ -81,7 +81,7 @@ rest output tensor elements.
**Types**
* *T*: any supported floating point type.
* *T*: any supported floating-point type.
**Example**

View File

@ -86,7 +86,7 @@ must be the same as for 1 input: `[number_of_ROIs, 4]`.
**Types**
* *T*: any supported floating point type.
* *T*: any supported floating-point type.
**Example**

View File

@ -72,7 +72,7 @@ Batch indices must be in the range of `[0, N-1]`.
**Types**
* *T*: any supported floating point type.
* *T*: any supported floating-point type.
**Example**

View File

@ -6,77 +6,14 @@
**Short description**: *PriorBoxClustered* operation generates prior boxes of specified sizes normalized to the input image size.
**Attributes**
* *width (height)*
* **Description**: *width (height)* specifies desired boxes widths (heights) in pixels.
* **Range of values**: floating point positive numbers
* **Type**: float[]
* **Default value**: 1.0
* **Required**: *no*
* *clip*
* **Description**: *clip* is a flag that denotes if each value in the output tensor should be clipped within [0,1].
* **Range of values**:
* false or 0 - clipping is not performed
* true or 1 - each value in the output tensor is within [0,1]
* **Type**: boolean
* **Default value**: true
* **Required**: *no*
* *step (step_w, step_h)*
* **Description**: *step (step_w, step_h)* is a distance between box centers. For example, *step* equal 85 means that the distance between neighborhood prior boxes centers is 85. If both *step_h* and *step_w* are 0 then they are updated with value of *step*. If after that they are still 0 then they are calculated as input image width(height) divided with first input width(height).
* **Range of values**: floating point positive number
* **Type**: float
* **Default value**: 0.0
* **Required**: *no*
* *offset*
* **Description**: *offset* is a shift of box respectively to top left corner. For example, *offset* equal 85 means that the shift of neighborhood prior boxes centers is 85.
* **Range of values**: floating point positive number
* **Type**: float
* **Required**: *yes*
* *variance*
* **Description**: *variance* denotes a variance of adjusting bounding boxes.
* **Range of values**: floating point positive numbers
* **Type**: float[]
* **Default value**: []
* **Required**: *no*
* *img_h (img_w)*
* **Description**: *img_h (img_w)* specifies height (width) of input image. These attributes are taken from the second input `image_size` height(width) unless provided explicitly as the value for this attributes.
* **Range of values**: floating point positive number
* **Type**: float
* **Default value**: 0
* **Required**: *no*
**Inputs**:
* **1**: `output_size` - 1D tensor with two integer elements `[height, width]`. Specifies the spatial size of generated grid with boxes. **Required.**
* **2**: `image_size` - 1D tensor with two integer elements `[image_height, image_width]` that specifies shape of the image for which boxes are generated. **Optional.**
**Outputs**:
* **1**: 2D tensor of shape `[2, 4 * height * width * priors_per_point]` with box coordinates. The `priors_per_point` is the number of boxes generated per each grid element. The number depends on layer attribute values.
**Detailed description**
*PriorBoxClustered* computes coordinates of prior boxes by following:
1. Calculates the *center_x* and *center_y* of prior box:
\f[
W \equiv Width \quad Of \quad Image
\f]
\f[
H \equiv Height \quad Of \quad Image
\f]
Let
\f[
W \equiv image\_width, \quad H \equiv image\_height.
\f]
Then calculations of *PriorBoxClustered* can be written as
\f[
center_x=(w+offset)*step
\f]
@ -89,7 +26,7 @@
\f[
h \subset \left( 0, H \right )
\f]
2. For each \f$s \subset \left( 0, W \right )\f$ calculates the prior boxes coordinates:
For each \f$s = \overline{0, W - 1}\f$ calculates the prior boxes coordinates:
\f[
xmin = \frac{center_x - \frac{width_s}{2}}{W}
\f]
@ -105,6 +42,64 @@
If *clip* is defined, the coordinates of prior boxes are recalculated with the formula:
\f$coordinate = \min(\max(coordinate,0), 1)\f$
**Attributes**
* *width (height)*
* **Description**: *width (height)* specifies desired boxes widths (heights) in pixels.
* **Range of values**: floating-point positive numbers
* **Type**: `float[]`
* **Default value**: 1.0
* **Required**: *no*
* *clip*
* **Description**: *clip* is a flag that denotes if each value in the output tensor should be clipped within `[0,1]`.
* **Range of values**:
* false or 0 - clipping is not performed
* true or 1 - each value in the output tensor is within `[0,1]`
* **Type**: `boolean`
* **Default value**: true
* **Required**: *no*
* *step (step_w, step_h)*
* **Description**: *step (step_w, step_h)* is a distance between box centers. For example, *step* equal 85 means that the distance between neighborhood prior boxes centers is 85. If both *step_h* and *step_w* are 0 then they are updated with value of *step*. If after that they are still 0 then they are calculated as input image width(height) divided with first input width(height).
* **Range of values**: floating-point positive number
* **Type**: `float`
* **Default value**: 0.0
* **Required**: *no*
* *offset*
* **Description**: *offset* is a shift of box respectively to top left corner. For example, *offset* equal 85 means that the shift of neighborhood prior boxes centers is 85.
* **Range of values**: floating-point positive number
* **Type**: `float`
* **Required**: *yes*
* *variance*
* **Description**: *variance* denotes a variance of adjusting bounding boxes. The attribute could be 0, 1 or 4 elements.
* **Range of values**: floating-point positive numbers
* **Type**: `float[]`
* **Default value**: []
* **Required**: *no*
**Inputs**:
* **1**: `output_size` - 1D tensor of type *T_INT* with two elements `[height, width]`. Specifies the spatial size of generated grid with boxes. Required.
* **2**: `image_size` - 1D tensor of type *T_INT* with two elements `[image_height, image_width]` that specifies shape of the image for which boxes are generated. Optional.
**Outputs**:
* **1**: 2D tensor of shape `[2, 4 * height * width * priors_per_point]` and type *T_OUT* with box coordinates. The `priors_per_point` is the number of boxes generated per each grid element. The number depends on layer attribute values.
**Types**
* *T_INT*: any supported integer type.
* *T_OUT*: supported floating-point type.
**Example**
```xml

View File

@ -46,7 +46,7 @@
* *min_size (max_size)*
* **Description**: *min_size (max_size)* is the minimum (maximum) box size (in pixels).
* **Range of values**: positive floating point numbers
* **Range of values**: positive floating-point numbers
* **Type**: `float[]`
* **Default value**: []
* **Required**: *no*
@ -82,7 +82,7 @@
* *step*
* **Description**: *step* is a distance between box centers.
* **Range of values**: floating point non-negative number
* **Range of values**: floating-point non-negative number
* **Type**: `float`
* **Default value**: 0
* **Required**: *no*
@ -90,14 +90,14 @@
* *offset*
* **Description**: *offset* is a shift of box respectively to top left corner.
* **Range of values**: floating point non-negative number
* **Range of values**: floating-point non-negative number
* **Type**: `float`
* **Required**: *yes*
* *variance*
* **Description**: *variance* denotes a variance of adjusting bounding boxes. The attribute could contain 0, 1 or 4 elements.
* **Range of values**: floating point positive numbers
* **Range of values**: floating-point positive numbers
* **Type**: `float[]`
* **Default value**: []
* **Required**: *no*
@ -149,7 +149,7 @@
**Types**
* *T_INT*: any supported integer type.
* *T_OUT*: supported floating point type.
* *T_OUT*: supported floating-point type.
**Example**

View File

@ -141,7 +141,7 @@
**Types**
* *T*: floating point type.
* *T*: floating-point type.
**Example**

View File

@ -152,7 +152,7 @@ the second optional tensor of shape `[batch_size * post_nms_topn]` with probabil
**Types**
* *T*: floating point type.
* *T*: floating-point type.
**Example**

View File

@ -69,7 +69,7 @@ The box height and width are calculated the following way: `roi_width = max(spat
**Types**
* *T*: any supported floating point type.
* *T*: any supported floating-point type.
* *IND_T*: any supported integer type.

View File

@ -64,7 +64,7 @@ Batch indices must be in the range of `[0, N-1]`.
**Types**
* *T*: any supported floating point type.
* *T*: any supported floating-point type.
**Example**

View File

@ -13,7 +13,7 @@
* *anchors*
* **Description**: *anchors* codes a flattened list of pairs `[width, height]` that codes prior box sizes. This attribute is not used in output computation, but it is required for post-processing to restore real box coordinates.
* **Range of values**: list of any length of positive floating point number
* **Range of values**: list of any length of positive floating-point number
* **Type**: `float[]`
* **Default value**: None
* **Required**: *no*
@ -83,7 +83,7 @@
`output.shape = [data.shape[0], ..., data.shape[axis-1], flat_dim, data.shape[end_axis + 1], ...]`
**Types**
* *T*: any supported floating point type.
* *T*: any supported floating-point type.
**Example**

View File

@ -51,7 +51,7 @@ the i-th element is calculated by the following formula:
val[i+1]=val[i]+step.
\f]
The calculations are done after casting all values to `accumulate_type(output_type)`. `accumulate_type` is a type that have better or equal accuracy for accumulation than `output_type` on current hardware, e.g. `fp64` for `fp16`. The number of elements is calculated in the floating point type according to the following formula:
The calculations are done after casting all values to `accumulate_type(output_type)`. `accumulate_type` is a type that have better or equal accuracy for accumulation than `output_type` on current hardware, e.g. `fp64` for `fp16`. The number of elements is calculated in the floating-point type according to the following formula:
\f[
max(ceil((end start) / step), 0)
@ -103,7 +103,7 @@ This is aligned with PyTorch's operation `torch.arange`, to align with tensorflo
</layer>
```
*Example 3: floating point*
*Example 3: floating-point*
```xml
<layer ... type="Range">

View File

@ -60,7 +60,7 @@ This is a scalar that specifies padding for each spatial dimension.
**Inputs**
* **1**: `data` - Input tensor with data for interpolation. Type of elements is any supported floating point type. **Required.**
* **1**: `data` - Input tensor with data for interpolation. Type of elements is any supported floating-point type. **Required.**
* **2**: `target_spatial_shape` - 1D tensor describing output shape for spatial axes. Number of elements matches the number of indices in *axes* attribute, the order matches as well. **Required.**

View File

@ -80,8 +80,8 @@
* *cube_coeff*
* **Description**: *cube_coeff* specifies the parameter *a* for cubic interpolation (see, e.g. [article](https://ieeexplore.ieee.org/document/1163711/)). *cube_coeff* is used only when `mode == cubic`.
* **Range of values**: floating point number
* **Type**: any of supported floating point type
* **Range of values**: floating-point number
* **Type**: any of supported floating-point type
* **Default value**: `-0.75`
* **Required**: *no*
@ -102,7 +102,7 @@
**Types**
* *T*: any supported numeric type.
* *T_SIZE*: any supported integer type.
* *T_SCALES*: any supported floating point type.
* *T_SCALES*: any supported floating-point type.
* *T_AXES*: any supported integer type.

View File

@ -67,7 +67,7 @@ Two attributes, `transpose_a` and `transpose_b` specify embedded transposition f
**Types**:
* *T*: any supported floating point or integer type.
* *T*: any supported floating-point or integer type.
**Example**

View File

@ -8,7 +8,7 @@
**Detailed description**:
*GRN* computes the L2 norm by channels for input tensor with shape `[N, C, ...]`. *GRN* does the following with the input tensor:
*GRN* computes the L2 norm across channels for input tensor with shape `[N, C, ...]`. *GRN* does the following with the input tensor:
output[i0, i1, ..., iN] = x[i0, i1, ..., iN] / sqrt(sum[j = 0..C-1](x[i0, j, ..., iN]**2) + bias)
@ -16,23 +16,27 @@
* *bias*
* **Description**: *bias* is added to the variance.
* **Range of values**: a non-negative floating point value
* **Description**: *bias* is added to the sum of squares.
* **Range of values**: a positive floating-point number
* **Type**: `float`
* **Required**: *yes*
**Inputs**
* **1**: Input tensor with element of any floating point type and `2 <= rank <=4`. **Required.**
* **1**: `data` - A tensor of type *T* and `2 <= rank <= 4`. **Required.**
**Outputs**
* **1**: Output tensor of the same type and shape as the input tensor.
* **1**: The result of *GRN* function applied to `data` input tensor. Normalized tensor of the same type and shape as the data input.
**Types**
* *T*: arbitrary supported floating-point type.
**Example**
```xml
<layer id="5" name="normalization" type="GRN">
<layer ... type="GRN">
<data bias="1e-4"/>
<input>
<port id="0">

View File

@ -68,7 +68,7 @@ output = data / (bias + (alpha / size ** len(axes)) * sqr_sum) ** beta
* **1**: Output tensor of type *T* and the same shape as the `data` input tensor.
**Types**
* *T*: any supported floating point type.
* *T*: any supported floating-point type.
* *T_IND*: any supported integer type.
**Example**

View File

@ -4,57 +4,89 @@
**Category**: *Normalization*
**Short description**: [Reference](http://caffe.berkeleyvision.org/tutorial/layers/mvn.html)
**Short description**: Calculates mean-variance normalization of the input tensor. Supports two normalization techniques: [Instance/Contrast Normalization](https://arxiv.org/abs/1607.08022) and [Layer Normalization](https://arxiv.org/abs/1607.06450).
**Detailed description**
*MVN* subtracts mean value from the input blob:
Based on `across_channels` attribute mean value is calculated using one of formulas below:
1. if `true` mean value is calculated using Layer Normalization:
\f[
o_{i} = i_{i} - \frac{\sum{i_{k}}}{C * H * W}
\mu_{n} = \frac{\sum_{c}^{C}\sum_{h}^{H}\sum_{w}^{W} i_{nchw}}{C * H * W}
\f]
If *normalize_variance* is set to 1, the output blob is divided by variance:
2. if `false` mean value is calculated using Instance/Contrast Normalization:
\f[
o_{i}=\frac{o_{i}}{\sum \sqrt {o_{k}^2}+\epsilon}
\mu_{nc} = \frac{\sum_{h}^{H}\sum_{w}^{W} i_{nchw}}{H * W}
\f]
where \f$i_{nchw}\f$ is an input tensor parametrized by \f$n\f$ batches, \f$c\f$ channels and \f$h,w\f$ spatial dimesnions.
If `reduction_axes` attribute is provided mean value is calculated based on formula:
\f[
\mu_{n} = ReduceMean(i_{k}, reduction_axes)
\f]
Afterwards *MVN* subtracts mean value from the input blob.
If *normalize_variance* is set to `true`, the output blob is divided by variance:
\f[
o_{i}=\frac{o_{i}}{\sqrt {\sum {\sigma_{k}^2}+\epsilon}}
\f]
where \f$\sigma_{k}^2\f$ is the variance calculated based on mean value, \f$\epsilon\f$ is a value added to the variance for numerical stability and corresponds to `epsilon` attribute.
**Attributes**
* *across_channels*
* **Description**: *across_channels* is a flag that specifies whether mean values are shared across channels. For example, *across_channels* equal to `false` means that mean values are not shared across channels.
* **Description**: *across_channels* is a flag that specifies whether mean values are shared across channels. If `true` mean values and variance are calculated for each sample across all channels and spatial dimensions (Layer Normalization), otherwise calculation is done for each sample and for each channel across spatial dimensions (Instance/Contrast Normalization).
* **Range of values**:
* `false` - do not share mean values across channels
* `true` - share mean values across channels
* **Type**: `boolean`
* **Default value**: `false`
* **Required**: *no*
* **Required**: *yes*
* *reduction_axes*
* **Description**: 1D tensor of unique elements and type *T_IND* which specifies indices of dimensions in `data` that define normalization slices. Negative value means counting dimensions from the back.
* **Range of values**: allowed range of axes is `[-r; r-1]` where `r = rank(data)`, the order cannot be sorted
* **Type**: `int`
* **Required**: *yes*
* *normalize_variance*
* **Description**: *normalize_variance* is a flag that specifies whether to perform variance normalization.
* **Range of values**:
* `false` -- do not normalize variance
* `true` -- normalize variance
* `false` - do not normalize variance
* `true` - normalize variance
* **Type**: `boolean`
* **Default value**: `false`
* **Required**: *no*
* **Required**: *yes*
* *eps*
* **Description**: *eps* is the number to be added to the variance to avoid division by zero when normalizing the value. For example, *epsilon* equal to 0.001 means that 0.001 is added to the variance.
* **Range of values**: a positive floating-point number
* **Type**: `float`
* **Type**: `double`
* **Required**: *yes*
* **Note** Important: it is necessary to use only one of `across_channels` or `reduction_axes` attributes, they cannot be defined together.
**Inputs**
* **1**: 4D or 5D input tensor of any floating point type. **Required.**
* **1**: `data` - input tensor of type *T* and arbitrary shape. **Required.**
**Outputs**
* **1**: normalized tensor of the same type and shape as input tensor.
* **1**: normalized tensor of type *T* and shape as input tensor.
**Example**
**Types**
* *T*: any floating point type.
* *T_IND*: `int64` or `int32`.
**Examples**
*Example: with `across_channels` attribute*
```xml
<layer ... type="MVN">
@ -77,3 +109,27 @@ o_{i}=\frac{o_{i}}{\sum \sqrt {o_{k}^2}+\epsilon}
</output>
</layer>
```
*Example: with `reduction_axes` attribute*
```xml
<layer ... type="MVN">
<data reduction_axes="2,3" eps="1e-9" normalize_variance="true"/>
<input>
<port id="0">
<dim>6</dim>
<dim>12</dim>
<dim>10</dim>
<dim>24</dim>
</port>
</input>
<output>
<port id="2">
<dim>6</dim>
<dim>12</dim>
<dim>10</dim>
<dim>24</dim>
</port>
</output>
</layer>
```

View File

@ -30,8 +30,8 @@ o_{i}=\frac{o_{i}}{\sqrt {\sum {o_{k}^2}}+\epsilon}
* **Description**: *normalize_variance* is a flag that specifies whether to perform variance normalization.
* **Range of values**:
* `false` -- Do not normalize variance
* `true` -- Normalize variance
* `false` - do not normalize variance
* `true` - normalize variance
* **Type**: `boolean`
* **Required**: *yes*
@ -46,14 +46,14 @@ o_{i}=\frac{o_{i}}{\sqrt {\sum {o_{k}^2}}+\epsilon}
* **Description**: Choose where to add epsilon.
* **Range of values**:
* `inside_sqrt` -- Add epsilon inside sqrt
* `outside_sqrt` -- Add epsilon outside of sqrt
* `inside_sqrt` - add epsilon inside sqrt
* `outside_sqrt` - add epsilon outside of sqrt
* **Type**: `string`
* **Required**: *yes*
**Inputs**
* **1**: `data` - Input tensor to be normalized. Type *T*. **Required.**
* **1**: `data` - Input tensor to be normalized of type *T* and arbitrary shape. **Required.**
* **2**: `axes` - 1D tensor which specifies indices of dimensions in `data` that define normalization slices. Allowed range of axes is `[-r; r-1]` where `r = rank(data)`, the order can be not sorted. Negative value means counting dimensions from the back. Type *T_IND*. **Required.**
@ -64,7 +64,6 @@ o_{i}=\frac{o_{i}}{\sqrt {\sum {o_{k}^2}}+\epsilon}
**Types**
* *T*: any floating point type.
* *T_IND*: `int64` or `int32`.
**Example**

View File

@ -79,6 +79,7 @@ declared in `namespace opset8`.
* [HSigmoid](activation/HSigmoid_5.md)
* [HSwish](activation/HSwish_4.md)
* [IDFT](signals/IDFT_7.md)
* [If](condition/If_8.md)
* [Interpolate](image/Interpolate_4.md)
* [Less](comparison/Less_1.md)
* [LessEqual](comparison/LessEqual_1.md)

View File

@ -70,7 +70,7 @@
**Types**
* *T*: floating point or integer type.
* *T*: floating-point or integer type.
**Mathematical Formulation**
Output shape calculation based on `auto_pad` and `rounding_type`:

View File

@ -19,7 +19,7 @@ Decoding is done in two steps:
Sequences in the batch can have different length. The lengths of sequences are coded in the second input integer tensor `sequence_length`.
The main difference between [CTCGreedyDecoder](CTCGreedyDecoder_1.md) and CTCGreedyDecoderSeqLen is in the second input. CTCGreedyDecoder uses 2D input floating point tensor with sequence masks for each sequence in the batch while CTCGreedyDecoderSeqLen uses 1D integer tensor with sequence lengths.
The main difference between [CTCGreedyDecoder](CTCGreedyDecoder_1.md) and CTCGreedyDecoderSeqLen is in the second input. CTCGreedyDecoder uses 2D input floating-point tensor with sequence masks for each sequence in the batch while CTCGreedyDecoderSeqLen uses 1D integer tensor with sequence lengths.
**Attributes**
@ -63,7 +63,7 @@ The main difference between [CTCGreedyDecoder](CTCGreedyDecoder_1.md) and CTCGre
**Types**
* *T_F*: any supported floating point type.
* *T_F*: any supported floating-point type.
* *T_I*: `int32` or `int64`.

View File

@ -37,7 +37,7 @@ Sequences in the batch can have different length. The lengths of sequences are c
* **1**: Output tensor of type *T_F* and shape `[N, T, 1, 1]` which is filled with integer elements containing final sequence class indices. A final sequence can be shorter that the size `T` of the tensor, all elements that do not code sequence classes are filled with `-1`.
**Types**
* *T_F*: any supported floating point type.
* *T_F*: any supported floating-point type.
**Example**

View File

@ -96,7 +96,7 @@ Having log-probabilities for aligned paths, log of summed up probabilities for t
**Types**
* *T_F*: any supported floating point type.
* *T_F*: any supported floating-point type.
* *T1*, *T2*: `int32` or `int64`.

View File

@ -65,7 +65,7 @@
**Types**
* *T*: any supported floating point type.
* *T*: any supported floating-point type.
**Example**
```xml

View File

@ -81,7 +81,7 @@ A single cell in the sequence is implemented in the same way as in <a href="#GRU
**Types**
* *T1*: any supported floating point type.
* *T1*: any supported floating-point type.
* *T2*: any supported integer type.
**Example**

View File

@ -79,7 +79,7 @@ tanh - (e^{2x} - 1)/(e^{2x} + 1)
**Types**
* *T*: any supported floating point type.
* *T*: any supported floating-point type.
**Example**
```xml

View File

@ -77,7 +77,7 @@ A single cell in the sequence is implemented in the same way as in <a href="#LST
**Types**
* *T1*: any supported floating point type.
* *T1*: any supported floating-point type.
* *T2*: any supported integer type.
**Example**

View File

@ -57,7 +57,7 @@
**Types**
* *T*: any supported floating point type.
* *T*: any supported floating-point type.
**Example**
```xml

View File

@ -73,7 +73,7 @@ A single cell in the sequence is implemented in the same way as in <a href="#RNN
**Types**
* *T1*: any supported floating point type.
* *T1*: any supported floating-point type.
* *T2*: any supported integer type.
**Example**

View File

@ -35,7 +35,7 @@ output tensor elements.
**Types**
* *T*: any supported floating point type.
* *T*: any supported floating-point type.
**Example**

View File

@ -136,11 +136,11 @@ When there is no box selected, `selected_num` is filled with `0`. `selected_outp
**Types**
* *T*: floating point type.
* *T*: floating-point type.
* *T_MAX_BOXES*: integer type.
* *T_THRESHOLDS*: floating point type.
* *T_THRESHOLDS*: floating-point type.
* *T_IND*: `int64` or `int32`.

View File

@ -129,11 +129,11 @@ When there is no box selected, `selected_num` is filled with `0`. `selected_outp
**Types**
* *T*: floating point type.
* *T*: floating-point type.
* *T_MAX_BOXES*: integer type.
* *T_THRESHOLDS*: floating point type.
* *T_THRESHOLDS*: floating-point type.
* *T_IND*: `int64` or `int32`.

View File

@ -41,15 +41,15 @@ class must not exceed `max_output_boxes_per_class`.
**Inputs**:
* **1**: `boxes` - floating point tensor of shape `[num_batches, num_boxes, 4]` with box coordinates. **Required.**
* **1**: `boxes` - floating-point tensor of shape `[num_batches, num_boxes, 4]` with box coordinates. **Required.**
* **2**: `scores` - floating point tensor of shape `[num_batches, num_classes, num_boxes]` with box scores. **Required.**
* **2**: `scores` - floating-point tensor of shape `[num_batches, num_classes, num_boxes]` with box scores. **Required.**
* **3**: `max_output_boxes_per_class` - integer scalar tensor specifying maximum number of boxes to be selected per class. Optional with default value 0 meaning select no boxes.
* **4**: `iou_threshold` - floating point scalar tensor specifying intersection over union threshold. Optional with default value 0 meaning keep all boxes.
* **4**: `iou_threshold` - floating-point scalar tensor specifying intersection over union threshold. Optional with default value 0 meaning keep all boxes.
* **5**: `score_threshold` - floating point scalar tensor specifying minimum score to consider box for the processing. Optional with default value 0.
* **5**: `score_threshold` - floating-point scalar tensor specifying minimum score to consider box for the processing. Optional with default value 0.
**Outputs**:

View File

@ -66,11 +66,11 @@ The output tensor is filled with -1s for output tensor elements if the total num
**Types**
* *T*: floating point type.
* *T*: floating-point type.
* *T_MAX_BOXES*: integer type.
* *T_THRESHOLDS*: floating point type.
* *T_THRESHOLDS*: floating-point type.
* *T_IND*: `int64` or `int32`.

View File

@ -66,11 +66,11 @@ The output tensor is filled with -1s for output tensor elements if the total num
**Types**
* *T*: floating point type.
* *T*: floating-point type.
* *T_MAX_BOXES*: integer type.
* *T_THRESHOLDS*: floating point type.
* *T_THRESHOLDS*: floating-point type.
* *T_IND*: `int64` or `int32`.

View File

@ -78,11 +78,11 @@ Plugins which do not support dynamic output tensors produce `selected_indices` a
**Types**
* *T*: floating point type.
* *T*: floating-point type.
* *T_MAX_BOXES*: integer type.
* *T_THRESHOLDS*: floating point type.
* *T_THRESHOLDS*: floating-point type.
* *T_IND*: `int64` or `int32`.

View File

@ -0,0 +1,118 @@
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include <ie_core.hpp>
#include <ie_ngraph_utils.hpp>
#include <ngraph/ngraph.hpp>
#include <shared_test_classes/base/layer_test_utils.hpp>
#include <tuple>
#include "base_reference_test.hpp"
using namespace ngraph;
using namespace InferenceEngine;
namespace {
struct GrnParams {
template <class IT>
GrnParams(const float bias, const ngraph::PartialShape& shape, const ngraph::element::Type& iType, const std::vector<IT>& iValues,
const std::vector<IT>& oValues)
: bias(bias), pshape(shape), inType(iType), outType(iType), inputData(CreateBlob(iType, iValues)), refData(CreateBlob(iType, oValues)) {}
float bias;
ngraph::PartialShape pshape;
ngraph::element::Type inType;
ngraph::element::Type outType;
InferenceEngine::Blob::Ptr inputData;
InferenceEngine::Blob::Ptr refData;
};
class ReferenceGrnLayerTest : public testing::TestWithParam<GrnParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params.bias, params.pshape, params.inType);
inputData = {params.inputData};
refOutData = {params.refData};
}
static std::string getTestCaseName(const testing::TestParamInfo<GrnParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "bias=" << param.bias << "_";
result << "shape=" << param.pshape << "_";
result << "iType=" << param.inType << "_";
result << "oType=" << param.outType;
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(float bias, const PartialShape& input_shape, const element::Type& input_type) {
const auto in = std::make_shared<op::Parameter>(input_type, input_shape);
const auto grn = std::make_shared<op::v0::GRN>(in, bias);
return std::make_shared<Function>(NodeVector {grn}, ParameterVector {in});
}
};
TEST_P(ReferenceGrnLayerTest, CompareWithHardcodedRefs) {
Exec();
}
template <element::Type_t IN_ET>
std::vector<GrnParams> generateGrnParams(const ngraph::element::Type& type) {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<GrnParams> grnParams {
// bias 1e-6 // 2D // 3D // 4D
GrnParams(1e-6, ngraph::PartialShape {3, 4}, type, std::vector<T> {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12},
std::vector<T> {0.182574, 0.365148, 0.547723, 0.730297, 0.379049, 0.454859, 0.530669, 0.606478, 0.426162, 0.473514, 0.520865, 0.568217}),
GrnParams(1e-6, ngraph::PartialShape {2, 3, 4}, type,
std::vector<T> {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24},
std::vector<T> {0.0966737, 0.169031, 0.224231, 0.267261, 0.483368, 0.507093, 0.523205, 0.534522, 0.870063, 0.845154, 0.822179, 0.801784,
0.433574, 0.441836, 0.449215, 0.455842, 0.566982, 0.568075, 0.569005, 0.569803, 0.700389, 0.694314, 0.688796, 0.683763}),
GrnParams(1e-6, ngraph::PartialShape {1, 2, 3, 4}, type,
std::vector<T> {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24},
std::vector<T> {0.0766965, 0.141421, 0.196116, 0.242536, 0.282166, 0.316228, 0.345705, 0.371391, 0.393919, 0.413803, 0.431455, 0.447214,
0.997055, 0.989949, 0.980581, 0.970143, 0.959365, 0.948683, 0.938343, 0.928477, 0.919145, 0.910366, 0.902134, 0.894427}),
GrnParams(1e-6, ngraph::PartialShape {2, 2, 3, 4}, type,
std::vector<T> {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48},
std::vector<T> {0.0766965, 0.141421, 0.196116, 0.242536, 0.282166, 0.316228, 0.345705, 0.371391, 0.393919, 0.413803, 0.431455, 0.447214,
0.997055, 0.989949, 0.980581, 0.970143, 0.959365, 0.948683, 0.938343, 0.928477, 0.919145, 0.910366, 0.902134, 0.894427,
0.559857, 0.564684, 0.56921, 0.573462, 0.577465, 0.581238, 0.584802, 0.588172, 0.591364, 0.594391, 0.597266, 0.6,
0.828589, 0.825307, 0.822192, 0.819232, 0.816416, 0.813733, 0.811176, 0.808736, 0.806405, 0.804176, 0.802043, 0.8}),
// bias 100.25 // 2D // 3D // 4D
GrnParams(100.25, ngraph::PartialShape {3, 4}, type, std::vector<T> {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12},
std::vector<T> {0.0876216, 0.175243, 0.262865, 0.350486, 0.301923, 0.362308, 0.422693, 0.483077, 0.385076, 0.427863, 0.470649, 0.513435}),
GrnParams(100.25, ngraph::PartialShape {2, 3, 4}, type,
std::vector<T> {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24},
std::vector<T> {0.0694629, 0.129032, 0.179525, 0.222137, 0.347314, 0.387097, 0.418891, 0.444273, 0.625166, 0.645161, 0.658258, 0.66641,
0.41125, 0.421303, 0.430287, 0.438356, 0.537789, 0.541675, 0.54503, 0.547945, 0.664327, 0.662047, 0.659774, 0.657534}),
GrnParams(100.25, ngraph::PartialShape {1, 2, 3, 4}, type,
std::vector<T> {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24},
std::vector<T> {0.0608299, 0.115422, 0.164091, 0.207321, 0.245662, 0.279675, 0.309889, 0.336786, 0.360795, 0.38229, 0.401596, 0.418994,
0.790789, 0.807954, 0.820457, 0.829283, 0.835252, 0.839026, 0.841128, 0.841965, 0.841854, 0.841037, 0.839701, 0.837989f}),
GrnParams(100.25, ngraph::PartialShape {2, 2, 3, 4}, type,
std::vector<T> {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48},
std::vector<T> {0.0608299, 0.115422, 0.164091, 0.207321, 0.245662, 0.279675, 0.309889, 0.336786, 0.360795, 0.38229, 0.401596, 0.418994,
0.790789, 0.807954, 0.820457, 0.829283, 0.835252, 0.839026, 0.841128, 0.841965, 0.841854, 0.841037, 0.839701, 0.837989,
0.546293, 0.551788, 0.556938, 0.561772, 0.566319, 0.570601, 0.574641, 0.578458, 0.582069, 0.585489, 0.588734, 0.591816,
0.808514, 0.80646, 0.804466, 0.802532, 0.800658, 0.798842, 0.797083, 0.795379, 0.79373, 0.792133, 0.790586, 0.789088})};
return grnParams;
}
std::vector<GrnParams> generateGrnCombinedParams() {
const std::vector<std::vector<GrnParams>> grnTypeParams {generateGrnParams<element::Type_t::bf16>(ngraph::element::bf16),
generateGrnParams<element::Type_t::f16>(ngraph::element::f16),
generateGrnParams<element::Type_t::f32>(ngraph::element::f32)};
std::vector<GrnParams> combinedParams;
std::for_each(grnTypeParams.begin(), grnTypeParams.end(), [&](std::vector<GrnParams> params) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
});
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_GRN_With_Hardcoded_Refs, ReferenceGrnLayerTest, ::testing::ValuesIn(generateGrnCombinedParams()),
ReferenceGrnLayerTest::getTestCaseName);
} // namespace

View File

@ -0,0 +1,139 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include <ie_core.hpp>
#include <ie_ngraph_utils.hpp>
#include <ngraph/ngraph.hpp>
#include <shared_test_classes/base/layer_test_utils.hpp>
#include <tuple>
#include "base_reference_test.hpp"
using namespace ngraph;
using namespace InferenceEngine;
struct SelectParams {
template <class IT, class OT>
SelectParams(const element::Type& data_type, const op::AutoBroadcastSpec& broadcast, const PartialShape& select_input_pshape,
const std::vector<char>& select_input, const PartialShape& if_input_pshape, const std::vector<IT>& if_input,
const PartialShape& else_input_pshape, const std::vector<IT>& else_input, const std::vector<OT>& expected_output)
: data_type(data_type),
broadcast(broadcast),
select_input_pshape(select_input_pshape),
select_input(CreateBlob(element::boolean, select_input)),
if_input_pshape(if_input_pshape),
if_input(CreateBlob(data_type, if_input)),
else_input_pshape(else_input_pshape),
else_input(CreateBlob(data_type, else_input)),
expected_output(CreateBlob(data_type, expected_output)) {}
element::Type data_type;
op::AutoBroadcastSpec broadcast;
PartialShape select_input_pshape;
InferenceEngine::Blob::Ptr select_input;
PartialShape if_input_pshape;
InferenceEngine::Blob::Ptr if_input;
PartialShape else_input_pshape;
InferenceEngine::Blob::Ptr else_input;
InferenceEngine::Blob::Ptr expected_output;
};
class ReferenceSelectLayerTest : public testing::TestWithParam<SelectParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params.data_type, params.broadcast, params.select_input_pshape, params.if_input_pshape, params.else_input_pshape);
inputData = {params.select_input, params.if_input, params.else_input};
refOutData = {params.expected_output};
}
static std::string getTestCaseName(const testing::TestParamInfo<SelectParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "data_type=" << param.data_type << "_";
result << "broadcast=" << param.broadcast.m_type << "_";
result << "select_shape=" << param.select_input_pshape << "_";
result << "if_shape=" << param.if_input_pshape << "_";
result << "else_shape=" << param.else_input_pshape;
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(const element::Type& data_type, const op::AutoBroadcastSpec& broadcast,
const PartialShape& select_pshape, const PartialShape& if_pshape, const PartialShape& else_pshape) {
auto A = std::make_shared<op::Parameter>(element::boolean, select_pshape);
auto B = std::make_shared<op::Parameter>(data_type, if_pshape);
auto C = std::make_shared<op::Parameter>(data_type, else_pshape);
return std::make_shared<Function>(std::make_shared<op::v1::Select>(A, B, C, broadcast), ParameterVector {A, B, C});
}
};
TEST_P(ReferenceSelectLayerTest, CompareWithHardcodedRefs) {
Exec();
}
INSTANTIATE_TEST_SUITE_P(smoke_Select_With_Hardcoded_Refs, ReferenceSelectLayerTest,
::testing::Values(
// fp32, no brodcasting
SelectParams(element::f32, // if/else/output data type
op::AutoBroadcastType::NONE, // broadcasting type
PartialShape {2, 2, 2}, // select shape
std::vector<char> {0, 1, 1, 0, 0, 1, 0, 1}, // select data
PartialShape {2, 2, 2}, // if shape
std::vector<float> {1, 2, 3, 4, 5, 6, 7, 8}, // if data
PartialShape {2, 2, 2}, // else shape
std::vector<float> {11, 12, 13, 14, 15, 16, 17, 18}, // else data
std::vector<float> {11, 2, 3, 14, 15, 6, 17, 8}), // expected output data
// i32, no brodcasting
SelectParams(element::i32, // if/else/output data type
op::AutoBroadcastType::NONE, // broadcasting type
PartialShape {2, 2, 2}, // select shape
std::vector<char> {0, 1, 1, 0, 0, 1, 0, 1}, // select data
PartialShape {2, 2, 2}, // if shape
std::vector<float> {1, 2, 3, 4, 5, 6, 7, 8}, // if data
PartialShape {2, 2, 2}, // else shape
std::vector<float> {11, 12, 13, 14, 15, 16, 17, 18}, // else data
std::vector<float> {11, 2, 3, 14, 15, 6, 17, 8}), // expected output data
// fp32, numpy brodcasting
SelectParams(element::f32, // if/else/output data type
op::AutoBroadcastType::NUMPY, // broadcasting type
PartialShape {4}, // select shape
std::vector<char> {0, 1, 1, 0}, // select data
PartialShape {4}, // if shape
std::vector<float> {1, 2, 3, 4}, // if data
PartialShape {2, 4}, // else shape
std::vector<float> {11, 12, 13, 14, 15, 16, 17, 18}, // else data
std::vector<float> {11, 2, 3, 14, 15, 2, 3, 18}), // expected output data
// i32, numpy brodcasting
SelectParams(element::i32, // if/else/output data type
op::AutoBroadcastType::NUMPY, // broadcasting type
PartialShape {4}, // select shape
std::vector<char> {0, 1, 1, 0}, // select data
PartialShape {4}, // if shape
std::vector<float> {1, 2, 3, 4}, // if data
PartialShape {2, 4}, // else shape
std::vector<float> {11, 12, 13, 14, 15, 16, 17, 18}, // else data
std::vector<float> {11, 2, 3, 14, 15, 2, 3, 18}), // expected output data
// fp32, pdpd brodcasting
SelectParams(element::f32, // if/else/output data type
{op::AutoBroadcastType::PDPD, -1}, // broadcasting type
PartialShape {2, 4}, // select shape
std::vector<char> {0, 0, 0, 0, 0, 1, 1, 1}, // select data
PartialShape {2, 4}, // if shape
std::vector<float> {1, 2, 3, 4, 5, 6, 7, 8}, // if data
PartialShape {4}, // else shape
std::vector<float> {11, 12, 13, 14}, // else data
std::vector<float> {11, 12, 13, 14, 11, 6, 7, 8}), // expected output data
// i32, pdpd brodcasting
SelectParams(element::i32, // if/else/output data type
{op::AutoBroadcastType::PDPD, -1}, // broadcasting type
PartialShape {2, 4}, // select shape
std::vector<char> {0, 0, 0, 0, 0, 1, 1, 1}, // select data
PartialShape {2, 4}, // if shape
std::vector<float> {1, 2, 3, 4, 5, 6, 7, 8}, // if data
PartialShape {4}, // else shape
std::vector<float> {11, 12, 13, 14}, // else data
std::vector<float> {11, 12, 13, 14, 11, 6, 7, 8})), // expected output data
ReferenceSelectLayerTest::getTestCaseName);

View File

@ -0,0 +1,80 @@
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include <ie_core.hpp>
#include <ie_ngraph_utils.hpp>
#include <ngraph/ngraph.hpp>
#include <shared_test_classes/base/layer_test_utils.hpp>
#include <tuple>
#include "base_reference_test.hpp"
using namespace ngraph;
using namespace InferenceEngine;
struct SignParams {
template <class IT, class OT>
SignParams(const ngraph::PartialShape& shape, const ngraph::element::Type& iType, const ngraph::element::Type& oType, const std::vector<IT>& iValues,
const std::vector<OT>& oValues)
: pshape(shape), inType(iType), outType(oType), inputData(CreateBlob(iType, iValues)), refData(CreateBlob(oType, oValues)) {}
ngraph::PartialShape pshape;
ngraph::element::Type inType;
ngraph::element::Type outType;
InferenceEngine::Blob::Ptr inputData;
InferenceEngine::Blob::Ptr refData;
};
class ReferenceSignLayerTest : public testing::TestWithParam<SignParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params.pshape, params.inType);
inputData = {params.inputData};
refOutData = {params.refData};
}
static std::string getTestCaseName(const testing::TestParamInfo<SignParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "shape=" << param.pshape << "_";
result << "iType=" << param.inType << "_";
result << "oType=" << param.outType;
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(const PartialShape& input_shape, const element::Type& input_type) {
const auto in = std::make_shared<op::Parameter>(input_type, input_shape);
const auto sign = std::make_shared<op::Sign>(in);
return std::make_shared<Function>(NodeVector {sign}, ParameterVector {in});
}
};
TEST_P(ReferenceSignLayerTest, CompareWithHardcodedRefs) {
Exec();
}
INSTANTIATE_TEST_SUITE_P(
smoke_Sign_With_Hardcoded_Refs, ReferenceSignLayerTest,
::testing::Values(
SignParams(ngraph::PartialShape {6}, ngraph::element::f32, ngraph::element::f32,
std::vector<float> {1, -2, 0, -4.8f, 4.8f, -0.0f},
std::vector<float> {1, -1, 0, -1, 1, 0}),
SignParams(ngraph::PartialShape {6}, ngraph::element::f16, ngraph::element::f16,
std::vector<float16> {1, -2, 0, -4.8f, 4.8f, -0.0f},
std::vector<float16> {1, -1, 0, -1, 1, 0}),
SignParams(ngraph::PartialShape {6}, ngraph::element::u64, ngraph::element::u64,
std::vector<uint64_t> {1, 2, 0, 4, 4, 0},
std::vector<uint64_t> {1, 1, 0, 1, 1, 0}),
SignParams(ngraph::PartialShape {6}, ngraph::element::u32, ngraph::element::u32,
std::vector<uint32_t> {1, 2, 0, 4, 4, 0},
std::vector<uint32_t> {1, 1, 0, 1, 1, 0}),
SignParams(ngraph::PartialShape {6}, ngraph::element::i32, ngraph::element::i32,
std::vector<int32_t> {1, -2, 0, -4, 4, -0},
std::vector<int32_t> {1, -1, 0, -1, 1, 0}),
SignParams(ngraph::PartialShape {6}, ngraph::element::i64, ngraph::element::i64,
std::vector<int64_t> {1, -2, 0, -4, 4, -0},
std::vector<int64_t> {1, -1, 0, -1, 1, 0})),
ReferenceSignLayerTest::getTestCaseName);

View File

@ -6,14 +6,14 @@ include_guard(GLOBAL)
set(VPU_SUPPORTED_FIRMWARES usb-ma2x8x pcie-ma2x8x)
set(VPU_SUPPORTED_FIRMWARES_HASH
"420b300d193f7fcfe7e3f9bbec6c247d65b784a500b5cd2effb7cb1ec6e1b209"
"bfe3caf270b168b9de18ef88f04bde3907d7d12a679f1fa7cc580423c35db637")
"d55a824838accec31733e4d4c45e8774bdd5690da8beefe41360f1983476e3d0"
"61797a77b38fc677be4cc63d730e8871bbf169686b88eabb7066b01f9d156129")
#
# Default packages
#
set(FIRMWARE_PACKAGE_VERSION 1688)
set(FIRMWARE_PACKAGE_VERSION 1714)
set(VPU_CLC_MA2X8X_VERSION "movi-cltools-20.09.2")
#

View File

@ -43,12 +43,14 @@ else()
endif()
if(ENABLE_CONDA_FOLDER)
set(PYTHON_COMPONENT conda_${PYTHON_VERSION})
if(WIN32)
set(PYTHON_BRIDGE_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$<CONFIG>/python_api/Conda/${PYTHON_VERSION}/openvino)
else()
set(PYTHON_BRIDGE_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/python_api/Conda/${PYTHON_VERSION}/openvino)
endif()
else()
set(PYTHON_COMPONENT ${PYTHON_VERSION})
if(WIN32)
set(PYTHON_BRIDGE_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$<CONFIG>/python_api/${PYTHON_VERSION}/openvino)
else()
@ -74,19 +76,19 @@ endif()
# install
ie_cpack_add_component(${PYTHON_VERSION})
ie_cpack_add_component(${PYTHON_COMPONENT})
install(FILES requirements.txt
DESTINATION ${PYTHON_BRIDGE_CPACK_PATH}/${PYTHON_VERSION}
COMPONENT ${PYTHON_VERSION})
COMPONENT ${PYTHON_COMPONENT})
install(FILES requirements.txt
DESTINATION ${PYTHON_BRIDGE_CPACK_PATH}
COMPONENT ${PYTHON_VERSION})
COMPONENT ${PYTHON_COMPONENT})
install(PROGRAMS src/openvino/__init__.py
DESTINATION ${PYTHON_BRIDGE_CPACK_PATH}/${PYTHON_VERSION}/openvino
COMPONENT ${PYTHON_VERSION})
COMPONENT ${PYTHON_COMPONENT})
# install Python samples
@ -96,4 +98,4 @@ install(DIRECTORY sample/
DESTINATION ${IE_CPACK_IE_DIR}/samples/python
COMPONENT python_samples)
ie_cpack(${PYTHON_VERSION} python_samples)
ie_cpack(${PYTHON_COMPONENT} python_samples)

View File

@ -70,12 +70,12 @@ add_custom_command(TARGET ${TARGET_NAME}
# install
install(TARGETS ${INSTALLED_TARGETS}
RUNTIME DESTINATION ${PYTHON_BRIDGE_CPACK_PATH}/${PYTHON_VERSION}/openvino/inference_engine COMPONENT ${PYTHON_VERSION}
LIBRARY DESTINATION ${PYTHON_BRIDGE_CPACK_PATH}/${PYTHON_VERSION}/openvino/inference_engine COMPONENT ${PYTHON_VERSION})
RUNTIME DESTINATION ${PYTHON_BRIDGE_CPACK_PATH}/${PYTHON_VERSION}/openvino/inference_engine COMPONENT ${PYTHON_COMPONENT}
LIBRARY DESTINATION ${PYTHON_BRIDGE_CPACK_PATH}/${PYTHON_VERSION}/openvino/inference_engine COMPONENT ${PYTHON_COMPONENT})
install(PROGRAMS __init__.py
DESTINATION ${PYTHON_BRIDGE_CPACK_PATH}/${PYTHON_VERSION}/openvino/inference_engine
COMPONENT ${PYTHON_VERSION})
COMPONENT ${PYTHON_COMPONENT})
add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME}
EXCLUDE_PATTERNS ".*\\.cxx;.*\\.pxd;.*\\.pyx")

View File

@ -54,12 +54,12 @@ add_custom_command(TARGET ${TARGET_NAME}
# install
# TODO: use ${PYTHON_VERSION}_dev component below
# ie_cpack_add_component(${PYTHON_VERSION}_dev DEPENDS ${PYTHON_VERSION})
# ie_cpack_add_component(${PYTHON_VERSION}_dev DEPENDS ${PYTHON_COMPONENT})
install(TARGETS ${TARGET_NAME}
RUNTIME DESTINATION python/${PYTHON_VERSION}/openvino/offline_transformations COMPONENT ${PYTHON_VERSION}
LIBRARY DESTINATION python/${PYTHON_VERSION}/openvino/offline_transformations COMPONENT ${PYTHON_VERSION})
RUNTIME DESTINATION python/${PYTHON_VERSION}/openvino/offline_transformations COMPONENT ${PYTHON_COMPONENT}
LIBRARY DESTINATION python/${PYTHON_VERSION}/openvino/offline_transformations COMPONENT ${PYTHON_COMPONENT})
install(PROGRAMS __init__.py
DESTINATION python/${PYTHON_VERSION}/openvino/offline_transformations
COMPONENT ${PYTHON_VERSION})
COMPONENT ${PYTHON_COMPONENT})

View File

@ -30,7 +30,7 @@ public:
* @param ptrNumMemoryBytes pointer to specific number of memory bytes
* @return none.
*/
virtual void GetFileInfo(const char* fileName, uint32_t numArrayToFindSize, uint32_t* ptrNumArrays, uint32_t* ptrNumMemoryBytes);
void GetFileInfo(const char* fileName, uint32_t numArrayToFindSize, uint32_t* ptrNumArrays, uint32_t* ptrNumMemoryBytes) override;
/**
* @brief Load Kaldi ARK speech feature vector file
@ -43,8 +43,8 @@ public:
* @param ptrNumBytesPerElement pointer to number bytes per element (size of float by default)
* @return none.
*/
virtual void LoadFile(const char* fileName, uint32_t arrayIndex, std::string& ptrName, std::vector<uint8_t>& memory, uint32_t* ptrNumRows,
uint32_t* ptrNumColumns, uint32_t* ptrNumBytesPerElement);
void LoadFile(const char* fileName, uint32_t arrayIndex, std::string& ptrName, std::vector<uint8_t>& memory, uint32_t* ptrNumRows, uint32_t* ptrNumColumns,
uint32_t* ptrNumBytesPerElement) override;
/**
* @brief Save Kaldi ARK speech feature vector file
@ -56,7 +56,7 @@ public:
* @param numColumns number of columns
* @return none.
*/
virtual void SaveFile(const char* fileName, bool shouldAppend, std::string name, void* ptrMemory, uint32_t numRows, uint32_t numColumns);
void SaveFile(const char* fileName, bool shouldAppend, std::string name, void* ptrMemory, uint32_t numRows, uint32_t numColumns) override;
};
/// @brief Responsible to work with .npz files
@ -70,7 +70,7 @@ public:
* @param ptrNumMemoryBytes pointer to specific number of memory bytes
* @return none.
*/
virtual void GetFileInfo(const char* fileName, uint32_t numArrayToFindSize, uint32_t* ptrNumArrays, uint32_t* ptrNumMemoryBytes);
void GetFileInfo(const char* fileName, uint32_t numArrayToFindSize, uint32_t* ptrNumArrays, uint32_t* ptrNumMemoryBytes) override;
/**
* @brief Load Numpy* uncompressed NPZ speech feature vector file
@ -83,8 +83,8 @@ public:
* @param ptrNumBytesPerElement pointer to number bytes per element (size of float by default)
* @return none.
*/
virtual void LoadFile(const char* fileName, uint32_t arrayIndex, std::string& ptrName, std::vector<uint8_t>& memory, uint32_t* ptrNumRows,
uint32_t* ptrNumColumns, uint32_t* ptrNumBytesPerElement);
void LoadFile(const char* fileName, uint32_t arrayIndex, std::string& ptrName, std::vector<uint8_t>& memory, uint32_t* ptrNumRows, uint32_t* ptrNumColumns,
uint32_t* ptrNumBytesPerElement) override;
/**
* @brief Save Numpy* uncompressed NPZ speech feature vector file
@ -96,5 +96,5 @@ public:
* @param numColumns number of columns
* @return none.
*/
virtual void SaveFile(const char* fileName, bool shouldAppend, std::string name, void* ptrMemory, uint32_t numRows, uint32_t numColumns);
void SaveFile(const char* fileName, bool shouldAppend, std::string name, void* ptrMemory, uint32_t numRows, uint32_t numColumns) override;
};

View File

@ -70,9 +70,12 @@
#include <transformations/low_precision/disable_convert_constant_folding_on_const_path.hpp>
#include <low_precision/pull_reshape_through_dequantization.hpp>
#include <low_precision/pull_transpose_through_dequantization.hpp>
#include <low_precision/transformer.hpp>
#include <low_precision/convolution.hpp>
#include <low_precision/convolution_backprop_data.hpp>
#include <low_precision/group_convolution.hpp>
#include <low_precision/low_precision.hpp>
#include <low_precision/mat_mul.hpp>
#include <low_precision/multiply_to_group_convolution.hpp>
#include <low_precision/strided_slice.hpp>
#include <low_precision/network_helper.hpp>
@ -83,6 +86,7 @@
#include "gpu/gpu_config.hpp"
#include "cldnn/runtime/device_query.hpp"
#include "cldnn/runtime/debug_configuration.hpp"
#ifdef __linux__
# include <dlfcn.h>
@ -150,10 +154,12 @@ InferenceEngine::CNNNetwork clDNNEngine::CloneAndTransformNetwork(const Inferenc
OV_ITT_SCOPED_TASK(itt::domains::CLDNNPlugin, "clDNNEngine::TransformNetwork");
auto nGraphFunc = clonedNetwork.getFunction();
using const_node_ptr = const std::shared_ptr<const ngraph::Node>;
bool enableInt8;
{
ngraph::pass::Manager manager;
enableInt8 = config.enableInt8 && ngraph::pass::low_precision::LowPrecisionTransformer::isFunctionQuantized(nGraphFunc);
enableInt8 = config.enableInt8 && ngraph::pass::low_precision::LowPrecision::isFunctionQuantized(nGraphFunc);
if (enableInt8) {
manager.register_pass<ngraph::pass::DisableConvertConstantFoldingOnConstPath>(
std::vector<ngraph::element::Type>{ ngraph::element::i8, ngraph::element::u8, ngraph::element::i4, ngraph::element::u4 });
@ -207,8 +213,6 @@ InferenceEngine::CNNNetwork clDNNEngine::CloneAndTransformNetwork(const Inferenc
auto pass_config = manager.get_pass_config();
using const_node_ptr = const std::shared_ptr<const ngraph::Node>;
// SpaceToDepth/DepthToSpace node implementation supports only equal input/output tensors with rank <= 5
pass_config->set_callback<ngraph::pass::ConvertSpaceToDepth,
ngraph::pass::ConvertDepthToSpace>(
@ -390,28 +394,78 @@ InferenceEngine::CNNNetwork clDNNEngine::CloneAndTransformNetwork(const Inferenc
if (!config.enable_fp16_for_quantized_models) {
manager.register_pass<ngraph::pass::ConvertPrecision>(precisions_array {{ ngraph::element::f16, ngraph::element::f32 }});
}
auto lptPrerequisites = manager.register_pass<ngraph::pass::GraphRewrite>();
const std::vector<ngraph::element::Type> supportedTypes = { ngraph::element::i8, ngraph::element::u8 };
lptPrerequisites->add_matcher<PullReshapeThroughDequantization>(supportedTypes);
lptPrerequisites->add_matcher<PullTransposeThroughDequantization>(supportedTypes);
lptPrerequisites->add_matcher<ngraph::pass::LinOpSequenceFusion>();
manager.run_passes(nGraphFunc);
auto params = LayerTransformation::Params(true, // updatePrecisions
LayerTransformation::QuantizedTensorAlignment::UpdateLevel, // quantizedTensorAlignmentOnActivations
LayerTransformation::QuantizedTensorAlignment::None, // quantizedTensorAlignmentOnWeights
true); // supportAsymmetricQuantization
LowPrecisionTransformer transformer(LowPrecisionTransformer::getAllTransformations(params)
.add<MatMulTransformation, ngraph::opset1::MatMul>(LayerTransformation::Params(params)
.setSupportAsymmetricQuantization(false)
.setSupport3DTensorOnActivations(false))
.add<ConvolutionBackpropDataTransformation, ngraph::opset1::ConvolutionBackpropData>(LayerTransformation::Params(params)
.setSupportAsymmetricQuantization(false)
.setDeconvolutionSpecificChannelsRatio(true))
// INT8 StridedSlice not supported
.remove<StridedSliceTransformation, ngraph::opset1::StridedSlice>());
auto supportedPrecisions = std::vector<OperationPrecisionRestriction>({
OperationPrecisionRestriction::create<ngraph::opset1::Convolution>({
{0, {ngraph::element::u8, ngraph::element::i8}},
{1, {ngraph::element::i8}},
}),
OperationPrecisionRestriction::create<ngraph::opset1::ConvolutionBackpropData>({
{0, {ngraph::element::u8, ngraph::element::i8}},
{1, {ngraph::element::i8}}
}),
OperationPrecisionRestriction::create<ngraph::opset1::GroupConvolution>({
{0, {ngraph::element::u8, ngraph::element::i8}},
{1, {ngraph::element::i8}}
}),
OperationPrecisionRestriction::create<ngraph::opset1::StridedSlice>({})
});
transformer.transform(nGraphFunc);
auto perTensorQuantization = std::vector<OperationPerTensorQuantizationRestriction>({
OperationPerTensorQuantizationRestriction::create<ngraph::opset1::Convolution>({0}),
OperationPerTensorQuantizationRestriction::create<ngraph::opset1::ConvolutionBackpropData>({0}),
});
ngraph::pass::Manager lptManager;
auto lptPassConfig = lptManager.get_pass_config();
lptPassConfig->disable<ngraph::pass::low_precision::StridedSliceTransformation>();
lptPassConfig->set_callback<ngraph::pass::low_precision::MarkupPrecisions>([](const_node_ptr& node) -> bool {
if (const auto mulitply = std::dynamic_pointer_cast<const ngraph::opset1::Multiply>(node)) {
return !MultiplyToGroupConvolutionTransformation::canBeTransformedToGroupConvolution(mulitply);
}
return false;
});
lptPassConfig->set_callback<ConvolutionBackpropDataTransformation>([](const_node_ptr& node) -> bool {
auto fillStaticChannel = [](const ngraph::PartialShape& shape, size_t& channel) -> bool {
const auto rank = shape.rank();
if (rank.is_dynamic()) {
return false;
}
if (rank.get_length() < 2ul) {
return false;
}
const auto dimension = shape[1];
if (dimension.is_dynamic()) {
return false;
}
channel = dimension.get_length();
return true;
};
size_t inputChannels;
if (!fillStaticChannel(node->get_input_partial_shape(0), inputChannels)) {
return true;
}
size_t outputChannels;
if (!fillStaticChannel(node->get_output_partial_shape(0), outputChannels)) {
return true;
}
if ((inputChannels % 4 != 0) || (outputChannels % 16 != 0)) {
return true;
}
return LayerTransformation::isAsymmetricQuantization(node) || WeightableLayerTransformation::isAsymmetricOnWeights(node);
});
lptPassConfig->set_callback<MatMulTransformation>([](const_node_ptr& node) -> bool {
return MatMulTransformation::is3DTensorOnActivations(node);
});
lptManager.register_pass<LowPrecision>(supportedPrecisions, perTensorQuantization);
lptManager.run_passes(nGraphFunc);
}
{
@ -436,6 +490,11 @@ InferenceEngine::CNNNetwork clDNNEngine::CloneAndTransformNetwork(const Inferenc
manager.run_passes(nGraphFunc);
}
}
GPU_DEBUG_GET_INSTANCE(debug_config);
GPU_DEBUG_IF(!debug_config->dump_graphs.empty()) {
clonedNetwork.serialize(debug_config->dump_graphs + "/transformed_func.xml");
}
return clonedNetwork;
}

View File

@ -62,6 +62,8 @@ void CreateMatMulOp(Program& p, const std::shared_ptr<ngraph::op::v0::MatMul>& o
bool is_fc = IsNodeOnConstPath(op->get_input_node_shared_ptr(1));
is_fc &= std::count_if(shape_b.begin(), shape_b.end(), [](size_t x) { return x != 1; }) <= 2;
// TODO: This conditions can be relaxed with proper handling in FC path
is_fc &= shape_b.size() > 1 && shape_a.size() > 1;
if (is_fc) {
ngraph::Shape shape_a_aligned, shape_b_aligned;
@ -73,10 +75,10 @@ void CreateMatMulOp(Program& p, const std::shared_ptr<ngraph::op::v0::MatMul>& o
auto inputName = inputPrimitives[0];
auto weightsName = inputPrimitives[1];
// Weights normalization
if (!op->get_transpose_b()) {
ngraph::Shape output_shape = shape_b;
std::vector<uint16_t> transpose_order(output_shape.size());
std::vector<uint16_t> transpose_order(shape_b.size());
std::iota(transpose_order.begin(), transpose_order.end(), 0);
std::swap(*(transpose_order.end() - 1), *(transpose_order.end() - 2));
@ -95,8 +97,7 @@ void CreateMatMulOp(Program& p, const std::shared_ptr<ngraph::op::v0::MatMul>& o
// Input normalization
if (op->get_transpose_a()) {
ngraph::Shape output_shape = shape_a;
std::vector<uint16_t> transpose_order(output_shape.size());
std::vector<uint16_t> transpose_order(shape_a.size());
std::iota(transpose_order.begin(), transpose_order.end(), 0);
std::swap(*(transpose_order.end() - 1), *(transpose_order.end() - 2));
@ -131,16 +132,20 @@ void CreateMatMulOp(Program& p, const std::shared_ptr<ngraph::op::v0::MatMul>& o
if (reshape_fc) {
inputName = reshape_to_2d(shape_a, inputName, shape_a.back(), "_cldnn_reshape_in");
}
if (shape_b.size() != 2) {
weightsName = reshape_to_2d(shape_b, weightsName, K, "_cldnn_reshape_weights");
}
auto input_rank = reshape_fc ? 2 : shape_a.size();
auto fcPrim = cldnn::fully_connected(layerName,
inputName,
weightsName,
"",
DataTypeFromPrecision(op->get_output_element_type(0)),
cldnn::padding(),
op->get_output_shape(0).size());
input_rank);
p.AddPrimitive(fcPrim);
@ -196,7 +201,29 @@ void CreateMatMulOp(Program& p, const std::shared_ptr<ngraph::op::v0::MatMul>& o
auto reshapeName = layerName + "_cldnn_in" + std::to_string(i) + "_reshape";
// Extend input dimensions by prepending ones
inputDims.insert(inputDims.begin(), outDimsN - inputDimsN, 1ul);
if (inputDimsN == 1) {
// One-dimensional tensors unsqueezing is applied for each input independently.
// The axes inserted in this step are not included in the output shape.
// * If rank of the **first** input is equal to 1, it is always unsqueezed to 2D tensor **row vector** (regardless of `transpose_a`)
// by adding axes with size 1 at ROW_INDEX_DIM, to the **left** of the shape. For example `[S]` will be reshaped to `[1, S]`.
// * If rank of the **second** input is equal to 1, it is always unsqueezed to 2D tensor **column vector** (regardless of `transpose_b`)
// by adding axes with size 1 at COL_INDEX_DIM, to the **right** of the shape. For example `[S]` will be reshaped to `[S, 1]`.
bool transpose = false;
if (i == 0) {
transpose = op->get_transpose_a();
inputDims.insert(inputDims.begin(), 1);
} else {
transpose = op->get_transpose_b();
inputDims.insert(inputDims.end(), 1);
}
// Specs says that shapes must be unsqueezed regardless of tranpose flag, but primitive implementation always respects transposes
// so we have to swap dimensions correspondingly to have consistent shapes.
if (transpose) {
std::swap(inputDims[0], inputDims[1]);
}
}
if (inputDimsN < outDimsN)
inputDims.insert(inputDims.begin(), outDimsN - inputDimsN, 1ul);
auto targetShape = gemmSpecificTensor(inputDims);

View File

@ -65,9 +65,11 @@ inline std::pair<InferenceEngine::CNNLayerPtr, InferenceEngine::CNNLayerPtr> Fin
if (parent->outData.size() != 1 || InferenceEngine::getInputTo(parent->outData[0]).size() != 1) {
return std::make_pair(nullptr, nullptr);
}
auto parent_dims = parent->outData[0]->getDims();
// Check if the previous layer has all dimensions except one to be equal to 1
if (std::count_if(std::begin(parent_dims), std::end(parent_dims), [](size_t dim) { return dim != 1; }) > 1) {
// Check if reshape is expected for this pattern:
// the previous layer has number of channels > 1 and one of height/width dimensions is also > 1
if (GetDataDimSize(parent->outData[0], InferenceEngine::DataDimName::C) != 1 &&
(GetDataDimSize(parent->outData[0], InferenceEngine::DataDimName::H) != 1 ||
GetDataDimSize(parent->outData[0], InferenceEngine::DataDimName::W) != 1)) {
return std::make_pair(nullptr, nullptr);
}
}

View File

@ -470,7 +470,6 @@ void GNAPlugin::UpdateInputScaleFromNetwork(InferenceEngine::CNNNetwork & networ
auto data = input.second->getInputData();
for (auto && nextToInputLayer : getInputTo(data)) {
if (!LayerInfo(nextToInputLayer.second).isFakeQuantize()) {
inputIdx++;
continue;
}
// replacing scale factor from this fq layer
@ -493,6 +492,9 @@ void GNAPlugin::UpdateInputScaleFromNetwork(InferenceEngine::CNNNetwork & networ
scaleInput = (fqLayer.getLevels() - 1) / (2 * maxAbsVal);
}
IE_ASSERT(config.inputScaleFactors.size() > inputIdx);
IE_ASSERT(inputsDesc->inputScaleFactors.size() > inputIdx);
if (!config.inputScaleFactors.empty()) {
gnalog() << "Scale factor calculated during model quantization (" << scaleInput
<< ") will be used instead of user input (" << inputsDesc->inputScaleFactors[inputIdx] << ").\n";
@ -505,9 +507,9 @@ void GNAPlugin::UpdateInputScaleFromNetwork(InferenceEngine::CNNNetwork & networ
config.inputScaleFactors[inputIdx] = scaleInput;
inputsDesc->inputScaleFactors[inputIdx] = scaleInput;
inputIdx++;
}
inputIdx++;
}
}
@ -752,12 +754,14 @@ void GNAPlugin::LoadNetwork(CNNNetwork & _network) {
passes->registerPass<FuseFQIntoWeightsPass>();
passes->registerPass<MoveFakeQuantizeLayerIntoQuantParamsPass>();
passes->registerPass<SubstituteScaleShiftBroadCastPass>();
passes->registerPass<BroadcastConstPass>();
passes->registerPass<TransposeWeightsFromNCHWToNHWCPass>();
passes->registerPass<SubstitutePReluPass>();
passes->registerPass<SubstituteSoftSignPass>();
passes->registerPass<BroadcastConstPass>();
passes->registerPass<ReorderMaxPoolPass>();
passes->registerPass<EltwiseSplitOverChannelsPass>();
passes->registerPass<InsertSplitAligningFilterPass>();
@ -775,7 +779,6 @@ void GNAPlugin::LoadNetwork(CNNNetwork & _network) {
#if GNA_LIB_VER == 2
passes->registerPass<ForbidActivationFusingPass>();
#endif
passes->registerPass<SubstituteScaleShiftBroadCastPass>();
passes->registerPass<FuseMultipleIdentitiesPass>();
passIdx = passes->run(passIdx);
};

View File

@ -1530,16 +1530,7 @@ void SubstituteScaleShiftBroadCastPass::run() {
continue;
}
// only 3d scaleshift supported where number of c is arbitrary
auto lastD = reshape_batch ? dataDims[1] : dataDims.back();
if (lastD != weightsElements) {
THROW_GNA_EXCEPTION << "Unsupported layer: " << l->name
<< " should have last dim(" << lastD << ") equal to weights(" << weightsElements << ") length";
}
if (dataDims.size() == 2) {
THROW_GNA_EXCEPTION << "For layer: " << l->name
<< " weights size(" << weightsElements<< ") invalid: should match input size of(" << lastD << ")";
}
// TODO: add broadcasting rules checks
gnalog() << "Substitution ScaleShift broadcast for layer: " << l->name << "\n";
if (nElements % scaleShift->_weights->size()) {
@ -2186,7 +2177,7 @@ void MoveFakeQuantizeLayerIntoQuantParamsPass :: run() {
}
if (isFQFuseAllowed) {
getInputTo(prevData).clear();
getInputTo(prevData).erase(l->name);
}
// Connect all next layers after FQ to the layer that is before FQ
@ -2220,6 +2211,17 @@ void TransposeWeightsFromNCHWToNHWCPass::run() {
}
};
auto transpInfoMatchWeightsSize = [](const std::vector<TranspositionInfo> &transpositionInfo, size_t weightsSize, const std::string &layerName) {
size_t totalElements = 0;
for (auto && transpositionInfoPart : transpositionInfo) {
totalElements += transpositionInfoPart.num_transpose_rows * transpositionInfoPart.num_transpose_columns;
}
if (totalElements != weightsSize) {
THROW_GNA_EXCEPTION << layerName << " weights elements from transposition info (" << totalElements
<< ") don't match input dimensions (" << weightsSize << ")";
}
};
for (auto &&l : *pLayers) {
if (LayerInfo(l).isScaleShift()) {
std::vector<TranspositionInfo> transpositionInfo;
@ -2237,6 +2239,10 @@ void TransposeWeightsFromNCHWToNHWCPass::run() {
}
auto weightable = dynamic_cast<WeightableLayer*>(l.get());
IE_ASSERT(weightable != nullptr);
size_t totalWeights = weightable->_weights->size();
transpInfoMatchWeightsSize(transpositionInfo, totalWeights, l->name);
ConvertTensorFromNCHWToNHWC(weightable->precision.size(), 1, weightable->_weights->size(),
weightable->_weights->cbuffer().as<uint8_t*>(), true, transpositionInfo);
if (weightable->_biases) {
@ -2270,14 +2276,9 @@ void TransposeWeightsFromNCHWToNHWCPass::run() {
// If we found a split it's not possible to rotate data
THROW_GNA_EXCEPTION << l->name << " won't be transposed due to a split before it";
}
size_t totalColumns = 0;
for (auto && transpositionInfoPart : transpositionInfo) {
totalColumns += transpositionInfoPart.num_transpose_rows * transpositionInfoPart.num_transpose_columns;
}
if (weightsColumns != totalColumns) {
THROW_GNA_EXCEPTION << l->name << " weights columns from transposition info (" << totalColumns
<< ") don't match input dimensions (" << weightsColumns << ")";
}
transpInfoMatchWeightsSize(transpositionInfo, weightsColumns, l->name);
ConvertTensorFromNCHWToNHWC(precision, weightsRows, weightsColumns, weightable->_weights->cbuffer().as<uint8_t*>(),
true, transpositionInfo);
gnalog() << l->name << " weights rows transposition info:\n";
@ -2297,14 +2298,9 @@ void TransposeWeightsFromNCHWToNHWCPass::run() {
// If we found a concat it's not possible to rotate data
THROW_GNA_EXCEPTION << l->name << " won't be transposed due to a concat after it";
}
size_t totalRows = 0;
for (const auto& transpositionInfoPart : transpositionInfo) {
totalRows += transpositionInfoPart.num_transpose_rows * transpositionInfoPart.num_transpose_columns;
}
if (weightsRows != totalRows) {
THROW_GNA_EXCEPTION << l->name << " weights rows from transposition info (" << totalRows
<< ") don't match output dimensions (" << weightsRows << ")";
}
transpInfoMatchWeightsSize(transpositionInfo, weightsRows, l->name);
ConvertTensorFromNCHWToNHWC(precision, weightsRows, weightsColumns, weightable->_weights->cbuffer().as<uint8_t*>(),
false, transpositionInfo);
gnalog() << l->name << " weights columns transposition info:\n";

View File

@ -8,6 +8,7 @@
#include <ngraph/opsets/opset7.hpp>
#include <ngraph/pattern/op/or.hpp>
#include <ngraph/pattern/op/wrap_type.hpp>
#include <ngraph/rt_info.hpp>
#include "layers/gna_permute.hpp"
#include "backend/gna_limitations.hpp"
@ -62,30 +63,36 @@ static bool Convert(std::shared_ptr<ngraph::Node> matmul_node,
ngraph::Shape{1, 1, width, in_channels});
auto reshape_before = std::make_shared<ngraph::opset7::Reshape>(input_node, reshape_const_before, false);
reshape_before->set_friendly_name(base_name + "/reshape_in");
ngraph::copy_runtime_info(input_node, reshape_before);
auto transpose_before = std::make_shared<ngraph::opset7::Transpose>(reshape_before,
ngraph::opset7::Constant::create(ngraph::element::i64, ngraph::Shape{4},
GetPermuteOrder(InferenceEngine::Layout::NHWC, InferenceEngine::Layout::NCHW)));
transpose_before->set_friendly_name(base_name + "/transpose_in");
ngraph::copy_runtime_info(matmul_node, transpose_before);
auto weights_reshape_const = std::make_shared<ngraph::opset7::Constant>(ngraph::element::Type_t::i64,
ngraph::Shape{4}, ngraph::Shape{out_channels, in_channels, 1, 1});
auto weights_reshaped = std::make_shared<ngraph::opset7::Reshape>(weights_node, weights_reshape_const, false);
ngraph::copy_runtime_info(weights_node, weights_reshaped);
std::shared_ptr<ngraph::Node> conv_node = std::make_shared<ngraph::opset7::Convolution>(transpose_before, weights_reshaped,
ngraph::Strides{1, 1}, ngraph::CoordinateDiff{0, 0}, ngraph::CoordinateDiff{0, 0},
ngraph::Strides{1, 1}, ngraph::op::PadType::VALID);
conv_node->set_friendly_name(base_name + "/conv");
ngraph::copy_runtime_info(transpose_before, conv_node);
std::shared_ptr<ngraph::Node> root_node = matmul_node;
if (bias != nullptr) {
conv_node = std::make_shared<ngraph::opset7::Add>(conv_node, bias);
ngraph::copy_runtime_info(transpose_before, conv_node);
root_node = add;
}
if (fq != nullptr) {
conv_node = fq->clone_with_new_inputs({conv_node, fq->input_value(1), fq->input_value(2),
fq->input_value(3), fq->input_value(4)});
ngraph::copy_runtime_info(fq, conv_node);
root_node = fq;
}
@ -93,6 +100,7 @@ static bool Convert(std::shared_ptr<ngraph::Node> matmul_node,
ngraph::opset7::Constant::create(ngraph::element::i64, ngraph::Shape{4},
GetPermuteOrder(InferenceEngine::Layout::NCHW, InferenceEngine::Layout::NHWC)));
transpose_after->set_friendly_name(base_name + "/transpose_out");
ngraph::copy_runtime_info(conv_node, transpose_after);
auto output_shape = matmul_node->get_output_shape(0);
output_shape[output_shape.size() - 1] = out_channels;
@ -102,6 +110,7 @@ static bool Convert(std::shared_ptr<ngraph::Node> matmul_node,
output_shape);
auto reshape_after = std::make_shared<ngraph::opset7::Reshape>(transpose_after, reshape_const_after, false);
reshape_after->set_friendly_name(base_name);
ngraph::copy_runtime_info(transpose_after, reshape_after);
ngraph::replace_node(root_node, reshape_after);
return true;

View File

@ -9,7 +9,7 @@
#include <ngraph/opsets/opset7.hpp>
#include <ngraph/pattern/op/or.hpp>
#include <ngraph/pattern/op/wrap_type.hpp>
#include <ngraph/rt_info.hpp>
#include <gna_plugin_log.hpp>
using namespace GNAPluginNS;
@ -63,6 +63,7 @@ ReorderActivationAndPooling::ReorderActivationAndPooling() {
}
ngraph::replace_output_update_name(pool_node->output(0), pool_node->input_value(0));
ngraph::copy_runtime_info(pool_node, new_pool);
return true;
};

View File

@ -120,10 +120,12 @@ ie_faster_build(${TARGET_NAME}_obj
)
target_compile_definitions(${TARGET_NAME}_obj PRIVATE IMPLEMENT_INFERENCE_ENGINE_API
$<TARGET_PROPERTY:ngraph::ngraph,INTERFACE_COMPILE_DEFINITIONS>)
$<TARGET_PROPERTY:ngraph::ngraph,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:ngraph::frontend_manager::static,INTERFACE_COMPILE_DEFINITIONS>)
target_include_directories(${TARGET_NAME}_obj SYSTEM PRIVATE $<TARGET_PROPERTY:ngraph::ngraph,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:pugixml::static,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:ngraph::frontend_manager::static,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:xbyak,INTERFACE_INCLUDE_DIRECTORIES>)
target_include_directories(${TARGET_NAME}_obj PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}"
@ -160,7 +162,7 @@ if (TBBBIND_2_4_FOUND)
endif()
target_link_libraries(${TARGET_NAME} PRIVATE pugixml::static openvino::itt ${CMAKE_DL_LIBS} Threads::Threads
ngraph inference_engine_transformations)
ngraph ngraph::frontend_manager::static inference_engine_transformations)
target_include_directories(${TARGET_NAME} INTERFACE
$<BUILD_INTERFACE:${PUBLIC_HEADERS_DIR}>
@ -200,7 +202,7 @@ if(WIN32)
set_target_properties(${TARGET_NAME}_s PROPERTIES COMPILE_PDB_NAME ${TARGET_NAME}_s)
endif()
target_link_libraries(${TARGET_NAME}_s PRIVATE openvino::itt ${CMAKE_DL_LIBS} ngraph
target_link_libraries(${TARGET_NAME}_s PRIVATE openvino::itt ${CMAKE_DL_LIBS} ngraph ngraph::frontend_manager::static
inference_engine_transformations pugixml::static)
target_compile_definitions(${TARGET_NAME}_s PUBLIC USE_STATIC_IE)

View File

@ -9,6 +9,7 @@
#include <file_utils.h>
#include <ie_reader.hpp>
#include <ie_ir_version.hpp>
#include <frontend_manager/frontend_manager.hpp>
#include <fstream>
#include <istream>
@ -226,6 +227,26 @@ CNNNetwork details::ReadNetwork(const std::string& modelPath, const std::string&
return reader->read(modelStream, exts);
}
}
// Try to load with FrontEndManager
static ngraph::frontend::FrontEndManager manager;
ngraph::frontend::FrontEnd::Ptr FE;
ngraph::frontend::InputModel::Ptr inputModel;
if (!binPath.empty()) {
#if defined(ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
std::wstring weights_path = FileUtils::multiByteCharToWString(binPath.c_str());
#else
std::string weights_path = binPath;
#endif
FE = manager.load_by_model(model_path, weights_path);
if (FE) inputModel = FE->load(model_path, weights_path);
} else {
FE = manager.load_by_model(model_path);
if (FE) inputModel = FE->load(model_path);
}
if (inputModel) {
auto ngFunc = FE->convert(inputModel);
return CNNNetwork(ngFunc);
}
IE_THROW() << "Unknown model format! Cannot find reader for model format: " << fileExt << " and read the model: " << modelPath <<
". Please check that reader library exists in your PATH.";
}
@ -248,4 +269,4 @@ CNNNetwork details::ReadNetwork(const std::string& model, const Blob::CPtr& weig
IE_THROW() << "Unknown model format! Cannot find reader for the model and read it. Please check that reader library exists in your PATH.";
}
} // namespace InferenceEngine
} // namespace InferenceEngine

View File

@ -1025,7 +1025,8 @@ public:
Logical_OR,
Logical_XOR,
Logical_NOT,
Mean
Mean,
Abs,
};
/**

View File

@ -28,8 +28,6 @@ ie_faster_build(${TARGET_NAME}
ie_add_vs_version_file(NAME ${TARGET_NAME}
FILEDESCRIPTION "Inference Engine LP transformations library")
target_compile_definitions(${TARGET_NAME} PRIVATE inference_engine_transformations_EXPORTS)
target_link_libraries(${TARGET_NAME} PUBLIC inference_engine_transformations
PRIVATE openvino::itt)

View File

@ -11,12 +11,11 @@ namespace ngraph {
namespace pass {
namespace low_precision {
class TRANSFORMATIONS_API AddTransformation : public EltwiseBaseTransformation {
class LP_TRANSFORMATIONS_API AddTransformation : public EltwiseBaseTransformation {
public:
AddTransformation(const Params& params) : EltwiseBaseTransformation(params) {}
~AddTransformation() override {}
void registerMatcherIn(GraphRewrite& pass, TransformationContext& context) const override;
bool transform(TransformationContext& context, ngraph::pattern::Matcher &m) const override;
NGRAPH_RTTI_DECLARATION;
AddTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ngraph::pattern::Matcher &m) override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> layer) const override;
};

View File

@ -0,0 +1,25 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <memory>
#include <ngraph/pass/pass.hpp>
#include "low_precision/lpt_visibility.hpp"
namespace ngraph {
namespace pass {
namespace low_precision {
class LP_TRANSFORMATIONS_API AlignQuantizationIntervals;
} // namespace low_precision
} // namespace pass
} // namespace ngraph
class ngraph::pass::low_precision::AlignQuantizationIntervals : public ngraph::pass::FunctionPass {
public:
NGRAPH_RTTI_DECLARATION;
bool run_on_function(std::shared_ptr<ngraph::Function> f) override;
};

View File

@ -0,0 +1,26 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <memory>
#include <ngraph/pass/pass.hpp>
#include "low_precision/lpt_visibility.hpp"
namespace ngraph {
namespace pass {
namespace low_precision {
class LP_TRANSFORMATIONS_API AlignQuantizationParameters;
} // namespace low_precision
} // namespace pass
} // namespace ngraph
class ngraph::pass::low_precision::AlignQuantizationParameters : public ngraph::pass::FunctionPass {
public:
NGRAPH_RTTI_DECLARATION;
bool run_on_function(std::shared_ptr<ngraph::Function> f) override;
};

View File

@ -11,11 +11,11 @@ namespace ngraph {
namespace pass {
namespace low_precision {
class TRANSFORMATIONS_API AvgPoolTransformation : public LayerTransformation {
class LP_TRANSFORMATIONS_API AvgPoolTransformation : public LayerTransformation {
public:
AvgPoolTransformation(const Params& params);
void registerMatcherIn(GraphRewrite& pass, TransformationContext& context) const override;
bool transform(TransformationContext& context, ngraph::pattern::Matcher &m) const override;
NGRAPH_RTTI_DECLARATION;
AvgPoolTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ngraph::pattern::Matcher &m) override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> layer) const override;
};

View File

@ -0,0 +1,24 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <ngraph/node.hpp>
#include <ngraph/pass/graph_rewrite.hpp>
#include "rt_info/attribute_parameters.hpp"
namespace ngraph {
namespace pass {
namespace low_precision {
class LP_TRANSFORMATIONS_API BaseMatcherPass;
} // namespace low_precision
} // namespace pass
} // namespace ngraph
class LP_TRANSFORMATIONS_API ngraph::pass::low_precision::BaseMatcherPass : public ngraph::pass::MatcherPass {
public:
BaseMatcherPass(const AttributeParameters& params = AttributeParameters());
AttributeParameters params;
};

View File

@ -12,11 +12,11 @@ namespace ngraph {
namespace pass {
namespace low_precision {
class TRANSFORMATIONS_API ClampTransformation : public LayerTransformation {
class LP_TRANSFORMATIONS_API ClampTransformation : public LayerTransformation {
public:
ClampTransformation(const Params& params);
void registerMatcherIn(GraphRewrite& pass, TransformationContext& context) const override;
bool transform(TransformationContext& context, ngraph::pattern::Matcher& m) const override;
NGRAPH_RTTI_DECLARATION;
ClampTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ngraph::pattern::Matcher& m) override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> op) const override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
};

View File

@ -13,7 +13,7 @@
#include <ngraph/check.hpp>
#include <ngraph/opsets/opset1.hpp>
#include "transformations_visibility.hpp"
#include "low_precision/lpt_visibility.hpp"
#include "transformations/rt_info/dequantization_attribute.hpp"
namespace ngraph {
@ -21,7 +21,7 @@ namespace pass {
namespace low_precision {
// template<typename BaseOp2>
// class TRANSFORMATIONS_API DequantizationOp : public BaseOp2 {
// class LP_TRANSFORMATIONS_API DequantizationOp : public BaseOp2 {
// public:
// template <typename ... Args>
// DequantizationOp(Args&&... args) : BaseOp2(std::forward<Args>(args)...) {
@ -63,7 +63,7 @@ void copyRuntimeInfo(const ngraph::Node& from, ngraph::Node& to) {
} // namespace
class TRANSFORMATIONS_API DequantizationConvert : public ngraph::opset1::Convert {
class LP_TRANSFORMATIONS_API DequantizationConvert : public ngraph::opset1::Convert {
public:
DequantizationConvert(const ngraph::Output<Node>& arg, const ngraph::element::Type& destination_type) :
ngraph::opset1::Convert(arg, destination_type) {
@ -77,7 +77,7 @@ public:
}
};
class TRANSFORMATIONS_API DequantizationSubtract : public ngraph::opset1::Subtract {
class LP_TRANSFORMATIONS_API DequantizationSubtract : public ngraph::opset1::Subtract {
public:
DequantizationSubtract(
const ngraph::Output<Node>& arg0,
@ -94,7 +94,7 @@ public:
}
};
class TRANSFORMATIONS_API DequantizationMultiply : public ngraph::opset1::Multiply {
class LP_TRANSFORMATIONS_API DequantizationMultiply : public ngraph::opset1::Multiply {
public:
DequantizationMultiply(
const Output<Node>& arg0,
@ -116,7 +116,7 @@ public:
}
};
class TRANSFORMATIONS_API DequantizationAdd : public ngraph::opset1::Add {
class LP_TRANSFORMATIONS_API DequantizationAdd : public ngraph::opset1::Add {
public:
DequantizationAdd(
const ngraph::Output<Node>& arg0,

View File

@ -8,6 +8,7 @@
#include <tuple>
#include <ngraph/ngraph.hpp>
#include <ngraph/opsets/opset1.hpp>
#include <low_precision/lpt_visibility.hpp>
namespace ngraph {
namespace pass {
@ -15,7 +16,7 @@ namespace low_precision {
typedef std::tuple<std::shared_ptr<Node>, std::shared_ptr<Node>> FakeQuantizeDequantizationValues;
class FakeQuantizeDequantization {
class LP_TRANSFORMATIONS_API FakeQuantizeDequantization {
public:
FakeQuantizeDequantization();

View File

@ -7,7 +7,7 @@
#include <exception>
#include <string>
#include <ngraph/node.hpp>
#include <transformations_visibility.hpp>
#include <low_precision/lpt_visibility.hpp>
/**
* @def THROW_TRANSFORMATION_EXCEPTION_LPT
@ -19,7 +19,7 @@ namespace ngraph {
namespace pass {
namespace low_precision {
class TRANSFORMATIONS_API Exception : std::exception {
class LP_TRANSFORMATIONS_API Exception : std::exception {
std::shared_ptr<std::ostringstream> buffer;
mutable std::string buffer_str;
public:
@ -42,7 +42,7 @@ public:
#define THROW_TRANSFORMATION_EXCEPTION throw ::ngraph::pass::low_precision::Exception() << __FILE__ << ":" << __LINE__ << " "
class TRANSFORMATIONS_API InferenceEngineLptException : public Exception {
class LP_TRANSFORMATIONS_API InferenceEngineLptException : public Exception {
public:
InferenceEngineLptException(const std::string& filename, const size_t line, const Node& node) {
*this

View File

@ -0,0 +1,56 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <vector>
#include <ngraph/node.hpp>
#include <ngraph/variant.hpp>
#include <low_precision/lpt_visibility.hpp>
#include <ngraph/pass/graph_rewrite.hpp>
namespace ngraph {
namespace pass {
namespace low_precision {
class OperationPerTensorQuantizationRestriction {
public:
using RestrictedPorts = std::vector<size_t>;
ngraph::Node::type_info_t operationType;
bool specifyVersion;
std::vector<size_t> restrictedPorts;
OperationPerTensorQuantizationRestriction() = default;
OperationPerTensorQuantizationRestriction(
const ngraph::Node::type_info_t operationType,
const bool specifyVersion,
const RestrictedPorts& restrictedPorts) :
operationType(operationType),
specifyVersion(specifyVersion),
restrictedPorts(restrictedPorts) {}
template <typename T>
static OperationPerTensorQuantizationRestriction create(
const RestrictedPorts& restrictedPorts = {},
const bool specifyVersion = false) {
return OperationPerTensorQuantizationRestriction(T::get_type_info_static(), specifyVersion, restrictedPorts);
}
template <typename T>
static RestrictedPorts getPrecisionsByOperationType(std::vector<OperationPerTensorQuantizationRestriction>& restrictions) {
for (const auto& restriction : restrictions) {
if (restriction.operationType == T::get_type_info_static()) {
return restriction.restrictedPorts;
}
}
return {};
}
};
} // namespace low_precision
} // namespace pass
} // namespace ngraph

View File

@ -0,0 +1,59 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <memory>
#include <set>
#include <unordered_set>
#include <vector>
#include <ngraph/node.hpp>
#include <ngraph/variant.hpp>
#include <low_precision/lpt_visibility.hpp>
#include <ngraph/pass/graph_rewrite.hpp>
namespace ngraph {
namespace pass {
namespace low_precision {
class OperationPrecisionRestriction {
public:
using PrecisionsByPort = std::vector<std::pair<size_t, std::vector<ngraph::element::Type>>>;
ngraph::Node::type_info_t operationType;
bool specifyVersion;
std::vector<std::pair<size_t, std::vector<ngraph::element::Type>>> precisionsByPort;
OperationPrecisionRestriction() = default;
OperationPrecisionRestriction(
const ngraph::Node::type_info_t operationType,
const bool specifyVersion,
const PrecisionsByPort& precisionsByPort) :
operationType(operationType),
specifyVersion(specifyVersion),
precisionsByPort(precisionsByPort) {}
template <typename T>
static OperationPrecisionRestriction create(
const PrecisionsByPort& precisionsByPort,
const bool specifyVersion = false) {
return OperationPrecisionRestriction(T::get_type_info_static(), specifyVersion, precisionsByPort);
}
template <typename T>
static PrecisionsByPort getPrecisionsByOperationType(std::vector<OperationPrecisionRestriction>& restrictions) {
for (const auto& restriction : restrictions) {
if (restriction.operationType == T::get_type_info_static()) {
return restriction.precisionsByPort;
}
}
return {};
}
};
} // namespace low_precision
} // namespace pass
} // namespace ngraph

Some files were not shown because too many files have changed in this diff Show More