Merge remote-tracking branch 'github/master' into auto-batch-master

# Conflicts:
#	inference-engine/src/cldnn_engine/cldnn_executable_network.cpp
#	inference-engine/src/plugin_api/performance_heuristics.hpp
This commit is contained in:
myshevts 2021-11-19 14:49:16 +03:00
commit caef69f4d0
1443 changed files with 49175 additions and 21556 deletions

View File

@ -1,3 +1,12 @@
trigger:
branches:
include:
- master
- releases/*
paths:
exclude:
- docs/*
resources:
repositories:
- repository: openvino_contrib
@ -12,6 +21,16 @@ resources:
jobs:
- job: Lin
strategy:
matrix:
Dynamic:
CMAKE_BUILD_SHARED_LIBS: 'ON'
PYTHON_STATIC_ARGS:
Static:
CMAKE_BUILD_SHARED_LIBS: 'OFF'
PYTHON_STATIC_ARGS: -m "not dynamic_library and not template_plugin"
maxParallel: 2
# About 150% of total time
timeoutInMinutes: 90
@ -34,6 +53,9 @@ jobs:
INSTALL_TEST_DIR: $(INSTALL_DIR)/tests
LAYER_TESTS_DIR: $(INSTALL_TEST_DIR)/layer_tests
SETUPVARS: $(INSTALL_DIR)/setupvars.sh
TMP_DIR: /mnt/tmp
SHARE_DIR: /mount/cinfsshare/onnxtestdata
CCACHE_DIR: $(SHARE_DIR)/ccache
steps:
- script: |
@ -54,14 +76,20 @@ jobs:
df
lsblk -o NAME,HCTL,SIZE,MOUNTPOINT | grep -i "sd"
free -h
echo TargetBranch: $(System.PullRequest.TargetBranch)
echo SourceBranch: $(Build.SourceBranch)
displayName: 'System info'
- script: |
set -e
rm -rf $(WORK_DIR) ; mkdir $(WORK_DIR)
rm -rf $(BUILD_DIR) ; mkdir $(BUILD_DIR)
rm -rf $(BUILD_SAMPLES_DIR) ; mkdir $(BUILD_SAMPLES_DIR)
echo TargetBranch: $(System.PullRequest.TargetBranch)
echo SourceBranch: $(Build.SourceBranch)
sudo rm -rf $(TMP_DIR) ; sudo mkdir $(TMP_DIR) ; sudo chmod 777 -R $(TMP_DIR)
sudo mkdir -p $(SHARE_DIR)
sudo apt --assume-yes install nfs-common
sudo mount -vvv -t nfs cinfsshare.file.core.windows.net:/cinfsshare/onnxtestdata $(SHARE_DIR) -o vers=4,minorversion=1,sec=sys
mkdir -p $(CCACHE_DIR)
displayName: 'Make dir'
- checkout: self
@ -117,6 +145,9 @@ jobs:
-DVERBOSE_BUILD=ON
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE)
-DENABLE_PYTHON=ON
-DBUILD_SHARED_LIBS=$(CMAKE_BUILD_SHARED_LIBS)
-DENABLE_GNA=$(CMAKE_BUILD_SHARED_LIBS)
-DENABLE_ONEDNN_FOR_GPU=$(CMAKE_BUILD_SHARED_LIBS)
-DPYTHON_EXECUTABLE=/usr/bin/python3.8
-DENABLE_WHEEL=ON
-DENABLE_TESTS=ON
@ -125,16 +156,27 @@ jobs:
-DENABLE_STRICT_DEPENDENCIES=OFF
-DENABLE_REQUIREMENTS_INSTALL=OFF
-DIE_EXTRA_MODULES=$(OPENVINO_CONTRIB_REPO_DIR)/modules
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DCMAKE_C_COMPILER_LAUNCHER=ccache
$(REPO_DIR)
workingDirectory: $(BUILD_DIR)
- script: ls -alR $(REPO_DIR)/inference-engine/temp/
displayName: 'List temp SDKs'
- script: ninja
- script: ccache --zero-stats --max-size=1T --show-config
displayName: 'Clean ccache stats'
- script: |
export CCACHE_DIR=$(CCACHE_DIR)
export CCACHE_TEMPDIR=$(TMP_DIR)/ccache
ninja
workingDirectory: $(BUILD_DIR)
displayName: 'Build Lin'
- script: ccache --show-stats
displayName: 'Show ccache stats'
- script: ls -alR $(REPO_DIR)/bin/
displayName: 'List bin files'
@ -174,10 +216,12 @@ jobs:
- script: $(INSTALL_DIR)/samples/cpp/build_samples.sh
workingDirectory: $(BUILD_SAMPLES_DIR)
displayName: 'Build cpp samples'
condition: eq(variables['CMAKE_BUILD_SHARED_LIBS'], 'ON')
- script: $(INSTALL_DIR)/samples/c/build_samples.sh
workingDirectory: $(BUILD_SAMPLES_DIR)
displayName: 'Build c samples'
condition: eq(variables['CMAKE_BUILD_SHARED_LIBS'], 'ON')
- script: rm -fr $(BUILD_DIR)
displayName: 'Clean build dir'
@ -187,13 +231,13 @@ jobs:
- script: |
export DATA_PATH=$(MODELS_PATH)
export MODELS_PATH=$(MODELS_PATH)
. $(SETUPVARS) -pyver 3.8 && python3 -m pytest -s $(INSTALL_TEST_DIR)/pyngraph --junitxml=TEST-Pyngraph.xml --ignore=$(INSTALL_TEST_DIR)/pyngraph/tests/test_onnx/test_zoo_models.py --ignore=$(INSTALL_TEST_DIR)/pyngraph/tests/test_onnx/test_backend.py
. $(SETUPVARS) -pyver 3.8 && python3 -m pytest -s $(INSTALL_TEST_DIR)/pyngraph $(PYTHON_STATIC_ARGS) --junitxml=TEST-Pyngraph.xml --ignore=$(INSTALL_TEST_DIR)/pyngraph/tests/test_onnx/test_zoo_models.py --ignore=$(INSTALL_TEST_DIR)/pyngraph/tests/test_onnx/test_backend.py
displayName: 'nGraph Python Bindings Tests'
continueOnError: false
- script: |
export MO_ROOT=$(INSTALL_DIR)/tools/model_optimizer
. $(SETUPVARS) -pyver 3.8 && python3 -m pytest -s $(INSTALL_DIR)/tools/model_optimizer/unit_tests --junitxml=TEST-ModelOptimizer.xml
. $(SETUPVARS) -pyver 3.8 && python3 -m pytest -s $(INSTALL_DIR)/tests/model_optimizer/unit_tests --junitxml=TEST-ModelOptimizer.xml
displayName: 'Model Optimizer UT'
continueOnError: false
@ -226,6 +270,7 @@ jobs:
- script: . $(SETUPVARS) && $(INSTALL_TEST_DIR)/gnaUnitTests --gtest_output=xml:TEST-gnaUnitTests.xml
displayName: 'GNA UT'
continueOnError: false
condition: eq(variables['CMAKE_BUILD_SHARED_LIBS'], 'ON')
- script: . $(SETUPVARS) && $(INSTALL_TEST_DIR)/vpuUnitTests --gtest_output=xml:TEST-vpuUnitTests.xml
displayName: 'VPU UT'
@ -246,6 +291,7 @@ jobs:
- script: . $(SETUPVARS) && $(INSTALL_TEST_DIR)/cpuFuncTests --gtest_filter=*smoke* --gtest_print_time=1 --gtest_output=xml:TEST-cpuFuncTests.xml
displayName: 'CPU FuncTests'
continueOnError: false
condition: eq(variables['CMAKE_BUILD_SHARED_LIBS'], 'OFF')
- script: |
export DATA_PATH=$(MODELS_PATH)
@ -258,7 +304,7 @@ jobs:
export DATA_PATH=$(MODELS_PATH)
export MODELS_PATH=$(MODELS_PATH)
cd $(REPO_DIR)/inference-engine/ie_bridges/python/tests
. $(SETUPVARS) -pyver 3.8 && python3 -m pytest --junitxml=TEST-PythonAPI.xml
. $(SETUPVARS) -pyver 3.8 && python3 -m pytest --junitxml=TEST-PythonAPI.xml $(PYTHON_STATIC_ARGS)
displayName: 'Python API Tests'
continueOnError: false

View File

@ -1,3 +1,12 @@
trigger:
branches:
include:
- master
- releases/*
paths:
exclude:
- docs/*
jobs:
- job: LinCC
# About 150% of total time

View File

@ -43,8 +43,6 @@ jobs:
rm -rf $(WORK_DIR) ; mkdir $(WORK_DIR)
rm -rf $(BUILD_DIR) ; mkdir $(BUILD_DIR)
rm -rf $(BUILD_SAMPLES_DIR) ; mkdir $(BUILD_SAMPLES_DIR)
echo TargetBranch: $(System.PullRequest.TargetBranch)
echo SourceBranch: $(Build.SourceBranch)
displayName: 'Make dir'
- checkout: self
@ -89,7 +87,7 @@ jobs:
- script: $(WORK_DIR)/cov-analysis*/bin/cov-build --dir $(BUILD_DIR)/cov-int ninja
workingDirectory: $(BUILD_DIR)
displayName: 'Build Lin with Coverity'
- script: ls -alR $(REPO_DIR)/bin/
displayName: 'List bin files'

View File

@ -60,8 +60,6 @@ jobs:
rm -rf $(WORK_DIR) ; mkdir $(WORK_DIR)
rm -rf $(BUILD_DIR) ; mkdir $(BUILD_DIR)
rm -rf $(BUILD_SAMPLES_DIR) ; mkdir $(BUILD_SAMPLES_DIR)
echo TargetBranch: $(System.PullRequest.TargetBranch)
echo SourceBranch: $(Build.SourceBranch)
displayName: 'Make dir'
- checkout: self

View File

@ -1,14 +1,21 @@
trigger:
branches:
include:
- master
- releases/*
paths:
exclude:
- docs/*
jobs:
- job: OpenVINO_ONNX_CI
strategy:
matrix:
Release:
BUILD_TYPE: 'Release'
PROTOBUF_LITE: 'ON'
TOX_COMMAND: 'tox && tox -e zoo_models'
Debug:
BUILD_TYPE: 'Debug'
PROTOBUF_LITE: 'ON'
TOX_COMMAND: 'tox'
maxParallel: 2
@ -77,10 +84,10 @@ jobs:
condition: ne(variables['BUILD_TYPE'], 'Debug')
- script: sudo docker build --tag=openvino-onnx-ci-image --file=.ci/openvino-onnx/Dockerfile --build-arg BUILD_TYPE=$(BUILD_TYPE) --build-arg PROTOBUF_LITE=$(PROTOBUF_LITE) .
displayName: 'Docker build $(BUILD_TYPE) protobuf-lite: $(PROTOBUF_LITE)'
displayName: 'Docker build $(BUILD_TYPE)'
- script: sudo fallocate -l 64G /swapfile ; sudo mkswap /swapfile ; sudo swapon /swapfile ; df ; free -h
displayName: 'Create swap'
- script: sudo docker run --name openvino-onnx-ci-container --volume $(MODELS_DIR)/models_data/model_zoo/onnx_model_zoo_$(ONNX_MODEL_ZOO_SHA):/root/.onnx/model_zoo/onnx_model_zoo --volume $(MODELS_DIR)/msft:/root/.onnx/model_zoo/MSFT openvino-onnx-ci-image /bin/bash -c "$(TOX_COMMAND)"
displayName: 'Docker run $(BUILD_TYPE) protobuf-lite: $(PROTOBUF_LITE)'
displayName: 'Docker run $(BUILD_TYPE)'

View File

@ -1,3 +1,11 @@
trigger:
branches:
include:
- releases/*
paths:
exclude:
- docs/*
jobs:
- job: onnxruntime
timeoutInMinutes: 90

View File

@ -1,3 +1,12 @@
trigger:
branches:
include:
- master
- releases/*
paths:
exclude:
- docs/*
resources:
repositories:
- repository: openvino_contrib

View File

@ -1,3 +1,12 @@
trigger:
branches:
include:
- master
- releases/*
paths:
exclude:
- docs/*
resources:
repositories:
- repository: openvino_contrib
@ -12,6 +21,14 @@ resources:
jobs:
- job: Win
strategy:
matrix:
Dynamic:
CMAKE_BUILD_SHARED_LIBS: 'ON'
Static:
CMAKE_BUILD_SHARED_LIBS: 'OFF'
maxParallel: 2
# About 150% of total time
timeoutInMinutes: 120
@ -102,7 +119,7 @@ jobs:
- script: |
set PATH=$(WORK_DIR)\ninja-win;%PATH%
call "$(MSVS_VARS_PATH)" && cmake -GNinja -DENABLE_REQUIREMENTS_INSTALL=OFF -DENABLE_FASTER_BUILD=ON -DENABLE_TEMPLATE_PLUGIN=ON -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DENABLE_TESTS=ON -DENABLE_STRICT_DEPENDENCIES=OFF -DENABLE_PYTHON=ON -DPYTHON_EXECUTABLE="C:\hostedtoolcache\windows\Python\3.7.6\x64\python.exe" -DIE_EXTRA_MODULES=$(OPENVINO_CONTRIB_REPO_DIR)\modules -DCMAKE_C_COMPILER:PATH="$(MSVC_COMPILER_PATH)" -DCMAKE_CXX_COMPILER:PATH="$(MSVC_COMPILER_PATH)" $(REPO_DIR)
call "$(MSVS_VARS_PATH)" && cmake -GNinja -DENABLE_CLDNN=$(CMAKE_BUILD_SHARED_LIBS) -DENABLE_GAPI_PREPROCESSING=$(CMAKE_BUILD_SHARED_LIBS) -DBUILD_SHARED_LIBS=$(CMAKE_BUILD_SHARED_LIBS) -DENABLE_REQUIREMENTS_INSTALL=OFF -DENABLE_FASTER_BUILD=ON -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DENABLE_TESTS=ON -DENABLE_STRICT_DEPENDENCIES=OFF -DENABLE_PYTHON=ON -DPYTHON_EXECUTABLE="C:\hostedtoolcache\windows\Python\3.7.6\x64\python.exe" -DIE_EXTRA_MODULES=$(OPENVINO_CONTRIB_REPO_DIR)\modules -DCMAKE_C_COMPILER:PATH="$(MSVC_COMPILER_PATH)" -DCMAKE_CXX_COMPILER:PATH="$(MSVC_COMPILER_PATH)" $(REPO_DIR)
workingDirectory: $(BUILD_DIR)
displayName: 'CMake'
@ -135,10 +152,12 @@ jobs:
- script: $(INSTALL_DIR)\samples\cpp\build_samples_msvc.bat
workingDirectory: $(BUILD_SAMPLES_DIR)
displayName: 'Build cpp samples'
condition: eq(variables['CMAKE_BUILD_SHARED_LIBS'], 'ON')
- script: $(INSTALL_DIR)\samples\c\build_samples_msvc.bat
workingDirectory: $(BUILD_SAMPLES_DIR)
displayName: 'Build c samples'
condition: eq(variables['CMAKE_BUILD_SHARED_LIBS'], 'ON')
- script: rd /Q /S $(BUILD_DIR)
displayName: 'Clean build dir'
@ -152,10 +171,12 @@ jobs:
- script: call $(SETUPVARS) && $(INSTALL_TEST_DIR)\paddlepaddle_tests --gtest_print_time=1 --gtest_filter=-backend_api.config_unsupported:*IE_GPU* --gtest_output=xml:TEST-PaddlePaddle.xml
displayName: 'PaddlePaddle Frontend UT'
continueOnError: false
condition: eq(variables['CMAKE_BUILD_SHARED_LIBS'], 'ON')
- script: call $(SETUPVARS) && $(INSTALL_TEST_DIR)\tensorflow_tests --gtest_print_time=1 --gtest_output=xml:TEST-Tensorflow.xml
displayName: 'Tensorflow Frontend UT'
continueOnError: false
condition: eq(variables['CMAKE_BUILD_SHARED_LIBS'], 'ON')
- script: |
set PATH=$(IB_DIR);%PATH%
@ -197,6 +218,7 @@ jobs:
call $(SETUPVARS) && "$(IB_TESTCONSOLE)" $(INSTALL_TEST_DIR)\cpuFuncTests.exe --gtest_filter=*smoke*:-*CompareWithRefs/base_size=16_pre_nms_topn=100_post_nms_topn=100_nms_thresh=0.7_feat_stride=1_min_size=1_ratio*:*smoke_GRUSequenceCommonZeroClip/GRUSequenceTest.CompareWithRefs/mode=CONVERT_TO_TI_MAX_SEQ_LEN_CONST_seq_lengths* --gtest_output=xml:TEST-cpuFuncTests-IB.xml /testlevel=24
displayName: 'CPU FuncTests - IB'
continueOnError: false
condition: eq(variables['CMAKE_BUILD_SHARED_LIBS'], 'OFF')
- script: |
set DATA_PATH=$(MODELS_PATH)

View File

@ -1,3 +1,12 @@
trigger:
branches:
include:
- master
- releases/*
paths:
exclude:
- docs/*
jobs:
- job: WinCC
# About 150% of total time

View File

@ -4,7 +4,6 @@ LABEL version=2021.03.30.1
# Build configuration arguments
ARG BUILD_TYPE=Release
ARG PROTOBUF_LITE=ON
ARG http_proxy
ARG https_proxy
@ -69,8 +68,7 @@ RUN cmake .. \
-DPYTHON_EXECUTABLE=/usr/bin/python3 \
-DNGRAPH_ONNX_FRONTEND_ENABLE=ON \
-DOPENVINO_DEBUG_ENABLE=OFF \
-DCMAKE_INSTALL_PREFIX=/openvino/dist \
-DNGRAPH_USE_PROTOBUF_LITE=${PROTOBUF_LITE}
-DCMAKE_INSTALL_PREFIX=/openvino/dist
RUN make -j $(nproc) install
# Run tests via tox

View File

@ -6,9 +6,8 @@ DOCKER_IMAGE_TAG = "openvino-onnx-ci-image"
ONNX_MODEL_ZOO_SHA = "d58213534f2a4d1c4b19ba62b3bb5f544353256e"
BACKEND_CONFIGURATIONS = [
[ name: "Release", build_type: "Release", protobuf_lite : "OFF" ],
[ name: "Debug", build_type: "Debug", protobuf_lite : "OFF" ],
[ name: "Rel_Lite", build_type: "Release", protobuf_lite : "ON" ],
[ name: "Release", build_type: "Release" ],
[ name: "Debug", build_type: "Debug" ],
]
// workaround for aborting previous builds on PR update
@ -111,7 +110,6 @@ def buildDockerImage(Map configuration, String workdir) {
sh """
docker build --tag=${docker_image_tag} \
--build-arg BUILD_TYPE=${configuration.build_type} \
--build-arg PROTOBUF_LITE=${configuration.protobuf_lite} \
--file=.ci/openvino-onnx/Dockerfile \
--build-arg http_proxy=${HTTP_PROXY} \
--build-arg https_proxy=${HTTPS_PROXY} .

View File

@ -85,16 +85,10 @@ include(cmake/test_model_zoo.cmake)
add_subdirectory(thirdparty)
add_subdirectory(openvino)
add_subdirectory(ngraph)
add_subdirectory(runtime)
add_subdirectory(inference-engine)
# for Template plugin
openvino_developer_export_targets(COMPONENT ngraph TARGETS ngraph_backend interpreter_backend)
add_subdirectory(runtime)
add_subdirectory(samples)
include(cmake/extra_modules.cmake)
if(ENABLE_SAMPLES)
add_subdirectory(samples)
endif()
add_subdirectory(model-optimizer)
add_subdirectory(docs)
add_subdirectory(tools)

View File

@ -1,5 +1,5 @@
# OpenVINO™ Toolkit
[![Stable release](https://img.shields.io/badge/version-2021.4.1-green.svg)](https://github.com/openvinotoolkit/openvino/releases/tag/2021.4.1)
[![Stable release](https://img.shields.io/badge/version-2021.4.2-green.svg)](https://github.com/openvinotoolkit/openvino/releases/tag/2021.4.2)
[![Apache License Version 2.0](https://img.shields.io/badge/license-Apache_2.0-green.svg)](LICENSE)
![GitHub branch checks state](https://img.shields.io/github/checks-status/openvinotoolkit/openvino/master?label=GitHub%20checks)
![Azure DevOps builds (branch)](https://img.shields.io/azure-devops/build/openvinoci/b2bab62f-ab2f-4871-a538-86ea1be7d20f/13?label=Public%20CI)

View File

@ -103,17 +103,22 @@ if(THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO")
endif()
if(WIN32 AND X86_64)
#TODO: add target_path to be platform specific as well, to avoid following if
# TODO: add target_path to be platform specific as well, to avoid following if
RESOLVE_DEPENDENCY(TBB
ARCHIVE_WIN "tbb2020_20200415_win.zip"
TARGET_PATH "${TEMP}/tbb"
ENVIRONMENT "TBBROOT"
SHA256 "f1c9b9e2861efdaa01552bd25312ccbc5feeb45551e5f91ae61e29221c5c1479")
RESOLVE_DEPENDENCY(TBBBIND_2_5
ARCHIVE_WIN "tbbbind_2_5_static_win_v1.zip"
TARGET_PATH "${TEMP}/tbbbind_2_5"
ENVIRONMENT "TBBBIND_2_5_ROOT"
SHA256 "a67afeea8cf194f97968c800dab5b5459972908295242e282045d6b8953573c1")
if(ENABLE_TBBBIND_2_5)
RESOLVE_DEPENDENCY(TBBBIND_2_5
ARCHIVE_WIN "tbbbind_2_5_static_win_v1.zip"
TARGET_PATH "${TEMP}/tbbbind_2_5"
ENVIRONMENT "TBBBIND_2_5_ROOT"
SHA256 "a67afeea8cf194f97968c800dab5b5459972908295242e282045d6b8953573c1")
else()
message(WARNING "prebuilt TBBBIND_2_5 is not available.
Build oneTBB from sources and set TBBROOT environment var before OpenVINO cmake configure")
endif()
elseif(ANDROID) # Should be before LINUX due LINUX is detected as well
RESOLVE_DEPENDENCY(TBB
ARCHIVE_ANDROID "tbb2020_20200404_android.tgz"
@ -126,11 +131,16 @@ if(THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO")
TARGET_PATH "${TEMP}/tbb"
ENVIRONMENT "TBBROOT"
SHA256 "95b2f3b0b70c7376a0c7de351a355c2c514b42c4966e77e3e34271a599501008")
RESOLVE_DEPENDENCY(TBBBIND_2_5
ARCHIVE_LIN "tbbbind_2_5_static_lin_v2.tgz"
TARGET_PATH "${TEMP}/tbbbind_2_5"
ENVIRONMENT "TBBBIND_2_5_ROOT"
SHA256 "865e7894c58402233caf0d1b288056e0e6ab2bf7c9d00c9dc60561c484bc90f4")
if(ENABLE_TBBBIND_2_5)
RESOLVE_DEPENDENCY(TBBBIND_2_5
ARCHIVE_LIN "tbbbind_2_5_static_lin_v2.tgz"
TARGET_PATH "${TEMP}/tbbbind_2_5"
ENVIRONMENT "TBBBIND_2_5_ROOT"
SHA256 "865e7894c58402233caf0d1b288056e0e6ab2bf7c9d00c9dc60561c484bc90f4")
else()
message(WARNING "prebuilt TBBBIND_2_5 is not available.
Build oneTBB from sources and set TBBROOT environment var before OpenVINO cmake configure")
endif()
elseif(LINUX AND AARCH64)
RESOLVE_DEPENDENCY(TBB
ARCHIVE_LIN "keembay/tbb2020_38404_kmb_lic.tgz"

View File

@ -208,6 +208,13 @@ endif()
# General flags
macro(ov_install_static_lib target comp)
if(NOT BUILD_SHARED_LIBS)
install(TARGETS ${target} EXPORT OpenVINOTargets
ARCHIVE DESTINATION ${IE_CPACK_ARCHIVE_PATH} COMPONENT ${comp})
endif()
endmacro()
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
@ -235,7 +242,11 @@ endif()
# macro to mark target as conditionally compiled
function(ie_mark_target_as_cc TARGET_NAME)
target_link_libraries(${TARGET_NAME} PRIVATE openvino::conditional_compilation)
set(cc_library openvino::conditional_compilation)
if(TARGET IE::conditional_compilation)
set(cc_library IE::conditional_compilation)
endif()
target_link_libraries(${TARGET_NAME} PRIVATE ${cc_library})
if(NOT (SELECTIVE_BUILD STREQUAL "ON"))
return()

View File

@ -54,8 +54,4 @@ endforeach()
set(IE_PLUGINS_MAP_DEFINITION "${IE_PLUGINS_MAP_DEFINITION}
};\n")
message("${IE_PLUGINS_DECLARATIONS}")
message("${IE_PLUGINS_MAP_DEFINITION}")
configure_file("${IE_PLUGINS_HPP_HEADER_IN}" "${IE_PLUGINS_HPP_HEADER}" @ONLY)

View File

@ -75,6 +75,8 @@ function(ie_add_plugin)
target_compile_definitions(${IE_PLUGIN_NAME} PRIVATE
IE_CREATE_EXTENSION=CreateExtensionShared${IE_PLUGIN_DEVICE_NAME})
endif()
# install static plugins
ov_install_static_lib(${IE_PLUGIN_NAME} core)
endif()
ie_add_vs_version_file(NAME ${IE_PLUGIN_NAME}
@ -113,17 +115,20 @@ function(ie_add_plugin)
# fake dependencies to build in the following order:
# IE -> IE readers -> IE inference plugins -> IE-based apps
if(BUILD_SHARED_LIBS)
if(TARGET ir_ngraph_frontend)
add_dependencies(${IE_PLUGIN_NAME} ir_ngraph_frontend)
if(TARGET ir_ov_frontend)
add_dependencies(${IE_PLUGIN_NAME} ir_ov_frontend)
endif()
if(TARGET inference_engine_ir_v7_reader)
add_dependencies(${IE_PLUGIN_NAME} inference_engine_ir_v7_reader)
endif()
if(TARGET onnx_ngraph_frontend)
add_dependencies(${IE_PLUGIN_NAME} onnx_ngraph_frontend)
if(TARGET onnx_ov_frontend)
add_dependencies(${IE_PLUGIN_NAME} onnx_ov_frontend)
endif()
if(TARGET paddlepaddle_ngraph_frontend)
add_dependencies(${IE_PLUGIN_NAME} paddlepaddle_ngraph_frontend)
if(TARGET paddlepaddle_ov_frontend)
add_dependencies(${IE_PLUGIN_NAME} paddlepaddle_ov_frontend)
endif()
if(TARGET tensorflow_ov_frontend)
add_dependencies(${IE_PLUGIN_NAME} tensorflow_ov_frontend)
endif()
endif()
@ -173,8 +178,9 @@ macro(ie_register_plugins_dynamic)
message(FATAL_ERROR "Please, define MAIN_TARGET")
endif()
# Unregister <device_name>.xml files for plugins from current build tree
set(plugins_to_remove ${IE_REGISTER_POSSIBLE_PLUGINS})
set(plugin_files_local)
set(config_output_file "$<TARGET_FILE_DIR:${IE_REGISTER_MAIN_TARGET}>/plugins.xml")
foreach(plugin IN LISTS plugins_to_remove)
@ -190,6 +196,9 @@ macro(ie_register_plugins_dynamic)
VERBATIM)
endforeach()
# Generate <device_name>.xml files
set(plugin_files_local)
foreach(name IN LISTS PLUGIN_FILES)
string(REPLACE ":" ";" name "${name}")
list(LENGTH name length)
@ -217,6 +226,8 @@ macro(ie_register_plugins_dynamic)
list(APPEND plugin_files_local "${config_file_name}")
endforeach()
# Combine all <device_name>.xml files into plugins.xml
add_custom_command(TARGET ${IE_REGISTER_MAIN_TARGET} POST_BUILD
COMMAND
"${CMAKE_COMMAND}"
@ -229,15 +240,37 @@ macro(ie_register_plugins_dynamic)
VERBATIM)
endmacro()
macro(ie_register_plugins)
if(BUILD_SHARED_LIBS)
ie_register_plugins_dynamic(${ARGN})
endif()
endmacro()
function(ie_target_link_plugins TARGET_NAME)
if(BUILD_SHARED_LIBS)
return()
endif()
foreach(name IN LISTS PLUGIN_FILES)
string(REPLACE ":" ";" name "${name}")
list(LENGTH name length)
if(NOT ${length} EQUAL 2)
message(FATAL_ERROR "Unexpected error, please, contact developer of this script")
endif()
# link plugin to ${TARGET_NAME} static version
list(GET name 1 plugin_name)
target_link_libraries(${TARGET_NAME} PRIVATE ${plugin_name})
endforeach()
endfunction()
#
# ie_register_plugins_static(MAIN_TARGET <main target name>
# POSSIBLE_PLUGINS <list of plugins which can be build by this repo>)
# ie_generate_plugins_hpp()
#
macro(ie_register_plugins_static)
set(options)
set(oneValueArgs MAIN_TARGET)
set(multiValueArgs POSSIBLE_PLUGINS)
cmake_parse_arguments(IE_REGISTER "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
function(ie_generate_plugins_hpp)
if(BUILD_SHARED_LIBS)
return()
endif()
set(device_mapping)
set(device_configs)
@ -266,13 +299,15 @@ macro(ie_register_plugins_static)
if(${device_name}_CONFIG)
list(APPEND device_configs -D "${device_name}_CONFIG=${${device_name}_CONFIG}")
endif()
# link plugin to inference_engine static version
list(GET name 1 plugin_name)
target_link_libraries(${IE_REGISTER_MAIN_TARGET} PRIVATE ${plugin_name})
endforeach()
set(ie_plugins_hpp "${CMAKE_CURRENT_BINARY_DIR}/ie_plugins.hpp")
# add plugins to libraries including ie_plugins.hpp
ie_target_link_plugins(inference_engine)
if(TARGET inference_engine_s)
ie_target_link_plugins(inference_engine_s)
endif()
set(ie_plugins_hpp "${CMAKE_BINARY_DIR}/inference-engine/src/inference_engine/ie_plugins.hpp")
set(plugins_hpp_in "${IEDevScripts_DIR}/plugins/plugins.hpp.in")
add_custom_command(OUTPUT "${ie_plugins_hpp}"
@ -291,30 +326,25 @@ macro(ie_register_plugins_static)
"Generate ie_plugins.hpp for static build"
VERBATIM)
# for some reason dependency on source files does not work
# so, we have to use explicit target and make it dependency for inference_engine
add_custom_target(ie_generate_hpp DEPENDS ${ie_plugins_hpp})
add_dependencies(inference_engine ie_generate_hpp)
# add dependency for object files
get_target_property(sources ${IE_REGISTER_MAIN_TARGET} SOURCES)
get_target_property(sources inference_engine SOURCES)
foreach(source IN LISTS sources)
if("${source}" MATCHES "\\$\\<TARGET_OBJECTS\\:([A-Za-z0-9_]*)\\>")
# object library
set(obj_library ${CMAKE_MATCH_1})
get_target_property(obj_sources ${obj_library} SOURCES)
list(APPEND patched_sources ${obj_sources})
list(APPEND all_sources ${obj_sources})
else()
# usual source
list(APPEND patched_sources ${source})
list(APPEND all_sources ${source})
endif()
endforeach()
set_source_files_properties(${patched_sources} PROPERTIES OBJECT_DEPENDS ${ie_plugins_hpp})
endmacro()
#
# ie_register_plugins(MAIN_TARGET <main target name>
# POSSIBLE_PLUGINS <list of plugins which can be build by this repo>)
#
macro(ie_register_plugins)
if(BUILD_SHARED_LIBS)
ie_register_plugins_dynamic(${ARGN})
else()
ie_register_plugins_static(${ARGN})
endif()
endmacro()
# add dependency on header file generation for all inference_engine source files
set_source_files_properties(${all_sources} PROPERTIES OBJECT_DEPENDS ${ie_plugins_hpp})
endfunction()

View File

@ -1,88 +1,112 @@
# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
function(ie_generate_dev_package_config)
# dummy check that OpenCV is here
find_package(OpenCV QUIET)
# dummy check that OpenCV is here
find_package(OpenCV QUIET)
set(all_dev_targets gflags ie_libraries)
foreach(component IN LISTS openvino_export_components)
export(TARGETS ${${component}} NAMESPACE IE::
APPEND FILE "${CMAKE_BINARY_DIR}/${component}_dev_targets.cmake")
list(APPEND all_dev_targets ${${component}})
endforeach()
add_custom_target(ie_dev_targets ALL DEPENDS ${all_dev_targets})
set(all_dev_targets gflags ie_libraries)
foreach(component IN LISTS openvino_export_components)
# export all targets with prefix and use them during extra modules build
export(TARGETS ${${component}} NAMESPACE IE::
APPEND FILE "${CMAKE_BINARY_DIR}/${component}_dev_targets.cmake")
list(APPEND all_dev_targets ${${component}})
endforeach()
add_custom_target(ie_dev_targets ALL DEPENDS ${all_dev_targets})
configure_package_config_file("${OpenVINO_SOURCE_DIR}/cmake/templates/InferenceEngineDeveloperPackageConfig.cmake.in"
"${CMAKE_BINARY_DIR}/InferenceEngineDeveloperPackageConfig.cmake"
INSTALL_DESTINATION share # not used
PATH_VARS "OpenVINO_SOURCE_DIR;gflags_BINARY_DIR"
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
configure_package_config_file("${OpenVINO_SOURCE_DIR}/cmake/templates/InferenceEngineDeveloperPackageConfig.cmake.in"
"${CMAKE_BINARY_DIR}/InferenceEngineDeveloperPackageConfig.cmake"
INSTALL_DESTINATION share # not used
PATH_VARS "OpenVINO_SOURCE_DIR;gflags_BINARY_DIR"
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
configure_file("${OpenVINO_SOURCE_DIR}/cmake/templates/InferenceEngineConfig-version.cmake.in"
"${CMAKE_BINARY_DIR}/InferenceEngineDeveloperPackageConfig-version.cmake"
@ONLY)
configure_file("${OpenVINO_SOURCE_DIR}/cmake/templates/InferenceEngineConfig-version.cmake.in"
"${CMAKE_BINARY_DIR}/InferenceEngineDeveloperPackageConfig-version.cmake"
@ONLY)
endfunction()
ie_generate_dev_package_config()
#
# Add extra modules
#
function(register_extra_modules)
# post export
openvino_developer_export_targets(COMPONENT inference_engine TARGETS inference_engine)
openvino_developer_export_targets(COMPONENT ngraph TARGETS ngraph)
# post export
openvino_developer_export_targets(COMPONENT inference_engine TARGETS inference_engine)
openvino_developer_export_targets(COMPONENT ngraph TARGETS ngraph)
set(InferenceEngineDeveloperPackage_DIR "${CMAKE_CURRENT_BINARY_DIR}/runtime")
set(InferenceEngineDeveloperPackage_DIR "${CMAKE_CURRENT_BINARY_DIR}/runtime")
function(generate_fake_dev_package)
set(iedevconfig_file "${InferenceEngineDeveloperPackage_DIR}/InferenceEngineDeveloperPackageConfig.cmake")
file(REMOVE "${iedevconfig_file}")
function(generate_fake_dev_package)
set(iedevconfig_file "${InferenceEngineDeveloperPackage_DIR}/InferenceEngineDeveloperPackageConfig.cmake")
file(REMOVE "${iedevconfig_file}")
file(WRITE "${iedevconfig_file}" "\# !! AUTOGENERATED: DON'T EDIT !!\n\n")
file(APPEND "${iedevconfig_file}" "ie_deprecated_no_errors()\n")
file(WRITE "${iedevconfig_file}" "\# !! AUTOGENERATED: DON'T EDIT !!\n\n")
file(APPEND "${iedevconfig_file}" "ie_deprecated_no_errors()\n")
foreach(target IN LISTS ${openvino_export_components})
if(target)
file(APPEND "${iedevconfig_file}" "add_library(IE::${target} ALIAS ${target})\n")
foreach(target IN LISTS ${openvino_export_components})
if(target)
file(APPEND "${iedevconfig_file}" "add_library(IE::${target} ALIAS ${target})\n")
endif()
endforeach()
endfunction()
generate_fake_dev_package()
# automatically import plugins from the 'runtime/plugins' folder
file(GLOB local_extra_modules "runtime/plugins/*")
# add template plugin
if(ENABLE_TEMPLATE)
list(APPEND local_extra_modules "${OpenVINO_SOURCE_DIR}/docs/template_plugin")
endif()
# detect where IE_EXTRA_MODULES contains folders with CMakeLists.txt
# other folders are supposed to have sub-folders with CMakeLists.txt
foreach(module_path IN LISTS IE_EXTRA_MODULES)
if(EXISTS "${module_path}/CMakeLists.txt")
list(APPEND extra_modules "${module_path}")
elseif(module_path)
file(GLOB extra_modules ${extra_modules} "${module_path}/*")
endif()
endforeach()
# add each extra module
foreach(module_path IN LISTS extra_modules local_extra_modules)
if(module_path)
get_filename_component(module_name "${module_path}" NAME)
set(build_module ON)
if(NOT EXISTS "${module_path}/CMakeLists.txt") # if module is built not using cmake
set(build_module OFF)
endif()
if(NOT DEFINED BUILD_${module_name})
set(BUILD_${module_name} ${build_module} CACHE BOOL "Build ${module_name} extra module" FORCE)
endif()
if(BUILD_${module_name})
message(STATUS "Register ${module_name} to be built in build-modules/${module_name}")
add_subdirectory("${module_path}" "build-modules/${module_name}")
endif()
endif()
endforeach()
endfunction()
generate_fake_dev_package()
#
# Extra modules support
#
# automatically import plugins from the 'plugins' folder
file(GLOB local_extra_modules "runtime/plugins/*")
# add template plugin
list(APPEND local_extra_modules "${OpenVINO_SOURCE_DIR}/docs/template_plugin")
# for Template plugin
openvino_developer_export_targets(COMPONENT ngraph TARGETS ngraph_backend interpreter_backend)
# detect where IE_EXTRA_MODULES contains folders with CMakeLists.txt
# other folders are supposed to have sub-folders with CMakeLists.txt
foreach(module_path IN LISTS IE_EXTRA_MODULES)
if(EXISTS "${module_path}/CMakeLists.txt")
list(APPEND extra_modules "${module_path}")
elseif(module_path)
file(GLOB extra_modules ${extra_modules} "${module_path}/*")
endif()
endforeach()
# this InferenceEngineDeveloperPackageConfig.cmake is not used
# during extra modules build since it's generated after modules
# are configured
ie_generate_dev_package_config()
# add each extra module
foreach(module_path IN LISTS extra_modules local_extra_modules)
if(module_path)
get_filename_component(module_name "${module_path}" NAME)
set(build_module ON)
if(NOT EXISTS "${module_path}/CMakeLists.txt") # if module is built not using cmake
set(build_module OFF)
endif()
if(NOT DEFINED BUILD_${module_name})
set(BUILD_${module_name} ${build_module} CACHE BOOL "Build ${module_name} extra module" FORCE)
endif()
if(BUILD_${module_name})
message(STATUS "Register ${module_name} to be built in build-modules/${module_name}")
add_subdirectory("${module_path}" "build-modules/${module_name}")
endif()
endif()
endforeach()
endfunction()
# extra modules must be registered after inference_engine library
# and all other IE common libraries (ie_libraries) are creared
# because 'register_extra_modules' creates fake InferenceEngineDeveloperPackageConfig.cmake
# with all imported developer targets
register_extra_modules()
register_extra_modules()
# for static libraries case we need to generate final ie_plugins.hpp
# with all the information about plugins
ie_generate_plugins_hpp()

View File

@ -14,6 +14,17 @@ ie_option (ENABLE_STRICT_DEPENDENCIES "Skip configuring \"convinient\" dependenc
ie_dependent_option (ENABLE_CLDNN "clDnn based plugin for inference engine" ON "X86_64;NOT APPLE;NOT MINGW;NOT WINDOWS_STORE;NOT WINDOWS_PHONE" OFF)
if (NOT ENABLE_CLDNN OR ANDROID OR
(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0))
# oneDNN doesn't support old compilers and android builds for now, so we'll
# build GPU plugin without oneDNN
set(ENABLE_ONEDNN_FOR_GPU_DEFAULT OFF)
else()
set(ENABLE_ONEDNN_FOR_GPU_DEFAULT ON)
endif()
ie_dependent_option (ENABLE_ONEDNN_FOR_GPU "Enable oneDNN with GPU support" ON "ENABLE_ONEDNN_FOR_GPU_DEFAULT" OFF)
ie_option (ENABLE_PROFILING_ITT "Build with ITT tracing. Optionally configure pre-built ittnotify library though INTEL_VTUNE_DIR variable." OFF)
ie_option_enum(ENABLE_PROFILING_FILTER "Enable or disable ITT counter groups.\
@ -62,6 +73,15 @@ if (NOT THREADING STREQUAL "TBB" AND
message(FATAL_ERROR "THREADING should be set to TBB, TBB_AUTO, OMP or SEQ. Default option is ${THREADING_DEFAULT}")
endif()
if((THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO") AND
(BUILD_SHARED_LIBS OR (LINUX AND X86_64)))
set(ENABLE_TBBBIND_2_5_DEFAULT ON)
else()
set(ENABLE_TBBBIND_2_5_DEFAULT OFF)
endif()
ie_dependent_option (ENABLE_TBBBIND_2_5 "Enable TBBBind_2_5 static usage in OpenVINO runtime" ON "ENABLE_TBBBIND_2_5_DEFAULT" OFF)
if (ENABLE_GNA)
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.4)
set (DEFAULT_GNA_LIB GNA1)
@ -86,17 +106,21 @@ endif()
ie_option (ENABLE_IR_V7_READER "Enables IR v7 reader" ${ENABLE_IR_V7_READER_DEFAULT})
ie_option (ENABLE_GAPI_PREPROCESSING "Enables G-API preprocessing" ON)
ie_option (ENABLE_MULTI "Enables Multi Device Plugin" ON)
ie_option (ENABLE_HETERO "Enables Hetero Device Plugin" ON)
ie_option (ENABLE_TEMPLATE "Enable template plugin" ON)
ie_dependent_option (ENABLE_VPU "vpu targeted plugins for inference engine" ON "NOT WINDOWS_PHONE;NOT WINDOWS_STORE" OFF)
ie_dependent_option (ENABLE_MYRIAD "myriad targeted plugin for inference engine" ON "ENABLE_VPU" OFF)
ie_dependent_option (ENABLE_MYRIAD_NO_BOOT "myriad plugin will skip device boot" OFF "ENABLE_MYRIAD" OFF)
ie_dependent_option (ENABLE_GAPI_TESTS "tests for GAPI kernels" ON "ENABLE_TESTS" OFF)
ie_dependent_option (ENABLE_GAPI_TESTS "tests for GAPI kernels" ON "ENABLE_GAPI_PREPROCESSING;ENABLE_TESTS" OFF)
ie_dependent_option (GAPI_TEST_PERF "if GAPI unit tests should examine performance" OFF "ENABLE_GAPI_TESTS" OFF)
@ -118,7 +142,7 @@ set(IE_EXTRA_MODULES "" CACHE STRING "Extra paths for extra modules to include i
ie_dependent_option(ENABLE_TBB_RELEASE_ONLY "Only Release TBB libraries are linked to the Inference Engine binaries" ON "THREADING MATCHES TBB;LINUX" OFF)
ie_option (ENABLE_SYSTEM_PUGIXML "use the system copy of pugixml" OFF)
ie_dependent_option (ENABLE_SYSTEM_PUGIXML "use the system copy of pugixml" OFF "BUILD_SHARED_LIBS" OFF)
ie_option (ENABLE_DEBUG_CAPS "enable OpenVINO debug capabilities at runtime" OFF)
@ -136,8 +160,6 @@ ie_dependent_option(NGRAPH_ONNX_FRONTEND_ENABLE "Enable ONNX FrontEnd" ON "proto
ie_dependent_option(NGRAPH_PDPD_FRONTEND_ENABLE "Enable PaddlePaddle FrontEnd" ON "protoc_available" OFF)
ie_option(NGRAPH_IR_FRONTEND_ENABLE "Enable IR FrontEnd" ON)
ie_dependent_option(NGRAPH_TF_FRONTEND_ENABLE "Enable TensorFlow FrontEnd" ON "protoc_available" OFF)
ie_dependent_option(NGRAPH_USE_PROTOBUF_LITE "Compiles and links with protobuf-lite" ON
"NGRAPH_ONNX_FRONTEND_ENABLE" OFF)
ie_dependent_option(NGRAPH_USE_SYSTEM_PROTOBUF "Use system protobuf" OFF
"NGRAPH_ONNX_FRONTEND_ENABLE OR NGRAPH_PDPD_FRONTEND_ENABLE OR NGRAPH_TF_FRONTEND_ENABLE" OFF)
ie_dependent_option(NGRAPH_UNIT_TEST_ENABLE "Enables ngraph unit tests" ON "ENABLE_TESTS;NOT ANDROID" OFF)

View File

@ -160,8 +160,20 @@ if(THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO" AND NOT TBB_FOUND)
${_tbb_dir}
NO_CMAKE_FIND_ROOT_PATH
NO_DEFAULT_PATH)
set(install_tbbbind "@install_tbbbind@")
if(install_tbbbind)
set_and_check(_tbb_bind_dir "@PACKAGE_IE_TBBBIND_DIR@")
_ov_find_dependency(TBBBIND_2_5
PATHS ${_tbb_bind_dir}
NO_CMAKE_FIND_ROOT_PATH
NO_DEFAULT_PATH)
set_target_properties(${TBBBIND_2_5_IMPORTED_TARGETS} PROPERTIES IMPORTED_GLOBAL ON)
endif()
endif()
_ov_find_dependency(Threads)
if(NOT TARGET inference_engine)
set(_ov_as_external_package ON)
include("${CMAKE_CURRENT_LIST_DIR}/OpenVINOTargets.cmake")

View File

@ -28,11 +28,11 @@
#
# ngraph::frontend_manager - nGraph frontend manager
#
# ngraph_onnx_ngraph_frontend_FOUND - True if the system has onnx_ngraph_frontend library
# ngraph::onnx_ngraph_frontend - ONNX FrontEnd target (optional)
# ngraph_onnx_ov_frontend_FOUND - True if the system has onnx_ov_frontend library
# ngraph::onnx_ov_frontend - ONNX FrontEnd target (optional)
#
# ngraph_paddlepaddle_frontend_FOUND - True if the system has PDPD frontend
# ngraph::paddlepaddle_ngraph_frontend - nGraph PDPD frontend (optional)
# ngraph::paddlepaddle_ov_frontend - nGraph PDPD frontend (optional)
#
@PACKAGE_INIT@
@ -58,38 +58,38 @@ if(TARGET openvino::frontend::manager AND NOT TARGET ngraph::frontend_manager)
INTERFACE_LINK_LIBRARIES openvino::frontend::manager)
endif()
if(TARGET openvino::frontend::onnx AND NOT TARGET ngraph::onnx_ngraph_frontend)
add_library(ngraph::onnx_ngraph_frontend INTERFACE IMPORTED)
set_target_properties(ngraph::onnx_ngraph_frontend PROPERTIES
if(TARGET openvino::frontend::onnx AND NOT TARGET ngraph::onnx_ov_frontend)
add_library(ngraph::onnx_ov_frontend INTERFACE IMPORTED)
set_target_properties(ngraph::onnx_ov_frontend PROPERTIES
INTERFACE_LINK_LIBRARIES openvino::frontend::onnx)
endif()
if(TARGET openvino::frontend::paddlepaddle AND NOT TARGET ngraph::paddlepaddle_ngraph_frontend)
add_library(ngraph::paddlepaddle_ngraph_frontend INTERFACE IMPORTED)
set_target_properties(ngraph::paddlepaddle_ngraph_frontend PROPERTIES
if(TARGET openvino::frontend::paddlepaddle AND NOT TARGET ngraph::paddlepaddle_ov_frontend)
add_library(ngraph::paddlepaddle_ov_frontend INTERFACE IMPORTED)
set_target_properties(ngraph::paddlepaddle_ov_frontend PROPERTIES
INTERFACE_LINK_LIBRARIES openvino::frontend::paddlepaddle)
endif()
if(TARGET openvino::frontend::tensorflow AND NOT TARGET ngraph::tensorflow_ngraph_frontend)
add_library(ngraph::tensorflow_ngraph_frontend INTERFACE IMPORTED)
set_target_properties(ngraph::tensorflow_ngraph_frontend PROPERTIES
if(TARGET openvino::frontend::tensorflow AND NOT TARGET ngraph::tensorflow_ov_frontend)
add_library(ngraph::tensorflow_ov_frontend INTERFACE IMPORTED)
set_target_properties(ngraph::tensorflow_ov_frontend PROPERTIES
INTERFACE_LINK_LIBRARIES openvino::frontend::tensorflow)
endif()
set(ngraph_ngraph_FOUND ON)
set(NGRAPH_LIBRARIES ngraph::ngraph)
set(ngraph_onnx_ngraph_frontend_FOUND ${OpenVINO_Frontend_ONNX_FOUND})
set(ngraph_onnx_ov_frontend_FOUND ${OpenVINO_Frontend_ONNX_FOUND})
set(ngraph_onnx_importer_FOUND ${OpenVINO_Frontend_ONNX_FOUND})
if(ngraph_onnx_importer_FOUND)
set(ONNX_IMPORTER_LIBRARIES ngraph::onnx_ngraph_frontend)
set(ONNX_IMPORTER_LIBRARIES ngraph::onnx_ov_frontend)
# ngraph::onnx_importer target and variables are deprecated
# but need to create a dummy target for BW compatibility
if(NOT TARGET ngraph::onnx_importer)
add_library(ngraph::onnx_importer INTERFACE IMPORTED)
set_target_properties(ngraph::onnx_importer PROPERTIES
INTERFACE_LINK_LIBRARIES ngraph::onnx_ngraph_frontend)
INTERFACE_LINK_LIBRARIES ngraph::onnx_ov_frontend)
endif()
endif()

View File

@ -86,6 +86,11 @@ ov_model_convert("${OpenVINO_SOURCE_DIR}/${rel_path}"
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_model_zoo/onnx_import"
ie_onnx_import_out_files)
set(rel_path "docs/onnx_custom_op")
ov_model_convert("${OpenVINO_SOURCE_DIR}/${rel_path}"
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_model_zoo/docs/models"
docs_onnx_out_files)
if(ENABLE_TESTS)
if(NGRAPH_ONNX_FRONTEND_ENABLE AND ENABLE_REQUIREMENTS_INSTALL)
find_package(PythonInterp 3 REQUIRED)
@ -124,13 +129,14 @@ if(ENABLE_TESTS)
${ft_out_files}
${ie_onnx_out_files}
${ie_serialize_out_files}
${ie_onnx_import_out_files})
${ie_onnx_import_out_files}
${docs_onnx_out_files})
if(TARGET test_pip_prerequsites)
add_dependencies(test_model_zoo test_pip_prerequsites)
endif()
if (NGRAPH_PDPD_FRONTEND_ENABLE)
if (NGRAPH_PDPD_FRONTEND_ENABLE AND NGRAPH_UNIT_TEST_ENABLE)
add_dependencies(test_model_zoo paddlepaddle_test_models)
endif()

View File

@ -17,5 +17,8 @@ macro(_set_if_not_defined var val)
endif()
endmacro()
# for ittapi
_set_if_not_defined(FORCE_32 ON)
# need libusb 32-bits version
_set_if_not_defined(ENABLE_VPU OFF)

View File

@ -29,6 +29,8 @@ onecoreuap_set_runtime(STATIC_CRT)
onecoreuap_set_runtime(protobuf_MSVC_STATIC_RUNTIME)
# clDNN
onecoreuap_set_runtime(CLDNN__COMPILE_LINK_USE_STATIC_RUNTIME)
# OpenCL
onecoreuap_set_runtime(USE_DYNAMIC_VCXX_RUNTIME)
# google-test
if(use_static_runtime)
set(gtest_force_shared_crt OFF CACHE BOOL "" FORCE)

View File

@ -23,8 +23,8 @@ if(NOT ENABLE_DOCKER)
add_subdirectory(template_extension)
set(all_docs_targets
ie_docs_snippets
template_extension templatePlugin templateFuncTests)
ie_docs_snippets templateFuncTests
template_extension template_ov_extension templatePlugin)
foreach(target_name IN LISTS all_docs_targets)
if(TARGET ${target_name})
set_target_properties(${target_name} PROPERTIES FOLDER docs)
@ -36,8 +36,14 @@ if(NOT ENABLE_DOCKER)
# install
install(TARGETS templatePlugin template_extension template_ov_extension
LIBRARY DESTINATION ${IE_CPACK_RUNTIME_PATH} COMPONENT tests EXCLUDE_FROM_ALL)
foreach(target templatePlugin template_extension template_ov_extension)
if(TARGET ${target})
install(TARGETS ${target}
LIBRARY DESTINATION ${IE_CPACK_RUNTIME_PATH}
COMPONENT tests
EXCLUDE_FROM_ALL)
endif()
endforeach()
endif()
set(OMZ_DOCS_DIR "" CACHE PATH "Path to open_model_zoo documentation")

View File

@ -60,7 +60,7 @@ Low-Precision 8-bit integer models cannot be converted to BF16, even if bfloat16
Bfloat16 simulation mode is available on CPU and Intel® AVX-512 platforms that do not support the native `avx512_bf16` instruction. The simulator does not guarantee an adequate performance.
To enable Bfloat16 simulator:
* In [Benchmark App](../../inference-engine/samples/benchmark_app/README.md), add the `-enforcebf16=true` option
* In [Benchmark App](../../samples/cpp/benchmark_app/README.md), add the `-enforcebf16=true` option
* In C++ API, set `KEY_ENFORCE_BF16` to `YES`
* In C API:
```

View File

@ -40,13 +40,13 @@ This library contains the classes to:
Starting from 2022.1 release, OpenVINO Runtime introduced a concept of frontend plugins. Such plugins can be automatically dynamically loaded by OpenVINO Runtime dynamically depending on file format:
* Linux* OS:
- `libir_ngraph_frontend.so` to read a network from IR
- `libpaddlepaddle_ngraph_frontend.so` to read a network from PaddlePaddle model format
- `libonnx_ngraph_frontend.so` to read a network from ONNX model format
- `libir_ov_frontend.so` to read a network from IR
- `libpaddlepaddle_ov_frontend.so` to read a network from PaddlePaddle model format
- `libonnx_ov_frontend.so` to read a network from ONNX model format
* Windows* OS:
- `ir_ngraph_frontend.dll` to read a network from IR
- `paddlepaddle_ngraph_frontend.dll` to read a network from PaddlePaddle model format
- `onnx_ngraph_frontend.dll` to read a network from ONNX model format
- `ir_ov_frontend.dll` to read a network from IR
- `paddlepaddle_ov_frontend.dll` to read a network from PaddlePaddle model format
- `onnx_ov_frontend.dll` to read a network from ONNX model format
### Device-Specific Plugin Libraries

View File

@ -26,7 +26,18 @@ New operator registration must happen before an ONNX model is read. For example,
Reregistering ONNX operators within the same process is supported. If you register an existing operator, you get a warning.
The example below demonstrates an exemplary model that requires a previously created `CustomRelu` operator:
@snippet onnx_custom_op/onnx_custom_op.cpp onnx_custom_op:model
@include onnx_custom_op/custom_relu_model.prototxt
This model is in text format, so before it can be passed to Inference Engine, it has to be converted to binary using:
```py
from google.protobuf import text_format
import onnx
with open("custom_relu_model.prototxt") as in_file:
proto = onnx.ModelProto()
text_format.Parse(in_file.read(), proto, allow_field_number=True)
s = onnx._serialize(proto)
onnx._save_bytes(s, "custom_relu_model.onnx")
```
To create a graph with nGraph operations, visit [Custom nGraph Operations](AddingNGraphOps.md).
@ -51,7 +62,7 @@ The example below demonstrates how to unregister an operator from the destructor
## Requirements for Building with CMake
A program that uses the `register_operator` functionality requires `openvino::core` and `openvino::frontend::onnx` libraries in addition to the OpenVINO Inference Runtime.
The `onnx_ngraph_frontend` is a component of the `OpenVINO` package , so `find_package(OpenVINO REQUIRED COMPONENTS ONNX)` can find both.
The `onnx_ov_frontend` is a component of the `OpenVINO` package , so `find_package(OpenVINO REQUIRED COMPONENTS ONNX)` can find both.
Those libraries need to be passed to the `target_link_libraries` command in the CMakeLists.txt file.
See CMakeLists.txt below for reference:

View File

@ -45,4 +45,4 @@ The following pages describe how to integrate custom _kernels_ into the Inferenc
* [Build an extension library using CMake*](Building.md)
* [Using Inference Engine Samples](../Samples_Overview.md)
* [Hello Shape Infer SSD sample](../../../inference-engine/samples/hello_reshape_ssd/README.md)
* [Hello Shape Infer SSD sample](../../../samples/cpp/hello_reshape_ssd/README.md)

View File

@ -2,7 +2,7 @@ Introduction to Inference Engine Device Query API {#openvino_docs_IE_DG_Inferenc
===============================
This section provides a high-level description of the process of querying of different device properties and configuration values.
Refer to the [Hello Query Device Sample](../../inference-engine/samples/hello_query_device/README.md) sources and [Multi-Device Plugin guide](supported_plugins/MULTI.md) for example of using the Inference Engine Query API in user applications.
Refer to the [Hello Query Device Sample](../../samples/cpp/hello_query_device/README.md) sources and [Multi-Device Plugin guide](supported_plugins/MULTI.md) for example of using the Inference Engine Query API in user applications.
## Using the Inference Engine Query API in Your Code
@ -71,10 +71,6 @@ Or the current temperature of `MYRIAD` device:
@snippet snippets/InferenceEngine_QueryAPI4.cpp part4
The code below demonstrates how to get memory statistics of `GPU` device:
@snippet snippets/InferenceEngine_QueryAPI6.cpp part6
### GetConfig()
The method is used to get information about configuration values the executable network has been created with:

View File

@ -41,7 +41,7 @@ After that, you should quantize the model by the [Model Quantizer](@ref omz_tool
## Inference
The simplest way to infer the model and collect performance counters is the [C++ Benchmark Application](../../inference-engine/samples/benchmark_app/README.md).
The simplest way to infer the model and collect performance counters is the [C++ Benchmark Application](../../samples/cpp/benchmark_app/README.md).
```sh
./benchmark_app -m resnet-50-tf.xml -d CPU -niter 1 -api sync -report_type average_counters -report_folder pc_report_dir
```

View File

@ -2,7 +2,7 @@ Integrate the Inference Engine with Your Application {#openvino_docs_IE_DG_Integ
===============================
This section provides a high-level description of the process of integrating the Inference Engine into your application.
Refer to the [Hello Classification Sample](../../inference-engine/samples/hello_classification/README.md) sources
Refer to the [Hello Classification Sample](../../samples/cpp/hello_classification/README.md) sources
for example of using the Inference Engine in applications.
## Use the Inference Engine API in Your Code
@ -73,7 +73,7 @@ methods:
> Inference Engine expects two separate image planes (Y and UV). You must use a specific
> `InferenceEngine::NV12Blob` object instead of default blob object and set this blob to
> the Inference Engine Infer Request using `InferenceEngine::InferRequest::SetBlob()`.
> Refer to [Hello NV12 Input Classification C++ Sample](../../inference-engine/samples/hello_nv12_input_classification/README.md)
> Refer to [Hello NV12 Input Classification C++ Sample](../../samples/cpp/hello_nv12_input_classification/README.md)
> for more details.
If you skip this step, the default values are set:
@ -209,6 +209,6 @@ It's allowed to specify additional build options (e.g. to build CMake project on
### Run Your Application
Before running, make sure you completed **Set the Environment Variables** section in [OpenVINO Installation](../../inference-engine/samples/hello_nv12_input_classification/README.md) document so that the application can find the libraries.
Before running, make sure you completed **Set the Environment Variables** section in [OpenVINO Installation](../../samples/cpp/hello_nv12_input_classification/README.md) document so that the application can find the libraries.
[integration_process]: img/integration_process.png

View File

@ -29,7 +29,7 @@ Refer to the ENABLE_FP16_FOR_QUANTIZED_MODELS key in the [GPU Plugin documentati
One way to increase computational efficiency is batching, which combines many (potentially tens) of
input images to achieve optimal throughput. However, high batch size also comes with a
latency penalty. So, for more real-time oriented usages, lower batch sizes (as low as a single input) are used.
Refer to the [Benchmark App](../../inference-engine/samples/benchmark_app/README.md) sample, which allows latency vs. throughput measuring.
Refer to the [Benchmark App](../../samples/cpp/benchmark_app/README.md) sample, which allows latency vs. throughput measuring.
## Using Caching API for first inference latency optimization
Since with the 2021.4 release, Inference Engine provides an ability to enable internal caching of loaded networks.
@ -42,7 +42,7 @@ To gain better performance on accelerators, such as VPU, the Inference Engine us
[Integrating Inference Engine in Your Application (current API)](Integrate_with_customer_application_new_API.md)).
The point is amortizing the costs of data transfers, by pipe-lining, see [Async API explained](@ref omz_demos_object_detection_demo_cpp).
Since the pipe-lining relies on the availability of the parallel slack, running multiple inference requests in parallel is essential.
Refer to the [Benchmark App](../../inference-engine/samples/benchmark_app/README.md) sample, which enables running a number of inference requests in parallel. Specifying different number of request produces different throughput measurements.
Refer to the [Benchmark App](../../samples/cpp/benchmark_app/README.md) sample, which enables running a number of inference requests in parallel. Specifying different number of request produces different throughput measurements.
## Best Latency on the Multi-Socket CPUs
Note that when latency is of concern, there are additional tips for multi-socket systems.
@ -70,7 +70,7 @@ OpenVINO™ toolkit provides a "throughput" mode that allows running multiple in
Internally, the execution resources are split/pinned into execution "streams".
Using this feature gains much better performance for the networks that originally are not scaled well with a number of threads (for example, lightweight topologies). This is especially pronounced for the many-core server machines.
Run the [Benchmark App](../../inference-engine/samples/benchmark_app/README.md) and play with number of infer requests running in parallel, next section.
Run the [Benchmark App](../../samples/cpp/benchmark_app/README.md) and play with number of infer requests running in parallel, next section.
Try different values of the `-nstreams` argument from `1` to a number of CPU cores and find one that provides the best performance.
The throughput mode relaxes the requirement to saturate the CPU by using a large batch: running multiple independent inference requests in parallel often gives much better performance, than using a batch only.
@ -78,7 +78,7 @@ This allows you to simplify the app-logic, as you don't need to combine multiple
Instead, it is possible to keep a separate infer request per camera or another source of input and process the requests in parallel using Async API.
## Benchmark App
[Benchmark App](../../inference-engine/samples/benchmark_app/README.md) sample is the best performance reference.
[Benchmark App](../../samples/cpp/benchmark_app/README.md) sample is the best performance reference.
It has a lot of device-specific knobs, but the primary usage is as simple as:
```bash
$ ./benchmark_app d GPU m <model> -i <input>

View File

@ -10,35 +10,35 @@ After installation of Intel® Distribution of OpenVINO™ toolkit, С, C++ and P
Inference Engine sample applications include the following:
- **Speech Sample** - Acoustic model inference based on Kaldi neural networks and speech feature vectors.
- [Automatic Speech Recognition C++ Sample](../../inference-engine/samples/speech_sample/README.md)
- [Automatic Speech Recognition C++ Sample](../../samples/cpp/speech_sample/README.md)
- [Automatic Speech Recognition Python Sample](../../samples/python/speech_sample/README.md)
- **Benchmark Application** Estimates deep learning inference performance on supported devices for synchronous and asynchronous modes.
- [Benchmark C++ Tool](../../inference-engine/samples/benchmark_app/README.md)
- [Benchmark C++ Tool](../../samples/cpp/benchmark_app/README.md)
- [Benchmark Python Tool](../../tools/benchmark_tool/README.md)
- **Hello Classification Sample** Inference of image classification networks like AlexNet and GoogLeNet using Synchronous Inference Request API. Input of any size and layout can be set to an infer request which will be pre-processed automatically during inference (the sample supports only images as inputs and supports Unicode paths).
- [Hello Classification C++ Sample](../../inference-engine/samples/hello_classification/README.md)
- [Hello Classification C++ Sample](../../samples/cpp/hello_classification/README.md)
- [Hello Classification C Sample](../../samples/c/hello_classification/README.md)
- [Hello Classification Python Sample](../../samples/python/hello_classification/README.md)
- **Hello NV12 Input Classification Sample** Input of any size and layout can be provided to an infer request. The sample transforms the input to the NV12 color format and pre-process it automatically during inference. The sample supports only images as inputs.
- [Hello NV12 Input Classification C++ Sample](../../inference-engine/samples/hello_nv12_input_classification/README.md)
- [Hello NV12 Input Classification C++ Sample](../../samples/cpp/hello_nv12_input_classification/README.md)
- [Hello NV12 Input Classification C Sample](../../samples/c/hello_nv12_input_classification/README.md)
- **Hello Query Device Sample** Query of available Inference Engine devices and their metrics, configuration values.
- [Hello Query Device C++ Sample](../../inference-engine/samples/hello_query_device/README.md)
- [Hello Query Device C++ Sample](../../samples/cpp/hello_query_device/README.md)
- [Hello Query Device Python* Sample](../../samples/python/hello_query_device/README.md)
- **Hello Reshape SSD Sample** Inference of SSD networks resized by ShapeInfer API according to an input size.
- [Hello Reshape SSD C++ Sample**](../../inference-engine/samples/hello_reshape_ssd/README.md)
- [Hello Reshape SSD C++ Sample**](../../samples/cpp/hello_reshape_ssd/README.md)
- [Hello Reshape SSD Python Sample**](../../samples/python/hello_reshape_ssd/README.md)
- **Image Classification Sample Async** Inference of image classification networks like AlexNet and GoogLeNet using Asynchronous Inference Request API (the sample supports only images as inputs).
- [Image Classification Async C++ Sample](../../inference-engine/samples/classification_sample_async/README.md)
- [Image Classification Async C++ Sample](../../samples/cpp/classification_sample_async/README.md)
- [Image Classification Async Python* Sample](../../samples/python/classification_sample_async/README.md)
- **Style Transfer Sample** Style Transfer sample (the sample supports only images as inputs).
- [Style Transfer C++ Sample](../../inference-engine/samples/style_transfer_sample/README.md)
- [Style Transfer C++ Sample](../../samples/cpp/style_transfer_sample/README.md)
- [Style Transfer Python* Sample](../../samples/python/style_transfer_sample/README.md)
- **nGraph Function Creation Sample** Construction of the LeNet network using the nGraph function creation sample.
- [nGraph Function Creation C++ Sample](../../inference-engine/samples/ngraph_function_creation_sample/README.md)
- [nGraph Function Creation C++ Sample](../../samples/cpp/ngraph_function_creation_sample/README.md)
- [nGraph Function Creation Python Sample](../../samples/python/ngraph_function_creation_sample/README.md)
- **Object Detection for SSD Sample** Inference of object detection networks based on the SSD, this sample is simplified version that supports only images as inputs.
- [Object Detection SSD C++ Sample](../../inference-engine/samples/object_detection_sample_ssd/README.md)
- [Object Detection SSD C++ Sample](../../samples/cpp/object_detection_sample_ssd/README.md)
- [Object Detection SSD C Sample](../../samples/c/object_detection_sample_ssd/README.md)
- [Object Detection SSD Python* Sample](../../samples/python/object_detection_sample_ssd/README.md)

View File

@ -45,13 +45,13 @@ This library contains the classes to:
Starting from 2022.1 release, OpenVINO Runtime introduced a concept of frontend plugins. Such plugins can be automatically dynamically loaded by OpenVINO Runtime dynamically depending on file format:
* Unix* OS:
- `libir_ngraph_frontend.so` to read a network from IR
- `libpaddlepaddle_ngraph_frontend.so` to read a network from PaddlePaddle model format
- `libonnx_ngraph_frontend.so` to read a network from ONNX model format
- `libir_ov_frontend.so` to read a network from IR
- `libpaddlepaddle_ov_frontend.so` to read a network from PaddlePaddle model format
- `libonnx_ov_frontend.so` to read a network from ONNX model format
* Windows* OS:
- `ir_ngraph_frontend.dll` to read a network from IR
- `paddlepaddle_ngraph_frontend.dll` to read a network from PaddlePaddle model format
- `onnx_ngraph_frontend.dll` to read a network from ONNX model format
- `ir_ov_frontend.dll` to read a network from IR
- `paddlepaddle_ov_frontend.dll` to read a network from PaddlePaddle model format
- `onnx_ov_frontend.dll` to read a network from ONNX model format
### Device-specific Plugin Libraries ###

View File

@ -48,7 +48,7 @@ Auto-device supports query device optimization capabilities in metric;
### Enumerating Available Devices
Inference Engine now features a dedicated API to enumerate devices and their capabilities.
See [Hello Query Device C++ Sample](../../../inference-engine/samples/hello_query_device/README.md).
See [Hello Query Device C++ Sample](../../../samples/cpp/hello_query_device/README.md).
This is the example output from the sample (truncated to the devices' names only):
```sh

View File

@ -99,7 +99,7 @@ CPU plugin removes a Power layer from a topology if it has the following paramet
The plugin supports the configuration parameters listed below.
All parameters must be set with the <code>InferenceEngine::Core::LoadNetwork()</code> method.
When specifying key values as raw strings (that is, when using Python API), omit the `KEY_` prefix.
Refer to the OpenVINO samples for usage examples: [Benchmark App](../../../inference-engine/samples/benchmark_app/README.md).
Refer to the OpenVINO samples for usage examples: [Benchmark App](../../../samples/cpp/benchmark_app/README.md).
These are general options, also supported by other plugins:

View File

@ -12,7 +12,7 @@ For an in-depth description of clDNN, see [Inference Engine source files](https:
* "GPU" is an alias for "GPU.0"
* If the system doesn't have an integrated GPU, then devices are enumerated starting from 0.
For demonstration purposes, see the [Hello Query Device C++ Sample](../../../inference-engine/samples/hello_query_device/README.md) that can print out the list of available devices with associated indices. Below is an example output (truncated to the device names only):
For demonstration purposes, see the [Hello Query Device C++ Sample](../../../samples/cpp/hello_query_device/README.md) that can print out the list of available devices with associated indices. Below is an example output (truncated to the device names only):
```sh
./hello_query_device
@ -105,7 +105,8 @@ When specifying key values as raw strings (that is, when using Python API), omit
| `KEY_CACHE_DIR` | `"<cache_dir>"` | `""` | Specifies a directory where compiled OCL binaries can be cached. First model loading generates the cache, and all subsequent LoadNetwork calls use precompiled kernels which significantly improves load time. If empty - caching is disabled |
| `KEY_PERF_COUNT` | `YES` / `NO` | `NO` | Collect performance counters during inference |
| `KEY_CONFIG_FILE` | `"<file1> [<file2> ...]"` | `""` | Load custom layer configuration files |
| `KEY_GPU_PLUGIN_`<br>`PRIORITY` | `<0-3>` | `0` | OpenCL queue priority (before usage, make sure your OpenCL driver supports appropriate extension)<br> Higher value means higher priority for OpenCL queue. 0 disables the setting. |
| `KEY_GPU_MODEL_`<br>`PRIORITY` | `GPU_MODEL_PRIORITY_<HIGH\|LOW>` <br/> `GPU_QUEUE_PRIORITY_<LOW\|HIGH\|MED\|DEFAULT>` <br/> `GPU_HOST_TASK_PRIORITY_<HIGH\|LOW\|ANY>` | `GPU_QUEUE_PRIORITY_DEFAULT` <br/> `\|GPU_HOST_TASK_PRIORITY_ANY` | Specifies two types of priority: host task priority and OpenCL queue priority.<br/><br/>Host task priority is specified by `GPU_HOST_TASK_PRIORITY_[level]` and there are three types of task levels: `HIGH`, `LOW`, and `ANY`. Note that `HIGH` and `LOW` are effective only when tbb is used for multithreading the LoadNetwork workload and the host processor is hybrid type. For hybrid processors, if the task priority type is set as `HIGH` the task will have higher priority for core type selection, and vice versa. If the host processor is not hybrid core or the multi threading is not using tbb, it is set as `ANY`, which is the default type.<br/><br/>OpenCL queue priority is specified by `GPU_QUEUE_PRIORITY_[level]` and there are four types of levels: `HIGH`, `MED`, `LOW`, and `DEFAULT`, where the default value is `DEFAULT`. Before usage, make sure your OpenCL driver supports appropriate extension.<br/><br/>Basically `GPU_MODEL_PRIORITY` can be set as combination of the two priority types, such as<br/>-`GPU_QUEUE_PRIORITY_HIGH\|GPU_HOST_TASK_PRIORITY_HIGH` or<br/>-`GPU_QUEUE_PRIORITY_LOW\|GPU_HOST_TASK_PRIORITY_HIGH`.<br/><br/>Also it can be set as a more abstract level of priority PLUGIN_PRIORIY_[level], which represents combination of the two priorities as follows:<br/>-`GPU_MODEL_PRIORITY_HIGH` : `GPU_QUEUE_PRIORITY_HIGH\|GPU_HOST_TASK_PRIORITY_HIGH`<br/>-`GPU_MODEL_PRIORITY_LOW` : `GPU_QUEUE_PRIORITY_LOW\|GPU_HOST_TASK_PRIORITY_LOW`<br/><br/>The default of `KEY_GPU_MODEL_PRIORITY` is `GPU_QUEUE_PRIORITY_DEFAULT\|GPU_HOST_TASK_PRIORITY_ANY`.<br> |
| `KEY_GPU_PLUGIN_`<br>`PRIORITY` | `<0-3>` | `0` | OpenCL queue priority (before usage, make sure your OpenCL driver supports appropriate extension)<br> Higher value means higher priority for OpenCL queue. 0 disables the setting. **Deprecated**. Please use KEY_GPU_MODEL_PRIORITY |
| `KEY_GPU_PLUGIN_`<br>`THROTTLE` | `<0-3>` | `0` | OpenCL queue throttling (before usage, make sure your OpenCL driver supports appropriate extension)<br> Lower value means lower driver thread priority and longer sleep time for it. 0 disables the setting. |
| `KEY_CLDNN_ENABLE_`<br>`FP16_FOR_QUANTIZED_`<br>`MODELS` | `YES` / `NO` | `YES` | Allows using FP16+INT8 mixed precision mode, so non-quantized parts of a model will be executed in FP16 precision for FP16 IR. Does not affect quantized FP32 IRs |
| `KEY_GPU_NV12_`<br>`TWO_INPUTS` | `YES` / `NO` | `NO` | Controls preprocessing logic for nv12 input. If it's set to YES, then device graph will expect that user will set biplanar nv12 blob as input wich will be directly passed to device execution graph. Otherwise, preprocessing via GAPI is used to convert NV12->BGR, thus GPU graph have to expect single input |
@ -113,7 +114,7 @@ When specifying key values as raw strings (that is, when using Python API), omit
| `KEY_EXCLUSIVE_ASYNC_`<br>`REQUESTS` | `YES` / `NO` | `NO` | Forces async requests (also from different executable networks) to execute serially.|
| `KEY_GPU_MAX_NUM_`<br>`THREADS` | `integer value` | `maximum # of HW threads available in host environment` | Specifies the number of CPU threads that can be used for GPU engine, e.g, JIT compilation of GPU kernels or cpu kernel processing within GPU plugin. The default value is set as the number of maximum available threads in host environment to minimize the time for LoadNetwork, where the GPU kernel build time occupies a large portion. Note that if the specified value is larger than the maximum available # of threads or less than zero, it is set as maximum available # of threads. It can be specified with a smaller number than the available HW threads according to the usage scenario, e.g., when the user wants to assign more CPU threads while GPU plugin is running. Note that setting this value with lower number will affect not only the network loading time but also the cpu layers of GPU networks that are optimized with multi-threading. |
| `KEY_GPU_ENABLE_`<br>`LOOP_UNROLLING` | `YES` / `NO` | `YES` | Enables recurrent layers such as TensorIterator or Loop with fixed iteration count to be unrolled. It is turned on by default. Turning this key on will achieve better inference performance for loops with not too many iteration counts (less than 16, as a rule of thumb). Turning this key off will achieve better performance for both graph loading time and inference time with many iteration counts (greater than 16). Note that turning this key on will increase the graph loading time in proportion to the iteration counts. Thus, this key should be turned off if graph loading time is considered to be most important target to optimize. |
| `KEY_CLDNN_PLUGIN_`<br>`PRIORITY` | `<0-3>` | `0` | OpenCL queue priority (before usage, make sure your OpenCL driver supports appropriate extension)<br> Higher value means higher priority for OpenCL queue. 0 disables the setting. **Deprecated**. Please use KEY_GPU_PLUGIN_PRIORITY |
| `KEY_CLDNN_PLUGIN_`<br>`PRIORITY` | `<0-3>` | `0` | OpenCL queue priority (before usage, make sure your OpenCL driver supports appropriate extension)<br> Higher value means higher priority for OpenCL queue. 0 disables the setting. **Deprecated**. Please use KEY_GPU_MODEL_PRIORITY |
| `KEY_CLDNN_PLUGIN_`<br>`THROTTLE` | `<0-3>` | `0` | OpenCL queue throttling (before usage, make sure your OpenCL driver supports appropriate extension)<br> Lower value means lower driver thread priority and longer sleep time for it. 0 disables the setting. **Deprecated**. Please use KEY_GPU_PLUGIN_THROTTLE |
| `KEY_CLDNN_GRAPH_`<br>`DUMPS_DIR` | `"<dump_dir>"` | `""` | clDNN graph optimizer stages dump output directory (in GraphViz format) **Deprecated**. Will be removed in the next release |
| `KEY_CLDNN_SOURCES_`<br>`DUMPS_DIR` | `"<dump_dir>"` | `""` | Final optimized clDNN OpenCL sources dump output directory. **Deprecated**. Will be removed in the next release |
@ -121,6 +122,11 @@ When specifying key values as raw strings (that is, when using Python API), omit
| `KEY_TUNING_MODE` | `TUNING_DISABLED` <br /> `TUNING_CREATE` <br /> `TUNING_USE_EXISTING` | `TUNING_DISABLED` | Disable inference kernel tuning <br /> Create tuning file (expect much longer runtime) <br /> Use an existing tuning file. **Deprecated**. Will be removed in the next release |
| `KEY_TUNING_FILE` | `"<filename>"` | `""` | Tuning file to create / use. **Deprecated**. Will be removed in the next release |
## Quering GPU specific metric keys
* MEMORY_STATISTICS : Returns overall memory statistics of `GPU` device allocated by engine with allocation types. If the network has `TensorIterator` or `Loop` operation which is not unrolled, there will be additional allocation at the first inference phase. In such a case, querying for `MEMORY_STATISTICS` should be done after first inference for more accurate result. The code below demonstrates how to query overall memory statistics of `GPU` device:
@snippet snippets/GPU_Metric0.cpp part0
## GPU Context and Video Memory Sharing RemoteBlob API
See [RemoteBlob API of GPU Plugin](GPU_RemoteBlob_API.md)

View File

@ -38,7 +38,7 @@ Notice that the priorities of the devices can be changed in real time for the ex
Finally, there is a way to specify number of requests that the multi-device will internally keep for each device. Suppose your original app was running 4 cameras with 4 inference requests. You would probably want to share these 4 requests between 2 devices used in the MULTI. The easiest way is to specify a number of requests for each device using parentheses: "MULTI:CPU(2),GPU(2)" and use the same 4 requests in your app. However, such an explicit configuration is not performance-portable and hence not recommended. Instead, the better way is to configure the individual devices and query the resulting number of requests to be used at the application level (see [Configuring the Individual Devices and Creating the Multi-Device On Top](#configuring-the-individual-devices-and-creating-the-multi-device-on-top)).
## Enumerating Available Devices
Inference Engine now features a dedicated API to enumerate devices and their capabilities. See [Hello Query Device C++ Sample](../../../inference-engine/samples/hello_query_device/README.md). This is example output from the sample (truncated to the devices' names only):
Inference Engine now features a dedicated API to enumerate devices and their capabilities. See [Hello Query Device C++ Sample](../../../samples/cpp/hello_query_device/README.md). This is example output from the sample (truncated to the devices' names only):
```sh
./hello_query_device
@ -86,7 +86,7 @@ Notice that until R2 you had to calculate number of requests in your application
## Using the Multi-Device with OpenVINO Samples and Benchmarking the Performance
Notice that every OpenVINO sample that supports "-d" (which stands for "device") command-line option transparently accepts the multi-device.
The [Benchmark Application](../../../inference-engine/samples/benchmark_app/README.md) is the best reference to the optimal usage of the multi-device. As discussed multiple times earlier, you don't need to setup number of requests, CPU streams or threads as the application provides optimal out of the box performance.
The [Benchmark Application](../../../samples/cpp/benchmark_app/README.md) is the best reference to the optimal usage of the multi-device. As discussed multiple times earlier, you don't need to setup number of requests, CPU streams or threads as the application provides optimal out of the box performance.
Below is example command-line to evaluate HDDL+GPU performance with that:
```sh

View File

@ -304,6 +304,7 @@ Some TensorFlow\* operations do not match to any Inference Engine layer, but are
| SparseFillEmptyRows | Supported only when it is part of a sub-graph of the special form |
| SparseReshape | Supported only when it is part of a sub-graph of the special form |
| SparseSegmentSum | Supported only when it is part of a sub-graph of the special form |
| SparseSegmentMean | Supported only when it is part of a sub-graph of the special form |
| SparseToDense | CPU only |
| Split | |
| SplitV | |
@ -525,7 +526,7 @@ Some TensorFlow\* operations do not match to any Inference Engine layer, but are
| GRU | |
| Gather | |
| GatherElements | Doesn't work with negative indices |
| GatherND | |
| GatherND | Doesn't work with negative indices |
| GatherTree | |
| Gemm | |
| GlobalAveragePool | |

View File

@ -14,7 +14,7 @@ The IR will have two inputs: `input` for data and `ivector` for ivectors.
## Example: Run ASpIRE Chain TDNN Model with the Speech Recognition Sample
These instructions show how to run the converted model with the [Speech Recognition sample](../../../../../inference-engine/samples/speech_sample/README.md).
These instructions show how to run the converted model with the [Speech Recognition sample](../../../../../samples/cpp/speech_sample/README.md).
In this example, the input data contains one utterance from one speaker.
To follow the steps described below, you must first do the following:
@ -109,4 +109,4 @@ speech_sample -i feats.ark,ivector_online_ie.ark -m final.xml -d CPU -o predicti
```
Results can be decoded as described in "Use of Sample in Kaldi* Speech Recognition Pipeline" chapter
in [the Speech Recognition Sample description](../../../../../inference-engine/samples/speech_sample/README.md).
in [the Speech Recognition Sample description](../../../../../samples/cpp/speech_sample/README.md).

View File

@ -59,7 +59,7 @@ For example, if you downloaded the [pre-trained SSD InceptionV2 topology](http:/
Inference Engine comes with a number of samples to infer Object Detection API models including:
* [Object Detection for SSD Sample](../../../../../inference-engine/samples/object_detection_sample_ssd/README.md) --- for RFCN, SSD and Faster R-CNNs
* [Object Detection for SSD Sample](../../../../../samples/cpp/object_detection_sample_ssd/README.md) --- for RFCN, SSD and Faster R-CNNs
* [Mask R-CNN Sample for TensorFlow* Object Detection API Models](@ref omz_demos_mask_rcnn_demo_cpp) --- for Mask R-CNNs
There are several important notes about feeding input images to the samples:

View File

@ -99,30 +99,30 @@ python mo.py
IteratorGetNext:2[2],
IteratorGetNext:4[2],
IteratorGetNext:7[2],
linear/linear_model/linear_model/linear_model/education/to_sparse_input/indices:0[10 2]{i32},
linear/linear_model/linear_model/linear_model/education/hash_table_Lookup/LookupTableFindV2:0[10]{i32},
linear/linear_model/linear_model/linear_model/education/to_sparse_input/dense_shape:0[2]{i32}->[2 50],
linear/linear_model/linear_model/linear_model/marital_status/to_sparse_input/indices:0[10 2]{i32},
linear/linear_model/linear_model/linear_model/marital_status/hash_table_Lookup/LookupTableFindV2:0[10]{i32},
linear/linear_model/linear_model/linear_model/marital_status/to_sparse_input/dense_shape:0[2]{i32}->[2 50],
linear/l inear_model/linear_model/linear_model/relationship/to_sparse_input/indices:0[10 2]{i32},
linear/linear_model/linear_model/linear_model/relationship/hash_table_Lookup/LookupTableFindV2:0[10]{i32},
linear/linear_model/linear_model/linear_model/relationship/to_sparse_input/dense_shape:0[2]{i32}->[2 50],
linear/linear_model/linear_model/linear_model/workclass/to_sparse_input/indices:0[10 2]{i32},
linear/linear_model/linear_model/linear_model/workclass/hash_table_Lookup/LookupTableFindV2:0[10]{i32},
linear/linear_model/linear_model/linear_model/workclass/to_sparse_input/dense_shape:0[2]{i32}->[2 50],
dnn/input_from_feature_columns/input_layer/education_indicator/to_sparse_input/indices:0[10 2]{i32},
dnn/input_from_feature_columns/input_layer/education_indicator/hash_table_Lookup/LookupTableFindV2:0[10]{i32},
dnn/input_from_feature_columns/input_layer/education_indicator/to_sparse_input/dense_shape:0[2]{i32}->[2 50],
dnn/input_from_feature_columns/input_layer/marital_status_indicator/to_sparse_input/indices:0[10 2]{i32},
dnn/input_from_feature_columns/input_layer/marital_status_indicator/hash_table_Lookup/LookupTableFindV2:0[10]{i32},
dnn/input_from_feature_columns/input_layer/marital_status_indicator/to_sparse_input/dense_shape:0[2]{i32}->[2 50],
dnn/input_from_feature_columns/input_layer/relationship_indicator/to_sparse_input/indices:0[10 2]{i32},
dnn/input_from_feature_columns/input_layer/relationship_indicator/hash_table_Lookup/LookupTableFindV2:0[10]{i32},
dnn/input_from_feature_columns/input_layer/relationship_indicator/to_sparse_input/dense_shape:0[2]{i32}->[2 50],
dnn/input_from_feature_columns/input_layer/workclass_indicator/to_sparse_input/indices:0[10 2]{i32},
dnn/input_from_feature_columns/input_layer/workclass_indicator/hash_table_Lookup/LookupTableFindV2:0[10]{i32},
dnn/input_from_feature_columns/input_layer/workclass_indicator/to_sparse_input/dense_shape:0[2]{i32}->[2 50]"
linear/linear_model/linear_model/linear_model/education/to_sparse_input/indices:0[10 2]{i64},
linear/linear_model/linear_model/linear_model/education/hash_table_Lookup/LookupTableFindV2:0[10]{i64},
linear/linear_model/linear_model/linear_model/education/to_sparse_input/dense_shape:0[2]{i64}->[2 50],
linear/linear_model/linear_model/linear_model/marital_status/to_sparse_input/indices:0[10 2]{i64},
linear/linear_model/linear_model/linear_model/marital_status/hash_table_Lookup/LookupTableFindV2:0[10]{i64},
linear/linear_model/linear_model/linear_model/marital_status/to_sparse_input/dense_shape:0[2]{i64}->[2 50],
linear/l inear_model/linear_model/linear_model/relationship/to_sparse_input/indices:0[10 2]{i64},
linear/linear_model/linear_model/linear_model/relationship/hash_table_Lookup/LookupTableFindV2:0[10]{i64},
linear/linear_model/linear_model/linear_model/relationship/to_sparse_input/dense_shape:0[2]{i64}->[2 50],
linear/linear_model/linear_model/linear_model/workclass/to_sparse_input/indices:0[10 2]{i64},
linear/linear_model/linear_model/linear_model/workclass/hash_table_Lookup/LookupTableFindV2:0[10]{i64},
linear/linear_model/linear_model/linear_model/workclass/to_sparse_input/dense_shape:0[2]{i64}->[2 50],
dnn/input_from_feature_columns/input_layer/education_indicator/to_sparse_input/indices:0[10 2]{i64},
dnn/input_from_feature_columns/input_layer/education_indicator/hash_table_Lookup/LookupTableFindV2:0[10]{i64},
dnn/input_from_feature_columns/input_layer/education_indicator/to_sparse_input/dense_shape:0[2]{i64}->[2 50],
dnn/input_from_feature_columns/input_layer/marital_status_indicator/to_sparse_input/indices:0[10 2]{i64},
dnn/input_from_feature_columns/input_layer/marital_status_indicator/hash_table_Lookup/LookupTableFindV2:0[10]{i64},
dnn/input_from_feature_columns/input_layer/marital_status_indicator/to_sparse_input/dense_shape:0[2]{i64}->[2 50],
dnn/input_from_feature_columns/input_layer/relationship_indicator/to_sparse_input/indices:0[10 2]{i64},
dnn/input_from_feature_columns/input_layer/relationship_indicator/hash_table_Lookup/LookupTableFindV2:0[10]{i64},
dnn/input_from_feature_columns/input_layer/relationship_indicator/to_sparse_input/dense_shape:0[2]{i64}->[2 50],
dnn/input_from_feature_columns/input_layer/workclass_indicator/to_sparse_input/indices:0[10 2]{i64},
dnn/input_from_feature_columns/input_layer/workclass_indicator/hash_table_Lookup/LookupTableFindV2:0[10]{i64},
dnn/input_from_feature_columns/input_layer/workclass_indicator/to_sparse_input/dense_shape:0[2]{i64}->[2 50]"
--output head/predictions/probabilities
```

View File

@ -15,7 +15,7 @@ The models used in the performance benchmarks were chosen based on general adopt
CF means Caffe*, while TF means TensorFlow*.
#### 5. How can I run the benchmark results on my own?
All of the performance benchmarks were generated using the open-sourced tool within the Intel® Distribution of OpenVINO™ toolkit called `benchmark_app`, which is available in both [C++](../../inference-engine/samples/benchmark_app/README.md) and [Python](../../tools/benchmark_tool/README.md).
All of the performance benchmarks were generated using the open-sourced tool within the Intel® Distribution of OpenVINO™ toolkit called `benchmark_app`, which is available in both [C++](../../samples/cpp/benchmark_app/README.md) and [Python](../../tools/benchmark_tool/README.md).
#### 6. What image sizes are used for the classification network models?
The image size used in the inference depends on the network being benchmarked. The following table shows the list of input sizes for each network model.

View File

@ -1,4 +1,4 @@
openvino/inference-engine/samples/hello_reshape_ssd/README.md
openvino/samples/cpp/hello_reshape_ssd/README.md
openvino/docs/index.md
inference-engine/include/ie_icnn_network.hpp
openvino/docs/get_started/get_started_dl_workbench.md

View File

@ -177,6 +177,8 @@ limitations under the License.
<tab type="user" title="HardSigmoid-1" url="@ref openvino_docs_ops_activation_HardSigmoid_1"/>
<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="I420toBGR-8" url="@ref openvino_docs_ops_image_I420toBGR_8"/>
<tab type="user" title="I420toRGB-8" url="@ref openvino_docs_ops_image_I420toRGB_8"/>
<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"/>

View File

@ -113,7 +113,7 @@ When the script completes, you see the label and confidence for the top-10 categ
Top 10 results:
Image /home/user/dldt/inference-engine/samples/sample_data/car.png
Image /home/user/openvino/samples/cpp/sample_data/car.png
classid probability label
------- ----------- -----
@ -366,7 +366,7 @@ When the Sample Application completes, you see the label and confidence for the
```sh
Top 10 results:
Image /home/user/dldt/inference-engine/samples/sample_data/car.png
Image /home/user/openvino/samples/cpp/sample_data/car.png
classid probability label
------- ----------- -----

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a200fb147754dca9ca7da1cd6659e694373f66cc9516f93cab4fd1ff25830afe
size 73116

View File

@ -32,6 +32,8 @@ OpenVINO™ 2.0 API:
@snippet snippets/ov_common.cpp ov_api_2_0:read_model
Read model has the same structure as in the example from [OpenVINO™ Graph Construction](@ref ov_graph_construction) guide.
### 2.1 Configure Input and Output of the Model
Inference Engine API:
@ -52,4 +54,108 @@ OpenVINO™ 2.0 API:
@snippet snippets/ov_common.cpp ov_api_2_0:compile_model
## 5. TBD
## 4. Create an Inference Request
Inference Engine API:
@snippet snippets/ie_common.cpp ie:create_infer_request
OpenVINO™ 2.0 API:
@snippet snippets/ov_common.cpp ov_api_2_0:create_infer_request
## 5. Prepare input
### IR v10
Inference Engine API:
@snippet snippets/ie_common.cpp ie:get_input_tensor
OpenVINO™ 2.0 API:
@snippet snippets/ov_common.cpp ov_api_2_0:get_input_tensor_v10
### IR v11
Inference Engine API:
@snippet snippets/ie_common.cpp ie:get_input_tensor
OpenVINO™ 2.0 API:
@snippet snippets/ov_common.cpp ov_api_2_0:get_input_tensor_aligned
### ONNX
Inference Engine API:
@snippet snippets/ie_common.cpp ie:get_input_tensor
OpenVINO™ 2.0 API:
@snippet snippets/ov_common.cpp ov_api_2_0:get_input_tensor_aligned
### From Function
Inference Engine API:
@snippet snippets/ie_common.cpp ie:get_input_tensor
OpenVINO™ 2.0 API:
@snippet snippets/ov_common.cpp ov_api_2_0:get_input_tensor_aligned
## 6. Start Inference
Inference Engine API:
@snippet snippets/ie_common.cpp ie:inference
OpenVINO™ 2.0 API:
@snippet snippets/ov_common.cpp ov_api_2_0:inference
## 7. Process the Inference Results
### IR v10
Inference Engine API:
@snippet snippets/ie_common.cpp ie:get_output_tensor
OpenVINO™ 2.0 API:
@snippet snippets/ov_common.cpp ov_api_2_0:get_output_tensor_v10
### IR v11
Inference Engine API:
@snippet snippets/ie_common.cpp ie:get_output_tensor
OpenVINO™ 2.0 API:
@snippet snippets/ov_common.cpp ov_api_2_0:get_output_tensor_aligned
### ONNX
Inference Engine API:
@snippet snippets/ie_common.cpp ie:get_output_tensor
OpenVINO™ 2.0 API:
@snippet snippets/ov_common.cpp ov_api_2_0:get_output_tensor_aligned
### From Function
Inference Engine API:
@snippet snippets/ie_common.cpp ie:get_output_tensor
OpenVINO™ 2.0 API:
@snippet snippets/ov_common.cpp ov_api_2_0:get_output_tensor_aligned

View File

@ -0,0 +1,12 @@
# OpenVINO™ graph construction {#ov_graph_construction}
OpenVINO™ 2.0 includes nGraph engine in a common part. The `ngraph` namespace was changed to `ov`.
Code snippets below show how application code should be changed for migration to OpenVINO™ 2.0.
nGraph API:
@snippet snippets/ngraph.cpp ngraph:graph
OpenVINO™ 2.0 API:
@snippet snippets/ov_graph.cpp ov:graph

View File

@ -9,4 +9,5 @@ The list with differences between APIs below:
- Namespaces were aligned between components.
Please look at next transition guides to understand how transit own application to OpenVINO™ API 2.0.
- [OpenVINO™ Graph Construction](@ref ov_graph_construction)
- [OpenVINO™ Common Inference pipeline](@ref ov_inference_pipeline)

View File

@ -0,0 +1,52 @@
ir_version: 3
producer_name: "nGraph ONNX Importer"
graph {
node {
input: "in"
output: "out"
name: "customrelu"
op_type: "CustomRelu"
domain: "com.example"
attribute {
name: "alpha"
type: FLOAT
f: 2
}
attribute {
name: "beta"
type: FLOAT
f: 3
}
}
name: "custom relu graph"
input {
name: "in"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 8
}
}
}
}
}
output {
name: "out"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 8
}
}
}
}
}
}
opset_import {
domain: "com.example"
version: 1
}

View File

@ -9,68 +9,6 @@
#include <ngraph/opsets/opset5.hpp>
//! [onnx_custom_op:headers]
std::string custom_relu_model() {
return
//! [onnx_custom_op:model]
R"ONNX(
ir_version: 3
producer_name: "nGraph ONNX Importer"
graph {
node {
input: "in"
output: "out"
name: "customrelu"
op_type: "CustomRelu"
domain: "com.example"
attribute {
name: "alpha"
type: FLOAT
f: 2
}
attribute {
name: "beta"
type: FLOAT
f: 3
}
}
name: "custom relu graph"
input {
name: "in"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 8
}
}
}
}
}
output {
name: "out"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 8
}
}
}
}
}
}
opset_import {
domain: "com.example"
version: 1
}
)ONNX";
//! [onnx_custom_op:model]
}
void register_custom_relu_operator() {
// CustomRelu is defined as follows:
// x >= 0 => f(x) = x * alpha

View File

@ -4,8 +4,5 @@
#pragma once
#include <string>
std::string custom_relu_model();
void register_custom_relu_operator();
void unregister_custom_relu_operator();

View File

@ -0,0 +1,88 @@
## I420toBGR <a name="I420toBGR"></a> {#openvino_docs_ops_image_I420toBGR_8}
**Versioned name**: *I420toBGR-8*
**Category**: *Image processing*
**Short description**: *I420toBGR* performs image conversion from I420 to BGR format.
**Detailed description**:
Similar to *I420toRGB* but output channels for each pixel are reversed so that the first channel is `blue`, the second one is `green`, the last one is `red`. See detailed conversion formulas in the [I420toRGB description](I420toRGB_8.md).
**Inputs:**
Same as specified for [I420toRGB](I420toRGB_8.md) operation.
**Outputs:**
* **1**: A tensor of type *T* representing an image converted in BGR format. Dimensions:
* `N` - batch dimension
* `H` - height dimension is the same as the image height
* `W` - width dimension is the same as the image width
* `C` - channels dimension is equal to 3. The first channel is Blue, the second one is Green, the last one is Red
**Types:**
* *T*: `uint8` or any supported floating-point type.
**Examples:**
*Example 1*
```xml
<layer ... type="I420toBGR">
<input>
<port id="0">
<dim>1</dim>
<dim>720</dim>
<dim>640</dim>
<dim>1</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>480</dim>
<dim>640</dim>
<dim>3</dim>
</port>
</output>
</layer>
```
*Example 2*
```xml
<layer ... type="I420toBGR">
<input>
<port id="0"> <!-- Y plane -->
<dim>1</dim>
<dim>480</dim>
<dim>640</dim>
<dim>1</dim>
</port>
<port id="1"> <!-- U plane -->
<dim>1</dim>
<dim>240</dim>
<dim>320</dim>
<dim>1</dim>
</port>
<port id="2"> <!-- V plane -->
<dim>1</dim>
<dim>240</dim>
<dim>320</dim>
<dim>1</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>480</dim>
<dim>640</dim>
<dim>3</dim>
</port>
</output>
</layer>
```

View File

@ -0,0 +1,120 @@
## I420toRGB <a name="I420toRGB"></a> {#openvino_docs_ops_image_I420toRGB_8}
**Versioned name**: *I420toRGB-8*
**Category**: *Image processing*
**Short description**: *I420toRGB* performs image conversion from I420 to RGB format.
**Detailed description:**
Conversion of each pixel from I420 (YUV) to RGB space is represented by the following formulas (same as in [NV12toRGB](NV12toRGB_8.md)):
\f[
\begin{aligned}
& R = 1.164 \cdot (Y - 16) + 1.596 \cdot (V - 128) \\
& G = 1.164 \cdot (Y - 16) - 0.813 \cdot (V - 128) - 0.391 \cdot (U - 128) \\
& B = 1.164 \cdot (Y - 16) + 2.018 \cdot (U - 128)
\end{aligned}
\f]
Then R, G, B values are clipped to range (0, 255).
**Inputs:**
Input I420 image tensor shall have `NHWC (also known as NYXC)` layout and can be represented in two ways:
* *Single plane*:
* **1**: Tensor of type *T*. **Required.** Dimensions:
* `N` - batch dimension
* `H` - height dimension is 1.5x bigger than the image height
* `W` - width dimension is the same as the image width
* `C` - channels dimension is equal to 1 (one plane)
* *Three separate planes - Y, U and V*:
* **1**: Tensor of type *T* representing Y plane. **Required.** Dimensions:
* `N` - batch dimension
* `H` - height dimension is the same as the image height
* `W` - width dimension is the same as the image width
* `C` - channels dimension is equal to 1 (only Y channel)
* **2**: Tensor of type *T* representing U plane. **Required.** Dimensions:
* `N` - batch dimension. Shall be the same as the batch dimension for Y plane
* `H` - height dimension shall be half of the image height (for example, `image_height / 2`)
* `W` - width dimension shall be half of the image width (for example, `image_width / 2`)
* `C` - channels dimension shall be equal to 1 (U channel)
* **3**: Tensor of type *T* representing V plane. **Required.** Dimensions:
* `N` - batch dimension. Shall be the same as the batch dimension for Y plane
* `H` - height dimension shall be half of the image height (for example, `image_height / 2`)
* `W` - width dimension shall be half of the image width (for example, `image_width / 2`)
* `C` - channels dimension shall be equal to 1 (V channel)
**Outputs:**
* **1**: A tensor of type *T* representing an image converted in RGB format. Dimensions:
* `N` - batch dimension
* `H` - height dimension is the same as the image height
* `W` - width dimension is the same as the image width
* `C` - channels dimension is equal to 3. The first channel is Red, the second one is Green, the last one is Blue
**Types:**
* *T*: `uint8` or any supported floating-point type.
**Examples:**
*Example 1*
```xml
<layer ... type="I420toRGB">
<input>
<port id="0">
<dim>1</dim>
<dim>720</dim>
<dim>640</dim>
<dim>1</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>480</dim>
<dim>640</dim>
<dim>3</dim>
</port>
</output>
</layer>
```
*Example 2*
```xml
<layer ... type="I420toRGB">
<input>
<port id="0"> <!-- Y plane -->
<dim>1</dim>
<dim>480</dim>
<dim>640</dim>
<dim>1</dim>
</port>
<port id="1"> <!-- U plane -->
<dim>1</dim>
<dim>240</dim>
<dim>320</dim>
<dim>1</dim>
</port>
<port id="2"> <!-- V plane -->
<dim>1</dim>
<dim>240</dim>
<dim>320</dim>
<dim>1</dim>
</port>
</input>
<output>
<port id="1">
<dim>1</dim>
<dim>480</dim>
<dim>640</dim>
<dim>3</dim>
</port>
</output>
</layer>
```

View File

@ -65,7 +65,7 @@ declared in `namespace opset8`.
* [FloorMod](arithmetic/FloorMod_1.md)
* [Gather](movement/Gather_8.md)
* [GatherElements](movement/GatherElements_6.md)
* [GatherND_8](movement/GatherND_8.md)
* [GatherND](movement/GatherND_8.md)
* [GatherTree](movement/GatherTree_1.md)
* [Gelu](activation/GELU_7.md)
* [Greater](comparison/Greater_1.md)
@ -79,6 +79,8 @@ declared in `namespace opset8`.
* [HSigmoid](activation/HSigmoid_5.md)
* [HSwish](activation/HSwish_4.md)
* [IDFT](signals/IDFT_7.md)
* [I420toBGR](image/I420toBGR_8.md)
* [I420toRGB](image/I420toRGB_8.md)
* [If](condition/If_8.md)
* [Interpolate](image/Interpolate_4.md)
* [Less](comparison/Less_1.md)
@ -94,12 +96,14 @@ declared in `namespace opset8`.
* [LSTMCell](sequence/LSTMCell_1.md)
* [LSTMSequence](sequence/LSTMSequence_1.md)
* [MatMul](matrix/MatMul_1.md)
* [MaxPool](pooling/MaxPool_1.md)
* [MatrixNMS](sort/MatrixNMS_8.md)
* [MaxPool](pooling/MaxPool_8.md)
* [Maximum](arithmetic/Maximum_1.md)
* [Minimum](arithmetic/Minimum_1.md)
* [Mish](activation/Mish_4.md)
* [Mod](arithmetic/Mod_1.md)
* [MVN](normalization/MVN_6.md)
* [MulticlassNMS](sort/MulticlassNMS_8.md)
* [Multiply](arithmetic/Multiply_1.md)
* [Negative](arithmetic/Negative_1.md)
* [NonMaxSuppression](sort/NonMaxSuppression_5.md)
@ -152,6 +156,7 @@ declared in `namespace opset8`.
* [Sign](arithmetic/Sign_1.md)
* [Sin](arithmetic/Sin_1.md)
* [Sinh](arithmetic/Sinh_1.md)
* [Slice](movement/Slice_8.md)
* [SoftMax](activation/SoftMax_8.md)
* [SoftPlus](activation/SoftPlus_4.md)
* [SpaceToBatch](movement/SpaceToBatch_2.md)

View File

@ -6,21 +6,20 @@
**Short description**: *LSTMCell* operation represents a single LSTM cell. It computes the output using the formula described in the original paper [Long Short-Term Memory](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.676.4320&rep=rep1&type=pdf).
**Detailed description**
**Detailed description**: *LSTMCell* computes the output *Ht* and *ot* for current time step based on the following formula:
```
Formula:
* - matrix mult
(.) - eltwise mult
* - matrix multiplication
(.) - Hadamard product (element-wise)
[,] - concatenation
sigm - 1/(1 + e^{-x})
tanh - (e^{2x} - 1)/(e^{2x} + 1)
f = sigm(Wf*[Hi, X] + Bf)
i = sigm(Wi*[Hi, X] + Bi)
c = tanh(Wc*[Hi, X] + Bc)
o = sigm(Wo*[Hi, X] + Bo)
Co = f (.) Ci + i (.) c
Ho = o (.) tanh(Co)
f, g, h - are activation functions.
it = f(Xt*(Wi^T) + Ht-1*(Ri^T) + Wbi + Rbi)
ft = f(Xt*(Wf^T) + Ht-1*(Rf^T) + Wbf + Rbf)
ct = g(Xt*(Wc^T) + Ht-1*(Rc^T) + Wbc + Rbc)
Ct = ft (.) Ct-1 + it (.) ct
ot = f(Xt*(Wo^T) + Ht-1*(Ro^T) + Wbo + Rbo)
Ht = ot (.) h(Ct)
```
**Attributes**
@ -37,7 +36,7 @@ tanh - (e^{2x} - 1)/(e^{2x} + 1)
* **Description**: *activations* specifies activation functions for gates, there are three gates, so three activation functions should be specified as a value for this attributes
* **Range of values**: any combination of *relu*, *sigmoid*, *tanh*
* **Type**: a list of strings
* **Default value**: *sigmoid,tanh,tanh*
* **Default value**: *sigmoid* for f, *tanh* for g, *tanh* for h
* **Required**: *no*
* *activations_alpha, activations_beta*
@ -68,7 +67,7 @@ tanh - (e^{2x} - 1)/(e^{2x} + 1)
* **5**: `R` - 2D tensor of type *T* `[4 * hidden_size, hidden_size]`, the recurrence weights for matrix multiplication, gate order: fico. **Required.**
* **6**: `B` 1D tensor of type *T* `[4 * hidden_size]`, the sum of biases (weights and recurrence weights). **Required.**
* **6**: `B` 1D tensor of type *T* `[4 * hidden_size]`, the sum of biases (weights and recurrence weights), if not specified - assumed to be 0. **optional.**
**Outputs**

View File

@ -8,6 +8,8 @@
**Detailed description**: This is the second case of the PyTorch [EmbeddingBag](https://pytorch.org/docs/stable/nn.html#embeddingbag), it has indices in two 1D tensors provided as 2nd and 3rd inputs. For each index in `indices` this operator gets values from `data` embedding table and sums all values belonging to each bag. Values in `offsets` define starting index in `indices` tensor of each "bag", e.g. `offsets` with value `[0,3,4,4,6]` define 5 "bags" containing `[3,1,0,2,n-6]` elements.
**Attributes**: EmbeddingBagOffsetsSum operation has no attributes.
**Inputs**:
* **1**: `emb_table` tensor containing the embedding lookup table of the module of shape `[num_emb, emb_dim1, emb_dim2, ...]` and of type *T*. **Required.**
@ -42,7 +44,7 @@
<port id="1"> <!-- indices value is: [0, 2, 3, 4] -->
<dim>4</dim>
</port>
<port id="2"> <!-- offsets value is: [0, 2, 2] - second "bag" is empty -->
<port id="2"> <!-- offsets value is: [0, 2, 2] - 3 "bags" containing [2,0,4-2] elements, second "bag" is empty -->
<dim>3</dim>
</port>
<port id="3"/> <!-- default_index value is: 0 -->

View File

@ -8,6 +8,8 @@
**Detailed description**: This is the first case of the PyTorch [EmbeddingBag](https://pytorch.org/docs/stable/nn.html#embeddingbag), it has indices in the tensor of format `[batch, indices_per_bag]`. If 3rd input is not provided, this operation is equivalent to *Gather* followed by *ReduceSum(axis=0)*. However, *EmbeddingBagPackedSum* is much more time and memory efficient than using a chain of these operations.
**Attributes**: EmbeddingBagPackedSum operation has no attributes.
**Inputs**:
* **1**: `emb_table` tensor containing the embedding lookup table of the module of shape `[num_emb, emb_dim1, emb_dim2, ...]` and of type *T*. **Required.**

View File

@ -8,6 +8,8 @@
**Detailed description**: This is [sparse.segment_sum](https://www.tensorflow.org/api_docs/python/tf/sparse/segment_sum) operation from Tensorflow. For each index in `indices` this operator gets values from `data` embedding table and sums all values belonging to each segment. Values in `segment_ids` define which segment index in `indices` tensor belong to, e.g. `segments_ids` with value `[0,0,0,1,1,3,5,5]` define 4 non empty segments other segments are empty, the number of segments is defined by `num_segments` input.
**Attributes**: EmbeddingSegmentsSum operation has no attributes.
**Inputs**:
* **1**: `emb_table` tensor containing the embedding lookup table of the module of shape `[num_emb, emb_dim1, emb_dim2, ...]` and of type *T*. **Required.**

View File

@ -53,9 +53,9 @@ When evaluating performance of your model with the Inference Engine, you must me
In the asynchronous case (see <a href="#new-request-based-api">Request-Based API and “GetBlob” Idiom</a>), the performance of an individual infer request is usually of less concern. Instead, you typically execute multiple requests asynchronously and measure the throughput in images per second by dividing the number of images that were processed by the processing time.
In contrast, for latency-oriented tasks, the time to a single frame is more important.
Refer to the [Benchmark App](../../inference-engine/samples/benchmark_app/README.md) sample, which allows latency vs. throughput measuring.
Refer to the [Benchmark App](../../samples/cpp/benchmark_app/README.md) sample, which allows latency vs. throughput measuring.
> **NOTE**: The [Benchmark App](../../inference-engine/samples/benchmark_app/README.md) sample also supports batching, that is, automatically packing multiple input images into a single request. However, high batch size results in a latency penalty. So for more real-time oriented usages, batch sizes that are as low as a single input are usually used. Still, devices like CPU, Intel®Movidius™ Myriad™ 2 VPU, Intel® Movidius™ Myriad™ X VPU, or Intel® Vision Accelerator Design with Intel® Movidius™ VPU require a number of parallel requests instead of batching to leverage the performance. Running multiple requests should be coupled with a device configured to the corresponding number of streams. See <a href="#cpu-streams">details on CPU streams</a> for an example.
> **NOTE**: The [Benchmark App](../../samples/cpp/benchmark_app/README.md) sample also supports batching, that is, automatically packing multiple input images into a single request. However, high batch size results in a latency penalty. So for more real-time oriented usages, batch sizes that are as low as a single input are usually used. Still, devices like CPU, Intel®Movidius™ Myriad™ 2 VPU, Intel® Movidius™ Myriad™ X VPU, or Intel® Vision Accelerator Design with Intel® Movidius™ VPU require a number of parallel requests instead of batching to leverage the performance. Running multiple requests should be coupled with a device configured to the corresponding number of streams. See <a href="#cpu-streams">details on CPU streams</a> for an example.
[OpenVINO™ Deep Learning Workbench tool](https://docs.openvinotoolkit.org/latest/workbench_docs_Workbench_DG_Introduction.html) provides throughput versus latency charts for different numbers of streams, requests, and batch sizes to find the performance sweet spot.
@ -63,7 +63,7 @@ Refer to the [Benchmark App](../../inference-engine/samples/benchmark_app/README
When comparing the Inference Engine performance with the framework or another reference code, make sure that both versions are as similar as possible:
- Wrap exactly the inference execution (refer to the [Benchmark App](../../inference-engine/samples/benchmark_app/README.md) sample for an example).
- Wrap exactly the inference execution (refer to the [Benchmark App](../../samples/cpp/benchmark_app/README.md) sample for an example).
- Track model loading time separately.
- Ensure the inputs are identical for the Inference Engine and the framework. For example, Caffe\* allows you to auto-populate the input with random values. Notice that it might give different performance than on real images.
- Similarly, for correct performance comparison, make sure the access pattern, for example, input layouts, is optimal for Inference Engine (currently, it is NCHW).
@ -79,7 +79,7 @@ You need to build your performance conclusions on reproducible data. Do the perf
- If the warm-up run does not help or execution time still varies, you can try running a large number of iterations and then average or find a mean of the results.
- For time values that range too much, use geomean.
Refer to the [Benchmark App](../../inference-engine/samples/benchmark_app/README.md) for code examples of performance measurements. Almost every sample, except interactive demos, has the `-ni` option to specify the number of iterations.
Refer to the [Benchmark App](../../samples/cpp/benchmark_app/README.md) for code examples of performance measurements. Almost every sample, except interactive demos, has the `-ni` option to specify the number of iterations.
## Model Optimizer Knobs Related to Performance <a name="mo-knobs-related-to-performance"></a>
@ -121,9 +121,9 @@ for the multi-device execution:
(e.g., the number of request in the flight is not enough to saturate all devices).
- It is highly recommended to query the optimal number of inference requests directly from the instance of the ExecutionNetwork
(resulted from the LoadNetwork call with the specific multi-device configuration as a parameter).
Please refer to the code of the [Benchmark App](../../inference-engine/samples/benchmark_app/README.md) sample for details.
Please refer to the code of the [Benchmark App](../../samples/cpp/benchmark_app/README.md) sample for details.
- Notice that for example CPU+GPU execution performs better with certain knobs
which you can find in the code of the same [Benchmark App](../../inference-engine/samples/benchmark_app/README.md) sample.
which you can find in the code of the same [Benchmark App](../../samples/cpp/benchmark_app/README.md) sample.
One specific example is disabling GPU driver polling, which in turn requires multiple GPU streams (which is already a default for the GPU) to amortize slower
inference completion from the device to the host.
- Multi-device logic always attempts to save on the (e.g., inputs) data copies between device-agnostic, user-facing inference requests
@ -169,7 +169,7 @@ This feature usually provides much better performance for the networks than batc
Compared with the batching, the parallelism is somewhat transposed (i.e. performed over inputs, and much less within CNN ops):
![](../img/cpu_streams_explained.png)
Try the [Benchmark App](../../inference-engine/samples/benchmark_app/README.md) sample and play with the number of streams running in parallel. The rule of thumb is tying up to a number of CPU cores on your machine.
Try the [Benchmark App](../../samples/cpp/benchmark_app/README.md) sample and play with the number of streams running in parallel. The rule of thumb is tying up to a number of CPU cores on your machine.
For example, on an 8-core CPU, compare the `-nstreams 1` (which is a legacy, latency-oriented scenario) to the 2, 4, and 8 streams.
Notice that on a multi-socket machine, the bare minimum of streams for a latency scenario equals the number of sockets.
@ -190,13 +190,13 @@ Inference Engine relies on the [Compute Library for Deep Neural Networks (clDNN)
- If your application is simultaneously using the inference on the CPU or otherwise loads the host heavily, make sure that the OpenCL driver threads do not starve. You can use [CPU configuration options](../IE_DG/supported_plugins/CPU.md) to limit number of inference threads for the CPU plugin.
- In the GPU-only scenario, a GPU driver might occupy a CPU core with spin-looped polling for completion. If the _CPU_ utilization is a concern, consider the `KEY_CLDND_PLUGIN_THROTTLE` configuration option.
> **NOTE**: See the [Benchmark App Sample](../../inference-engine/samples/benchmark_app/README.md) code for a usage example.
> **NOTE**: See the [Benchmark App Sample](../../samples/cpp/benchmark_app/README.md) code for a usage example.
Notice that while disabling the polling, this option might reduce the GPU performance, so usually this option is used with multiple [GPU streams](../IE_DG/supported_plugins/GPU.md).
### Intel® Movidius™ Myriad™ X Visual Processing Unit and Intel® Vision Accelerator Design with Intel® Movidius™ VPUs <a name="myriad"></a>
Since Intel® Movidius™ Myriad™ X Visual Processing Unit (Intel® Movidius™ Myriad™ 2 VPU) communicates with the host over USB, minimum four infer requests in flight are recommended to hide the data transfer costs. See <a href="#new-request-based-api">Request-Based API and “GetBlob” Idiom</a> and [Benchmark App Sample](../../inference-engine/samples/benchmark_app/README.md) for more information.
Since Intel® Movidius™ Myriad™ X Visual Processing Unit (Intel® Movidius™ Myriad™ 2 VPU) communicates with the host over USB, minimum four infer requests in flight are recommended to hide the data transfer costs. See <a href="#new-request-based-api">Request-Based API and “GetBlob” Idiom</a> and [Benchmark App Sample](../../samples/cpp/benchmark_app/README.md) for more information.
Intel® Vision Accelerator Design with Intel® Movidius™ VPUs requires keeping at least 32 inference requests in flight to fully saturate the device.
@ -240,7 +240,7 @@ For general details on the heterogeneous plugin, refer to the [corresponding sec
Every Inference Engine sample supports the `-d` (device) option.
For example, here is a command to run an [Object Detection Sample SSD Sample](../../inference-engine/samples/object_detection_sample_ssd/README.md):
For example, here is a command to run an [Object Detection Sample SSD Sample](../../samples/cpp/object_detection_sample_ssd/README.md):
```sh
./object_detection_sample_ssd -m <path_to_model>/ModelSSD.xml -i <path_to_pictures>/picture.jpg -d HETERO:GPU,CPU
@ -284,7 +284,7 @@ You can use the GraphViz\* utility or `.dot` converters (for example, to `.png`
![](../img/output_trimmed.png)
You can also use performance data (in the [Benchmark App](../../inference-engine/samples/benchmark_app/README.md), it is an option `-pc`) to get performance data on each subgraph. Again, refer to the [HETERO plugin documentation](https://docs.openvinotoolkit.org/latest/openvino_docs_IE_DG_supported_plugins_HETERO.html#analyzing_heterogeneous_execution) and to <a href="#performance-counters">Internal Inference Performance Counters</a> for information on general counters.
You can also use performance data (in the [Benchmark App](../../samples/cpp/benchmark_app/README.md), it is an option `-pc`) to get performance data on each subgraph. Again, refer to the [HETERO plugin documentation](https://docs.openvinotoolkit.org/latest/openvino_docs_IE_DG_supported_plugins_HETERO.html#analyzing_heterogeneous_execution) and to <a href="#performance-counters">Internal Inference Performance Counters</a> for information on general counters.
## Optimizing Custom Kernels <a name="optimizing-custom-kernels"></a>
@ -430,7 +430,7 @@ There are important performance caveats though: for example, the tasks that run
Also, if the inference is performed on the graphics processing unit (GPU), there is little gain in doing the encoding of the resulting video on the same GPU in parallel, for instance, because the device is already busy.
Refer to the [Object Detection SSD Demo](@ref omz_demos_object_detection_demo_cpp) (latency-oriented Async API showcase) and [Benchmark App Sample](../../inference-engine/samples/benchmark_app/README.md) (which has both latency and throughput-oriented modes) for complete examples of the Async API in action.
Refer to the [Object Detection SSD Demo](@ref omz_demos_object_detection_demo_cpp) (latency-oriented Async API showcase) and [Benchmark App Sample](../../samples/cpp/benchmark_app/README.md) (which has both latency and throughput-oriented modes) for complete examples of the Async API in action.
## Using Tools <a name="using-tools"></a>

View File

@ -46,7 +46,7 @@ if(OpenCV_FOUND)
endif()
if(NGRAPH_ONNX_FRONTEND_ENABLE)
target_link_libraries(${TARGET_NAME} PRIVATE onnx_ngraph_frontend)
target_link_libraries(${TARGET_NAME} PRIVATE onnx_ov_frontend)
endif()
if(NOT MSVC)

View File

@ -2,11 +2,11 @@
int main() {
using namespace InferenceEngine;
//! [part6]
//! [part0]
InferenceEngine::Core core;
auto network = core.ReadNetwork("sample.xml");
auto exeNetwork = core.LoadNetwork(network, "GPU");
std::map<std::string, uint64_t> statistics_map = exeNetwork.GetMetric(GPU_METRIC_KEY(MEMORY_STATISTICS));
//! [part6]
std::map<std::string, uint64_t> statistics_map = core.GetMetric("GPU", GPU_METRIC_KEY(MEMORY_STATISTICS));
//! [part0]
return 0;
}

View File

@ -27,8 +27,29 @@ int main() {
//! [ie:create_infer_request]
//! [ie:get_input_tensor]
InferenceEngine::Blob::Ptr input_blob = infer_request.GetBlob(inputs.begin()->first);
// fill input blob
InferenceEngine::Blob::Ptr input_blob1 = infer_request.GetBlob(inputs.begin()->first);
// fill first blob
InferenceEngine::SizeVector dims1 = input_blob1->getTensorDesc().getDims();
InferenceEngine::MemoryBlob::Ptr minput1 = InferenceEngine::as<InferenceEngine::MemoryBlob>(input_blob1);
if (minput1) {
// locked memory holder should be alive all time while access to its
// buffer happens
auto minputHolder = minput1->wmap();
// Original I64 precision was converted to I32
auto data = minputHolder.as<InferenceEngine::PrecisionTrait<InferenceEngine::Precision::I32>::value_type*>();
// Fill data ...
}
InferenceEngine::Blob::Ptr input_blob2 = infer_request.GetBlob("data2");
// fill first blob
InferenceEngine::MemoryBlob::Ptr minput2 = InferenceEngine::as<InferenceEngine::MemoryBlob>(input_blob2);
if (minput2) {
// locked memory holder should be alive all time while access to its
// buffer happens
auto minputHolder = minput2->wmap();
// Original I64 precision was converted to I32
auto data = minputHolder.as<InferenceEngine::PrecisionTrait<InferenceEngine::Precision::I32>::value_type*>();
// Fill data ...
}
//! [ie:get_input_tensor]
//! [ie:inference]
@ -37,7 +58,16 @@ int main() {
//! [ie:get_output_tensor]
InferenceEngine::Blob::Ptr output_blob = infer_request.GetBlob(outputs.begin()->first);
// process output data
InferenceEngine::MemoryBlob::Ptr moutput = InferenceEngine::as<InferenceEngine::MemoryBlob>(output_blob);
if (moutput) {
// locked memory holder should be alive all time while access to its
// buffer happens
auto minputHolder = moutput->rmap();
// Original I64 precision was converted to I32
auto data =
minputHolder.as<const InferenceEngine::PrecisionTrait<InferenceEngine::Precision::I32>::value_type*>();
// process output data
}
//! [ie:get_output_tensor]
return 0;
}

48
docs/snippets/ngraph.cpp Normal file
View File

@ -0,0 +1,48 @@
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <ngraph/ngraph.hpp>
#include <ngraph/opsets/opset8.hpp>
int main() {
//! [ngraph:graph]
// _____________ _____________
// | Parameter | | Parameter |
// | data1 | | data2 |
// |___________| |___________|
// | |
// data1_t | | data2_t
// \ /
// \ /
// \ /
// ____\____/____
// | Concat |
// | concat |
// |____________|
// |
// | concat_t
// |
// _______|_______
// | Result |
// | result |
// |_____________|
auto data1 = std::make_shared<ngraph::opset8::Parameter>(ngraph::element::i64, ngraph::Shape{1, 3, 2, 2});
data1->set_friendly_name("data1"); // operation name
data1->output(0).set_names({"data1_t"}); // tensor names
auto data2 = std::make_shared<ngraph::opset8::Parameter>(ngraph::element::i64, ngraph::Shape{1, 2, 2, 2});
data2->set_friendly_name("data2"); // operation name
data2->output(0).set_names({"data2_t"}); // tensor names
auto concat = std::make_shared<ngraph::opset8::Concat>(ngraph::OutputVector{data1, data2}, 1);
concat->set_friendly_name("concat"); // operation name
concat->output(0).set_names({"concat_t"}); // tensor name
auto result = std::make_shared<ngraph::opset8::Result>(concat);
result->set_friendly_name("result"); // operation name
auto f = std::make_shared<ngraph::Function>(ngraph::ResultVector{result},
ngraph::ParameterVector{data1, data2},
"function_name");
//! [ngraph:graph]
return 0;
}

View File

@ -1,9 +1,61 @@
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <openvino/core/function.hpp>
#include <openvino/core/core.hpp>
#include <openvino/runtime/runtime.hpp>
void inputs_v10(ov::runtime::InferRequest& infer_request) {
//! [ov_api_2_0:get_input_tensor_v10]
// Get input tensor by index
ov::runtime::Tensor input_tensor1 = infer_request.get_input_tensor(0);
// IR v10 works with converted precisions (i64 -> i32)
auto data1 = input_tensor1.data<int32_t>();
// Fill first data ...
// Get input tensor by tensor name
ov::runtime::Tensor input_tensor2 = infer_request.get_tensor("data2_t");
// IR v10 works with converted precisions (i64 -> i32)
auto data2 = input_tensor1.data<int32_t>();
// Fill first data ...
//! [ov_api_2_0:get_input_tensor_v10]
}
void inputs_aligned(ov::runtime::InferRequest& infer_request) {
//! [ov_api_2_0:get_input_tensor_aligned]
// Get input tensor by index
ov::runtime::Tensor input_tensor1 = infer_request.get_input_tensor(0);
// Element types, names and layouts are aligned with framework
auto data1 = input_tensor1.data<int64_t>();
// Fill first data ...
// Get input tensor by tensor name
ov::runtime::Tensor input_tensor2 = infer_request.get_tensor("data2_t");
// Element types, names and layouts are aligned with framework
auto data2 = input_tensor1.data<int64_t>();
// Fill first data ...
//! [ov_api_2_0:get_input_tensor_aligned]
}
void outputs_v10(ov::runtime::InferRequest& infer_request) {
//! [ov_api_2_0:get_output_tensor_v10]
// model has only one output
ov::runtime::Tensor output_tensor = infer_request.get_output_tensor();
// IR v10 works with converted precisions (i64 -> i32)
auto out_data = output_tensor.data<int32_t>();
// process output data
//! [ov_api_2_0:get_output_tensor_v10]
}
void outputs_aligned(ov::runtime::InferRequest& infer_request) {
//! [ov_api_2_0:get_output_tensor_aligned]
// model has only one output
ov::runtime::Tensor output_tensor = infer_request.get_output_tensor();
// Element types, names and layouts are aligned with framework
auto out_data = output_tensor.data<int64_t>();
// process output data
//! [ov_api_2_0:get_output_tensor_aligned]
}
int main() {
//! [ov_api_2_0:create_core]
ov::runtime::Core core;
@ -14,21 +66,24 @@ int main() {
//! [ov_api_2_0:read_model]
//! [ov_api_2_0:get_inputs_outputs]
ov::ParameterVector inputs = network->get_parameters();
ov::ResultVector outputs = network->get_results();
std::vector<ov::Output<ov::Node>> inputs = network->inputs();
std::vector<ov::Output<ov::Node>> outputs = network->outputs();
//! [ov_api_2_0:get_inputs_outputs]
//! [ov_api_2_0:compile_model]
ov::runtime::ExecutableNetwork exec_network = core.compile_model(network, "CPU");
//! [ov_api_2_0:compile_model]
//! [ov_api_2_0:create_infer_request]
ov::runtime::InferRequest infer_request = exec_network.create_infer_request();
//
// InferenceEngine::Blob::Ptr input_blob = infer_request.GetBlob(inputs.begin()->first);
// // fill input blob
// infer_request.Infer();
//
// InferenceEngine::Blob::Ptr output_blob = infer_request.GetBlob(outputs.begin()->first);
// process output data
//! [ov_api_2_0:create_infer_request]
inputs_aligned(infer_request);
//! [ov_api_2_0:inference]
infer_request.infer();
//! [ov_api_2_0:inference]
outputs_aligned(infer_request);
return 0;
}

View File

@ -0,0 +1,47 @@
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <openvino/core/core.hpp>
#include <openvino/opsets/opset8.hpp>
int main() {
//! [ov:graph]
// _____________ _____________
// | Parameter | | Parameter |
// | data1 | | data2 |
// |___________| |___________|
// | |
// data1_t | | data2_t
// \ /
// \ /
// \ /
// ____\____/____
// | Concat |
// | concat |
// |____________|
// |
// | concat_t
// |
// _______|_______
// | Result |
// | result |
// |_____________|
auto data1 = std::make_shared<ov::opset8::Parameter>(ov::element::i64, ov::Shape{1, 3, 2, 2});
data1->set_friendly_name("data1"); // operation name
data1->output(0).set_names({"data1_t"}); // tensor names
auto data2 = std::make_shared<ov::opset8::Parameter>(ov::element::i64, ov::Shape{1, 2, 2, 2});
data2->set_friendly_name("data2"); // operation name
data2->output(0).set_names({"data2_t"}); // tensor names
auto concat = std::make_shared<ov::opset8::Concat>(ov::OutputVector{data1, data2}, 1);
concat->set_friendly_name("concat"); // operation name
concat->output(0).set_names({"concat_t"}); // tensor name
auto result = std::make_shared<ov::opset8::Result>(concat);
result->set_friendly_name("result"); // operation name
auto f =
std::make_shared<ov::Function>(ov::ResultVector{result}, ov::ParameterVector{data1, data2}, "function_name");
//! [ov:graph]
return 0;
}

View File

@ -40,13 +40,5 @@ set_target_properties(${TARGET_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_REL
# POSSIBLE_PLUGINS ${TARGET_NAME})
# [cmake:plugin]
# ATTENTION: uncomment to install component
# install
# set(component_name template)
# ie_cpack_add_component(${component_name} REQUIRED)
# install(TARGETS ${TARGET_NAME}
# RUNTIME DESTINATION ${IE_CPACK_RUNTIME_PATH}
# LIBRARY DESTINATION ${IE_CPACK_LIBRARY_PATH}
# COMPONENT ${component_name})
ov_install_static_lib(ngraph_backend ngraph)
ov_install_static_lib(interpreter_backend ngraph)

View File

@ -218,7 +218,9 @@ void TemplatePlugin::ExecutableNetwork::Export(std::ostream& modelStream) {
// Note: custom ngraph extensions are not supported
std::map<std::string, ngraph::OpSet> custom_opsets;
std::stringstream xmlFile, binFile;
OPENVINO_SUPPRESS_DEPRECATED_START
ov::pass::Serialize serializer(xmlFile, binFile, custom_opsets);
OPENVINO_SUPPRESS_DEPRECATED_END
serializer.run_on_function(_function);
auto m_constants = binFile.str();

View File

@ -0,0 +1,222 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "openvino/opsets/opset1.hpp"
#include "openvino/opsets/opset2.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
using namespace ov;
namespace {
struct BatchToSpaceParams {
BatchToSpaceParams(const Tensor& dataTensor, const Tensor& blockShapeTensor,
const Tensor& cropsBeginTensor, const Tensor& cropsEndTensor,
const Tensor& expectedTensor, const std::string& testcaseName = "") :
dataTensor(dataTensor), blockShapeTensor(blockShapeTensor),
cropsBeginTensor(cropsBeginTensor), cropsEndTensor(cropsEndTensor),
expectedTensor(expectedTensor), testcaseName(testcaseName) {}
Tensor dataTensor;
Tensor blockShapeTensor;
Tensor cropsBeginTensor;
Tensor cropsEndTensor;
Tensor expectedTensor;
std::string testcaseName;
};
class ReferenceBatchToSpaceLayerTest : public testing::TestWithParam<BatchToSpaceParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params);
inputData = {params.dataTensor.data};
refOutData = {params.expectedTensor.data};
}
static std::string getTestCaseName(const testing::TestParamInfo<BatchToSpaceParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "dType=" << param.dataTensor.type;
result << "_dShape=" << param.dataTensor.shape;
result << "_bsType=" << param.blockShapeTensor.type;
result << "_bsShape=" << param.blockShapeTensor.shape;
result << "_cbType=" << param.cropsBeginTensor.type;
result << "_cbShape=" << param.cropsBeginTensor.shape;
result << "_ceType=" << param.cropsEndTensor.type;
result << "_ceShape=" << param.cropsEndTensor.shape;
result << "_eType=" << param.expectedTensor.type;
if (param.testcaseName != "") {
result << "_eShape=" << param.expectedTensor.shape;
result << "_" << param.testcaseName;
} else {
result << "_eShape=" << param.expectedTensor.shape;
}
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(const BatchToSpaceParams& params) {
const auto data = std::make_shared<opset1::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto blockShape = std::make_shared<opset1::Constant>(element::i64, params.blockShapeTensor.shape, params.blockShapeTensor.data.data());
const auto cropsBegin = std::make_shared<opset1::Constant>(element::i64, params.cropsBeginTensor.shape, params.cropsBeginTensor.data.data());
const auto cropsEnd = std::make_shared<opset1::Constant>(element::i64, params.cropsEndTensor.shape, params.cropsEndTensor.data.data());
const auto batchToSpace = std::make_shared<opset2::BatchToSpace>(data, blockShape, cropsBegin, cropsEnd);
return std::make_shared<Function>(NodeVector {batchToSpace}, ParameterVector {data});
}
};
TEST_P(ReferenceBatchToSpaceLayerTest, CompareWithRefs) {
Exec();
}
template <element::Type_t IN_ET>
std::vector<BatchToSpaceParams> generateBatchToSpaceParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<BatchToSpaceParams> batchToSpaceParams {
// input_with_shape_4x3
BatchToSpaceParams(
Tensor({4, 3}, IN_ET, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}),
Tensor({2}, element::i64, std::vector<int64_t>{1, 2}),
Tensor({2}, element::i64, std::vector<int64_t>{0, 0}),
Tensor({2}, element::i64, std::vector<int64_t>{0, 0}),
Tensor({2, 6}, IN_ET, std::vector<T>{1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12}),
"input_with_shape_4x3"),
// input_with_shape_4x1x1x3
BatchToSpaceParams(
Tensor({4, 1, 1, 3}, IN_ET, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}),
Tensor({4}, element::i64, std::vector<int64_t>{1, 1, 1, 2}),
Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 0}),
Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 0}),
Tensor({2, 1, 1, 6}, IN_ET, std::vector<T>{1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12}),
"input_with_shape_4x1x1x3"),
// input_with_shape_4x1x1x3_1
BatchToSpaceParams(
Tensor({4, 1, 1, 3}, IN_ET, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}),
Tensor({4}, element::i64, std::vector<int64_t>{1, 1, 2, 1}),
Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 0}),
Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 0}),
Tensor({2, 1, 2, 3}, IN_ET, std::vector<T>{1, 2, 3, 7, 8, 9, 4, 5, 6, 10, 11, 12}),
"input_with_shape_4x1x1x3_1"),
// input_with_shape_4x1x1x3_2
BatchToSpaceParams(
Tensor({4, 1, 1, 3}, IN_ET, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}),
Tensor({4}, element::i64, std::vector<int64_t>{1, 1, 2, 2}),
Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 0}),
Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 0}),
Tensor({2, 1, 1, 6}, IN_ET, std::vector<T>{1, 4, 2, 5, 3, 6, 7, 10, 8, 11, 9, 12}),
"input_with_shape_4x1x1x3_2"),
// input_with_shape_4x1x2x3
BatchToSpaceParams(
Tensor({4, 1, 2, 3}, IN_ET, 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}),
Tensor({4}, element::i64, std::vector<int64_t>{1, 1, 1, 2}),
Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 0}),
Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 0}),
Tensor({2, 1, 2, 6}, IN_ET, std::vector<T>{1, 13, 2, 14, 3, 15,
4, 16, 5, 17, 6, 18,
7, 19, 8, 20, 9, 21,
10, 22, 11, 23, 12, 24}),
"input_with_shape_4x1x2x3"),
// input_with_shape_4x1x2x3_1
BatchToSpaceParams(
Tensor({4, 1, 2, 3}, IN_ET, 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}),
Tensor({4}, element::i64, std::vector<int64_t>{1, 1, 2, 1}),
Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 0}),
Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 0}),
Tensor({2, 1, 4, 3}, IN_ET, std::vector<T>{1, 2, 3, 13, 14, 15,
4, 5, 6, 16, 17, 18,
7, 8, 9, 19, 20, 21,
10, 11, 12, 22, 23, 24}),
"input_with_shape_4x1x2x3_1"),
// input_with_shape_4x1x2x3_2
BatchToSpaceParams(
Tensor({4, 1, 2, 3}, IN_ET, 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}),
Tensor({4}, element::i64, std::vector<int64_t>{1, 1, 2, 2}),
Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 0}),
Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 0}),
Tensor({1, 1, 4, 6}, IN_ET, std::vector<T>{1, 7, 2, 8, 3, 9,
13, 19, 14, 20, 15, 21,
4, 10, 5, 11, 6, 12,
16, 22, 17, 23, 18, 24}),
"input_with_shape_4x1x2x3_2"),
// input_with_shape_with_crop_4x1x2x3
BatchToSpaceParams(
Tensor({4, 1, 2, 3}, IN_ET, 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}),
Tensor({4}, element::i64, std::vector<int64_t>{1, 1, 2, 2}),
Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 0}),
Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 2}),
Tensor({1, 1, 4, 4}, IN_ET, std::vector<T>{1, 7, 2, 8, 13, 19, 14, 20,
4, 10, 5, 11, 16, 22, 17, 23}),
"input_with_shape_with_crop_4x1x2x3"),
// input_with_shape_with_crop_4x1x2x3_1
BatchToSpaceParams(
Tensor({4, 1, 2, 3}, IN_ET, 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}),
Tensor({4}, element::i64, std::vector<int64_t>{1, 1, 2, 2}),
Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 2}),
Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 0}),
Tensor({1, 1, 4, 4}, IN_ET, std::vector<T>{2, 8, 3, 9, 14, 20, 15, 21,
5, 11, 6, 12, 17, 23, 18, 24}),
"input_with_shape_with_crop_4x1x2x3_1"),
// input_with_shape_with_crop_4x1x2x3_2
BatchToSpaceParams(
Tensor({4, 1, 2, 3}, IN_ET, 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}),
Tensor({4}, element::i64, std::vector<int64_t>{1, 1, 2, 2}),
Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 1, 0}),
Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 1, 0}),
Tensor({1, 1, 2, 6}, IN_ET, std::vector<T>{13, 19, 14, 20, 15, 21,
4, 10, 5, 11, 6, 12}),
"input_with_shape_with_crop_4x1x2x3_2"),
};
return batchToSpaceParams;
}
std::vector<BatchToSpaceParams> generateBatchToSpaceCombinedParams() {
const std::vector<std::vector<BatchToSpaceParams>> batchToSpaceTypeParams {
generateBatchToSpaceParams<element::Type_t::i8>(),
generateBatchToSpaceParams<element::Type_t::i16>(),
generateBatchToSpaceParams<element::Type_t::i32>(),
generateBatchToSpaceParams<element::Type_t::i64>(),
generateBatchToSpaceParams<element::Type_t::u8>(),
generateBatchToSpaceParams<element::Type_t::u16>(),
generateBatchToSpaceParams<element::Type_t::u32>(),
generateBatchToSpaceParams<element::Type_t::u64>(),
generateBatchToSpaceParams<element::Type_t::bf16>(),
generateBatchToSpaceParams<element::Type_t::f16>(),
generateBatchToSpaceParams<element::Type_t::f32>(),
generateBatchToSpaceParams<element::Type_t::f64>(),
};
std::vector<BatchToSpaceParams> combinedParams;
for (const auto& params : batchToSpaceTypeParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_BatchToSpace_With_Hardcoded_Refs, ReferenceBatchToSpaceLayerTest,
testing::ValuesIn(generateBatchToSpaceCombinedParams()), ReferenceBatchToSpaceLayerTest::getTestCaseName);
} // namespace

View File

@ -0,0 +1,171 @@
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include <openvino/core/function.hpp>
#include <tuple>
#include <openvino/op/i420_to_rgb.hpp>
#include <openvino/op/i420_to_bgr.hpp>
#include "base_reference_test.hpp"
#include "functional_test_utils/skip_tests_config.hpp"
using namespace ov;
using namespace InferenceEngine;
using namespace reference_tests;
class ReferenceConvertColorI420LayerTest : public testing::Test, public CommonReferenceTest {
public:
void SetUp() override {
SKIP_IF_CURRENT_TEST_IS_DISABLED()
abs_threshold = 1.f; // allow R, G, B absolute deviation to 1 (of max 255)
threshold = 1.f; // Ignore relative comparison (100%)
}
public:
template <typename T>
static std::shared_ptr<Function> CreateFunction(const Tensor& input) {
const auto in = std::make_shared<op::v0::Parameter>(input.type, input.shape);
std::shared_ptr<Node> conv;
conv = std::make_shared<T>(in);
auto res = std::make_shared<op::v0::Result>(conv);
return std::make_shared<Function>(ResultVector{res}, ParameterVector {in});
}
template <typename T>
static std::shared_ptr<Function> CreateFunction3(const Tensor& input1, const Tensor& input2, const Tensor& input3) {
const auto in1 = std::make_shared<op::v0::Parameter>(input1.type, input1.shape);
const auto in2 = std::make_shared<op::v0::Parameter>(input2.type, input2.shape);
const auto in3 = std::make_shared<op::v0::Parameter>(input3.type, input3.shape);
std::shared_ptr<Node> conv;
conv = std::make_shared<T>(in1, in2, in3);
auto res = std::make_shared<op::v0::Result>(conv);
return std::make_shared<Function>(ResultVector{res}, ParameterVector {in1, in2, in3});
}
};
TEST_F(ReferenceConvertColorI420LayerTest, CompareWithHardcodedRefs_r_u8_single_rgb) {
auto input = std::vector<uint8_t> {0x51, 0x51, 0x51, 0x51,
0x51, 0x51, 0x51, 0x51,
0x5a, 0x5a, 0xf0, 0xf0};
auto input_shape = Shape{1, 3, 4, 1};
auto exp_out = std::vector<uint8_t> {0xff, 0, 0, 0xff, 0, 0, 0xff, 0, 0, 0xff, 0, 0,
0xff, 0, 0, 0xff, 0, 0, 0xff, 0, 0, 0xff, 0, 0};
auto out_shape = Shape{1, 2, 4, 3};
Tensor inp_tensor(input_shape, element::u8, input);
inputData = {inp_tensor.data};
function = CreateFunction<op::v8::I420toRGB>(inp_tensor);
Tensor exp_tensor_u8(out_shape, element::u8, exp_out);
refOutData = {exp_tensor_u8.data};
Exec();
}
TEST_F(ReferenceConvertColorI420LayerTest, CompareWithHardcodedRefs_color_u8_single_bgr) {
auto input = std::vector<uint8_t> {0x51, 0xeb, 0x51, 0xeb,
0x51, 0xeb, 0x51, 0xeb,
0x6d, 0x6d, 0xb8, 0xb8};
auto input_shape = Shape{1, 6, 2, 1};
auto exp_out = std::vector<uint8_t> {37, 37, 164, 217, 216, 255, 37, 37, 164, 217, 216, 255,
37, 37, 164, 217, 216, 255, 37, 37, 164, 217, 216, 255};
auto out_shape = Shape{1, 4, 2, 3};
Tensor inp_tensor(input_shape, element::u8, input);
inputData = {inp_tensor.data};
Tensor exp_tensor_u8(out_shape, element::u8, exp_out);
refOutData = {exp_tensor_u8.data};
function = CreateFunction<op::v8::I420toBGR>(inp_tensor);
Exec();
}
TEST_F(ReferenceConvertColorI420LayerTest, CompareWithHardcodedRefs_g_fp32_single_rgb) {
auto input = std::vector<float> {145.f, 145.f, 145.f, 145.f,
145.f, 145.f, 145.f, 145.f,
54.f, 54.f, 34.f, 34.f};
auto input_shape = Shape{1, 3, 4, 1};
auto exp_out = std::vector<float> {0, 255.f, 0, 0, 255.f, 0, 0, 255.f, 0, 0, 255.f, 0,
0, 255.f, 0, 0, 255.f, 0, 0, 255.f, 0, 0, 255.f, 0};
auto out_shape = Shape{1, 2, 4, 3};
Tensor inp_tensor(input_shape, element::f32, input);
inputData = {inp_tensor.data};
Tensor exp_tensor(out_shape, element::f32, exp_out);
refOutData = {exp_tensor.data};
function = CreateFunction<op::v8::I420toRGB>(inp_tensor);
Exec();
}
TEST_F(ReferenceConvertColorI420LayerTest, CompareWithHardcodedRefs_batch_fp32_three_bgr) {
auto input_y = std::vector<float> {81.f, 81.f, 81.f, 81.f,
145.f, 145.f, 145.f, 145.f,
41.f, 41.f, 41.f, 41.f};
auto input_shape_y = Shape{3, 2, 2, 1};
auto input_u = std::vector<float> {90.,
54.,
240.};
auto input_shape_u = Shape{3, 1, 1, 1};
auto input_v = std::vector<float> {240.,
34.,
110.};
auto input_shape_v = Shape{3, 1, 1, 1};
auto exp_out = std::vector<float> {0, 0, 255., 0, 0, 255., 0, 0, 255., 0, 0, 255.,
0, 255., 0, 0, 255., 0, 0, 255., 0, 0, 255., 0,
255., 0, 0, 255., 0, 0, 255., 0, 0, 255., 0, 0};
auto out_shape = Shape{3, 2, 2, 3};
Tensor inp_tensor_y(input_shape_y, element::f32, input_y);
Tensor inp_tensor_u(input_shape_u, element::f32, input_u);
Tensor inp_tensor_v(input_shape_v, element::f32, input_v);
inputData = {inp_tensor_y.data, inp_tensor_u.data, inp_tensor_v.data};
Tensor exp_tensor(out_shape, element::f32, exp_out);
refOutData = {exp_tensor.data};
function = CreateFunction3<op::v8::I420toBGR>(inp_tensor_y, inp_tensor_u, inp_tensor_v);
Exec();
}
TEST_F(ReferenceConvertColorI420LayerTest, CompareWithHardcodedRefs_color4x4_f32_three_rgb) {
auto input_y = std::vector<float> {81, 235,
81, 235,
81, 81,
81, 81,
145, 145,
145, 145,
41, 41,
41, 41};
auto input_shape_y = Shape{1, 8, 2, 1};
auto input_u = std::vector<float> {109, 90, 54, 240};
auto input_shape_u = Shape{1, 4, 1, 1};
auto input_v = std::vector<float> {184, 240, 34, 110};
auto input_shape_v = Shape{1, 4, 1, 1};
auto exp_out = std::vector<float> {165, 37, 37, 255, 216, 217, 165, 37, 37, 255, 216, 217,
255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0,
0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0,
0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255};
auto out_shape = Shape{1, 2, 2, 3};
Tensor inp_tensor_y(input_shape_y, element::f32, input_y);
Tensor inp_tensor_u(input_shape_u, element::f32, input_u);
Tensor inp_tensor_v(input_shape_v, element::f32, input_v);
inputData = {inp_tensor_y.data, inp_tensor_u.data, inp_tensor_v.data};
Tensor exp_tensor(out_shape, element::f32, exp_out);
refOutData = {exp_tensor.data};
function = CreateFunction3<op::v8::I420toRGB>(inp_tensor_y, inp_tensor_u, inp_tensor_v);
Exec();
}

View File

@ -0,0 +1,132 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "openvino/op/ctc_greedy_decoder.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
using namespace ov;
namespace {
struct CTCGreedyDecoderParams {
CTCGreedyDecoderParams(
const Tensor& dataTensor, const Tensor& masksTensor, int64_t ctcMergedRepeat,
const Tensor& expectedTensor, const std::string& testcaseName = "") :
dataTensor(dataTensor), masksTensor(masksTensor), ctcMergedRepeat(ctcMergedRepeat),
expectedTensor(expectedTensor), testcaseName(testcaseName) {}
Tensor dataTensor;
Tensor masksTensor;
bool ctcMergedRepeat;
Tensor expectedTensor;
std::string testcaseName;
};
class ReferenceCTCGreedyDecoderTest : public testing::TestWithParam<CTCGreedyDecoderParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params);
inputData = {params.dataTensor.data, params.masksTensor.data};
refOutData = {params.expectedTensor.data};
}
static std::string getTestCaseName(const testing::TestParamInfo<CTCGreedyDecoderParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "dType=" << param.dataTensor.type;
result << "_dShape=" << param.dataTensor.shape;
result << "_aType=" << param.masksTensor.type;
result << "_aShape=" << param.masksTensor.shape;
result << "_bDims=" << param.ctcMergedRepeat;
result << "_eType=" << param.expectedTensor.type;
if (param.testcaseName != "") {
result << "_eShape=" << param.expectedTensor.shape;
result << "_=" << param.testcaseName;
} else {
result << "_eShape=" << param.expectedTensor.shape;
}
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(const CTCGreedyDecoderParams& params) {
std::shared_ptr<Function> function;
const auto data = std::make_shared<op::v0::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto indices = std::make_shared<op::v0::Parameter>(params.masksTensor.type, params.masksTensor.shape);
const auto decoder = std::make_shared<op::v0::CTCGreedyDecoder>(data, indices, params.ctcMergedRepeat);
function = std::make_shared<ov::Function>(NodeVector{decoder}, ParameterVector{data, indices});
return function;
}
};
TEST_P(ReferenceCTCGreedyDecoderTest, CompareWithRefs) {
Exec();
}
template <element::Type_t IN_ET>
std::vector<CTCGreedyDecoderParams> generateParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<CTCGreedyDecoderParams> params {
CTCGreedyDecoderParams(
Tensor(IN_ET, {3, 1, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.4f, 0.3f, 0.f, 0.5f, 0.6f, 0.f}),
Tensor(IN_ET, {3, 1}, std::vector<T>{1.0f, 1.0f, 1.0f}),
false,
Tensor(IN_ET, {1, 3, 1, 1}, std::vector<T>{1.0f, 0.0f, 1.0f}),
"ctc_greedy_decoder"),
CTCGreedyDecoderParams(
Tensor(IN_ET, {3, 2, 3}, std::vector<T>{
0.1f, 0.2f, 0.f, 0.15f, 0.25f, 0.f, 0.4f, 0.3f, 0.f, 0.45f, 0.35f, 0.f, 0.5f, 0.6f, 0.f, 0.55f, 0.65f, 0.f}),
Tensor(IN_ET, {3, 2}, std::vector<T>{1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f}),
false,
Tensor(IN_ET, {2, 3, 1, 1}, std::vector<T>{1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f}),
"ctc_greedy_decoder_multiple_batches"),
CTCGreedyDecoderParams(
Tensor(IN_ET, {3, 1, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.4f, 0.3f, 0.f, 0.5f, 0.6f, 0.f}),
Tensor(IN_ET, {3, 1}, std::vector<T>{1.0f, 1.0f, 0.0f}),
false,
Tensor(IN_ET, {1, 3, 1, 1}, std::vector<T>{1.0f, 0.0f, -1.0f}),
"ctc_greedy_decoder_single_batch_short_sequence"),
CTCGreedyDecoderParams(
Tensor(IN_ET, {3, 1, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.3f, 0.4f, 0.f, 0.6f, 0.5f, 0.f}),
Tensor(IN_ET, {3, 1}, std::vector<T>{1.0f, 1.0f, 1.0f}),
true,
Tensor(IN_ET, {1, 3, 1, 1}, std::vector<T>{1.0f, 0.0f, -1.0f}),
"ctc_greedy_decoder_merge"),
CTCGreedyDecoderParams(
Tensor(IN_ET, {3, 1, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.3f, 0.4f, 0.f, 0.6f, 0.5f, 0.f}),
Tensor(IN_ET, {3, 1}, std::vector<T>{1.0f, 1.0f, 1.0f}),
false,
Tensor(IN_ET, {1, 3, 1, 1}, std::vector<T>{1.0f, 1.0f, 0.0f}),
"ctc_greedy_decoder_single_no_merge"),
CTCGreedyDecoderParams(
Tensor(IN_ET, {2, 2, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.4f, 0.3f, 0.f, 0.5f, 0.6f, 0.f, 0.7f, 0.8f, 0.f}),
Tensor(IN_ET, {2, 2}, std::vector<T>{1.0f, 1.0f, 1.0f, 0.0f}),
false,
Tensor(IN_ET, {2, 2, 1, 1}, std::vector<T>{1.0f, 1.0f, 0.0f, -1.0f}),
"ctc_greedy_decoder_multiple_sequences"),
};
return params;
}
std::vector<CTCGreedyDecoderParams> generateCombinedParams() {
const std::vector<std::vector<CTCGreedyDecoderParams>> generatedParams {
generateParams<element::Type_t::bf16>(),
generateParams<element::Type_t::f16>(),
generateParams<element::Type_t::f32>(),
generateParams<element::Type_t::f64>(),
};
std::vector<CTCGreedyDecoderParams> combinedParams;
for (const auto& params : generatedParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_CTCGreedyDecoder_With_Hardcoded_Refs, ReferenceCTCGreedyDecoderTest,
testing::ValuesIn(generateCombinedParams()), ReferenceCTCGreedyDecoderTest::getTestCaseName);
} // namespace

View File

@ -0,0 +1,228 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "openvino/op/ctc_greedy_decoder_seq_len.hpp"
#include "openvino/op/constant.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
using namespace ov;
namespace {
struct CTCGreedyDecoderSeqLenParams {
CTCGreedyDecoderSeqLenParams(
const Tensor& dataTensor, const Tensor& seqLenTensor, const Tensor& blankIndexTensor, int64_t mergeRepeated,
const Tensor& expectedTensor, const Tensor& expectedTensor2, const std::string& testcaseName = "") :
dataTensor(dataTensor), seqLenTensor(seqLenTensor), blankIndexTensor(blankIndexTensor), mergeRepeated(mergeRepeated),
expectedTensor(expectedTensor), expectedTensor2(expectedTensor2), testcaseName(testcaseName) {}
Tensor dataTensor;
Tensor seqLenTensor;
Tensor blankIndexTensor;
bool mergeRepeated;
Tensor expectedTensor;
Tensor expectedTensor2;
std::string testcaseName;
};
struct CTCGreedyDecoderSeqLenParamsNoOptionalInput {
CTCGreedyDecoderSeqLenParamsNoOptionalInput(
const Tensor& dataTensor, const Tensor& seqLenTensor, int64_t mergeRepeated,
const Tensor& expectedTensor, const Tensor& expectedTensor2, const std::string& testcaseName = "") :
dataTensor(dataTensor), seqLenTensor(seqLenTensor), mergeRepeated(mergeRepeated),
expectedTensor(expectedTensor), expectedTensor2(expectedTensor2), testcaseName(testcaseName) {}
Tensor dataTensor;
Tensor seqLenTensor;
bool mergeRepeated;
Tensor expectedTensor;
Tensor expectedTensor2;
std::string testcaseName;
};
class ReferenceCTCGreedyDecoderSeqLenTest : public testing::TestWithParam<CTCGreedyDecoderSeqLenParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params);
inputData = {params.dataTensor.data, params.seqLenTensor.data};
refOutData = {params.expectedTensor.data, params.expectedTensor2.data};
}
static std::string getTestCaseName(const testing::TestParamInfo<CTCGreedyDecoderSeqLenParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "dType=" << param.dataTensor.type;
result << "_dShape=" << param.dataTensor.shape;
result << "_sType=" << param.seqLenTensor.type;
result << "_sShape=" << param.seqLenTensor.shape;
result << "_bType=" << param.blankIndexTensor.type;
result << "_bShape=" << param.blankIndexTensor.shape;
result << "_mRepeated=" << param.mergeRepeated;
result << "_eType=" << param.expectedTensor.type;
if (param.testcaseName != "") {
result << "_eShape=" << param.expectedTensor.shape;
result << "_=" << param.testcaseName;
} else {
result << "_eShape=" << param.expectedTensor.shape;
}
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(const CTCGreedyDecoderSeqLenParams& params) {
std::shared_ptr<Function> function;
const auto data = std::make_shared<op::v0::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto seq_len = std::make_shared<op::v0::Parameter>(params.seqLenTensor.type, params.seqLenTensor.shape);
auto blank_index = std::make_shared<op::v0::Constant>(params.blankIndexTensor.type, params.blankIndexTensor.shape,
params.blankIndexTensor.data.data());
const auto decoder = std::make_shared<op::v6::CTCGreedyDecoderSeqLen>(data, seq_len, blank_index, params.mergeRepeated);
function = std::make_shared<ov::Function>(decoder->outputs(), ParameterVector{data, seq_len});
return function;
}
};
class ReferenceCTCGreedyDecoderSeqLenTestNoOptionalInput :
public testing::TestWithParam<CTCGreedyDecoderSeqLenParamsNoOptionalInput>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params);
inputData = {params.dataTensor.data, params.seqLenTensor.data};
refOutData = {params.expectedTensor.data, params.expectedTensor2.data};
}
static std::string getTestCaseName(const testing::TestParamInfo<CTCGreedyDecoderSeqLenParamsNoOptionalInput>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "dType=" << param.dataTensor.type;
result << "_dShape=" << param.dataTensor.shape;
result << "_sType=" << param.seqLenTensor.type;
result << "_sShape=" << param.seqLenTensor.shape;
result << "_mRepeated=" << param.mergeRepeated;
result << "_eType=" << param.expectedTensor.type;
if (param.testcaseName != "") {
result << "_eShape=" << param.expectedTensor.shape;
result << "_=" << param.testcaseName;
} else {
result << "_eShape=" << param.expectedTensor.shape;
}
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(const CTCGreedyDecoderSeqLenParamsNoOptionalInput& params) {
std::shared_ptr<Function> function;
const auto data = std::make_shared<op::v0::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto seq_len = std::make_shared<op::v0::Parameter>(params.seqLenTensor.type, params.seqLenTensor.shape);
const auto decoder = std::make_shared<op::v6::CTCGreedyDecoderSeqLen>(data, seq_len, params.mergeRepeated);
function = std::make_shared<ov::Function>(decoder->outputs(), ParameterVector{data, seq_len});
return function;
}
};
TEST_P(ReferenceCTCGreedyDecoderSeqLenTest, CompareWithRefs) {
Exec();
}
TEST_P(ReferenceCTCGreedyDecoderSeqLenTestNoOptionalInput, CompareWithRefs) {
Exec();
}
template <element::Type_t ET>
std::vector<CTCGreedyDecoderSeqLenParams> generateParams() {
using T = typename element_type_traits<ET>::value_type;
std::vector<CTCGreedyDecoderSeqLenParams> params {
CTCGreedyDecoderSeqLenParams(
Tensor(ET, {1, 3, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.4f, 0.3f, 0.f, 0.5f, 0.6f, 0.f}),
Tensor(element::i32, {1}, std::vector<int32_t>{2}),
Tensor(element::i32, {}, std::vector<int32_t>{2}),
false,
Tensor(element::i32, {1, 3}, std::vector<int32_t>{1, 0, -1}),
Tensor(element::i32, {1}, std::vector<int32_t>{2}),
"evaluate_ctc_greedy_decoder_seq_len"),
CTCGreedyDecoderSeqLenParams(
Tensor(ET, {1, 3, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.4f, 0.3f, 0.f, 0.5f, 0.6f, 0.f}),
Tensor(element::i32, {1}, std::vector<int32_t>{2}),
Tensor(element::i32, {}, std::vector<int32_t>{2}),
true,
Tensor(element::i32, {1, 3}, std::vector<int32_t>{1, 0, -1}),
Tensor(element::i32, {1}, std::vector<int32_t>{2}),
"evaluate_ctc_greedy_decoder_seq_len_merge"),
CTCGreedyDecoderSeqLenParams(
Tensor(ET, {2, 3, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.15f, 0.25f, 0.f, 0.4f, 0.3f, 0.f,
0.45f, 0.35f, 0.f, 0.5f, 0.6f, 0.f, 0.55f, 0.65f, 0.f}),
Tensor(element::i32, {2}, std::vector<int32_t>{1, 1}),
Tensor(element::i32, {}, std::vector<int32_t>{2}),
false,
Tensor(element::i32, {2, 3}, std::vector<int32_t>{1, -1, -1, 0, -1, -1}),
Tensor(element::i32, {2}, std::vector<int32_t>{1, 1}),
"evaluate_ctc_greedy_decoder_seq_len_multiple_batches"),
CTCGreedyDecoderSeqLenParams(
Tensor(ET, {3, 3, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.15f, 0.25f, 0.f, 0.4f, 0.3f, 0.f,
0.45f, 0.35f, 0.f, 0.5f, 0.6f, 0.f, 0.55f, 0.65f, 0.f,
0.1f, 0.2f, 0.f, 0.15f, 0.25f, 0.f, 0.4f, 0.3f, 0.f}),
Tensor(element::i32, {3}, std::vector<int32_t>{2, 3, 1}),
Tensor(element::i32, {}, std::vector<int32_t>{2}),
false,
Tensor(element::i32, {3, 3}, std::vector<int32_t>{1, 1, -1, 0, 1, 1, 1, -1, -1}),
Tensor(element::i32, {3}, std::vector<int32_t>{2, 3, 1}),
"evaluate_ctc_greedy_decoder_seq_len_multiple_batches2"),
};
return params;
}
std::vector<CTCGreedyDecoderSeqLenParams> generateCombinedParams() {
const std::vector<std::vector<CTCGreedyDecoderSeqLenParams>> generatedParams {
generateParams<element::Type_t::bf16>(),
generateParams<element::Type_t::f16>(),
generateParams<element::Type_t::f32>(),
generateParams<element::Type_t::f64>(),
};
std::vector<CTCGreedyDecoderSeqLenParams> combinedParams;
for (const auto& params : generatedParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
template <element::Type_t ET>
std::vector<CTCGreedyDecoderSeqLenParamsNoOptionalInput> generateParamsNoOptionalInput() {
using T = typename element_type_traits<ET>::value_type;
std::vector<CTCGreedyDecoderSeqLenParamsNoOptionalInput> params {
CTCGreedyDecoderSeqLenParamsNoOptionalInput(
Tensor(ET, {1, 3, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.4f, 0.3f, 0.f, 0.5f, 0.6f, 0.f}),
Tensor(element::i32, {1}, std::vector<int32_t>{2}),
false,
Tensor(element::i32, {1, 3}, std::vector<int32_t>{1, 0, -1}),
Tensor(element::i32, {1}, std::vector<int32_t>{2}),
"evaluate_ctc_greedy_decoder_seq_len_no_optional_input"),
};
return params;
}
std::vector<CTCGreedyDecoderSeqLenParamsNoOptionalInput> generateCombinedParamsNoOptionalInput() {
const std::vector<std::vector<CTCGreedyDecoderSeqLenParamsNoOptionalInput>> generatedParams {
generateParamsNoOptionalInput<element::Type_t::bf16>(),
generateParamsNoOptionalInput<element::Type_t::f16>(),
generateParamsNoOptionalInput<element::Type_t::f32>(),
generateParamsNoOptionalInput<element::Type_t::f64>(),
};
std::vector<CTCGreedyDecoderSeqLenParamsNoOptionalInput> combinedParams;
for (const auto& params : generatedParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_CTCGreedyDecoderSeqLen_With_Hardcoded_Refs, ReferenceCTCGreedyDecoderSeqLenTest,
testing::ValuesIn(generateCombinedParams()), ReferenceCTCGreedyDecoderSeqLenTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_CTCGreedyDecoderSeqLen_With_Hardcoded_Refs, ReferenceCTCGreedyDecoderSeqLenTestNoOptionalInput,
testing::ValuesIn(generateCombinedParamsNoOptionalInput()), ReferenceCTCGreedyDecoderSeqLenTestNoOptionalInput::getTestCaseName);
} // namespace

View File

@ -0,0 +1,157 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "openvino/opsets/opset1.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
using namespace ov;
namespace {
struct DepthToSpaceParams {
DepthToSpaceParams(const Tensor& dataTensor, const std::string mode, const int32_t blockSize,
const Tensor& expectedTensor, const std::string& testcaseName = "") :
dataTensor(dataTensor), mode(mode), blockSize(blockSize), expectedTensor(expectedTensor),
testcaseName(testcaseName) {}
Tensor dataTensor;
std::string mode;
int32_t blockSize;
Tensor expectedTensor;
std::string testcaseName;
};
class ReferenceDepthToSpaceLayerTest : public testing::TestWithParam<DepthToSpaceParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params);
inputData = {params.dataTensor.data};
refOutData = {params.expectedTensor.data};
}
static std::string getTestCaseName(const testing::TestParamInfo<DepthToSpaceParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "dType=" << param.dataTensor.type;
result << "_dShape=" << param.dataTensor.shape;
result << "_eType=" << param.expectedTensor.type;
if (param.testcaseName != "") {
result << "_eShape=" << param.expectedTensor.shape;
result << "_" << param.testcaseName;
} else {
result << "_eShape=" << param.expectedTensor.shape;
}
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(const DepthToSpaceParams& params) {
opset1::DepthToSpace::DepthToSpaceMode mode = params.mode == "DEPTH_FIRST" ?
opset1::DepthToSpace::DepthToSpaceMode::DEPTH_FIRST : opset1::DepthToSpace::DepthToSpaceMode::BLOCKS_FIRST;
const auto data = std::make_shared<opset1::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto depthToSpace = std::make_shared<opset1::DepthToSpace>(data, mode, params.blockSize);
return std::make_shared<Function>(NodeVector {depthToSpace}, ParameterVector {data});
}
};
TEST_P(ReferenceDepthToSpaceLayerTest, CompareWithRefs) {
Exec();
}
template <element::Type_t IN_ET>
std::vector<DepthToSpaceParams> generateDepthToSpaceParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<DepthToSpaceParams> depthToSpaceParams {
// depth_to_space_block_first_K1_BS2
DepthToSpaceParams(
Tensor({1, 8, 2}, IN_ET, std::vector<T>{0, 2, 8, 10, 16, 18, 24, 26, 1, 3, 9, 11, 17, 19, 25, 27}),
"BLOCKS_FIRST",
2,
Tensor({1, 4, 4}, IN_ET, std::vector<T>{0, 1, 2, 3, 8, 9, 10, 11, 16, 17, 18, 19, 24, 25, 26, 27}),
"depth_to_space_block_first_K1_BS2"),
// depth_to_space_block_first_K2_BS2
DepthToSpaceParams(
Tensor({1, 8, 2, 2}, IN_ET, std::vector<T>{0, 2, 8, 10, 16, 18, 24, 26, 1, 3, 9,
11, 17, 19, 25, 27, 4, 6, 12, 14, 20, 22,
28, 30, 5, 7, 13, 15, 21, 23, 29, 31}),
"BLOCKS_FIRST",
2,
Tensor({1, 2, 4, 4}, IN_ET, std::vector<T>{0, 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}),
"depth_to_space_block_first_K2_BS2"),
// depth_to_space_block_first_K2_BS4
DepthToSpaceParams(
Tensor({1, 16, 2, 1}, IN_ET, std::vector<T>{0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5,
21, 6, 22, 7, 23, 8, 24, 9, 25, 10, 26,
11, 27, 12, 28, 13, 29, 14, 30, 15, 31}),
"BLOCKS_FIRST",
4,
Tensor({1, 1, 8, 4}, IN_ET, std::vector<T>{0, 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}),
"depth_to_space_block_first_K2_BS4"),
// depth_to_space_depth_first_1K_BS2
DepthToSpaceParams(
Tensor({1, 8, 2}, IN_ET, std::vector<T>{0, 2, 1, 3, 4, 6, 5, 7, 8, 10, 9, 11, 12, 14, 13, 15}),
"DEPTH_FIRST",
2,
Tensor({1, 4, 4}, IN_ET, std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}),
"depth_to_space_depth_first_1K_BS2"),
// depth_to_space_depth_first_2K_BS2
DepthToSpaceParams(
Tensor({1, 8, 2, 2}, IN_ET, std::vector<T>{0, 2, 8, 10, 16, 18, 24, 26, 1, 3, 9,
11, 17, 19, 25, 27, 4, 6, 12, 14, 20, 22,
28, 30, 5, 7, 13, 15, 21, 23, 29, 31}),
"DEPTH_FIRST",
2,
Tensor({1, 2, 4, 4}, IN_ET, std::vector<T>{0, 16, 2, 18, 1, 17, 3, 19, 8, 24, 10, 26, 9, 25, 11, 27,
4, 20, 6, 22, 5, 21, 7, 23, 12, 28, 14, 30, 13, 29, 15, 31}),
"depth_to_space_depth_first_2K_BS2"),
// depth_to_space_depth_first_2K_BS4
DepthToSpaceParams(
Tensor({1, 16, 2, 1}, IN_ET, std::vector<T>{0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5,
21, 6, 22, 7, 23, 8, 24, 9, 25, 10, 26,
11, 27, 12, 28, 13, 29, 14, 30, 15, 31}),
"DEPTH_FIRST",
4,
Tensor({1, 1, 8, 4}, IN_ET, std::vector<T>{0, 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}),
"depth_to_space_depth_first_2K_BS4"),
};
return depthToSpaceParams;
}
std::vector<DepthToSpaceParams> generateDepthToSpaceCombinedParams() {
const std::vector<std::vector<DepthToSpaceParams>> depthToSpaceTypeParams {
generateDepthToSpaceParams<element::Type_t::i8>(),
generateDepthToSpaceParams<element::Type_t::i16>(),
generateDepthToSpaceParams<element::Type_t::i32>(),
generateDepthToSpaceParams<element::Type_t::i64>(),
generateDepthToSpaceParams<element::Type_t::u8>(),
generateDepthToSpaceParams<element::Type_t::u16>(),
generateDepthToSpaceParams<element::Type_t::u32>(),
generateDepthToSpaceParams<element::Type_t::u64>(),
generateDepthToSpaceParams<element::Type_t::bf16>(),
generateDepthToSpaceParams<element::Type_t::f16>(),
generateDepthToSpaceParams<element::Type_t::f32>(),
generateDepthToSpaceParams<element::Type_t::f64>(),
};
std::vector<DepthToSpaceParams> combinedParams;
for (const auto& params : depthToSpaceTypeParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_DepthToSpace_With_Hardcoded_Refs, ReferenceDepthToSpaceLayerTest,
testing::ValuesIn(generateDepthToSpaceCombinedParams()), ReferenceDepthToSpaceLayerTest::getTestCaseName);
} // namespace

View File

@ -0,0 +1,214 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include <shared_test_classes/base/layer_test_utils.hpp>
#include "base_reference_test.hpp"
using namespace reference_tests;
using namespace ngraph;
using namespace InferenceEngine;
struct EmbeddingSegmentsSumParams {
template <class IT>
EmbeddingSegmentsSumParams(const ov::PartialShape& iShape,
const ov::element::Type& iType,
const std::vector<IT>& iValues,
const ov::PartialShape& oShape,
const ov::element::Type& oType,
const std::vector<IT>& oValues,
const std::shared_ptr<ngraph::opset1::Constant>& indices,
const std::shared_ptr<ngraph::opset1::Constant>& segment_ids,
const std::shared_ptr<ngraph::opset1::Constant>& num_segments,
const std::shared_ptr<ngraph::opset1::Constant>& default_index = nullptr,
const std::shared_ptr<ngraph::opset1::Constant>& per_sample_weights = nullptr)
: _iShape(iShape),
_iType(iType),
_iData(CreateTensor(iType, iValues)),
_refShape(oShape),
_refType(oType),
_refData(CreateTensor(oType, oValues)) {
_segmentIds = segment_ids;
_indices = indices;
_numSegments = num_segments;
_defaultIndex = default_index;
_perSampleWeights = per_sample_weights;
}
ov::PartialShape _iShape;
ov::element::Type _iType;
ov::runtime::Tensor _iData;
ov::PartialShape _refShape;
ov::element::Type _refType;
ov::runtime::Tensor _refData;
std::shared_ptr<ngraph::opset1::Constant> _indices;
std::shared_ptr<ngraph::opset1::Constant> _segmentIds;
std::shared_ptr<ngraph::opset1::Constant> _numSegments;
std::shared_ptr<ngraph::opset1::Constant> _defaultIndex; // Optional, default filled zero.
std::shared_ptr<ngraph::opset1::Constant> _perSampleWeights; // Optional, default is tensor of ones.
};
class ReferenceEmbeddingSegmentsSumLayerTest : public testing::TestWithParam<EmbeddingSegmentsSumParams>,
public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params._iShape,
params._iType,
params._indices,
params._segmentIds,
params._numSegments,
params._defaultIndex,
params._perSampleWeights);
inputData = {params._iData};
refOutData = {params._refData};
}
static std::string getTestCaseName(const testing::TestParamInfo<EmbeddingSegmentsSumParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "_iShape=" << param._iShape << "_";
result << "_iType=" << param._iType << "_";
result << "_refShape=" << param._refShape << "_";
result << "_refType=" << param._refType;
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(
const PartialShape& input_shape,
const element::Type& input_type,
const std::shared_ptr<ngraph::opset1::Constant> indices,
const std::shared_ptr<ngraph::opset1::Constant> segment_ids,
const std::shared_ptr<ngraph::opset1::Constant> num_segments,
const std::shared_ptr<ngraph::opset1::Constant> default_index,
const std::shared_ptr<ngraph::opset1::Constant> per_sample_weights) {
const auto in = std::make_shared<op::Parameter>(input_type, input_shape);
if (default_index) {
if (per_sample_weights) {
const auto ess = std::make_shared<op::v3::EmbeddingSegmentsSum>(in,
indices,
segment_ids,
num_segments,
default_index,
per_sample_weights);
return std::make_shared<Function>(NodeVector{ess}, ParameterVector{in});
} else {
const auto ess = std::make_shared<op::v3::EmbeddingSegmentsSum>(in,
indices,
segment_ids,
num_segments,
default_index);
return std::make_shared<Function>(NodeVector{ess}, ParameterVector{in});
}
} else {
const auto ess = std::make_shared<op::v3::EmbeddingSegmentsSum>(in, indices, segment_ids, num_segments);
return std::make_shared<Function>(NodeVector{ess}, ParameterVector{in});
}
}
};
TEST_P(ReferenceEmbeddingSegmentsSumLayerTest, CompareWithRefs) {
Exec();
}
INSTANTIATE_TEST_SUITE_P(
smoke_EmbeddingSegmentsSum_With_Hardcoded_Refs,
ReferenceEmbeddingSegmentsSumLayerTest,
::testing::Values(
EmbeddingSegmentsSumParams(
ov::PartialShape{5, 2},
ov::element::f32,
std::vector<float>{-0.2, -0.6, -0.1, -0.4, -1.9, -1.8, -1., 1.5, 0.8, -0.7},
ov::PartialShape{3, 2},
ov::element::f32,
{-1.05f, -1.2f, -0.2f, -0.6f, -0.1f, 0.4f},
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape({4}), std::vector<int32_t>{0, 2, 3, 4}),
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape({4}), std::vector<int32_t>{0, 0, 2, 2}),
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape(), std::vector<int32_t>{3}),
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape(), std::vector<int32_t>{0}),
std::make_shared<ngraph::opset1::Constant>(element::f32,
ov::Shape({4}),
std::vector<float>{0.5, 0.5, 0.5, 0.5})),
EmbeddingSegmentsSumParams(
ov::PartialShape{5, 2},
ov::element::f64,
std::vector<double>{-0.2, -0.6, -0.1, -0.4, -1.9, -1.8, -1., 1.5, 0.8, -0.7},
ov::PartialShape{3, 2},
ov::element::f64,
std::vector<double>{-2.1, -2.4, -0.2, -0.6, -0.2, 0.8},
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape({4}), std::vector<int32_t>{0, 2, 3, 4}),
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape({4}), std::vector<int32_t>{0, 0, 2, 2}),
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape(), std::vector<int32_t>{3}),
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape(), std::vector<int32_t>{0})),
EmbeddingSegmentsSumParams(
ov::PartialShape{5, 2},
ov::element::i32,
std::vector<int32_t>{-1, 2, 3, 4, -5, -6, -7, 8, 9, 10},
ov::PartialShape{3, 2},
ov::element::i32,
std::vector<int32_t>{-6, -4, 0, 0, 2, 18},
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape({4}), std::vector<int32_t>{0, 2, 3, 4}),
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape({4}), std::vector<int32_t>{0, 0, 2, 2}),
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape(), std::vector<int32_t>{3})),
EmbeddingSegmentsSumParams(
ov::PartialShape{5, 2},
ov::element::u32,
std::vector<uint32_t>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
ov::PartialShape{3, 2},
ov::element::u32,
std::vector<uint32_t>{6, 8, 3, 4, 16, 18},
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape({4}), std::vector<int32_t>{0, 2, 3, 4}),
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape({4}), std::vector<int32_t>{0, 0, 2, 2}),
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape(), std::vector<int32_t>{3}),
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape(), std::vector<int32_t>{1})),
EmbeddingSegmentsSumParams(
ov::PartialShape{5, 2},
ov::element::f16,
std::vector<float16>{-0.2, -0.6, -0.1, -0.4, -1.9, -1.8, -1., 1.5, 0.8, -0.7},
ov::PartialShape{3, 2},
ov::element::f16,
std::vector<float16>{-2.1, -2.4, 0, 0, -0.2, 0.8},
std::make_shared<ngraph::opset1::Constant>(element::i64, ov::Shape({4}), std::vector<int64_t>{0, 2, 3, 4}),
std::make_shared<ngraph::opset1::Constant>(element::i64, ov::Shape({4}), std::vector<int64_t>{0, 0, 2, 2}),
std::make_shared<ngraph::opset1::Constant>(element::i64, ov::Shape(), std::vector<int64_t>{3})),
EmbeddingSegmentsSumParams(
ov::PartialShape{5, 2},
ov::element::i64,
std::vector<int64_t>{-1, 2, 3, 4, -5, -6, -7, 8, 9, 10},
ov::PartialShape{3, 2},
ov::element::i64,
std::vector<int64_t>{-6, -4, -1, 2, 2, 18},
std::make_shared<ngraph::opset1::Constant>(element::i64, ov::Shape({4}), std::vector<int64_t>{0, 2, 3, 4}),
std::make_shared<ngraph::opset1::Constant>(element::i64, ov::Shape({4}), std::vector<int64_t>{0, 0, 2, 2}),
std::make_shared<ngraph::opset1::Constant>(element::i64, ov::Shape(), std::vector<int64_t>{3}),
std::make_shared<ngraph::opset1::Constant>(element::i64, ov::Shape(), std::vector<int64_t>{0})),
EmbeddingSegmentsSumParams(
ov::PartialShape{5, 2},
ov::element::i8,
std::vector<int8_t>{-1, 2, 3, 4, -5, -6, -7, 8, 9, 10},
ov::PartialShape{3, 2},
ov::element::i8,
std::vector<int8_t>{-12, -8, -1, 2, 4, 36},
std::make_shared<ngraph::opset1::Constant>(element::i64, ov::Shape({4}), std::vector<int64_t>{0, 2, 3, 4}),
std::make_shared<ngraph::opset1::Constant>(element::i64, ov::Shape({4}), std::vector<int64_t>{0, 0, 2, 2}),
std::make_shared<ngraph::opset1::Constant>(element::i64, ov::Shape(), std::vector<int64_t>{3}),
std::make_shared<ngraph::opset1::Constant>(element::i64, ov::Shape(), std::vector<int64_t>{0}),
std::make_shared<ngraph::opset1::Constant>(element::i8, ov::Shape({4}), std::vector<int8_t>{2, 2, 2, 2})),
EmbeddingSegmentsSumParams(
ov::PartialShape{5, 2},
ov::element::u8,
std::vector<uint8_t>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
ov::PartialShape{3, 2},
ov::element::u8,
std::vector<uint8_t>{6, 8, 1, 2, 16, 18},
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape({4}), std::vector<int32_t>{0, 2, 3, 4}),
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape({4}), std::vector<int32_t>{0, 0, 2, 2}),
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape(), std::vector<int32_t>{3}),
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape(), std::vector<int32_t>{0}))),
ReferenceEmbeddingSegmentsSumLayerTest::getTestCaseName);

View File

@ -0,0 +1,195 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include <shared_test_classes/base/layer_test_utils.hpp>
#include "base_reference_test.hpp"
using namespace reference_tests;
using namespace ngraph;
using namespace InferenceEngine;
struct EmbeddingBagOffsetsSumParams {
template <class IT>
EmbeddingBagOffsetsSumParams(const ov::PartialShape& iShape,
const ov::element::Type& iType,
const std::vector<IT>& iValues,
const ov::PartialShape& oShape,
const ov::element::Type& oType,
const std::vector<IT>& oValues,
const std::shared_ptr<ngraph::opset1::Constant>& indices,
const std::shared_ptr<ngraph::opset1::Constant>& offsets,
const std::shared_ptr<ngraph::opset1::Constant>& default_index = nullptr,
const std::shared_ptr<ngraph::opset1::Constant>& per_sample_weights = nullptr)
: _iShape(iShape),
_iType(iType),
_iData(CreateTensor(iType, iValues)),
_refShape(oShape),
_refType(oType),
_refData(CreateTensor(oType, oValues)) {
_indices = indices;
_offsets = offsets;
_defaultIndex = default_index;
_perSampleWeights = per_sample_weights;
}
ov::PartialShape _iShape;
ov::element::Type _iType;
ov::runtime::Tensor _iData;
ov::PartialShape _refShape;
ov::element::Type _refType;
ov::runtime::Tensor _refData;
std::shared_ptr<ngraph::opset1::Constant> _indices;
std::shared_ptr<ngraph::opset1::Constant> _offsets;
std::shared_ptr<ngraph::opset1::Constant> _defaultIndex; // Optional, default filled zero.
std::shared_ptr<ngraph::opset1::Constant> _perSampleWeights; // Optional, default is tensor of ones.
};
class ReferenceEmbeddingBagOffsetsSumLayerTest : public testing::TestWithParam<EmbeddingBagOffsetsSumParams>,
public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params._iShape,
params._iType,
params._indices,
params._offsets,
params._defaultIndex,
params._perSampleWeights);
inputData = {params._iData};
refOutData = {params._refData};
}
static std::string getTestCaseName(const testing::TestParamInfo<EmbeddingBagOffsetsSumParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "_iShape=" << param._iShape << "_";
result << "_iType=" << param._iType << "_";
result << "_refShape=" << param._refShape << "_";
result << "_refType=" << param._refType;
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(
const PartialShape& input_shape,
const element::Type& input_type,
const std::shared_ptr<ngraph::opset1::Constant> indices,
const std::shared_ptr<ngraph::opset1::Constant> offsets,
const std::shared_ptr<ngraph::opset1::Constant> default_index,
const std::shared_ptr<ngraph::opset1::Constant> per_sample_weights) {
const auto in = std::make_shared<op::Parameter>(input_type, input_shape);
if (default_index) {
if (per_sample_weights) {
const auto ess = std::make_shared<op::v3::EmbeddingBagOffsetsSum>(in,
indices,
offsets,
default_index,
per_sample_weights);
return std::make_shared<Function>(NodeVector{ess}, ParameterVector{in});
} else {
const auto ess = std::make_shared<op::v3::EmbeddingBagOffsetsSum>(in, indices, offsets, default_index);
return std::make_shared<Function>(NodeVector{ess}, ParameterVector{in});
}
} else {
const auto ess = std::make_shared<op::v3::EmbeddingBagOffsetsSum>(in, indices, offsets);
return std::make_shared<Function>(NodeVector{ess}, ParameterVector{in});
}
}
};
TEST_P(ReferenceEmbeddingBagOffsetsSumLayerTest, CompareWithRefs) {
Exec();
}
INSTANTIATE_TEST_SUITE_P(
smoke_EmbeddingBagOffsetsSum_With_Hardcoded_Refs,
ReferenceEmbeddingBagOffsetsSumLayerTest,
::testing::Values(
EmbeddingBagOffsetsSumParams(
ov::PartialShape{5, 2},
ov::element::f32,
std::vector<float>{-0.2, -0.6, -0.1, -0.4, -1.9, -1.8, -1., 1.5, 0.8, -0.7},
ov::PartialShape{3, 2},
ov::element::f32,
{-1.05f, -1.2f, -0.2f, -0.6f, -0.1f, 0.4f},
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape({4}), std::vector<int32_t>{0, 2, 3, 4}),
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape({3}), std::vector<int32_t>{0, 2, 2}),
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape(), std::vector<int32_t>{0}),
std::make_shared<ngraph::opset1::Constant>(element::f32,
ov::Shape({4}),
std::vector<float>{0.5, 0.5, 0.5, 0.5})),
EmbeddingBagOffsetsSumParams(
ov::PartialShape{5, 2},
ov::element::f64,
std::vector<double>{-0.2, -0.6, -0.1, -0.4, -1.9, -1.8, -1., 1.5, 0.8, -0.7},
ov::PartialShape{3, 2},
ov::element::f64,
std::vector<double>{-2.1, -2.4, -0.2, -0.6, -0.2, 0.8},
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape({4}), std::vector<int32_t>{0, 2, 3, 4}),
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape({3}), std::vector<int32_t>{0, 2, 2}),
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape(), std::vector<int32_t>{0})),
EmbeddingBagOffsetsSumParams(
ov::PartialShape{5, 2},
ov::element::i32,
std::vector<int32_t>{-1, 2, 3, 4, -5, -6, -7, 8, 9, 10},
ov::PartialShape{3, 2},
ov::element::i32,
std::vector<int32_t>{-6, -4, 0, 0, 2, 18},
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape({4}), std::vector<int32_t>{0, 2, 3, 4}),
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape({3}), std::vector<int32_t>{0, 2, 2})),
EmbeddingBagOffsetsSumParams(
ov::PartialShape{5, 2},
ov::element::u32,
std::vector<uint32_t>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
ov::PartialShape{3, 2},
ov::element::u32,
std::vector<uint32_t>{6, 8, 3, 4, 16, 18},
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape({4}), std::vector<int32_t>{0, 2, 3, 4}),
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape({3}), std::vector<int32_t>{0, 2, 2}),
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape(), std::vector<int32_t>{1})),
EmbeddingBagOffsetsSumParams(
ov::PartialShape{5, 2},
ov::element::f16,
std::vector<float16>{-0.2, -0.6, -0.1, -0.4, -1.9, -1.8, -1., 1.5, 0.8, -0.7},
ov::PartialShape{3, 2},
ov::element::f16,
std::vector<float16>{-2.1, -2.4, 0, 0, -0.2, 0.8},
std::make_shared<ngraph::opset1::Constant>(element::i64, ov::Shape({4}), std::vector<int64_t>{0, 2, 3, 4}),
std::make_shared<ngraph::opset1::Constant>(element::i64, ov::Shape({3}), std::vector<int64_t>{0, 2, 2})),
EmbeddingBagOffsetsSumParams(
ov::PartialShape{5, 2},
ov::element::i64,
std::vector<int64_t>{-1, 2, 3, 4, -5, -6, -7, 8, 9, 10},
ov::PartialShape{3, 2},
ov::element::i64,
std::vector<int64_t>{-6, -4, -1, 2, 2, 18},
std::make_shared<ngraph::opset1::Constant>(element::i64, ov::Shape({4}), std::vector<int64_t>{0, 2, 3, 4}),
std::make_shared<ngraph::opset1::Constant>(element::i64, ov::Shape({3}), std::vector<int64_t>{0, 2, 2}),
std::make_shared<ngraph::opset1::Constant>(element::i64, ov::Shape(), std::vector<int64_t>{0})),
EmbeddingBagOffsetsSumParams(
ov::PartialShape{5, 2},
ov::element::i8,
std::vector<int8_t>{-1, 2, 3, 4, -5, -6, -7, 8, 9, 10},
ov::PartialShape{3, 2},
ov::element::i8,
std::vector<int8_t>{-12, -8, -1, 2, 4, 36},
std::make_shared<ngraph::opset1::Constant>(element::i64, ov::Shape({4}), std::vector<int64_t>{0, 2, 3, 4}),
std::make_shared<ngraph::opset1::Constant>(element::i64, ov::Shape({3}), std::vector<int64_t>{0, 2, 2}),
std::make_shared<ngraph::opset1::Constant>(element::i64, ov::Shape(), std::vector<int64_t>{0}),
std::make_shared<ngraph::opset1::Constant>(element::i8, ov::Shape({4}), std::vector<int8_t>{2, 2, 2, 2})),
EmbeddingBagOffsetsSumParams(
ov::PartialShape{5, 2},
ov::element::u8,
std::vector<uint8_t>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
ov::PartialShape{3, 2},
ov::element::u8,
std::vector<uint8_t>{6, 8, 1, 2, 16, 18},
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape({4}), std::vector<int32_t>{0, 2, 3, 4}),
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape({3}), std::vector<int32_t>{0, 2, 2}),
std::make_shared<ngraph::opset1::Constant>(element::i32, ov::Shape(), std::vector<int32_t>{0}))),
ReferenceEmbeddingBagOffsetsSumLayerTest::getTestCaseName);

View File

@ -0,0 +1,170 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include <shared_test_classes/base/layer_test_utils.hpp>
#include "base_reference_test.hpp"
using namespace reference_tests;
using namespace ngraph;
using namespace InferenceEngine;
struct EmbeddingBagPackedSumParams {
template <class IT>
EmbeddingBagPackedSumParams(const ov::PartialShape& iShape,
const ov::element::Type& iType,
const std::vector<IT>& iValues,
const ov::PartialShape& oShape,
const ov::element::Type& oType,
const std::vector<IT>& oValues,
const std::shared_ptr<ngraph::opset1::Constant>& indices,
const std::shared_ptr<ngraph::opset1::Constant>& per_sample_weights = nullptr)
: _iShape(iShape),
_iType(iType),
_iData(CreateTensor(iType, iValues)),
_refShape(oShape),
_refType(oType),
_refData(CreateTensor(oType, oValues)) {
_indices = indices;
_perSampleWeights = per_sample_weights;
}
ov::PartialShape _iShape;
ov::element::Type _iType;
ov::runtime::Tensor _iData;
ov::PartialShape _refShape;
ov::element::Type _refType;
ov::runtime::Tensor _refData;
std::shared_ptr<ngraph::opset1::Constant> _indices;
std::shared_ptr<ngraph::opset1::Constant> _perSampleWeights; // Optional, default is tensor of ones.
};
class ReferenceEmbeddingBagPackedSumLayerTest : public testing::TestWithParam<EmbeddingBagPackedSumParams>,
public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params._iShape, params._iType, params._indices, params._perSampleWeights);
inputData = {params._iData};
refOutData = {params._refData};
}
static std::string getTestCaseName(const testing::TestParamInfo<EmbeddingBagPackedSumParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "_iShape=" << param._iShape << "_";
result << "_iType=" << param._iType << "_";
result << "_refShape=" << param._refShape << "_";
result << "_refType=" << param._refType;
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(
const PartialShape& input_shape,
const element::Type& input_type,
const std::shared_ptr<ngraph::opset1::Constant> indices,
const std::shared_ptr<ngraph::opset1::Constant> per_sample_weights) {
const auto in = std::make_shared<op::Parameter>(input_type, input_shape);
if (per_sample_weights) {
const auto ess = std::make_shared<op::v3::EmbeddingBagPackedSum>(in, indices, per_sample_weights);
return std::make_shared<Function>(NodeVector{ess}, ParameterVector{in});
} else {
const auto ess = std::make_shared<op::v3::EmbeddingBagPackedSum>(in, indices);
return std::make_shared<Function>(NodeVector{ess}, ParameterVector{in});
}
}
};
TEST_P(ReferenceEmbeddingBagPackedSumLayerTest, CompareWithRefs) {
Exec();
}
template <class T>
inline std::shared_ptr<ngraph::opset1::Constant> CreateConstant(const std::vector<std::vector<T>>& val,
const ov::element::Type& element_type) {
if (val.size() > 0) {
ov::Shape i_shape({val.size(), val[0].size()});
size_t i_size = ov::shape_size(i_shape);
std::vector<T> i_values(i_size);
for (size_t i = 0; i < i_shape[0]; i++) {
for (size_t j = 0; j < i_shape[1]; j++) {
i_values[i * i_shape[1] + j] = val[i][j];
}
}
return std::make_shared<ngraph::opset1::Constant>(element_type, i_shape, i_values);
} else {
return std::make_shared<ngraph::opset1::Constant>(element_type, ov::Shape(), std::vector<T>());
}
}
INSTANTIATE_TEST_SUITE_P(
smoke_EmbeddingBagPackedSum_With_Hardcoded_Refs,
ReferenceEmbeddingBagPackedSumLayerTest,
::testing::Values(
EmbeddingBagPackedSumParams(ov::PartialShape{5, 2},
ov::element::f32,
std::vector<float>{-0.2, -0.6, -0.1, -0.4, -1.9, -1.8, -1., 1.5, 0.8, -0.7},
ov::PartialShape{3, 2},
ov::element::f32,
std::vector<float>{-1.05f, -1.2f, -1.f, -1.1f, -0.1f, 0.4f},
CreateConstant<int32_t>({{0, 2}, {1, 2}, {3, 4}}, element::i32),
CreateConstant<float>({{0.5, 0.5}, {0.5, 0.5}, {0.5, 0.5}}, element::f32)),
EmbeddingBagPackedSumParams(ov::PartialShape{5, 2},
ov::element::f64,
std::vector<double>{-0.2, -0.6, -0.1, -0.4, -1.9, -1.8, -1., 1.5, 0.8, -0.7},
ov::PartialShape{3, 2},
ov::element::f64,
std::vector<double>{-2.1, -2.4, -2.0, -2.2, -0.2, 0.8},
CreateConstant<int32_t>({{0, 2}, {1, 2}, {3, 4}}, element::i32)),
EmbeddingBagPackedSumParams(ov::PartialShape{5, 2},
ov::element::i32,
std::vector<int32_t>{-1, 2, 3, 4, -5, -6, -7, 8, 9, 10},
ov::PartialShape{3, 2},
ov::element::i32,
std::vector<int32_t>{-6, -4, -2, -2, 2, 18},
CreateConstant<int32_t>({{0, 2}, {1, 2}, {3, 4}}, element::i32)),
EmbeddingBagPackedSumParams(ov::PartialShape{5, 2},
ov::element::u32,
std::vector<uint32_t>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
ov::PartialShape{3, 2},
ov::element::u32,
std::vector<uint32_t>{6, 8, 8, 10, 16, 18},
CreateConstant<int32_t>({{0, 2}, {1, 2}, {3, 4}}, element::i32)),
EmbeddingBagPackedSumParams(ov::PartialShape{5, 2},
ov::element::f16,
std::vector<float16>{-0.2, -0.6, -0.1, -0.4, -1.9, -1.8, -1., 1.5, 0.8, -0.7},
ov::PartialShape{3, 2},
ov::element::f16,
std::vector<float16>{-2.1, -2.4, -2.0, -2.2, -0.2, 0.8},
CreateConstant<int64_t>({{0, 2}, {1, 2}, {3, 4}}, element::i64)),
EmbeddingBagPackedSumParams(ov::PartialShape{5, 2},
ov::element::i64,
std::vector<int64_t>{-1, 2, 3, 4, -5, -6, -7, 8, 9, 10},
ov::PartialShape{3, 2},
ov::element::i64,
std::vector<int64_t>{-6, -4, -2, -2, 2, 18},
CreateConstant<int64_t>({{0, 2}, {1, 2}, {3, 4}}, element::i64)),
EmbeddingBagPackedSumParams(ov::PartialShape{5, 2},
ov::element::i8,
std::vector<int8_t>{-1, 2, 3, 4, -5, -6, -7, 8, 9, 10},
ov::PartialShape{3, 2},
ov::element::i8,
std::vector<int8_t>{-12, -8, -4, -4, 4, 36},
CreateConstant<int64_t>({{0, 2}, {1, 2}, {3, 4}}, element::i64),
CreateConstant<int8_t>({{2, 2}, {2, 2}, {2, 2}}, element::i8)),
EmbeddingBagPackedSumParams(ov::PartialShape{5, 2},
ov::element::u8,
std::vector<uint8_t>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
ov::PartialShape{3, 2},
ov::element::u8,
std::vector<uint8_t>{6, 8, 8, 10, 16, 18},
CreateConstant<int64_t>({{0, 2}, {1, 2}, {3, 4}}, element::i64))),
ReferenceEmbeddingBagPackedSumLayerTest::getTestCaseName);

View File

@ -3,6 +3,7 @@
//
#include <gtest/gtest.h>
#include "functional_test_utils/skip_tests_config.hpp"
#include "openvino/op/erf.hpp"
#include "base_reference_test.hpp"
@ -43,6 +44,7 @@ struct ErfParams {
class ReferenceErfLayerTest : public testing::TestWithParam<ErfParams>, public CommonReferenceTest {
public:
void SetUp() override {
SKIP_IF_CURRENT_TEST_IS_DISABLED();
auto params = GetParam();
function = CreateFunction(params.pshape, params.inType, params.outType);
inputData = {params.inputData};

View File

@ -7,6 +7,8 @@
#include "openvino/op/exp.hpp"
#include "base_reference_test.hpp"
#include "functional_test_utils/skip_tests_config.hpp"
using namespace reference_tests;
using namespace ov;
using namespace InferenceEngine;
@ -31,6 +33,7 @@ struct ExpParams {
class ReferenceExpLayerTest : public testing::TestWithParam<ExpParams>, public CommonReferenceTest {
public:
void SetUp() override {
SKIP_IF_CURRENT_TEST_IS_DISABLED();
auto params = GetParam();
function = CreateFunction(params.pshape, params.inType, params.outType);
inputData = {params.inputData};
@ -160,9 +163,7 @@ std::vector<ExpParams> generateExpCombinedParams() {
generateExpFloatParams<element::Type_t::f32>(),
generateExpFloatParams<element::Type_t::f16>(),
generateExpIntParams<element::Type_t::i32>(),
generateExpIntParams<element::Type_t::i64>(),
generateExpUintParams<element::Type_t::u32>(),
generateExpUintParams<element::Type_t::u64>()
generateExpIntParams<element::Type_t::i64>()
};
std::vector<ExpParams> combinedParams;
@ -191,4 +192,4 @@ INSTANTIATE_TEST_SUITE_P(smoke_Exp_With_Hardcoded_Refs, ReferenceExpLayerTest,
INSTANTIATE_TEST_SUITE_P(smoke_Exp_In_Place_With_Hardcoded_Refs, ReferenceExpInPlaceLayerTest,
testing::ValuesIn(generateExpInPlaceCombinedParams()), ReferenceExpInPlaceLayerTest::getTestCaseName);
} // namespace
} // namespace

View File

@ -0,0 +1,108 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "openvino/op/experimental_detectron_topkrois.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
using namespace ov;
namespace {
struct ExperimentalDetectronTopKROIsParams {
ExperimentalDetectronTopKROIsParams(
const Tensor& dataTensor, const Tensor& probsTensor, const int32_t numRois,
const Tensor& expectedTensor, const std::string& testcaseName = "") :
dataTensor(dataTensor), probsTensor(probsTensor), numRois(numRois),
expectedTensor(expectedTensor), testcaseName(testcaseName) {}
Tensor dataTensor;
Tensor probsTensor;
int32_t numRois;
Tensor expectedTensor;
std::string testcaseName;
};
class ReferenceExperimentalDetectronTopKROIsTest : public testing::TestWithParam<ExperimentalDetectronTopKROIsParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params);
inputData = {params.dataTensor.data, params.probsTensor.data};
refOutData = {params.expectedTensor.data};
}
static std::string getTestCaseName(const testing::TestParamInfo<ExperimentalDetectronTopKROIsParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "dType=" << param.dataTensor.type;
result << "_dShape=" << param.dataTensor.shape;
result << "_pType=" << param.probsTensor.type;
result << "_pShape=" << param.probsTensor.shape;
result << "_numRois=" << param.numRois;
result << "_eType=" << param.expectedTensor.type;
if (param.testcaseName != "") {
result << "_eShape=" << param.expectedTensor.shape;
result << "_=" << param.testcaseName;
} else {
result << "_eShape=" << param.expectedTensor.shape;
}
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(const ExperimentalDetectronTopKROIsParams& params) {
std::shared_ptr<Function> function;
const auto data = std::make_shared<op::v0::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto probs = std::make_shared<op::v0::Parameter>(params.probsTensor.type, params.probsTensor.shape);
const auto topkRois = std::make_shared<op::v6::ExperimentalDetectronTopKROIs>(data, probs, params.numRois);
function = std::make_shared<ov::Function>(topkRois, ParameterVector{data, probs});
return function;
}
};
TEST_P(ReferenceExperimentalDetectronTopKROIsTest, CompareWithRefs) {
Exec();
}
template <element::Type_t ET>
std::vector<ExperimentalDetectronTopKROIsParams> generateParams() {
using T = typename element_type_traits<ET>::value_type;
std::vector<ExperimentalDetectronTopKROIsParams> params {
ExperimentalDetectronTopKROIsParams(
Tensor(ET, {2, 4}, std::vector<T>{1.0f, 1.0f, 3.0f, 4.0f, 2.0f, 1.0f, 5.0f, 7.0f}),
Tensor(ET, {2}, std::vector<T>{0.5f, 0.3f}),
1,
Tensor(ET, {1, 4}, std::vector<T>{1.0, 1.0, 3.0, 4.0}),
"experimental_detectron_topk_rois_eval"),
ExperimentalDetectronTopKROIsParams(
Tensor(ET, {4, 4}, std::vector<T>{1.0f, 1.0f, 4.0f, 5.0f, 3.0f, 2.0f, 7.0f, 9.0f,
10.0f, 15.0f, 13.0f, 17.0f, 13.0f, 10.0f, 18.0f, 15.0f}),
Tensor(ET, {4}, std::vector<T>{0.1f, 0.7f, 0.5f, 0.9f}),
2,
Tensor(ET, {2, 4}, std::vector<T>{13.0f, 10.0f, 18.0f, 15.0f, 3.0f, 2.0f, 7.0f, 9.0f}),
"experimental_detectron_topk_rois_eval"),
};
return params;
}
std::vector<ExperimentalDetectronTopKROIsParams> generateCombinedParams() {
const std::vector<std::vector<ExperimentalDetectronTopKROIsParams>> generatedParams {
generateParams<element::Type_t::bf16>(),
generateParams<element::Type_t::f16>(),
generateParams<element::Type_t::f32>(),
generateParams<element::Type_t::f64>(),
};
std::vector<ExperimentalDetectronTopKROIsParams> combinedParams;
for (const auto& params : generatedParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_ExperimentalDetectronTopKROIs_With_Hardcoded_Refs, ReferenceExperimentalDetectronTopKROIsTest,
testing::ValuesIn(generateCombinedParams()), ReferenceExperimentalDetectronTopKROIsTest::getTestCaseName);
} // namespace

View File

@ -0,0 +1,880 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "openvino/op/gather.hpp"
#include "openvino/op/constant.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
using namespace ov;
namespace {
struct GatherParams {
GatherParams(
const Tensor& dataTensor, const Tensor& indicesTensor, const Tensor& axisTensor,
const Tensor& expectedTensor, const std::string& testcaseName = "") :
dataTensor(dataTensor), indicesTensor(indicesTensor), axisTensor(axisTensor),
expectedTensor(expectedTensor), testcaseName(testcaseName) {}
Tensor dataTensor;
Tensor indicesTensor;
Tensor axisTensor;
Tensor expectedTensor;
std::string testcaseName;
};
class ReferenceGatherTest : public testing::TestWithParam<GatherParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params);
inputData = {params.dataTensor.data, params.indicesTensor.data};
refOutData = {params.expectedTensor.data};
}
static std::string getTestCaseName(const testing::TestParamInfo<GatherParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "dType=" << param.dataTensor.type;
result << "_dShape=" << param.dataTensor.shape;
result << "_iType=" << param.indicesTensor.type;
result << "_iShape=" << param.indicesTensor.shape;
result << "_aType=" << param.axisTensor.type;
result << "_aShape=" << param.axisTensor.shape;
result << "_eType=" << param.expectedTensor.type;
if (param.testcaseName != "") {
result << "_eShape=" << param.expectedTensor.shape;
result << "_=" << param.testcaseName;
} else {
result << "_eShape=" << param.expectedTensor.shape;
}
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(const GatherParams& params) {
const auto P = std::make_shared<op::v0::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto I = std::make_shared<op::v0::Parameter>(params.indicesTensor.type, params.indicesTensor.shape);
const auto A = op::v0::Constant::create(params.axisTensor.type, params.axisTensor.shape,
params.axisTensor.data.data());
const auto G = std::make_shared<op::v1::Gather>(P, I, A);
const auto f = std::make_shared<Function>(G, ParameterVector{P, I});
return f;
}
};
TEST_P(ReferenceGatherTest, CompareWithRefs) {
Exec();
}
struct GatherParamsV7 {
GatherParamsV7(
const Tensor& dataTensor, const Tensor& indicesTensor, const Tensor& axisTensor, int64_t batchDims,
const Tensor& expectedTensor, const std::string& testcaseName = "") :
dataTensor(dataTensor), indicesTensor(indicesTensor), axisTensor(axisTensor), batchDims(batchDims),
expectedTensor(expectedTensor), testcaseName(testcaseName) {}
Tensor dataTensor;
Tensor indicesTensor;
Tensor axisTensor;
int64_t batchDims;
Tensor expectedTensor;
std::string testcaseName;
};
class ReferenceGatherTestV7 : public testing::TestWithParam<GatherParamsV7>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params);
inputData = {params.dataTensor.data, params.indicesTensor.data};
refOutData = {params.expectedTensor.data};
}
static std::string getTestCaseName(const testing::TestParamInfo<GatherParamsV7>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "dType=" << param.dataTensor.type;
result << "_dShape=" << param.dataTensor.shape;
result << "_iType=" << param.indicesTensor.type;
result << "_iShape=" << param.indicesTensor.shape;
result << "_aType=" << param.axisTensor.type;
result << "_aShape=" << param.axisTensor.shape;
result << "_batchDims=" << param.batchDims;
result << "_eType=" << param.expectedTensor.type;
if (param.testcaseName != "") {
result << "_eShape=" << param.expectedTensor.shape;
result << "_=" << param.testcaseName;
} else {
result << "_eShape=" << param.expectedTensor.shape;
}
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(const GatherParamsV7& params) {
const auto P = std::make_shared<op::v0::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto I = std::make_shared<op::v0::Parameter>(params.indicesTensor.type, params.indicesTensor.shape);
const auto A = op::v0::Constant::create(params.axisTensor.type, params.axisTensor.shape,
params.axisTensor.data.data());
const auto G = std::make_shared<op::v7::Gather>(P, I, A, params.batchDims);
const auto f = std::make_shared<Function>(G, ParameterVector{P, I});
return f;
}
};
TEST_P(ReferenceGatherTestV7, CompareWithRefs) {
Exec();
}
template <element::Type_t ET, element::Type_t ET_I, element::Type_t ET_A>
std::vector<GatherParams> generateParams() {
using T = typename element_type_traits<ET>::value_type;
using T_I = typename element_type_traits<ET_I>::value_type;
using T_A = typename element_type_traits<ET_A>::value_type;
std::vector<GatherParams> params {
GatherParams(
Tensor(ET, {3, 2}, std::vector<T>{
10, 11, 20, 21, 30, 31}),
Tensor(ET_I, {2, 2, 3, 4}, std::vector<T_I>{
0, 1, 1, 2, 0, 1, 1, 2, 0, 1, 1, 2, 0, 1, 1, 2, 0, 1, 1, 2, 0, 1, 1, 2,
0, 1, 1, 2, 0, 1, 1, 2, 0, 1, 1, 2, 0, 1, 1, 2, 0, 1, 1, 2, 0, 1, 1, 2}),
Tensor(ET_A, {}, std::vector<T_A>{0}),
Tensor(ET, {2, 2, 3, 4, 2}, std::vector<T>{
10, 11, 20, 21, 20, 21, 30, 31, 10, 11, 20, 21, 20, 21, 30, 31, 10, 11, 20, 21, 20, 21, 30, 31,
10, 11, 20, 21, 20, 21, 30, 31, 10, 11, 20, 21, 20, 21, 30, 31, 10, 11, 20, 21, 20, 21, 30, 31,
10, 11, 20, 21, 20, 21, 30, 31, 10, 11, 20, 21, 20, 21, 30, 31, 10, 11, 20, 21, 20, 21, 30, 31,
10, 11, 20, 21, 20, 21, 30, 31, 10, 11, 20, 21, 20, 21, 30, 31, 10, 11, 20, 21, 20, 21, 30, 31}),
"gather_4d_indices_axis_0"),
GatherParams(
Tensor(ET, {3, 2}, std::vector<T>{
10, 11, 20, 21, 30, 31}),
Tensor(ET_I, {2, 2}, std::vector<T_I>{
0, 1, 1, 2}),
Tensor(ET_A, {}, std::vector<T_A>{0}),
Tensor(ET, {2, 2, 2}, std::vector<T>{
10, 11, 20, 21, 20, 21, 30, 31}),
"gather_axis_0"),
};
return params;
}
template <element::Type_t ET, element::Type_t ET_I, element::Type_t ET_A>
std::vector<GatherParams> generateParamsFloatValue() {
using T = typename element_type_traits<ET>::value_type;
using T_I = typename element_type_traits<ET_I>::value_type;
using T_A = typename element_type_traits<ET_A>::value_type;
std::vector<GatherParams> params {
GatherParams(
Tensor(ET, {3, 2}, std::vector<T>{
1.0f, 1.1f,
2.0f, 2.1f,
3.0f, 3.1f}),
Tensor(ET_I, {2, 2, 3, 4}, std::vector<T_I>{
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2}),
Tensor(ET_A, {}, std::vector<T_A>{0}),
Tensor(ET, {2, 2, 3, 4, 2}, std::vector<T>{
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f}),
"gather_4d_indices_axis_0_2d_input"),
GatherParams(
Tensor(ET, {3, 2}, std::vector<T>{
1.0f, 1.1f,
2.0f, 2.1f,
3.0f, 3.1f}),
Tensor(ET_I, {2, 3, 4}, std::vector<T_I>{
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2}),
Tensor(ET_A, {}, std::vector<T_A>{0}),
Tensor(ET, {2, 3, 4, 2}, std::vector<T>{
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f}),
"gather_3d_indices_axis_0_2d_input"),
GatherParams(
Tensor(ET, {3, 2}, std::vector<T>{
1.0f, 1.1f,
2.0f, 2.1f,
3.0f, 3.1f}),
Tensor(ET_I, {2, 2}, std::vector<T_I>{
0, 1, 1, 2}),
Tensor(ET_A, {}, std::vector<T_A>{0}),
Tensor(ET, {2, 2, 2}, std::vector<T>{
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f}),
"gather_2d_indices_axis_0_2d_input"),
GatherParams(
Tensor(ET, {3, 2}, std::vector<T>{
1.0f, 1.1f,
2.0f, 2.1f,
3.0f, 3.1f}),
Tensor(ET_I, {2, 2}, std::vector<T_I>{
0, -2, 1, 2}),
Tensor(ET_A, {}, std::vector<T_A>{0}),
Tensor(ET, {2, 2, 2}, std::vector<T>{
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f}),
"gather_2d_negative_and_positive_indices_axis_0_2d_input"),
GatherParams(
Tensor(ET, {3}, std::vector<T>{
1.0f, 2.0f, 3.0f}),
Tensor(ET_I, {2}, std::vector<T_I>{
1, 0}),
Tensor(ET_A, {}, std::vector<T_A>{0}),
Tensor(ET, {2}, std::vector<T>{
2.0f, 1.0f}),
"gather_1d_indices_axis_0_1d_input"),
GatherParams(
Tensor(ET, {3, 2}, std::vector<T>{
1.0f, 1.1f, 2.0f, 2.1f, 3.0f, 3.1f}),
Tensor(ET_I, {}, std::vector<T_I>{1}),
Tensor(ET_A, {}, std::vector<T_A>{0}),
Tensor(ET, {2}, std::vector<T>{
2.0f, 2.1f}),
"gather_scalar_indices_axis_0_2d_input"),
GatherParams(
Tensor(ET, {3, 3}, std::vector<T>{
1.0f, 1.1f, 1.2f,
2.0f, 2.1f, 2.2f,
3.0f, 3.1f, 3.2f}),
Tensor(ET_I, {1, 2}, std::vector<T_I>{
0, 2}),
Tensor(ET_A, {}, std::vector<T_A>{1}),
Tensor(ET, {3, 1, 2}, std::vector<T>{
1.0f, 1.2f,
2.0f, 2.2f,
3.0f, 3.2f}),
"gather_2d_indices_axis_1_2d_input"),
GatherParams(
Tensor(ET, {2, 2, 3, 3}, std::vector<T>{
1.0f, 1.1f, 1.2f,
2.0f, 2.1f, 2.2f,
3.0f, 3.1f, 3.2f,
11.0f, 11.1f, 11.2f,
12.0f, 12.1f, 12.2f,
13.0f, 13.1f, 13.2f,
101.0f, 101.1f, 101.2f,
102.0f, 102.1f, 102.2f,
103.0f, 103.1f, 103.2f,
111.0f, 111.1f, 111.2f,
112.0f, 112.1f, 112.2f,
113.0f, 113.1f, 113.2f}),
Tensor(ET_I, {2}, std::vector<T_I>{
0, 2}),
Tensor(ET_A, {}, std::vector<T_A>{2}),
Tensor(ET, {2, 2, 2, 3}, std::vector<T>{
1.0f, 1.1f, 1.2f,
3.0f, 3.1f, 3.2f,
11.0f, 11.1f, 11.2f,
13.0f, 13.1f, 13.2f,
101.0f, 101.1f, 101.2f,
103.0f, 103.1f, 103.2f,
111.0f, 111.1f, 111.2f,
113.0f, 113.1f, 113.2f}),
"gather_1d_indices_axis_2_4d_input"),
GatherParams(
Tensor(ET, {3, 3}, std::vector<T>{
1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f, 3.0f, 3.1f, 3.2f}),
Tensor(ET_I, {}, std::vector<T_I>{0}),
Tensor(ET_A, {}, std::vector<T_A>{1}),
Tensor(ET, {3}, std::vector<T>{
1.0f, 2.0f, 3.0f}),
"gather_scalar_indices_axis_1_2d_input"),
};
return params;
}
std::vector<GatherParams> generateCombinedParams() {
const std::vector<std::vector<GatherParams>> generatedParams {
generateParams<element::Type_t::i8, element::Type_t::i32, element::Type_t::i64>(),
generateParams<element::Type_t::i16, element::Type_t::i32, element::Type_t::i64>(),
generateParams<element::Type_t::i32, element::Type_t::i32, element::Type_t::i64>(),
generateParams<element::Type_t::i64, element::Type_t::i32, element::Type_t::i64>(),
generateParams<element::Type_t::u8, element::Type_t::i32, element::Type_t::i64>(),
generateParams<element::Type_t::u16, element::Type_t::i32, element::Type_t::i64>(),
generateParams<element::Type_t::u32, element::Type_t::i32, element::Type_t::i64>(),
generateParams<element::Type_t::u64, element::Type_t::i32, element::Type_t::i64>(),
generateParamsFloatValue<element::Type_t::bf16, element::Type_t::i32, element::Type_t::i64>(),
generateParamsFloatValue<element::Type_t::f16, element::Type_t::i32, element::Type_t::i64>(),
generateParamsFloatValue<element::Type_t::f32, element::Type_t::i32, element::Type_t::i64>(),
generateParamsFloatValue<element::Type_t::f64, element::Type_t::i32, element::Type_t::i64>(),
};
std::vector<GatherParams> combinedParams;
for (const auto& params : generatedParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_Gather_With_Hardcoded_Refs, ReferenceGatherTest,
testing::ValuesIn(generateCombinedParams()), ReferenceGatherTest::getTestCaseName);
template <element::Type_t ET, element::Type_t ET_I, element::Type_t ET_A>
std::vector<GatherParamsV7> generateParamsV7() {
using T = typename element_type_traits<ET>::value_type;
using T_I = typename element_type_traits<ET_I>::value_type;
using T_A = typename element_type_traits<ET_A>::value_type;
std::vector<GatherParamsV7> params {
GatherParamsV7(
Tensor(ET, {3}, std::vector<T>{
1, 2, 3}),
Tensor(ET_I, {2}, std::vector<T_I>{
2, 0}),
Tensor(ET_A, {}, std::vector<T_A>{0}),
0,
Tensor(ET, {2}, std::vector<T>{
3, 1}),
"gather_v7_1d"),
GatherParamsV7(
Tensor(ET, {3, 2}, std::vector<T>{
10, 11, 20, 21, 30, 31}),
Tensor(ET_I, {2, 2}, std::vector<T_I>{
0, 1, 1, 2}),
Tensor(ET_A, {}, std::vector<T_A>{0}),
0,
Tensor(ET, {2, 2, 2}, std::vector<T>{
10, 11, 20, 21, 20, 21, 30, 31}),
"gather_v7_axis_0"),
GatherParamsV7(
Tensor(ET, {2, 3}, std::vector<T>{
1, 2, 3,
4, 5, 6}),
Tensor(ET_I, {2, 2, 2}, std::vector<T_I>{
0, 1,
1, 2,
2, 0,
1, 2}),
Tensor(ET_A, {}, std::vector<T_A>{1}),
1,
Tensor(ET, {2, 2, 2}, std::vector<T>{
1, 2,
2, 3,
6, 4,
5, 6}),
"gather_v7_data_int32_3d_indices_axis_1_batch_dims_1"),
GatherParamsV7(
Tensor(ET, {2, 5}, std::vector<T>{
1, 2, 3, 4, 5,
6, 7, 8, 9, 10}),
Tensor(ET_I, {2, 3}, std::vector<T_I>{
0, 0, 4,
4, 0, 0}),
Tensor(ET_A, {}, std::vector<T_A>{1}),
1,
Tensor(ET, {2, 3}, std::vector<T>{
1, 1, 5,
10, 6, 6}),
"gather_v7_data_int32_2d_indices_axis_1_batch_dims_1"),
GatherParamsV7(
Tensor(ET, {2, 5}, std::vector<T>{
1, 2, 3, 4, 5,
6, 7, 8, 9, 10}),
Tensor(ET_I, {2, 3}, std::vector<T_I>{
0, 0, 4,
4, 0, 0}),
Tensor(ET_A, {}, std::vector<T_A>{1}),
-1,
Tensor(ET, {2, 3}, std::vector<T>{
1, 1, 5,
10, 6, 6}),
"gather_v7_data_int32_2d_indices_axis_1_negative_batch_dims"),
GatherParamsV7(
Tensor(ET, {2, 1, 5, 4}, 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}),
Tensor(ET_I, {2, 3}, std::vector<T_I>{
1, 2, 4,
4, 3, 2}),
Tensor(ET_A, {}, std::vector<T_A>{2}),
1,
Tensor(ET, {2, 1, 3, 4}, std::vector<T>{
5, 6, 7, 8,
9, 10, 11, 12,
17, 18, 19, 20,
37, 38, 39, 40,
33, 34, 35, 36,
29, 30, 31, 32}),
"gather_v7_4d_data_axis_2_batch_dims_1_int32"),
};
return params;
}
template <>
std::vector<GatherParamsV7> generateParamsV7<element::boolean, element::i32, element::i64>() {
std::vector<GatherParamsV7> params {
GatherParamsV7(
Tensor(element::boolean, {3, 2}, std::vector<char>{
1, 1, 1, 0, 0, 1}),
Tensor(element::i32, {2, 2}, std::vector<int32_t>{
0, 1, 1, 2}),
Tensor(element::i64, {}, std::vector<int64_t>{0}),
0,
Tensor(element::boolean, {2, 2, 2}, std::vector<char>{
1, 1, 1, 0, 1, 0, 0, 1}),
"gather_v7_axis_0_bool"),
};
return params;
}
template <element::Type_t ET, element::Type_t ET_I, element::Type_t ET_A>
std::vector<GatherParamsV7> generateParamsFloatValueV7() {
using T = typename element_type_traits<ET>::value_type;
using T_I = typename element_type_traits<ET_I>::value_type;
using T_A = typename element_type_traits<ET_A>::value_type;
std::vector<GatherParamsV7> params {
GatherParamsV7(
Tensor(ET, {3, 2}, std::vector<T>{
1.0f, 1.1f,
2.0f, 2.1f,
3.0f, 3.1f}),
Tensor(ET_I, {2, 2, 3, 4}, std::vector<T_I>{
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2}),
Tensor(ET_A, {}, std::vector<T_A>{0}),
0,
Tensor(ET, {2, 2, 3, 4, 2}, std::vector<T>{
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f}),
"gather_v7_4d_indices_axis_0_2d_input"),
GatherParamsV7(
Tensor(ET, {3, 2}, std::vector<T>{
1.0f, 1.1f,
2.0f, 2.1f,
3.0f, 3.1f}),
Tensor(ET_I, {2, 3, 4}, std::vector<T_I>{
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2,
0, 1, 1, 2}),
Tensor(ET_A, {}, std::vector<T_A>{0}),
0,
Tensor(ET, {2, 3, 4, 2}, std::vector<T>{
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f,
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f}),
"gather_v7_3d_indices_axis_0_2d_input"),
GatherParamsV7(
Tensor(ET, {3, 2}, std::vector<T>{
1.0f, 1.1f,
2.0f, 2.1f,
3.0f, 3.1f}),
Tensor(ET_I, {2, 2}, std::vector<T_I>{
0, 1, 1, 2}),
Tensor(ET_A, {}, std::vector<T_A>{0}),
0,
Tensor(ET, {2, 2, 2}, std::vector<T>{
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f}),
"gather_v7_2d_indices_axis_0_2d_input"),
GatherParamsV7(
Tensor(ET, {3, 2}, std::vector<T>{
1.0f, 1.1f,
2.0f, 2.1f,
3.0f, 3.1f}),
Tensor(ET_I, {2, 2}, std::vector<T_I>{
0, -2, 1, 2}),
Tensor(ET_A, {}, std::vector<T_A>{0}),
0,
Tensor(ET, {2, 2, 2}, std::vector<T>{
1.0f, 1.1f,
2.0f, 2.1f,
2.0f, 2.1f,
3.0f, 3.1f}),
"gather_v7_2d_negative_and_positive_indices_axis_0_2d_input"),
GatherParamsV7(
Tensor(ET, {3}, std::vector<T>{
1.0f, 2.0f, 3.0f}),
Tensor(ET_I, {2}, std::vector<T_I>{
1, 0}),
Tensor(ET_A, {}, std::vector<T_A>{0}),
0,
Tensor(ET, {2}, std::vector<T>{
2.0f, 1.0f}),
"gather_v7_1d_indices_axis_0_1d_input"),
GatherParamsV7(
Tensor(ET, {3, 2}, std::vector<T>{
1.0f, 1.1f, 2.0f, 2.1f, 3.0f, 3.1f}),
Tensor(ET_I, {}, std::vector<T_I>{1}),
Tensor(ET_A, {}, std::vector<T_A>{0}),
0,
Tensor(ET, {2}, std::vector<T>{
2.0f, 2.1f}),
"gather_v7_scalar_indices_axis_0_2d_input"),
GatherParamsV7(
Tensor(ET, {3, 3}, std::vector<T>{
1.0f, 1.1f, 1.2f,
2.0f, 2.1f, 2.2f,
3.0f, 3.1f, 3.2f}),
Tensor(ET_I, {1, 2}, std::vector<T_I>{
0, 2}),
Tensor(ET_A, {}, std::vector<T_A>{1}),
0,
Tensor(ET, {3, 1, 2}, std::vector<T>{
1.0f, 1.2f,
2.0f, 2.2f,
3.0f, 3.2f}),
"gather_v7_2d_indices_axis_1_2d_input"),
GatherParamsV7(
Tensor(ET, {2, 2, 3, 3}, std::vector<T>{
1.0f, 1.1f, 1.2f,
2.0f, 2.1f, 2.2f,
3.0f, 3.1f, 3.2f,
11.0f, 11.1f, 11.2f,
12.0f, 12.1f, 12.2f,
13.0f, 13.1f, 13.2f,
101.0f, 101.1f, 101.2f,
102.0f, 102.1f, 102.2f,
103.0f, 103.1f, 103.2f,
111.0f, 111.1f, 111.2f,
112.0f, 112.1f, 112.2f,
113.0f, 113.1f, 113.2f}),
Tensor(ET_I, {2}, std::vector<T_I>{
0, 2}),
Tensor(ET_A, {}, std::vector<T_A>{2}),
0,
Tensor(ET, {2, 2, 2, 3}, std::vector<T>{
1.0f, 1.1f, 1.2f,
3.0f, 3.1f, 3.2f,
11.0f, 11.1f, 11.2f,
13.0f, 13.1f, 13.2f,
101.0f, 101.1f, 101.2f,
103.0f, 103.1f, 103.2f,
111.0f, 111.1f, 111.2f,
113.0f, 113.1f, 113.2f}),
"gather_v7_1d_indices_axis_2_4d_input"),
GatherParamsV7(
Tensor(ET, {3, 3}, std::vector<T>{
1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f, 3.0f, 3.1f, 3.2f}),
Tensor(ET_I, {}, std::vector<T_I>{0}),
Tensor(ET_A, {}, std::vector<T_A>{1}),
0,
Tensor(ET, {3}, std::vector<T>{
1.0f, 2.0f, 3.0f}),
"gather_v7_scalar_indices_axis_1_2d_input"),
GatherParamsV7(
Tensor(ET, {2, 5, 2}, std::vector<T>{
1.0f, 2.0f,
3.0f, 4.0f,
5.0f, 6.0f,
7.0f, 8.0f,
9.0f, 10.0f,
11.0f, 12.0f,
13.0f, 14.0f,
15.0f, 16.0f,
17.0f, 18.0f,
19.0f, 20.0f}),
Tensor(ET_I, {2, 2, 3}, std::vector<T_I>{
0, 0, 4,
4, 0, 0,
1, 2, 4,
4, 3, 2}),
Tensor(ET_A, {}, std::vector<T_A>{1}),
1,
Tensor(ET, {2, 2, 3, 2}, std::vector<T>{
1.0f, 2.0f,
1.0f, 2.0f,
9.0f, 10.0f,
9.0f, 10.0f,
1.0f, 2.0f,
1.0f, 2.0f,
13.0f, 14.0f,
15.0f, 16.0f,
19.0f, 20.0f,
19.0f, 20.0f,
17.0f, 18.0f,
15.0f, 16.0f}),
"gather_v7_3d_indices_axis_1_batch_dims_1"),
};
return params;
}
std::vector<GatherParamsV7> generateCombinedParamsV7() {
const std::vector<std::vector<GatherParamsV7>> generatedParams {
generateParamsV7<element::Type_t::boolean, element::Type_t::i32, element::Type_t::i64>(),
generateParamsV7<element::Type_t::i8, element::Type_t::i32, element::Type_t::i64>(),
generateParamsV7<element::Type_t::i16, element::Type_t::i32, element::Type_t::i64>(),
generateParamsV7<element::Type_t::i32, element::Type_t::i32, element::Type_t::i64>(),
generateParamsV7<element::Type_t::i64, element::Type_t::i32, element::Type_t::i64>(),
generateParamsV7<element::Type_t::u8, element::Type_t::i32, element::Type_t::i64>(),
generateParamsV7<element::Type_t::u16, element::Type_t::i32, element::Type_t::i64>(),
generateParamsV7<element::Type_t::u32, element::Type_t::i32, element::Type_t::i64>(),
generateParamsV7<element::Type_t::u64, element::Type_t::i32, element::Type_t::i64>(),
generateParamsFloatValueV7<element::Type_t::bf16, element::Type_t::i32, element::Type_t::i64>(),
generateParamsFloatValueV7<element::Type_t::f16, element::Type_t::i32, element::Type_t::i64>(),
generateParamsFloatValueV7<element::Type_t::f32, element::Type_t::i32, element::Type_t::i64>(),
generateParamsFloatValueV7<element::Type_t::f64, element::Type_t::i32, element::Type_t::i64>(),
};
std::vector<GatherParamsV7> combinedParams;
for (const auto& params : generatedParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_Gather_With_Hardcoded_Refs, ReferenceGatherTestV7,
testing::ValuesIn(generateCombinedParamsV7()), ReferenceGatherTestV7::getTestCaseName);
} // namespace

View File

@ -25,7 +25,7 @@ struct GatherNDParams {
std::string testcaseName;
};
class ReferenceGatherNDTest : public testing::TestWithParam<GatherNDParams>, public CommonReferenceTest {
class ReferenceGatherND5Test : public testing::TestWithParam<GatherNDParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
@ -59,18 +59,18 @@ private:
PartialShape{params.dataTensor.shape});
const auto indices = std::make_shared<op::v0::Parameter>(params.indicesTensor.type,
PartialShape{params.indicesTensor.shape});
std::shared_ptr<op::v5::GatherND> gatherElement;
std::shared_ptr<op::v5::GatherND> gatherND;
if (params.batchDims == 0) {
gatherElement = std::make_shared<op::v5::GatherND>(data, indices);
gatherND = std::make_shared<op::v5::GatherND>(data, indices);
} else {
gatherElement = std::make_shared<op::v5::GatherND>(data, indices, params.batchDims);
gatherND = std::make_shared<op::v5::GatherND>(data, indices, params.batchDims);
}
function = std::make_shared<ov::Function>(NodeVector {gatherElement}, ParameterVector {data, indices});
function = std::make_shared<ov::Function>(NodeVector {gatherND}, ParameterVector {data, indices});
return function;
}
};
TEST_P(ReferenceGatherNDTest, CompareWithRefs) {
TEST_P(ReferenceGatherND5Test, CompareWithRefs) {
Exec();
}
@ -203,6 +203,207 @@ std::vector<GatherNDParams> generateCombinedParams() {
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_GatherND_With_Hardcoded_Refs, ReferenceGatherNDTest,
testing::ValuesIn(generateCombinedParams()), ReferenceGatherNDTest::getTestCaseName);
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_GatherND_With_Hardcoded_Refs, ReferenceGatherND5Test,
testing::ValuesIn(generateCombinedParams()), ReferenceGatherND5Test::getTestCaseName);
class ReferenceGatherND8Test : public testing::TestWithParam<GatherNDParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params);
inputData = {params.dataTensor.data, params.indicesTensor.data};
refOutData = {params.expectedTensor.data};
}
static std::string getTestCaseName(const testing::TestParamInfo<GatherNDParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "dType=" << param.dataTensor.type;
result << "_dShape=" << param.dataTensor.shape;
result << "_aType=" << param.indicesTensor.type;
result << "_aShape=" << param.indicesTensor.shape;
result << "_bDims=" << param.batchDims;
result << "_eType=" << param.expectedTensor.type;
if (param.testcaseName != "") {
result << "_eShape=" << param.expectedTensor.shape;
result << "_=" << param.testcaseName;
} else {
result << "_eShape=" << param.expectedTensor.shape;
}
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(const GatherNDParams& params) {
std::shared_ptr<Function> function;
const auto data = std::make_shared<op::v0::Parameter>(params.dataTensor.type,
PartialShape{params.dataTensor.shape});
const auto indices = std::make_shared<op::v0::Parameter>(params.indicesTensor.type,
PartialShape{params.indicesTensor.shape});
std::shared_ptr<op::v8::GatherND> gatherND;
if (params.batchDims == 0) {
gatherND = std::make_shared<op::v8::GatherND>(data, indices);
} else {
gatherND = std::make_shared<op::v8::GatherND>(data, indices, params.batchDims);
}
function = std::make_shared<ov::Function>(NodeVector {gatherND}, ParameterVector {data, indices});
return function;
}
};
TEST_P(ReferenceGatherND8Test, CompareWithRefs) {
Exec();
}
template <element::Type_t IN_ET>
std::vector<GatherNDParams> generateParams_v8() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<GatherNDParams> params {
GatherNDParams(
Tensor(IN_ET, {3, 3}, std::vector<T>{10, 11, 12, 13, 14, 15, 16, 17, 18}),
Tensor(element::i32, {2}, std::vector<int32_t>{1, 2}),
0,
Tensor(IN_ET, {}, std::vector<T>{15}),
"gather_nd_8_single_indices"),
GatherNDParams(
Tensor(IN_ET, {2, 2}, std::vector<T>{10, 11, 12, 13}),
Tensor(element::i32, {2, 2}, std::vector<int32_t>{0, 0, 1, 1}),
0,
Tensor(IN_ET, {2}, std::vector<T>{10, 13}),
"gather_nd_8_scalar_from_2d"),
GatherNDParams(
Tensor(IN_ET, {2, 2}, std::vector<T>{10, 11, 12, 13}),
Tensor(element::i32, {2, 1}, std::vector<int32_t>{1, 0}),
0,
Tensor(IN_ET, {2, 2}, std::vector<T>{12, 13, 10, 11}),
"gather_nd_8_1d_from_2d"),
GatherNDParams(
Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
Tensor(element::i32, {2, 3}, std::vector<int32_t>{0, 0, 1, 1, 0, 1}),
0,
Tensor(IN_ET, {2}, std::vector<T>{11, 21}),
"gather_nd_8_scalar_from_3d"),
GatherNDParams(
Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
Tensor(element::i32, {2, 2}, std::vector<int32_t>{0, 1, 1, 0}),
0,
Tensor(IN_ET, {2, 2}, std::vector<T>{12, 13, 20, 21}),
"gather_nd_8_1d_from_3d"),
GatherNDParams(
Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
Tensor(element::i32, {1, 1}, std::vector<int32_t>{1}),
0,
Tensor(IN_ET, {1, 2, 2}, std::vector<T>{20, 21, 22, 23}),
"gather_nd_8_2d_from_3d"),
GatherNDParams(
Tensor(IN_ET, {2, 2}, std::vector<T>{10, 11, 12, 13}),
Tensor(element::i32, {2, 1, 2}, std::vector<int32_t>{0, 0, 0, 1}),
0,
Tensor(IN_ET, {2, 1}, std::vector<T>{10, 11}),
"gather_nd_8_batch_scalar_from_2d"),
GatherNDParams(
Tensor(IN_ET, {2, 2}, std::vector<T>{10, 11, 12, 13}),
Tensor(element::i32, {2, 1, 1}, std::vector<int32_t>{1, 0}),
0,
Tensor(IN_ET, {2, 1, 2}, std::vector<T>{12, 13, 10, 11}),
"gather_nd_8_batch_1d_from_2d"),
GatherNDParams(
Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
Tensor(element::i32, {2, 2, 3}, std::vector<int32_t>{0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0}),
0,
Tensor(IN_ET, {2, 2}, std::vector<T>{11, 21, 13, 22}),
"gather_nd_8_batch_scalar_from_3d"),
GatherNDParams(
Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
Tensor(element::i32, {2, 2, 2}, std::vector<int32_t>{0, 1, 1, 0, 0, 0, 1, 1}),
0,
Tensor(IN_ET, {2, 2, 2}, std::vector<T>{12, 13, 20, 21, 10, 11, 22, 23}),
"gather_nd_8_batch_1d_from_3d"),
GatherNDParams(
Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
Tensor(element::i32, {2, 2, 2}, std::vector<int32_t>{0, -1, -1, 0, 0, 0, 1, 1}),
0,
Tensor(IN_ET, {2, 2, 2}, std::vector<T>{12, 13, 20, 21, 10, 11, 22, 23}),
"gather_nd_8_batch_1d_from_3d_negative"),
GatherNDParams(
Tensor(IN_ET, {2, 2, 2}, std::vector<T>{10, 11, 12, 13, 20, 21, 22, 23}),
Tensor(element::i32, {2, 1, 1}, std::vector<int32_t>{1, 0}),
0,
Tensor(IN_ET, {2, 1, 2, 2}, std::vector<T>{20, 21, 22, 23, 10, 11, 12, 13}),
"gather_nd_8_batch_2d_from_3d"),
GatherNDParams(
Tensor(IN_ET, {2, 3, 4}, 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}),
Tensor(element::i32, {2, 1}, std::vector<int32_t>{1, 0}),
1,
Tensor(IN_ET, {2, 4}, std::vector<T>{5, 6, 7, 8, 13, 14, 15, 16}),
"gather_nd_8_batch_dims1"),
GatherNDParams(
Tensor(IN_ET, {2, 3, 4, 2}, 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}),
Tensor(element::i32, {2, 3, 3, 2}, std::vector<int32_t>{
1, 0, 3, 1, 2, 1, 0, 1, 1, 1, 2, 0, 3, 0, 3, 1, 2, 1,
2, 0, 1, 1, 3, 1, 1, 1, 2, 0, 2, 0, 0, 0, 3, 1, 3, 1}),
2,
Tensor(IN_ET, {2, 3, 3}, std::vector<T>{
3, 8, 6, 10, 12, 13, 23, 24, 22, 29, 28, 32, 36, 37, 37, 41, 48, 48}),
"gather_8_nd_batch_dims2"),
GatherNDParams(
Tensor(IN_ET, {2, 3, 4}, 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}),
Tensor(element::i32, {2, 3, 1, 1}, std::vector<int32_t>{1, 0, 2, 0, 2, 2}),
2,
Tensor(IN_ET, {2, 3, 1}, std::vector<T>{2, 5, 11, 13, 19, 23}),
"gather_8_nd_batch_dims2_lead_dims"),
GatherNDParams(
Tensor(IN_ET, {2, 3, 4, 5}, 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,
49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
111, 112, 113, 114, 115, 116, 117, 118, 119, 120}),
Tensor(element::i32, {2, 3, 2, 1}, std::vector<int32_t>{
1, 0, 2, 0, 2, 0, 1, 0, 2, 0, 2, 0}),
2,
Tensor(IN_ET, {2, 3, 2, 5}, std::vector<T>{
6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 31, 32, 33, 34, 35, 21, 22, 23,
24, 25, 51, 52, 53, 54, 55, 41, 42, 43, 44, 45, 66, 67, 68, 69,
70, 61, 62, 63, 64, 65, 91, 92, 93, 94, 95, 81, 82, 83, 84, 85,
111, 112, 113, 114, 115, 101, 102, 103, 104, 105}),
"gather_8_nd_batch_dims2_non_scalar_slices"),
};
return params;
}
std::vector<GatherNDParams> generateCombinedParams_v8() {
const std::vector<std::vector<GatherNDParams>> generatedParams {
generateParams_v8<element::Type_t::i8>(),
generateParams_v8<element::Type_t::i16>(),
generateParams_v8<element::Type_t::i32>(),
generateParams_v8<element::Type_t::i64>(),
generateParams_v8<element::Type_t::u8>(),
generateParams_v8<element::Type_t::u16>(),
generateParams_v8<element::Type_t::u32>(),
generateParams_v8<element::Type_t::u64>(),
generateParams_v8<element::Type_t::bf16>(),
generateParams_v8<element::Type_t::f16>(),
generateParams_v8<element::Type_t::f32>(),
generateParams_v8<element::Type_t::f64>(),
};
std::vector<GatherNDParams> combinedParams;
for (const auto& params : generatedParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_GatherND_With_Hardcoded_Refs, ReferenceGatherND8Test,
testing::ValuesIn(generateCombinedParams_v8()), ReferenceGatherND8Test::getTestCaseName);
} // namespace

View File

@ -0,0 +1,294 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "openvino/op/gru_cell.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
using namespace ov;
namespace {
struct GRUCellParams {
GRUCellParams(
const int32_t batchSize, const int32_t inputSize, const int32_t hiddenSize, const int32_t gatesCount, const bool linearBeforeReset,
const Tensor& X, const Tensor& H_t, const Tensor& W, const Tensor& R, const Tensor& B,
const Tensor& Ho, const std::string& testcaseName = "") :
batchSize(batchSize), inputSize(inputSize), hiddenSize(hiddenSize), gatesCount(gatesCount), linearBeforeReset(linearBeforeReset),
X(X), H_t(H_t), W(W), R(R), B(B), Ho(Ho), testcaseName(testcaseName) {}
int32_t batchSize;
int32_t inputSize;
int32_t hiddenSize;
int32_t gatesCount;
bool linearBeforeReset;
Tensor X;
Tensor H_t;
Tensor W;
Tensor R;
Tensor B;
Tensor Ho;
std::string testcaseName;
};
class ReferenceGRUCellTest : public testing::TestWithParam<GRUCellParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params);
inputData = {params.X.data, params.H_t.data, params.W.data, params.R.data, params.B.data};
refOutData = {params.Ho.data};
}
static std::string getTestCaseName(const testing::TestParamInfo<GRUCellParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "bSize=" << param.batchSize;
result << "_iSize=" << param.inputSize;
result << "_hSize=" << param.hiddenSize;
result << "_gCount=" << param.gatesCount;
result << "_lbReset=" << param.linearBeforeReset;
result << "_xType=" << param.X.type;
result << "_xShape=" << param.X.shape;
result << "_htType=" << param.H_t.type;
result << "_htShape=" << param.H_t.shape;
result << "_wType=" << param.W.type;
result << "_wShape=" << param.W.shape;
result << "_rType=" << param.R.type;
result << "_rShape=" << param.R.shape;
result << "_hoType=" << param.Ho.type;
if (param.testcaseName != "") {
result << "_hoShape=" << param.Ho.shape;
result << "_=" << param.testcaseName;
} else {
result << "_hoShape=" << param.Ho.shape;
}
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(const GRUCellParams& params) {
float clip = 2.88f;
const auto X = std::make_shared<op::v0::Parameter>(params.X.type, params.X.shape);
const auto H_t = std::make_shared<op::v0::Parameter>(params.H_t.type, params.H_t.shape);
const auto W = std::make_shared<op::v0::Parameter>(params.W.type, params.W.shape);
const auto R = std::make_shared<op::v0::Parameter>(params.R.type, params.R.shape);
const auto B = std::make_shared<op::v0::Parameter>(params.B.type, params.B.shape);
const auto gru_cell = std::make_shared<op::v3::GRUCell>(X,
H_t,
W,
R,
B,
params.hiddenSize,
std::vector<std::string>{"sigmoid", "tanh"},
std::vector<float>{},
std::vector<float>{},
clip,
params.linearBeforeReset);
auto function = std::make_shared<Function>(NodeVector{gru_cell}, ParameterVector{X, H_t, W, R, B});
return function;
}
};
// Hard Sigmoid activation function is unsupprted with v3::GRUCell
class ReferenceGRUCellTestHardsigmoidActivationFunction : public ReferenceGRUCellTest {
public:
void SetUp() override {
threshold = 1e-1f;
auto params = GetParam();
function = CreateFunction(params);
inputData = {params.X.data, params.H_t.data, params.W.data, params.R.data, params.B.data};
refOutData = {params.Ho.data};
}
private:
static std::shared_ptr<Function> CreateFunction(const GRUCellParams& params) {
float clip = 2.88f;
const auto X = std::make_shared<op::v0::Parameter>(params.X.type, params.X.shape);
const auto H_t = std::make_shared<op::v0::Parameter>(params.H_t.type, params.H_t.shape);
const auto W = std::make_shared<op::v0::Parameter>(params.W.type, params.W.shape);
const auto R = std::make_shared<op::v0::Parameter>(params.R.type, params.R.shape);
const auto B = std::make_shared<op::v0::Parameter>(params.B.type, params.B.shape);
const auto gru_cell = std::make_shared<op::v3::GRUCell>(X,
H_t,
W,
R,
B,
params.hiddenSize,
std::vector<std::string>{"hardsigmoid", "hardsigmoid"},
std::vector<float>{1.8345f, 1.8345f},
std::vector<float>{3.05f, 3.05f},
clip,
params.linearBeforeReset);
auto function = std::make_shared<Function>(NodeVector{gru_cell}, ParameterVector{X, H_t, W, R, B});
return function;
}
};
TEST_P(ReferenceGRUCellTest, CompareWithRefs) {
Exec();
}
TEST_P(ReferenceGRUCellTestHardsigmoidActivationFunction, CompareWithRefs) {
Exec();
}
template <element::Type_t ET>
std::vector<GRUCellParams> generateParams() {
using T = typename element_type_traits<ET>::value_type;
std::vector<GRUCellParams> params {
GRUCellParams(
2, 3, 3, 3, false,
Tensor(ET, {2, 3}, std::vector<T>{
0.52421564f, 0.78845507f, 0.9372873f, 0.59783894f, 0.18278378f, 0.2084126f}),
Tensor(ET, {2, 3}, std::vector<T>{
0.45738035f, 0.996877f, 0.82882977f, 0.47492632f, 0.88471466f, 0.57833236f}),
Tensor(ET, {3 * 3, 3}, std::vector<T>{
0.5815369f, 0.16559383f, 0.08464007f, 0.843122f, 0.73968244f, 0.11359601f,
0.8295078f, 0.9240567f, 0.10007995f, 0.20573162f, 0.09002485f, 0.2839569f,
0.3096991f, 0.5638341f, 0.5787327f, 0.84552664f, 0.16263747f, 0.7243242f,
0.8049057f, 0.43966424f, 0.46294412f, 0.9833361f, 0.31369713f, 0.1719934f,
0.4937093f, 0.6353004f, 0.77982515f}),
Tensor(ET, {3 * 3, 3}, std::vector<T>{
0.16510165f, 0.52435565f, 0.2788478f, 0.99427545f, 0.1623331f, 0.01389796f,
0.99669236f, 0.53901845f, 0.8737506f, 0.9254788f, 0.21172932f, 0.11634306f,
0.40111724f, 0.37497616f, 0.2903471f, 0.6796794f, 0.65131867f, 0.78163475f,
0.12058706f, 0.45591718f, 0.791677f, 0.76497287f, 0.9895242f, 0.7845312f,
0.51267904f, 0.49030215f, 0.08498167f}),
Tensor(ET, {3 * 3}, std::vector<T>{
0.8286678f + 0.9175602f,
0.9153158f + 0.14958014f,
0.9581612f + 0.49230585f,
0.6639213f + 0.63162816f,
0.84239805f + 0.4161903f,
0.5282445f + 0.22148274f,
0.14153397f + 0.50496656f,
0.22404431f + 0.34798595f,
0.6549655f + 0.6699164f}),
Tensor(ET, {2, 3}, std::vector<T>{
0.48588726f, 0.99670005f, 0.83759373f, 0.5023099f, 0.89410484f, 0.60011315f}),
"gru_cell_bias_clip"),
GRUCellParams(
2, 3, 3, 3, true,
Tensor(ET, {2, 3}, std::vector<T>{
0.12249453f, 0.6127907f, 0.5001741f, 0.5124603f, 0.04329684f, 0.023834f}),
Tensor(ET, {2, 3}, std::vector<T>{
0.8598948f, 0.41189128f, 0.72824323f, 0.53940123f, 0.31485787f, 0.04053852f}),
Tensor(ET, {3 * 3, 3}, std::vector<T>{
0.72259396f, 0.11561195f, 0.9457856f, 0.19037509f, 0.6964006f, 0.33459795f,
0.5468904f, 0.85646594f, 0.5101311f, 0.9712257f, 0.3687071f, 0.60280246f,
0.56943774f, 0.7475505f, 0.2490578f, 0.86977345f, 0.85542053f, 0.29660386f,
0.49717373f, 0.7473479f, 0.53454477f, 0.15974349f, 0.5804805f, 0.14303213f,
0.07514781f, 0.5865731f, 0.76409274f}),
Tensor(ET, {3 * 3, 3}, std::vector<T>{
0.91382647f, 0.41527033f, 0.28040004f, 0.23601337f, 0.04471736f, 0.03888785f,
0.06308217f, 0.44844428f, 0.29384327f, 0.49037653f, 0.50421673f, 0.7366393f,
0.63143945f, 0.00277612f, 0.37198433f, 0.06966069f, 0.4613444f, 0.10999731f,
0.78273284f, 0.21453214f, 0.10751773f, 0.18332677f, 0.1326976f, 0.9998985f,
0.19263928f, 0.10979804f, 0.52575564f}),
Tensor(ET, {(3 + 1) * 3}, std::vector<T>{
0.61395123f, // 0.09875853f + 0.5151927f,
1.08667738f, // 0.37801138f + 0.708666f,
1.32600244f, // 0.7729636f + 0.55303884f,
0.81917698f, // 0.78493553f + 0.03424145f,
1.37736335f, // 0.5662702f + 0.81109315f,
0.42931147f, // 0.12406381f + 0.30524766f,
0.66729516f,
0.7752771f,
0.78819966f,
0.6606634f,
0.99040645f,
0.21112025f}),
Tensor(ET, {2, 3}, std::vector<T>{
0.8709214f, 0.48411977f, 0.74495184f, 0.6074972f, 0.44572943f, 0.1467715f}),
"gru_cell_linear_before_reset"),
};
return params;
}
std::vector<GRUCellParams> generateCombinedParams() {
const std::vector<std::vector<GRUCellParams>> generatedParams {
generateParams<element::Type_t::bf16>(),
generateParams<element::Type_t::f16>(),
generateParams<element::Type_t::f32>(),
generateParams<element::Type_t::f64>(),
};
std::vector<GRUCellParams> combinedParams;
for (const auto& params : generatedParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
template <element::Type_t ET>
std::vector<GRUCellParams> generateParamsHardsigmoidActivationFunction() {
using T = typename element_type_traits<ET>::value_type;
std::vector<GRUCellParams> params {
GRUCellParams(
2, 3, 3, 3, true,
Tensor(ET, {2, 3}, std::vector<T>{
0.12249453f, 0.6127907f, 0.5001741f, 0.5124603f, 0.04329684f, 0.023834f}),
Tensor(ET, {2, 3}, std::vector<T>{
0.8598948f, 0.41189128f, 0.72824323f, 0.53940123f, 0.31485787f, 0.04053852f}),
Tensor(ET, {3 * 3, 3}, std::vector<T>{
0.72259396f, 0.11561195f, 0.9457856f, 0.19037509f, 0.6964006f, 0.33459795f,
0.5468904f, 0.85646594f, 0.5101311f, 0.9712257f, 0.3687071f, 0.60280246f,
0.56943774f, 0.7475505f, 0.2490578f, 0.86977345f, 0.85542053f, 0.29660386f,
0.49717373f, 0.7473479f, 0.53454477f, 0.15974349f, 0.5804805f, 0.14303213f,
0.07514781f, 0.5865731f, 0.76409274f}),
Tensor(ET, {3 * 3, 3}, std::vector<T>{
0.91382647f, 0.41527033f, 0.28040004f, 0.23601337f, 0.04471736f, 0.03888785f,
0.06308217f, 0.44844428f, 0.29384327f, 0.49037653f, 0.50421673f, 0.7366393f,
0.63143945f, 0.00277612f, 0.37198433f, 0.06966069f, 0.4613444f, 0.10999731f,
0.78273284f, 0.21453214f, 0.10751773f, 0.18332677f, 0.1326976f, 0.9998985f,
0.19263928f, 0.10979804f, 0.52575564f}),
Tensor(ET, {(3 + 1) * 3}, std::vector<T>{
0.09875853f + 0.5151927f,
0.37801138f + 0.708666f,
0.7729636f + 0.55303884f,
0.78493553f + 0.03424145f,
0.5662702f + 0.81109315f,
0.12406381f + 0.30524766f,
0.66729516f,
0.7752771f,
0.78819966f,
0.6606634f,
0.99040645f,
0.21112025f}),
Tensor(ET, {2, 3}, std::vector<T>{
0.8598948f, 0.41189128f, 0.72824323f, 0.53940123f, 0.31485787f, 0.04053852f}),
"gru_cell_hardsigmoid_activation_function"),
};
return params;
}
std::vector<GRUCellParams> generateCombinedParamsHardsigmoidActivationFunction() {
const std::vector<std::vector<GRUCellParams>> generatedParams {
generateParamsHardsigmoidActivationFunction<element::Type_t::bf16>(),
generateParamsHardsigmoidActivationFunction<element::Type_t::f16>(),
generateParamsHardsigmoidActivationFunction<element::Type_t::f32>(),
generateParamsHardsigmoidActivationFunction<element::Type_t::f64>(),
};
std::vector<GRUCellParams> combinedParams;
for (const auto& params : generatedParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_GRUCell_With_Hardcoded_Refs, ReferenceGRUCellTest,
testing::ValuesIn(generateCombinedParams()), ReferenceGRUCellTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_GRUCell_With_Hardcoded_Refs, ReferenceGRUCellTestHardsigmoidActivationFunction,
testing::ValuesIn(generateCombinedParamsHardsigmoidActivationFunction()), ReferenceGRUCellTest::getTestCaseName);
} // namespace

View File

@ -0,0 +1,379 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "openvino/op/lstm_cell.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
using namespace ov;
namespace {
struct LSTMCellParams {
LSTMCellParams(
int32_t batchSize, int32_t inputSize, int32_t hiddenSize, int32_t gatesCount,
const Tensor& X, const Tensor& W, const Tensor& R, const Tensor& H_t, const Tensor& C_t, const Tensor& B,
const Tensor& Ho, const Tensor& Co, const std::string& testcaseName = "") :
batchSize(batchSize), inputSize(inputSize), hiddenSize(hiddenSize), gatesCount(gatesCount),
X(X), W(W), R(R), H_t(H_t), C_t(C_t), B(B), Ho(Ho), Co(Co), testcaseName(testcaseName) {}
int32_t batchSize;
int32_t inputSize;
int32_t hiddenSize;
int32_t gatesCount;
Tensor X;
Tensor W;
Tensor R;
Tensor H_t;
Tensor C_t;
Tensor B;
Tensor Ho;
Tensor Co;
std::string testcaseName;
};
class ReferenceLSTMCellTest : public testing::TestWithParam<LSTMCellParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params);
inputData = {params.X.data, params.H_t.data, params.C_t.data, params.W.data, params.R.data, params.B.data};
refOutData = {params.Ho.data, params.Co.data};
}
static std::string getTestCaseName(const testing::TestParamInfo<LSTMCellParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "bSize=" << param.batchSize;
result << "_iSize=" << param.inputSize;
result << "_hSize=" << param.hiddenSize;
result << "_gCount=" << param.gatesCount;
result << "_xType=" << param.X.type;
result << "_xShape=" << param.X.shape;
result << "_wType=" << param.W.type;
result << "_wShape=" << param.W.shape;
result << "_rType=" << param.R.type;
result << "_rShape=" << param.R.shape;
result << "_htType=" << param.H_t.type;
result << "_htShape=" << param.H_t.shape;
result << "_ctType=" << param.C_t.type;
result << "_ctShape=" << param.C_t.shape;
result << "_hoType=" << param.Ho.type;
result << "_hoShape=" << param.Ho.shape;
result << "_coType=" << param.Co.type;
if (param.testcaseName != "") {
result << "_coShape=" << param.Co.shape;
result << "_=" << param.testcaseName;
} else {
result << "_coShape=" << param.Co.shape;
}
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(const LSTMCellParams& params) {
const auto X = std::make_shared<op::v0::Parameter>(params.X.type, params.X.shape);
const auto W = std::make_shared<op::v0::Parameter>(params.W.type, params.W.shape);
const auto R = std::make_shared<op::v0::Parameter>(params.R.type, params.R.shape);
const auto H_t = std::make_shared<op::v0::Parameter>(params.H_t.type, params.H_t.shape);
const auto C_t = std::make_shared<op::v0::Parameter>(params.C_t.type, params.C_t.shape);
const auto B = std::make_shared<op::v0::Parameter>(params.B.type, params.B.shape);
const auto lstm_cell =
std::make_shared<op::v4::LSTMCell>(X,
H_t,
C_t,
op::util::convert_lstm_node_format(W, op::util::LSTMWeightsFormat::IOFC),
op::util::convert_lstm_node_format(R, op::util::LSTMWeightsFormat::IOFC),
op::util::convert_lstm_node_format(B, op::util::LSTMWeightsFormat::IOFC),
params.hiddenSize);
auto function = std::make_shared<Function>(lstm_cell->outputs(), ParameterVector{X, H_t, C_t, W, R, B});
return function;
}
};
class ReferenceLSTMCellTestBiasDefaultAttrs : public ReferenceLSTMCellTest {
public:
void SetUp() override {
threshold = 1e-1f;
auto params = GetParam();
function = CreateFunction(params);
inputData = {params.X.data, params.H_t.data, params.C_t.data, params.W.data, params.R.data, params.B.data};
refOutData = {params.Ho.data, params.Co.data};
}
private:
static std::shared_ptr<Function> CreateFunction(const LSTMCellParams& params) {
const auto X = std::make_shared<op::v0::Parameter>(params.X.type, params.X.shape);
const auto W = std::make_shared<op::v0::Parameter>(params.W.type, params.W.shape);
const auto R = std::make_shared<op::v0::Parameter>(params.R.type, params.R.shape);
const auto H_t = std::make_shared<op::v0::Parameter>(params.H_t.type, params.H_t.shape);
const auto C_t = std::make_shared<op::v0::Parameter>(params.C_t.type, params.C_t.shape);
const auto B = std::make_shared<op::v0::Parameter>(params.B.type, params.B.shape);
const auto lstm_cell =
std::make_shared<op::v4::LSTMCell>(X,
H_t,
C_t,
op::util::convert_lstm_node_format(W, op::util::LSTMWeightsFormat::IOFC),
op::util::convert_lstm_node_format(R, op::util::LSTMWeightsFormat::IOFC),
op::util::convert_lstm_node_format(B, op::util::LSTMWeightsFormat::IOFC),
params.hiddenSize);
auto function = std::make_shared<Function>(lstm_cell->outputs(), ParameterVector{X, H_t, C_t, W, R, B});
return function;
}
};
class ReferenceLSTMCellTestBiasClip : public ReferenceLSTMCellTest {
public:
void SetUp() override {
threshold = 1e-1f;
auto params = GetParam();
function = CreateFunction(params);
inputData = {params.X.data, params.H_t.data, params.C_t.data, params.W.data, params.R.data, params.B.data};
refOutData = {params.Ho.data, params.Co.data};
}
private:
static std::shared_ptr<Function> CreateFunction(const LSTMCellParams& params) {
const float clip_threshold = 3.5f;
const auto X = std::make_shared<op::v0::Parameter>(params.X.type, params.X.shape);
const auto W = std::make_shared<op::v0::Parameter>(params.W.type, params.W.shape);
const auto R = std::make_shared<op::v0::Parameter>(params.R.type, params.R.shape);
const auto H_t = std::make_shared<op::v0::Parameter>(params.H_t.type, params.H_t.shape);
const auto C_t = std::make_shared<op::v0::Parameter>(params.C_t.type, params.C_t.shape);
const auto B = std::make_shared<op::v0::Parameter>(params.B.type, params.B.shape);
const auto lstm_cell =
std::make_shared<op::v4::LSTMCell>(X,
H_t,
C_t,
W,
R,
B,
params.hiddenSize,
std::vector<std::string>{"sigmoid", "tanh", "tanh"},
std::vector<float>{},
std::vector<float>{},
clip_threshold);
auto function = std::make_shared<Function>(lstm_cell->outputs(), ParameterVector{X, H_t, C_t, W, R, B});
return function;
}
};
TEST_P(ReferenceLSTMCellTest, CompareWithRefs) {
Exec();
}
TEST_P(ReferenceLSTMCellTestBiasDefaultAttrs, CompareWithRefs) {
Exec();
}
TEST_P(ReferenceLSTMCellTestBiasClip, CompareWithRefs) {
Exec();
}
template <element::Type_t ET>
std::vector<LSTMCellParams> generateParams() {
using T = typename element_type_traits<ET>::value_type;
std::vector<LSTMCellParams> params {
LSTMCellParams(
2, 3, 3, 4,
Tensor(ET, {2, 3}, std::vector<T>{
0.81342685f, 0.84108883f, 0.8152282f, 0.46893653f, 0.0901856f, 0.37088776f}),
Tensor(ET, {4 * 3, 3}, std::vector<T>{
3.3330739e-01f, 3.6229487e-04f, 4.6773660e-01f, 4.3046016e-01f, 7.3950343e-02f, 3.8063636e-01f,
9.6921772e-01f, 9.6897459e-01f, 6.2964785e-01f, 3.1134409e-01f, 8.4709978e-01f, 9.4928098e-01f,
6.1676943e-01f, 6.6020679e-01f, 1.9072217e-01f, 8.8032126e-02f, 4.0472135e-01f, 6.8342745e-01f,
8.3432144e-01f, 4.4928190e-01f, 7.9524308e-01f, 5.3966165e-01f, 8.5936421e-01f, 8.3136767e-01f,
5.5125546e-02f, 4.7791195e-01f, 3.5788772e-01f, 6.7507404e-01f, 2.1716513e-01f, 2.7473119e-01f,
3.3999152e-02f, 9.6835363e-01f, 3.7581277e-01f, 2.4026000e-01f, 6.7418844e-01f, 3.4199652e-01f}),
Tensor(ET, {4 * 3, 3}, std::vector<T>{
0.0987983f, 0.52032113f, 0.5848073f, 0.5356095f, 0.74497133f, 0.73260087f,
0.1700787f, 0.45684233f, 0.1495722f, 0.42734373f, 0.4433832f, 0.25906256f,
0.03854987f, 0.47480518f, 0.37215272f, 0.99890584f, 0.74019486f, 0.3518967f,
0.6881257f, 0.8170279f, 0.54088944f, 0.81225616f, 0.14619833f, 0.42941234f,
0.86843914f, 0.45967972f, 0.6237719f, 0.11074839f, 0.6029616f, 0.3149305f,
0.46504205f, 0.5843412f, 0.8733427f, 0.7687243f, 0.07074859f, 0.39188156f}),
Tensor(ET, {2, 3}, std::vector<T>{
0.77956f, 0.5331557f, 0.04297554f, 0.7962175f, 0.7635707f, 0.11989366f}),
Tensor(ET, {2, 3}, std::vector<T>{
0.8488452f, 0.18851636f, 0.5020695f, 0.29716516f, 0.06740791f, 0.45384037f}),
Tensor(ET, {4 * 3}, std::vector<T>(4 * 3, 0.f)),
Tensor(ET, {2, 3}, std::vector<T>{0.81457126f, 0.61109227f, 0.769522f, 0.52239674f, 0.4324641f, 0.63183f}),
Tensor(ET, {2, 3}, std::vector<T>{1.4444952f, 0.9635685f, 1.2875274f, 0.8053419f, 0.7184521f, 0.95803297f}),
"lstm_cell_zero_bias_default_attrs"),
};
return params;
}
std::vector<LSTMCellParams> generateCombinedParams() {
const std::vector<std::vector<LSTMCellParams>> generatedParams {
generateParams<element::Type_t::bf16>(),
generateParams<element::Type_t::f16>(),
generateParams<element::Type_t::f32>(),
generateParams<element::Type_t::f64>(),
};
std::vector<LSTMCellParams> combinedParams;
for (const auto& params : generatedParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
template <element::Type_t ET>
std::vector<LSTMCellParams> generateParamsBiasDefaultAttrs() {
using T = typename element_type_traits<ET>::value_type;
std::vector<LSTMCellParams> params {
LSTMCellParams(
2, 3, 3, 4,
Tensor(ET, {2, 3}, std::vector<T>{
0.81342685f, 0.84108883f, 0.8152282f, 0.46893653f, 0.0901856f, 0.37088776f}),
Tensor(ET, {4 * 3, 3}, std::vector<T>{
3.3330739e-01f, 3.6229487e-04f, 4.6773660e-01f, 4.3046016e-01f, 7.3950343e-02f, 3.8063636e-01f,
9.6921772e-01f, 9.6897459e-01f, 6.2964785e-01f, 3.1134409e-01f, 8.4709978e-01f, 9.4928098e-01f,
6.1676943e-01f, 6.6020679e-01f, 1.9072217e-01f, 8.8032126e-02f, 4.0472135e-01f, 6.8342745e-01f,
8.3432144e-01f, 4.4928190e-01f, 7.9524308e-01f, 5.3966165e-01f, 8.5936421e-01f, 8.3136767e-01f,
5.5125546e-02f, 4.7791195e-01f, 3.5788772e-01f, 6.7507404e-01f, 2.1716513e-01f, 2.7473119e-01f,
3.3999152e-02f, 9.6835363e-01f, 3.7581277e-01f, 2.4026000e-01f, 6.7418844e-01f, 3.4199652e-01f}),
Tensor(ET, {4 * 3, 3}, std::vector<T>{
0.0987983f, 0.52032113f, 0.5848073f, 0.5356095f, 0.74497133f, 0.73260087f,
0.1700787f, 0.45684233f, 0.1495722f, 0.42734373f, 0.4433832f, 0.25906256f,
0.03854987f, 0.47480518f, 0.37215272f, 0.99890584f, 0.74019486f, 0.3518967f,
0.6881257f, 0.8170279f, 0.54088944f, 0.81225616f, 0.14619833f, 0.42941234f,
0.86843914f, 0.45967972f, 0.6237719f, 0.11074839f, 0.6029616f, 0.3149305f,
0.46504205f, 0.5843412f, 0.8733427f, 0.7687243f, 0.07074859f, 0.39188156f}),
Tensor(ET, {2, 3}, std::vector<T>{
0.77956f, 0.5331557f, 0.04297554f, 0.7962175f, 0.7635707f, 0.11989366f}),
Tensor(ET, {2, 3}, std::vector<T>{
0.8488452f, 0.18851636f, 0.5020695f, 0.29716516f, 0.06740791f, 0.45384037f}),
Tensor(ET, {4 * 3}, std::vector<T>{1.07393714f,
1.15248052f,
1.16671345f,
0.21450312f,
1.2380678f,
1.51688835f,
0.46718366f,
0.91810346f,
1.1274234f,
0.51022074f,
1.11389844f,
0.74174305f}),
Tensor(ET, {2, 3}, std::vector<T>{0.81014400720596313,
0.76665538549423218,
0.82509011030197144,
0.6479143500328064,
0.66586339473724365,
0.74838578701019287}),
Tensor(ET, {2, 3}, std::vector<T>{1.6800162792205811,
1.1150213479995728,
1.4578367471694946,
1.0649888515472412,
0.93761754035949707,
1.3659683465957642}),
"lstm_cell_bias_default_attrs"),
};
return params;
}
std::vector<LSTMCellParams> generateCombinedParamsBiasDefaultAttrs() {
const std::vector<std::vector<LSTMCellParams>> generatedParams {
generateParamsBiasDefaultAttrs<element::Type_t::bf16>(),
generateParamsBiasDefaultAttrs<element::Type_t::f16>(),
generateParamsBiasDefaultAttrs<element::Type_t::f32>(),
generateParamsBiasDefaultAttrs<element::Type_t::f64>(),
};
std::vector<LSTMCellParams> combinedParams;
for (const auto& params : generatedParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
template <element::Type_t ET>
std::vector<LSTMCellParams> generateParamsBiasClip() {
using T = typename element_type_traits<ET>::value_type;
std::vector<LSTMCellParams> params {
LSTMCellParams(
2, 3, 3, 4,
Tensor(ET, {2, 3}, std::vector<T>{
0.81342685f, 0.84108883f, 0.8152282f, 0.46893653f, 0.0901856f, 0.37088776f}),
Tensor(ET, {4 * 3, 3}, std::vector<T>{
3.3330739e-01f, 3.6229487e-04f, 4.6773660e-01f, 4.3046016e-01f, 7.3950343e-02f, 3.8063636e-01f,
9.6921772e-01f, 9.6897459e-01f, 6.2964785e-01f, 3.1134409e-01f, 8.4709978e-01f, 9.4928098e-01f,
6.1676943e-01f, 6.6020679e-01f, 1.9072217e-01f, 8.8032126e-02f, 4.0472135e-01f, 6.8342745e-01f,
8.3432144e-01f, 4.4928190e-01f, 7.9524308e-01f, 5.3966165e-01f, 8.5936421e-01f, 8.3136767e-01f,
5.5125546e-02f, 4.7791195e-01f, 3.5788772e-01f, 6.7507404e-01f, 2.1716513e-01f, 2.7473119e-01f,
3.3999152e-02f, 9.6835363e-01f, 3.7581277e-01f, 2.4026000e-01f, 6.7418844e-01f, 3.4199652e-01f}),
Tensor(ET, {4 * 3, 3}, std::vector<T>{
0.0987983f, 0.52032113f, 0.5848073f, 0.5356095f, 0.74497133f, 0.73260087f,
0.1700787f, 0.45684233f, 0.1495722f, 0.42734373f, 0.4433832f, 0.25906256f,
0.03854987f, 0.47480518f, 0.37215272f, 0.99890584f, 0.74019486f, 0.3518967f,
0.6881257f, 0.8170279f, 0.54088944f, 0.81225616f, 0.14619833f, 0.42941234f,
0.86843914f, 0.45967972f, 0.6237719f, 0.11074839f, 0.6029616f, 0.3149305f,
0.46504205f, 0.5843412f, 0.8733427f, 0.7687243f, 0.07074859f, 0.39188156f}),
Tensor(ET, {2, 3}, std::vector<T>{
0.77956f, 0.5331557f, 0.04297554f, 0.7962175f, 0.7635707f, 0.11989366f}),
Tensor(ET, {2, 3}, std::vector<T>{
0.8488452f, 0.18851636f, 0.5020695f, 0.29716516f, 0.06740791f, 0.45384037f}),
Tensor(ET, {4 * 3}, std::vector<T>{1.07393714f,
1.15248052f,
1.16671345f,
0.21450312f,
1.2380678f,
1.51688835f,
0.46718366f,
0.91810346f,
1.1274234f,
0.51022074f,
1.11389844f,
0.74174305f}),
Tensor(ET, {2, 3}, std::vector<T>{0.81014400720596313,
0.76665538549423218,
0.82387429475784302,
0.6479143500328064,
0.66586339473724365,
0.74838578701019287}),
Tensor(ET, {2, 3}, std::vector<T>{1.6800162792205811,
1.1150213479995728,
1.4510968923568726,
1.0649888515472412,
0.93761754035949707,
1.3659683465957642}),
"lstm_cell_bias_clip"),
};
return params;
}
std::vector<LSTMCellParams> generateCombinedParamsBiasClip() {
const std::vector<std::vector<LSTMCellParams>> generatedParams {
generateParamsBiasClip<element::Type_t::bf16>(),
generateParamsBiasClip<element::Type_t::f16>(),
generateParamsBiasClip<element::Type_t::f32>(),
generateParamsBiasClip<element::Type_t::f64>(),
};
std::vector<LSTMCellParams> combinedParams;
for (const auto& params : generatedParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_LSTMCell_With_Hardcoded_Refs, ReferenceLSTMCellTest,
testing::ValuesIn(generateCombinedParams()), ReferenceLSTMCellTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_LSTMCell_With_Hardcoded_Refs, ReferenceLSTMCellTestBiasDefaultAttrs,
testing::ValuesIn(generateCombinedParamsBiasDefaultAttrs()), ReferenceLSTMCellTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_LSTMCell_With_Hardcoded_Refs, ReferenceLSTMCellTestBiasClip,
testing::ValuesIn(generateCombinedParamsBiasClip()), ReferenceLSTMCellTest::getTestCaseName);
} // namespace

View File

@ -0,0 +1,226 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "openvino/op/one_hot.hpp"
#include "openvino/op/constant.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
using namespace ov;
namespace {
struct OneHotParams {
OneHotParams(
const Tensor& dataTensor, const int32_t axis,
const Tensor& depthTensor, const Tensor& onValueTensor, const Tensor& offValueTensor,
const Tensor& expectedTensor, const std::string& testcaseName = "") :
dataTensor(dataTensor), axis(axis),
depthTensor(depthTensor), onValueTensor(onValueTensor), offValueTensor(offValueTensor),
expectedTensor(expectedTensor), testcaseName(testcaseName) {}
Tensor dataTensor;
int32_t axis;
Tensor depthTensor;
Tensor onValueTensor;
Tensor offValueTensor;
Tensor expectedTensor;
std::string testcaseName;
};
class ReferenceOneHotTest : public testing::TestWithParam<OneHotParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params);
inputData = {params.dataTensor.data};
refOutData = {params.expectedTensor.data};
}
static std::string getTestCaseName(const testing::TestParamInfo<OneHotParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "dType=" << param.dataTensor.type;
result << "_dShape=" << param.dataTensor.shape;
result << "_axis=" << param.axis;
result << "_deType=" << param.depthTensor.type;
result << "_deShape=" << param.depthTensor.shape;
result << "_onType=" << param.onValueTensor.type;
result << "_onShape=" << param.onValueTensor.shape;
result << "_offType=" << param.offValueTensor.type;
result << "_offShape=" << param.offValueTensor.shape;
result << "_eType=" << param.expectedTensor.type;
if (param.testcaseName != "") {
result << "_eShape=" << param.expectedTensor.shape;
result << "_=" << param.testcaseName;
} else {
result << "_eShape=" << param.expectedTensor.shape;
}
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(const OneHotParams& params) {
std::shared_ptr<Function> function;
const auto data = std::make_shared<op::v0::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto depth = std::make_shared<op::v0::Constant>(params.depthTensor.type, params.depthTensor.shape,
params.depthTensor.data.data());
const auto onValue = std::make_shared<op::v0::Constant>(params.onValueTensor.type, params.onValueTensor.shape,
params.onValueTensor.data.data());
const auto offValue = std::make_shared<op::v0::Constant>(params.offValueTensor.type, params.offValueTensor.shape,
params.offValueTensor.data.data());
const auto oneHot = std::make_shared<op::v1::OneHot>(data, depth, onValue, offValue, params.axis);
function = std::make_shared<ov::Function>(oneHot, ParameterVector{data});
return function;
}
};
TEST_P(ReferenceOneHotTest, CompareWithRefs) {
Exec();
}
template<typename T>
std::vector<T> generateExpectedValues(const Shape& input_shape, std::vector<T> input, uint32_t category_count) {
// std::vector<T> input{0, 11, 101, 1001, 10001, static_cast<int32_t>(category_count - 1)};
std::vector<T> output(shape_size(input_shape), 0);
for (size_t i = 0; i < input.size(); ++i) {
output[i * category_count + input[i]] = 1;
}
return output;
}
template <element::Type_t ET1, element::Type_t ET2>
std::vector<OneHotParams> generateParams() {
using T1 = typename element_type_traits<ET1>::value_type;
using T2 = typename element_type_traits<ET2>::value_type;
std::vector<OneHotParams> params {
OneHotParams(
Tensor(ET1, {}, std::vector<T1>{2}),
0,
Tensor(ET1, {}, std::vector<T1>{3}),
Tensor(ET2, {}, std::vector<T2>{1}),
Tensor(ET2, {}, std::vector<T2>{0}),
Tensor(ET2, {3}, std::vector<T2>{0, 0, 1}),
"one_hot_scalar_2_in_3"),
OneHotParams(
Tensor(ET1, {}, std::vector<T1>{1}),
0,
Tensor(ET1, {}, std::vector<T1>{3}),
Tensor(ET2, {}, std::vector<T2>{1}),
Tensor(ET2, {}, std::vector<T2>{0}),
Tensor(ET2, {3}, std::vector<T2>{0, 1, 0}),
"one_hot_scalar_1_in_3"),
OneHotParams(
Tensor(ET1, {}, std::vector<T1>{0}),
0,
Tensor(ET1, {}, std::vector<T1>{3}),
Tensor(ET2, {}, std::vector<T2>{1}),
Tensor(ET2, {}, std::vector<T2>{0}),
Tensor(ET2, {3}, std::vector<T2>{1, 0, 0}),
"one_hot_scalar_0_in_3"),
OneHotParams(
Tensor(ET1, {8}, std::vector<T1>{2, 1, 0, 0, 2, 2, 1, 0}),
0,
Tensor(ET1, {}, std::vector<T1>{3}),
Tensor(ET2, {}, std::vector<T2>{1}),
Tensor(ET2, {}, std::vector<T2>{0}),
Tensor(ET2, {3, 8}, std::vector<T2>{0, 0, 1, 1, 0, 0, 0, 1,
0, 1, 0, 0, 0, 0, 1, 0,
1, 0, 0, 0, 1, 1, 0, 0}),
"one_hot_vector_0"),
OneHotParams(
Tensor(ET1, {8}, std::vector<T1>{2, 1, 0, 0, 2, 2, 1, 0}),
1,
Tensor(ET1, {}, std::vector<T1>{3}),
Tensor(ET2, {}, std::vector<T2>{1}),
Tensor(ET2, {}, std::vector<T2>{0}),
Tensor(ET2, {8, 3}, std::vector<T2>{0, 0, 1, 0, 1, 0, 1, 0,
0, 1, 0, 0, 0, 0, 1, 0,
0, 1, 0, 1, 0, 1, 0, 0}),
"one_hot_vector_1"),
OneHotParams(
Tensor(ET1, {8}, std::vector<T1>{2, 1, 0, 0, 3, 2, 1, 0}),
1,
Tensor(ET1, {}, std::vector<T1>{3}),
Tensor(ET2, {}, std::vector<T2>{1}),
Tensor(ET2, {}, std::vector<T2>{0}),
Tensor(ET2, {8, 3}, std::vector<T2>{0, 0, 1, 0, 1, 0, 1, 0,
0, 1, 0, 0, 0, 0, 0, 0,
0, 1, 0, 1, 0, 1, 0, 0}),
"one_hot_vector_1_barely_oob"),
OneHotParams(
Tensor(ET1, {3, 3}, std::vector<T1>{0, 1, 1, 2, 1, 0, 0, 2, 1}),
0,
Tensor(ET1, {}, std::vector<T1>{3}),
Tensor(ET2, {}, std::vector<T2>{1}),
Tensor(ET2, {}, std::vector<T2>{0}),
Tensor(ET2, {3, 3, 3}, std::vector<T2>{1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1,
0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0}),
"one_hot_matrix_0"),
OneHotParams(
Tensor(ET1, {6}, std::vector<T1>{0, 11, 101, 1001, 10001, 19999}),
1,
Tensor(ET1, {}, std::vector<T1>{20000}),
Tensor(ET2, {}, std::vector<T2>{1}),
Tensor(ET2, {}, std::vector<T2>{0}),
Tensor(ET2, {6, 20000}, generateExpectedValues({6, 20000},
std::vector<T2>{0, 11, 101, 1001, 10001, 19999},
20000)),
"one_hot_vector_many_categories"),
};
return params;
}
template <element::Type_t ET1, element::Type_t ET2>
std::vector<OneHotParams> generateParamsFloat() {
using T1 = typename element_type_traits<ET1>::value_type;
using T2 = typename element_type_traits<ET2>::value_type;
std::vector<OneHotParams> params {
OneHotParams(
Tensor(ET1, {3, 3}, std::vector<T1>{0, 1, 1, 2, 1, 0, 0, 2, 1}),
0,
Tensor(ET1, {}, std::vector<T1>{3}),
Tensor(ET2, {}, std::vector<T2>{2.5}),
Tensor(ET2, {}, std::vector<T2>{0.5}),
Tensor(ET2, {3, 3, 3}, std::vector<T2>{
2.5, 0.5, 0.5, 0.5, 0.5, 2.5, 2.5, 0.5, 0.5, 0.5, 2.5, 2.5, 0.5, 2.5,
0.5, 0.5, 0.5, 2.5, 0.5, 0.5, 0.5, 2.5, 0.5, 0.5, 0.5, 2.5, 0.5}),
"one_hot_on_off_float"),
};
return params;
}
std::vector<OneHotParams> generateCombinedParams() {
const std::vector<std::vector<OneHotParams>> generatedParams {
generateParams<element::Type_t::i32, element::Type_t::i16>(),
generateParams<element::Type_t::i32, element::Type_t::i32>(),
generateParams<element::Type_t::i32, element::Type_t::i64>(),
generateParams<element::Type_t::i32, element::Type_t::u16>(),
generateParams<element::Type_t::i32, element::Type_t::u32>(),
generateParams<element::Type_t::i32, element::Type_t::u64>(),
generateParams<element::Type_t::i64, element::Type_t::i16>(),
generateParams<element::Type_t::i64, element::Type_t::i32>(),
generateParams<element::Type_t::i64, element::Type_t::i64>(),
generateParams<element::Type_t::i64, element::Type_t::u16>(),
generateParams<element::Type_t::i64, element::Type_t::u32>(),
generateParams<element::Type_t::i64, element::Type_t::u64>(),
generateParamsFloat<element::Type_t::i32, element::Type_t::bf16>(),
generateParamsFloat<element::Type_t::i32, element::Type_t::f16>(),
generateParamsFloat<element::Type_t::i32, element::Type_t::f32>(),
generateParamsFloat<element::Type_t::i32, element::Type_t::f64>(),
generateParamsFloat<element::Type_t::i64, element::Type_t::f32>(),
generateParamsFloat<element::Type_t::i64, element::Type_t::f64>(),
};
std::vector<OneHotParams> combinedParams;
for (const auto& params : generatedParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_OneHot_With_Hardcoded_Refs, ReferenceOneHotTest,
testing::ValuesIn(generateCombinedParams()), ReferenceOneHotTest::getTestCaseName);
} // namespace

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,126 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "openvino/op/prior_box.hpp"
#include "base_reference_test.hpp"
#include "openvino/opsets/opset1.hpp"
using namespace reference_tests;
using namespace ov;
namespace {
struct PriorBoxParams {
template <class IT>
PriorBoxParams(const std::vector<float>& min_size,
const std::vector<float>& aspect_ratio,
const bool scale_all_size,
const ov::Shape& layerShapeShape, const ov::Shape& imageShapeShape,
const ov::element::Type& iType,
const std::vector<IT>& layerShapeValues, const std::vector<IT>& imageShapeValues,
const std::vector<float>& oValues,
const std::string& testcaseName = "")
: layerShapeShape(layerShapeShape),
imageShapeShape(imageShapeShape),
inType(iType),
outType(ov::element::Type_t::f32),
layerShapeData(CreateTensor(iType, layerShapeValues)),
imageShapeData(CreateTensor(iType, imageShapeValues)),
refData(CreateTensor(outType, oValues)),
testcaseName(testcaseName) {
attrs.min_size = min_size;
attrs.aspect_ratio = aspect_ratio;
attrs.scale_all_sizes = scale_all_size;
}
ov::op::v0::PriorBox::Attributes attrs;
ov::Shape layerShapeShape;
ov::Shape imageShapeShape;
ov::element::Type inType;
ov::element::Type outType;
ov::runtime::Tensor layerShapeData;
ov::runtime::Tensor imageShapeData;
ov::runtime::Tensor refData;
std::string testcaseName;
};
class ReferencePriorBoxLayerTest : public testing::TestWithParam<PriorBoxParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params);
inputData = {};
refOutData = {params.refData};
}
static std::string getTestCaseName(const testing::TestParamInfo<PriorBoxParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "layerShapeShape=" << param.layerShapeShape << "_";
result << "imageShapeShape=" << param.imageShapeShape << "_";
result << "iType=" << param.inType << "_";
result << "oType=" << param.outType;
if (param.testcaseName != "")
result << "_" << param.testcaseName;
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(const PriorBoxParams& params) {
auto LS = std::make_shared<opset1::Constant>(params.inType, params.layerShapeShape, params.layerShapeData.data());
auto IS = std::make_shared<opset1::Constant>(params.inType, params.imageShapeShape, params.imageShapeData.data());
const auto PriorBox = std::make_shared<op::v0::PriorBox>(LS, IS, params.attrs);
return std::make_shared<ov::Function>(NodeVector {PriorBox}, ParameterVector {});
}
};
TEST_P(ReferencePriorBoxLayerTest, CompareWithRefs) {
Exec();
}
template <element::Type_t IN_ET>
std::vector<PriorBoxParams> generatePriorBoxFloatParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<PriorBoxParams> priorBoxParams {
PriorBoxParams({2.0f}, {1.5f}, false,
{2}, {2},
IN_ET,
std::vector<T>{2, 2},
std::vector<T>{10, 10},
std::vector<float>{-0.75, -0.75, 1.25, 1.25, -0.974745, -0.566497, 1.47474, 1.0665,
-0.25, -0.75, 1.75, 1.25, -0.474745, -0.566497, 1.97474, 1.0665,
-0.75, -0.25, 1.25, 1.75, -0.974745, -0.0664966, 1.47474, 1.5665,
-0.25, -0.25, 1.75, 1.75, -0.474745, -0.0664966, 1.97474, 1.5665,
0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1}),
};
return priorBoxParams;
}
std::vector<PriorBoxParams> generatePriorBoxCombinedParams() {
const std::vector<std::vector<PriorBoxParams>> priorBoxTypeParams {
generatePriorBoxFloatParams<element::Type_t::i64>(),
generatePriorBoxFloatParams<element::Type_t::i32>(),
generatePriorBoxFloatParams<element::Type_t::i16>(),
generatePriorBoxFloatParams<element::Type_t::i8>(),
generatePriorBoxFloatParams<element::Type_t::u64>(),
generatePriorBoxFloatParams<element::Type_t::u32>(),
generatePriorBoxFloatParams<element::Type_t::u16>(),
generatePriorBoxFloatParams<element::Type_t::u8>(),
};
std::vector<PriorBoxParams> combinedParams;
for (const auto& params : priorBoxTypeParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_PriorBox_With_Hardcoded_Refs, ReferencePriorBoxLayerTest,
testing::ValuesIn(generatePriorBoxCombinedParams()), ReferencePriorBoxLayerTest::getTestCaseName);
} // namespace

View File

@ -0,0 +1,134 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "openvino/op/prior_box.hpp"
#include "base_reference_test.hpp"
#include "openvino/opsets/opset1.hpp"
using namespace reference_tests;
using namespace ov;
namespace {
struct PriorBoxClusteredParams {
template <class IT>
PriorBoxClusteredParams(const std::vector<float>& widths,
const std::vector<float>& heights,
const bool clip,
const ov::Shape& layerShapeShape, const ov::Shape& imageShapeShape,
const ov::element::Type& iType,
const std::vector<IT>& layerShapeValues, const std::vector<IT>& imageShapeValues,
const std::vector<float>& oValues,
const std::vector<float>& variances = {},
const std::string& testcaseName = "")
: layerShapeShape(layerShapeShape),
imageShapeShape(imageShapeShape),
inType(iType),
outType(ov::element::Type_t::f32),
layerShapeData(CreateTensor(iType, layerShapeValues)),
imageShapeData(CreateTensor(iType, imageShapeValues)),
refData(CreateTensor(outType, oValues)),
testcaseName(testcaseName) {
attrs.widths = widths;
attrs.heights = heights;
attrs.clip = clip;
if ( variances.size() != 0)
attrs.variances = variances;
}
ov::op::v0::PriorBoxClustered::Attributes attrs;
ov::Shape layerShapeShape;
ov::Shape imageShapeShape;
ov::element::Type inType;
ov::element::Type outType;
ov::runtime::Tensor layerShapeData;
ov::runtime::Tensor imageShapeData;
ov::runtime::Tensor refData;
std::string testcaseName;
};
class ReferencePriorBoxClusteredLayerTest : public testing::TestWithParam<PriorBoxClusteredParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params);
inputData = {};
refOutData = {params.refData};
}
static std::string getTestCaseName(const testing::TestParamInfo<PriorBoxClusteredParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "layerShapeShape=" << param.layerShapeShape << "_";
result << "imageShapeShape=" << param.imageShapeShape << "_";
result << "variancesSize=" << param.attrs.variances.size() << "_";
result << "iType=" << param.inType << "_";
result << "oType=" << param.outType;
if (param.testcaseName != "")
result << "_" << param.testcaseName;
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(const PriorBoxClusteredParams& params) {
auto LS = std::make_shared<opset1::Constant>(params.inType, params.layerShapeShape, params.layerShapeData.data());
auto IS = std::make_shared<opset1::Constant>(params.inType, params.imageShapeShape, params.imageShapeData.data());
const auto PriorBoxClustered = std::make_shared<op::v0::PriorBoxClustered>(LS, IS, params.attrs);
return std::make_shared<ov::Function>(NodeVector {PriorBoxClustered}, ParameterVector {});
}
};
TEST_P(ReferencePriorBoxClusteredLayerTest, CompareWithRefs) {
Exec();
}
template <element::Type_t IN_ET>
std::vector<PriorBoxClusteredParams> generatePriorBoxClusteredFloatParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<PriorBoxClusteredParams> priorBoxClusteredParams {
PriorBoxClusteredParams({3.0f}, {3.0f}, true,
{2}, {2},
IN_ET,
std::vector<T>{2, 2},
std::vector<T>{10, 10},
std::vector<float>{0, 0, 0.15f, 0.15f, 0.34999f, 0, 0.64999f, 0.15f, 0, 0.34999f, 0.15f,
0.64999f, 0.34999f, 0.34999f, 0.64999f, 0.64999f, 0.1f, 0.1f, 0.1f, 0.1f, 0.1f, 0.1f,
0.1f, 0.1f, 0.1f, 0.1f, 0.1f, 0.1f, 0.1f, 0.1f, 0.1f, 0.1f}),
PriorBoxClusteredParams({3.0f}, {3.0f}, true,
{2}, {2},
IN_ET,
std::vector<T>{2, 2},
std::vector<T>{10, 10},
std::vector<float>{0, 0, 0.15f, 0.15f, 0.34999f, 0, 0.64999f, 0.15f, 0, 0.34999f, 0.15f,
0.64999f, 0.34999f, 0.34999f, 0.64999f, 0.64999f, 0.1f, 0.2f, 0.3f, 0.4f, 0.1f, 0.2f,
0.3f, 0.4f, 0.1f, 0.2f, 0.3f, 0.4f, 0.1f, 0.2f, 0.3f, 0.4f},
{0.1f, 0.2f, 0.3f, 0.4f}),
};
return priorBoxClusteredParams;
}
std::vector<PriorBoxClusteredParams> generatePriorBoxClusteredCombinedParams() {
const std::vector<std::vector<PriorBoxClusteredParams>> priorBoxClusteredTypeParams {
generatePriorBoxClusteredFloatParams<element::Type_t::i64>(),
generatePriorBoxClusteredFloatParams<element::Type_t::i32>(),
generatePriorBoxClusteredFloatParams<element::Type_t::i16>(),
generatePriorBoxClusteredFloatParams<element::Type_t::i8>(),
generatePriorBoxClusteredFloatParams<element::Type_t::u64>(),
generatePriorBoxClusteredFloatParams<element::Type_t::u32>(),
generatePriorBoxClusteredFloatParams<element::Type_t::u16>(),
generatePriorBoxClusteredFloatParams<element::Type_t::u8>(),
};
std::vector<PriorBoxClusteredParams> combinedParams;
for (const auto& params : priorBoxClusteredTypeParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_PriorBoxClustered_With_Hardcoded_Refs, ReferencePriorBoxClusteredLayerTest,
testing::ValuesIn(generatePriorBoxClusteredCombinedParams()), ReferencePriorBoxClusteredLayerTest::getTestCaseName);
} // namespace

View File

@ -0,0 +1,123 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "openvino/op/reorg_yolo.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
using namespace ov;
namespace {
struct ReorgYoloParams {
template <class IT>
ReorgYoloParams(const ov::Strides& stride,
const ov::PartialShape& inputShape,
const ov::element::Type& iType,
const std::vector<IT>& oValues,
const std::string& testcaseName = "")
: stride(stride),
inputShape(inputShape),
inType(iType),
outType(iType),
refData(CreateTensor(iType, oValues)),
testcaseName(testcaseName) {
std::vector<IT> iValues(shape_size(inputShape.get_shape()));
std::iota(iValues.begin(), iValues.end(), 0);
inputData = CreateTensor(iType, iValues);
}
ov::Strides stride;
ov::PartialShape inputShape;
ov::element::Type inType;
ov::element::Type outType;
ov::runtime::Tensor inputData;
ov::runtime::Tensor refData;
std::string testcaseName;
};
class ReferenceReorgYoloLayerTest : public testing::TestWithParam<ReorgYoloParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params);
inputData = {params.inputData};
refOutData = {params.refData};
}
static std::string getTestCaseName(const testing::TestParamInfo<ReorgYoloParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "inputShape=" << param.inputShape << "_";
result << "iType=" << param.inType << "_";
result << "oType=" << param.outType << "_";
result << "stride=" << param.stride;
if (param.testcaseName != "")
result << "_" << param.testcaseName;
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(const ReorgYoloParams& params) {
const auto p = std::make_shared<op::v0::Parameter>(params.inType, params.inputShape);
const auto ReorgYolo = std::make_shared<op::v0::ReorgYolo>(p, params.stride);
return std::make_shared<ov::Function>(NodeVector {ReorgYolo}, ParameterVector {p});
}
};
TEST_P(ReferenceReorgYoloLayerTest, CompareWithRefs) {
Exec();
}
template <element::Type_t IN_ET>
std::vector<ReorgYoloParams> generateReorgYoloParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<ReorgYoloParams> reorgYoloParams {
ReorgYoloParams({2},
PartialShape {1, 8, 4, 4},
IN_ET,
std::vector<T>{0, 2, 4, 6, 16, 18, 20, 22, 32, 34, 36, 38, 48, 50, 52, 54, 64, 66, 68, 70, 80, 82,
84, 86, 96, 98, 100, 102, 112, 114, 116, 118, 1, 3, 5, 7, 17, 19, 21, 23, 33, 35, 37, 39,
49, 51, 53, 55, 65, 67, 69, 71, 81, 83, 85, 87, 97, 99, 101, 103, 113, 115, 117, 119, 8, 10,
12, 14, 24, 26, 28, 30, 40, 42, 44, 46, 56, 58, 60, 62, 72, 74, 76, 78, 88, 90, 92, 94,
104, 106, 108, 110, 120, 122, 124, 126, 9, 11, 13, 15, 25, 27, 29, 31, 41, 43, 45, 47, 57, 59,
61, 63, 73, 75, 77, 79, 89, 91, 93, 95, 105, 107, 109, 111, 121, 123, 125, 127}),
ReorgYoloParams({3},
PartialShape {1, 9, 3, 3},
IN_ET,
std::vector<T>{0, 3, 6, 27, 30, 33, 54, 57, 60, 1, 4, 7, 28, 31, 34, 55, 58, 61, 2, 5, 8, 29, 32, 35, 56, 59, 62,
9, 12, 15, 36, 39, 42, 63, 66, 69, 10, 13, 16, 37, 40, 43, 64, 67, 70, 11, 14, 17, 38, 41, 44, 65, 68, 71,
18, 21, 24, 45, 48, 51, 72, 75, 78, 19, 22, 25, 46, 49, 52, 73, 76, 79, 20, 23, 26, 47, 50, 53, 74, 77, 80}),
};
return reorgYoloParams;
}
std::vector<ReorgYoloParams> generateReorgYoloCombinedParams() {
const std::vector<std::vector<ReorgYoloParams>> reorgYoloTypeParams {
generateReorgYoloParams<element::Type_t::f64>(),
generateReorgYoloParams<element::Type_t::f32>(),
generateReorgYoloParams<element::Type_t::f16>(),
generateReorgYoloParams<element::Type_t::bf16>(),
generateReorgYoloParams<element::Type_t::i64>(),
generateReorgYoloParams<element::Type_t::i32>(),
generateReorgYoloParams<element::Type_t::i16>(),
generateReorgYoloParams<element::Type_t::i8>(),
generateReorgYoloParams<element::Type_t::u64>(),
generateReorgYoloParams<element::Type_t::u32>(),
generateReorgYoloParams<element::Type_t::u16>(),
generateReorgYoloParams<element::Type_t::u8>(),
};
std::vector<ReorgYoloParams> combinedParams;
for (const auto& params : reorgYoloTypeParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_ReorgYolo_With_Hardcoded_Refs, ReferenceReorgYoloLayerTest,
testing::ValuesIn(generateReorgYoloCombinedParams()), ReferenceReorgYoloLayerTest::getTestCaseName);
} // namespace

View File

@ -0,0 +1,304 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "openvino/op/rnn_cell.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
using namespace ov;
namespace {
struct RNNCellParams {
RNNCellParams(
int32_t batchSize, int32_t inputSize, int32_t hiddenSize,
const Tensor& X, const Tensor& H_t, const Tensor& W, const Tensor& R, const Tensor& B,
const Tensor& Ho, const std::string& testcaseName = "") :
batchSize(batchSize), inputSize(inputSize), hiddenSize(hiddenSize),
X(X), H_t(H_t), W(W), R(R), B(B), Ho(Ho), testcaseName(testcaseName) {}
int32_t batchSize;
int32_t inputSize;
int32_t hiddenSize;
Tensor X;
Tensor H_t;
Tensor W;
Tensor R;
Tensor B;
Tensor Ho;
std::string testcaseName;
};
class ReferenceRNNCellTest : public testing::TestWithParam<RNNCellParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params);
inputData = {params.X.data, params.H_t.data, params.W.data, params.R.data, params.B.data};
refOutData = {params.Ho.data};
}
static std::string getTestCaseName(const testing::TestParamInfo<RNNCellParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "bSize=" << param.batchSize;
result << "_iSize=" << param.inputSize;
result << "_hSize=" << param.hiddenSize;
result << "_xType=" << param.X.type;
result << "_xShape=" << param.X.shape;
result << "_htType=" << param.H_t.type;
result << "_htShape=" << param.H_t.shape;
result << "_wType=" << param.W.type;
result << "_wShape=" << param.W.shape;
result << "_rType=" << param.R.type;
result << "_rShape=" << param.R.shape;
result << "_hoType=" << param.Ho.type;
if (param.testcaseName != "") {
result << "_hoShape=" << param.Ho.shape;
result << "_=" << param.testcaseName;
} else {
result << "_hoShape=" << param.Ho.shape;
}
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(const RNNCellParams& params) {
const auto X = std::make_shared<op::v0::Parameter>(params.X.type, params.X.shape);
const auto H_t = std::make_shared<op::v0::Parameter>(params.H_t.type, params.H_t.shape);
const auto W = std::make_shared<op::v0::Parameter>(params.W.type, params.W.shape);
const auto R = std::make_shared<op::v0::Parameter>(params.R.type, params.R.shape);
const auto B = std::make_shared<op::v0::Parameter>(params.B.type, params.B.shape);
const auto rnn_cell = std::make_shared<op::v0::RNNCell>(X, H_t, W, R, B, params.hiddenSize);
auto function = std::make_shared<Function>(NodeVector{rnn_cell}, ParameterVector{X, H_t, W, R, B});
return function;
}
};
class ReferenceRNNCellTestBiasClip : public ReferenceRNNCellTest {
private:
static std::shared_ptr<Function> CreateFunction(const RNNCellParams& params) {
float clip = 2.88f;
const auto X = std::make_shared<op::v0::Parameter>(params.X.type, params.X.shape);
const auto H_t = std::make_shared<op::v0::Parameter>(params.H_t.type, params.H_t.shape);
const auto W = std::make_shared<op::v0::Parameter>(params.W.type, params.W.shape);
const auto R = std::make_shared<op::v0::Parameter>(params.R.type, params.R.shape);
const auto B = std::make_shared<op::v0::Parameter>(params.B.type, params.B.shape);
const auto rnn_cell = std::make_shared<op::v0::RNNCell>(
X, H_t, W, R, B, params.hiddenSize,
std::vector<std::string>{"tanh"}, std::vector<float>{}, std::vector<float>{}, clip);
auto function = std::make_shared<Function>(NodeVector{rnn_cell}, ParameterVector{X, H_t, W, R, B});
return function;
}
};
class ReferenceRNNCellTestSigmoidActivationFunction : public ReferenceRNNCellTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params);
inputData = {params.X.data, params.H_t.data, params.W.data, params.R.data, params.B.data};
refOutData = {params.Ho.data};
}
private:
static std::shared_ptr<Function> CreateFunction(const RNNCellParams& params) {
float clip = 2.88f;
const auto X = std::make_shared<op::v0::Parameter>(params.X.type, params.X.shape);
const auto H_t = std::make_shared<op::v0::Parameter>(params.H_t.type, params.H_t.shape);
const auto W = std::make_shared<op::v0::Parameter>(params.W.type, params.W.shape);
const auto R = std::make_shared<op::v0::Parameter>(params.R.type, params.R.shape);
const auto B = std::make_shared<op::v0::Parameter>(params.B.type, params.B.shape);
const auto rnn_cell = std::make_shared<op::v0::RNNCell>(X,
H_t,
W,
R,
B,
params.hiddenSize,
std::vector<std::string>{"sigmoid"},
std::vector<float>{},
std::vector<float>{},
clip);
auto function = std::make_shared<Function>(NodeVector{rnn_cell}, ParameterVector{X, H_t, W, R, B});
return function;
}
};
TEST_P(ReferenceRNNCellTest, CompareWithRefs) {
Exec();
}
TEST_P(ReferenceRNNCellTestBiasClip, CompareWithRefs) {
Exec();
}
TEST_P(ReferenceRNNCellTestSigmoidActivationFunction, CompareWithRefs) {
Exec();
}
template <element::Type_t ET>
std::vector<RNNCellParams> generateParams() {
using T = typename element_type_traits<ET>::value_type;
std::vector<RNNCellParams> params {
RNNCellParams(
2, 3, 3,
Tensor(ET, {2, 3}, std::vector<T>{
0.3432185f, 0.612268f, 0.20272376f, 0.9513413f, 0.30585995f, 0.7265472f}),
Tensor(ET, {2, 3}, std::vector<T>{
0.12444675f, 0.52055854f, 0.46489045f, 0.4983964f, 0.7730452f, 0.28439692f}),
Tensor(ET, {3, 3}, std::vector<T>{0.41930267f,
0.7872176f,
0.89940447f,
0.23659843f,
0.24676207f,
0.17101714f,
0.3147149f,
0.6555601f,
0.4559603f}),
Tensor(ET, {3, 3}, std::vector<T>{0.8374871f,
0.86660194f,
0.82114047f,
0.71549815f,
0.18775631f,
0.3182116f,
0.25392973f,
0.38301638f,
0.85531586f}),
Tensor(ET, {3}, std::vector<T>{0.0f, 0.0f, 0.0f}),
Tensor(ET, {2, 3}, std::vector<T>{0.9408395f, 0.53823817f, 0.84270686f, 0.98932856f, 0.768665f, 0.90461975f}),
"rnn_cell_zero_bias_default_attrs"),
};
return params;
}
std::vector<RNNCellParams> generateCombinedParams() {
const std::vector<std::vector<RNNCellParams>> generatedParams {
generateParams<element::Type_t::bf16>(),
generateParams<element::Type_t::f16>(),
generateParams<element::Type_t::f32>(),
generateParams<element::Type_t::f64>(),
};
std::vector<RNNCellParams> combinedParams;
for (const auto& params : generatedParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
template <element::Type_t ET>
std::vector<RNNCellParams> generateParamsBiasClip() {
using T = typename element_type_traits<ET>::value_type;
std::vector<RNNCellParams> params {
RNNCellParams(
2, 3, 3,
Tensor(ET, {2, 3}, std::vector<T>{
0.3432185f, 0.612268f, 0.20272376f, 0.9513413f, 0.30585995f, 0.7265472f}),
Tensor(ET, {2, 3}, std::vector<T>{
0.12444675f, 0.52055854f, 0.46489045f, 0.4983964f, 0.7730452f, 0.28439692f}),
Tensor(ET, {3, 3}, std::vector<T>{0.41930267f,
0.7872176f,
0.89940447f,
0.23659843f,
0.24676207f,
0.17101714f,
0.3147149f,
0.6555601f,
0.4559603f}),
Tensor(ET, {3, 3}, std::vector<T>{0.8374871f,
0.86660194f,
0.82114047f,
0.71549815f,
0.18775631f,
0.3182116f,
0.25392973f,
0.38301638f,
0.85531586f}),
Tensor(ET, {3}, std::vector<T>{1.0289404f, 1.6362579f, 0.4370661f}),
Tensor(ET, {2, 3}, std::vector<T>{0.9922437f, 0.97749525f, 0.9312212f, 0.9937176f, 0.9901317f, 0.95906746f}),
"rnn_cell_bias_clip"),
};
return params;
}
std::vector<RNNCellParams> generateCombinedParamsBiasClip() {
const std::vector<std::vector<RNNCellParams>> generatedParams {
generateParamsBiasClip<element::Type_t::bf16>(),
generateParamsBiasClip<element::Type_t::f16>(),
generateParamsBiasClip<element::Type_t::f32>(),
generateParamsBiasClip<element::Type_t::f64>(),
};
std::vector<RNNCellParams> combinedParams;
for (const auto& params : generatedParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
template <element::Type_t ET>
std::vector<RNNCellParams> generateParamsSigmoidActivationFunction() {
using T = typename element_type_traits<ET>::value_type;
std::vector<RNNCellParams> params {
RNNCellParams(
2, 3, 3,
Tensor(ET, {2, 3}, std::vector<T>{
0.3432185f, 0.612268f, 0.20272376f, 0.9513413f, 0.30585995f, 0.7265472f}),
Tensor(ET, {2, 3}, std::vector<T>{
0.12444675f, 0.52055854f, 0.46489045f, 0.4983964f, 0.7730452f, 0.28439692f}),
Tensor(ET, {3, 3}, std::vector<T>{0.41930267f,
0.7872176f,
0.89940447f,
0.23659843f,
0.24676207f,
0.17101714f,
0.3147149f,
0.6555601f,
0.4559603f}),
Tensor(ET, {3, 3}, std::vector<T>{0.8374871f,
0.86660194f,
0.82114047f,
0.71549815f,
0.18775631f,
0.3182116f,
0.25392973f,
0.38301638f,
0.85531586f}),
Tensor(ET, {3}, std::vector<T>{1.0289404f, 1.6362579f, 0.4370661f}),
Tensor(ET, {2, 3}, std::vector<T>{0.94126844f, 0.9036043f, 0.841243f, 0.9468489f, 0.934215f, 0.873708f}),
"rnn_cell_sigmoid_activation_function"),
};
return params;
}
std::vector<RNNCellParams> generateCombinedParamsSigmoidActivationFunction() {
const std::vector<std::vector<RNNCellParams>> generatedParams {
generateParamsSigmoidActivationFunction<element::Type_t::bf16>(),
generateParamsSigmoidActivationFunction<element::Type_t::f16>(),
generateParamsSigmoidActivationFunction<element::Type_t::f32>(),
generateParamsSigmoidActivationFunction<element::Type_t::f64>(),
};
std::vector<RNNCellParams> combinedParams;
for (const auto& params : generatedParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_RNNCell_With_Hardcoded_Refs, ReferenceRNNCellTest,
testing::ValuesIn(generateCombinedParams()), ReferenceRNNCellTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_RNNCell_With_Hardcoded_Refs, ReferenceRNNCellTestBiasClip,
testing::ValuesIn(generateCombinedParamsBiasClip()), ReferenceRNNCellTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_RNNCell_With_Hardcoded_Refs, ReferenceRNNCellTestSigmoidActivationFunction,
testing::ValuesIn(generateCombinedParamsSigmoidActivationFunction()), ReferenceRNNCellTest::getTestCaseName);
} // namespace

View File

@ -0,0 +1,212 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "openvino/opsets/opset1.hpp"
#include "openvino/opsets/opset7.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
using namespace ov;
namespace {
struct RollParams {
RollParams(const Tensor& dataTensor, const Tensor& shiftTensor, const Tensor& axesTensor,
const Tensor& expectedTensor, const std::string& testcaseName = "") :
dataTensor(dataTensor), shiftTensor(shiftTensor), axesTensor(axesTensor),
expectedTensor(expectedTensor), testcaseName(testcaseName) {}
Tensor dataTensor;
Tensor shiftTensor;
Tensor axesTensor;
Tensor expectedTensor;
std::string testcaseName;
};
class ReferenceRollLayerTest : public testing::TestWithParam<RollParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params);
inputData = {params.dataTensor.data};
refOutData = {params.expectedTensor.data};
}
static std::string getTestCaseName(const testing::TestParamInfo<RollParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "dType=" << param.dataTensor.type;
result << "_dShape=" << param.dataTensor.shape;
result << "_sType=" << param.shiftTensor.type;
result << "_sShape=" << param.shiftTensor.shape;
result << "_aType=" << param.axesTensor.type;
result << "_aShape=" << param.axesTensor.shape;
result << "_eType=" << param.expectedTensor.type;
if (param.testcaseName != "") {
result << "_eShape=" << param.expectedTensor.shape;
result << "_=" << param.testcaseName;
} else {
result << "_eShape=" << param.expectedTensor.shape;
}
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(const RollParams& params) {
const auto data = std::make_shared<opset1::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto shift = std::make_shared<opset1::Constant>(params.shiftTensor.type,
params.shiftTensor.shape,
params.shiftTensor.data.data());
const auto axes = std::make_shared<opset1::Constant>(params.axesTensor.type,
params.axesTensor.shape,
params.axesTensor.data.data());
const auto roll = std::make_shared<opset7::Roll>(data, shift, axes);
return std::make_shared<Function>(NodeVector {roll}, ParameterVector {data});
}
};
TEST_P(ReferenceRollLayerTest, CompareWithRefs) {
Exec();
}
template <element::Type_t IN_ET>
std::vector<RollParams> generateRollParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<RollParams> rollParams {
// roll_repeated_axes
RollParams(
Tensor({4, 3}, IN_ET, std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}),
Tensor({3}, element::i64, std::vector<int64_t>{1, 2, 1}),
Tensor({3}, element::i64, std::vector<int64_t>{0, 1, 0}),
Tensor({4, 3}, IN_ET, std::vector<T>{8, 9, 7, 11, 12, 10, 2, 3, 1, 5, 6, 4}),
"roll_repeated_axes"),
// roll_negative_axes
RollParams(
Tensor({4, 2, 3}, IN_ET, 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}),
Tensor({3}, element::i64, std::vector<int64_t>{2, -1, -7}),
Tensor({3}, element::i64, std::vector<int64_t>{-1, -1, -2}),
Tensor({4, 2, 3}, IN_ET, std::vector<T>{6, 4, 5, 3, 1, 2, 12, 10, 11, 9, 7, 8, 18, 16, 17, 15, 13, 14, 24, 22, 23, 21, 19, 20}),
"roll_negative_axes"),
};
return rollParams;
}
std::vector<RollParams> generateRollFloatingPointParams() {
std::vector<RollParams> rollParams {
// roll_2d_input
RollParams(
Tensor({4, 3}, element::f32, std::vector<float>{50.2907,
70.8054,
-68.3403,
62.6444,
4.9748,
-18.5551,
40.5383,
-15.3859,
-4.5881,
-43.3479,
94.1676,
-95.7097}),
Tensor({1}, element::i64, std::vector<int64_t>{1}),
Tensor({1}, element::i64, std::vector<int64_t>{0}),
Tensor({4, 3}, element::f32, std::vector<float>{-43.3479,
94.1676,
-95.7097,
50.2907,
70.8054,
-68.3403,
62.6444,
4.9748,
-18.5551,
40.5383,
-15.3859,
-4.5881}),
"roll_2d_input"),
// roll_2d_input_negative_shift
RollParams(
Tensor({4, 3}, element::f32, std::vector<float>{50.2907,
70.8054,
-68.3403,
62.6444,
4.9748,
-18.5551,
40.5383,
-15.3859,
-4.5881,
-43.3479,
94.1676,
-95.7097}),
Tensor({2}, element::i64, std::vector<int64_t>{-1, 2}),
Tensor({2}, element::i64, std::vector<int64_t>{0, 1}),
Tensor({4, 3}, element::f32, std::vector<float>{4.9748,
-18.5551,
62.6444,
-15.3859,
-4.5881,
40.5383,
94.1676,
-95.7097,
-43.3479,
70.8054,
-68.3403,
50.2907}),
"roll_2d_input_negative_shift"),
// roll_3d_input
RollParams(
Tensor({4, 2, 3}, element::f32, std::vector<float>{94.0773, 33.0599, 58.1724, -20.3640, 54.5372, -54.3023, 10.4662, 11.7532,
-11.7692, 56.4223, -95.3774, 8.8978, 1.9305, 13.8025, 12.0827, 81.4669,
19.5321, -8.9553, -75.3226, 20.8033, 20.7660, 62.7361, 14.9372, -33.0825}),
Tensor({3}, element::i64, std::vector<int64_t>{2, 1, 3}),
Tensor({3}, element::i64, std::vector<int64_t>{0, 1, 2}),
Tensor({4, 2, 3}, element::f32, std::vector<float>{81.4669, 19.5321, -8.9553, 1.9305, 13.8025, 12.0827, 62.7361, 14.9372,
-33.0825, -75.3226, 20.8033, 20.7660, -20.3640, 54.5372, -54.3023, 94.0773,
33.0599, 58.1724, 56.4223, -95.3774, 8.8978, 10.4662, 11.7532, -11.7692}),
"roll_3d_input"),
// roll_3d_input_negative_shift
RollParams(
Tensor({4, 2, 3}, element::f32, std::vector<float>{94.0773, 33.0599, 58.1724, -20.3640, 54.5372, -54.3023, 10.4662, 11.7532,
-11.7692, 56.4223, -95.3774, 8.8978, 1.9305, 13.8025, 12.0827, 81.4669,
19.5321, -8.9553, -75.3226, 20.8033, 20.7660, 62.7361, 14.9372, -33.0825}),
Tensor({3}, element::i64, std::vector<int64_t>{-5, 1, 3}),
Tensor({3}, element::i64, std::vector<int64_t>{0, 1, 1}),
Tensor({4, 2, 3}, element::f32, std::vector<float>{10.4662, 11.7532, -11.7692, 56.4223, -95.3774, 8.8978, 1.9305, 13.8025,
12.0827, 81.4669, 19.5321, -8.9553, -75.3226, 20.8033, 20.7660, 62.7361,
14.9372, -33.0825, 94.0773, 33.0599, 58.1724, -20.3640, 54.5372, -54.3023}),
"roll_3d_input_negative_shift"),
};
return rollParams;
}
std::vector<RollParams> generateRollCombinedParams() {
const std::vector<std::vector<RollParams>> rollTypeParams {
generateRollParams<element::Type_t::i8>(),
generateRollParams<element::Type_t::i16>(),
generateRollParams<element::Type_t::i32>(),
generateRollParams<element::Type_t::i64>(),
generateRollParams<element::Type_t::u8>(),
generateRollParams<element::Type_t::u16>(),
generateRollParams<element::Type_t::u32>(),
generateRollParams<element::Type_t::u64>(),
generateRollParams<element::Type_t::bf16>(),
generateRollParams<element::Type_t::f16>(),
generateRollParams<element::Type_t::f32>(),
generateRollParams<element::Type_t::f64>(),
generateRollFloatingPointParams(),
};
std::vector<RollParams> combinedParams;
for (const auto& params : rollTypeParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_Roll_With_Hardcoded_Refs, ReferenceRollLayerTest,
testing::ValuesIn(generateRollCombinedParams()), ReferenceRollLayerTest::getTestCaseName);
} // namespace

View File

@ -0,0 +1,209 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "openvino/opsets/opset1.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
using namespace ov;
namespace {
struct ShuffleChannelsParams {
ShuffleChannelsParams(const Tensor& dataTensor, const int32_t axis, const int32_t group,
const Tensor& expectedTensor, const std::string& testcaseName = "") :
dataTensor(dataTensor), axis(axis), group(group),
expectedTensor(expectedTensor), testcaseName(testcaseName) {}
Tensor dataTensor;
int32_t axis;
int32_t group;
Tensor expectedTensor;
std::string testcaseName;
};
class ReferenceShuffleChannelsLayerTest : public testing::TestWithParam<ShuffleChannelsParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params);
inputData = {params.dataTensor.data};
refOutData = {params.expectedTensor.data};
}
static std::string getTestCaseName(const testing::TestParamInfo<ShuffleChannelsParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "dType=" << param.dataTensor.type;
result << "_dShape=" << param.dataTensor.shape;
result << "_axis=" << param.axis;
result << "_group=" << param.group;
result << "_eType=" << param.expectedTensor.type;
if (param.testcaseName != "") {
result << "_eShape=" << param.expectedTensor.shape;
result << "_=" << param.testcaseName;
} else {
result << "_eShape=" << param.expectedTensor.shape;
}
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(const ShuffleChannelsParams& params) {
const auto data = std::make_shared<opset1::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto function = std::make_shared<opset1::ShuffleChannels>(data, params.axis, params.group);
return std::make_shared<Function>(NodeVector {function}, ParameterVector {data});
}
};
TEST_P(ReferenceShuffleChannelsLayerTest, CompareWithRefs) {
Exec();
}
template <element::Type_t IN_ET>
std::vector<ShuffleChannelsParams> generateParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<ShuffleChannelsParams> params {
// shuffle_channels_simple
ShuffleChannelsParams(
Tensor({1, 15, 2, 2}, IN_ET, std::vector<T>{
0, 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, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59}),
1,
5,
Tensor({1, 15, 2, 2}, IN_ET, std::vector<T>{
0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51,
4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55,
8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59}),
"shuffle_channels_simple"),
// shuffle_channels_negative_axis
ShuffleChannelsParams(
Tensor({15, 2, 1, 2}, IN_ET, std::vector<T>{
0, 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, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59}),
-4,
5,
Tensor({15, 2, 1, 2}, IN_ET, std::vector<T>{
0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51,
4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55,
8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59}),
"shuffle_channels_negative_axis"),
// shuffle_channels_float
ShuffleChannelsParams(
Tensor({6, 1, 1, 1}, IN_ET, std::vector<T>{0, 1, 2, 3, 4, 5}),
0,
2,
Tensor({6, 1, 1, 1}, IN_ET, std::vector<T>{0, 3, 1, 4, 2, 5}),
"shuffle_channels_float"),
// shuffle_channels_1d
ShuffleChannelsParams(
Tensor({15}, IN_ET, std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}),
0,
5,
Tensor({15}, IN_ET, std::vector<T>{0, 3, 6, 9, 12, 1, 4, 7, 10, 13, 2, 5, 8, 11, 14}),
"shuffle_channels_1d"),
// shuffle_channels_2d
ShuffleChannelsParams(
Tensor({15, 4}, IN_ET, std::vector<T>{
0, 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, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59}),
0,
5,
Tensor({15, 4}, IN_ET, std::vector<T>{
0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38,
39, 48, 49, 50, 51, 4, 5, 6, 7, 16, 17, 18, 19, 28, 29,
30, 31, 40, 41, 42, 43, 52, 53, 54, 55, 8, 9, 10, 11, 20,
21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59}),
"shuffle_channels_2d"),
// shuffle_channels_3d
ShuffleChannelsParams(
Tensor({15, 2, 2}, IN_ET, std::vector<T>{
0, 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, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59}),
0,
5,
Tensor({15, 2, 2}, IN_ET, std::vector<T>{
0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38,
39, 48, 49, 50, 51, 4, 5, 6, 7, 16, 17, 18, 19, 28, 29,
30, 31, 40, 41, 42, 43, 52, 53, 54, 55, 8, 9, 10, 11, 20,
21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59}),
"shuffle_channels_3d"),
// shuffle_channels_5d
ShuffleChannelsParams(
Tensor({2, 2, 15, 2, 2}, IN_ET, std::vector<T>{
0, 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, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
0, 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, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
0, 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, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
0, 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, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59}),
2,
5,
Tensor({2, 2, 15, 2, 2}, IN_ET, std::vector<T>{
0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51,
4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55,
8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59,
0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51,
4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55,
8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59,
0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51,
4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55,
8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59,
0, 1, 2, 3, 12, 13, 14, 15, 24, 25, 26, 27, 36, 37, 38, 39, 48, 49, 50, 51,
4, 5, 6, 7, 16, 17, 18, 19, 28, 29, 30, 31, 40, 41, 42, 43, 52, 53, 54, 55,
8, 9, 10, 11, 20, 21, 22, 23, 32, 33, 34, 35, 44, 45, 46, 47, 56, 57, 58, 59}),
"shuffle_channels_5d"),
};
return params;
}
std::vector<ShuffleChannelsParams> generateShuffleChannelsCombinedParams() {
const std::vector<std::vector<ShuffleChannelsParams>> generatedParams {
generateParams<element::Type_t::i8>(),
generateParams<element::Type_t::i16>(),
generateParams<element::Type_t::i32>(),
generateParams<element::Type_t::i64>(),
generateParams<element::Type_t::u8>(),
generateParams<element::Type_t::u16>(),
generateParams<element::Type_t::u32>(),
generateParams<element::Type_t::u64>(),
generateParams<element::Type_t::bf16>(),
generateParams<element::Type_t::f16>(),
generateParams<element::Type_t::f32>(),
generateParams<element::Type_t::f64>(),
};
std::vector<ShuffleChannelsParams> combinedParams;
for (const auto& params : generatedParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannels_With_Hardcoded_Refs, ReferenceShuffleChannelsLayerTest,
testing::ValuesIn(generateShuffleChannelsCombinedParams()), ReferenceShuffleChannelsLayerTest::getTestCaseName);
} // namespace

View File

@ -0,0 +1,143 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "openvino/opsets/opset1.hpp"
#include "openvino/opsets/opset2.hpp"
#include "openvino/op/constant.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
using namespace ov;
namespace {
struct SpaceToBatchParams {
SpaceToBatchParams(const Tensor& dataTensor, const Tensor& blockShapeTensor,
const Tensor& padsBeginTensor, const Tensor& padsEndTensor,
const Tensor& expectedTensor, const std::string& testcaseName = "") :
dataTensor(dataTensor), blockShapeTensor(blockShapeTensor),
padsBeginTensor(padsBeginTensor), padsEndTensor(padsEndTensor),
expectedTensor(expectedTensor), testcaseName(testcaseName) {}
Tensor dataTensor;
Tensor blockShapeTensor;
Tensor padsBeginTensor;
Tensor padsEndTensor;
Tensor expectedTensor;
std::string testcaseName;
};
class ReferenceSpaceToBatchLayerTest : public testing::TestWithParam<SpaceToBatchParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params);
inputData = {params.dataTensor.data};
refOutData = {params.expectedTensor.data};
}
static std::string getTestCaseName(const testing::TestParamInfo<SpaceToBatchParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "dType=" << param.dataTensor.type;
result << "_dShape=" << param.dataTensor.shape;
result << "_bsType=" << param.blockShapeTensor.type;
result << "_bsShape=" << param.blockShapeTensor.shape;
result << "_pbType=" << param.padsBeginTensor.type;
result << "_pbShape=" << param.padsBeginTensor.shape;
result << "_peType=" << param.padsEndTensor.type;
result << "_peShape=" << param.padsEndTensor.shape;
result << "_eType=" << param.expectedTensor.type;
if (param.testcaseName != "") {
result << "_eShape=" << param.expectedTensor.shape;
result << "_" << param.testcaseName;
} else {
result << "_eShape=" << param.expectedTensor.shape;
}
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(const SpaceToBatchParams& params) {
const auto data = std::make_shared<opset1::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto blockShape = std::make_shared<opset1::Constant>(element::i64, params.blockShapeTensor.shape, params.blockShapeTensor.data.data());
const auto padsBegin = std::make_shared<opset1::Constant>(element::i64, params.padsBeginTensor.shape, params.padsBeginTensor.data.data());
const auto padsEnd = std::make_shared<opset1::Constant>(element::i64, params.padsEndTensor.shape, params.padsEndTensor.data.data());
const auto batchToSpace = std::make_shared<opset2::SpaceToBatch>(data, blockShape, padsBegin, padsEnd);
return std::make_shared<ov::Function>(NodeVector {batchToSpace}, ParameterVector {data});
}
};
TEST_P(ReferenceSpaceToBatchLayerTest, CompareWithRefs) {
Exec();
}
template <element::Type_t IN_ET>
std::vector<SpaceToBatchParams> generateParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<SpaceToBatchParams> batchToSpaceParams {
// space_to_batch_4D
SpaceToBatchParams(
Tensor({1, 1, 2, 2}, IN_ET, std::vector<T>{1, 1, 1, 1}),
Tensor({4}, element::i64, std::vector<int64_t>{1, 1, 1, 1}),
Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 0}),
Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 0}),
Tensor({1, 1, 2, 2}, IN_ET, std::vector<T>{1, 1, 1, 1}),
"space_to_batch_4D"),
// space_to_batch_5D
SpaceToBatchParams(
Tensor({1, 1, 3, 2, 1}, IN_ET, std::vector<T>{1, 1, 1, 1, 1, 1}),
Tensor({5}, element::i64, std::vector<int64_t>{1, 1, 3, 2, 2}),
Tensor({5}, element::i64, std::vector<int64_t>{0, 0, 1, 0, 3}),
Tensor({5}, element::i64, std::vector<int64_t>{0, 0, 2, 0, 0}),
Tensor({12, 1, 2, 1, 2}, IN_ET, std::vector<T>{
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0}),
"space_to_batch_5D"),
// space_to_batch_4x4
SpaceToBatchParams(
Tensor({1, 1, 4, 4}, IN_ET, std::vector<T>{
1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}),
Tensor({4}, element::i64, std::vector<int64_t>{1, 1, 1, 1}),
Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 1, 0}),
Tensor({4}, element::i64, std::vector<int64_t>{0, 0, 0, 0}),
Tensor({1, 1, 5, 4}, IN_ET, std::vector<T>{
0, 0, 0, 0, 1, 0, 0, 0, 0, 1,
0, 0, 0, 0, 1, 0, 0, 0, 0, 1}),
"space_to_batch_4x4"),
};
return batchToSpaceParams;
}
std::vector<SpaceToBatchParams> generateCombinedParams() {
const std::vector<std::vector<SpaceToBatchParams>> batchToSpaceTypeParams {
generateParams<element::Type_t::i8>(),
generateParams<element::Type_t::i16>(),
generateParams<element::Type_t::i32>(),
generateParams<element::Type_t::i64>(),
generateParams<element::Type_t::u8>(),
generateParams<element::Type_t::u16>(),
generateParams<element::Type_t::u32>(),
generateParams<element::Type_t::u64>(),
generateParams<element::Type_t::bf16>(),
generateParams<element::Type_t::f16>(),
generateParams<element::Type_t::f32>(),
generateParams<element::Type_t::f64>(),
};
std::vector<SpaceToBatchParams> combinedParams;
for (const auto& params : batchToSpaceTypeParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_SpaceToBatch_With_Hardcoded_Refs, ReferenceSpaceToBatchLayerTest,
testing::ValuesIn(generateCombinedParams()), ReferenceSpaceToBatchLayerTest::getTestCaseName);
} // namespace

View File

@ -0,0 +1,169 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "openvino/opsets/opset1.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
using namespace ov;
namespace {
struct SpaceToDepthParams {
SpaceToDepthParams(const Tensor& dataTensor, const std::string mode, const int32_t blockSize,
const Tensor& expectedTensor, const std::string& testcaseName = "") :
dataTensor(dataTensor), mode(mode), blockSize(blockSize), expectedTensor(expectedTensor),
testcaseName(testcaseName) {}
Tensor dataTensor;
std::string mode;
int32_t blockSize;
Tensor expectedTensor;
std::string testcaseName;
};
class ReferenceSpaceToDepthLayerTest : public testing::TestWithParam<SpaceToDepthParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params);
inputData = {params.dataTensor.data};
refOutData = {params.expectedTensor.data};
}
static std::string getTestCaseName(const testing::TestParamInfo<SpaceToDepthParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "dType=" << param.dataTensor.type;
result << "_dShape=" << param.dataTensor.shape;
result << "_eType=" << param.expectedTensor.type;
if (param.testcaseName != "") {
result << "_eShape=" << param.expectedTensor.shape;
result << "_" << param.testcaseName;
} else {
result << "_eShape=" << param.expectedTensor.shape;
}
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(const SpaceToDepthParams& params) {
opset1::SpaceToDepth::SpaceToDepthMode mode = params.mode == "DEPTH_FIRST" ?
opset1::SpaceToDepth::SpaceToDepthMode::DEPTH_FIRST : opset1::SpaceToDepth::SpaceToDepthMode::BLOCKS_FIRST;
const auto data = std::make_shared<opset1::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto SpaceToDepth = std::make_shared<opset1::SpaceToDepth>(data, mode, params.blockSize);
return std::make_shared<Function>(NodeVector {SpaceToDepth}, ParameterVector {data});
}
};
TEST_P(ReferenceSpaceToDepthLayerTest, CompareWithRefs) {
Exec();
}
template <element::Type_t IN_ET>
std::vector<SpaceToDepthParams> generateParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<SpaceToDepthParams> params {
// space_to_depth_block_first_K2_BS2
SpaceToDepthParams(
Tensor({1, 2, 4, 4}, IN_ET, std::vector<T>{
0, 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}),
"BLOCKS_FIRST",
2,
Tensor({1, 8, 2, 2}, IN_ET, std::vector<T>{
0, 2, 8, 10, 16, 18, 24, 26, 1, 3, 9, 11, 17, 19, 25, 27,
4, 6, 12, 14, 20, 22, 28, 30, 5, 7, 13, 15, 21, 23, 29, 31}),
"space_to_depth_block_first_K2_BS2"),
// space_to_depth_block_first_K2_BS3
SpaceToDepthParams(
Tensor({1, 2, 6, 3}, IN_ET, std::vector<T>{
0, 4, 8, 12, 16, 20, 24, 28, 32, 1, 5, 9,
13, 17, 21, 25, 29, 33, 2, 6, 10, 14, 18, 22,
26, 30, 34, 3, 7, 11, 15, 19, 23, 27, 31, 35}),
"BLOCKS_FIRST",
3,
Tensor({1, 18, 2, 1}, IN_ET, std::vector<T>{
0, 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}),
"space_to_depth_block_first_K2_BS3"),
// space_to_depth_block_first_K1_BS3
SpaceToDepthParams(
Tensor({1, 2, 6}, IN_ET, std::vector<T>{
0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11}),
"BLOCKS_FIRST",
3,
Tensor({1, 6, 2}, IN_ET, std::vector<T>{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}),
"space_to_depth_block_first_K1_BS3"),
// space_to_depth_depth_first_K2_BS2
SpaceToDepthParams(
Tensor({1, 2, 4, 4}, IN_ET, std::vector<T>{
0, 16, 2, 18, 1, 17, 3, 19, 8, 24, 10,
26, 9, 25, 11, 27, 4, 20, 6, 22, 5, 21,
7, 23, 12, 28, 14, 30, 13, 29, 15, 31}),
"DEPTH_FIRST",
2,
Tensor({1, 8, 2, 2}, IN_ET, std::vector<T>{
0, 2, 8, 10, 16, 18, 24, 26, 1, 3, 9, 11, 17, 19, 25, 27,
4, 6, 12, 14, 20, 22, 28, 30, 5, 7, 13, 15, 21, 23, 29, 31}),
"space_to_depth_depth_first_K2_BS2"),
// space_to_depth_depth_first_K2_BS3
SpaceToDepthParams(
Tensor({1, 2, 6, 3}, IN_ET, std::vector<T>{
0, 2, 4, 6, 8, 10, 12, 14, 16, 1, 3, 5,
7, 9, 11, 13, 15, 17, 18, 20, 22, 24, 26, 28,
30, 32, 34, 19, 21, 23, 25, 27, 29, 31, 33, 35}),
"DEPTH_FIRST",
3,
Tensor({1, 18, 2, 1}, IN_ET, std::vector<T>{
0, 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}),
"space_to_depth_depth_first_K2_BS3"),
// space_to_depth_depth_first_K1_BS3
SpaceToDepthParams(
Tensor({1, 2, 6}, IN_ET, std::vector<T>{
0, 2, 4, 1, 3, 5, 6, 8, 10, 7, 9, 11}),
"DEPTH_FIRST",
3,
Tensor({1, 6, 2}, IN_ET, std::vector<T>{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}),
"space_to_depth_depth_first_K1_BS3"),
};
return params;
}
std::vector<SpaceToDepthParams> generateCombinedParams() {
const std::vector<std::vector<SpaceToDepthParams>> generatedParams {
generateParams<element::Type_t::i8>(),
generateParams<element::Type_t::i16>(),
generateParams<element::Type_t::i32>(),
generateParams<element::Type_t::i64>(),
generateParams<element::Type_t::u8>(),
generateParams<element::Type_t::u16>(),
generateParams<element::Type_t::u32>(),
generateParams<element::Type_t::u64>(),
generateParams<element::Type_t::bf16>(),
generateParams<element::Type_t::f16>(),
generateParams<element::Type_t::f32>(),
generateParams<element::Type_t::f64>(),
};
std::vector<SpaceToDepthParams> combinedParams;
for (const auto& params : generatedParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_SpaceToDepth_With_Hardcoded_Refs, ReferenceSpaceToDepthLayerTest,
testing::ValuesIn(generateCombinedParams()), ReferenceSpaceToDepthLayerTest::getTestCaseName);
} // namespace

View File

@ -0,0 +1,424 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include "openvino/op/strided_slice.hpp"
#include "openvino/op/constant.hpp"
#include "base_reference_test.hpp"
using namespace reference_tests;
using namespace ov;
namespace {
struct StridedSliceParams {
StridedSliceParams(const PartialShape& dynamicDataShape,
const Tensor& dataTensor,
const Tensor& beginTensor,
const Tensor& endTensor,
const Tensor& stridesTensor,
const std::vector<int64_t>& beginMask,
const std::vector<int64_t>& endMask,
const std::vector<int64_t>& newAxisMask,
const std::vector<int64_t>& shrinkAxisMask,
const std::vector<int64_t>& ellipsisMask,
const Tensor& expectedTensor,
const std::string& testcaseName = "") :
dynamicDataShape(dynamicDataShape), dataTensor(dataTensor),
beginTensor(beginTensor), endTensor(endTensor),
stridesTensor(stridesTensor), beginMask(beginMask), endMask(endMask),
newAxisMask(newAxisMask), shrinkAxisMask(shrinkAxisMask), ellipsisMask(ellipsisMask),
expectedTensor(expectedTensor), testcaseName(testcaseName) {}
PartialShape dynamicDataShape;
Tensor dataTensor;
Tensor beginTensor;
Tensor endTensor;
Tensor stridesTensor;
std::vector<int64_t> beginMask;
std::vector<int64_t> endMask;
std::vector<int64_t> newAxisMask;
std::vector<int64_t> shrinkAxisMask;
std::vector<int64_t> ellipsisMask;
Tensor expectedTensor;
std::string testcaseName;
};
struct StridedSliceStrideOptionalParams {
StridedSliceStrideOptionalParams(const PartialShape& dynamicDataShape,
const Tensor& dataTensor,
const Tensor& beginTensor,
const Tensor& endTensor,
const std::vector<int64_t>& beginMask,
const std::vector<int64_t>& endMask,
const std::vector<int64_t>& newAxisMask,
const std::vector<int64_t>& shrinkAxisMask,
const std::vector<int64_t>& ellipsisMask,
const Tensor& expectedTensor,
const std::string& testcaseName = "") :
dynamicDataShape(dynamicDataShape), dataTensor(dataTensor),
beginTensor(beginTensor), endTensor(endTensor),
beginMask(beginMask), endMask(endMask),
newAxisMask(newAxisMask), shrinkAxisMask(shrinkAxisMask), ellipsisMask(ellipsisMask),
expectedTensor(expectedTensor), testcaseName(testcaseName) {}
PartialShape dynamicDataShape;
Tensor dataTensor;
Tensor beginTensor;
Tensor endTensor;
std::vector<int64_t> beginMask;
std::vector<int64_t> endMask;
std::vector<int64_t> newAxisMask;
std::vector<int64_t> shrinkAxisMask;
std::vector<int64_t> ellipsisMask;
Tensor expectedTensor;
std::string testcaseName;
};
class ReferenceStridedSliceLayerTest : public testing::TestWithParam<StridedSliceParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params);
if (params.dynamicDataShape.is_static()) {
inputData = {params.dataTensor.data};
} else {
inputData = {params.dataTensor.data, params.beginTensor.data, params.endTensor.data, params.stridesTensor.data};
}
refOutData = {params.expectedTensor.data};
}
static std::string getTestCaseName(const testing::TestParamInfo<StridedSliceParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "ddShape=" << param.dynamicDataShape;
result << "_dType=" << param.dataTensor.type;
result << "_dShape=" << param.dataTensor.shape;
result << "_bType=" << param.beginTensor.type;
result << "_bShape=" << param.beginTensor.shape;
result << "_eType=" << param.endTensor.type;
result << "_eShape=" << param.endTensor.shape;
result << "_sType=" << param.stridesTensor.type;
result << "_sShape=" << param.stridesTensor.shape;
result << "_eType=" << param.expectedTensor.type;
if (param.testcaseName != "") {
result << "_eShape=" << param.expectedTensor.shape;
result << "_" << param.testcaseName;
} else {
result << "_eShape=" << param.expectedTensor.shape;
}
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(const StridedSliceParams& params) {
std::shared_ptr<Function> function;
if (params.dynamicDataShape.is_static()) {
const auto data = std::make_shared<op::v0::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto beginOp = std::make_shared<op::v0::Constant>(params.beginTensor.type, params.beginTensor.shape,
params.beginTensor.data.data());
const auto endOp = std::make_shared<op::v0::Constant>(params.endTensor.type, params.endTensor.shape,
params.endTensor.data.data());
const auto stridesOp = std::make_shared<op::v0::Constant>(params.stridesTensor.type, params.stridesTensor.shape,
params.stridesTensor.data.data());
const auto StridedSlice = std::make_shared<op::v1::StridedSlice>(data, beginOp, endOp, stridesOp,
params.beginMask, params.endMask, params.newAxisMask,
params.shrinkAxisMask, params.ellipsisMask);
function = std::make_shared<ov::Function>(NodeVector{StridedSlice}, ParameterVector{data});
} else {
const auto data = std::make_shared<op::v0::Parameter>(params.dataTensor.type, PartialShape::dynamic());
const auto beginOp = std::make_shared<op::v0::Parameter>(params.beginTensor.type, params.beginTensor.shape);
const auto endOp = std::make_shared<op::v0::Parameter>(params.endTensor.type, params.endTensor.shape);
const auto stridesOp = std::make_shared<op::v0::Parameter>(params.stridesTensor.type, params.stridesTensor.shape);
const auto StridedSlice = std::make_shared<op::v1::StridedSlice>(data, beginOp, endOp, stridesOp,
params.beginMask, params.endMask, params.newAxisMask,
params.shrinkAxisMask, params.ellipsisMask);
function = std::make_shared<ov::Function>(NodeVector{StridedSlice}, ParameterVector{data, beginOp, endOp, stridesOp});
}
return function;
}
};
class ReferenceStridedSliceLayerTestStrideOptional : public testing::TestWithParam<StridedSliceStrideOptionalParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params);
if (params.dynamicDataShape.is_static()) {
inputData = {params.dataTensor.data};
} else {
inputData = {params.dataTensor.data, params.beginTensor.data, params.endTensor.data};
}
refOutData = {params.expectedTensor.data};
}
static std::string getTestCaseName(const testing::TestParamInfo<StridedSliceStrideOptionalParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "ddShape=" << param.dynamicDataShape;
result << "_dType=" << param.dataTensor.type;
result << "_dShape=" << param.dataTensor.shape;
result << "_bType=" << param.beginTensor.type;
result << "_bShape=" << param.beginTensor.shape;
result << "_eType=" << param.endTensor.type;
result << "_eShape=" << param.endTensor.shape;
result << "_eType=" << param.expectedTensor.type;
if (param.testcaseName != "") {
result << "_eShape=" << param.expectedTensor.shape;
result << "_" << param.testcaseName;
} else {
result << "_eShape=" << param.expectedTensor.shape;
}
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(const StridedSliceStrideOptionalParams& params) {
std::shared_ptr<Function> function;
if (params.dynamicDataShape.is_static()) {
const auto data = std::make_shared<op::v0::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto beginOp = std::make_shared<op::v0::Constant>(params.beginTensor.type, params.beginTensor.shape,
params.beginTensor.data.data());
const auto endOp = std::make_shared<op::v0::Constant>(params.endTensor.type, params.endTensor.shape,
params.endTensor.data.data());
const auto StridedSlice = std::make_shared<op::v1::StridedSlice>(data, beginOp, endOp,
params.beginMask, params.endMask, params.newAxisMask,
params.shrinkAxisMask, params.ellipsisMask);
function = std::make_shared<ov::Function>(NodeVector{StridedSlice}, ParameterVector{data});
} else {
const auto data = std::make_shared<op::v0::Parameter>(params.dataTensor.type, PartialShape::dynamic());
const auto beginOp = std::make_shared<op::v0::Parameter>(params.beginTensor.type, params.beginTensor.shape);
const auto endOp = std::make_shared<op::v0::Parameter>(params.endTensor.type, params.endTensor.shape);
const auto StridedSlice = std::make_shared<op::v1::StridedSlice>(data, beginOp, endOp,
params.beginMask, params.endMask, params.newAxisMask,
params.shrinkAxisMask, params.ellipsisMask);
function = std::make_shared<ov::Function>(NodeVector{StridedSlice}, ParameterVector{data, beginOp, endOp});
}
return function;
}
};
TEST_P(ReferenceStridedSliceLayerTest, CompareWithRefs) {
Exec();
}
TEST_P(ReferenceStridedSliceLayerTestStrideOptional, CompareWithRefs) {
Exec();
}
template<typename T>
std::vector<T> generateInputValues(const Shape& input_shape, T initial) {
std::vector<T> input_values(shape_size(input_shape));
std::iota(input_values.begin(), input_values.end(), static_cast<T>(initial));
return input_values;
}
template <element::Type_t IN_ET>
std::vector<StridedSliceParams> generateSmallParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<StridedSliceParams> params {
// strided_slice_0
StridedSliceParams(
{},
Tensor(IN_ET, {2, 3, 4}, std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23}),
Tensor(element::i64, {2}, std::vector<int64_t>{1, 0}),
Tensor(element::i64, {2}, std::vector<int64_t>{0, 0}),
Tensor(element::i64, {2}, std::vector<int64_t>{1, 1}),
std::vector<int64_t>{0, 0, 0},
std::vector<int64_t>{0, 0, 0},
std::vector<int64_t>{0, 1, 0},
std::vector<int64_t>{1, 0, 0},
std::vector<int64_t>{0, 0, 0},
Tensor(IN_ET, {1, 3, 4}, std::vector<T>{12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23}),
"strided_slice_0"),
// strided_slice_0_dynamic
StridedSliceParams(
PartialShape::dynamic(),
Tensor(IN_ET, {2, 3, 4}, std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23}),
Tensor(element::i64, {2}, std::vector<int64_t>{1, 0}),
Tensor(element::i64, {2}, std::vector<int64_t>{0, 0}),
Tensor(element::i64, {2}, std::vector<int64_t>{1, 1}),
std::vector<int64_t>{0, 0, 0},
std::vector<int64_t>{0, 0, 0},
std::vector<int64_t>{0, 1, 0},
std::vector<int64_t>{1, 0, 0},
std::vector<int64_t>{0, 0, 0},
Tensor(IN_ET, {1, 3, 4}, std::vector<T>{12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23}),
"strided_slice_0_dynamic"),
};
return params;
}
template <element::Type_t IN_ET>
std::vector<StridedSliceParams> generateParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<StridedSliceParams> params {
// strided_slice_0
StridedSliceParams(
{},
Tensor(IN_ET, {2, 3, 4}, std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23}),
Tensor(element::i64, {2}, std::vector<int64_t>{1, 0}),
Tensor(element::i64, {2}, std::vector<int64_t>{0, 0}),
Tensor(element::i64, {2}, std::vector<int64_t>{1, 1}),
std::vector<int64_t>{0, 0, 0},
std::vector<int64_t>{0, 0, 0},
std::vector<int64_t>{0, 1, 0},
std::vector<int64_t>{1, 0, 0},
std::vector<int64_t>{0, 0, 0},
Tensor(IN_ET, {1, 3, 4}, std::vector<T>{12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23}),
"strided_slice_0"),
// strided_slice_0_dynamic
StridedSliceParams(
PartialShape::dynamic(),
Tensor(IN_ET, {2, 3, 4}, std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23}),
Tensor(element::i64, {2}, std::vector<int64_t>{1, 0}),
Tensor(element::i64, {2}, std::vector<int64_t>{0, 0}),
Tensor(element::i64, {2}, std::vector<int64_t>{1, 1}),
std::vector<int64_t>{0, 0, 0},
std::vector<int64_t>{0, 0, 0},
std::vector<int64_t>{0, 1, 0},
std::vector<int64_t>{1, 0, 0},
std::vector<int64_t>{0, 0, 0},
Tensor(IN_ET, {1, 3, 4}, std::vector<T>{12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23}),
"strided_slice_0_dynamic"),
// strided_slice_1
StridedSliceParams(
{},
Tensor(IN_ET, {2, 4, 6, 8, 2, 2, 2}, generateInputValues<T>({2, 4, 6, 8, 2, 2, 2}, 0)),
Tensor(element::i64, {7}, std::vector<int64_t>{0, 0, 2, 7, 0, 0, 1}),
Tensor(element::i64, {7}, std::vector<int64_t>{0, 4, 6, 3, 0, 0, 0}),
Tensor(element::i64, {7}, std::vector<int64_t>{1, 1, 2, -2, 1, 1, 1}),
std::vector<int64_t>{0, 1, 0, 0, 0, 0, 0},
std::vector<int64_t>{1, 0, 0, 0, 0, 0, 0},
std::vector<int64_t>{0, 0, 0, 0, 1, 0, 0},
std::vector<int64_t>{0, 0, 0, 0, 0, 0, 1},
std::vector<int64_t>{0, 0, 0, 0, 0, 1, 0},
Tensor(IN_ET, {2, 4, 2, 2, 1, 2, 2}, std::vector<T>{
185, 187, 189, 191, 169, 171, 173, 175, 313, 315, 317, 319, 297, 299, 301,
303, 569, 571, 573, 575, 553, 555, 557, 559, 697, 699, 701, 703, 681, 683,
685, 687, 953, 955, 957, 959, 937, 939, 941, 943, 1081, 1083, 1085, 1087, 1065,
1067, 1069, 1071, 1337, 1339, 1341, 1343, 1321, 1323, 1325, 1327, 1465, 1467, 1469, 1471,
1449, 1451, 1453, 1455, 1721, 1723, 1725, 1727, 1705, 1707, 1709, 1711, 1849, 1851, 1853,
1855, 1833, 1835, 1837, 1839, 2105, 2107, 2109, 2111, 2089, 2091, 2093, 2095, 2233, 2235,
2237, 2239, 2217, 2219, 2221, 2223, 2489, 2491, 2493, 2495, 2473, 2475, 2477, 2479, 2617,
2619, 2621, 2623, 2601, 2603, 2605, 2607, 2873, 2875, 2877, 2879, 2857, 2859, 2861, 2863,
3001, 3003, 3005, 3007, 2985, 2987, 2989, 2991}),
"strided_slice_1"),
// strided_slice_1_dynamic
StridedSliceParams(
PartialShape::dynamic(),
Tensor(IN_ET, {2, 4, 6, 8, 2, 2, 2}, generateInputValues<T>({2, 4, 6, 8, 2, 2, 2}, 0)),
Tensor(element::i64, {7}, std::vector<int64_t>{0, 0, 2, 7, 0, 0, 1}),
Tensor(element::i64, {7}, std::vector<int64_t>{0, 4, 6, 3, 0, 0, 0}),
Tensor(element::i64, {7}, std::vector<int64_t>{1, 1, 2, -2, 1, 1, 1}),
std::vector<int64_t>{0, 1, 0, 0, 0, 0, 0},
std::vector<int64_t>{1, 0, 0, 0, 0, 0, 0},
std::vector<int64_t>{0, 0, 0, 0, 1, 0, 0},
std::vector<int64_t>{0, 0, 0, 0, 0, 0, 1},
std::vector<int64_t>{0, 0, 0, 0, 0, 1, 0},
Tensor(IN_ET, {2, 4, 2, 2, 1, 2, 2}, std::vector<T>{
185, 187, 189, 191, 169, 171, 173, 175, 313, 315, 317, 319, 297, 299, 301,
303, 569, 571, 573, 575, 553, 555, 557, 559, 697, 699, 701, 703, 681, 683,
685, 687, 953, 955, 957, 959, 937, 939, 941, 943, 1081, 1083, 1085, 1087, 1065,
1067, 1069, 1071, 1337, 1339, 1341, 1343, 1321, 1323, 1325, 1327, 1465, 1467, 1469, 1471,
1449, 1451, 1453, 1455, 1721, 1723, 1725, 1727, 1705, 1707, 1709, 1711, 1849, 1851, 1853,
1855, 1833, 1835, 1837, 1839, 2105, 2107, 2109, 2111, 2089, 2091, 2093, 2095, 2233, 2235,
2237, 2239, 2217, 2219, 2221, 2223, 2489, 2491, 2493, 2495, 2473, 2475, 2477, 2479, 2617,
2619, 2621, 2623, 2601, 2603, 2605, 2607, 2873, 2875, 2877, 2879, 2857, 2859, 2861, 2863,
3001, 3003, 3005, 3007, 2985, 2987, 2989, 2991}),
"strided_slice_1_dynamic"),
};
return params;
}
template <element::Type_t IN_ET>
std::vector<StridedSliceStrideOptionalParams> generateStrideOptionalParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<StridedSliceStrideOptionalParams> params {
// strided_slice_stride_optional
StridedSliceStrideOptionalParams(
{},
Tensor(IN_ET, {2, 3, 4}, std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23}),
Tensor(element::i64, {3}, std::vector<int64_t>{-1, -1, 0}),
Tensor(element::i64, {3}, std::vector<int64_t>{0, 0, 0}),
std::vector<int64_t>{0, 0, 0},
std::vector<int64_t>{0, 0, 0},
std::vector<int64_t>{0, 0, 1},
std::vector<int64_t>{1, 1, 0},
std::vector<int64_t>{0, 0, 0},
Tensor(IN_ET, {1, 4}, std::vector<T>{20, 21, 22, 23}),
"strided_slice_stride_optional"),
// strided_slice_stride_optional_dynamic
StridedSliceStrideOptionalParams(
PartialShape::dynamic(),
Tensor(IN_ET, {2, 3, 4}, std::vector<T>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23}),
Tensor(element::i64, {3}, std::vector<int64_t>{-1, -1, 0}),
Tensor(element::i64, {3}, std::vector<int64_t>{0, 0, 0}),
std::vector<int64_t>{0, 0, 0},
std::vector<int64_t>{0, 0, 0},
std::vector<int64_t>{0, 0, 1},
std::vector<int64_t>{1, 1, 0},
std::vector<int64_t>{0, 0, 0},
Tensor(IN_ET, {1, 4}, std::vector<T>{20, 21, 22, 23}),
"strided_slice_stride_optional_dynamic"),
};
return params;
}
std::vector<StridedSliceParams> generateCombinedParams() {
const std::vector<std::vector<StridedSliceParams>> generatedParams {
generateSmallParams<element::Type_t::i8>(),
generateParams<element::Type_t::i16>(),
generateParams<element::Type_t::i32>(),
generateParams<element::Type_t::i64>(),
generateSmallParams<element::Type_t::u8>(),
generateParams<element::Type_t::u16>(),
generateParams<element::Type_t::u32>(),
generateParams<element::Type_t::u64>(),
generateSmallParams<element::Type_t::bf16>(),
generateSmallParams<element::Type_t::f16>(),
generateParams<element::Type_t::f32>(),
generateParams<element::Type_t::f64>(),
};
std::vector<StridedSliceParams> combinedParams;
for (const auto& params : generatedParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
std::vector<StridedSliceStrideOptionalParams> generateCombinedStrideOptionalParams() {
const std::vector<std::vector<StridedSliceStrideOptionalParams>> generatedParams {
generateStrideOptionalParams<element::Type_t::i8>(),
generateStrideOptionalParams<element::Type_t::i16>(),
generateStrideOptionalParams<element::Type_t::i32>(),
generateStrideOptionalParams<element::Type_t::i64>(),
generateStrideOptionalParams<element::Type_t::u8>(),
generateStrideOptionalParams<element::Type_t::u16>(),
generateStrideOptionalParams<element::Type_t::u32>(),
generateStrideOptionalParams<element::Type_t::u64>(),
generateStrideOptionalParams<element::Type_t::f32>(),
generateStrideOptionalParams<element::Type_t::f64>(),
};
std::vector<StridedSliceStrideOptionalParams> combinedParams;
for (const auto& params : generatedParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_StridedSlice_With_Hardcoded_Refs, ReferenceStridedSliceLayerTest,
testing::ValuesIn(generateCombinedParams()), ReferenceStridedSliceLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_StridedSlice_With_Hardcoded_Refs, ReferenceStridedSliceLayerTestStrideOptional,
testing::ValuesIn(generateCombinedStrideOptionalParams()), ReferenceStridedSliceLayerTestStrideOptional::getTestCaseName);
} // namespace

View File

@ -4,6 +4,8 @@
#include "behavior/preprocessing/preprocessing.hpp"
#ifdef ENABLE_GAPI_PREPROCESSING
using namespace BehaviorTestsDefinitions;
namespace {
@ -36,3 +38,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_Behavior_PreprocessingPrecisionConvertTestsViaGet
PreprocessingPrecisionConvertTest::getTestCaseName);
} // namespace
#endif // ENABLE_GAPI_PREPROCESSING

View File

@ -4,6 +4,8 @@
#include "behavior/preprocessing/set_preprocess.hpp"
#ifdef ENABLE_GAPI_PREPROCESSING
using namespace BehaviorTestsDefinitions;
namespace {
@ -89,4 +91,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, InferRequestPreprocessDynamicallyI
::testing::ValuesIn(configs)),
InferRequestPreprocessDynamicallyInSetBlobTest::getTestCaseName);
} // namespace
} // namespace
#endif // ENABLE_GAPI_PREPROCESSING

View File

@ -11,6 +11,9 @@
namespace {
using namespace HeteroTests;
// this tests load plugin by library name: this is not available during static linkage
#ifndef OPENVINO_STATIC_LIBRARY
INSTANTIATE_TEST_SUITE_P(smoke_SingleMajorNode, HeteroSyntheticTest,
::testing::Combine(
::testing::Values(std::vector<PluginParameter>{{"TEMPLATE0", "templatePlugin"}, {"TEMPLATE1", "templatePlugin"}}),
@ -69,4 +72,6 @@ INSTANTIATE_TEST_SUITE_P(nightly_RandomMajorNodes_dynamic_batch, HeteroSynthetic
dynamicBuilders, true))),
HeteroSyntheticTest::getTestCaseName);
#endif // !OPENVINO_STATIC_LIBRARY
} // namespace

View File

@ -59,6 +59,38 @@ std::vector<std::string> disabledTestPatterns() {
R"(.*ReferenceExperimentalGPLayerTest.*bf16.*)",
// CVS-64105
R"(.*ReferenceGatherElementsTestNegative.*)",
// CVS-64052
R"(.*ReferenceStridedSliceLayerTest.*strided_slice_stride_optional_dynamic)",
// CVS-64017
R"(.*ReferenceGatherTest.*dType=i16.*)",
R"(.*ReferenceGatherTest.*dType=u16.*)",
R"(.*ReferenceGatherTest.*dType=bf16.*)",
R"(.*ReferenceGatherTest.*dType=f64.*)",
// CVS-64110
R"(.*ReferenceGatherTestV7.*dType=i16.*)",
R"(.*ReferenceGatherTestV7.*dType=u16.*)",
R"(.*ReferenceGatherTestV7.*dType=bf16.*)",
R"(.*ReferenceGatherTestV7.*dType=f64.*)",
// CVS-64037
R"(.*ReferencePadTest.*pad_exterior_2d_0x0)",
R"(.*ReferencePadTest.*pad_exterior_2d_0x3)",
R"(.*ReferencePadTest.*pad_exterior_2d_3x0)",
// CVS-70975
R"(.*ReferencePadTestParamsTooLarge.*)",
// CVS-64006
R"(.*ReferenceBatchToSpaceLayerTest.*dType=i4.*)",
R"(.*ReferenceBatchToSpaceLayerTest.*dType=u4.*)",
// CVS-64113
R"(.*ReferenceRollLayerTest.*dType=i4.*)",
R"(.*ReferenceRollLayerTest.*dType=u4.*)",
// CVS-64050
R"(.*ReferenceSpaceToBatchLayerTest.*dType=i4.*)",
R"(.*ReferenceSpaceToBatchLayerTest.*dType=u4.*)",
// CVS-64066
R"(.*ReferenceGRUCellTestHardsigmoidActivationFunction.*gru_cell_hardsigmoid_activation_function)",
// CVS-71381
R"(.*ReferenceExpLayerTest.*u32.*)",
R"(.*ReferenceExpLayerTest.*u64.*)",
};
#ifdef _WIN32

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