diff --git a/.ci/azure/linux.yml b/.ci/azure/linux.yml index 146775f6189f02..f9fcee6a66eb77 100644 --- a/.ci/azure/linux.yml +++ b/.ci/azure/linux.yml @@ -103,7 +103,6 @@ jobs: cmakeArgs: > -GNinja -DVERBOSE_BUILD=ON - -DENABLE_TEMPLATE_PLUGIN=ON -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DENABLE_PYTHON=ON -DPYTHON_EXECUTABLE=/usr/bin/python3.6 diff --git a/.ci/azure/linux_ngraph_onnx.yml b/.ci/azure/linux_ngraph_onnx.yml index 1e13710f2c2b1e..28326c890536d5 100644 --- a/.ci/azure/linux_ngraph_onnx.yml +++ b/.ci/azure/linux_ngraph_onnx.yml @@ -1,5 +1,20 @@ jobs: -- job: nGraph_ONNX_Lin +- job: OpenVINO_ONNX_CI + strategy: + matrix: + Release: + BUILD_TYPE: 'Release' + PROTOBUF_LITE: 'OFF' + TOX_COMMAND: 'tox && tox -e zoo_models' + Debug: + BUILD_TYPE: 'Debug' + PROTOBUF_LITE: 'OFF' + TOX_COMMAND: 'tox' + Protobuf_lite: + BUILD_TYPE: 'Release' + PROTOBUF_LITE: 'ON' + TOX_COMMAND: 'tox && tox -e zoo_models' + maxParallel: 3 # About 300% of total time timeoutInMinutes: 90 @@ -12,7 +27,6 @@ jobs: VSTS_HTTP_RETRY: 5 VSTS_HTTP_TIMEOUT: 200 WORKERS_NUMBER: 8 - BUILD_TYPE: Release REPO_DIR: $(Build.Repository.LocalPath) WORK_DIR: $(Pipeline.Workspace)/_w MODELS_DIR: /mount/cinfsshare/onnxtestdata @@ -54,31 +68,16 @@ jobs: submodules: recursive path: openvino - - script: docker build --tag=openvino-onnx-ci-image --file=.ci/openvino-onnx/Dockerfile . - displayName: 'Docker build' + - script: 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)' - script: ngraph/python/tests/test_onnx/model_zoo_preprocess.sh -d $(TMP_DIR) -o -s "$(ONNX_MODEL_ZOO_SHA)" displayName: 'Get models' - - - script: | - ##wget -O "$(TMP_DIR)/msft.zip" https://onnxruntimetestdata.blob.core.windows.net/models/20191107.zip - ##unzip "$(TMP_DIR)/msft.zip" -d "$(MODELS_DIR)/msft" - #unzip "/mnt/onnxtestdata/models/20191107.zip" -d "$(MODELS_DIR)/msft" - #mv $(MODELS_DIR)/msft/opset9/LSTM_Seq_lens_unpacked/seq_lens_sorted $(MODELS_DIR)/msft/opset9/LSTM_Seq_lens_unpacked/test_data_set_0 - #mv $(MODELS_DIR)/msft/opset9/LSTM_Seq_lens_unpacked/seq_lens_unsorted $(MODELS_DIR)/msft/opset9/LSTM_Seq_lens_unpacked/test_data_set_1 - displayName: 'Get MSFT models' - enabled: false - - - script: | - ls -alR $(MODELS_DIR) - ls -alR $(TMP_DIR) - displayName: 'List models' - enabled: false + condition: ne(variables['BUILD_TYPE'], 'Debug') - script: sudo fallocate -l 48G /swapfile ; sudo mkswap /swapfile ; sudo swapon /swapfile ; df ; free -h displayName: 'Create swap' - script: | - docker run --name openvino-onnx-ci-container --volume $(TMP_DIR)/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 && tox -e zoo_models" - displayName: 'Docker run' - + docker run --name openvino-onnx-ci-container --volume $(TMP_DIR)/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)' diff --git a/.gitattributes b/.gitattributes index de9c0b51d763cd..78133600185f69 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,7 +2,6 @@ # Set default behavior to automatically normalize line endings. ############################################################################### * text=auto - ############################################################################### # Set default behavior for command prompt diff. # @@ -11,9 +10,7 @@ # Note: This is only used by command line ############################################################################### #*.cs diff=csharp - *.py text eol=lf - ############################################################################### # Set the merge driver for project and solution files # @@ -36,7 +33,6 @@ #*.modelproj merge=binary #*.sqlproj merge=binary #*.wwaproj merge=binary - ############################################################################### # behavior for image files # @@ -45,7 +41,6 @@ #*.jpg binary #*.png binary #*.gif binary - ############################################################################### # diff behavior for common document formats # @@ -63,9 +58,9 @@ #*.PDF diff=astextplain #*.rtf diff=astextplain #*.RTF diff=astextplain - *.PNG filter=lfs diff=lfs merge=lfs -text *.png filter=lfs diff=lfs merge=lfs -text *.jpg filter=lfs diff=lfs merge=lfs -text *.gif filter=lfs diff=lfs merge=lfs -text *.vsdx filter=lfs diff=lfs merge=lfs -text +*.bmp filter=lfs diff=lfs merge=lfs -text diff --git a/.gitmodules b/.gitmodules index 5c1d9956c6a203..d3f72b54c4f9c5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -37,4 +37,16 @@ [submodule "thirdparty/ocl/clhpp_headers"] path = thirdparty/ocl/clhpp_headers url = https://github.com/KhronosGroup/OpenCL-CLHPP.git - ignore = dirty \ No newline at end of file + ignore = dirty +[submodule "thirdparty/onnx"] + path = thirdparty/onnx/onnx + url = https://github.com/openvinotoolkit/onnx.git +[submodule "thirdparty/protobuf"] + path = thirdparty/protobuf/protobuf + url = https://github.com/protocolbuffers/protobuf.git +[submodule "ngraph/python/pybind11"] + path = ngraph/python/pybind11 + url = https://github.com/pybind/pybind11.git +[submodule "thirdparty/ittapi/ittapi"] + path = thirdparty/ittapi/ittapi + url = https://github.com/intel/ittapi.git diff --git a/CMakeLists.txt b/CMakeLists.txt index b796977515b351..6019fe63d931f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,12 +63,6 @@ function(build_ngraph) ngraph_set(NGRAPH_PDPD_FRONTEND_ENABLE OFF) endif() - if(ENABLE_PYTHON) - ngraph_set(NGRAPH_PYTHON_BUILD_ENABLE ON) - else() - ngraph_set(NGRAPH_PYTHON_BUILD_ENABLE OFF) - endif() - if(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$") ie_add_compiler_flags(-Wno-error=uninitialized -Wno-error=literal-conversion) elseif(UNIX) diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index 498f6171fddd88..e84a7cdc7180cc 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -32,12 +32,12 @@ if(COMMAND get_linux_name) endif() if(CMAKE_CROSSCOMPILING AND CMAKE_HOST_SYSTEM_NAME MATCHES Linux AND CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*") - set(protoc_version "3.7.1") + set(protoc_version "3.9.2") RESOLVE_DEPENDENCY(SYSTEM_PROTOC_ROOT ARCHIVE_LIN "protoc-${protoc_version}-linux-x86_64.tar.gz" TARGET_PATH "${TEMP}/protoc-${protoc_version}-linux-x86_64" - SHA256 "a1bedd5c05ca51e49f8f254faa3d7331e05b3a806c151fb111d582f154d0fee8" + SHA256 "1d6da1d97d0cbfcd333558afe24533eb3cb48dc1e0ab5e971aa1e50ede8bcf45" ) debug_message(STATUS "host protoc-${protoc_version} root path = " ${SYSTEM_PROTOC_ROOT}) diff --git a/cmake/developer_package/IEDevScriptsConfig.cmake b/cmake/developer_package/IEDevScriptsConfig.cmake index 17d96a69920d80..46423aa61c72e7 100644 --- a/cmake/developer_package/IEDevScriptsConfig.cmake +++ b/cmake/developer_package/IEDevScriptsConfig.cmake @@ -249,6 +249,25 @@ function(ie_mark_target_as_cc TARGET_NAME) set_source_files_properties(${sources} PROPERTIES OBJECT_DEPENDS ${GENERATED_HEADER}) endfunction() +# check python package + +function(ie_check_pip_package name message_type) + find_package(PythonInterp 3 REQUIRED) + + execute_process( + COMMAND ${PYTHON_EXECUTABLE} -m pip show ${name} + RESULT_VARIABLE PIP_EXIT_CODE + OUTPUT_QUIET + ) + + if(NOT PIP_EXIT_CODE EQUAL 0) + set(${name}_FOUND OFF PARENT_SCOPE) + message(${message_type} "${name} package is not installed. Please use \"${PYTHON_EXECUTABLE} -m pip install ${name}\".") + else() + set(${name}_FOUND ON PARENT_SCOPE) + endif() +endfunction() + # Code style utils include(cpplint/cpplint) diff --git a/cmake/developer_package/api_validator/api_validator.cmake b/cmake/developer_package/api_validator/api_validator.cmake index c12b4108f4be38..204289dc83c30f 100644 --- a/cmake/developer_package/api_validator/api_validator.cmake +++ b/cmake/developer_package/api_validator/api_validator.cmake @@ -88,9 +88,12 @@ function(_ie_add_api_validator_post_build_step) macro(api_validator_get_target_name) get_target_property(IS_IMPORTED ${target} IMPORTED) + get_target_property(orig_target ${target} ALIASED_TARGET) if(IS_IMPORTED) get_target_property(target_location ${target} LOCATION) get_filename_component(target_name "${target_location}" NAME_WE) + elseif(TARGET "${orig_target}") + set(target_name ${orig_target}) else() set(target_name ${target}) endif() diff --git a/cmake/developer_package/compile_flags/sanitizer.cmake b/cmake/developer_package/compile_flags/sanitizer.cmake index 3e73ef280767d1..dbf351965079a3 100644 --- a/cmake/developer_package/compile_flags/sanitizer.cmake +++ b/cmake/developer_package/compile_flags/sanitizer.cmake @@ -5,46 +5,50 @@ include(CheckCXXCompilerFlag) if (ENABLE_SANITIZER) - set(SANITIZER_COMPILER_FLAGS "-g -fsanitize=address -fno-omit-frame-pointer") - CHECK_CXX_COMPILER_FLAG("-fsanitize-recover=address" SANITIZE_RECOVER_SUPPORTED) - if (SANITIZE_RECOVER_SUPPORTED) + set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize=address") + CHECK_CXX_COMPILER_FLAG("-fsanitize-recover=address" SANITIZE_RECOVER_ADDRESS_SUPPORTED) + if (SANITIZE_RECOVER_ADDRESS_SUPPORTED) set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize-recover=address") endif() - set(SANITIZER_LINKER_FLAGS "-fsanitize=address") - # prevent unloading libraries at runtime, so sanitizer can resolve their symbols - set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -Wl,-z,nodelete") + set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fsanitize=address") +endif() - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fuse-ld=gold") - elseif(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$" AND NOT WIN32) - if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) - set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fuse-ld=lld") - endif() +if (ENABLE_UB_SANITIZER) + # TODO: Remove -fno-sanitize=null as thirdparty/ocl/clhpp_headers UBSAN compatibility resolved: + # https://github.com/KhronosGroup/OpenCL-CLHPP/issues/17 + set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize=undefined -fno-sanitize=null") + CHECK_CXX_COMPILER_FLAG("-fsanitize-recover=undefined" SANITIZE_RECOVER_UNDEFINED_SUPPORTED) + if (SANITIZE_RECOVER_UNDEFINED_SUPPORTED) + set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize-recover=undefined") endif() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZER_COMPILER_FLAGS}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZER_COMPILER_FLAGS}") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SANITIZER_LINKER_FLAGS}") - set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${SANITIZER_LINKER_FLAGS}") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SANITIZER_LINKER_FLAGS}") + set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fsanitize=undefined") endif() if (ENABLE_THREAD_SANITIZER) - set(SANITIZER_COMPILER_FLAGS "-g -fsanitize=thread -fno-omit-frame-pointer") - set(SANITIZER_LINKER_FLAGS "-fsanitize=thread") + set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize=thread") + set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fsanitize=thread") +endif() + +# common sanitizer options +if (DEFINED SANITIZER_COMPILER_FLAGS) + # ensure sumbols are present + set(SANITIZER_COMPILER_FLAGS "-g -fno-omit-frame-pointer") + # prevent unloading libraries at runtime, so sanitizer can resolve their symbols set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -Wl,-z,nodelete") - if(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$" AND NOT WIN32) + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fuse-ld=gold") + elseif(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$" AND NOT WIN32) if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fuse-ld=lld") - else() - set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -static-libsan") endif() endif() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZER_COMPILER_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZER_COMPILER_FLAGS}") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SANITIZER_LINKER_FLAGS}") set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${SANITIZER_LINKER_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SANITIZER_LINKER_FLAGS}") -endif() +endif() \ No newline at end of file diff --git a/cmake/developer_package/features.cmake b/cmake/developer_package/features.cmake index 813b58b7dc0bce..487dea8c7e382a 100644 --- a/cmake/developer_package/features.cmake +++ b/cmake/developer_package/features.cmake @@ -20,10 +20,12 @@ endif() # FIXME: ARM cross-compiler generates several "false positive" warnings regarding __builtin_memcpy buffer overflow ie_dependent_option (TREAT_WARNING_AS_ERROR "Treat build warnings as errors" ON "X86 OR X86_64" OFF) -ie_option (ENABLE_INTEGRITYCHECK "build DLLs with /INTEGRITYCHECK flag" OFF) +ie_dependent_option (ENABLE_INTEGRITYCHECK "build DLLs with /INTEGRITYCHECK flag" OFF "CMAKE_CXX_COMPILER_ID STREQUAL MSVC" OFF) ie_option (ENABLE_SANITIZER "enable checking memory errors via AddressSanitizer" OFF) +ie_option (ENABLE_UB_SANITIZER "enable UndefinedBahavior sanitizer" OFF) + ie_option (ENABLE_THREAD_SANITIZER "enable checking data races via ThreadSanitizer" OFF) ie_dependent_option (ENABLE_COVERAGE "enable code coverage" OFF "CMAKE_CXX_COMPILER_ID STREQUAL GNU" OFF) diff --git a/cmake/developer_package/packaging.cmake b/cmake/developer_package/packaging.cmake index fd7d39a35ec53d..4cb21210d4a166 100644 --- a/cmake/developer_package/packaging.cmake +++ b/cmake/developer_package/packaging.cmake @@ -13,9 +13,9 @@ include(CPackComponent) set(IE_CPACK_IE_DIR deployment_tools/inference_engine) function(ie_cpack_set_library_dir) if(WIN32) - set(IE_CPACK_LIBRARY_PATH ${IE_CPACK_IE_DIR}/lib/${ARCH_FOLDER}/${CMAKE_BUILD_TYPE} PARENT_SCOPE) - set(IE_CPACK_RUNTIME_PATH ${IE_CPACK_IE_DIR}/bin/${ARCH_FOLDER}/${CMAKE_BUILD_TYPE} PARENT_SCOPE) - set(IE_CPACK_ARCHIVE_PATH ${IE_CPACK_IE_DIR}/lib/${ARCH_FOLDER}/${CMAKE_BUILD_TYPE} PARENT_SCOPE) + set(IE_CPACK_LIBRARY_PATH ${IE_CPACK_IE_DIR}/lib/${ARCH_FOLDER}/$ PARENT_SCOPE) + set(IE_CPACK_RUNTIME_PATH ${IE_CPACK_IE_DIR}/bin/${ARCH_FOLDER}/$ PARENT_SCOPE) + set(IE_CPACK_ARCHIVE_PATH ${IE_CPACK_IE_DIR}/lib/${ARCH_FOLDER}/$ PARENT_SCOPE) else() set(IE_CPACK_LIBRARY_PATH ${IE_CPACK_IE_DIR}/lib/${ARCH_FOLDER} PARENT_SCOPE) set(IE_CPACK_RUNTIME_PATH ${IE_CPACK_IE_DIR}/lib/${ARCH_FOLDER} PARENT_SCOPE) diff --git a/cmake/developer_package/version.cmake b/cmake/developer_package/version.cmake index e807a3ea31f65f..054bc10c78ed9a 100644 --- a/cmake/developer_package/version.cmake +++ b/cmake/developer_package/version.cmake @@ -31,19 +31,18 @@ macro(ie_parse_ci_build_number) set(IE_VERSION_MAJOR ${CMAKE_MATCH_1}) set(IE_VERSION_MINOR ${CMAKE_MATCH_2}) set(IE_VERSION_PATCH ${CMAKE_MATCH_3}) - set(has_ci_version ON) - else() - set(IE_VERSION_MAJOR 0) - set(IE_VERSION_MINOR 0) - set(IE_VERSION_PATCH 0) endif() if(NOT DEFINED repo_root) message(FATAL_ERROR "repo_root is not defined") endif() - if(DEFINED IEDevScripts_DIR AND DEFINED OpeenVINO_SOURCE_DIR AND NOT DEFINED custom_build) - set(ie_version_hpp "${IE_MAIN_SOURCE_DIR}/include/ie_version.hpp") + macro(ie_get_hpp_version) + if(NOT DEFINED OpenVINO_SOURCE_DIR) + return() + endif() + + set(ie_version_hpp "${OpenVINO_SOURCE_DIR}/inference-engine/include/ie_version.hpp") if(NOT EXISTS ${ie_version_hpp}) message(FATAL_ERROR "File ie_version.hpp with IE_VERSION definitions is not found") endif() @@ -57,6 +56,13 @@ macro(ie_parse_ci_build_number) string(REGEX REPLACE ".+IE_VERSION_PATCH[ ]+([0-9]+).*" "\\1" IE_VERSION_PATCH_HPP "${IE_VERSION_PARTS}") + set(ie_hpp_version_is_found ON) + endmacro() + + # detect OpenVINO version via ie_version.hpp + ie_get_hpp_version() + + if(ie_hpp_version_is_found) foreach(var IE_VERSION_MAJOR IE_VERSION_MINOR IE_VERSION_PATCH) if(DEFINED ${var} AND NOT ${var} EQUAL ${var}_HPP) message(FATAL_ERROR "${var} parsed from CI_BUILD_NUMBER (${${var}}) \ @@ -66,13 +72,10 @@ macro(ie_parse_ci_build_number) set(${var} ${${var}_HPP}) endif() endforeach() - elseif(has_ci_version) - message(WARNING "OpeenVINO_SOURCE_DIR is not defined. No way to compare versions") - else() - message(WARNING "No way to detect OpenVINO version. Supposing 0.0.0.0") endif() set(IE_VERSION "${IE_VERSION_MAJOR}.${IE_VERSION_MINOR}.${IE_VERSION_PATCH}") + message(STATUS "OpenVINO version is ${IE_VERSION}") endmacro() if (DEFINED ENV{CI_BUILD_NUMBER}) diff --git a/cmake/features.cmake b/cmake/features.cmake index 6042d9d2238881..1f0c198913cc23 100644 --- a/cmake/features.cmake +++ b/cmake/features.cmake @@ -24,8 +24,6 @@ Supported values:\ ie_option (ENABLE_PROFILING_FIRST_INFERENCE "Build with ITT tracing of first inference time." ON) -ie_option(ENABLE_TEMPLATE_PLUGIN "Register template plugin into plugins.xml" OFF) - ie_option_enum(SELECTIVE_BUILD "Enable OpenVINO conditional compilation or statistics collection. \ In case SELECTIVE_BUILD is enabled, the SELECTIVE_BUILD_STAT variable should contain the path to the collected InelSEAPI statistics. \ Usage: -DSELECTIVE_BUILD=ON -DSELECTIVE_BUILD_STAT=/path/*.csv" OFF diff --git a/cmake/templates/InferenceEngineDeveloperPackageConfig.cmake.in b/cmake/templates/InferenceEngineDeveloperPackageConfig.cmake.in index 319fd765c6abb6..4aca14b72bd46d 100644 --- a/cmake/templates/InferenceEngineDeveloperPackageConfig.cmake.in +++ b/cmake/templates/InferenceEngineDeveloperPackageConfig.cmake.in @@ -13,7 +13,8 @@ set_and_check(IE_MAIN_SOURCE_DIR "@IE_MAIN_SOURCE_DIR@") # HDDL # Variables to export in plugin's projects -set(ie_options "@IE_OPTIONS@;CMAKE_BUILD_TYPE;CMAKE_SKIP_RPATH") +set(ie_options "@IE_OPTIONS@;CMAKE_BUILD_TYPE;CMAKE_SKIP_RPATH;") +list(APPEND ie_options CMAKE_CXX_COMPILER_LAUNCHER CMAKE_C_COMPILER_LAUNCHER) file(TO_CMAKE_PATH "${CMAKE_CURRENT_LIST_DIR}" cache_path) message(STATUS "The following CMake options are exported from Inference Engine Developer package") diff --git a/cmake/toolchains/oecore.arm64.toolchain.cmake b/cmake/toolchains/oecore.arm64.toolchain.cmake new file mode 100644 index 00000000000000..ef32d5990ec30a --- /dev/null +++ b/cmake/toolchains/oecore.arm64.toolchain.cmake @@ -0,0 +1,50 @@ +# +# Copyright 2020 Intel Corporation. +# +# LEGAL NOTICE: Your use of this software and any required dependent software +# (the "Software Package") is subject to the terms and conditions of +# the Intel(R) OpenVINO(TM) Distribution License for the Software Package, +# which may also include notices, disclaimers, or license terms for +# third party or open source software included in or with the Software Package, +# and your use indicates your acceptance of all such terms. Please refer +# to the "third-party-programs.txt" or other similarly-named text file +# included with the Software Package for additional details. +# + +if(DEFINED OECORE_BASE_DIR) + # OECORE_BASE_DIR was passed via CMake command line, nothing to do +elseif(DEFINED ENV{OECORE_BASE_DIR}) + # User sets OECORE_BASE_DIR environment variable + set(OECORE_BASE_DIR $ENV{OECORE_BASE_DIR}) +elseif(DEFINED ENV{OECORE_NATIVE_SYSROOT}) + # OECORE_NATIVE_SYSROOT is a default environment variable for the OECore toolchain + set(OECORE_BASE_DIR "$ENV{OECORE_NATIVE_SYSROOT}/../..") +else() + # Use default value + set(OECORE_BASE_DIR "/usr/local/oecore-x86_64") +endif() + +set(OECORE_TARGET_NAME "aarch64-ese-linux") +set(OECORE_TARGET_SYSROOT "${OECORE_BASE_DIR}/sysroots/${OECORE_TARGET_NAME}") +set(OECORE_HOST_SYSROOT "${OECORE_BASE_DIR}/sysroots/x86_64-esesdk-linux") +set(OECORE_HOST_COMPILER_BIN_DIR "${OECORE_HOST_SYSROOT}/usr/bin/${OECORE_TARGET_NAME}") + +set(CMAKE_SYSTEM_NAME "Linux") +set(CMAKE_SYSTEM_PROCESSOR "aarch64") + +set(CMAKE_SYSROOT "${OECORE_TARGET_SYSROOT}") + +set(CMAKE_C_COMPILER "${OECORE_HOST_COMPILER_BIN_DIR}/aarch64-ese-linux-gcc") +set(CMAKE_CXX_COMPILER "${OECORE_HOST_COMPILER_BIN_DIR}/aarch64-ese-linux-g++") + +set(CMAKE_C_FLAGS_INIT "-mcpu=cortex-a53 -mtune=cortex-a53 --sysroot=${OECORE_TARGET_SYSROOT}") +set(CMAKE_CXX_FLAGS_INIT "-mcpu=cortex-a53 -mtune=cortex-a53 --sysroot=${OECORE_TARGET_SYSROOT}") + +set(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed --sysroot=${OECORE_TARGET_SYSROOT}") +set(CMAKE_SHARED_LINKER_FLAGS_INIT "-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed --sysroot=${OECORE_TARGET_SYSROOT}") +set(CMAKE_MODULE_LINKER_FLAGS_INIT "-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed --sysroot=${OECORE_TARGET_SYSROOT}") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 9b3859a29c4efc..c9859464ee13ea 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -48,7 +48,6 @@ if(NOT ENABLE_DOCKER) LIBRARY DESTINATION ${IE_CPACK_RUNTIME_PATH} COMPONENT tests EXCLUDE_FROM_ALL) endif() -set(LINKCHECKER_PY "" CACHE FILEPATH "Path to linkchecker.py for documentation check") set(OMZ_DOCS_DIR "" CACHE PATH "Path to open_model_zoo documentation") set(WORKBENCH_DOCS_DIR "" CACHE PATH "Path to workbench documentation") set(POT_DOCS_DIR "" CACHE PATH "Path to post-training-compression-tool documentation") @@ -56,18 +55,14 @@ set(GST_DOCS_DIR "" CACHE PATH "Path to gst-video-analytics documentation") function(build_docs) find_package(Doxygen REQUIRED dot) - find_package(PythonInterp 3 REQUIRED) find_package(LATEX REQUIRED) - execute_process( - COMMAND ${PYTHON_EXECUTABLE} -m pip show lxml - RESULT_VARIABLE PIP_EXIT_CODE - OUTPUT_QUIET - ) + ie_check_pip_package(lxml FATAL_ERROR) + ie_check_pip_package(LinkChecker WARNING) - if (NOT ${PIP_EXIT_CODE} EQUAL 0) - message(FATAL_ERROR "lxml package is not installed. Please use \"pip install lxml\".") - endif() + find_host_program(LINKCHECKER_PY + NAMES linkchecker + DOC "linkchecker tools for documentation check") set(DOCS_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}") set(DOXYGEN_DIR "${OpenVINO_SOURCE_DIR}/docs/doxygen") @@ -357,7 +352,7 @@ function(build_docs) if(EXISTS "${LINKCHECKER_PY}") add_custom_target(docs_check - COMMAND ${PYTHON_EXECUTABLE} "${LINKCHECKER_PY}" -v "${DOCS_BUILD_DIR}/html/" + COMMAND "${LINKCHECKER_PY}" -v "${DOCS_BUILD_DIR}/html/" COMMENT "Check links in generated documentation" WORKING_DIRECTORY "${DOCS_BUILD_DIR}" VERBATIM) diff --git a/docs/IE_DG/Integrate_with_customer_application_new_API.md b/docs/IE_DG/Integrate_with_customer_application_new_API.md index 9e35f483717433..93482a9093887e 100644 --- a/docs/IE_DG/Integrate_with_customer_application_new_API.md +++ b/docs/IE_DG/Integrate_with_customer_application_new_API.md @@ -210,11 +210,6 @@ It's allowed to specify additional build options (e.g. to build CMake project on ### Run Your Application -> **NOTE**: 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. - -To run compiled applications on Microsoft* Windows* OS, make sure that Microsoft* Visual C++ 2017 -Redistributable and Intel® C++ Compiler 2017 Redistributable packages are installed and -`/bin/intel64/Release/*.dll` files are placed to the -application folder or accessible via `%PATH%` environment variable. +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. [integration_process]: img/integration_process.png diff --git a/docs/IE_DG/img/applying_low_latency.png b/docs/IE_DG/img/applying_low_latency.png old mode 100755 new mode 100644 diff --git a/docs/IE_DG/img/applying_low_latency_2.png b/docs/IE_DG/img/applying_low_latency_2.png old mode 100755 new mode 100644 diff --git a/docs/IE_DG/img/llt2_use_const_initializer.png b/docs/IE_DG/img/llt2_use_const_initializer.png old mode 100755 new mode 100644 diff --git a/docs/IE_DG/img/low_latency_limitation_1.png b/docs/IE_DG/img/low_latency_limitation_1.png old mode 100755 new mode 100644 diff --git a/docs/IE_DG/img/low_latency_limitation_2.png b/docs/IE_DG/img/low_latency_limitation_2.png old mode 100755 new mode 100644 diff --git a/docs/doxygen/doxygen-ignore.txt b/docs/doxygen/doxygen-ignore.txt index 7f963ac63e71de..b1f27a4972cb0d 100644 --- a/docs/doxygen/doxygen-ignore.txt +++ b/docs/doxygen/doxygen-ignore.txt @@ -1,6 +1,5 @@ openvino/inference-engine/samples/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 openvino/docs/get_started/get_started_linux.md openvino/docs/get_started/get_started_raspbian.md @@ -11,25 +10,14 @@ openvino/docs/install_guides/deployment-manager-tool.md openvino/docs/MO_DG/prepare_model/customize_model_optimizer/Customize_Model_Optimizer.md openvino/docs/ovsa/ovsa_get_started.md openvino/inference-engine/ie_bridges/c/docs/api_overview.md -inference-engine/include/cpp/ie_infer_request.hpp -inference-engine/include/ie_parallel.hpp -inference-engine/include/gpu/gpu_context_api_ocl.hpp -inference-engine/include/gpu/gpu_context_api_va.hpp -inference-engine/include/ie_plugin_config.hpp -inference-engine/include/ie_unicode.hpp -inference-engine/include/vpu/myriad_config.hpp -inference-engine/include/vpu/vpu_config.hpp -inference-engine/include/vpu/vpu_plugin_config.hpp openvino/docs/benchmarks/performance_int8_vs_fp32.md openvino/docs/get_started/get_started_macos.md openvino/docs/optimization_guide/dldt_optimization_guide.md openvino/docs/IE_DG/ShapeInference.md -inference-engine/include/details/ie_so_pointer.hpp -inference-engine/include/ie_compound_blob.h -inference-engine/include/ie_data.h -inference-engine/include/ie_blob.h -inference-engine/include/ie_precision.hpp -inference-engine/include/ie_remote_context.hpp -inference-engine/include/gpu/gpu_context_api_dx.hpp build/docs/openvino_docs.xml -openvino/docs/install_guides/installing-openvino-linux-ivad-vpu.md \ No newline at end of file +openvino/docs/install_guides/installing-openvino-linux-ivad-vpu.md +inference-engine/include/ie_parallel.hpp +inference-engine/include/ie_plugin_config.hpp +inference-engine/include/vpu/myriad_config.hpp +inference-engine/include/vpu/vpu_config.hpp +inference-engine/include/vpu/vpu_plugin_config.hpp \ No newline at end of file diff --git a/docs/doxygen/ie_docs.config b/docs/doxygen/ie_docs.config index db424ce7adc986..bbd203c931c338 100644 --- a/docs/doxygen/ie_docs.config +++ b/docs/doxygen/ie_docs.config @@ -913,12 +913,14 @@ EXCLUDE_SYMBOLS = InferenceEngine::details \ DECLARE_*METRIC_KEY \ DECLARE_*METRIC_VALUE \ DECLARE_*CONFIG_KEY \ + DECLARE_VPU_CONFIG \ + VPU_CONFIG_KEY \ + VPU_CONFIG_VALUE \ + VPU_METRIC \ DECLARE_*CONFIG_VALUE \ DECLARE_PARAM_KEY_IMPL \ TBB_PREVIEW_LOCAL_OBSERVER \ PARTITIONING \ - CALL_STATUS_FNC* \ - CALL_FNC* \ __PRETTY_FUNCTION__ \ PRINT_COLOR_FORMAT \ PRINT_LAYOUT \ @@ -943,6 +945,8 @@ EXCLUDE_SYMBOLS = InferenceEngine::details \ InferenceEngine::parallel_* \ NOMINMAX \ TBB_PREVIEW_NUMA_SUPPORT \ + TBB_PREVIEW_TASK_ARENA_CONSTRAINTS_EXTENSION \ + _TBB_REDUCE_FUNC \ IE_THREAD_* # The EXAMPLE_PATH tag can be used to specify one or more files or directories diff --git a/docs/img/OV-diagram-step1.png b/docs/img/OV-diagram-step1.png index d1ff39f1aaa1ea..da3212d0713bdb 100644 Binary files a/docs/img/OV-diagram-step1.png and b/docs/img/OV-diagram-step1.png differ diff --git a/docs/img/OV-diagram-step4.png b/docs/img/OV-diagram-step4.png index 75fe645a313e32..7df9835e8e86e9 100644 Binary files a/docs/img/OV-diagram-step4.png and b/docs/img/OV-diagram-step4.png differ diff --git a/docs/install_guides/pypi-openvino-dev.md b/docs/install_guides/pypi-openvino-dev.md index 89bb5f3db614a3..01616f7e85eecf 100644 --- a/docs/install_guides/pypi-openvino-dev.md +++ b/docs/install_guides/pypi-openvino-dev.md @@ -15,11 +15,11 @@ The **developer package** includes the following components installed by default | Component | Console Script | Description | |------------------|---------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [Model Optimizer](https://docs.openvinotoolkit.org/latest/openvino_docs_MO_DG_Deep_Learning_Model_Optimizer_DevGuide.html) | `mo` |**Model Optimizer** imports, converts, and optimizes models that were trained in popular frameworks to a format usable by Intel tools, especially the Inference Engine. 
Popular frameworks include Caffe\*, TensorFlow\*, MXNet\*, and ONNX\*. | +| [Model Optimizer](https://docs.openvinotoolkit.org/latest/openvino_docs_MO_DG_Deep_Learning_Model_Optimizer_DevGuide.html) | `mo` |**Model Optimizer** imports, converts, and optimizes models that were trained in popular frameworks to a format usable by Intel tools, especially the Inference Engine. 
Supported frameworks include Caffe\*, TensorFlow\*, MXNet\*, and ONNX\*. | | [Benchmark Tool](https://docs.openvinotoolkit.org/latest/openvino_inference_engine_tools_benchmark_tool_README.html)| `benchmark_app` | **Benchmark Application** allows you to estimate deep learning inference performance on supported devices for synchronous and asynchronous modes. | -| [Accuracy Checker](https://docs.openvinotoolkit.org/latest/omz_tools_accuracy_checker.html) and
[Annotation Converter](https://docs.openvinotoolkit.org/latest/omz_tools_accuracy_checker_annotation_converters.html) | `accuracy_check`
`convert_annotation` |**Accuracy Checker** is a deep learning accuracy validation tool that allows you to collect accuracy metrics against popular datasets. The main advantages of the tool are the flexibility of configuration and an impressive set of supported datasets, preprocessing, postprocessing, and metrics.
**Annotation Converter** is a utility for offline conversion of datasets to the format suitable for metric evaluation used in Accuracy Checker. | +| [Accuracy Checker](https://docs.openvinotoolkit.org/latest/omz_tools_accuracy_checker.html) and
[Annotation Converter](https://docs.openvinotoolkit.org/latest/omz_tools_accuracy_checker_annotation_converters.html) | `accuracy_check`
`convert_annotation` |**Accuracy Checker** is a deep learning accuracy validation tool that allows you to collect accuracy metrics against popular datasets. The main advantages of the tool are the flexibility of configuration and a set of supported datasets, preprocessing, postprocessing, and metrics.
**Annotation Converter** is a utility that prepares datasets for evaluation with Accuracy Checker. | | [Post-Training Optimization Tool](https://docs.openvinotoolkit.org/latest/pot_README.html)| `pot` |**Post-Training Optimization Tool** allows you to optimize trained models with advanced capabilities, such as quantization and low-precision optimizations, without the need to retrain or fine-tune models. Optimizations are also available through the [API](https://docs.openvinotoolkit.org/latest/pot_compression_api_README.html). | -| [Model Downloader and other Open Model Zoo tools](https://docs.openvinotoolkit.org/latest/omz_tools_downloader.html)| `omz_downloader`
`omz_converter`
`omz_quantizer`
`omz_info_dumper`| **Model Downloader** is a tool for getting access to the collection of high-quality and extremely fast pre-trained deep learning [public](https://docs.openvinotoolkit.org/latest/omz_models_group_public.html) and [intel](https://docs.openvinotoolkit.org/latest/omz_models_group_intel.html)-trained models. Use these free pre-trained models instead of training your own models to speed up the development and production deployment process. The principle of the tool is as follows: it downloads model files from online sources and, if necessary, patches them with Model Optimizer to make them more usable. A number of additional tools are also provided to automate the process of working with downloaded models:
**Model Converter** is a tool for converting the models stored in a format other than the Intermediate Representation (IR) into that format using Model Optimizer.
**Model Quantizer** is a tool for automatic quantization of full-precision IR models into low-precision versions using Post-Training Optimization Tool.
**Model Information Dumper** is a helper utility for dumping information about the models in a stable machine-readable format.| +| [Model Downloader and other Open Model Zoo tools](https://docs.openvinotoolkit.org/latest/omz_tools_downloader.html)| `omz_downloader`
`omz_converter`
`omz_quantizer`
`omz_info_dumper`| **Model Downloader** is a tool for getting access to the collection of high-quality and extremely fast pre-trained deep learning [public](https://docs.openvinotoolkit.org/latest/omz_models_group_public.html) and [Intel](https://docs.openvinotoolkit.org/latest/omz_models_group_intel.html)-trained models. These free pre-trained models can be used to speed up the development and production deployment process without training your own models. The tool downloads model files from online sources and, if necessary, patches them to make them more usable with Model Optimizer. A number of additional tools are also provided to automate the process of working with downloaded models:
**Model Converter** is a tool for converting Open Model Zoo models that are stored in an original deep learning framework format into the Inference Engine Intermediate Representation (IR) using Model Optimizer.
**Model Quantizer** is a tool for automatic quantization of full-precision models in the IR format into low-precision versions using the Post-Training Optimization Tool.
**Model Information Dumper** is a helper utility for dumping information about the models to a stable, machine-readable format. **Developer package** also provides the **runtime package** installed as a dependency. The runtime package includes the following components: @@ -54,17 +54,14 @@ To avoid dependency conflicts, use a virtual environment. Skip this Create virtual environment: -On Linux and macOS: -```sh -# Depending on your OS, this step may require installing python3-venv -python3 -m venv openvino_env -``` - -On Windows: ```sh +python -m pip install --user virtualenv python -m venv openvino_env ``` +> **NOTE**: On Linux and macOS, you may need to type `python3` instead of +`python`. You may also need to [install pip](https://pip.pypa.io/en/stable/installing/). For example, on Ubuntu execute the following command to get pip installed: `sudo apt install python3-venv python3-pip`. + ### Step 2. Activate Virtual Environment On Linux and macOS: @@ -87,11 +84,11 @@ python -m pip install --upgrade pip To install and configure the components of the development package for working with specific frameworks, use the `pip install openvino-dev[extras]` command, where `extras` is a list of extras from the table below: -| DL Framework | Extra | +| DL Framework | Extra | | :------------------------------------------------------------------------------- | :-------------------------------| | [Caffe*](https://caffe.berkeleyvision.org/) | caffe | -| [Caffe2*](https://caffe2.ai/) | caffe2 | -| [Kaldi*](https://kaldi-asr.org/) | kaldi | +| [Caffe2*](https://github.com/pytorch/pytorch) | caffe2 | +| [Kaldi*](https://github.com/kaldi-asr/kaldi) | kaldi | | [MXNet*](https://mxnet.apache.org/) | mxnet | | [ONNX*](https://github.com/microsoft/onnxruntime/) | onnx | | [PyTorch*](https://pytorch.org/) | pytorch | diff --git a/docs/install_guides/pypi-openvino-rt.md b/docs/install_guides/pypi-openvino-rt.md index 7c20f9167b01ec..a41c02e7b2d7a7 100644 --- a/docs/install_guides/pypi-openvino-rt.md +++ b/docs/install_guides/pypi-openvino-rt.md @@ -51,7 +51,7 @@ python -m venv openvino_env ``` > **NOTE**: On Linux and macOS, you may need to type `python3` instead of -`python`. You may also need to [install pip](https://pip.pypa.io/en/stable/installing/). +`python`. You may also need to [install pip](https://pip.pypa.io/en/stable/installing/). For example, on Ubuntu execute the following command to get pip installed: `sudo apt install python3-venv python3-pip`. ### Step 2. Activate Virtual Environment diff --git a/docs/ops/arithmetic/Asinh_3.md b/docs/ops/arithmetic/Asinh_3.md index 9db15defa473ea..6fae01555d00ac 100644 --- a/docs/ops/arithmetic/Asinh_3.md +++ b/docs/ops/arithmetic/Asinh_3.md @@ -4,33 +4,29 @@ **Category**: Arithmetic unary operation -**Short description**: *Asinh* performs element-wise hyperbolic inverse sine (arcsinh) operation with given tensor. +**Short description**: *Asinh* performs element-wise inverse hyperbolic sine operation (arcsinh) on a given input tensor. -**Attributes**: +**Detailed description**: *Asinh* performs element-wise inverse hyperbolic sine operation on a given input tensor, based on the following mathematical formula: - No attributes available. +\f[ +a_{i} = asinh(a_{i}) +\f] + +**Attributes**: *Asinh* operation has no attributes. **Inputs** -* **1**: A tensor of type *T*. **Required.** +* **1**: A tensor of type *T* and arbitrary shape. **Required.** **Outputs** -* **1**: The result of element-wise asinh operation. A tensor of type *T*. +* **1**: The result of element-wise *Asinh* operation. A tensor of type *T* and the same shape as input tensor. **Types** -* *T*: any floating point type. - -*Asinh* does the following with the input tensor *a*: - -\f[ -a_{i} = asinh(a_{i}) -\f] - -**Examples** +* *T*: any numeric type. -*Example 1* +**Example** ```xml diff --git a/docs/ops/arithmetic/Atan_1.md b/docs/ops/arithmetic/Atan_1.md index dc4c3b6d824116..7fc9525bf6622c 100644 --- a/docs/ops/arithmetic/Atan_1.md +++ b/docs/ops/arithmetic/Atan_1.md @@ -6,32 +6,28 @@ **Short description**: *Atan* performs element-wise inverse tangent (arctangent) operation with given tensor. -**Attributes**: +**Detailed description**: Operation takes one input tensor and performs the element-wise inverse tangent function on a given input tensor, based on the following mathematical formula: - No attributes available. +\f[ +a_{i} = atan(a_{i}) +\f] + +**Attributes**: *Atan* operation has no attributes. **Inputs** -* **1**: An tensor of type *T*. **Required.** +* **1**: A tensor of type *T* and arbitrary shape. **Required.** **Outputs** -* **1**: The result of element-wise atan operation. A tensor of type *T*. +* **1**: The result of element-wise *Atan* applied to the input tensor. A tensor of type *T* and same shape as the input tensor. **Types** -* *T*: any numeric type. - -*atan* does the following with the input tensor *a*: - -\f[ -a_{i} = atan(a_{i}) -\f] +* *T*: any supported numeric type. **Examples** -*Example 1* - ```xml diff --git a/docs/ops/arithmetic/Cosh_1.md b/docs/ops/arithmetic/Cosh_1.md index 08b3be9f42158d..7f1e3055dd3d47 100644 --- a/docs/ops/arithmetic/Cosh_1.md +++ b/docs/ops/arithmetic/Cosh_1.md @@ -4,33 +4,29 @@ **Category**: Arithmetic unary operation -**Short description**: *Cosh* performs element-wise hyperbolic cosine operation with given tensor. +**Short description**: *Cosh* performs element-wise hyperbolic cosine operation on a given input tensor. -**Attributes**: +**Detailed description**: *Cosh* performs element-wise hyperbolic cosine (cosh) operation on a given input tensor, based on the following mathematical formula: - No attributes available. +\f[ +a_{i} = cosh(a_{i}) +\f] + +**Attributes**: *Cosh* operation has no attributes. **Inputs** -* **1**: An tensor of type *T*. **Required.** +* **1**: A tensor of type *T* and arbitrary shape. **Required.** **Outputs** -* **1**: The result of element-wise cosh operation. A tensor of type *T*. +* **1**: The result of element-wise *Cosh* operation. A tensor of type *T* and the same shape as the input tensor. **Types** * *T*: any numeric type. -*Cosh* does the following with the input tensor *a*: - -\f[ -a_{i} = cosh(a_{i}) -\f] - -**Examples** - -*Example 1* +**Example** ```xml diff --git a/docs/ops/arithmetic/Sinh_1.md b/docs/ops/arithmetic/Sinh_1.md index 94a724acfe9dd8..0f0c83b63e1044 100644 --- a/docs/ops/arithmetic/Sinh_1.md +++ b/docs/ops/arithmetic/Sinh_1.md @@ -4,11 +4,15 @@ **Category**: Arithmetic unary operation -**Short description**: *Sinh* performs element-wise hyperbolic sine (sinh) operation with given tensor. +**Short description**: *Sinh* performs element-wise hyperbolic sine (sinh) operation on a given input tensor -**Attributes**: +**Detailed description**: *Sinh* performs element-wise hyperbolic sine (sinh) operation on a given input tensor, based on the following mathematical formula: - No attributes available. +\f[ +a_{i} = sinh(a_{i}) +\f] + +**Attributes**: *Sinh* operation has no attributes. **Inputs** @@ -16,21 +20,13 @@ **Outputs** -* **1**: The result of element-wise sinh operation. A tensor of type *T*. +* **1**: The result of element-wise *Sinh* operation applied to the input tensor. A tensor of type *T* and the same shape as input tensor. **Types** -* *T*: any numeric type. - -*sinh* does the following with the input tensor *a*: - -\f[ -a_{i} = sinh(a_{i}) -\f] - -**Examples** +* *T*: any supported numeric type. -*Example 1* +**Example** ```xml diff --git a/docs/ops/movement/BatchToSpace_2.md b/docs/ops/movement/BatchToSpace_2.md index 936d597792eba3..85fdd781f6861b 100644 --- a/docs/ops/movement/BatchToSpace_2.md +++ b/docs/ops/movement/BatchToSpace_2.md @@ -4,46 +4,87 @@ **Category**: *Data movement* -**Short description**: The *BatchToSpace* operation reshapes the "batch" dimension 0 into N - 1 dimensions of shape `block_shape` + [batch] and interleaves these blocks back into the grid defined by the spatial dimensions `[1, ..., N - 1]` to obtain a result with the same rank as `data` input. The spatial dimensions of this intermediate result are then optionally cropped according to `crops_begin` and `crops_end` to produce the output. This is the reverse of the *SpaceToBatch* operation. +**Short description**: *BatchToSpace* operation permutes the batch dimension on a given input `data` into blocks in the spatial dimensions specified by `block_shape` input. The spatial dimensions are then optionally cropped according to `crops_begin` and `crops_end` inputs to produce the output. -**Detailed description**: +**Detailed description** -The *BatchToSpace* operation is similar to the TensorFlow* operation [BatchToSpaceND](https://www.tensorflow.org/api_docs/python/tf/batch_to_space_nd) +*BatchToSpace* operation is equivalent to the following operation steps on the input `data` with shape `[batch, D_1, D_2, ..., D_{N-1}]` and `block_shape`, `crops_begin`, `crops_end` inputs with shape `[N]` to produce the output tensor \f$y\f$. -The operation is equivalent to the following transformation of the input tensors `data` with shape `[batch, D_1, D_2 ... D_{N-1}]` and `block_shape`, `crops_begin`, `crops_end` of shape `[N]` to *Y* output tensor. +1. Reshape `data` input to produce a tensor of shape \f$[B_1, \dots, B_{N - 1}, \frac{batch}{\left(B_1 \times \dots \times B_{N - 1}\right)}, D_1, D_2, \dots, D_{N - 1}]\f$ +\f[x^{\prime} = reshape(data, [B_1, \dots, B_{N - 1}, \frac{batch}{\left(B_1 \times \dots \times B_{N - 1}\right)}, D_1, D_2, \dots, D_{N - 1}])\f] - note: B_0 is expected to be 1. - x' = reshape(`data`, [B_1, ..., B_{N - 1}, batch / (B_1 * ... B_{N - 1}), D_1, D_2, ..., D_{N - 1}]), where B_i = block_shape[i] +2. Permute dimensions of \f$x^{\prime}\f$ to produce a tensor of shape \f$[\frac{batch}{\left(B_1 \times \dots \times B_{N - 1}\right)}, D_1, B_1, D_2, B_2, \dots, D_{N-1}, B_{N - 1}]\f$ +\f[x^{\prime\prime} = transpose(x', [N, N + 1, 0, N + 2, 1, \dots, N + N - 1, N - 1])\f] - x'' = transpose(x', [N, N + 1, 0, N + 2, 1, ..., N + N - 1, N - 1]) +3. Reshape \f$x^{\prime\prime}\f$ to produce a tensor of shape \f$[\frac{batch}{\left(B_1 \times \dots \times B_{N - 1}\right)}, D_1 \times B_1, D_2 \times B_2, \dots, D_{N - 1} \times B_{N - 1}]\f$ +\f[x^{\prime\prime\prime} = reshape(x^{\prime\prime}, [\frac{batch}{\left(B_1 \times \dots \times B_{N - 1}\right)}, D_1 \times B_1, D_2 \times B_2, \dots, D_{N - 1} \times B_{N - 1}])\f] - x''' = reshape(x'', [batch / (B_1 * ... * B_{N - 1}), D_1 * B_1, D_2 * B_2, ... , D_{N - 1} * B_{N - 1}]) +4. Crop the start and end of spatial dimensions of \f$x^{\prime\prime\prime}\f$ according to `crops_begin` and `crops_end` inputs to produce the output \f$y\f$ of shape: +\f[\left[\frac{batch}{\left(B_1 \times \dots \times B_{N - 1}\right)}, crop(D_1 \times B_1, CB_1, CE_1), crop(D_2 \times B_2, CB_2, CE_2), \dots , crop(D_{N - 1} \times B_{N - 1}, CB_{N - 1}, CE_{N - 1})\right]\f] - Crop the start and end of dimensions according to `crops_begin`, `crops_end` to produce the output of shape: - note: `crops_begin[0], crops_end[0]` are expected to be 0. - `y = [batch / (B_1 * ... * B_{N - 1}), crop(D_1 * B_1, crops_begin[1], crops_end[1]), crop(D_2 * B_2, crops_begin[2], crops_end[2]), ... , crop(D_{N - 1} * B_{N - 1}, crops_begin[N - 1], crops_end[N - 1])]` +Where -**Attributes** +- \f$B_i\f$ = block_shape[i] +- \f$B_0\f$ is expected to be 1 +- \f$CB_i\f$ = crops_begin[i] +- \f$CE_i\f$ = crops_end[i] +- \f$CB_0\f$ and \f$CE_0\f$ are expected to be 0 +- \f$CB_i + CE_i \leq D_i \times B_i \f$ - No attributes available. +*BatchToSpace* operation is the reverse of *SpaceToBatch* operation. + +**Attributes**: *BatchToSpace* operation has no attributes. **Inputs** -* **1**: `data` - input N-D tensor `[batch, D_1, D_2 ... D_{N-1}]` of *T1* type with rank >= 2. **Required.** -* **2**: `block_shape` - input 1-D tensor of *T2* type with shape `[N]` that is equal to the size of `data` input shape. All values must be >= 1.`block_shape[0]` is expected to be 1. **Required.** -* **3**: `crops_begin` - input 1-D tensor of *T2* type with shape `[N]` that is equal to the size of `data` input shape. All values must be non-negative. crops_begin specifies the amount to crop from the beginning along each axis of `data` input . It is required that `crop_start[i] + crop_end[i] <= block_shape[i] * input_shape[i]`. `crops_begin[0]` is expected to be 0. **Required.** -* **4**: `crops_end` - input 1-D tensor of *T2* type with shape `[N]` that is equal to the size of `data` input shape. All values must be non-negative. crops_end specifies the amount to crop from the ending along each axis of `data` input. It is required that `crop_start[i] + crop_end[i] <= block_shape[i] * input_shape[i]`. `crops_end[0]` is expected to be 0. **Required.** +* **1**: `data` - A tensor of type *T* and rank greater than or equal to 2. Layout is `[batch, D_1, D_2 ... D_{N-1}]` (number of batches, spatial axes). **Required.** +* **2**: `block_shape` - Specifies the block sizes of `batch` axis of `data` input which are moved to the corresponding spatial axes. A 1D tensor of type *T_INT* and shape `[N]`. All element values must be greater than or equal to 1.`block_shape[0]` is expected to be 1. **Required.** +* **3**: `crops_begin` - Specifies the amount to crop from the beginning along each axis of `data` input. A 1D tensor of type *T_INT* and shape `[N]`. All element values must be greater than or equal to 0. `crops_begin[0]` is expected to be 0. **Required.** +* **4**: `crops_end` - Specifies the amount to crop from the ending along each axis of `data` input. A 1D tensor of type *T_INT* and shape `[N]`. All element values must be greater than or equal to 0. `crops_end[0]` is expected to be 0. **Required.** +* **Note**: `N` corresponds to the rank of `data` input. +* **Note**: `batch` axis of `data` input must be evenly divisible by the cumulative product of `block_shape` elements. +* **Note**: It is required that `crops_begin[i] + crops_end[i] <= block_shape[i] * input_shape[i]`. **Outputs** -* **1**: N-D tensor with shape `[batch / (block_shape[0] * block_shape[1] * ... * block_shape[N - 1]), D_1 * block_shape[1] - crops_begin[1] - crops_end[1], D_2 * block_shape[2] - crops_begin[2] - crops_end[2], ..., D_{N - 1} * block_shape[N - 1] - crops_begin[N - 1] - crops_end[N - 1]` of the same type as `data` input. +* **1**: Permuted tensor of type *T* with the same rank as `data` input tensor, and shape `[batch / (block_shape[0] * block_shape[1] * ... * block_shape[N - 1]), D_1 * block_shape[1] - crops_begin[1] - crops_end[1], D_2 * block_shape[2] - crops_begin[2] - crops_end[2], ..., D_{N - 1} * block_shape[N - 1] - crops_begin[N - 1] - crops_end[N - 1]`. **Types** -* *T1*: any supported type. -* *T2*: any supported integer type. +* *T*: any supported type. +* *T_INT*: any supported integer type. + +**Examples** + +*Example: 2D input tensor `data`* + +```xml + + + + 10 + 2 + + + 2 + + + 2 + + + 2 + + + + + 2 + 8 + + + +``` -**Example** +*Example: 5D input tensor `data`* ```xml diff --git a/docs/template_plugin/src/CMakeLists.txt b/docs/template_plugin/src/CMakeLists.txt index e91b6f215860a4..a6411523780629 100644 --- a/docs/template_plugin/src/CMakeLists.txt +++ b/docs/template_plugin/src/CMakeLists.txt @@ -36,10 +36,8 @@ target_link_libraries(${TARGET_NAME} PRIVATE set_target_properties(${TARGET_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO}) # ATTENTION: uncomment to register a plugin in the plugins.xml file -if(ENABLE_TEMPLATE_PLUGIN) - ie_register_plugins(MAIN_TARGET ${TARGET_NAME} - POSSIBLE_PLUGINS ${TARGET_NAME}) -endif() +# ie_register_plugins(MAIN_TARGET ${TARGET_NAME} +# POSSIBLE_PLUGINS ${TARGET_NAME}) # [cmake:plugin] # ATTENTION: uncomment to install component diff --git a/docs/template_plugin/src/template_plugin.cpp b/docs/template_plugin/src/template_plugin.cpp index a0f7a30ee171cf..c92918983cdcfe 100644 --- a/docs/template_plugin/src/template_plugin.cpp +++ b/docs/template_plugin/src/template_plugin.cpp @@ -66,8 +66,17 @@ std::shared_ptr TransformNetwork(const std::shared_ptr(); - // Template plugin handles only FP32 networks - passManager.register_pass(precisions_array {{ngraph::element::f16, ngraph::element::f32}}); + // GAPI supports only FP32 networks for pre-processing + bool needF16toF32 = false; + for (const auto& param : function->get_parameters()) { + if (param->get_element_type() == ngraph::element::f16 && + inputInfoMap.at(param->get_friendly_name())->getTensorDesc().getPrecision() != InferenceEngine::Precision::FP16) { + needF16toF32 = true; + break; + } + } + if (needF16toF32) + passManager.register_pass(precisions_array {{ngraph::element::f16, ngraph::element::f32}}); // Example: register plugin specific transformation passManager.register_pass(); passManager.register_pass(); diff --git a/docs/template_plugin/tests/functional/op_reference/base_reference_test.cpp b/docs/template_plugin/tests/functional/op_reference/base_reference_test.cpp new file mode 100644 index 00000000000000..51af4d2ea1a221 --- /dev/null +++ b/docs/template_plugin/tests/functional/op_reference/base_reference_test.cpp @@ -0,0 +1,173 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// +#include "base_reference_test.hpp" + +#include + +#include "transformations/utils/utils.hpp" + +using namespace InferenceEngine; + +CommonReferenceTest::CommonReferenceTest(): targetDevice("TEMPLATE") { + core = PluginCache::get().ie(targetDevice); +} + +void CommonReferenceTest::Exec() { + LoadNetwork(); + FillInputs(); + Infer(); + Validate(); +} + +void CommonReferenceTest::LoadNetwork() { + InferenceEngine::CNNNetwork cnnNetwork(function); + auto inputInfo = cnnNetwork.getInputsInfo(); + auto outputInfo = cnnNetwork.getOutputsInfo(); + for (const auto& param : function->get_parameters()) { + inputInfo[param->get_friendly_name()]->setPrecision(InferenceEngine::details::convertPrecision(param->get_element_type())); + } + for (const auto& result : function->get_results()) { + outputInfo[ngraph::op::util::create_ie_output_name(result->input_value(0))]->setPrecision( + InferenceEngine::details::convertPrecision(result->get_element_type())); + } + executableNetwork = core->LoadNetwork(cnnNetwork, targetDevice); +} + +void CommonReferenceTest::FillInputs() { + const auto& inputInfo = executableNetwork.GetInputsInfo(); + const auto& params = function->get_parameters(); + ASSERT_EQ(params.size(), inputData.size()); + ASSERT_EQ(inputInfo.size(), inputData.size()); + + for (size_t i = 0; i < params.size(); i++) { + const auto& param = params[i]; + const auto infoIt = inputInfo.find(param->get_friendly_name()); + GTEST_ASSERT_NE(infoIt, inputInfo.cend()); + + const auto& info = infoIt->second; + auto blob = make_blob_with_precision(info->getTensorDesc()); + blob->allocate(); + + ASSERT_EQ(blob->byteSize(), inputData[i]->byteSize()); + + MemoryBlob::Ptr mInputData = as(inputData[i]); + ASSERT_NE(mInputData, nullptr); + auto minputDataHolder = mInputData->rmap(); + + MemoryBlob::Ptr mBlob = as(blob); + ASSERT_NE(mBlob, nullptr); + auto mBlobHolder = mBlob->wmap(); + + std::memcpy(mBlobHolder.as(), minputDataHolder.as(), inputData[i]->byteSize()); + inputData[i] = blob; + } +} + +void CommonReferenceTest::Infer() { + inferRequest = executableNetwork.CreateInferRequest(); + + const auto& inputsInfo = executableNetwork.GetInputsInfo(); + const auto& functionParams = function->get_parameters(); + for (size_t i = 0; i < functionParams.size(); ++i) { + const auto& param = functionParams[i]; + const auto infoIt = inputsInfo.find(param->get_friendly_name()); + GTEST_ASSERT_NE(infoIt, inputsInfo.cend()); + + const auto& info = infoIt->second; + auto blob = inputData[i]; + + inferRequest.SetBlob(info->name(), blob); + } + inferRequest.Infer(); +} + +void CommonReferenceTest::Validate() { + ASSERT_EQ(executableNetwork.GetOutputsInfo().size(), refOutData.size()); + std::vector outputs; + for (const auto& result : function->get_results()) { + auto name = ngraph::op::util::create_ie_output_name(result->input_value(0)); + outputs.emplace_back(inferRequest.GetBlob(name)); + } + + ASSERT_EQ(refOutData.size(), outputs.size()); + for (size_t i = 0; i < refOutData.size(); i++) { + ValidateBlobs(refOutData[i], outputs[i]); + } +} +void CommonReferenceTest::ValidateBlobs(const InferenceEngine::Blob::Ptr& refBlob, const InferenceEngine::Blob::Ptr& outBlob) { + ASSERT_TRUE(refBlob != nullptr); + ASSERT_TRUE(outBlob != nullptr); + ASSERT_EQ(refBlob->getTensorDesc().getPrecision(), outBlob->getTensorDesc().getPrecision()); + ASSERT_EQ(refBlob->byteSize(), outBlob->byteSize()); + + auto mRef = as(refBlob); + IE_ASSERT(mRef); + const auto refLockMemory = mRef->rmap(); + const auto refBuffer = refLockMemory.as(); + + auto mOut = as(outBlob); + IE_ASSERT(mOut); + const auto outLockMemory = mOut->rmap(); + const auto outBuffer = outLockMemory.as(); + + const auto& precision = refBlob->getTensorDesc().getPrecision(); + switch (precision) { + case InferenceEngine::Precision::BF16: + LayerTestsUtils::LayerTestsCommon::Compare( + reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), refBlob->size(), threshold); + break; + case InferenceEngine::Precision::FP16: + LayerTestsUtils::LayerTestsCommon::Compare( + reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), refBlob->size(), threshold); + break; + case InferenceEngine::Precision::FP32: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), + refBlob->size(), threshold); + break; + case InferenceEngine::Precision::I8: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), + refBlob->size(), threshold); + break; + case InferenceEngine::Precision::I16: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), + refBlob->size(), threshold); + break; + case InferenceEngine::Precision::I32: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), + refBlob->size(), threshold); + break; + case InferenceEngine::Precision::I64: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), + refBlob->size(), threshold); + break; + case InferenceEngine::Precision::BOOL: + case InferenceEngine::Precision::U8: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), + refBlob->size(), threshold); + break; + case InferenceEngine::Precision::U16: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), + reinterpret_cast(outBuffer), refBlob->size(), threshold); + break; + case InferenceEngine::Precision::U32: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), + reinterpret_cast(outBuffer), refBlob->size(), threshold); + break; + case InferenceEngine::Precision::U64: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), + reinterpret_cast(outBuffer), refBlob->size(), threshold); + break; + case InferenceEngine::Precision::I4: + case InferenceEngine::Precision::U4: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), + refBlob->size() / 2, threshold); + break; + case InferenceEngine::Precision::BIN: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), + refBlob->size() / 8, threshold); + break; + default: + FAIL() << "Comparator for " << precision << " precision isn't supported"; + } +} diff --git a/docs/template_plugin/tests/functional/op_reference/base_reference_test.hpp b/docs/template_plugin/tests/functional/op_reference/base_reference_test.hpp new file mode 100644 index 00000000000000..6e3fd942a9e722 --- /dev/null +++ b/docs/template_plugin/tests/functional/op_reference/base_reference_test.hpp @@ -0,0 +1,53 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include +#include +#include + +class CommonReferenceTest { +public: + CommonReferenceTest(); + + void Exec(); + + void LoadNetwork(); + + void FillInputs(); + + void Infer(); + + void Validate(); + +private: + void ValidateBlobs(const InferenceEngine::Blob::Ptr& refBlob, const InferenceEngine::Blob::Ptr& outBlob); + +protected: + const std::string targetDevice; + std::shared_ptr core; + std::shared_ptr function; + + InferenceEngine::ExecutableNetwork executableNetwork; + InferenceEngine::InferRequest inferRequest; + std::vector inputData; + std::vector refOutData; + float threshold = 1e-2f; +}; + +template +InferenceEngine::Blob::Ptr CreateBlob(const ngraph::element::Type& element_type, const std::vector& values, size_t size = 0) { + size_t real_size = size ? size : values.size() * sizeof(T) / element_type.size(); + auto blob = make_blob_with_precision( + InferenceEngine::TensorDesc(InferenceEngine::details::convertPrecision(element_type), {real_size}, InferenceEngine::Layout::C)); + blob->allocate(); + InferenceEngine::MemoryBlob::Ptr minput = InferenceEngine::as(blob); + IE_ASSERT(minput); + auto minputHolder = minput->wmap(); + + std::memcpy(minputHolder.as(), values.data(), std::min(real_size * element_type.size(), sizeof(T) * values.size())); + + return blob; +} + diff --git a/docs/template_plugin/tests/functional/op_reference/convert.cpp b/docs/template_plugin/tests/functional/op_reference/convert.cpp new file mode 100644 index 00000000000000..fb32fda4cbbfd8 --- /dev/null +++ b/docs/template_plugin/tests/functional/op_reference/convert.cpp @@ -0,0 +1,441 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include +#include +#include +#include +#include + +#include "base_reference_test.hpp" + +using namespace ngraph; +using namespace InferenceEngine; + +struct ConvertParams { + template + ConvertParams(const ngraph::PartialShape& shape, const ngraph::element::Type& iType, const ngraph::element::Type& oType, const std::vector& iValues, + const std::vector& oValues, size_t iSize = 0, size_t oSize = 0) + : pshape(shape), inType(iType), outType(oType), inputData(CreateBlob(iType, iValues, iSize)), refData(CreateBlob(oType, oValues, oSize)) {} + ngraph::PartialShape pshape; + ngraph::element::Type inType; + ngraph::element::Type outType; + InferenceEngine::Blob::Ptr inputData; + InferenceEngine::Blob::Ptr refData; +}; + +class ReferenceConvertLayerTest : public testing::TestWithParam, public CommonReferenceTest { +public: + void SetUp() override { + auto params = GetParam(); + function = CreateFunction(params.pshape, params.inType, params.outType); + inputData = {params.inputData}; + refOutData = {params.refData}; + } + static std::string getTestCaseName(const testing::TestParamInfo& obj) { + auto param = obj.param; + std::ostringstream result; + result << "shape=" << param.pshape << "_"; + result << "iType=" << param.inType << "_"; + result << "oType=" << param.outType; + return result.str(); + } + +private: + static std::shared_ptr CreateFunction(const PartialShape& input_shape, const element::Type& input_type, + const element::Type& expected_output_type) { + const auto in = std::make_shared(input_type, input_shape); + const auto convert = std::make_shared(in, expected_output_type); + return std::make_shared(NodeVector {convert}, ParameterVector {in}); + } +}; + +TEST_P(ReferenceConvertLayerTest, CompareWithHardcodedRefs) { + Exec(); +} + +INSTANTIATE_TEST_SUITE_P( + smoke_Convert_With_Hardcoded_Refs, ReferenceConvertLayerTest, + ::testing::Values( + // destination boolean + ConvertParams(ngraph::PartialShape {2, 3}, ngraph::element::u8, ngraph::element::boolean, + std::vector {0, 12, 23, 0, std::numeric_limits::lowest(), std::numeric_limits::max()}, + std::vector {0, 1, 1, 0, 0, 1}), + ConvertParams(ngraph::PartialShape {2, 3}, ngraph::element::i32, ngraph::element::boolean, + std::vector {0, -12, 23, 0, std::numeric_limits::lowest(), std::numeric_limits::max()}, + std::vector {0, 1, 1, 0, 1, 1}), + ConvertParams(ngraph::PartialShape {3, 3}, ngraph::element::f32, ngraph::element::boolean, + std::vector {0.f, 1.5745f, 0.12352f, 0.f, std::numeric_limits::lowest(), std::numeric_limits::max(), + std::numeric_limits::min(), std::numeric_limits::infinity(), -std::numeric_limits::infinity()}, + std::vector {0, 1, 1, 0, 1, 1, 1, 1, 1}), + + // destination bf16 + ConvertParams(ngraph::PartialShape {1, 1, 3, 5}, ngraph::element::f32, ngraph::element::bf16, + std::vector {0.5f, 1.5f, 0.5f, 2.5f, 1.5f, 0.5f, 3.5f, 2.5f, 0.5f, 0.5f, 2.5f, 0.5f, 0.5f, 0.5f, 1.5f}, + std::vector {0.5f, 1.5f, 0.5f, 2.5f, 1.5f, 0.5f, 3.5f, 2.5f, 0.5f, 0.5f, 2.5f, 0.5f, 0.5f, 0.5f, 1.5f}), + ConvertParams(ngraph::PartialShape {11}, ngraph::element::u8, ngraph::element::bf16, + std::vector {0, 10, 15, 20, 43, 56, 78, 99, 102, 130, 142}, + std::vector {0, 10, 15, 20, 43, 56, 78, 99, 102, 130, 142}), + + // destination f16 + ConvertParams(ngraph::PartialShape {1, 1, 3, 5}, ngraph::element::f32, ngraph::element::f16, + std::vector {0.5f, 1.5f, 0.5f, 2.5f, 1.5f, 0.5f, 3.5f, 2.5f, 0.5f, 0.5f, 2.5f, 0.5f, 0.5f, 0.5f, 1.5f}, + std::vector {0.5f, 1.5f, 0.5f, 2.5f, 1.5f, 0.5f, 3.5f, 2.5f, 0.5f, 0.5f, 2.5f, 0.5f, 0.5f, 0.5f, 1.5f}), + ConvertParams(ngraph::PartialShape {11}, ngraph::element::u8, ngraph::element::f16, std::vector {0, 10, 15, 20, 43, 56, 78, 99, 102, 130, 142}, + std::vector {0, 10, 15, 20, 43, 56, 78, 99, 102, 130, 142}), + + // destination f32 + ConvertParams(ngraph::PartialShape {2, 2}, ngraph::element::u1, ngraph::element::f32, std::vector {0xA0}, + std::vector {1.0f, 0.0f, 1.0f, 0.0f}, 4), + ConvertParams(ngraph::PartialShape {2, 2}, ngraph::element::u4, ngraph::element::f32, std::vector {0xFB, 0x0A}, + std::vector {15.0f, 11.0f, 0.0f, 10.0f}, 4), + ConvertParams(ngraph::PartialShape {2, 2}, ngraph::element::u8, ngraph::element::f32, std::vector {255, 128, 32, 0}, + std::vector {255.0f, 128.0f, 32.0f, 0.0f}), + ConvertParams(ngraph::PartialShape {2, 2}, ngraph::element::u16, ngraph::element::f32, std::vector {64000, 32000, 128, 0}, + std::vector {64000.0f, 32000.0f, 128.0f, 0.0f}), + ConvertParams(ngraph::PartialShape {2, 2}, ngraph::element::u32, ngraph::element::f32, std::vector {4000000, 2000000, 128, 0}, + std::vector {4000000.0f, 2000000.0f, 128.0f, 0.0f}), + ConvertParams(ngraph::PartialShape {2, 2}, ngraph::element::u64, ngraph::element::f32, std::vector {4000000, 2000000, 128, 0}, + std::vector {4000000.0f, 2000000.0f, 128.0f, 0.0f}), + ConvertParams(ngraph::PartialShape {2, 2}, ngraph::element::i4, ngraph::element::f32, std::vector {0xFE, 0xF2}, + std::vector {-1.0f, -2.0f, -1.0f, 2.0f}, 4), + ConvertParams(ngraph::PartialShape {2, 2}, ngraph::element::i8, ngraph::element::f32, std::vector {-127, -0, 0, 127}, + std::vector {-127.0f, -0.0f, 0.0f, 127.0f}), + ConvertParams(ngraph::PartialShape {2, 2}, ngraph::element::i16, ngraph::element::f32, std::vector {-32000, -0, 0, 32000}, + std::vector {-32000.0f, -0.0f, 0.0f, 32000.0f}), + ConvertParams(ngraph::PartialShape {2, 2}, ngraph::element::i32, ngraph::element::f32, std::vector {-64000, -0, 0, 64000}, + std::vector {-64000.0f, -0.0f, 0.0f, 64000.0f}), + ConvertParams(ngraph::PartialShape {2, 2}, ngraph::element::i64, ngraph::element::f32, std::vector {-64000, -0, 0, 64000}, + std::vector {-64000.0f, -0.0f, 0.0f, 64000.0f}), + ConvertParams(ngraph::PartialShape {1, 1, 3, 5}, ngraph::element::bf16, ngraph::element::f32, + std::vector {0.5f, 1.5f, 0.5f, 2.5f, 1.5f, 0.5f, 3.5f, 2.5f, 0.5f, 0.5f, 2.5f, 0.5f, 0.5f, 0.5f, 1.5f}, + std::vector {0.5f, 1.5f, 0.5f, 2.5f, 1.5f, 0.5f, 3.5f, 2.5f, 0.5f, 0.5f, 2.5f, 0.5f, 0.5f, 0.5f, 1.5f}), + ConvertParams(ngraph::PartialShape {1, 1, 3, 5}, ngraph::element::f16, ngraph::element::f32, + std::vector {0.5f, 1.5f, 0.5f, 2.5f, 1.5f, 0.5f, 3.5f, 2.5f, 0.5f, 0.5f, 2.5f, 0.5f, 0.5f, 0.5f, 1.5f}, + std::vector {0.5f, 1.5f, 0.5f, 2.5f, 1.5f, 0.5f, 3.5f, 2.5f, 0.5f, 0.5f, 2.5f, 0.5f, 0.5f, 0.5f, 1.5f}), + ConvertParams(ngraph::PartialShape {1, 1, 3, 5}, ngraph::element::f32, ngraph::element::f32, + std::vector {0.5f, 1.5f, 0.5f, 2.5f, 1.5f, 0.5f, 3.5f, 2.5f, 0.5f, 0.5f, 2.5f, 0.5f, 0.5f, 0.5f, 1.5f}, + std::vector {0.5f, 1.5f, 0.5f, 2.5f, 1.5f, 0.5f, 3.5f, 2.5f, 0.5f, 0.5f, 2.5f, 0.5f, 0.5f, 0.5f, 1.5f}), + + // destination i4 + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u1, ngraph::element::i4, std::vector {0xA0}, std::vector {0x10, 0x10}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u4, ngraph::element::i4, std::vector {0x12, 0x03}, std::vector {0x12, 0x03}, + 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u8, ngraph::element::i4, std::vector {1, 2, 0, 3}, std::vector {0x12, 0x03}, + 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u16, ngraph::element::i4, std::vector {1, 2, 0, 3}, + std::vector {0x12, 0x03}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u32, ngraph::element::i4, std::vector {1, 2, 0, 3}, + std::vector {0x12, 0x03}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u64, ngraph::element::i4, std::vector {1, 2, 0, 3}, + std::vector {0x12, 0x03}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i4, ngraph::element::i4, std::vector {0xFE, 0x03}, std::vector {0xFE, 0x03}, + 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i8, ngraph::element::i4, std::vector {-1, -2, 2, 3}, std::vector {0xFE, 0x23}, + 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i16, ngraph::element::i4, std::vector {-1, -2, 2, 3}, + std::vector {0xFE, 0x23}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i32, ngraph::element::i4, std::vector {-1, -2, 2, 3}, + std::vector {0xFE, 0x23}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i64, ngraph::element::i4, std::vector {-1, -2, 2, 3}, + std::vector {0xFE, 0x23}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f16, ngraph::element::i4, std::vector {-1, -2, 0, 3}, + std::vector {0xFE, 0x03}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::bf16, ngraph::element::i4, std::vector {-1, -2, 0, 3}, + std::vector {0xFE, 0x03}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f32, ngraph::element::i4, std::vector {-1, -2, 2, 3}, std::vector {0xFE, 0x23}, + 4, 4), + // destination i8 + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u1, ngraph::element::i8, std::vector {0x81}, + std::vector {1, 0, 0, 0, 0, 0, 0, 1}, 8), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u4, ngraph::element::i8, std::vector {0x21, 0x43}, std::vector {2, 1, 4, 3}, + 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u8, ngraph::element::i8, std::vector {1, 2, 0, 3}, std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u16, ngraph::element::i8, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u32, ngraph::element::i8, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u64, ngraph::element::i8, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i4, ngraph::element::i8, std::vector {0x21, 0x43}, std::vector {2, 1, 4, 3}, + 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i8, ngraph::element::i8, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i16, ngraph::element::i8, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i32, ngraph::element::i8, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i64, ngraph::element::i8, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f16, ngraph::element::i8, std::vector {-1, -2, 0, 3}, + std::vector {-1, -2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::bf16, ngraph::element::i8, std::vector {-1, -2, 0, 3}, + std::vector {-1, -2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f32, ngraph::element::i8, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + // destination i16 + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u1, ngraph::element::i16, std::vector {0x81}, + std::vector {1, 0, 0, 0, 0, 0, 0, 1}, 8), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u4, ngraph::element::i16, std::vector {0x21, 0x43}, std::vector {2, 1, 4, 3}, + 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u8, ngraph::element::i16, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u16, ngraph::element::i16, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u32, ngraph::element::i16, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u64, ngraph::element::i16, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i4, ngraph::element::i16, std::vector {0x21, 0x43}, std::vector {2, 1, 4, 3}, + 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i8, ngraph::element::i16, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i16, ngraph::element::i16, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i32, ngraph::element::i16, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i64, ngraph::element::i16, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f16, ngraph::element::i16, std::vector {-1, -2, 0, 3}, + std::vector {-1, -2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::bf16, ngraph::element::i16, std::vector {-1, -2, 0, 3}, + std::vector {-1, -2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f32, ngraph::element::i16, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + // destination i32 + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u1, ngraph::element::i32, std::vector {0x81}, + std::vector {1, 0, 0, 0, 0, 0, 0, 1}, 8), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u4, ngraph::element::i32, std::vector {0x21, 0x43}, std::vector {2, 1, 4, 3}, + 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u8, ngraph::element::i32, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u16, ngraph::element::i32, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u32, ngraph::element::i32, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u64, ngraph::element::i32, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i4, ngraph::element::i32, std::vector {0x21, 0x43}, std::vector {2, 1, 4, 3}, + 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i8, ngraph::element::i32, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i16, ngraph::element::i32, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i32, ngraph::element::i32, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i64, ngraph::element::i32, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f16, ngraph::element::i32, std::vector {-1, -2, 0, 3}, + std::vector {-1, -2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::bf16, ngraph::element::i32, std::vector {-1, -2, 0, 3}, + std::vector {-1, -2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f32, ngraph::element::i32, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + // destination i64 + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u1, ngraph::element::i64, std::vector {0x81}, + std::vector {1, 0, 0, 0, 0, 0, 0, 1}, 8), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u4, ngraph::element::i64, std::vector {0x21, 0x43}, std::vector {2, 1, 4, 3}, + 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u8, ngraph::element::i64, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u16, ngraph::element::i64, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u32, ngraph::element::i64, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u64, ngraph::element::i64, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i4, ngraph::element::i64, std::vector {0x21, 0x43}, std::vector {2, 1, 4, 3}, + 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i8, ngraph::element::i64, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i16, ngraph::element::i64, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i32, ngraph::element::i64, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i64, ngraph::element::i64, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f16, ngraph::element::i64, std::vector {-1, -2, 0, 3}, + std::vector {-1, -2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::bf16, ngraph::element::i64, std::vector {-1, -2, 0, 3}, + std::vector {-1, -2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f32, ngraph::element::i64, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + + // destination u1 + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u1, ngraph::element::u1, std::vector {0xA0}, std::vector {0xA0}, 8, 8), + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u4, ngraph::element::u1, std::vector {0x10, 0x01, 0x00, 0x00}, + std::vector {0x90}, 8, 8), + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u8, ngraph::element::u1, std::vector {1, 0, 1, 0, 0, 0, 0, 1}, + std::vector {0xA1}, 8, 8), + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u16, ngraph::element::u1, std::vector {1, 0, 1, 0, 0, 0, 0, 1}, + std::vector {0xA1}, 8, 8), + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u32, ngraph::element::u1, std::vector {1, 0, 1, 0, 0, 0, 0, 1}, + std::vector {0xA1}, 8, 8), + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u64, ngraph::element::u1, std::vector {1, 0, 1, 0, 0, 0, 0, 1}, + std::vector {0xA1}, 8, 8), + ConvertParams(ngraph::PartialShape {8}, ngraph::element::i4, ngraph::element::u1, std::vector {0x10, 0x01, 0x00, 0x00}, + std::vector {0x90}, 8, 8), + ConvertParams(ngraph::PartialShape {8}, ngraph::element::i8, ngraph::element::u1, std::vector {1, 0, 1, 0, 0, 0, 0, 1}, + std::vector {0xA1}, 8, 8), + ConvertParams(ngraph::PartialShape {8}, ngraph::element::i16, ngraph::element::u1, std::vector {1, 0, 1, 0, 0, 0, 0, 1}, + std::vector {0xA1}, 8, 8), + ConvertParams(ngraph::PartialShape {8}, ngraph::element::i32, ngraph::element::u1, std::vector {1, 0, 1, 0, 0, 0, 0, 1}, + std::vector {0xA1}, 8, 8), + ConvertParams(ngraph::PartialShape {8}, ngraph::element::i64, ngraph::element::u1, std::vector {1, 0, 1, 0, 0, 0, 0, 1}, + std::vector {0xA1}, 8, 8), + ConvertParams(ngraph::PartialShape {8}, ngraph::element::f16, ngraph::element::u1, std::vector {1, 0, 1, 0, 0, 0, 0, 1}, + std::vector {0xA1}, 8, 8), + ConvertParams(ngraph::PartialShape {8}, ngraph::element::bf16, ngraph::element::u1, std::vector {1, 0, 1, 0, 0, 0, 0, 1}, + std::vector {0xA1}, 8, 8), + ConvertParams(ngraph::PartialShape {8}, ngraph::element::f32, ngraph::element::u1, std::vector {1, 0, 1, 0, 0, 0, 0, 1}, + std::vector {0xA1}, 8, 8), + + // destination u4 + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u1, ngraph::element::u4, std::vector {0xA0}, std::vector {0x10, 0x10}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u4, ngraph::element::u4, std::vector {0x12, 0x03}, std::vector {0x12, 0x03}, + 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u8, ngraph::element::u4, std::vector {1, 2, 0, 3}, std::vector {0x12, 0x03}, + 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u16, ngraph::element::u4, std::vector {1, 2, 0, 3}, + std::vector {0x12, 0x03}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u32, ngraph::element::u4, std::vector {1, 2, 0, 3}, + std::vector {0x12, 0x03}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u64, ngraph::element::u4, std::vector {1, 2, 0, 3}, + std::vector {0x12, 0x03}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i4, ngraph::element::u4, std::vector {0xFE, 0x03}, std::vector {0xFE, 0x03}, + 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i8, ngraph::element::u4, std::vector {-1, -2, 2, 3}, std::vector {0xFE, 0x23}, + 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i16, ngraph::element::u4, std::vector {-1, -2, 2, 3}, + std::vector {0xFE, 0x23}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i32, ngraph::element::u4, std::vector {-1, -2, 2, 3}, + std::vector {0xFE, 0x23}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i64, ngraph::element::u4, std::vector {-1, -2, 2, 3}, + std::vector {0xFE, 0x23}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f16, ngraph::element::u4, std::vector {-1, -2, 0, 3}, + std::vector {0xFE, 0x03}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::bf16, ngraph::element::u4, std::vector {-1, -2, 0, 3}, + std::vector {0xFE, 0x03}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f32, ngraph::element::u4, std::vector {-1, -2, 2, 3}, std::vector {0xFE, 0x23}, + 4, 4), + + // destination u8 + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u1, ngraph::element::u8, std::vector {0x81}, + std::vector {1, 0, 0, 0, 0, 0, 0, 1}, 8), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u4, ngraph::element::u8, std::vector {0x21, 0x43}, std::vector {2, 1, 4, 3}, + 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u8, ngraph::element::u8, std::vector {1, 2, 0, 3}, std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u16, ngraph::element::u8, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u32, ngraph::element::u8, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u64, ngraph::element::u8, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i4, ngraph::element::u8, std::vector {0x21, 0x43}, std::vector {2, 1, 4, 3}, + 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i8, ngraph::element::u8, std::vector {1, 2, 2, 3}, std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i16, ngraph::element::u8, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i32, ngraph::element::u8, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i64, ngraph::element::u8, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f16, ngraph::element::u8, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::bf16, ngraph::element::u8, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f32, ngraph::element::u8, std::vector {1, 2, 2, 3}, std::vector {1, 2, 2, 3}), + + // destination u16 + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u1, ngraph::element::u16, std::vector {0x81}, + std::vector {1, 0, 0, 0, 0, 0, 0, 1}, 8), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u4, ngraph::element::u16, std::vector {0x21, 0x43}, + std::vector {2, 1, 4, 3}, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u8, ngraph::element::u16, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u16, ngraph::element::u16, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u32, ngraph::element::u16, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u64, ngraph::element::u16, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i4, ngraph::element::u16, std::vector {0x21, 0x43}, + std::vector {2, 1, 4, 3}, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i8, ngraph::element::u16, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i16, ngraph::element::u16, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i32, ngraph::element::u16, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i64, ngraph::element::u16, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f16, ngraph::element::u16, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::bf16, ngraph::element::u16, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f32, ngraph::element::u16, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + + // destination u32 + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u1, ngraph::element::u32, std::vector {0x81}, + std::vector {1, 0, 0, 0, 0, 0, 0, 1}, 8), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u4, ngraph::element::u32, std::vector {0x21, 0x43}, + std::vector {2, 1, 4, 3}, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u8, ngraph::element::u32, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u16, ngraph::element::u32, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u32, ngraph::element::u32, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u64, ngraph::element::u32, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i4, ngraph::element::u32, std::vector {0x21, 0x43}, + std::vector {2, 1, 4, 3}, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i8, ngraph::element::u32, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i16, ngraph::element::u32, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i32, ngraph::element::u32, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i64, ngraph::element::u32, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f16, ngraph::element::u32, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::bf16, ngraph::element::u32, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f32, ngraph::element::u32, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + + // destination u64 + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u1, ngraph::element::u64, std::vector {0x81}, + std::vector {1, 0, 0, 0, 0, 0, 0, 1}, 8), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u4, ngraph::element::u64, std::vector {0x21, 0x43}, + std::vector {2, 1, 4, 3}, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u8, ngraph::element::u64, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u16, ngraph::element::u64, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u32, ngraph::element::u64, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u64, ngraph::element::u64, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i4, ngraph::element::u64, std::vector {0x21, 0x43}, + std::vector {2, 1, 4, 3}, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i8, ngraph::element::u64, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i16, ngraph::element::u64, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i32, ngraph::element::u64, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i64, ngraph::element::u64, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f16, ngraph::element::u64, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::bf16, ngraph::element::u64, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f32, ngraph::element::u64, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3})), + ReferenceConvertLayerTest::getTestCaseName); diff --git a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/core_integration.cpp b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/core_integration.cpp index 2c067aaf7b68ab..60ffbf048934e6 100644 --- a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/core_integration.cpp +++ b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/core_integration.cpp @@ -73,7 +73,7 @@ using IEClassSetConfigTestHETERO = IEClassNetworkTest; TEST_F(IEClassSetConfigTestHETERO, smoke_SetConfigNoThrow) { { - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(ie.SetConfig({{HETERO_CONFIG_KEY(DUMP_GRAPH_DOT), CONFIG_VALUE(YES)}}, "HETERO")); @@ -84,7 +84,7 @@ TEST_F(IEClassSetConfigTestHETERO, smoke_SetConfigNoThrow) { } { - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(ie.SetConfig({{HETERO_CONFIG_KEY(DUMP_GRAPH_DOT), CONFIG_VALUE(NO)}}, "HETERO")); @@ -95,7 +95,7 @@ TEST_F(IEClassSetConfigTestHETERO, smoke_SetConfigNoThrow) { } { - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(ie.GetMetric("HETERO", METRIC_KEY(SUPPORTED_CONFIG_KEYS))); @@ -118,7 +118,7 @@ INSTANTIATE_TEST_SUITE_P( using IEClassGetConfigTestTEMPLATE = IEClassNetworkTest; TEST_F(IEClassGetConfigTestTEMPLATE, smoke_GetConfigNoThrow) { - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; std::string deviceName = CommonTestUtils::DEVICE_TEMPLATE; @@ -209,4 +209,4 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE)); #endif // ENABLE_MKL_DNN -} // namespace \ No newline at end of file +} // namespace diff --git a/inference-engine/ie_bridges/c/src/ie_c_api.cpp b/inference-engine/ie_bridges/c/src/ie_c_api.cpp index 4346047c1b54fa..3b581db0abbbef 100644 --- a/inference-engine/ie_bridges/c/src/ie_c_api.cpp +++ b/inference-engine/ie_bridges/c/src/ie_c_api.cpp @@ -235,9 +235,8 @@ IEStatusCode ie_core_create(const char *xml_config_file, ie_core_t **core) { IEStatusCode status = IEStatusCode::OK; try { - std::unique_ptr tmp(new ie_core_t); - tmp->object = IE::Core(xml_config_file); - *core = tmp.release(); + auto object = IE::Core(xml_config_file); + *core = new ie_core_t { std::move(object) }; } CATCH_IE_EXCEPTIONS return status; diff --git a/inference-engine/ie_bridges/python/CMakeLists.txt b/inference-engine/ie_bridges/python/CMakeLists.txt index 89cdb5cc17f9fe..7b93a4291a2d3a 100644 --- a/inference-engine/ie_bridges/python/CMakeLists.txt +++ b/inference-engine/ie_bridges/python/CMakeLists.txt @@ -68,7 +68,7 @@ if(ENABLE_WHEEL) add_subdirectory(wheel) endif() -if (NGRAPH_PYTHON_BUILD_ENABLE) +if(TARGET _pyngraph) add_dependencies(ie_api _pyngraph) endif() diff --git a/inference-engine/ie_bridges/python/README.md b/inference-engine/ie_bridges/python/README.md index 0b50a0e2a6a938..b40a6ded9b048d 100644 --- a/inference-engine/ie_bridges/python/README.md +++ b/inference-engine/ie_bridges/python/README.md @@ -61,11 +61,6 @@ sudo apt install patchelf -DENABLE_PYTHON=ON -DENABLE_WHEEL=ON ``` -If you need to include other components to the package you need to enable them too. -For example, to include ngraph python API: -```shellscript --NGRAPH_PYTHON_BUILD_ENABLE=ON -``` ## Running sample diff --git a/inference-engine/ie_bridges/python/wheel/setup.py b/inference-engine/ie_bridges/python/wheel/setup.py index dc177be7d31375..5d9ca16238a68b 100644 --- a/inference-engine/ie_bridges/python/wheel/setup.py +++ b/inference-engine/ie_bridges/python/wheel/setup.py @@ -7,6 +7,7 @@ import errno import subprocess # nosec import typing +from fnmatch import fnmatchcase from pathlib import Path from shutil import copyfile, rmtree from distutils.command.install import install @@ -120,6 +121,16 @@ class CustomBuild(build): def run(self): self.run_command('build_clib') build.run(self) + # Copy extra package_data content filtered by find_packages + dst = Path(self.build_lib) + src = Path(get_package_dir(PY_INSTALL_CFG)) + exclude = ignore_patterns('*ez_setup*', '*__pycache__*', '*.egg-info*') + for path in src.glob('**/*'): + if path.is_dir() or exclude(str(path)): + continue + path_rel = path.relative_to(src) + (dst / path_rel.parent).mkdir(exist_ok=True, parents=True) + copyfile(path, dst / path_rel) class CustomInstall(install): @@ -215,6 +226,13 @@ def run(self): clean.run(self) +def ignore_patterns(*patterns): + """ + Filter names by given patterns + """ + return lambda name: any(fnmatchcase(name, pat=pat) for pat in patterns) + + def is_tool(name): """Check if the command-line tool is available""" try: @@ -348,8 +366,7 @@ def get_package_dir(install_cfg): if os.path.exists(package_license): copyfile(package_license, 'LICENSE') - -packages = find_namespace_packages(','.join(get_dir_list(PY_INSTALL_CFG))) +packages = find_namespace_packages(get_package_dir(PY_INSTALL_CFG)) package_data: typing.Dict[str, list] = {} setup( diff --git a/inference-engine/include/cpp/ie_cnn_network.h b/inference-engine/include/cpp/ie_cnn_network.h index 9e21a470d456e4..1fe5d2173f2267 100644 --- a/inference-engine/include/cpp/ie_cnn_network.h +++ b/inference-engine/include/cpp/ie_cnn_network.h @@ -199,6 +199,22 @@ class INFERENCE_ENGINE_API_CLASS(CNNNetwork) { */ void serialize(const std::string& xmlPath, const std::string& binPath = {}) const; + /** + * @brief Serialize network to IR and weights streams. + * + * @param xmlBuf output IR stream. + * @param binBuf output weights stream. + */ + void serialize(std::ostream& xmlBuf, std::ostream& binBuf) const; + + /** + * @brief Serialize network to IR stream and weights Blob::Ptr. + * + * @param xmlBuf output IR stream. + * @param binBlob output weights Blob::Ptr. + */ + void serialize(std::ostream& xmlBuf, Blob::Ptr& binBlob) const; + /** * @brief Method maps framework tensor name to OpenVINO name * @param orig_name Framework tensor name diff --git a/inference-engine/include/cpp/ie_executable_network.hpp b/inference-engine/include/cpp/ie_executable_network.hpp index 81d5b10e7dd4be..870f6c2a6fcd96 100644 --- a/inference-engine/include/cpp/ie_executable_network.hpp +++ b/inference-engine/include/cpp/ie_executable_network.hpp @@ -66,7 +66,6 @@ class INFERENCE_ENGINE_API_CLASS(ExecutableNetwork) { * This method need to be called to find out input names for using them later * when calling InferenceEngine::InferRequest::SetBlob * - * @param inputs Reference to InferenceEngine::ConstInputsDataMap object. * @return A collection that contains string as key, and const InputInfo smart pointer as value */ ConstInputsDataMap GetInputsInfo() const; diff --git a/inference-engine/include/cpp/ie_infer_request.hpp b/inference-engine/include/cpp/ie_infer_request.hpp index c5d52ec6fc0905..94393cea06225f 100644 --- a/inference-engine/include/cpp/ie_infer_request.hpp +++ b/inference-engine/include/cpp/ie_infer_request.hpp @@ -235,6 +235,9 @@ class INFERENCE_ENGINE_API_CLASS(InferRequest) { bool operator==(const InferRequest&) const noexcept; }; +/** + * @private + */ template<> struct InferRequest::SetCallback> { void operator()(std::function f) { @@ -245,6 +248,9 @@ struct InferRequest::SetCallback> IE_SUPPRESS_DEPRECATED_START +/** + * @private + */ template<> struct InferRequest::SetCallback { void operator()(IInferRequest::CompletionCallback f) { diff --git a/inference-engine/include/gpu/gpu_context_api_dx.hpp b/inference-engine/include/gpu/gpu_context_api_dx.hpp index 5f94db0595dcca..1a529e56c78009 100644 --- a/inference-engine/include/gpu/gpu_context_api_dx.hpp +++ b/inference-engine/include/gpu/gpu_context_api_dx.hpp @@ -106,8 +106,8 @@ class D3DSurface2DBlob : public ClImage2DBlob { } /** - * @brief Returns plane ID of underlying video decoder surface, - * or 0 if no video surface was shared. + * @brief Returns plane ID of underlying video decoder surface, or 0 if no video surface was shared. + * @return Plane ID */ uint32_t plane() { return _ObjFromParams(getParams(), diff --git a/inference-engine/include/gpu/gpu_context_api_ocl.hpp b/inference-engine/include/gpu/gpu_context_api_ocl.hpp index a39446b0368640..357b58d163b29d 100644 --- a/inference-engine/include/gpu/gpu_context_api_ocl.hpp +++ b/inference-engine/include/gpu/gpu_context_api_ocl.hpp @@ -39,6 +39,7 @@ class ClContext : public RemoteContext, public details::param_map_obj_getter { /** * @brief Returns the underlying OpenCL context handle. + * @return `cl_context` */ cl_context get() { return _ObjFromParams(getParams(), GPU_PARAM_KEY(OCL_CONTEXT), @@ -47,7 +48,7 @@ class ClContext : public RemoteContext, public details::param_map_obj_getter { /** * @brief OpenCL context handle conversion operator for the ClContext object. - * @return Underlying OpenCL context handle + * @return `cl_context` */ operator cl_context() { return get(); @@ -55,7 +56,7 @@ class ClContext : public RemoteContext, public details::param_map_obj_getter { /** * @brief Standard Khronos cl::Context wrapper conversion operator for the ClContext object. - * @return cl::Context object + * @return `cl::Context` object */ operator cl::Context() { return cl::Context(get(), true); @@ -101,6 +102,7 @@ class ClBufferBlob : public ClBlob, public details::param_map_obj_getter { /** * @brief Returns the underlying OpenCL memory object handle. + * @return underlying OpenCL memory object handle */ cl_mem get() { return _ObjFromParams(getParams(), GPU_PARAM_KEY(MEM_HANDLE), @@ -109,6 +111,7 @@ class ClBufferBlob : public ClBlob, public details::param_map_obj_getter { /** * @brief OpenCL memory handle conversion operator. + * @return `cl_mem` */ operator cl_mem() { return get(); @@ -116,7 +119,7 @@ class ClBufferBlob : public ClBlob, public details::param_map_obj_getter { /** * @brief Standard Khronos cl::Buffer wrapper conversion operator. - * @return cl::Buffer object + * @return `cl::Buffer` object */ operator cl::Buffer() { return cl::Buffer(get(), true); @@ -144,6 +147,7 @@ class ClImage2DBlob : public ClBlob, public details::param_map_obj_getter { /** * @brief Returns the underlying OpenCL memory object handle. + * @return `cl_mem` */ cl_mem get() { return _ObjFromParams(getParams(), GPU_PARAM_KEY(MEM_HANDLE), @@ -152,6 +156,7 @@ class ClImage2DBlob : public ClBlob, public details::param_map_obj_getter { /** * @brief OpenCL memory handle conversion operator. + * @return `cl_mem` */ operator cl_mem() { return get(); @@ -159,7 +164,7 @@ class ClImage2DBlob : public ClBlob, public details::param_map_obj_getter { /** * @brief Standard Khronos cl::Image2D wrapper conversion operator for the ClContext object. - * @return cl::Image2D object + * @return `cl::Image2D` object */ operator cl::Image2D() { return cl::Image2D(get(), true); @@ -269,7 +274,7 @@ static inline Blob::Ptr make_shared_blob(const TensorDesc& desc, RemoteContext:: * @brief This function is used to obtain remote blob object from user-supplied cl::Image2D wrapper object * @param desc A tensor descriptor object representing remote blob configuration * @param ctx A remote context used to create remote blob - * @param buffer A cl::Image2D object wrapped by a remote blob + * @param image A cl::Image2D object wrapped by a remote blob * @return A remote blob instance */ static inline Blob::Ptr make_shared_blob(const TensorDesc& desc, RemoteContext::Ptr ctx, cl::Image2D& image) { diff --git a/inference-engine/include/gpu/gpu_context_api_va.hpp b/inference-engine/include/gpu/gpu_context_api_va.hpp index 6e2bedacf625be..0784c729db134d 100644 --- a/inference-engine/include/gpu/gpu_context_api_va.hpp +++ b/inference-engine/include/gpu/gpu_context_api_va.hpp @@ -22,22 +22,22 @@ namespace InferenceEngine { namespace gpu { /** -* @brief This class represents an abstraction for GPU plugin remote context -* which is shared with VA display object. -* The plugin object derived from this class can be obtained either with -* GetContext() method of Executable network or using CreateContext() Core call. -* @note User can also obtain OpenCL context handle from this class. -*/ + * @brief This class represents an abstraction for GPU plugin remote context + * which is shared with VA display object. + * The plugin object derived from this class can be obtained either with + * GetContext() method of Executable network or using CreateContext() Core call. + * @note User can also obtain OpenCL context handle from this class. + */ class VAContext : public ClContext { public: /** - * @brief A smart pointer to the VAContext object - */ + * @brief A smart pointer to the VAContext object + */ using Ptr = std::shared_ptr; /** - * @brief VADisplay conversion operator for the VAContext object. - * @return Underlying VADisplay object handle + * @brief `VADisplay` conversion operator for the VAContext object. + * @return Underlying `VADisplay` object handle */ operator VADisplay() { return _ObjFromParams(getParams(), @@ -47,16 +47,16 @@ class VAContext : public ClContext { }; /** -* @brief This class represents an abstraction for GPU plugin remote blob -* which is shared with VA output surface. -* The plugin object derived from this class can be obtained with CreateBlob() call. -* @note User can also obtain OpenCL 2D image handle from this class. -*/ + * @brief This class represents an abstraction for GPU plugin remote blob + * which is shared with VA output surface. + * The plugin object derived from this class can be obtained with CreateBlob() call. + * @note User can also obtain OpenCL 2D image handle from this class. + */ class VASurfaceBlob : public ClImage2DBlob { public: /** - * @brief A smart pointer to the VASurfaceBlob object - */ + * @brief A smart pointer to the VASurfaceBlob object + */ using Ptr = std::shared_ptr; /** @@ -67,7 +67,7 @@ class VASurfaceBlob : public ClImage2DBlob { /** * @brief VASurfaceID conversion operator for the VASurfaceBlob object. - * @return VA surface handle + * @return `VASurfaceID` handle */ operator VASurfaceID() { return _ObjFromParams(getParams(), @@ -77,6 +77,7 @@ class VASurfaceBlob : public ClImage2DBlob { /** * @brief Returns plane ID of underlying video decoder surface + * @return Plane ID */ uint32_t plane() { return _ObjFromParams(getParams(), @@ -86,11 +87,16 @@ class VASurfaceBlob : public ClImage2DBlob { }; /** -* @brief This function is used to obtain a NV12 compound blob object from NV12 VA decoder output. -* The resulting compound contains two remote blobs for Y and UV planes of the surface. -*/ + * @brief This function is used to obtain a NV12 compound blob object from NV12 VA decoder output. + * The resulting compound contains two remote blobs for Y and UV planes of the surface. + * @param height A height of Y plane + * @param width A width of Y plane + * @param ctx A remote context instance + * @param nv12_surf NV12 `VASurfaceID` to create NV12 from + * @return A remote NV12 blob wrapping `VASurfaceID` + */ static inline Blob::Ptr make_shared_blob_nv12(size_t height, size_t width, RemoteContext::Ptr ctx, VASurfaceID nv12_surf) { - // despite of layout, blob dimensions always follow in N,C,H,W order + // despite of layout, blob dimensions always follow in N, C, H, W order TensorDesc ydesc(Precision::U8, { 1, 1, height, width }, Layout::NHWC); ParamMap blobParams = { { GPU_PARAM_KEY(SHARED_MEM_TYPE), GPU_PARAM_VALUE(VA_SURFACE) }, @@ -107,8 +113,12 @@ static inline Blob::Ptr make_shared_blob_nv12(size_t height, size_t width, Remot } /** -* @brief This function is used to obtain remote context object from VA display handle -*/ + * @brief This function is used to obtain remote context object from VA display handle + * @param core Inference Engine Core object + * @param deviceName A device name to create a remote context for + * @param device A `VADisplay` to create remote context from + * @return A remote context wrapping `VADisplay` + */ static inline VAContext::Ptr make_shared_context(Core& core, std::string deviceName, VADisplay device) { ParamMap contextParams = { { GPU_PARAM_KEY(CONTEXT_TYPE), GPU_PARAM_VALUE(VA_SHARED) }, @@ -118,8 +128,13 @@ static inline VAContext::Ptr make_shared_context(Core& core, std::string deviceN } /** -* @brief This function is used to obtain remote blob object from VA surface handle -*/ + * @brief This function is used to obtain remote blob object from VA surface handle + * @param desc Tensor descriptor + * @param ctx A remote context instance + * @param surface A `VASurfaceID` to create remote blob from + * @param plane An index of a plane inside `VASurfaceID` to create blob from + * @return A remote blob wrapping `VASurfaceID` + */ static inline VASurfaceBlob::Ptr make_shared_blob(const TensorDesc& desc, RemoteContext::Ptr ctx, VASurfaceID surface, uint32_t plane = 0) { auto casted = std::dynamic_pointer_cast(ctx); if (nullptr == casted) { diff --git a/inference-engine/include/gpu/gpu_ocl_wrapper.hpp b/inference-engine/include/gpu/gpu_ocl_wrapper.hpp index 31f77f93e0cc12..496f0974ad51e1 100644 --- a/inference-engine/include/gpu/gpu_ocl_wrapper.hpp +++ b/inference-engine/include/gpu/gpu_ocl_wrapper.hpp @@ -11,8 +11,8 @@ #pragma once /** -* @brief Definitions required by Khronos headers -*/ + * @brief Definitions required by Khronos headers + */ #ifndef CL_HPP_ENABLE_EXCEPTIONS # define CL_HPP_ENABLE_EXCEPTIONS diff --git a/inference-engine/include/gpu/gpu_params.hpp b/inference-engine/include/gpu/gpu_params.hpp index f7ccc86dcb0271..eac4cd3f409bd4 100644 --- a/inference-engine/include/gpu/gpu_params.hpp +++ b/inference-engine/include/gpu/gpu_params.hpp @@ -44,63 +44,65 @@ namespace GPUContextParams { #define DECLARE_GPU_PARAM_KEY(name, ...) \ static constexpr auto PARAM_##name = #name /** -* @brief Shared device context type: can be either pure OpenCL (OCL) -* or shared video decoder (VA_SHARED) context -*/ + * @brief Shared device context type: can be either pure OpenCL (OCL) + * or shared video decoder (VA_SHARED) context + */ DECLARE_GPU_PARAM_KEY(CONTEXT_TYPE, std::string); /** -* @brief Pure OpenCL device context -*/ + * @brief Pure OpenCL device context + */ DECLARE_GPU_PARAM_VALUE(OCL); /** -* @brief Shared context (video decoder or D3D) -*/ + * @brief Shared context (video decoder or D3D) + */ DECLARE_GPU_PARAM_VALUE(VA_SHARED); /** -* @brief This key identifies OpenCL context handle -* in a shared context or shared memory blob parameter map -*/ + * @brief This key identifies OpenCL context handle + * in a shared context or shared memory blob parameter map + */ DECLARE_GPU_PARAM_KEY(OCL_CONTEXT, gpu_handle_param); /** -* @brief This key identifies video acceleration device/display handle -* in a shared context or shared memory blob parameter map -*/ + * @brief This key identifies video acceleration device/display handle + * in a shared context or shared memory blob parameter map + */ DECLARE_GPU_PARAM_KEY(VA_DEVICE, gpu_handle_param); /** -* @brief This key identifies type of internal shared memory -* in a shared memory blob parameter map. -*/ + * @brief This key identifies type of internal shared memory + * in a shared memory blob parameter map. + */ DECLARE_GPU_PARAM_KEY(SHARED_MEM_TYPE, std::string); /** -* @brief Shared OpenCL buffer blob -*/ + * @brief Shared OpenCL buffer blob + */ DECLARE_GPU_PARAM_VALUE(OCL_BUFFER); /** -* @brief Shared OpenCL 2D image blob -*/ + * @brief Shared OpenCL 2D image blob + */ DECLARE_GPU_PARAM_VALUE(OCL_IMAGE2D); + /** -* @brief Shared video decoder surface or D3D 2D texture blob -*/ + * @brief Shared video decoder surface or D3D 2D texture blob + */ DECLARE_GPU_PARAM_VALUE(VA_SURFACE); + /** -* @brief Shared D3D buffer blob -*/ + * @brief Shared D3D buffer blob + */ DECLARE_GPU_PARAM_VALUE(DX_BUFFER); /** -* @brief This key identifies OpenCL memory handle -* in a shared memory blob parameter map -*/ + * @brief This key identifies OpenCL memory handle + * in a shared memory blob parameter map + */ DECLARE_GPU_PARAM_KEY(MEM_HANDLE, gpu_handle_param); /** -* @brief This key identifies video decoder surface handle -* in a shared memory blob parameter map -*/ + * @brief This key identifies video decoder surface handle + * in a shared memory blob parameter map + */ #ifdef _WIN32 DECLARE_GPU_PARAM_KEY(DEV_OBJECT_HANDLE, gpu_handle_param); #else @@ -108,9 +110,9 @@ DECLARE_GPU_PARAM_KEY(DEV_OBJECT_HANDLE, uint32_t); #endif /** -* @brief This key identifies video decoder surface plane -* in a shared memory blob parameter map -*/ + * @brief This key identifies video decoder surface plane + * in a shared memory blob parameter map + */ DECLARE_GPU_PARAM_KEY(VA_PLANE, uint32_t); } // namespace GPUContextParams diff --git a/inference-engine/include/ie_blob.h b/inference-engine/include/ie_blob.h index 3463ec18218f59..2342d4cbcf5bf8 100644 --- a/inference-engine/include/ie_blob.h +++ b/inference-engine/include/ie_blob.h @@ -304,6 +304,7 @@ class INFERENCE_ENGINE_API_CLASS(MemoryBlob): public Blob { /** * @brief Returns the tensor description + * @return A tensor description */ const TensorDesc& getTensorDesc() const noexcept override { return tensorDesc; @@ -311,6 +312,7 @@ class INFERENCE_ENGINE_API_CLASS(MemoryBlob): public Blob { /** * @brief Returns the tensor description + * @return A tensor description */ TensorDesc& getTensorDesc() noexcept override { return tensorDesc; @@ -333,12 +335,9 @@ class INFERENCE_ENGINE_API_CLASS(MemoryBlob): public Blob { return size() * element_size(); } - /** - * @brief Provides the number of bytes per element. - * Abstract method. - * @return The number of bytes per element. - */ - size_t element_size() const noexcept override = 0; + size_t element_size() const noexcept override { + return tensorDesc.getPrecision().size(); + } /** * @brief Allocates memory to store the data. @@ -395,7 +394,7 @@ class INFERENCE_ENGINE_API_CLASS(MemoryBlob): public Blob { * * @return A LockedMemory object */ - virtual LockedMemory rwmap()noexcept = 0; + virtual LockedMemory rwmap() noexcept = 0; /** * @brief Gets read only access to the memory in virtual space of the process. @@ -419,7 +418,7 @@ class INFERENCE_ENGINE_API_CLASS(MemoryBlob): public Blob { * * @return A LockedMemory object */ - virtual LockedMemory rmap()const noexcept = 0; + virtual LockedMemory rmap() const noexcept = 0; /** * @brief Gets "write only direction" access to the memory in virtual space of the process. @@ -446,7 +445,7 @@ class INFERENCE_ENGINE_API_CLASS(MemoryBlob): public Blob { * * @return A LockedMemory object */ - virtual LockedMemory wmap()noexcept = 0; + virtual LockedMemory wmap() noexcept = 0; protected: /** @@ -567,15 +566,6 @@ class TBlob : public MemoryBlob { */ virtual ~TBlob(); - /** - * @brief Gets the size of the given type. - * - * @return Size of the type - */ - size_t element_size() const noexcept override { - return sizeof(T); - } - /** * @brief Creates an new empty rvalue LockedMemory object. * @@ -594,9 +584,6 @@ class TBlob : public MemoryBlob { return std::move(lockme()); } - /** - * @brief Allocates or reallocates memory - */ void allocate() noexcept override { const auto allocator = getAllocator(); const auto rawHandle = allocator->alloc(byteSize()); @@ -612,27 +599,14 @@ class TBlob : public MemoryBlob { }); } - /** - * @brief Frees all allocated data - */ bool deallocate() noexcept override { return free(); } - /** - * @brief Creates a new LockedMemory instance holding void pointer. - * - * @return LockedMemory instance holding void pointer - */ LockedMemory buffer() noexcept override { return std::move(lockme()); } - /** - * @brief Creates a new LockedMemory instance holding constant void pointer. - * - * @return LockedMemory instance holding constant void pointer - */ LockedMemory cbuffer() const noexcept override { return std::move(lockme()); } @@ -734,6 +708,7 @@ class TBlob : public MemoryBlob { /** * @brief Frees handler and cleans up the stored data. + * @return `true` if memory was freed */ virtual bool free() { bool bCanRelease = _handle != nullptr; @@ -753,11 +728,6 @@ class TBlob : public MemoryBlob { // getTensorDesc().getBlockingDesc().getOffsetPadding()); } - /** - * @brief Gets an allocator or creates a default one. - * - * @return IAllocator instance - */ const std::shared_ptr& getAllocator() const noexcept override { // in case when constructor without allocator was used if (!_allocator) { @@ -767,9 +737,6 @@ class TBlob : public MemoryBlob { return _allocator; } - /** - * @brief Returns handle to the stored data. - */ void* getHandle() const noexcept override { return _handle.get(); } diff --git a/inference-engine/include/ie_compound_blob.h b/inference-engine/include/ie_compound_blob.h index 70889b9937d92c..8a0aae67c23060 100644 --- a/inference-engine/include/ie_compound_blob.h +++ b/inference-engine/include/ie_compound_blob.h @@ -73,16 +73,19 @@ class INFERENCE_ENGINE_API_CLASS(CompoundBlob): public Blob { /** * @brief Always returns an empty LockedMemory object + * @return Empty locked memory */ LockedMemory buffer() noexcept override; /** * @brief Always returns an empty LockedMemory object + * @return Empty locked memory */ LockedMemory cbuffer() const noexcept override; /** * @brief Returns the number of underlying blobs in the compound blob + * @return A number of underlying blobs */ size_t size() const noexcept override; @@ -109,9 +112,6 @@ class INFERENCE_ENGINE_API_CLASS(CompoundBlob): public Blob { */ std::vector _blobs; - /** - * @brief Returns nullptr as CompoundBlob is not allocator-based - */ const std::shared_ptr& getAllocator() const noexcept override; }; @@ -148,21 +148,25 @@ class INFERENCE_ENGINE_API_CLASS(NV12Blob): public CompoundBlob { /** * @brief Returns a shared pointer to Y plane + * @return Y plane */ virtual Blob::Ptr& y() noexcept; /** * @brief Returns a shared pointer to Y plane + * @return Y plane */ virtual const Blob::Ptr& y() const noexcept; /** * @brief Returns a shared pointer to UV plane + * @return UV plane */ virtual Blob::Ptr& uv() noexcept; /** * @brief Returns a shared pointer to UV plane + * @return UV plane */ virtual const Blob::Ptr& uv() const noexcept; diff --git a/inference-engine/include/ie_data.h b/inference-engine/include/ie_data.h index 618c1f86d0a7c1..f3c83720aea593 100644 --- a/inference-engine/include/ie_data.h +++ b/inference-engine/include/ie_data.h @@ -93,6 +93,7 @@ class INFERENCE_ENGINE_API_CLASS(Data) { /** * @brief Gets the layout value for this Data instance + * @return Layout */ Layout getLayout() const; diff --git a/inference-engine/include/ie_icnn_network.hpp b/inference-engine/include/ie_icnn_network.hpp index 6e42b5ea402d99..ec640691eccb91 100644 --- a/inference-engine/include/ie_icnn_network.hpp +++ b/inference-engine/include/ie_icnn_network.hpp @@ -200,6 +200,32 @@ class INFERENCE_ENGINE_API_CLASS(ICNNNetwork): public std::enable_shared_from_th virtual StatusCode serialize(const std::string& xmlPath, const std::string& binPath, ResponseDesc* resp) const noexcept = 0; + /** + * @deprecated Use InferenceEngine::CNNNetwork wrapper instead + * @brief Serialize network to IR and weights files. + * + * @param xmlStream A stream for xml content (.xml file) + * @param binStream A stream for weights content (.bin file) + * @param resp Pointer to the response message that holds a description of an error if any occurred + * @return Status code of the operation + */ + INFERENCE_ENGINE_DEPRECATED("Use InferenceEngine::CNNNetwork wrapper instead") + virtual StatusCode serialize(std::ostream& xmlStream, std::ostream& binStream, ResponseDesc* resp) const + noexcept = 0; + + /** + * @deprecated Use InferenceEngine::CNNNetwork wrapper instead + * @brief Serialize network to IR and weights files. + * + * @param xmlStream A stream for xml content (.xml file) + * @param binData A blob for weights content (.bin file) + * @param resp Pointer to the response message that holds a description of an error if any occurred + * @return Status code of the operation + */ + INFERENCE_ENGINE_DEPRECATED("Use InferenceEngine::CNNNetwork wrapper instead") + virtual StatusCode serialize(std::ostream& xmlStream, Blob::Ptr& binData, ResponseDesc* resp) const + noexcept = 0; + /** * @deprecated Use InferenceEngine::CNNNetwork wrapper instead * @brief Methods maps framework tensor name to OpenVINO name diff --git a/inference-engine/include/ie_plugin_config.hpp b/inference-engine/include/ie_plugin_config.hpp index 6cbd1e29ae9a8a..9c2dd68e46fe71 100644 --- a/inference-engine/include/ie_plugin_config.hpp +++ b/inference-engine/include/ie_plugin_config.hpp @@ -264,9 +264,9 @@ DECLARE_CONFIG_VALUE(HYBRID_AWARE); * (and what is the optimal number of streams) * - finally, specifying the positive integer value creates the requested number of streams */ +DECLARE_CONFIG_KEY(CPU_THROUGHPUT_STREAMS); DECLARE_CONFIG_VALUE(CPU_THROUGHPUT_NUMA); DECLARE_CONFIG_VALUE(CPU_THROUGHPUT_AUTO); -DECLARE_CONFIG_KEY(CPU_THROUGHPUT_STREAMS); /** * @brief The name for setting performance counters option. diff --git a/inference-engine/include/ie_precision.hpp b/inference-engine/include/ie_precision.hpp index e72a8248f0082d..28a7cf36abc62a 100644 --- a/inference-engine/include/ie_precision.hpp +++ b/inference-engine/include/ie_precision.hpp @@ -91,21 +91,24 @@ class Precision { precisionInfo.value = CUSTOM; } - /** @brief Creates custom precision with specific underlined type */ + /** + * @brief Creates custom precision with specific underlined type + * @param typeName A string name of precision + * @return Precision converted from string name + */ template static Precision fromType(const char* typeName = nullptr) { return Precision(8 * sizeof(T), typeName == nullptr ? typeid(T).name() : typeName); } - /** @brief checks whether given storage class T can be used to store objects of current precision */ + /** + * @brief checks whether given storage class T can be used to store objects of current precision + * @param typeName A string name of precision + * @return `true` if `typeName` has underlaying storage type + */ template bool hasStorageType(const char* typeName = nullptr) const noexcept { try { - if (precisionInfo.value != BIN) { - if (sizeof(T) != size()) { - return false; - } - } #define CASE(x, y) \ case x: \ return std::is_same() @@ -239,14 +242,14 @@ class Precision { } /** - * @brief Returns size of single element of that precision in bits + * @brief Returns size of single element of that precision in bytes * @returns Number of bytes per element */ size_t size() const { if (precisionInfo.bitsSize == 0) { IE_THROW() << " cannot estimate element if precision is " << precisionInfo.name; } - return precisionInfo.bitsSize >> 3; + return (precisionInfo.bitsSize + 7) / 8; } /** @@ -453,7 +456,7 @@ inline Precision::PrecisionInfo Precision::makePrecisionInfo(const char* name) { Precision::PrecisionInfo info; info.name = name; - size_t nBits = precision == BIN ? 1 : 8; + size_t nBits = precision == BIN ? 1 : (precision == U4 || precision == I4) ? 4 : 8; info.bitsSize = nBits * type_size_or_zero::value_type>(); info.isFloat = PrecisionTrait::is_float; info.value = precision; diff --git a/inference-engine/include/ie_remote_context.hpp b/inference-engine/include/ie_remote_context.hpp index 376459b4a9d99f..a6116fe6c0db12 100644 --- a/inference-engine/include/ie_remote_context.hpp +++ b/inference-engine/include/ie_remote_context.hpp @@ -46,13 +46,6 @@ class RemoteBlob : public MemoryBlob { */ explicit RemoteBlob(const TensorDesc& tensorDesc): MemoryBlob(tensorDesc) {} - /** - * @brief Returns the number of bytes per element. - */ - size_t element_size() const noexcept override { - return tensorDesc.getPrecision().size(); - } - /** * @brief Returns a map of device-specific parameters required for low-level * operations with underlying object. @@ -197,3 +190,4 @@ inline RemoteBlob::Ptr make_shared_blob(const TensorDesc& desc, RemoteContext::P } } // namespace InferenceEngine + diff --git a/inference-engine/samples/common/format_reader/CMakeLists.txt b/inference-engine/samples/common/format_reader/CMakeLists.txt index eb6c7cbe7e046b..f4a3dfd0c7dd61 100644 --- a/inference-engine/samples/common/format_reader/CMakeLists.txt +++ b/inference-engine/samples/common/format_reader/CMakeLists.txt @@ -13,7 +13,7 @@ source_group("src" FILES ${LIBRARY_SRC}) source_group("include" FILES ${LIBRARY_HEADERS}) # Create library file from sources. -add_library(${TARGET_NAME} SHARED EXCLUDE_FROM_ALL ${MAIN_SRC} ${LIBRARY_HEADERS}) +add_library(${TARGET_NAME} SHARED ${MAIN_SRC} ${LIBRARY_HEADERS}) # Find OpenCV components if exist find_package(OpenCV COMPONENTS core imgproc imgcodecs QUIET) @@ -39,4 +39,4 @@ set_target_properties(${TARGET_NAME} PROPERTIES COMPILE_PDB_NAME ${TARGET_NAME} if(COMMAND add_clang_format_target) add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME}) -endif() \ No newline at end of file +endif() diff --git a/inference-engine/src/auto_plugin/auto_infer_request.cpp b/inference-engine/src/auto_plugin/auto_infer_request.cpp index 9ed24a49ed8024..1497ee3557b449 100644 --- a/inference-engine/src/auto_plugin/auto_infer_request.cpp +++ b/inference-engine/src/auto_plugin/auto_infer_request.cpp @@ -78,7 +78,6 @@ void AutoInferRequest::HotSwapRequests() { InferenceEngine::SoExecutableNetworkInternal tempSoExecNetwork; if (_autoExecutableNetwork->TryGetActualNetwork(tempSoExecNetwork)) { _alreadyActualNetwork = true; - std::cout << "!!! DEBUG: HotSwapRequests !!!" << std::endl; _inferRequest = {tempSoExecNetwork, tempSoExecNetwork->CreateInferRequest()}; _inferRequest->SetCallback(_callback); } diff --git a/inference-engine/src/auto_plugin/auto_plugin.cpp b/inference-engine/src/auto_plugin/auto_plugin.cpp index 1b5bb70f8f697a..94b6a8a8b71794 100644 --- a/inference-engine/src/auto_plugin/auto_plugin.cpp +++ b/inference-engine/src/auto_plugin/auto_plugin.cpp @@ -84,14 +84,11 @@ std::shared_ptr AutoInferencePlugin::LoadNetworkImpl(cons [core, modelPath, network](const std::string& device) -> IE::SoExecutableNetworkInternal { IE::SoExecutableNetworkInternal executableNetwork; - std::cout << "!!! DEBUG: Starting Async loading to the " << device << " !!!" << std::endl; - std::cout << "!!! DEBUG: device full name: " << core->GetMetric(device, METRIC_KEY(FULL_DEVICE_NAME)).as() << std::endl; if (!modelPath.empty()) { executableNetwork = core->LoadNetwork(modelPath, device, {}); } else { executableNetwork = core->LoadNetwork(network, device, {}); } - std::cout << "!!! DEBUG: " << device << " was loaded !!!" << std::endl; return executableNetwork; }; diff --git a/inference-engine/src/cldnn_engine/cldnn_engine.cpp b/inference-engine/src/cldnn_engine/cldnn_engine.cpp index 5b3b90eb832597..72a34dd855af48 100644 --- a/inference-engine/src/cldnn_engine/cldnn_engine.cpp +++ b/inference-engine/src/cldnn_engine/cldnn_engine.cpp @@ -61,6 +61,7 @@ #include #include #include +#include #include #include #include diff --git a/inference-engine/src/cldnn_engine/cldnn_primitives_list.hpp b/inference-engine/src/cldnn_engine/cldnn_primitives_list.hpp index c0445c650729ed..e562447189b6c7 100644 --- a/inference-engine/src/cldnn_engine/cldnn_primitives_list.hpp +++ b/inference-engine/src/cldnn_engine/cldnn_primitives_list.hpp @@ -208,5 +208,8 @@ REGISTER_FACTORY(v6, MVN); // ------------------------------ Supported v7 ops ------------------------------ // REGISTER_FACTORY(v7, Gather); +// ------------------------------ Supported v8 ops ------------------------------ // +REGISTER_FACTORY(v8, Gather); + // --------------------------- Supported internal ops --------------------------- // REGISTER_FACTORY(internal, NonMaxSuppressionIEInternal); diff --git a/inference-engine/src/cldnn_engine/ops/gather.cpp b/inference-engine/src/cldnn_engine/ops/gather.cpp index 362854cc32aaeb..d22258e0673261 100644 --- a/inference-engine/src/cldnn_engine/ops/gather.cpp +++ b/inference-engine/src/cldnn_engine/ops/gather.cpp @@ -57,8 +57,8 @@ static cldnn::gather::gather_axis GetGatherAxis(int32_t axis, cldnn::format inpu } } -void CreateGatherOp(Program& p, const std::shared_ptr& op) { - p.ValidateInputs(op, {2, 3}); +template +void CreateGatherOpBase(Program& p, const std::shared_ptr& op, const int64_t batch_dim = 0, bool support_neg_ind = false) { auto inputPrimitives = p.GetInputPrimitiveIDs(op); std::string layerName = layer_type_name_ID(op); @@ -92,55 +92,33 @@ void CreateGatherOp(Program& p, const std::shared_ptr& o reorderedInputs[1], GetGatherAxis(axis, DefaultFormatForDims(op->get_input_shape(0).size())), outLayout, - CldnnTensorFromIEDims(op->get_output_shape(0))); + CldnnTensorFromIEDims(op->get_output_shape(0)), + batch_dim, + support_neg_ind); p.AddPrimitive(gatherPrim); p.AddPrimitiveToProfiler(op); } +void CreateGatherOp(Program& p, const std::shared_ptr& op) { + p.ValidateInputs(op, {2, 3}); + CreateGatherOpBase(p, op); +} + REGISTER_FACTORY_IMPL(v1, Gather); void CreateGatherOp(Program& p, const std::shared_ptr& op) { p.ValidateInputs(op, {2, 3, 4}); - auto inputPrimitives = p.GetInputPrimitiveIDs(op); - std::string layerName = layer_type_name_ID(op); - - int32_t axis = static_cast(op->get_axis()); - - std::vector reorderedInputs; - reorderedInputs.resize(inputPrimitives.size()); - - for (size_t portIndex = 0; portIndex < inputPrimitives.size(); portIndex++) { - auto inputDataType = DataTypeFromPrecision(op->get_input_element_type(portIndex)); - if (inputDataType == cldnn::data_types::i64) { - // clDNN primitive does not support i64 inputs, - // so we need additional reorders to convert them to i32 - auto reorderPrimName = inputPrimitives[portIndex] + "_" + op->get_friendly_name() + Program::m_preProcessTag; - auto targetFormat = DefaultFormatForDims(op->get_input_shape(portIndex).size()); - auto preprocessPrim = cldnn::reorder(reorderPrimName, - inputPrimitives[portIndex], - targetFormat, - cldnn::data_types::i32); - p.AddPrimitive(preprocessPrim); - p.AddInnerPrimitiveToProfiler(reorderPrimName, layerName, op); - reorderedInputs[portIndex] = reorderPrimName; - } else { - reorderedInputs[portIndex] = inputPrimitives[portIndex]; - } - } + CreateGatherOpBase(p, op, op->get_batch_dims()); +} - auto outLayout = DefaultFormatForDims(op->get_output_shape(0).size()); - auto gatherPrim = cldnn::gather(layerName, - reorderedInputs[0], - reorderedInputs[1], - GetGatherAxis(axis, DefaultFormatForDims(op->get_input_shape(0).size())), - outLayout, - CldnnTensorFromIEDims(op->get_output_shape(0)), - op->get_batch_dims()); +REGISTER_FACTORY_IMPL(v7, Gather); - p.AddPrimitive(gatherPrim); - p.AddPrimitiveToProfiler(op); +void CreateGatherOp(Program& p, const std::shared_ptr& op) { + p.ValidateInputs(op, {2, 3, 4}); + CreateGatherOpBase(p, op, op->get_batch_dims(), true); } -REGISTER_FACTORY_IMPL(v7, Gather); +REGISTER_FACTORY_IMPL(v8, Gather); + } // namespace CLDNNPlugin diff --git a/inference-engine/src/gna_plugin/backend/am_intel_dnn.cpp b/inference-engine/src/gna_plugin/backend/am_intel_dnn.cpp index 6b7774ce4029e1..a3a64c1605b0e0 100644 --- a/inference-engine/src/gna_plugin/backend/am_intel_dnn.cpp +++ b/inference-engine/src/gna_plugin/backend/am_intel_dnn.cpp @@ -25,6 +25,7 @@ #include "dnn_types.h" #include "gna_types.h" #include "gna_limitations.hpp" +#include "layers/gna_convolution_layer.hpp" #if GNA_LIB_VER == 2 #include @@ -50,6 +51,9 @@ using namespace GNAPluginNS::backend; +using GNAPluginNS::GNAConvolutionLayer::outputFromConv; +using GNAPluginNS::GNAConvolutionLayer::outputFromPooling; +using GNAPluginNS::GNAConvolutionLayer::outputFromPoolingLegacy; void GNAPluginNS::backend::AMIntelDNN::BeginNewWrite(uint32_t index) { dump_write_index = index; @@ -152,8 +156,7 @@ void GNAPluginNS::backend::AMIntelDNN::InitConvolutional1DComponentPrivate(intel uint32_t num_bytes_per_bias, uint32_t num_filters, uint32_t num_filter_coefficients, - uint32_t num_feature_map_rows, - uint32_t num_feature_map_columns, + const uint32_t convStride, float weight_scale_factor, float output_scale_factor, void *&ptr_inputs, @@ -177,8 +180,7 @@ void GNAPluginNS::backend::AMIntelDNN::InitConvolutional1DComponentPrivate(intel comp.op.conv1D.num_bytes_per_bias = num_bytes_per_bias; comp.op.conv1D.num_filters = num_filters; comp.op.conv1D.num_filter_coefficients = num_filter_coefficients; - comp.op.conv1D.num_feature_map_rows = num_feature_map_rows; - comp.op.conv1D.num_feature_map_columns = num_feature_map_columns; + comp.op.conv1D.convStride = convStride; comp.op.conv1D.weight_scale_factor = weight_scale_factor; comp.output_scale_factor = output_scale_factor; comp.input_scale_factor = output_scale_factor / weight_scale_factor; @@ -195,18 +197,17 @@ void GNAPluginNS::backend::AMIntelDNN::InitConvolutional1DComponentPrivate(intel ptr_outputs = &comp.ptr_outputs; } - if (comp.num_columns_in % 8 != 0) { - THROW_GNA_EXCEPTION << "Number of inputs to Convolutional1DComponent (" << comp.num_columns_in << + if (num_columns_in % 8 != 0) { + THROW_GNA_EXCEPTION << "Number of inputs to Convolutional1DComponent (" << num_columns_in << ") is not a multiply by 8"; } - if (comp.op.conv1D.num_filters < GNALimitations::convMinFiltersNum || - comp.op.conv1D.num_filters > GNALimitations::convMaxFiltersNum || - comp.op.conv1D.num_filters % GNALimitations::convFiltersNumDivider != 0) { - THROW_GNA_EXCEPTION << "Unsupported number of filters in Convolutional1DComponent: " << comp.op.conv1D.num_filters; + if (num_filters < GNALimitations::convMinFiltersNum || + num_filters > GNALimitations::convMaxFiltersNum || + num_filters % GNALimitations::convFiltersNumDivider != 0) { + THROW_GNA_EXCEPTION << "Unsupported number of filters in Convolutional1DComponent: " << num_filters; } - auto filter_stride_size = comp.op.conv1D.num_feature_map_columns; - auto max_number_of_out_elements = (comp.num_columns_in - comp.op.conv1D.num_filter_coefficients) / filter_stride_size + 1; - if (comp.num_columns_out / max_number_of_out_elements != comp.op.conv1D.num_filters) { + auto max_number_of_out_elements = outputFromConv(num_columns_in, num_filter_coefficients, convStride); + if (num_columns_out / max_number_of_out_elements != num_filters) { THROW_GNA_EXCEPTION << "Number of outputs or feature map config is incorrect in Convolutional1DComponent"; } } @@ -538,8 +539,7 @@ void GNAPluginNS::backend::AMIntelDNN::WriteGraphWizModel(const char *filename) auto &conv = components[k].op.conv1D; graph << " num_filters" << conv.num_filters<< "\n"; graph << " num_filter_coefficients" << conv.num_filter_coefficients<< "\n"; - graph << " num_feature_map_rows" << conv.num_feature_map_rows<< "\n"; - graph << " num_feature_map_columns" << conv.num_feature_map_columns<< "\n"; + graph << " conv_stride" << conv.convStride<< "\n"; graph << " wscale" << conv.weight_scale_factor<< "\n"; graph << " wbit" << conv.num_bytes_per_weight<< "\n"; graph << " bbit" << conv.num_bytes_per_bias<< "\n"; @@ -936,16 +936,14 @@ void GNAPluginNS::backend::AMIntelDNN::WriteDnnText(const char *filename, intel_ case kDnnConvolutional1dOp: { uint32_t num_filters = component[i].op.conv1D.num_filters; uint32_t num_filter_coefficients = component[i].op.conv1D.num_filter_coefficients; - uint32_t num_feature_map_rows = component[i].op.conv1D.num_feature_map_rows; - uint32_t num_feature_map_columns = component[i].op.conv1D.num_feature_map_columns; + const auto convStride = component[i].op.conv1D.convStride; uint32_t num_bytes_per_weight = component[i].op.conv1D.num_bytes_per_weight; uint32_t num_bytes_per_bias = component[i].op.conv1D.num_bytes_per_bias; float weight_scale_factor = component[i].op.conv1D.weight_scale_factor; float output_scale_factor = component[i].output_scale_factor; out_file << " " << std::dec << num_filters << "\n"; out_file << " " << std::dec << num_filter_coefficients << "\n"; - out_file << " " << std::dec << num_feature_map_rows << "\n"; - out_file << " " << std::dec << num_feature_map_columns << "\n"; + out_file << " " << std::dec << convStride << "\n"; if ((compute_precision_ == kDnnInt) && (logging_precision == kDnnFloat)) { out_file << " " << std::dec << 4 << "\n"; out_file << " " << std::dec << 4 << "\n"; @@ -1362,35 +1360,6 @@ uint32_t GNAPluginNS::backend::AMIntelDNN::CountLayers() { return n; } -namespace { -uint32_t outputFromConv(const uint32_t in, const uint32_t flt, const uint32_t stride) { - // floor[(in - flt)/stride] + 1, GNA Spec 1.24 - if (flt > in || flt == 0 || stride == 0) { - THROW_GNA_EXCEPTION << "Invalid (input, filter, stride) = (" << in << "," << flt << "," << stride << ")"; - } - return (in - flt) / stride + 1; -} - -uint32_t outputFromPooling(const uint32_t in, const uint32_t window, const uint32_t stride) { - // ceil[(in - window)/stride] + 1, GNA Spec 1.24 - if (window > in || window == 0 || stride == 0) { - THROW_GNA_EXCEPTION << "Invalid (input, window, stride) = (" << in << "," << window << "," << stride << ")"; - } - if (window == in) return 1; - - return (in - window - 1) / stride + 2; -} - -uint32_t outputFromPoolingLegacy(const uint32_t in, const uint32_t stride) { - // floor[(in - 1)/stride] + 1, GNA 1.0/2.0 HW Spec - if (in == 0 || stride == 0) { - THROW_GNA_EXCEPTION << "Invalid (input, stride) = (" << in << "," << stride << ")"; - } - return (in - 1) / stride + 1; -} - -} // namespace - #if GNA_LIB_VER == 2 void GNAPluginNS::backend::AMIntelDNN::InitGNAStruct(Gna2Model *gnaModel) { Gna2Operation * gnaOperation; @@ -1593,7 +1562,7 @@ void GNAPluginNS::backend::AMIntelDNN::InitGNAStruct(intel_nnet_type_t *ptr_nnet comp.op.conv1D.ptr_biases), nullptr, create_shape1D_parameter( - comp.op.conv1D.num_feature_map_columns), + comp.op.conv1D.convStride), nullptr, nullptr); @@ -1619,11 +1588,11 @@ void GNAPluginNS::backend::AMIntelDNN::InitGNAStruct(intel_nnet_type_t *ptr_nnet pConvolutionalLayer->nBytesBias = component[i].op.conv1D.num_bytes_per_bias; pConvolutionalLayer->nBytesFilterCoefficient = component[i].op.conv1D.num_bytes_per_weight; pConvolutionalLayer->nFilters = component[i].op.conv1D.num_filters; - pConvolutionalLayer->nFilterRows = comp.op.conv1D.num_filter_coefficients / comp.op.conv1D.num_feature_map_columns; + pConvolutionalLayer->nFilterRows = comp.op.conv1D.num_filter_coefficients / comp.op.conv1D.convStride; pConvolutionalLayer->nFilterCoefficients = component[i].op.conv1D.num_filter_coefficients; pConvolutionalLayer->nFeatureMaps = 1; - pConvolutionalLayer->nFeatureMapRows = component[i].op.conv1D.num_feature_map_rows; - pConvolutionalLayer->nFeatureMapColumns = component[i].op.conv1D.num_feature_map_columns; + pConvolutionalLayer->nFeatureMapColumns = component[i].op.conv1D.convStride; + pConvolutionalLayer->nFeatureMapRows = pLayer->nInputColumns / pConvolutionalLayer->nFeatureMapColumns; pConvolutionalLayer->poolType = INTEL_NO_POOLING; // will be overwritten pConvolutionalLayer->nPoolSize = 0; // will be overwritten pConvolutionalLayer->nPoolStride = 0; // will be overwritten @@ -1750,8 +1719,7 @@ void GNAPluginNS::backend::AMIntelDNN::InitGNAStruct(intel_nnet_type_t *ptr_nnet auto fltStrideSz = pConvolutionalLayer->nFeatureMaps * pConvolutionalLayer->nFeatureMapColumns; // always move 1 "row" auto outFromConv = outputFromConv(pLayer->nInputColumns, nFltSize, fltStrideSz); // FLAT input matrix, pooled outputs per filter - // TODO: Issue 50386 check why (outFromConv - 1) an not (outFromConv - nPoolSize) - pLayer->nOutputColumns = pConvolutionalLayer->nFilters * ((outFromConv - 1) / pConvolutionalLayer->nPoolStride + 1); + pLayer->nOutputColumns = pConvolutionalLayer->nFilters * outputFromPoolingLegacy(outFromConv, pConvolutionalLayer->nPoolStride); } #endif } else { diff --git a/inference-engine/src/gna_plugin/backend/am_intel_dnn.hpp b/inference-engine/src/gna_plugin/backend/am_intel_dnn.hpp index c4020a2bec9725..7dcab94a685870 100644 --- a/inference-engine/src/gna_plugin/backend/am_intel_dnn.hpp +++ b/inference-engine/src/gna_plugin/backend/am_intel_dnn.hpp @@ -97,8 +97,7 @@ class AMIntelDNN { uint32_t num_bytes_per_bias, uint32_t num_filters, uint32_t num_filter_coefficients, - uint32_t num_feature_map_rows, - uint32_t num_feature_map_columns, + uint32_t convStride, float weight_scale_factor, float output_scale_factor, A *&ptr_inputs, @@ -114,8 +113,7 @@ class AMIntelDNN { num_bytes_per_bias, num_filters, num_filter_coefficients, - num_feature_map_rows, - num_feature_map_columns, + convStride, weight_scale_factor, output_scale_factor, (void *&) ptr_inputs, @@ -428,8 +426,7 @@ class AMIntelDNN { uint32_t num_bytes_per_bias, uint32_t num_filters, uint32_t num_filter_coefficients, - uint32_t num_feature_map_rows, - uint32_t num_feature_map_columns, + uint32_t convStride, float weight_scale_factor, float output_scale_factor, void *&ptr_inputs, diff --git a/inference-engine/src/gna_plugin/backend/dnn_types.h b/inference-engine/src/gna_plugin/backend/dnn_types.h index fe1dbdf7839b93..d08d9346d35c89 100644 --- a/inference-engine/src/gna_plugin/backend/dnn_types.h +++ b/inference-engine/src/gna_plugin/backend/dnn_types.h @@ -146,8 +146,7 @@ typedef struct { uint32_t num_bytes_per_bias; uint32_t num_filters; uint32_t num_filter_coefficients; - uint32_t num_feature_map_rows; - uint32_t num_feature_map_columns; + uint32_t convStride; float weight_scale_factor; void *ptr_filters; // filters stored one after the other void *ptr_biases; diff --git a/inference-engine/src/gna_plugin/backend/gna_limitations.hpp b/inference-engine/src/gna_plugin/backend/gna_limitations.hpp index 59dd0478cfa900..90af04519291a6 100644 --- a/inference-engine/src/gna_plugin/backend/gna_limitations.hpp +++ b/inference-engine/src/gna_plugin/backend/gna_limitations.hpp @@ -16,6 +16,7 @@ constexpr uint32_t bufferMaxSize = 65528; constexpr uint32_t convMinFiltersNum = 4; constexpr uint32_t convMaxFiltersNum = 65532; constexpr uint32_t convFiltersNumDivider = 4; +constexpr uint32_t convFilterSizeDivider = 8; constexpr uint32_t convFilterMaxSize = 768; constexpr uint32_t convEachKernelByteAlignment = 16; constexpr uint32_t noOfInputsDivisor = 8; diff --git a/inference-engine/src/gna_plugin/frontend/precision_ex.hpp b/inference-engine/src/gna_plugin/frontend/precision_ex.hpp index c29ec5e48a0c6f..a5f86262deba29 100644 --- a/inference-engine/src/gna_plugin/frontend/precision_ex.hpp +++ b/inference-engine/src/gna_plugin/frontend/precision_ex.hpp @@ -65,17 +65,6 @@ class TPrecision : public Precision { explicit TPrecision(const Precision::ePrecision value) : Precision(value) {} }; -template TPrecision createTPrecision() { - TPrecision cnt(InferenceEngine::Precision::fromType()); - return cnt; -} - -template -TPrecision::value_type> createTPrecision() { - TPrecision::value_type> cnt(T); - return cnt; -} - // special case for Mixed, or undefined precisions template <> diff --git a/inference-engine/src/gna_plugin/frontend/scale_factor_calc.hpp b/inference-engine/src/gna_plugin/frontend/scale_factor_calc.hpp index 11f13a7a9acad7..7fe08a571f829c 100644 --- a/inference-engine/src/gna_plugin/frontend/scale_factor_calc.hpp +++ b/inference-engine/src/gna_plugin/frontend/scale_factor_calc.hpp @@ -1138,7 +1138,7 @@ class ScaleFactorPerLayer { double weights_reducer = 1.0; auto conv = dynamic_cast(wl); - if (conv) { + if (conv && !LayerInfo(conv).isConvolutionFilter()) { const auto inDepth = GetDataDimSize(conv->insData.front().lock(), InferenceEngine::DataDimName::C); weights_reducer = GNAConvolutionLayer::getWeightsReducer(*conv); weights_reducer *= MAX_VAL_2B_FEAT * scaleRange * inDepth / std::numeric_limits::max(); diff --git a/inference-engine/src/gna_plugin/gna2_model_debug_log.cpp b/inference-engine/src/gna_plugin/gna2_model_debug_log.cpp index 4e2de69a351da4..7fe0e4d9b0b659 100644 --- a/inference-engine/src/gna_plugin/gna2_model_debug_log.cpp +++ b/inference-engine/src/gna_plugin/gna2_model_debug_log.cpp @@ -390,6 +390,7 @@ void DumpGna2Model(const Gna2Model& gnaModel, const std::string dumpFolderNameGN dumpFile << "\tOperand " << j << " (" << GetOperandName(operation.Type, j) << ")" << " type: " << GetOperandType(operand.Type) << " shape: " << GetSimpleString(operand.Shape) << + " data: " << operand.Data << " layout: "; DumpCharArray(dumpFile, operand.Layout, GNA2_SHAPE_MAXIMUM_NUMBER_OF_DIMENSIONS); diff --git a/inference-engine/src/gna_plugin/gna_graph_compiler.cpp b/inference-engine/src/gna_plugin/gna_graph_compiler.cpp index 53d3c98a43201d..51a429d9a33b42 100644 --- a/inference-engine/src/gna_plugin/gna_graph_compiler.cpp +++ b/inference-engine/src/gna_plugin/gna_graph_compiler.cpp @@ -162,7 +162,7 @@ void GNAGraphCompiler::fillSplitConnections(InferenceEngine::CNNLayerPtr layer) InferenceEngine::details::product(begin(dataOutput->getDims()), end(dataOutput->getDims())) * dataOutput->getPrecision().size(); - if (LayerInfo(outFunctionalLayer.first).isAffineFilter()) { + if (LayerInfo(outFunctionalLayer.first).isConvolutionFilter()) { size_t aligned64_offset = outFunctionalLayer.first->GetParamAsInt("offset"); layerInfoItem.splitOutputLayers.emplace_back( outFunctionalLayer.first, @@ -351,37 +351,33 @@ void GNAGraphCompiler::finalizeConvolution1DPrimitive(InferenceEngine::CNNLayerP } // have to pad input to let last kernel meets it's corresponding input - uint32_t num_inputs = in_width * in_channels; + const auto num_inputs = in_width * in_channels; uint32_t num_input_padding = ALIGN(num_inputs, 8) - num_inputs; // convert to 2D and set GNA input feature map size - uint32_t effectiveStride = convolution._stride_x * convolution._stride_y; + auto convStride = convolution._stride_x * convolution._stride_y; if (convolution._stride_y != 1) { - effectiveStride = convolution._stride_x; + convStride = convolution._stride_x; } else if (in_width == 1 && convolution._stride_x != 1) { - effectiveStride = convolution._stride_y; + convStride = convolution._stride_y; } - uint32_t num_feature_map_columns = in_channels * effectiveStride; - - uint32_t num_feature_map_rows = (in_channels * in_width) / num_feature_map_columns; + const auto effectiveStride = in_channels * convStride; uint32_t num_filters = convolution._out_depth; uint32_t num_filter_coefficients = single_conv_kernel_size + num_conv_kernel_padding; uint32_t num_columns_in = num_inputs + num_input_padding; - uint32_t num_columns_out = (((num_inputs - num_filter_coefficients) / num_feature_map_columns) + 1) * convolution._out_depth; - uint32_t num_columns_out_unpadded = (((num_inputs - single_conv_kernel_size) / num_feature_map_columns) + 1) * convolution._out_depth; + uint32_t num_columns_out = (((num_inputs - num_filter_coefficients) / effectiveStride) + 1) * convolution._out_depth; + uint32_t num_columns_out_unpadded = (((num_inputs - single_conv_kernel_size) / effectiveStride) + 1) * convolution._out_depth; - uint32_t original_num_feature_map_rows = num_feature_map_rows; uint32_t original_input_padding = num_input_padding; uint32_t additional_padding = 0; // if kernel padding to multiple of 8 will cause missed outputs, need to pad further while (num_columns_out < out_batch * out_channels * out_width) { num_input_padding = original_input_padding + additional_padding; - num_feature_map_rows = original_num_feature_map_rows + (num_input_padding) / num_feature_map_columns; num_columns_in = num_inputs + num_input_padding; - num_columns_out = (((num_inputs + num_input_padding - num_filter_coefficients) / num_feature_map_columns) + 1) * convolution._out_depth; + num_columns_out = (((num_inputs + num_input_padding - num_filter_coefficients) / effectiveStride) + 1) * convolution._out_depth; dnn->new_num_conv_columns = num_columns_out; additional_padding += 8; } @@ -427,8 +423,7 @@ void GNAGraphCompiler::finalizeConvolution1DPrimitive(InferenceEngine::CNNLayerP num_bytes_per_bias, num_filters, num_filter_coefficients, - num_feature_map_rows, - num_feature_map_columns, + effectiveStride, weight_scale_factor, output_scale_factor, ptr_inputs, @@ -457,8 +452,8 @@ void GNAGraphCompiler::finalizeConvolution1DPrimitive(InferenceEngine::CNNLayerP if (inputs->getLayout() != Layout::NHWC && LayerInfo(connectedInputLayer).isInput()) { // Kaldi features are opposite orientation dnn->do_rotate_input = true; - dnn->num_rotate_rows = num_feature_map_columns; - dnn->num_rotate_columns = original_num_feature_map_rows; + dnn->num_rotate_rows = effectiveStride; + dnn->num_rotate_columns = num_inputs / effectiveStride; } else { dnn->do_rotate_input = false; } @@ -559,20 +554,10 @@ void GNAGraphCompiler::finalizeConvolution2DPrimitive(InferenceEngine::CNNLayerP const auto outputs = convolution.outData.front(); // have to pad input to let last kernel meets it's corresponding input - uint32_t num_inputs = in_width * in_height * in_channels; + const auto num_inputs = in_width * in_height * in_channels; uint32_t num_input_padding = ALIGN(num_inputs, 8) - num_inputs; - // convert to 2D and set GNA input feature map size - uint32_t num_feature_map_columns = in_channels * convolution._stride_x * convolution._stride_y; - if (in_height == 1 && convolution._stride_y != 1) { - num_feature_map_columns = in_channels * convolution._stride_x; - } else if (in_width == 1 && convolution._stride_x != 1) { - num_feature_map_columns = in_channels * convolution._stride_y; - } - uint32_t num_feature_map_rows = (in_channels * in_height * in_width) / num_feature_map_columns; - const uint32_t filter_n = convolution._out_depth; - uint32_t original_num_feature_map_rows = num_feature_map_rows; // if kernel padding to multiple of 8 will cause missed outputs, need to pad further if (num_input_padding == 0) { @@ -638,15 +623,17 @@ void GNAGraphCompiler::finalizeConvolution2DPrimitive(InferenceEngine::CNNLayerP auto connectedInputLayer = connectInput(layer, ptr_inputs, num_data_bytes_in).input; // TODO: convolution might be not the first layer in sorted order but connected via split for example - dont know how kaldi will handle that - if (!dnn->do_rotate_input) { - if (inputs->getLayout() != Layout::NHWC && LayerInfo(connectedInputLayer).isInput()) { - // Kaldi features are opposite orientation - dnn->do_rotate_input = true; - dnn->num_rotate_rows = num_feature_map_columns; - dnn->num_rotate_columns = original_num_feature_map_rows; - } else { - dnn->do_rotate_input = false; + if (!dnn->do_rotate_input && inputs->getLayout() != Layout::NHWC && LayerInfo(connectedInputLayer).isInput()) { + // Kaldi features are opposite orientation + dnn->do_rotate_input = true; + dnn->num_rotate_rows = in_channels; + if (in_height != 1) { + dnn->num_rotate_rows *= convolution._stride_y; } + if (in_width != 1) { + dnn->num_rotate_rows *= convolution._stride_x; + } + dnn->num_rotate_columns = num_inputs / dnn->num_rotate_rows; } connectOutput(layer, ptr_outputs, num_data_bytes_out); @@ -654,7 +641,7 @@ void GNAGraphCompiler::finalizeConvolution2DPrimitive(InferenceEngine::CNNLayerP const auto kernelHW = convolution._kernel_y * convolution._kernel_x; std::vector transposedWeights; - const auto singleKernelSize = in_channels* kernelHW* convolution.precision.size(); + const auto singleKernelSize = in_channels* kernelHW * convolution.precision.size(); const auto kernelPad = Gna2RoundUp(singleKernelSize, 16) - singleKernelSize; for (uint32_t k = 0; k < convolution._out_depth; k++) { uint8_t* ptr_filt_current @@ -1728,8 +1715,8 @@ void GNAGraphCompiler::ConcatAlignFilterPrimitive(InferenceEngine::CNNLayerPtr l } } -void GNAGraphCompiler::AffineFilterPrimitive(InferenceEngine::CNNLayerPtr layer) { - auto filterLayer = dynamic_cast (layer.get()); +void GNAGraphCompiler::ConvolutionFilterPrimitive(InferenceEngine::CNNLayerPtr layer) { + auto filterLayer = dynamic_cast (layer.get()); if (filterLayer == nullptr) { return; @@ -1752,62 +1739,57 @@ void GNAGraphCompiler::AffineFilterPrimitive(InferenceEngine::CNNLayerPtr layer) auto outputs = *layer->outData.begin(); auto inputs = layer->insData.begin()->lock(); - const uint32_t noOfInputsDivisor = gnaFlags->input_low_precision ? + const auto noOfInputsDivisor = gnaFlags->input_low_precision ? GNALimitations::noOfInputsLowPrecDivisor : GNALimitations::noOfInputsDivisor; - uint32_t num_columns_in = GetDataDimSize(inputs, 2); - uint32_t num_rows_out = GetDataDimSize(outputs, 1); - uint32_t num_rows_in = filterLayer->_weights->size() / num_rows_out; - - uint32_t num_padding = ALIGN(num_rows_in, noOfInputsDivisor) - num_rows_in; - auto biasPrecision = filterLayer->_biases ? filterLayer->_biases->getTensorDesc().getPrecision() : outputs->getPrecision(); + const uint32_t orginalInputSize = GetDataDimSize(inputs, 1); + const uint32_t orginalOutputSize = GetDataDimSize(outputs, 1); + if (orginalInputSize != orginalOutputSize) { + THROW_GNA_LAYER_EXCEPTION(filterLayer) << "Number in inputs (" << orginalInputSize << + ") should be equal to number of outputs (" << orginalOutputSize << ")!"; + } + const auto numberOfFilters = filterLayer->_out_depth; + const auto convolutionStride = numberOfFilters; + const auto filterWidth = filterLayer->_kernel_x; + const auto minOutputsPerFilter = ALIGN(orginalOutputSize, numberOfFilters) / numberOfFilters; + const auto minInputsNeeded = (minOutputsPerFilter - 1) * convolutionStride + filterWidth; + const auto numInputsFullyPadedAndAligned = ALIGN(minInputsNeeded, noOfInputsDivisor); + + auto numOutputs = GNAConvolutionLayer::outputFromConv(numInputsFullyPadedAndAligned, filterWidth, convolutionStride); + numOutputs *= numberOfFilters; + const auto& biasPrecision = filterLayer->_biases ? filterLayer->_biases->getTensorDesc().getPrecision() : outputs->getPrecision(); auto& currentComponent = dnnComponents.addComponent(layer->name, "affine"); - dnn->InitAffineComponent(currentComponent, - num_rows_in + num_padding, - num_columns_in, - num_rows_out, + layer->params["num_rows_for_pwl"] = std::to_string(numOutputs); + dnn->InitConvolutional1DComponent(currentComponent, + numInputsFullyPadedAndAligned, + numOutputs, inputs->getPrecision().size(), outputs->getPrecision().size(), filterLayer->_weights->getTensorDesc().getPrecision().size(), biasPrecision.size(), + numberOfFilters, + filterWidth, + convolutionStride, quantized == nullptr ? 1 : quantized->_weights_quant.GetScale(), quantized == nullptr ? 1 : quantized->_dst_quant.GetScale(), ptr_inputs, ptr_outputs, ptr_weights, - ptr_biases, - false); + ptr_biases); size_t num_data_bytes_out = InferenceEngine::details::product( begin(outputs->getDims()), end(outputs->getDims())) * 4; - size_t num_data_bytes_in = num_columns_in * - ALIGN(num_rows_in, noOfInputsDivisor) * inputs->getPrecision().size(); + size_t num_data_bytes_in = numInputsFullyPadedAndAligned * inputs->getPrecision().size(); connectInput(layer, ptr_inputs, num_data_bytes_in, 0, 0); connectOutput(layer, ptr_outputs, num_data_bytes_out); - if (num_padding == 0) { - gnamem->readonly().push_ptr(ptr_weights, - filterLayer->_weights->cbuffer().as(), - filterLayer->_weights->byteSize(), - 64); - } else { - auto elementsIn = (num_rows_in + num_padding) * num_columns_in; - auto paddedWeights = elementsIn * num_rows_out; - auto paddedWeightsSize = paddedWeights * filterLayer->precision.size(); - - gnamem->readonly().push_initializer(ptr_weights, paddedWeightsSize, [=](void* data, size_t size) { - size_t offset = 0; - for (uint32_t i = 0; i < num_rows_out && size >= offset; i++) { - ie_memcpy(reinterpret_cast(data) + offset, size - offset, - filterLayer->_weights->cbuffer().as() + num_rows_in * i * filterLayer->precision.size(), - num_rows_in* filterLayer->precision.size()); - offset += (num_rows_in + num_padding) * filterLayer->precision.size(); - } - }, 64); - } + gnamem->readonly().push_ptr(ptr_weights, + filterLayer->_weights->cbuffer().as(), + filterLayer->_weights->byteSize(), + 64); if (filterLayer->_biases) { gnamem->readonly().push_ptr(ptr_biases, @@ -1815,7 +1797,7 @@ void GNAGraphCompiler::AffineFilterPrimitive(InferenceEngine::CNNLayerPtr layer) filterLayer->_biases->byteSize(), 64); } else { - gnamem->readonly().push_value(ptr_biases, 0.0f, num_rows_out, 64); + gnamem->readonly().push_value(ptr_biases, 0.0f, numberOfFilters, 64); } } @@ -1878,13 +1860,18 @@ void GNAGraphCompiler::PWLPrimitive(InferenceEngine::CNNLayerPtr layer) { } // TODO: solve this by layer level transformations - auto concatAlignFilter = CNNNetPrevLayer(layer, 0); - if (LayerInfo(concatAlignFilter).isConcatAlignFilter()) { - auto rowsCopiedOffset = concatAlignFilter->GetParamAsInt("rows_copied_offset"); + auto prevLayer = CNNNetPrevLayer(layer, 0); + if (LayerInfo(prevLayer).isConcatAlignFilter()) { + auto rowsCopiedOffset = prevLayer->GetParamAsInt("rows_copied_offset"); if (rowsCopiedOffset != 0) { num_rows -= rowsCopiedOffset / outputs->getPrecision().size(); layer->params["output_offset"] = std::to_string(rowsCopiedOffset); } + } else if (LayerInfo(prevLayer).isConvolutionFilter()) { + const auto num_rows_for_pwl = prevLayer->GetParamAsInt("num_rows_for_pwl", 0); + if (num_rows_for_pwl != 0) { + num_rows = num_rows_for_pwl; + } } size_t num_data_bytes_out = num_columns * num_rows * outputs->getPrecision().size(); size_t num_data_bytes_in = num_columns * num_rows * inputs->getPrecision().size(); @@ -2135,7 +2122,7 @@ void GNAGraphCompiler::CreateLayerPrimitive(CNNLayerPtr layer) { {{"FullyConnected", "InnerProduct"}, CREATE(AffinePrimitive)}, {{"Gemm"}, CREATE(GemmPrimitive)}, {{"ScaleShift"}, CREATE(DiagonalPrimitive)}, - {{"AffineFilter"}, CREATE(AffineFilterPrimitive)}, + {{"ConvolutionFilter"}, CREATE(ConvolutionFilterPrimitive)}, {{"ConcatAlignFilter"}, CREATE(ConcatAlignFilterPrimitive)}, {{"Const"}, CREATE(ConstPrimitive)}, {{"Eltwise"}, CREATE(EltwisePrimitive)}, // same as diagonal while weights are not taken from network, rather than from another output diff --git a/inference-engine/src/gna_plugin/gna_graph_compiler.hpp b/inference-engine/src/gna_plugin/gna_graph_compiler.hpp index d761d91739269c..5aebc3aa158045 100644 --- a/inference-engine/src/gna_plugin/gna_graph_compiler.hpp +++ b/inference-engine/src/gna_plugin/gna_graph_compiler.hpp @@ -108,7 +108,7 @@ class GNAGraphCompiler { void CreateLayerPrimitive(InferenceEngine::CNNLayerPtr); void AffinePrimitive(InferenceEngine::CNNLayerPtr, bool isDiag = false); - void AffineFilterPrimitive(InferenceEngine::CNNLayerPtr); + void ConvolutionFilterPrimitive(InferenceEngine::CNNLayerPtr); void ConcatAlignFilterPrimitive(InferenceEngine::CNNLayerPtr); void DiagonalPrimitive(InferenceEngine::CNNLayerPtr); void ConstPrimitive(InferenceEngine::CNNLayerPtr); diff --git a/inference-engine/src/gna_plugin/layers/gna_convolution_layer.cpp b/inference-engine/src/gna_plugin/layers/gna_convolution_layer.cpp new file mode 100644 index 00000000000000..f226138251bedb --- /dev/null +++ b/inference-engine/src/gna_plugin/layers/gna_convolution_layer.cpp @@ -0,0 +1,79 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gna_convolution_layer.hpp" + +#include +#include +#include +#include +#include + +#include +#include "gna_graph_tools.hpp" +#include "gna_plugin_log.hpp" + +namespace GNAPluginNS { +namespace GNAConvolutionLayer { +bool isMappableFrom2DTo1D(const uint32_t inHeight, const uint32_t inWidth, const uint32_t kernelWidth, const uint32_t strideWidth) { + return inHeight > 1 && inWidth > 1 && inWidth == kernelWidth && strideWidth == 1; +} + +// 3D input or 2D kernel +bool isConv2D(const uint32_t inHeight, const uint32_t inWidth, const uint32_t inDepth, + const uint32_t kernelHeight, const uint32_t kernelWidth) { + return (kernelHeight > 1 && kernelWidth > 1) || (inHeight > 1 && inWidth > 1 && inDepth > 1); +} + +double getWeightsReducer(InferenceEngine::ConvolutionLayer& conv) { + using KRT = std::pair; + // Empirically determined weights reducers for 2D Convolution + // i.e.: + // for kernelSize >= 9 -> 1.3 + // for kernelSize in {7, 8} -> 1.2 + const std::vector< KRT > reducers{ {9, 1.3}, {7, 1.2} }; + auto reducer = 1.0; + const auto inDepth = GetDataDimSize(conv.insData.front().lock(), InferenceEngine::DataDimName::C); + const auto inHeight = GetDataDimSize(conv.insData.front().lock(), InferenceEngine::DataDimName::H); + const auto inWidth = GetDataDimSize(conv.insData.front().lock(), InferenceEngine::DataDimName::W); + if (isConv2D(inHeight, inWidth, inDepth, conv._kernel_y, conv._kernel_x) && + !isMappableFrom2DTo1D(inHeight, inWidth, conv._kernel_x, conv._stride_x)) { + const auto kernelSize = conv._kernel_x * conv._kernel_y; + auto r = std::lower_bound(reducers.begin(), reducers.end(), kernelSize, + [](const KRT& l, const KRT::first_type& r) {return l.first > r; }); + if (r != reducers.end()) + reducer = r->second; + } + return reducer; +} + +uint32_t outputFromConv(const uint32_t in, const uint32_t flt, const uint32_t stride) { + // floor[(in - flt)/stride] + 1, GNA Spec 1.24 + if (flt > in || flt == 0 || stride == 0) { + THROW_GNA_EXCEPTION << "Invalid (input, filter, stride) = (" << in << "," << flt << "," << stride << ")"; + } + return (in - flt) / stride + 1; +} + +uint32_t outputFromPooling(const uint32_t in, const uint32_t window, const uint32_t stride) { + // ceil[(in - window)/stride] + 1, GNA Spec 1.24 + if (window > in || window == 0 || stride == 0) { + THROW_GNA_EXCEPTION << "Invalid (input, window, stride) = (" << in << "," << window << "," << stride << ")"; + } + if (window == in) return 1; + + return (in - window - 1) / stride + 2; +} + +uint32_t outputFromPoolingLegacy(const uint32_t in, const uint32_t stride) { + // floor[(in - 1)/stride] + 1, GNA 1.0/2.0 HW Spec + // See issue 50386 for details + if (in == 0 || stride == 0) { + THROW_GNA_EXCEPTION << "Invalid (input, stride) = (" << in << "," << stride << ")"; + } + return (in - 1) / stride + 1; +} + +} // namespace GNAConvolutionLayer +} // namespace GNAPluginNS diff --git a/inference-engine/src/gna_plugin/layers/gna_convolution_layer.hpp b/inference-engine/src/gna_plugin/layers/gna_convolution_layer.hpp index e83d9b6c535191..1ed7125b633de3 100644 --- a/inference-engine/src/gna_plugin/layers/gna_convolution_layer.hpp +++ b/inference-engine/src/gna_plugin/layers/gna_convolution_layer.hpp @@ -4,46 +4,25 @@ #pragma once -#include -#include -#include -#include +#include #include -#include "../gna_graph_tools.hpp" namespace GNAPluginNS { -struct GNAConvolutionLayer { - static bool isMappableFrom2DTo1D(const uint32_t inHeight, const uint32_t inWidth, const uint32_t kernelWidth, const uint32_t strideWidth) { - return inHeight > 1 && inWidth > 1 && inWidth == kernelWidth && strideWidth == 1; - } - - // 3D input or 2D kernel - static bool isConv2D(const uint32_t inHeight, const uint32_t inWidth, const uint32_t inDepth, - const uint32_t kernelHeight, const uint32_t kernelWidth) { - return (kernelHeight > 1 && kernelWidth > 1) || (inHeight > 1 && inWidth > 1 && inDepth > 1); - } - - static double getWeightsReducer(InferenceEngine::ConvolutionLayer& conv) { - using KRT = std::pair; - // Empirically determined weights reducers for 2D Convolution - // i.e.: - // for kernelSize >= 9 -> 1.3 - // for kernelSize in {7, 8} -> 1.2 - const std::vector< KRT > reducers{ {9, 1.3}, {7, 1.2} }; - auto reducer = 1.0; - const auto inDepth = GetDataDimSize(conv.insData.front().lock(), InferenceEngine::DataDimName::C); - const auto inHeight = GetDataDimSize(conv.insData.front().lock(), InferenceEngine::DataDimName::H); - const auto inWidth = GetDataDimSize(conv.insData.front().lock(), InferenceEngine::DataDimName::W); - if (isConv2D(inHeight, inWidth, inDepth, conv._kernel_y, conv._kernel_x) && - !isMappableFrom2DTo1D(inHeight, inWidth, conv._kernel_x, conv._stride_x)) { - const auto kernelSize = conv._kernel_x * conv._kernel_y; - auto r = std::lower_bound(reducers.begin(), reducers.end(), kernelSize, - [](const KRT& l, const KRT::first_type& r) {return l.first > r; }); - if (r != reducers.end()) - reducer = r->second; - } - return reducer; - } -}; -} // namespace GNAPluginNS +namespace GNAConvolutionLayer { +bool isMappableFrom2DTo1D(const uint32_t inHeight, const uint32_t inWidth, const uint32_t kernelWidth, const uint32_t strideWidth); + +// 3D input or 2D kernel +bool isConv2D(const uint32_t inHeight, const uint32_t inWidth, const uint32_t inDepth, + const uint32_t kernelHeight, const uint32_t kernelWidth); + +double getWeightsReducer(InferenceEngine::ConvolutionLayer& conv); + +uint32_t outputFromConv(const uint32_t in, const uint32_t flt, const uint32_t stride); + +uint32_t outputFromPooling(const uint32_t in, const uint32_t window, const uint32_t stride); + +uint32_t outputFromPoolingLegacy(const uint32_t in, const uint32_t stride); + +} // namespace GNAConvolutionLayer +} // namespace GNAPluginNS diff --git a/inference-engine/src/gna_plugin/layers/gna_layer_info.hpp b/inference-engine/src/gna_plugin/layers/gna_layer_info.hpp index 93fb4417dc7296..53362a2d702bc1 100644 --- a/inference-engine/src/gna_plugin/layers/gna_layer_info.hpp +++ b/inference-engine/src/gna_plugin/layers/gna_layer_info.hpp @@ -70,6 +70,7 @@ class LayerInfo { [this]() { return isFullyConnected(); }, [this]() { return isAffineFilter(); }, [this]() { return isConcatAlignFilter(); }, + [this]() { return isConvolutionFilter(); }, [this]() { return isEltwise(); }, [this]() { return isScaleShift(); }, [this]() { return isConvolution(); }, @@ -157,6 +158,9 @@ class LayerInfo { bool isAffineFilter() const noexcept { return isOfType("AffineFilter"); } + bool isConvolutionFilter() const noexcept { + return isOfType("ConvolutionFilter"); + } bool isRelu() const noexcept { return isOfType("relu"); } diff --git a/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp b/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp index f16645ae6cb2ad..ae731465025e05 100644 --- a/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp +++ b/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp @@ -41,6 +41,7 @@ #include "gna_data_types.hpp" #include "gna_tensor_tools.hpp" #include "gna_itt.hpp" +#include "backend/gna_limitations.hpp" using namespace InferenceEngine; using namespace InferenceEngine::details; @@ -1277,35 +1278,49 @@ void InsertSplitAligningFilterPass::run() { gnalog() << std::endl; #endif auto filterLayer = - std::make_shared(LayerParams({filterName, "AffineFilter", Precision::FP32})); + std::make_shared(LayerParams({filterName, "ConvolutionFilter", Precision::FP32})); auto inputData = splitOutput; size_t aligned64_offset = std::max(0, static_cast(ALIGN64(currentOffset) - 64)); - size_t - newOutputSize = (currentOffset + ALIGN(outputSize, 8) * bytesPerSplitElement - aligned64_offset) - / bytesPerSplitElement; IE_ASSERT(filterLayer != nullptr); // encodes offset to beginning of split layer input filterLayer->params["offset"] = std::to_string(aligned64_offset / bytesPerSplitElement); - auto dims = splitOutput->getTensorDesc().getDims(); if (dims.size() > 3) { THROW_GNA_EXCEPTION << "unsupported split layer dims size: " << dims.size(); } - auto num_rows_out = dims[1] * (dims.size() != 2 ? dims[2] : 1); - std::vector filterWeights(newOutputSize * num_rows_out, 0.f); - - auto offset = (currentOffset - aligned64_offset) / bytesPerSplitElement; - - for (int i = 0; i != outputSize; i++) { - filterWeights[offset] = 1.0f; - offset += newOutputSize + 1; + const auto offsetOfUnalignment = (currentOffset - aligned64_offset) / bytesPerSplitElement; + // TODO consider to use a different number of filters do decrese the number of trailing zeros (additionalPaddingOfFilter) + const auto numberOfFilters = GNALimitations::convMinFiltersNum; + const auto filterSize = ALIGN(offsetOfUnalignment + numberOfFilters, GNALimitations::convFilterSizeDivider); + + // filterWeights: numberOfFilters X (offsetOfUnalignment + additionalPaddingOfFilter + numberOfFilters) + // offsetOfUnalignment - the leading zeros in the filter + // | + // | additionalPaddingOfFilter = filterSize - offsetOfUnalignment - numberOfFilters + // ____|___ ___|___ + // | | | | + // 0 0 ... 0 1 0 0 0 0 ... 0 + // 0 0 ... 0 0 1 0 0 0 ... 0 + // 0 0 ... 0 0 0 1 0 0 ... 0 + // 0 0 ... 0 0 0 0 1 0 ... 0 + std::vector filterWeights(filterSize * 4, 0.f); + for (auto f = 0u; f < numberOfFilters; f++) { + filterWeights[f * filterSize + f + offsetOfUnalignment] = 1; } + filterLayer->_out_depth = numberOfFilters; + filterLayer->_stride_x = numberOfFilters; + filterLayer->_stride_y = 1; + filterLayer->_kernel_x = filterSize; + filterLayer->_kernel_y = 1; + filterLayer->_padding_x = 0; + filterLayer->_padding_y = 0; + filterLayer->_weights = make_shared_blob(TensorDesc( inputData->getTensorDesc().getPrecision(), SizeVector({filterWeights.size()}), @@ -1313,6 +1328,15 @@ void InsertSplitAligningFilterPass::run() { filterLayer->_weights->allocate(); CopyVectorToBlob(filterLayer->_weights, filterWeights); + std::vector biasWeights(numberOfFilters, 0.f); + + filterLayer->_biases = make_shared_blob(TensorDesc( + inputData->getTensorDesc().getPrecision(), + SizeVector({ biasWeights.size() }), + Layout::C)); + filterLayer->_biases->allocate(); + CopyVectorToBlob(filterLayer->_biases, biasWeights); + auto outData = std::make_shared(filterName, TensorDesc(splitOutput->getTensorDesc().getPrecision(), splitOutput->getTensorDesc().getDims(), diff --git a/inference-engine/src/gna_plugin/runtime/cnn.cpp b/inference-engine/src/gna_plugin/runtime/cnn.cpp index e4824b84b0602b..2e0071040f92ab 100644 --- a/inference-engine/src/gna_plugin/runtime/cnn.cpp +++ b/inference-engine/src/gna_plugin/runtime/cnn.cpp @@ -12,7 +12,9 @@ #include "backend/dnn_types.h" #include "backend/gna_limitations.hpp" #include "gna_lib_ver_selector.hpp" +#include "layers/gna_convolution_layer.hpp" +using namespace GNAPluginNS::GNAConvolutionLayer; void CNNFilter32(intel_dnn_component_t *component) { auto filters = reinterpret_cast(component->op.conv1D.ptr_filters); @@ -20,11 +22,10 @@ void CNNFilter32(intel_dnn_component_t *component) { auto input = reinterpret_cast(component->ptr_inputs); auto output = reinterpret_cast(component->ptr_outputs); - const auto convolutionStride = component->op.conv1D.num_feature_map_columns; + const auto convolutionStride = component->op.conv1D.convStride; const auto filterSize = component->op.conv1D.num_filter_coefficients; const auto numberOfInputs = component->num_columns_in; - // TODO: reuse outputFromConv() from backend\am_intel_dnn.cpp - const auto numberOfOutputsPerFilter = (numberOfInputs - filterSize) / convolutionStride + 1; + const auto numberOfOutputsPerFilter = outputFromConv(numberOfInputs, filterSize, convolutionStride); const auto numberOfFilters = component->op.conv1D.num_filters; std::string layer_name; diff --git a/inference-engine/src/gna_plugin/transformations/convert_padded2valid_conv.cpp b/inference-engine/src/gna_plugin/transformations/convert_padded2valid_conv.cpp index 019c7747a5a28c..b07add2183d16a 100644 --- a/inference-engine/src/gna_plugin/transformations/convert_padded2valid_conv.cpp +++ b/inference-engine/src/gna_plugin/transformations/convert_padded2valid_conv.cpp @@ -29,19 +29,12 @@ struct ConvData { size_t input_height; size_t input_width; size_t input_channel_count; - size_t filter_height; - size_t filter_width; size_t filter_count; - size_t filter_dilation_width; - size_t filter_dilation_height; - size_t filter_stride_width; - size_t filter_stride_height; size_t pads_begin_width; size_t pads_begin_height; size_t pads_end_width; size_t pads_end_height; ngraph::op::PadType padding_type; - ngraph::Shape output_shape; ngraph::element::Type element_type; }; @@ -55,27 +48,18 @@ static bool VerifyAndGetConvParams(std::shared_ptr return false; } - conv_data.output_shape = conv->get_output_shape(0); conv_data.padding_type = conv->get_auto_pad(); conv_data.input_channel_count = conv->input_value(0).get_shape()[1]; conv_data.input_height = conv->input_value(0).get_shape()[2]; conv_data.input_width = conv->input_value(0).get_shape()[3]; conv_data.filter_count = conv->input_value(1).get_shape()[0]; - conv_data.filter_height = conv->input_value(1).get_shape()[2]; - conv_data.filter_width = conv->input_value(1).get_shape()[3]; - conv_data.filter_dilation_height = conv->get_dilations()[0]; - conv_data.filter_dilation_width = conv->get_dilations()[1]; - conv_data.filter_stride_height = conv->get_strides()[0]; - conv_data.filter_stride_width = conv->get_strides()[1]; conv_data.pads_begin_height = conv->get_pads_begin()[0]; conv_data.pads_begin_width = conv->get_pads_begin()[1]; conv_data.pads_end_height = conv->get_pads_end()[0]; conv_data.pads_end_width = conv->get_pads_end()[1]; conv_data.element_type = conv->get_element_type(); - IE_ASSERT(conv_data.filter_count == conv_data.output_shape[1]); - - return true; + return conv_data.pads_begin_height || conv_data.pads_end_height || conv_data.pads_begin_width || conv_data.pads_end_width; } static bool TransposeOrderMatches(std::shared_ptr transpose, std::vector order) { @@ -117,75 +101,9 @@ static bool VerifyMaxPool(std::shared_ptr max_pool) { auto pool_kernel = max_pool->get_kernel(); // Check if MaxPool vertical stride == pool size - // (TODO: remove when 50386 and 50379 are fixed and also verify pool_kernel[0] > 8 limitation below, gna_limitations can be used then) // Check if padding is VALID return (max_pool->get_auto_pad() == ngraph::op::PadType::VALID && - pool_kernel.size() == 2 && pool_strides.size() == 2 && - pool_kernel[0] == pool_strides[0] && pool_kernel[0] <= 8); -} - -static size_t GetRequiredInputPadding(size_t input_size, size_t filter_size, size_t stride_size, size_t dilation_size, size_t output_size) { - size_t partial_padding_size = (output_size - 1) * stride_size + (filter_size - 1) * dilation_size + 1; - - // This way of padding size calculation avoids problem with fractional numbers - return (partial_padding_size > input_size) ? (partial_padding_size - input_size) : 0; -} - -static size_t CalculateOutputSize(size_t input_size, size_t filter_size, size_t stride_size, size_t dilation_size, size_t padding_size) { - return (input_size + padding_size - ((filter_size - 1) * dilation_size + 1)) / stride_size + 1; -} - -static bool CalculatePadding(ConvData& conv_data) { - size_t output_height{ 0 }; - size_t output_width{ 0 }; - - switch (conv_data.padding_type) { - case ngraph::op::PadType::EXPLICIT: - // all paddings already set - break; - case ngraph::op::PadType::VALID: - conv_data.pads_begin_height = 0; - conv_data.pads_begin_width = 0; - conv_data.pads_end_height = 0; - conv_data.pads_end_width = 0; - break; - case ngraph::op::PadType::SAME_LOWER: - case ngraph::op::PadType::SAME_UPPER: - { - output_height = conv_data.output_shape[2]; - output_width = conv_data.output_shape[3]; - - size_t pads_width = GetRequiredInputPadding(conv_data.input_width, conv_data.filter_width, - conv_data.filter_stride_width, conv_data.filter_dilation_width, output_width); - size_t pads_height = GetRequiredInputPadding(conv_data.input_height, conv_data.filter_height, - conv_data.filter_stride_height, conv_data.filter_dilation_height, output_height); - - conv_data.pads_begin_width = conv_data.pads_end_width = pads_width / 2; - conv_data.pads_begin_height = conv_data.pads_end_height = pads_height / 2; - - if (conv_data.padding_type == ngraph::op::PadType::SAME_LOWER) { - conv_data.pads_begin_width += (pads_width % 2); - conv_data.pads_begin_height += (pads_height % 2); - } else { - conv_data.pads_end_width += (pads_width % 2); - conv_data.pads_end_height += (pads_height % 2); - } - break; - } - default: - break; - } - - output_width = CalculateOutputSize(conv_data.input_width, conv_data.filter_width, conv_data.filter_stride_width, - conv_data.filter_dilation_width, conv_data.pads_begin_width + conv_data.pads_end_width); - output_height = CalculateOutputSize(conv_data.input_height, conv_data.filter_height, conv_data.filter_stride_height, - conv_data.filter_dilation_height, conv_data.pads_begin_height + conv_data.pads_end_height); - - IE_ASSERT(output_width == conv_data.output_shape[3]); - IE_ASSERT(output_height == conv_data.output_shape[2]); - - // Check if any calculated padding is non-zero, otherwise there is no need to decompose such convolution - return conv_data.pads_begin_height || conv_data.pads_end_height || conv_data.pads_begin_width || conv_data.pads_end_width; + pool_kernel.size() == 2 && pool_strides.size() == 2); } static std::shared_ptr FlatCrop(ngraph::Output input, size_t offset, size_t size) { @@ -227,7 +145,7 @@ static std::shared_ptr CreatePaddedNet(std::shared_ptrinput_value(0).get_shape()) }), false); - // zero padding + // Constant with zero padding auto const_holding_padding = std::make_shared(conv_data.element_type, ngraph::Shape{ 1, biggest_padding }, 0); copy_runtime_info(conv, const_holding_padding); @@ -342,9 +260,6 @@ static bool Convert(std::shared_ptr leading_transpose, if (max_pool && !VerifyMaxPool(std::dynamic_pointer_cast(max_pool))) return false; - if (!CalculatePadding(conv_data)) - return false; - GeneratePadding(std::dynamic_pointer_cast(leading_transpose), std::dynamic_pointer_cast(conv), conv_data); diff --git a/inference-engine/src/inference_engine/cnn_network_ngraph_impl.cpp b/inference-engine/src/inference_engine/cnn_network_ngraph_impl.cpp index 1252c1b856aff4..1f05ca0098c3da 100644 --- a/inference-engine/src/inference_engine/cnn_network_ngraph_impl.cpp +++ b/inference-engine/src/inference_engine/cnn_network_ngraph_impl.cpp @@ -8,6 +8,10 @@ #include #include +#include +#include + + #include #include #include @@ -476,6 +480,64 @@ StatusCode CNNNetworkNGraphImpl::serialize(const std::string& xmlPath, return OK; } +StatusCode CNNNetworkNGraphImpl::serialize(std::ostream& xmlBuf, + std::ostream& binBuf, + ResponseDesc* resp) const noexcept { + try { + std::map custom_opsets; + for (const auto& extension : _ie_extensions) { + auto opset = extension->getOpSets(); + custom_opsets.insert(begin(opset), end(opset)); + } + ngraph::pass::Manager manager; + manager.register_pass( + xmlBuf, binBuf, ngraph::pass::Serialize::Version::IR_V10, + custom_opsets); + manager.run_passes(_ngraph_function); + } catch (const Exception& e) { + return DescriptionBuffer(GENERAL_ERROR, resp) << e.what(); + } catch (const std::exception& e) { + return DescriptionBuffer(UNEXPECTED, resp) << e.what(); + } catch (...) { + return DescriptionBuffer(UNEXPECTED, resp); + } + return OK; +} + +StatusCode CNNNetworkNGraphImpl::serialize(std::ostream& xmlBuf, + Blob::Ptr& binBlob, + ResponseDesc* resp) const noexcept { + try { + std::map custom_opsets; + for (const auto& extension : _ie_extensions) { + auto opset = extension->getOpSets(); + custom_opsets.insert(begin(opset), end(opset)); + } + + std::stringstream binBuf; + ngraph::pass::Manager manager; + manager.register_pass( + xmlBuf, binBuf, ngraph::pass::Serialize::Version::IR_V10, + custom_opsets); + manager.run_passes(_ngraph_function); + + std::streambuf* pbuf = binBuf.rdbuf(); + unsigned long bufSize = binBuf.tellp(); + + TensorDesc tensorDesc(Precision::U8, { bufSize }, Layout::C); + binBlob = make_shared_blob(tensorDesc); + binBlob->allocate(); + pbuf->sgetn(binBlob->buffer(), bufSize); + } catch (const Exception& e) { + return DescriptionBuffer(GENERAL_ERROR, resp) << e.what(); + } catch (const std::exception& e) { + return DescriptionBuffer(UNEXPECTED, resp) << e.what(); + } catch (...) { + return DescriptionBuffer(UNEXPECTED, resp); + } + return OK; +} + StatusCode CNNNetworkNGraphImpl::getOVNameForTensor(std::string& ov_name, const std::string& orig_name, ResponseDesc* resp) const noexcept { if (_tensorNames.find(orig_name) == _tensorNames.end()) return DescriptionBuffer(NOT_FOUND, resp) << "Framework tensor with name \"" << orig_name << "\" was not mapped to OpenVINO data!"; diff --git a/inference-engine/src/inference_engine/cnn_network_ngraph_impl.hpp b/inference-engine/src/inference_engine/cnn_network_ngraph_impl.hpp index db0d1d9ab49f23..6fe00b8ad8164f 100644 --- a/inference-engine/src/inference_engine/cnn_network_ngraph_impl.hpp +++ b/inference-engine/src/inference_engine/cnn_network_ngraph_impl.hpp @@ -79,6 +79,12 @@ class INFERENCE_ENGINE_API_CLASS(CNNNetworkNGraphImpl) final : public ICNNNetwor StatusCode serialize(const std::string& xmlPath, const std::string& binPath, ResponseDesc* resp) const noexcept override; + StatusCode serialize(std::ostream& xmlBuf, std::ostream& binBuf, ResponseDesc* resp) const + noexcept override; + + StatusCode serialize(std::ostream& xmlBuf, Blob::Ptr& binBlob, ResponseDesc* resp) const + noexcept override; + StatusCode getOVNameForTensor(std::string& ov_name, const std::string& orig_name, ResponseDesc* resp) const noexcept override; // used by convertFunctionToICNNNetwork from legacy library diff --git a/inference-engine/src/inference_engine/cpp/ie_cnn_network.cpp b/inference-engine/src/inference_engine/cpp/ie_cnn_network.cpp index 52ae8998038342..e2506d6cdca9e3 100644 --- a/inference-engine/src/inference_engine/cpp/ie_cnn_network.cpp +++ b/inference-engine/src/inference_engine/cpp/ie_cnn_network.cpp @@ -124,6 +124,14 @@ void CNNNetwork::serialize(const std::string& xmlPath, const std::string& binPat CALL_STATUS_FNC(serialize, xmlPath, binPath); } +void CNNNetwork::serialize(std::ostream& xmlBuf, std::ostream& binBuf) const { + CALL_STATUS_FNC(serialize, xmlBuf, binBuf); +} + +void CNNNetwork::serialize(std::ostream& xmlBuf, Blob::Ptr& binBlob) const { + CALL_STATUS_FNC(serialize, xmlBuf, binBlob); +} + std::string CNNNetwork::getOVNameForTensor(const std::string& orig_name) const { std::string ov_name; CALL_STATUS_FNC(getOVNameForTensor, ov_name, orig_name); diff --git a/inference-engine/src/inference_engine/ie_core.cpp b/inference-engine/src/inference_engine/ie_core.cpp index 9582c12f9413da..3c101ea42713ed 100644 --- a/inference-engine/src/inference_engine/ie_core.cpp +++ b/inference-engine/src/inference_engine/ie_core.cpp @@ -775,7 +775,7 @@ class Core::Impl : public ICore, public std::enable_shared_from_this { } /** - * @brief Porvides a list of plugin names in registry; physically such plugins may not be created + * @brief Provides a list of plugin names in registry; physically such plugins may not be created * @return A list of plugin names */ std::vector GetListOfDevicesInRegistry() const { diff --git a/inference-engine/src/inference_engine/os/win/win_shared_object_loader.cpp b/inference-engine/src/inference_engine/os/win/win_shared_object_loader.cpp index ec0d5c1526a21f..31c148ec111ff9 100644 --- a/inference-engine/src/inference_engine/os/win/win_shared_object_loader.cpp +++ b/inference-engine/src/inference_engine/os/win/win_shared_object_loader.cpp @@ -98,7 +98,7 @@ class SharedObjectLoader::Impl { // Exclude current directory from DLL search path process wise. // If application specific path was configured before then // current directory is already excluded. - // GetDLLDirectory does not distinguish if aplication specific + // GetDLLDirectory does not distinguish if application specific // path was set to "" or NULL so reset it to "" to keep // application safe. void ExcludeCurrentDirectoryA() { diff --git a/inference-engine/src/legacy_api/include/legacy/cnn_network_impl.hpp b/inference-engine/src/legacy_api/include/legacy/cnn_network_impl.hpp index 8151832d027b3d..4849f4d0193001 100644 --- a/inference-engine/src/legacy_api/include/legacy/cnn_network_impl.hpp +++ b/inference-engine/src/legacy_api/include/legacy/cnn_network_impl.hpp @@ -122,6 +122,12 @@ class INFERENCE_ENGINE_API_CLASS(CNNNetworkImpl) final : public ICNNNetwork { StatusCode serialize(const std::string& xmlPath, const std::string& binPath, ResponseDesc* resp) const noexcept override; + StatusCode serialize(std::ostream& xmlBuf, std::ostream& binBuf, ResponseDesc* resp) const + noexcept override; + + StatusCode serialize(std::ostream& xmlBuf, Blob::Ptr& binBlob, ResponseDesc* resp) const + noexcept override; + protected: std::map _data; std::map _layers; diff --git a/inference-engine/src/legacy_api/src/cnn_network_impl.cpp b/inference-engine/src/legacy_api/src/cnn_network_impl.cpp index c332d2e07ae555..a7309caca6947a 100644 --- a/inference-engine/src/legacy_api/src/cnn_network_impl.cpp +++ b/inference-engine/src/legacy_api/src/cnn_network_impl.cpp @@ -408,6 +408,17 @@ StatusCode CNNNetworkImpl::serialize(const std::string& xmlPath, const std::stri return DescriptionBuffer(NOT_IMPLEMENTED, resp) << "The CNNNetworkImpl::serialize is not implemented"; } + +StatusCode CNNNetworkImpl::serialize(std::ostream& xmlBuf, std::ostream& binBuf, ResponseDesc* resp) const + noexcept { + return DescriptionBuffer(NOT_IMPLEMENTED, resp) << "The CNNNetworkImpl::serialize is not implemented"; +} + +StatusCode CNNNetworkImpl::serialize(std::ostream& xmlBuf, Blob::Ptr& binBlob, ResponseDesc* resp) const + noexcept { + return DescriptionBuffer(NOT_IMPLEMENTED, resp) << "The CNNNetworkImpl::serialize is not implemented"; +} + StatusCode CNNNetworkImpl::setBatchSize(size_t size, ResponseDesc* responseDesc) noexcept { try { auto originalBatchSize = getBatchSize(); diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp index 3f53db150ce98b..733d785d5940b1 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include diff --git a/inference-engine/src/offline_transformations/src/moc_transformations.cpp b/inference-engine/src/offline_transformations/src/moc_transformations.cpp index 745e173b4d765d..50ae6bcaa7e851 100644 --- a/inference-engine/src/offline_transformations/src/moc_transformations.cpp +++ b/inference-engine/src/offline_transformations/src/moc_transformations.cpp @@ -5,12 +5,54 @@ #include #include "moc_transformations.hpp" -#include "pruning.hpp" #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include NGRAPH_RTTI_DEFINITION(ngraph::pass::MOCTransformations, "MOCTransformations", 0); bool ngraph::pass::MOCTransformations::run_on_function(std::shared_ptr f) { + // To avoid issues with dynamism we make nGraph Function dynamic and after we apply all + // transformations we restore original shapes to the nGraph Function back + std::unordered_map input_shapes; + for (auto && param : f->get_parameters()) { + input_shapes[param.get()] = param->get_partial_shape(); + param->set_partial_shape(PartialShape::dynamic(param->get_partial_shape().rank())); + } + f->validate_nodes_and_infer_types(); + + ngraph::pass::Manager manager(get_pass_config()); + + manager.register_pass(); + manager.register_pass(); + manager.register_pass(); + + auto common_fusions = manager.register_pass(); + common_fusions->add_matcher(); + common_fusions->add_matcher(); + common_fusions->add_matcher(); + common_fusions->add_matcher(); + common_fusions->add_matcher(); + common_fusions->add_matcher(); + common_fusions->add_matcher(); + common_fusions->set_name("ngraph::pass::CommonFusions"); + + manager.run_passes(f); + + // Restore original shapes to the nGraph Function + for (auto && param : f->get_parameters()) { + param->set_partial_shape(input_shapes.at(param.get())); + } + f->validate_nodes_and_infer_types(); + return false; } \ No newline at end of file diff --git a/inference-engine/src/plugin_api/ie_ngraph_utils.hpp b/inference-engine/src/plugin_api/ie_ngraph_utils.hpp index 40904bb07215ca..48a9a026daceab 100644 --- a/inference-engine/src/plugin_api/ie_ngraph_utils.hpp +++ b/inference-engine/src/plugin_api/ie_ngraph_utils.hpp @@ -134,6 +134,8 @@ inline Precision convertPrecision(const ::ngraph::element::Type& precision) { return Precision(Precision::BIN); case ::ngraph::element::Type_t::boolean: return Precision(Precision::BOOL); + case ::ngraph::element::Type_t::dynamic: + return Precision(Precision::UNSPECIFIED); default: IE_THROW() << "Incorrect precision " << precision.get_type_name() << "!"; return{}; } diff --git a/inference-engine/src/preprocessing/arm_neon/ie_preprocess_gapi_kernels_neon.cpp b/inference-engine/src/preprocessing/arm_neon/ie_preprocess_gapi_kernels_neon.cpp index 390d41ce24a60a..cba0b9b5da070c 100644 --- a/inference-engine/src/preprocessing/arm_neon/ie_preprocess_gapi_kernels_neon.cpp +++ b/inference-engine/src/preprocessing/arm_neon/ie_preprocess_gapi_kernels_neon.cpp @@ -29,19 +29,6 @@ namespace InferenceEngine { namespace gapi { namespace kernels { namespace neon { -void calcRowArea_8U(uchar dst[], const uchar *src[], const Size& inSz, - const Size& outSz, Q0_16 yalpha, const MapperUnit8U &ymap, - int xmaxdf, const short xindex[], const Q0_16 xalpha[], - Q8_8 vbuf[]) { - calcRowArea_impl(dst, src, inSz, outSz, yalpha, ymap, xmaxdf, xindex, xalpha, vbuf); -} - -void calcRowArea_32F(float dst[], const float *src[], const Size& inSz, - const Size& outSz, float yalpha, const MapperUnit32F& ymap, - int xmaxdf, const int xindex[], const float xalpha[], - float vbuf[]) { - calcRowArea_impl(dst, src, inSz, outSz, yalpha, ymap, xmaxdf, xindex, xalpha, vbuf); -} template CV_ALWAYS_INLINE void channels2planes_store(std::array, chanNum>& dst, @@ -649,6 +636,16 @@ template void mergeRowImpl(neon_tag, const std::array(neon_tag, uint8_t dst[], const uint8_t* src[], const Size& inSz, + const Size& outSz, Q0_16 yalpha, const MapperUnit8U &ymap, + int xmaxdf, const short xindex[], const Q0_16 xalpha[], + Q8_8 vbuf[]); + +template void calcRowAreaImpl(neon_tag, float dst[], const float *src[], const Size& inSz, + const Size& outSz, float yalpha, const MapperUnit32F& ymap, + int xmaxdf, const int xindex[], const float xalpha[], + float vbuf[]); } // namespace kernels } // namespace gapi } // namespace InferenceEngine diff --git a/inference-engine/src/preprocessing/arm_neon/ie_preprocess_gapi_kernels_neon.hpp b/inference-engine/src/preprocessing/arm_neon/ie_preprocess_gapi_kernels_neon.hpp index dba6fe63f1d5d6..5d4173bae4a77b 100644 --- a/inference-engine/src/preprocessing/arm_neon/ie_preprocess_gapi_kernels_neon.hpp +++ b/inference-engine/src/preprocessing/arm_neon/ie_preprocess_gapi_kernels_neon.hpp @@ -32,41 +32,19 @@ void calcRowArea_32F(float dst[], const float *src[], const Size &inSz, const Si template void chanToPlaneRowImpl(isa_tag_t, const T* in, const int chan, const int chs, T* out, const int length); -extern template void chanToPlaneRowImpl(neon_tag, const uint8_t* in, const int chan, const int chs, uint8_t* out, const int length); -extern template void chanToPlaneRowImpl(neon_tag, const float* in, const int chan, const int chs, float * out, const int length); - template void nv12ToRgbRowImpl(isa_tag_t, const uint8_t** y_rows, const uint8_t* uv_row, uint8_t** out_rows, const int buf_width); -extern template void nv12ToRgbRowImpl(neon_tag, const uint8_t** y_rows, const uint8_t* uv_row, uint8_t** out_rows, const int buf_width); - template void i420ToRgbRowImpl(isa_tag_t, const uint8_t** y_rows, const uint8_t* u_row, const uint8_t* v_row, uint8_t** out_rows, const int buf_width); -extern template void i420ToRgbRowImpl(neon_tag, const uint8_t** y_rows, const uint8_t* u_row, - const uint8_t* v_row, uint8_t** out_rows, const int buf_width); - template void splitRowImpl(isa_tag_t, const T* in, std::array& outs, const int length); -extern template void splitRowImpl(neon_tag, const uint8_t* in, std::array& outs, const int length); -extern template void splitRowImpl(neon_tag, const float* in, std::array& outs, const int length); -extern template void splitRowImpl(neon_tag, const uint8_t* in, std::array& outs, const int length); -extern template void splitRowImpl(neon_tag, const float* in, std::array& outs, const int length); -extern template void splitRowImpl(neon_tag, const uint8_t* in, std::array& outs, const int length); -extern template void splitRowImpl(neon_tag, const float* in, std::array& outs, const int length); - template void mergeRowImpl(isa_tag_t, const std::array& ins, T* out, const int length); -extern template void mergeRowImpl(neon_tag, const std::array& ins, uint8_t* out, const int length); -extern template void mergeRowImpl(neon_tag, const std::array& ins, float* out, const int length); -extern template void mergeRowImpl(neon_tag, const std::array& ins, uint8_t* out, const int length); -extern template void mergeRowImpl(neon_tag, const std::array& ins, float* out, const int length); -extern template void mergeRowImpl(neon_tag, const std::array& ins, uint8_t* out, const int length); -extern template void mergeRowImpl(neon_tag, const std::array& ins, float* out, const int length); - template bool calcRowLinear8UC1Impl(isa_tag_t, uint8_t* dst[], const uint8_t* src0[], const uint8_t* src1[], const short alpha[], const short clone[], const short mapsx[], @@ -79,18 +57,17 @@ void calcRowLinear32FC1Impl(isa_tag_t, float* dst[], const float* src0[], const const float beta[], const Size& inSz, const Size& outSz, const int lpi, const int l); -extern template void calcRowLinear32FC1Impl(neon_tag, float* dst[], const float* src0[], - const float* src1[], const float alpha[], - const int mapsx[], const float beta[], - const Size& inSz, const Size& outSz, - const int lpi, const int l); - template bool calcRowLinear8UC3C4Impl(isa_tag_t, std::array, chs>& dst, const uint8_t* src0[], const uint8_t* src1[], const short alpha[], const short clone[], const short mapsx[], const short beta[], uint8_t tmp[], const Size& inSz, const Size& outSz, const int lpi, const int l); + +template +void calcRowAreaImpl(isa_tag_t, T dst[], const T* src[], const Size& inSz, + const Size& outSz, A yalpha, const MapperUnit& ymap, + int xmaxdf, const I xindex[], const A xalpha[], W vbuf[]); } // namespace kernels } // namespace gapi } // namespace InferenceEngine diff --git a/inference-engine/src/preprocessing/cpu_x86_avx2/ie_preprocess_gapi_kernels_avx2.cpp b/inference-engine/src/preprocessing/cpu_x86_avx2/ie_preprocess_gapi_kernels_avx2.cpp index c5588b0cf39ad3..fcc13cce4ea2aa 100644 --- a/inference-engine/src/preprocessing/cpu_x86_avx2/ie_preprocess_gapi_kernels_avx2.cpp +++ b/inference-engine/src/preprocessing/cpu_x86_avx2/ie_preprocess_gapi_kernels_avx2.cpp @@ -47,20 +47,6 @@ namespace kernels { namespace avx { -void calcRowArea_8U(uchar dst[], const uchar *src[], const Size& inSz, - const Size& outSz, Q0_16 yalpha, const MapperUnit8U &ymap, - int xmaxdf, const short xindex[], const Q0_16 xalpha[], - Q8_8 vbuf[]) { - calcRowArea_impl(dst, src, inSz, outSz, yalpha, ymap, xmaxdf, xindex, xalpha, vbuf); -} - -void calcRowArea_32F(float dst[], const float *src[], const Size& inSz, - const Size& outSz, float yalpha, const MapperUnit32F& ymap, - int xmaxdf, const int xindex[], const float xalpha[], - float vbuf[]) { - calcRowArea_impl(dst, src, inSz, outSz, yalpha, ymap, xmaxdf, xindex, xalpha, vbuf); -} - CV_ALWAYS_INLINE void main_computation_horizontalPass_lpi4(const v_uint8& val_0, const v_uint8& val_1, const v_uint8& val_2, @@ -528,6 +514,16 @@ template void calcRowLinear32FC1Impl(avx2_tag, float* dst[], const float* src0[] const float alpha[], const int mapsx[], const float beta[], const Size& inSz, const Size& outSz, const int lpi, const int l); + +template void calcRowAreaImpl(avx2_tag, uint8_t dst[], const uint8_t* src[], const Size& inSz, + const Size& outSz, Q0_16 yalpha, const MapperUnit8U &ymap, + int xmaxdf, const short xindex[], const Q0_16 xalpha[], + Q8_8 vbuf[]); + +template void calcRowAreaImpl(avx2_tag, float dst[], const float *src[], const Size& inSz, + const Size& outSz, float yalpha, const MapperUnit32F& ymap, + int xmaxdf, const int xindex[], const float xalpha[], + float vbuf[]); } // namespace kernels } // namespace gapi } // namespace InferenceEngine diff --git a/inference-engine/src/preprocessing/cpu_x86_avx2/ie_preprocess_gapi_kernels_avx2.hpp b/inference-engine/src/preprocessing/cpu_x86_avx2/ie_preprocess_gapi_kernels_avx2.hpp index 73562c3920e9e1..3457134303c968 100644 --- a/inference-engine/src/preprocessing/cpu_x86_avx2/ie_preprocess_gapi_kernels_avx2.hpp +++ b/inference-engine/src/preprocessing/cpu_x86_avx2/ie_preprocess_gapi_kernels_avx2.hpp @@ -44,44 +44,20 @@ void calcRowArea_CVKL_U8_SSE42(const uchar * src[], template void chanToPlaneRowImpl(isa_tag_t, const T* in, const int chan, const int chs, T* out, const int length); -extern template void chanToPlaneRowImpl(avx2_tag, const uint8_t* in, const int chan, const int chs, uint8_t* out, const int length); -extern template void chanToPlaneRowImpl(avx2_tag, const float* in, const int chan, const int chs, float * out, const int length); - template void nv12ToRgbRowImpl(isa_tag_t, const uint8_t** y_rows, const uint8_t* uv_row, uint8_t** out_rows, const int buf_width); -extern template void nv12ToRgbRowImpl(avx2_tag, const uint8_t** y_rows, - const uint8_t* uv_row, uint8_t** out_rows, - const int buf_width); - template void i420ToRgbRowImpl(isa_tag_t, const uint8_t** y_rows, const uint8_t* u_row, const uint8_t* v_row, uint8_t** out_rows, const int buf_width); -extern template void i420ToRgbRowImpl(avx2_tag, const uint8_t** y_rows, const uint8_t* u_row, - const uint8_t* v_row, uint8_t** out_rows, const int buf_width); - template void splitRowImpl(isa_tag_t, const T* in, std::array& outs, const int length); -extern template void splitRowImpl(avx2_tag, const uint8_t* in, std::array& outs, const int length); -extern template void splitRowImpl(avx2_tag, const float* in, std::array& outs, const int length); -extern template void splitRowImpl(avx2_tag, const uint8_t* in, std::array& outs, const int length); -extern template void splitRowImpl(avx2_tag, const float* in, std::array& outs, const int length); -extern template void splitRowImpl(avx2_tag, const uint8_t* in, std::array& outs, const int length); -extern template void splitRowImpl(avx2_tag, const float* in, std::array& outs, const int length); - template void mergeRowImpl(isa_tag_t, const std::array& ins, T* out, const int length); -extern template void mergeRowImpl(avx2_tag, const std::array& ins, uint8_t* out, const int length); -extern template void mergeRowImpl(avx2_tag, const std::array& ins, float* out, const int length); -extern template void mergeRowImpl(avx2_tag, const std::array& ins, uint8_t* out, const int length); -extern template void mergeRowImpl(avx2_tag, const std::array& ins, float* out, const int length); -extern template void mergeRowImpl(avx2_tag, const std::array& ins, uint8_t* out, const int length); -extern template void mergeRowImpl(avx2_tag, const std::array& ins, float* out, const int length); - template bool calcRowLinear8UC1Impl(isa_tag_t, uint8_t* dst[], const uint8_t* src0[], const uint8_t* src1[], const short alpha[], const short clone[], const short mapsx[], @@ -94,17 +70,17 @@ void calcRowLinear32FC1Impl(isa_tag_t, float* dst[], const float* src0[], const const float beta[], const Size& inSz, const Size& outSz, const int lpi, const int l); -extern template void calcRowLinear32FC1Impl(avx2_tag, float* dst[], const float* src0[], const float* src1[], - const float alpha[], const int mapsx[], - const float beta[], const Size& inSz, const Size& outSz, - const int lpi, const int l); - template bool calcRowLinear8UC3C4Impl(isa_tag_t, std::array, chs>& dst, const uint8_t* src0[], const uint8_t* src1[], const short alpha[], const short clone[], const short mapsx[], const short beta[], uint8_t tmp[], const Size& inSz, const Size& outSz, const int lpi, const int l); + +template +void calcRowAreaImpl(isa_tag_t, T dst[], const T* src[], const Size& inSz, + const Size& outSz, A yalpha, const MapperUnit& ymap, + int xmaxdf, const I xindex[], const A xalpha[], W vbuf[]); } // namespace kernels } // namespace gapi } // namespace InferenceEngine diff --git a/inference-engine/src/preprocessing/cpu_x86_avx512/ie_preprocess_gapi_kernels_avx512.cpp b/inference-engine/src/preprocessing/cpu_x86_avx512/ie_preprocess_gapi_kernels_avx512.cpp index 6d7520193cea02..1266e389dcac9d 100644 --- a/inference-engine/src/preprocessing/cpu_x86_avx512/ie_preprocess_gapi_kernels_avx512.cpp +++ b/inference-engine/src/preprocessing/cpu_x86_avx512/ie_preprocess_gapi_kernels_avx512.cpp @@ -41,20 +41,6 @@ namespace kernels { namespace avx512 { -void calcRowArea_8U(uchar dst[], const uchar *src[], const Size& inSz, - const Size& outSz, Q0_16 yalpha, const MapperUnit8U &ymap, - int xmaxdf, const short xindex[], const Q0_16 xalpha[], - Q8_8 vbuf[]) { - calcRowArea_impl(dst, src, inSz, outSz, yalpha, ymap, xmaxdf, xindex, xalpha, vbuf); -} - -void calcRowArea_32F(float dst[], const float *src[], const Size& inSz, - const Size& outSz, float yalpha, const MapperUnit32F& ymap, - int xmaxdf, const int xindex[], const float xalpha[], - float vbuf[]) { - calcRowArea_impl(dst, src, inSz, outSz, yalpha, ymap, xmaxdf, xindex, xalpha, vbuf); -} - CV_ALWAYS_INLINE void verticalPass_lpi4_8U(const uint8_t* src0[], const uint8_t* src1[], uint8_t tmp[], const short beta[], const v_uint8& shuf_mask, const int width) { @@ -555,6 +541,16 @@ template void calcRowLinear32FC1Impl(avx512_tag, float* dst[], const float* src0 const int mapsx[], const float beta[], const Size& inSz, const Size& outSz, const int lpi, const int l); + +template void calcRowAreaImpl(avx512_tag, uint8_t dst[], const uint8_t* src[], const Size& inSz, + const Size& outSz, Q0_16 yalpha, const MapperUnit8U &ymap, + int xmaxdf, const short xindex[], const Q0_16 xalpha[], + Q8_8 vbuf[]); + +template void calcRowAreaImpl(avx512_tag, float dst[], const float *src[], const Size& inSz, + const Size& outSz, float yalpha, const MapperUnit32F& ymap, + int xmaxdf, const int xindex[], const float xalpha[], + float vbuf[]); } // namespace kernels } // namespace gapi } // namespace InferenceEngine diff --git a/inference-engine/src/preprocessing/cpu_x86_avx512/ie_preprocess_gapi_kernels_avx512.hpp b/inference-engine/src/preprocessing/cpu_x86_avx512/ie_preprocess_gapi_kernels_avx512.hpp index bbd43dcbd631c4..e95acb6004c59f 100644 --- a/inference-engine/src/preprocessing/cpu_x86_avx512/ie_preprocess_gapi_kernels_avx512.hpp +++ b/inference-engine/src/preprocessing/cpu_x86_avx512/ie_preprocess_gapi_kernels_avx512.hpp @@ -44,41 +44,19 @@ void calcRowArea_CVKL_U8(const uchar * src[], template void chanToPlaneRowImpl(isa_tag_t, const T* in, const int chan, const int chs, T* out, const int length); -extern template void chanToPlaneRowImpl(avx512_tag, const uint8_t* in, const int chan, const int chs, uint8_t* out, const int length); -extern template void chanToPlaneRowImpl(avx512_tag, const float* in, const int chan, const int chs, float* out, const int length); - template void nv12ToRgbRowImpl(isa_tag_t, const uint8_t** y_rows, const uint8_t* uv_row, uint8_t** out_rows, const int buf_width); -extern template void nv12ToRgbRowImpl(avx512_tag, const uint8_t** y_rows, const uint8_t* uv_row, uint8_t** out_rows, const int buf_width); - template void i420ToRgbRowImpl(isa_tag_t, const uint8_t** y_rows, const uint8_t* u_row, const uint8_t* v_row, uint8_t** out_rows, const int buf_width); -extern template void i420ToRgbRowImpl(avx512_tag, const uint8_t** y_rows, const uint8_t* u_row, - const uint8_t* v_row, uint8_t** out_rows, const int buf_width); - template void splitRowImpl(isa_tag_t, const T* in, std::array& outs, const int length); -extern template void splitRowImpl(avx512_tag, const uint8_t* in, std::array& outs, const int length); -extern template void splitRowImpl(avx512_tag, const float* in, std::array& outs, const int length); -extern template void splitRowImpl(avx512_tag, const uint8_t* in, std::array& outs, const int length); -extern template void splitRowImpl(avx512_tag, const float* in, std::array& outs, const int length); -extern template void splitRowImpl(avx512_tag, const uint8_t* in, std::array& outs, const int length); -extern template void splitRowImpl(avx512_tag, const float* in, std::array& outs, const int length); - template void mergeRowImpl(isa_tag_t, const std::array& ins, T* out, const int length); -extern template void mergeRowImpl(avx512_tag, const std::array& ins, uint8_t* out, const int length); -extern template void mergeRowImpl(avx512_tag, const std::array& ins, float* out, const int length); -extern template void mergeRowImpl(avx512_tag, const std::array& ins, uint8_t* out, const int length); -extern template void mergeRowImpl(avx512_tag, const std::array& ins, float* out, const int length); -extern template void mergeRowImpl(avx512_tag, const std::array& ins, uint8_t* out, const int length); -extern template void mergeRowImpl(avx512_tag, const std::array& ins, float* out, const int length); - template bool calcRowLinear8UC1Impl(isa_tag_t, uint8_t* dst[], const uint8_t* src0[], const uint8_t* src1[], const short alpha[], const short clone[], const short mapsx[], @@ -91,17 +69,17 @@ void calcRowLinear32FC1Impl(isa_tag_t, float* dst[], const float* src0[], const const float beta[], const Size& inSz, const Size& outSz, const int lpi, const int l); -extern template void calcRowLinear32FC1Impl(avx512_tag, float* dst[], const float* src0[], const float* src1[], - const float alpha[], const int mapsx[], - const float beta[], const Size& inSz, const Size& outSz, - const int lpi, const int l); - template bool calcRowLinear8UC3C4Impl(isa_tag_t, std::array, chs>& dst, const uint8_t* src0[], const uint8_t* src1[], const short alpha[], const short clone[], const short mapsx[], const short beta[], uint8_t tmp[], const Size& inSz, const Size& outSz, const int lpi, const int l); + +template +void calcRowAreaImpl(isa_tag_t, T dst[], const T* src[], const Size& inSz, + const Size& outSz, A yalpha, const MapperUnit& ymap, + int xmaxdf, const I xindex[], const A xalpha[], W vbuf[]); } // namespace kernels } // namespace gapi } // namespace InferenceEngine diff --git a/inference-engine/src/preprocessing/cpu_x86_sse42/ie_preprocess_gapi_kernels_sse42.cpp b/inference-engine/src/preprocessing/cpu_x86_sse42/ie_preprocess_gapi_kernels_sse42.cpp index 5ddf951db8af2e..646d334a111e5c 100644 --- a/inference-engine/src/preprocessing/cpu_x86_sse42/ie_preprocess_gapi_kernels_sse42.cpp +++ b/inference-engine/src/preprocessing/cpu_x86_sse42/ie_preprocess_gapi_kernels_sse42.cpp @@ -949,20 +949,6 @@ bool calcRowLinear8UC3C4Impl(sse42_tag, return calcRowLinear_8UC_Impl_(sse42_tag{}, dst, src0, src1, alpha, clone, mapsx, beta, tmp, inSz, outSz, lpi); } -//------------------------------------------------------------------------------ - -void calcRowArea_8U(uchar dst[], const uchar *src[], const Size& inSz, const Size& outSz, - Q0_16 yalpha, const MapperUnit8U &ymap, int xmaxdf, const short xindex[], const Q0_16 xalpha[], - Q8_8 vbuf[]) { - calcRowArea_impl(dst, src, inSz, outSz, yalpha, ymap, xmaxdf, xindex, xalpha, vbuf); -} - -void calcRowArea_32F(float dst[], const float *src[], const Size& inSz, const Size& outSz, - float yalpha, const MapperUnit32F& ymap, int xmaxdf, const int xindex[], const float xalpha[], - float vbuf[]) { - calcRowArea_impl(dst, src, inSz, outSz, yalpha, ymap, xmaxdf, xindex, xalpha, vbuf); -} - //------------------------------------------------------------------------------ #if USE_CVKL @@ -1296,6 +1282,16 @@ template void calcRowLinear32FC1Impl(sse42_tag, float* dst[], const float* src0[ const float alpha[], const int mapsx[], const float beta[], const Size& inSz, const Size& outSz, const int lpi, const int l); + +template void calcRowAreaImpl(sse42_tag, uint8_t dst[], const uint8_t* src[], const Size& inSz, + const Size& outSz, Q0_16 yalpha, const MapperUnit8U &ymap, + int xmaxdf, const short xindex[], const Q0_16 xalpha[], + Q8_8 vbuf[]); + +template void calcRowAreaImpl(sse42_tag, float dst[], const float *src[], const Size& inSz, + const Size& outSz, float yalpha, const MapperUnit32F& ymap, + int xmaxdf, const int xindex[], const float xalpha[], + float vbuf[]); } // namespace kernels } // namespace gapi } // namespace InferenceEngine diff --git a/inference-engine/src/preprocessing/cpu_x86_sse42/ie_preprocess_gapi_kernels_sse42.hpp b/inference-engine/src/preprocessing/cpu_x86_sse42/ie_preprocess_gapi_kernels_sse42.hpp index c71ebc93e7820a..f7aa5b401894f3 100644 --- a/inference-engine/src/preprocessing/cpu_x86_sse42/ie_preprocess_gapi_kernels_sse42.hpp +++ b/inference-engine/src/preprocessing/cpu_x86_sse42/ie_preprocess_gapi_kernels_sse42.hpp @@ -75,6 +75,11 @@ bool calcRowLinear8UC3C4Impl(isa_tag_t, std::array, chs> const short alpha[], const short clone[], const short mapsx[], const short beta[], uint8_t tmp[], const Size& inSz, const Size& outSz, const int lpi, const int l); + +template +void calcRowAreaImpl(isa_tag_t, T dst[], const T* src[], const Size& inSz, + const Size& outSz, A yalpha, const MapperUnit& ymap, + int xmaxdf, const I xindex[], const A xalpha[], W vbuf[]); } // namespace kernels } // namespace gapi } // namespace InferenceEngine diff --git a/inference-engine/src/preprocessing/ie_preprocess_gapi_kernels.cpp b/inference-engine/src/preprocessing/ie_preprocess_gapi_kernels.cpp index c465c49f4a7de7..7aa5bcb1b857ca 100644 --- a/inference-engine/src/preprocessing/ie_preprocess_gapi_kernels.cpp +++ b/inference-engine/src/preprocessing/ie_preprocess_gapi_kernels.cpp @@ -584,9 +584,9 @@ struct typed_resizeLinearU8C1 { const short beta[], uint8_t tmp[], const Size& inSz, const Size& outSz, const int lpi, const int length) { if (!calcRowLinear8UC1Impl(isa_tag_t{}, dst, src0, - src1, alpha, clone, - mapsx, beta, tmp, - inSz, outSz, lpi, length)) + src1, alpha, clone, + mapsx, beta, tmp, + inSz, outSz, lpi, length)) calcRowLinear8UC1Impl(scalar_tag{}, dst, src0, src1, alpha, clone, mapsx, beta, tmp, inSz, outSz, lpi, length); }; @@ -738,714 +738,357 @@ struct typed_resizeLinearU8C3C4 { }; } // namespace -template -struct choose_impl { -GAPI_FLUID_KERNEL(FChanToPlane, ChanToPlane, false) { - static const int Window = 1; - static void run(const cv::gapi::fluid::View& in, int chan, - cv::gapi::fluid::Buffer& out) { - GAPI_DbgAssert(is_cv_type_in_list(out.meta().depth)); - - const auto rowFunc = type_dispatch(out.meta().depth, cv_type_id{}, typed_chan_to_plane_row{}, nullptr); +template +struct AreaDownMapper { + typedef A alpha_type; + typedef I index_type; + typedef W work_type; - GAPI_DbgAssert(rowFunc); + typedef MapperUnit Unit; - rowFunc(in.InLineB(0), chan, in.meta().chan, out.OutLineB(), in.length()); - } -}; + inline Unit map(int outCoord) { + double inCoord0 = outCoord * ratio; + double inCoord1 = (outCoord + 1) * ratio; -GAPI_FLUID_KERNEL(FNV12toRGB, NV12toRGB, false) { - static const int Window = 1; - static const int LPI = 2; - static const auto Kind = cv::GFluidKernel::Kind::YUV420toRGB; + double index0 = std::floor(inCoord0 + 0.001); + double index1 = std::ceil(inCoord1 - 0.001); - static void run(const cv::gapi::fluid::View & in_y, - const cv::gapi::fluid::View & in_uv, - cv::gapi::fluid::Buffer & out) { - GAPI_DbgAssert(is_cv_type_in_list(out.meta().depth)); + double alpha0 = (index0 + 1 - inCoord0) * inv_ratio; + double alpha1 = - (index1 - 1 - inCoord1) * inv_ratio; - const uchar* uv_row = in_uv.InLineB(0); - const uchar* y_rows[2] = { in_y.InLineB(0), in_y.InLineB(1) }; - uchar* out_rows[2] = { out.OutLineB(0), out.OutLineB(1) }; + GAPI_Assert((0 <= outCoord) && (outCoord <= outSz-1)); + GAPI_Assert((0 <= index0) && (index0 < index1) && (index1 <= inSz)); - int buf_width = out.length(); + Unit unit; - const auto rowFunc = type_dispatch(out.meta().depth, cv_type_id{}, typed_nv12_to_rgb_row{}, nullptr); + unit.index0 = checked_cast(index0); + unit.index1 = checked_cast(index1); - GAPI_DbgAssert(rowFunc); + unit.alpha0 = convert_cast(alpha0); + unit.alpha1 = convert_cast(alpha1); - rowFunc(y_rows, uv_row, out_rows, buf_width); + return unit; } -}; -GAPI_FLUID_KERNEL(FI420toRGB, I420toRGB, false) { - static const int Window = 1; - static const int LPI = 2; - static const auto Kind = cv::GFluidKernel::Kind::YUV420toRGB; - - static void run(const cv::gapi::fluid::View & in_y, - const cv::gapi::fluid::View & in_u, - const cv::gapi::fluid::View & in_v, - cv::gapi::fluid::Buffer & out) { - GAPI_DbgAssert(is_cv_type_in_list(out.meta().depth)); - - const uchar* u_row = in_u.InLineB(0); - const uchar* v_row = in_v.InLineB(0); - const uchar* y_rows[2] = { in_y.InLineB(0), in_y.InLineB(1) }; - uchar* out_rows[2] = { out.OutLineB(0), out.OutLineB(1) }; + int inSz, outSz; + double ratio, inv_ratio; - int buf_width = out.length(); - GAPI_DbgAssert(in_u.length() == in_v.length()); + alpha_type alpha; // == inv_ratio, rounded - const auto rowFunc = type_dispatch(out.meta().depth, cv_type_id{}, typed_i420_to_rgb_row{}, nullptr); + AreaDownMapper(int _inSz, int _outSz) { + inSz = _inSz; + outSz = _outSz; - GAPI_DbgAssert(rowFunc); + inv_ratio = invRatio(inSz, outSz); + ratio = 1.0 / inv_ratio; - rowFunc(y_rows, u_row, v_row, out_rows, buf_width); + alpha = convert_cast(inv_ratio); } }; -GAPI_FLUID_KERNEL(FSplit2, Split2, false) { - static const int LPI = 4; - static const int Window = 1; - static void run(const cv::gapi::fluid::View & in, - cv::gapi::fluid::Buffer & out1, - cv::gapi::fluid::Buffer & out2) { - GAPI_DbgAssert(2 == in.meta().chan); - GAPI_DbgAssert(1 == out1.meta().chan); - GAPI_DbgAssert(1 == out2.meta().chan); - GAPI_DbgAssert(in.meta().depth == out1.meta().depth); - GAPI_DbgAssert(in.meta().depth == out2.meta().depth); - GAPI_DbgAssert(is_cv_type_in_list(in.meta().depth)); +namespace areaDownscale32f { +struct Mapper: public AreaDownMapper { + Mapper(int _inSz, int _outSz):AreaDownMapper(_inSz, _outSz) {} +}; +} - const auto rowFunc = type_dispatch(in.meta().depth, cv_type_id{}, typed_split_row{}, nullptr); - for (int i = 0, lpi = out1.lpi(); i < lpi; i++) { - std::array outs = { out1.OutLineB(i), out2.OutLineB(i) }; - rowFunc(in.InLineB(i), outs, in.length()); - } - } +namespace areaDownscale8u { +struct Mapper: public AreaDownMapper { + Mapper(int _inSz, int _outSz):AreaDownMapper(_inSz, _outSz) {} }; +} -GAPI_FLUID_KERNEL(FSplit3, Split3, false) { - static const int LPI = 4; - static const int Window = 1; - static void run(const cv::gapi::fluid::View & in, - cv::gapi::fluid::Buffer & out1, - cv::gapi::fluid::Buffer & out2, - cv::gapi::fluid::Buffer & out3) { - GAPI_DbgAssert(3 == in.meta().chan); - GAPI_DbgAssert(1 == out1.meta().chan); - GAPI_DbgAssert(1 == out2.meta().chan); - GAPI_DbgAssert(1 == out3.meta().chan); - GAPI_DbgAssert(in.meta().depth == out1.meta().depth); - GAPI_DbgAssert(in.meta().depth == out2.meta().depth); - GAPI_DbgAssert(in.meta().depth == out3.meta().depth); +namespace areaUpscale { +struct Mapper { + typedef short alpha_type; + typedef short index_type; + constexpr static const int unity = ONE; - GAPI_DbgAssert(is_cv_type_in_list(in.meta().depth)); + typedef MapperUnit Unit; - const auto rowFunc = type_dispatch(in.meta().depth, cv_type_id{}, typed_split_row{}, nullptr); - for (int i = 0, lpi = out1.lpi(); i < lpi; i++) { - std::array outs = { out1.OutLineB(i), out2.OutLineB(i), - out3.OutLineB(i) }; - rowFunc(in.InLineB(i), outs, in.length()); - } - } -}; + static inline Unit map(double ratio, int start, int max, int outCoord) { + const int s = cvFloor(outCoord*ratio); + float res = static_cast((outCoord + 1) - (s + 1)/ratio); + res = res <= 0 ? 0.f : res - cvFloor(res); -GAPI_FLUID_KERNEL(FSplit4, Split4, false) { - static const int LPI = 4; - static const int Window = 1; - static void run(const cv::gapi::fluid::View & in, - cv::gapi::fluid::Buffer & out1, - cv::gapi::fluid::Buffer & out2, - cv::gapi::fluid::Buffer & out3, - cv::gapi::fluid::Buffer & out4) { - GAPI_DbgAssert(4 == in.meta().chan); - GAPI_DbgAssert(1 == out1.meta().chan); - GAPI_DbgAssert(1 == out2.meta().chan); - GAPI_DbgAssert(1 == out3.meta().chan); - GAPI_DbgAssert(1 == out4.meta().chan); - GAPI_DbgAssert(in.meta().depth == out1.meta().depth); - GAPI_DbgAssert(in.meta().depth == out2.meta().depth); - GAPI_DbgAssert(in.meta().depth == out3.meta().depth); - GAPI_DbgAssert(in.meta().depth == out4.meta().depth); - GAPI_DbgAssert(is_cv_type_in_list(in.meta().depth)); + Unit u; - const auto rowFunc = type_dispatch(in.meta().depth, cv_type_id{}, typed_split_row{}, nullptr); - for (int i = 0, lpi = out1.lpi(); i < lpi; i++) { - std::array outs = { out1.OutLineB(i), out2.OutLineB(i), - out3.OutLineB(i), out4.OutLineB(i) }; - rowFunc(in.InLineB(i), outs, in.length()); - } - } -}; + u.index0 = std::max(s - start, 0); + u.index1 = ((res == 0.0) || (s + 1 >= max)) ? s - start : s - start + 1; -GAPI_FLUID_KERNEL(FMerge2, Merge2, false) { - static const int LPI = 4; - static const int Window = 1; - static void run(const cv::gapi::fluid::View & a, - const cv::gapi::fluid::View & b, - cv::gapi::fluid::Buffer & out) { - GAPI_DbgAssert(is_cv_type_in_list(out.meta().depth)); + u.alpha0 = saturate_cast(ONE * (1.0f - res)); + u.alpha1 = saturate_cast(ONE * res); - const auto rowFunc = type_dispatch(out.meta().depth, cv_type_id{}, typed_merge_row{}, nullptr); - for (int l = 0; l < out.lpi(); l++) { - rowFunc({ a.InLineB(l), b.InLineB(l) }, out.OutLineB(l), a.length()); - } + return u; } }; +} // namespace areaUpscale -GAPI_FLUID_KERNEL(FMerge3, Merge3, false) { - static const int LPI = 4; - static const int Window = 1; - static void run(const cv::gapi::fluid::View & a, - const cv::gapi::fluid::View & b, - const cv::gapi::fluid::View & c, - cv::gapi::fluid::Buffer & out) { - GAPI_DbgAssert(is_cv_type_in_list(out.meta().depth)); +namespace areaUpscale32f { +struct Mapper { + typedef float alpha_type; + typedef int index_type; + constexpr static const float unity = 1; - const auto rowFunc = type_dispatch(out.meta().depth, cv_type_id{}, typed_merge_row{}, nullptr); - for (int l = 0; l < out.lpi(); l++) { - rowFunc({ a.InLineB(l), b.InLineB(l), c.InLineB(l) }, out.OutLineB(l), a.length()); - } - } -}; + typedef MapperUnit Unit; -GAPI_FLUID_KERNEL(FMerge4, Merge4, false) { - static const int LPI = 4; - static const int Window = 1; - static void run(const cv::gapi::fluid::View & a, - const cv::gapi::fluid::View & b, - const cv::gapi::fluid::View & c, - const cv::gapi::fluid::View & d, - cv::gapi::fluid::Buffer & out) { - GAPI_DbgAssert(is_cv_type_in_list(out.meta().depth)); + static inline Unit map(double ratio, int start, int max, int outCoord) { + int s = cvFloor(outCoord*ratio); + float f = static_cast((outCoord+1) - (s+1)/ratio); + f = f <= 0 ? 0.f : f - cvFloor(f); - const auto rowFunc = type_dispatch(out.meta().depth, cv_type_id{}, typed_merge_row{}, nullptr); - for (int l = 0; l < out.lpi(); l++) { - rowFunc({ a.InLineB(l), b.InLineB(l), c.InLineB(l), d.InLineB(l) }, out.OutLineB(l), a.length()); - } + Unit u; + + u.index0 = std::max(s - start, 0); + u.index1 = ((f == 0.0) || s + 1 >= max) ? s - start : s - start + 1; + + u.alpha0 = 1.0f - f; + u.alpha1 = f; + + return u; } }; +} // namespace areaUpscale32f -template -static inline void callRowFunc(uint8_t* dst[], const uint8_t* src0[], - const uint8_t* src1[], const short alpha[], - const short clone[], const short mapsx[], - const short beta[], uint8_t tmp[], const Size& inSz, - const Size& outSz, const int lpi, const int length, const int depth) { - const auto rowFunc = type_dispatch(depth, cv_type_id{}, KT{}, nullptr); +template +static void initScratchArea(const cv::GMatDesc& in, const Size& outSz, + cv::gapi::fluid::Buffer &scratch) { + using Unit = typename Mapper::Unit; + using alpha_type = typename Mapper::alpha_type; + using index_type = typename Mapper::index_type; - GAPI_DbgAssert(rowFunc); + // compute the chunk of input pixels for each output pixel, + // along with the coefficients for taking the weigthed sum - rowFunc(dst, src0, src1, alpha, clone, mapsx, beta, tmp, inSz, outSz, lpi, length); -} + Size inSz = in.size; + Mapper mapper(inSz.width, outSz.width); -template -static inline void callRowFunc(float* dst[], const float* src0[], const float* src1[], - const float alpha[], const float clone[], const int mapsx[], - const float beta[], float tmp[], const Size& inSz, - const Size& outSz, const int lpi, const int length, const int depth) { - const auto rowFunc = type_dispatch(depth, cv_type_id{}, KT{}, nullptr); + std::vector xmaps(outSz.width); + int maxdif = 0; - GAPI_DbgAssert(rowFunc); + for (int w = 0; w < outSz.width; w++) { + Unit map = mapper.map(w); + xmaps[w] = map; - rowFunc(dst, src0, src1, alpha, mapsx, beta, inSz, outSz, lpi, length); -} + maxdif = std::max(maxdif, map.index1 - map.index0); + } -template -static inline void calcRowLinear(const cv::gapi::fluid::View& in, - cv::gapi::fluid::Buffer& out, - cv::gapi::fluid::Buffer& scratch) { - GAPI_DbgAssert(is_cv_type_in_list(out.meta().depth)); + // This assertion is critical for our trick with chunk sizes: + // we would expand a chunk it is smaller than maximal size + GAPI_Assert(inSz.width >= maxdif); - auto inSz = in.meta().size; - auto outSz = out.meta().size; + // pack the input chunks positions and coefficients into scratch-buffer, + // along with the maximal size of chunk (note that chunk size may vary) - auto inY = in.y(); - int length = out.length(); - int outY = out.y(); - int lpi = out.lpi(); - GAPI_DbgAssert(outY + lpi <= outSz.height); + size_t scratch_bytes = sizeof(int) + + outSz.width * sizeof(index_type) + + outSz.width * sizeof(alpha_type) * maxdif + + inSz.width * sizeof(alpha_type); + Size scratch_size{static_cast(scratch_bytes), 1}; - GAPI_DbgAssert(lpi <= 4); + cv::GMatDesc desc(CV_8UC1, 1, scratch_size); - linearScratchDesc scr(inSz.width, inSz.height, outSz.width, - outSz.height, scratch.OutLineB()); + cv::gapi::fluid::Buffer buffer(desc); + scratch = std::move(buffer); - const auto* alpha = scr.alpha; - const auto* clone = scr.clone; - const auto* mapsx = scr.mapsx; - const auto* beta0 = scr.beta; - const auto* mapsy = scr.mapsy; - auto* tmp = scr.tmp; + auto *maxdf = scratch.OutLine(); + auto *index = reinterpret_cast(maxdf + 1); + auto *alpha = reinterpret_cast(index + outSz.width); - const auto* beta = beta0 + outY; - const T* src0[4]; - const T* src1[4]; - T* dst[4]; + for (int w = 0; w < outSz.width; w++) { + // adjust input indices so that: + // - data chunk is exactly maxdif pixels + // - data chunk fits inside input width + int index0 = xmaps[w].index0; + int index1 = xmaps[w].index1; + int i0 = index0; + int i1 = index1; + i1 = std::min(i0 + maxdif, in.size.width); + i0 = i1 - maxdif; + GAPI_DbgAssert(i0 >= 0); - for (int l = 0; l < lpi; l++) { - auto index0 = mapsy[outY + l] - inY; - auto index1 = mapsy[outSz.height + outY + l] - inY; - src0[l] = in.InLine(index0); - src1[l] = in.InLine(index1); - dst[l] = out.OutLine(l); + // fulfill coefficients for the data chunk, + // extending with zeros if any extra pixels + alpha_type *alphaw = &alpha[w * maxdif]; + for (int i = 0; i < maxdif; i++) { + if (i + i0 == index0) { + alphaw[i] = xmaps[w].alpha0; + + } else if (i + i0 == index1 - 1) { + alphaw[i] = xmaps[w].alpha1; + + } else if (i + i0 > index0 && i + i0 < index1 - 1) { + alphaw[i] = mapper.alpha; + + } else { + alphaw[i] = 0; + } + } + + // start input chunk with adjusted position + index[w] = i0; } - callRowFunc(dst, src0, src1, alpha, clone, mapsx, beta, tmp, inSz, outSz, - lpi, length, out.meta().depth); + *maxdf = maxdif; } -GAPI_FLUID_KERNEL(FScalePlane8u, ScalePlane8u, true) { - static const int Window = 1; - static const int LPI = 4; - static const auto Kind = cv::GFluidKernel::Kind::Resize; +#if USE_CVKL +static int getResizeAreaTabSize(int dst_go, int ssize, int dsize, float scale) { + static const float threshold = 1e-3f; + int max_count = 0; - static void initScratch(const cv::GMatDesc & in, - Size outSz, int /*interp*/, - cv::gapi::fluid::Buffer & scratch) { - initScratchLinear(in, outSz, scratch, LPI); - } + for (int col = dst_go; col < dst_go + dsize; col++) { + int count = 0; - static void resetScratch(cv::gapi::fluid::Buffer& /*scratch*/) { - } + float fsx1 = col * scale; + float fsx2 = fsx1 + scale; - static void run(const cv::gapi::fluid::View & in, Size /*sz*/, int /*interp*/, - cv::gapi::fluid::Buffer & out, cv::gapi::fluid::Buffer & scratch) { - calcRowLinear, - resizeLinearU8C1_suptypes>(in, out, scratch); - } -}; + int sx1 = static_cast(ceil(fsx1)); + int sx2 = static_cast(floor(fsx2)); -GAPI_FLUID_KERNEL(FScalePlane32f, ScalePlane32f, true) { - static const int Window = 1; - static const int LPI = 4; - static const auto Kind = cv::GFluidKernel::Kind::Resize; + sx2 = std::min(sx2, ssize - 1); + sx1 = std::min(sx1, sx2); - static void initScratch(const cv::GMatDesc & in, - Size outSz, int /*interp*/, - cv::gapi::fluid::Buffer & scratch) { - GAPI_DbgAssert(in.depth == CV_32F && in.chan == 1); + if ((sx1 - fsx1) > threshold) { + count++; + } - initScratchLinear(in, outSz, scratch, 0); - } + for (int sx = sx1; sx < sx2; sx++) { + count++; + } - static void resetScratch(cv::gapi::fluid::Buffer& /*scratch*/) { + if ((fsx2 - sx2) > threshold) { + count++; + } + max_count = std::max(max_count, count); } - static void run(const cv::gapi::fluid::View & in, Size /*sz*/, int /*interp*/, - cv::gapi::fluid::Buffer & out, cv::gapi::fluid::Buffer & scratch) { - calcRowLinear, - resizeLinearF32C1_suptypes>(in, out, scratch); - } -}; + return max_count; +} -template -static inline void calcRowLinearC(const cv::gapi::fluid::View& in, - std::array, chs>& out, - cv::gapi::fluid::Buffer& scratch) { - GAPI_DbgAssert(is_cv_type_in_list(in.meta().depth)); +// taken from: ie_preprocess_data.cpp +static void computeResizeAreaTab(int src_go, int dst_go, int ssize, int dsize, float scale, + uint16_t* si, uint16_t* alpha, int max_count) { + static const float threshold = 1e-3f; + int k = 0; - auto inSz = in.meta().size; - auto outSz = out[0].get().meta().size; + for (int col = dst_go; col < dst_go + dsize; col++) { + int count = 0; - auto inY = in.y(); - auto outY = out[0].get().y(); - auto lpi = out[0].get().lpi(); + float fsx1 = col * scale; + float fsx2 = fsx1 + scale; + float cellWidth = (std::min)(scale, ssize - fsx1); - GAPI_DbgAssert(outY + lpi <= outSz.height); - GAPI_DbgAssert(lpi <= 4); + int sx1 = static_cast(ceil(fsx1)); + int sx2 = static_cast(floor(fsx2)); - linearScratchDesc scr(inSz.width, inSz.height, outSz.width, outSz.height, scratch.OutLineB()); + sx2 = (std::min)(sx2, ssize - 1); + sx1 = (std::min)(sx1, sx2); - const auto *alpha = scr.alpha; - const auto *clone = scr.clone; - const auto *mapsx = scr.mapsx; - const auto *beta0 = scr.beta; - const auto *mapsy = scr.mapsy; - auto *tmp = scr.tmp; + si[col - dst_go] = (uint16_t)(sx1 - src_go); - const auto *beta = beta0 + outY; - const T *src0[4]; - const T *src1[4]; - std::array, chs> dst; + if (sx1 - fsx1 > threshold) { + si[col - dst_go] = (uint16_t)(sx1 - src_go - 1); + alpha[k++] = (uint16_t)((1 << 16) * ((sx1 - fsx1) / cellWidth)); + count++; + } - for (int l = 0; l < lpi; l++) { - auto index0 = mapsy[outY + l] - inY; - auto index1 = mapsy[outSz.height + outY + l] - inY; - src0[l] = in.InLine(index0); - src1[l] = in.InLine(index1); - for (int c=0; c < chs; c++) { - dst[c][l] = out[c].get().template OutLine(l); + for (int sx = sx1; sx < sx2; sx++) { + alpha[k++] = (uint16_t)((1 << 16) * (1.0f / cellWidth)); + count++; } - } - auto length = out[0].get().length(); - const auto rowFunc = type_dispatch(in.meta().depth, - cv_type_id{}, - typed_resizeLinearU8C3C4{}, - nullptr); - GAPI_DbgAssert(rowFunc); + if (fsx2 - sx2 > threshold) { + alpha[k++] = (uint16_t)((1 << 16) * ((std::min)((std::min)(fsx2 - sx2, 1.f), cellWidth) / cellWidth)); + count++; + } - rowFunc(dst, src0, src1, alpha, clone, mapsx, beta, tmp, inSz, outSz, lpi, length); + if (count != max_count) { + alpha[k++] = 0; + } + } } -GAPI_FLUID_KERNEL(FScalePlanes, ScalePlanes, true) { - static const int Window = 1; - static const int LPI = 4; - static const auto Kind = cv::GFluidKernel::Kind::Resize; - - static void initScratch(const cv::GMatDesc& in, int, Size, - Size outSz, int /*interp*/, - cv::gapi::fluid::Buffer &scratch) { - initScratchLinear(in, outSz, scratch, LPI); +// teken from: ie_preprocess_data.cpp +static void generate_alpha_and_id_arrays(int x_max_count, int dcols, const uint16_t* xalpha, uint16_t* xsi, + uint16_t** alpha, uint16_t** sxid) { + if (x_max_count <= 4) { + for (int col = 0; col < dcols; col++) { + for (int x = 0; x < x_max_count; x++) { + alpha[x][col] = xalpha[col*x_max_count + x]; + } + } } + if (x_max_count <= 4) { + for (int col = 0; col <= dcols - 8; col += 8) { + for (int chunk_num_h = 0; chunk_num_h < x_max_count; chunk_num_h++) { + for (int i = 0; i < 128 / 16; i++) { + int id_diff = xsi[col + i] - xsi[col]; - static void resetScratch(cv::gapi::fluid::Buffer& /*scratch*/) { - } + for (int chunk_num_v = 0; chunk_num_v < x_max_count; chunk_num_v++) { + uint16_t* sxidp = sxid[chunk_num_v] + col * x_max_count + chunk_num_h * 8; - static void run(const cv::gapi::fluid::View& in, int, Size, Size/*sz*/, int /*interp*/, - cv::gapi::fluid::Buffer& out1, - cv::gapi::fluid::Buffer& out2, - cv::gapi::fluid::Buffer& out3, - cv::gapi::fluid::Buffer& scratch) { - constexpr int numChan = 3; - std::array, numChan> out = {out1, out2, out3}; - calcRowLinearC(in, out, scratch); + int id0 = (id_diff + chunk_num_v) * 2 + 0; + int id1 = (id_diff + chunk_num_v) * 2 + 1; + + (reinterpret_cast(sxidp + i))[0] = static_cast(id0 >= (chunk_num_h * 16) && id0 < (chunk_num_h + 1) * 16 ? id0 : -1); + (reinterpret_cast(sxidp + i))[1] = static_cast(id1 >= (chunk_num_h * 16) && id1 < (chunk_num_h + 1) * 16 ? id1 : -1); + } + } + } + } } -}; +} -GAPI_FLUID_KERNEL(FScalePlanes4, ScalePlanes4, true) { - static const int Window = 1; - static const int LPI = 4; - static const auto Kind = cv::GFluidKernel::Kind::Resize; +// taken from: ie_preprocess_data.cpp +// (and simplified for specifically downscale area 8u) +static size_t resize_get_buffer_size(const Size& inSz, const Size& outSz) { + int dst_full_width = outSz.width; + int dst_full_height = outSz.height; + int src_full_width = inSz.width; + int src_full_height = inSz.height; - static void initScratch(const cv::GMatDesc& in, int, Size, - Size outSz, int /*interp*/, - cv::gapi::fluid::Buffer &scratch) { - initScratchLinear(in, outSz, scratch, LPI); - } + auto resize_area_u8_downscale_sse_buffer_size = [&]() { + const int dwidth = outSz.width; + const int dheight = outSz.height; + const int swidth = inSz.width; - static void resetScratch(cv::gapi::fluid::Buffer& /*scratch*/) { - } + const int dst_go_x = 0; + const int dst_go_y = 0; - static void run(const cv::gapi::fluid::View& in, int, Size, Size/*sz*/, int /*interp*/, - cv::gapi::fluid::Buffer& out1, - cv::gapi::fluid::Buffer& out2, - cv::gapi::fluid::Buffer& out3, - cv::gapi::fluid::Buffer& out4, - cv::gapi::fluid::Buffer& scratch) { - constexpr int numChan = 4; - std::array, numChan> out = {out1, out2, out3, out4}; - calcRowLinearC(in, out, scratch); - } -}; -}; - -namespace { -struct CC_and_MergeISA { - cv::gapi::GKernelPackage& pckg; - - CC_and_MergeISA(cv::gapi::GKernelPackage& _pckg) : pckg(_pckg) {} - - template - inline bool operator()(type_to_type) { - pckg.include::FI420toRGB>(); - pckg.include::FNV12toRGB>(); - pckg.include::FChanToPlane>(); - pckg.include::FMerge2>(); - pckg.include::FMerge3>(); - pckg.include::FMerge4>(); - //at the moment type_dispatch requires something to be returned by the lambda - return true; - } -}; - -struct Split_ResizeISA { - cv::gapi::GKernelPackage& pckg; - - Split_ResizeISA(cv::gapi::GKernelPackage& _pckg) : pckg(_pckg) {} - - template - inline bool operator()(type_to_type) { - pckg.include::FSplit2>(); - pckg.include::FSplit3>(); - pckg.include::FSplit4>(); - pckg.include::FScalePlane8u>(); - pckg.include::FScalePlane32f>(); - pckg.include::FScalePlanes>(); - pckg.include::FScalePlanes4>(); - //at the moment type_dispatch requires something to be returned by the lambda - return true; - } -}; -} //namespace - -inline cv::gapi::GKernelPackage FKernelsChooseISA() { - // At the moment AVX512 implementation of wide universal intrinsics is slower than AVX2. - // So, disable it for now. - using isas = remove_t; - - cv::gapi::GKernelPackage pckg1, pckg2; - CC_and_MergeISA ccISA{ pckg1 }; - Split_ResizeISA sISA{ pckg2 }; - - type_dispatch(is_isa_present{}, ccISA, false); - type_dispatch(is_isa_present{}, sISA, false); - - return combine(pckg1, pckg2); -} - -//---------------------------------------------------------------------- - -GAPI_COMPOUND_KERNEL(FScalePlane, ScalePlane) { - static cv::GMat expand(cv::GMat in, int type, const Size& szIn, const Size& szOut, int interp) { - GAPI_DbgAssert(CV_8UC1 == type || CV_32FC1 == type); - GAPI_DbgAssert(cv::INTER_AREA == interp || cv::INTER_LINEAR == interp); - - if (cv::INTER_AREA == interp) { - bool upscale = szIn.width < szOut.width || szIn.height < szOut.height; - if (CV_8UC1 == type) { - if (upscale) - return UpscalePlaneArea8u::on(in, szOut, interp); - else - return ScalePlaneArea8u::on(in, szOut, interp); - } - if (CV_32FC1 == type) { - if (upscale) - return UpscalePlaneArea32f::on(in, szOut, interp); - else - return ScalePlaneArea32f::on(in, szOut, interp); - } - } - - if (cv::INTER_LINEAR == interp) { - if (CV_8UC1 == type) { - return ScalePlane8u::on(in, szOut, interp); - } - if (CV_32FC1 == type) { - return ScalePlane32f::on(in, szOut, interp); - } - } - - GAPI_Assert(!"unsupported parameters"); - return {}; - } -}; - -template -static void calcRowLinear(const cv::gapi::fluid::View & in, - cv::gapi::fluid::Buffer& out, - cv::gapi::fluid::Buffer& scratch) { - using alpha_type = typename Mapper::alpha_type; - - auto inSz = in.meta().size; - auto outSz = out.meta().size; - - auto inY = in.y(); - int length = out.length(); - int outY = out.y(); - int lpi = out.lpi(); - GAPI_DbgAssert(outY + lpi <= outSz.height); - - GAPI_DbgAssert(lpi <= 4); - - linearScratchDesc scr(inSz.width, inSz.height, outSz.width, outSz.height, scratch.OutLineB()); - - const auto *alpha = scr.alpha; - const auto *mapsx = scr.mapsx; - const auto *beta0 = scr.beta; - const auto *mapsy = scr.mapsy; - - const auto *beta = beta0 + outY; - const T *src0[4]; - const T *src1[4]; - T *dst[4]; - - for (int l = 0; l < lpi; l++) { - auto index0 = mapsy[outY + l] - inY; - auto index1 = mapsy[outSz.height + outY + l] - inY; - src0[l] = in.InLine(index0); - src1[l] = in.InLine(index1); - dst[l] = out.OutLine(l); - } - - for (int l = 0; l < lpi; l++) { - constexpr static const auto unity = Mapper::unity; - - auto beta0 = beta[l]; - auto beta1 = saturate_cast(unity - beta[l]); - - for (int x = 0; x < length; x++) { - auto alpha0 = alpha[x]; - auto alpha1 = saturate_cast(unity - alpha[x]); - auto sx0 = mapsx[x]; - auto sx1 = sx0 + 1; - T tmp0 = calc(beta0, src0[l][sx0], beta1, src1[l][sx0]); - T tmp1 = calc(beta0, src0[l][sx1], beta1, src1[l][sx1]); - dst[l][x] = calc(alpha0, tmp0, alpha1, tmp1); - } - } -} - -//------------------------------------------------------------------------------ -namespace areaUpscale { -struct Mapper { - typedef short alpha_type; - typedef short index_type; - constexpr static const int unity = ONE; - - typedef MapperUnit Unit; - - static inline Unit map(double ratio, int start, int max, int outCoord) { - int s = cvFloor(outCoord*ratio); - float f = static_cast((outCoord+1) - (s+1)/ratio); - f = f <= 0 ? 0.f : f - cvFloor(f); - - Unit u; - - u.index0 = std::max(s - start, 0); - u.index1 = ((f == 0.0) || s + 1 >= max) ? s - start : s - start + 1; - - u.alpha0 = saturate_cast(ONE * (1.0f - f)); - u.alpha1 = saturate_cast(ONE * f); - - return u; - } -}; -} // namespace areaUpscale - -namespace areaUpscale32f { -struct Mapper { - typedef float alpha_type; - typedef int index_type; - constexpr static const float unity = 1; - - typedef MapperUnit Unit; - - static inline Unit map(double ratio, int start, int max, int outCoord) { - int s = cvFloor(outCoord*ratio); - float f = static_cast((outCoord+1) - (s+1)/ratio); - f = f <= 0 ? 0.f : f - cvFloor(f); - - Unit u; - - u.index0 = std::max(s - start, 0); - u.index1 = ((f == 0.0) || s + 1 >= max) ? s - start : s - start + 1; - - u.alpha0 = 1.0f - f; - u.alpha1 = f; - - return u; - } -}; -} // namespace areaUpscale32f - -//------------------------------------------------------------------------------ - -template -struct AreaDownMapper { - typedef A alpha_type; - typedef I index_type; - typedef W work_type; - - typedef MapperUnit Unit; - - inline Unit map(int outCoord) { - double inCoord0 = outCoord * ratio; - double inCoord1 = (outCoord + 1) * ratio; - - double index0 = std::floor(inCoord0 + 0.001); - double index1 = std::ceil(inCoord1 - 0.001); - - double alpha0 = (index0 + 1 - inCoord0) * inv_ratio; - double alpha1 = - (index1 - 1 - inCoord1) * inv_ratio; - - GAPI_Assert(0 <= outCoord && outCoord <= outSz-1); - GAPI_Assert(0 <= index0 && index0 < index1 && index1 <= inSz); - - Unit unit; - - unit.index0 = checked_cast(index0); - unit.index1 = checked_cast(index1); - - unit.alpha0 = convert_cast(alpha0); - unit.alpha1 = convert_cast(alpha1); - - return unit; - } - - int inSz, outSz; - double ratio, inv_ratio; - - alpha_type alpha; // == inv_ratio, rounded - - void init(int _inSz, int _outSz) { - inSz = _inSz; - outSz = _outSz; + int x_max_count = getResizeAreaTabSize(dst_go_x, src_full_width, dwidth, static_cast(src_full_width) / dst_full_width) + 1; + int y_max_count = getResizeAreaTabSize(dst_go_y, src_full_height, dheight, static_cast(src_full_height) / dst_full_height) + 1; - inv_ratio = invRatio(inSz, outSz); - ratio = 1.0 / inv_ratio; + size_t si_buf_size = sizeof(uint16_t) * dwidth + sizeof(uint16_t) * dheight; + size_t alpha_buf_size = + sizeof(uint16_t) * (dwidth * x_max_count + 8 * 16) + sizeof(uint16_t) * dheight * y_max_count; + size_t vert_sum_buf_size = sizeof(uint16_t) * (swidth * 2); + size_t alpha_array_buf_size = sizeof(uint16_t) * 4 * dwidth; + size_t sxid_array_buf_size = sizeof(uint16_t) * 4 * 4 * dwidth; - alpha = convert_cast(inv_ratio); - } -}; + size_t buffer_size = si_buf_size + + alpha_buf_size + + vert_sum_buf_size + + alpha_array_buf_size + + sxid_array_buf_size; -namespace areaDownscale32f { -struct Mapper: public AreaDownMapper { - Mapper(int _inSz, int _outSz) { - init(_inSz, _outSz); - } -}; -} + return buffer_size; + }; -namespace areaDownscale8u { -struct Mapper: public AreaDownMapper { - Mapper(int _inSz, int _outSz) { - init(_inSz, _outSz); - } -}; + return resize_area_u8_downscale_sse_buffer_size(); } -template -static void initScratchArea(const cv::GMatDesc& in, const Size& outSz, - cv::gapi::fluid::Buffer &scratch) { - using Unit = typename Mapper::Unit; - using alpha_type = typename Mapper::alpha_type; - using index_type = typename Mapper::index_type; - - // compute the chunk of input pixels for each output pixel, - // along with the coefficients for taking the weigthed sum - - Size inSz = in.size; - Mapper mapper(inSz.width, outSz.width); - - std::vector xmaps(outSz.width); - int maxdif = 0; - - for (int w = 0; w < outSz.width; w++) { - Unit map = mapper.map(w); - xmaps[w] = map; - - int dif = map.index1 - map.index0; - if (dif > maxdif) - maxdif = dif; - } +// buffer-fulfill is taken from: ie_preprocess_data_sse42.cpp +static void initScratchArea_CVKL_U8(const cv::GMatDesc & in, + const Size & outSz, + cv::gapi::fluid::Buffer & scratch) { + const Size& inSz = in.size; - // This assertion is critical for our trick with chunk sizes: - // we would expand a chunk it is is smaller than maximal size - GAPI_Assert(inSz.width >= maxdif); + // estimate buffer size + size_t scratch_bytes = resize_get_buffer_size(inSz, outSz); - // pack the input chunks positions and coefficients into scratch-buffer, - // along with the maximal size of chunk (note that chunk size may vary) + // allocate buffer - size_t scratch_bytes = sizeof(int) - + outSz.width * sizeof(index_type) - + outSz.width * sizeof(alpha_type) * maxdif - + inSz.width * sizeof(alpha_type); Size scratch_size{static_cast(scratch_bytes), 1}; cv::GMatDesc desc; @@ -1456,60 +1099,64 @@ static void initScratchArea(const cv::GMatDesc& in, const Size& outSz, cv::gapi::fluid::Buffer buffer(desc); scratch = std::move(buffer); - auto *maxdf = scratch.OutLine(); - auto *index = reinterpret_cast(maxdf + 1); - auto *alpha = reinterpret_cast(index + outSz.width); -// auto *vbuf = reinterpret_cast(alpha + outSz.width * maxdif); + // fulfil buffer + { + // this code is taken from: ie_preprocess_data_sse42.cpp + // (and simplified for 1-channel cv::Mat instead of blob) - for (int w = 0; w < outSz.width; w++) { - // adjust input indices so that: - // - data chunk is exactly maxdif pixels - // - data chunk fits inside input width - int index0 = xmaps[w].index0; - int index1 = xmaps[w].index1; - int i0 = index0, i1 = index1; - i1 = (std::min)(i0 + maxdif, in.size.width); - i0 = i1 - maxdif; - GAPI_DbgAssert(i0 >= 0); + auto dwidth = outSz.width; + auto dheight = outSz.height; + auto swidth = inSz.width; + auto sheight = inSz.height; - // fulfill coefficients for the data chunk, - // extending with zeros if any extra pixels - alpha_type *alphaw = &alpha[w * maxdif]; - for (int i = 0; i < maxdif; i++) { - if (i + i0 == index0) { - alphaw[i] = xmaps[w].alpha0; + const int src_go_x = 0; + const int src_go_y = 0; + const int dst_go_x = 0; + const int dst_go_y = 0; - } else if (i + i0 == index1 - 1) { - alphaw[i] = xmaps[w].alpha1; + auto src_full_width = swidth; + auto src_full_height = sheight; + auto dst_full_width = dwidth; + auto dst_full_height = dheight; - } else if (i + i0 > index0 && i + i0 < index1 - 1) { - alphaw[i] = mapper.alpha; + float scale_x = static_cast(src_full_width) / dst_full_width; + float scale_y = static_cast(src_full_height) / dst_full_height; - } else { - alphaw[i] = 0; - } - } + int x_max_count = getResizeAreaTabSize(dst_go_x, src_full_width, dwidth, scale_x); + int y_max_count = getResizeAreaTabSize(dst_go_y, src_full_height, dheight, scale_y); - // start input chunk with adjusted position - index[w] = i0; - } + auto* maxdif = scratch.OutLine(); + auto* xsi = reinterpret_cast(maxdif + 2); + auto* ysi = xsi + dwidth; + auto* xalpha = ysi + dheight; + auto* yalpha = xalpha + dwidth*x_max_count + 8*16; - *maxdf = maxdif; -} + maxdif[0] = x_max_count; + maxdif[1] = y_max_count; -#if defined __GNUC__ -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif + computeResizeAreaTab(src_go_x, dst_go_x, src_full_width, dwidth, scale_x, xsi, xalpha, x_max_count); + computeResizeAreaTab(src_go_y, dst_go_y, src_full_height, dheight, scale_y, ysi, yalpha, y_max_count); -template -static void calcAreaRow(const cv::gapi::fluid::View& in, cv::gapi::fluid::Buffer& out, - cv::gapi::fluid::Buffer& scratch) { - using Unit = typename Mapper::Unit; - using alpha_type = typename Mapper::alpha_type; - using index_type = typename Mapper::index_type; - using work_type = typename Mapper::work_type; + int vest_sum_size = 2*swidth; + uint16_t* vert_sum = yalpha + dheight*y_max_count; + uint16_t* alpha0 = vert_sum + vest_sum_size; + uint16_t* alpha1 = alpha0 + dwidth; + uint16_t* alpha2 = alpha1 + dwidth; + uint16_t* alpha3 = alpha2 + dwidth; + uint16_t* sxid0 = alpha3 + dwidth; + uint16_t* sxid1 = sxid0 + 4*dwidth; + uint16_t* sxid2 = sxid1 + 4*dwidth; + uint16_t* sxid3 = sxid2 + 4*dwidth; + + uint16_t* alpha[] = {alpha0, alpha1, alpha2, alpha3}; + uint16_t* sxid[] = {sxid0, sxid1, sxid2, sxid3}; + generate_alpha_and_id_arrays(x_max_count, dwidth, xalpha, xsi, alpha, sxid); + } +} +static void calcAreaRow_CVKL_U8(const cv::gapi::fluid::View & in, + cv::gapi::fluid::Buffer & out, + cv::gapi::fluid::Buffer & scratch) { Size inSz = in.meta().size; Size outSz = out.meta().size; @@ -1517,508 +1164,633 @@ static void calcAreaRow(const cv::gapi::fluid::View& in, cv::gapi::fluid::Buffer GAPI_DbgAssert(inSz.width >= outSz.width); GAPI_DbgAssert(inSz.height >= outSz.height); -// Mapper xmapper(inSz.width, outSz.width); - Mapper ymapper(inSz.height, outSz.height); - - auto *xmaxdf = scratch.OutLine(); - auto maxdif = xmaxdf[0]; - - auto *xindex = reinterpret_cast(xmaxdf + 1); - auto *xalpha = reinterpret_cast(xindex + outSz.width); - auto *vbuf_c = reinterpret_cast(xalpha + outSz.width * maxdif); + int dwidth = outSz.width; + int dheight = outSz.height; - auto *vbuf = const_cast(vbuf_c); + auto* maxdif = scratch.OutLine(); + int x_max_count = maxdif[0]; + int y_max_count = maxdif[1]; - int iny = in.y(); - int y = out.y(); + auto* xsi = reinterpret_cast(maxdif + 2); + auto* ysi = xsi + dwidth; + auto* xalpha = ysi + dheight; + auto* yalpha = xalpha + dwidth*x_max_count + 8*16; + auto* vert_sum = yalpha + dheight*y_max_count; + + int iny = in.y(); + int y = out.y(); int lpi = out.lpi(); GAPI_DbgAssert(y + lpi <= outSz.height); for (int l = 0; l < lpi; l++) { - Unit ymap = ymapper.map(y + l); + int yin0 = ysi[y + l]; + int yin1 = yin0 + y_max_count; - GAPI_Assert(ymap.index1 - ymap.index0 <= 32); - GAPI_Assert(ymap.index1 - ymap.index0 > 0); - const T *src[32] = {}; + GAPI_Assert(yin1 - yin0 <= 32); + const uint8_t *src[32] = {}; - for (int yin = ymap.index0; yin < ymap.index1; yin++) { - src[yin - ymap.index0] = in.InLine(yin - iny); + for (int yin = yin0; yin < yin1 && yin < inSz.height; yin++) { + if (yalpha[(y+l)*y_max_count + yin - yin0] == 0) { + src[yin - yin0] = in.InLine(yin - iny - 1); + } else { + src[yin - yin0] = in.InLine(yin - iny); + } } - auto dst = out.OutLine(l); - - #ifdef HAVE_AVX512 - if (with_cpu_x86_avx512f()) { - if (std::is_same::value) { - avx512::calcRowArea_8U(reinterpret_cast(dst), - reinterpret_cast(src), - inSz, outSz, - static_cast(ymapper.alpha), - reinterpret_cast(ymap), - xmaxdf[0], - reinterpret_cast(xindex), - reinterpret_cast(xalpha), - reinterpret_cast(vbuf)); - continue; // next l = 0, ..., lpi-1 - } + uint8_t *dst = out.OutLine(l); - if (std::is_same::value) { - avx512::calcRowArea_32F(reinterpret_cast(dst), - reinterpret_cast(src), - inSz, outSz, - static_cast(ymapper.alpha), - reinterpret_cast(ymap), - xmaxdf[0], - reinterpret_cast(xindex), - reinterpret_cast(xalpha), - reinterpret_cast(vbuf)); - continue; - } - } - #endif // HAVE_AVX512 - - #ifdef HAVE_AVX2 - if (with_cpu_x86_avx2()) { - if (std::is_same::value) { - avx::calcRowArea_8U(reinterpret_cast(dst), - reinterpret_cast(src), - inSz, outSz, - static_cast(ymapper.alpha), - reinterpret_cast(ymap), - xmaxdf[0], - reinterpret_cast(xindex), - reinterpret_cast(xalpha), - reinterpret_cast(vbuf)); - continue; // next l = 0, ..., lpi-1 - } + calcRowArea_CVKL_U8_SSE42(src, dst, inSz, outSz, y + l, xsi, ysi, + xalpha, yalpha, x_max_count, y_max_count, vert_sum); + } +} - if (std::is_same::value) { - avx::calcRowArea_32F(reinterpret_cast(dst), - reinterpret_cast(src), - inSz, outSz, - static_cast(ymapper.alpha), - reinterpret_cast(ymap), - xmaxdf[0], - reinterpret_cast(xindex), - reinterpret_cast(xalpha), - reinterpret_cast(vbuf)); - continue; - } - } - #endif // HAVE_AVX2 +#endif // USE_CVKL - #ifdef HAVE_SSE - if (with_cpu_x86_sse42()) { - if (std::is_same::value) { - calcRowArea_8U(reinterpret_cast(dst), - reinterpret_cast(src), - inSz, outSz, - static_cast(ymapper.alpha), - reinterpret_cast(ymap), - xmaxdf[0], - reinterpret_cast(xindex), - reinterpret_cast(xalpha), - reinterpret_cast(vbuf)); - continue; // next l = 0, ..., lpi-1 - } +namespace { - if (std::is_same::value) { - calcRowArea_32F(reinterpret_cast(dst), - reinterpret_cast(src), - inSz, outSz, - static_cast(ymapper.alpha), - reinterpret_cast(ymap), - xmaxdf[0], - reinterpret_cast(xindex), - reinterpret_cast(xalpha), - reinterpret_cast(vbuf)); - continue; - } +using resizeArea_suptypes = typelist; + +template +inline void calcRowAreaImpl(scalar_tag, + T dst[], const T* src[], const Size& inSz, + const Size& outSz, A yalpha, + const MapperUnit& ymap, int xmaxdf, + const I xindex[], const A xalpha[], + W vbuf[]) { + // vertical pass + int y_1st = ymap.index0; + int ylast = ymap.index1 - 1; + if (y_1st < ylast) { + for (int w = 0; w < inSz.width; w++) { + vbuf[w] = mulas(ymap.alpha0, src[0][w]) // Q8_8 = Q0_16 * U8 + + mulas(ymap.alpha1, src[ylast - y_1st][w]); } - #endif // HAVE_SSE - - // vertical pass - int y_1st = ymap.index0; - int ylast = ymap.index1 - 1; - if (y_1st < ylast) { - for (int w = 0; w < inSz.width; w++) { - vbuf[w] = mulas(ymap.alpha0, src[0][w]) // Q8_8 = Q0_16 * U8 - + mulas(ymap.alpha1, src[ylast - y_1st][w]); - } - for (int i = 1; i < ylast - y_1st; i++) { - for (int w = 0; w < inSz.width; w++) { - vbuf[w] += mulas(ymapper.alpha, src[i][w]); - } - } - } else { + for (int i = 1; i < ylast - y_1st; i++) { for (int w = 0; w < inSz.width; w++) { - vbuf[w] = convert_cast(src[0][w]); // Q8_8 = U8 + vbuf[w] += mulas(yalpha, src[i][w]); } } + } else { + for (int w = 0; w < inSz.width; w++) { + vbuf[w] = convert_cast(src[0][w]); // Q8_8 = U8 + } + } - // horizontal pass - for (int x = 0; x < outSz.width; x++) { - work_type sum = 0; - - auto index = xindex[x]; - const auto *alpha = &xalpha[x * maxdif]; + // horizontal pass + for (int x = 0; x < outSz.width; x++) { + W sum = 0; - for (int i = 0; i < maxdif; i++) { - sum += mulaw(alpha[i], vbuf[index + i]); // Q8_8 = Q0_16 * Q8_8 - } + auto index = xindex[x]; + const auto *alpha = &xalpha[x * xmaxdf]; - dst[x] = convert_cast(sum); // U8 = Q8_8 + for (int i = 0; i < xmaxdf; i++) { + sum += mulaw(alpha[i], vbuf[index + i]); // Q8_8 = Q0_16 * Q8_8 } + + dst[x] = convert_cast(sum); // U8 = Q8_8 } } -#if defined __GNUC__ -# pragma GCC diagnostic pop -#endif +template +struct typed_resizeArea { + using p_f = void (*)(T dst[], const T* src[], const Size& inSz, const Size& outSz, + A yalpha, const MapperUnit& ymap, int xmaxdf, + const I xindex[], const A xalpha[], W vbuf[]); + +template +inline p_f operator()(type_to_type) { + return [](T dst[], const T* src[], const Size& inSz, const Size& outSz, + A yalpha, const MapperUnit& ymap, int xmaxdf, + const I xindex[], const A xalpha[], W vbuf[]) { + calcRowAreaImpl(isa_tag_t{}, dst, src, inSz, outSz, yalpha, + ymap, xmaxdf, xindex, xalpha, vbuf); + }; +} +}; +} // namespace -//---------------------------------------------------------------------- +template +struct choose_impl { +GAPI_FLUID_KERNEL(FChanToPlane, ChanToPlane, false) { + static const int Window = 1; + static void run(const cv::gapi::fluid::View& in, int chan, + cv::gapi::fluid::Buffer& out) { + GAPI_DbgAssert(is_cv_type_in_list(out.meta().depth)); -#if USE_CVKL + const auto rowFunc = type_dispatch(out.meta().depth, cv_type_id{}, typed_chan_to_plane_row{}, nullptr); -// taken from: ie_preprocess_data.cpp -static int getResizeAreaTabSize(int dst_go, int ssize, int dsize, float scale) { - static const float threshold = 1e-3f; - int max_count = 0; + GAPI_DbgAssert(rowFunc); - for (int col = dst_go; col < dst_go + dsize; col++) { - int count = 0; + rowFunc(in.InLineB(0), chan, in.meta().chan, out.OutLineB(), in.length()); + } +}; - float fsx1 = col * scale; - float fsx2 = fsx1 + scale; +GAPI_FLUID_KERNEL(FNV12toRGB, NV12toRGB, false) { + static const int Window = 1; + static const int LPI = 2; + static const auto Kind = cv::GFluidKernel::Kind::YUV420toRGB; - int sx1 = static_cast(ceil(fsx1)); - int sx2 = static_cast(floor(fsx2)); + static void run(const cv::gapi::fluid::View & in_y, + const cv::gapi::fluid::View & in_uv, + cv::gapi::fluid::Buffer & out) { + GAPI_DbgAssert(is_cv_type_in_list(out.meta().depth)); - sx2 = (std::min)(sx2, ssize - 1); - sx1 = (std::min)(sx1, sx2); + const uchar* uv_row = in_uv.InLineB(0); + const uchar* y_rows[2] = { in_y.InLineB(0), in_y.InLineB(1) }; + uchar* out_rows[2] = { out.OutLineB(0), out.OutLineB(1) }; - if (sx1 - fsx1 > threshold) { - count++; - } + int buf_width = out.length(); - for (int sx = sx1; sx < sx2; sx++) { - count++; - } + const auto rowFunc = type_dispatch(out.meta().depth, cv_type_id{}, typed_nv12_to_rgb_row{}, nullptr); - if (fsx2 - sx2 > threshold) { - count++; - } - max_count = (std::max)(max_count, count); + GAPI_DbgAssert(rowFunc); + + rowFunc(y_rows, uv_row, out_rows, buf_width); } +}; - return max_count; -} +GAPI_FLUID_KERNEL(FI420toRGB, I420toRGB, false) { + static const int Window = 1; + static const int LPI = 2; + static const auto Kind = cv::GFluidKernel::Kind::YUV420toRGB; -// taken from: ie_preprocess_data.cpp -static void computeResizeAreaTab(int src_go, int dst_go, int ssize, int dsize, float scale, - uint16_t* si, uint16_t* alpha, int max_count) { - static const float threshold = 1e-3f; - int k = 0; + static void run(const cv::gapi::fluid::View & in_y, + const cv::gapi::fluid::View & in_u, + const cv::gapi::fluid::View & in_v, + cv::gapi::fluid::Buffer & out) { + GAPI_DbgAssert(is_cv_type_in_list(out.meta().depth)); - for (int col = dst_go; col < dst_go + dsize; col++) { - int count = 0; + const uchar* u_row = in_u.InLineB(0); + const uchar* v_row = in_v.InLineB(0); + const uchar* y_rows[2] = { in_y.InLineB(0), in_y.InLineB(1) }; + uchar* out_rows[2] = { out.OutLineB(0), out.OutLineB(1) }; - float fsx1 = col * scale; - float fsx2 = fsx1 + scale; - float cellWidth = (std::min)(scale, ssize - fsx1); + int buf_width = out.length(); + GAPI_DbgAssert(in_u.length() == in_v.length()); - int sx1 = static_cast(ceil(fsx1)); - int sx2 = static_cast(floor(fsx2)); + const auto rowFunc = type_dispatch(out.meta().depth, cv_type_id{}, + typed_i420_to_rgb_row{}, + nullptr); - sx2 = (std::min)(sx2, ssize - 1); - sx1 = (std::min)(sx1, sx2); + GAPI_DbgAssert(rowFunc); - si[col - dst_go] = (uint16_t)(sx1 - src_go); + rowFunc(y_rows, u_row, v_row, out_rows, buf_width); + } +}; - if (sx1 - fsx1 > threshold) { - si[col - dst_go] = (uint16_t)(sx1 - src_go - 1); - alpha[k++] = (uint16_t)((1 << 16) * ((sx1 - fsx1) / cellWidth)); - count++; +GAPI_FLUID_KERNEL(FSplit2, Split2, false) { + static const int LPI = 4; + static const int Window = 1; + static void run(const cv::gapi::fluid::View & in, + cv::gapi::fluid::Buffer & out1, + cv::gapi::fluid::Buffer & out2) { + GAPI_DbgAssert(2 == in.meta().chan); + GAPI_DbgAssert(1 == out1.meta().chan); + GAPI_DbgAssert(1 == out2.meta().chan); + GAPI_DbgAssert(in.meta().depth == out1.meta().depth); + GAPI_DbgAssert(in.meta().depth == out2.meta().depth); + GAPI_DbgAssert(is_cv_type_in_list(in.meta().depth)); + + const auto rowFunc = type_dispatch(in.meta().depth, cv_type_id{}, + typed_split_row{}, nullptr); + for (int i = 0, lpi = out1.lpi(); i < lpi; i++) { + std::array outs = { out1.OutLineB(i), out2.OutLineB(i) }; + rowFunc(in.InLineB(i), outs, in.length()); } + } +}; - for (int sx = sx1; sx < sx2; sx++) { - alpha[k++] = (uint16_t)((1 << 16) * (1.0f / cellWidth)); - count++; +GAPI_FLUID_KERNEL(FSplit3, Split3, false) { + static const int LPI = 4; + static const int Window = 1; + static void run(const cv::gapi::fluid::View & in, + cv::gapi::fluid::Buffer & out1, + cv::gapi::fluid::Buffer & out2, + cv::gapi::fluid::Buffer & out3) { + GAPI_DbgAssert(3 == in.meta().chan); + GAPI_DbgAssert(1 == out1.meta().chan); + GAPI_DbgAssert(1 == out2.meta().chan); + GAPI_DbgAssert(1 == out3.meta().chan); + GAPI_DbgAssert(in.meta().depth == out1.meta().depth); + GAPI_DbgAssert(in.meta().depth == out2.meta().depth); + GAPI_DbgAssert(in.meta().depth == out3.meta().depth); + + GAPI_DbgAssert(is_cv_type_in_list(in.meta().depth)); + + const auto rowFunc = type_dispatch(in.meta().depth, cv_type_id{}, + typed_split_row{}, nullptr); + for (int i = 0, lpi = out1.lpi(); i < lpi; i++) { + std::array outs = { out1.OutLineB(i), out2.OutLineB(i), + out3.OutLineB(i) }; + rowFunc(in.InLineB(i), outs, in.length()); } + } +}; - if (fsx2 - sx2 > threshold) { - alpha[k++] = (uint16_t)((1 << 16) * ((std::min)((std::min)(fsx2 - sx2, 1.f), cellWidth) / cellWidth)); - count++; +GAPI_FLUID_KERNEL(FSplit4, Split4, false) { + static const int LPI = 4; + static const int Window = 1; + static void run(const cv::gapi::fluid::View & in, + cv::gapi::fluid::Buffer & out1, + cv::gapi::fluid::Buffer & out2, + cv::gapi::fluid::Buffer & out3, + cv::gapi::fluid::Buffer & out4) { + GAPI_DbgAssert(4 == in.meta().chan); + GAPI_DbgAssert(1 == out1.meta().chan); + GAPI_DbgAssert(1 == out2.meta().chan); + GAPI_DbgAssert(1 == out3.meta().chan); + GAPI_DbgAssert(1 == out4.meta().chan); + GAPI_DbgAssert(in.meta().depth == out1.meta().depth); + GAPI_DbgAssert(in.meta().depth == out2.meta().depth); + GAPI_DbgAssert(in.meta().depth == out3.meta().depth); + GAPI_DbgAssert(in.meta().depth == out4.meta().depth); + GAPI_DbgAssert(is_cv_type_in_list(in.meta().depth)); + + const auto rowFunc = type_dispatch(in.meta().depth, cv_type_id{}, + typed_split_row{}, nullptr); + for (int i = 0, lpi = out1.lpi(); i < lpi; i++) { + std::array outs = { out1.OutLineB(i), out2.OutLineB(i), + out3.OutLineB(i), out4.OutLineB(i) }; + rowFunc(in.InLineB(i), outs, in.length()); } + } +}; - if (count != max_count) { - alpha[k++] = 0; +GAPI_FLUID_KERNEL(FMerge2, Merge2, false) { + static const int LPI = 4; + static const int Window = 1; + static void run(const cv::gapi::fluid::View & a, + const cv::gapi::fluid::View & b, + cv::gapi::fluid::Buffer & out) { + GAPI_DbgAssert(is_cv_type_in_list(out.meta().depth)); + + const auto rowFunc = type_dispatch(out.meta().depth, cv_type_id{}, + typed_merge_row{}, nullptr); + for (int l = 0; l < out.lpi(); l++) { + rowFunc({ a.InLineB(l), b.InLineB(l) }, out.OutLineB(l), a.length()); + } + } +}; + +GAPI_FLUID_KERNEL(FMerge3, Merge3, false) { + static const int LPI = 4; + static const int Window = 1; + static void run(const cv::gapi::fluid::View & a, + const cv::gapi::fluid::View & b, + const cv::gapi::fluid::View & c, + cv::gapi::fluid::Buffer & out) { + GAPI_DbgAssert(is_cv_type_in_list(out.meta().depth)); + + const auto rowFunc = type_dispatch(out.meta().depth, cv_type_id{}, + typed_merge_row{}, nullptr); + for (int l = 0; l < out.lpi(); l++) { + rowFunc({ a.InLineB(l), b.InLineB(l), c.InLineB(l) }, out.OutLineB(l), a.length()); } } -} +}; -// teken from: ie_preprocess_data.cpp -static void generate_alpha_and_id_arrays(int x_max_count, int dcols, const uint16_t* xalpha, uint16_t* xsi, - uint16_t** alpha, uint16_t** sxid) { - if (x_max_count <= 4) { - for (int col = 0; col < dcols; col++) { - for (int x = 0; x < x_max_count; x++) { - alpha[x][col] = xalpha[col*x_max_count + x]; - } +GAPI_FLUID_KERNEL(FMerge4, Merge4, false) { + static const int LPI = 4; + static const int Window = 1; + static void run(const cv::gapi::fluid::View & a, + const cv::gapi::fluid::View & b, + const cv::gapi::fluid::View & c, + const cv::gapi::fluid::View & d, + cv::gapi::fluid::Buffer & out) { + GAPI_DbgAssert(is_cv_type_in_list(out.meta().depth)); + + const auto rowFunc = type_dispatch(out.meta().depth, cv_type_id{}, + typed_merge_row{}, nullptr); + for (int l = 0; l < out.lpi(); l++) { + rowFunc({ a.InLineB(l), b.InLineB(l), c.InLineB(l), d.InLineB(l) }, out.OutLineB(l), a.length()); } } - if (x_max_count <= 4) { - for (int col = 0; col <= dcols - 8; col += 8) { - for (int chunk_num_h = 0; chunk_num_h < x_max_count; chunk_num_h++) { - for (int i = 0; i < 128 / 16; i++) { - int id_diff = xsi[col + i] - xsi[col]; +}; - for (int chunk_num_v = 0; chunk_num_v < x_max_count; chunk_num_v++) { - uint16_t* sxidp = sxid[chunk_num_v] + col * x_max_count + chunk_num_h * 8; +template +static inline void callRowFunc(uint8_t* dst[], const uint8_t* src0[], + const uint8_t* src1[], const short alpha[], + const short clone[], const short mapsx[], + const short beta[], uint8_t tmp[], const Size& inSz, + const Size& outSz, const int lpi, const int length, const int depth) { + const auto rowFunc = type_dispatch(depth, cv_type_id{}, KT{}, nullptr); - int id0 = (id_diff + chunk_num_v) * 2 + 0; - int id1 = (id_diff + chunk_num_v) * 2 + 1; + GAPI_DbgAssert(rowFunc); - (reinterpret_cast(sxidp + i))[0] = static_cast(id0 >= (chunk_num_h * 16) && id0 < (chunk_num_h + 1) * 16 ? id0 : -1); - (reinterpret_cast(sxidp + i))[1] = static_cast(id1 >= (chunk_num_h * 16) && id1 < (chunk_num_h + 1) * 16 ? id1 : -1); - } - } - } - } - } + rowFunc(dst, src0, src1, alpha, clone, mapsx, beta, tmp, inSz, outSz, lpi, length); } -// taken from: ie_preprocess_data.cpp -// (and simplified for specifically downscale area 8u) -static size_t resize_get_buffer_size(const Size& inSz, const Size& outSz) { - int dst_full_width = outSz.width; - int dst_full_height = outSz.height; - int src_full_width = inSz.width; - int src_full_height = inSz.height; +template +static inline void callRowFunc(float* dst[], const float* src0[], const float* src1[], + const float alpha[], const float clone[], const int mapsx[], + const float beta[], float tmp[], const Size& inSz, + const Size& outSz, const int lpi, const int length, const int depth) { + const auto rowFunc = type_dispatch(depth, cv_type_id{}, KT{}, nullptr); - auto resize_area_u8_downscale_sse_buffer_size = [&]() { - const int dwidth = outSz.width; - const int dheight = outSz.height; - const int swidth = inSz.width; + GAPI_DbgAssert(rowFunc); - const int dst_go_x = 0; - const int dst_go_y = 0; + rowFunc(dst, src0, src1, alpha, mapsx, beta, inSz, outSz, lpi, length); +} - int x_max_count = getResizeAreaTabSize(dst_go_x, src_full_width, dwidth, static_cast(src_full_width) / dst_full_width) + 1; - int y_max_count = getResizeAreaTabSize(dst_go_y, src_full_height, dheight, static_cast(src_full_height) / dst_full_height) + 1; +template +static inline void calcRowLinear(const cv::gapi::fluid::View& in, + cv::gapi::fluid::Buffer& out, + cv::gapi::fluid::Buffer& scratch) { + GAPI_DbgAssert(is_cv_type_in_list(out.meta().depth)); - size_t si_buf_size = sizeof(uint16_t) * dwidth + sizeof(uint16_t) * dheight; - size_t alpha_buf_size = - sizeof(uint16_t) * (dwidth * x_max_count + 8 * 16) + sizeof(uint16_t) * dheight * y_max_count; - size_t vert_sum_buf_size = sizeof(uint16_t) * (swidth * 2); - size_t alpha_array_buf_size = sizeof(uint16_t) * 4 * dwidth; - size_t sxid_array_buf_size = sizeof(uint16_t) * 4 * 4 * dwidth; + auto inSz = in.meta().size; + auto outSz = out.meta().size; - size_t buffer_size = si_buf_size + - alpha_buf_size + - vert_sum_buf_size + - alpha_array_buf_size + - sxid_array_buf_size; + auto inY = in.y(); + int length = out.length(); + int outY = out.y(); + int lpi = out.lpi(); + GAPI_DbgAssert(outY + lpi <= outSz.height); - return buffer_size; - }; + GAPI_DbgAssert(lpi <= 4); - return resize_area_u8_downscale_sse_buffer_size(); -} + linearScratchDesc scr(inSz.width, inSz.height, outSz.width, + outSz.height, scratch.OutLineB()); -// buffer-fulfill is taken from: ie_preprocess_data_sse42.cpp -static void initScratchArea_CVKL_U8(const cv::GMatDesc & in, - const Size & outSz, - cv::gapi::fluid::Buffer & scratch) { - const Size& inSz = in.size; + const auto* alpha = scr.alpha; + const auto* clone = scr.clone; + const auto* mapsx = scr.mapsx; + const auto* beta0 = scr.beta; + const auto* mapsy = scr.mapsy; + auto* tmp = scr.tmp; - // estimate buffer size - size_t scratch_bytes = resize_get_buffer_size(inSz, outSz); + const auto* beta = beta0 + outY; + const T* src0[4]; + const T* src1[4]; + T* dst[4]; - // allocate buffer + for (int l = 0; l < lpi; l++) { + auto index0 = mapsy[outY + l] - inY; + auto index1 = mapsy[outSz.height + outY + l] - inY; + src0[l] = in.InLine(index0); + src1[l] = in.InLine(index1); + dst[l] = out.OutLine(l); + } - Size scratch_size{static_cast(scratch_bytes), 1}; + callRowFunc(dst, src0, src1, alpha, clone, mapsx, beta, tmp, inSz, outSz, + lpi, length, out.meta().depth); +} - cv::GMatDesc desc; - desc.chan = 1; - desc.depth = CV_8UC1; - desc.size = scratch_size; +GAPI_FLUID_KERNEL(FScalePlane8u, ScalePlane8u, true) { + static const int Window = 1; + static const int LPI = 4; + static const auto Kind = cv::GFluidKernel::Kind::Resize; - cv::gapi::fluid::Buffer buffer(desc); - scratch = std::move(buffer); + static void initScratch(const cv::GMatDesc & in, + Size outSz, int /*interp*/, + cv::gapi::fluid::Buffer & scratch) { + initScratchLinear(in, outSz, scratch, LPI); + } - // fulfil buffer - { - // this code is taken from: ie_preprocess_data_sse42.cpp - // (and simplified for 1-channel cv::Mat instead of blob) + static void resetScratch(cv::gapi::fluid::Buffer& /*scratch*/) { + } - auto dwidth = outSz.width; - auto dheight = outSz.height; - auto swidth = inSz.width; - auto sheight = inSz.height; + static void run(const cv::gapi::fluid::View & in, Size /*sz*/, int /*interp*/, + cv::gapi::fluid::Buffer & out, cv::gapi::fluid::Buffer & scratch) { + calcRowLinear, + resizeLinearU8C1_suptypes>(in, out, scratch); + } +}; - const int src_go_x = 0; - const int src_go_y = 0; - const int dst_go_x = 0; - const int dst_go_y = 0; +GAPI_FLUID_KERNEL(FScalePlane32f, ScalePlane32f, true) { + static const int Window = 1; + static const int LPI = 4; + static const auto Kind = cv::GFluidKernel::Kind::Resize; - auto src_full_width = swidth; - auto src_full_height = sheight; - auto dst_full_width = dwidth; - auto dst_full_height = dheight; + static void initScratch(const cv::GMatDesc & in, + Size outSz, int /*interp*/, + cv::gapi::fluid::Buffer & scratch) { + GAPI_DbgAssert(in.depth == CV_32F && in.chan == 1); - float scale_x = static_cast(src_full_width) / dst_full_width; - float scale_y = static_cast(src_full_height) / dst_full_height; + initScratchLinear(in, outSz, scratch, 0); + } - int x_max_count = getResizeAreaTabSize(dst_go_x, src_full_width, dwidth, scale_x); - int y_max_count = getResizeAreaTabSize(dst_go_y, src_full_height, dheight, scale_y); + static void resetScratch(cv::gapi::fluid::Buffer& /*scratch*/) { + } - auto* maxdif = scratch.OutLine(); - auto* xsi = reinterpret_cast(maxdif + 2); - auto* ysi = xsi + dwidth; - auto* xalpha = ysi + dheight; - auto* yalpha = xalpha + dwidth*x_max_count + 8*16; - // auto* vert_sum = yalpha + dheight*y_max_count; + static void run(const cv::gapi::fluid::View & in, Size /*sz*/, int /*interp*/, + cv::gapi::fluid::Buffer & out, cv::gapi::fluid::Buffer & scratch) { + calcRowLinear, + resizeLinearF32C1_suptypes>(in, out, scratch); + } +}; - maxdif[0] = x_max_count; - maxdif[1] = y_max_count; +GAPI_FLUID_KERNEL(FUpscalePlaneArea8u, UpscalePlaneArea8u, true) { + static const int Window = 1; + static const int LPI = 4; + static const auto Kind = cv::GFluidKernel::Kind::Resize; - computeResizeAreaTab(src_go_x, dst_go_x, src_full_width, dwidth, scale_x, xsi, xalpha, x_max_count); - computeResizeAreaTab(src_go_y, dst_go_y, src_full_height, dheight, scale_y, ysi, yalpha, y_max_count); + static void initScratch(const cv::GMatDesc & in, + Size outSz, int /*interp*/, + cv::gapi::fluid::Buffer & scratch) { + initScratchLinear(in, outSz, scratch, LPI); + } - int vest_sum_size = 2*swidth; - uint16_t* vert_sum = yalpha + dheight*y_max_count; - uint16_t* alpha0 = vert_sum + vest_sum_size; - uint16_t* alpha1 = alpha0 + dwidth; - uint16_t* alpha2 = alpha1 + dwidth; - uint16_t* alpha3 = alpha2 + dwidth; - uint16_t* sxid0 = alpha3 + dwidth; - uint16_t* sxid1 = sxid0 + 4*dwidth; - uint16_t* sxid2 = sxid1 + 4*dwidth; - uint16_t* sxid3 = sxid2 + 4*dwidth; + static void resetScratch(cv::gapi::fluid::Buffer& /*scratch*/) { + } - uint16_t* alpha[] = {alpha0, alpha1, alpha2, alpha3}; - uint16_t* sxid[] = {sxid0, sxid1, sxid2, sxid3}; - generate_alpha_and_id_arrays(x_max_count, dwidth, xalpha, xsi, alpha, sxid); + static void run(const cv::gapi::fluid::View & in, Size /*sz*/, int /*interp*/, + cv::gapi::fluid::Buffer & out, cv::gapi::fluid::Buffer & scratch) { + calcRowLinear, + resizeLinearU8C1_suptypes>(in, out, scratch); } -} +}; -static void calcAreaRow_CVKL_U8(const cv::gapi::fluid::View & in, - cv::gapi::fluid::Buffer & out, - cv::gapi::fluid::Buffer & scratch) { - Size inSz = in.meta().size; - Size outSz = out.meta().size; +GAPI_FLUID_KERNEL(FUpscalePlaneArea32f, UpscalePlaneArea32f, true) { + static const int Window = 1; + static const int LPI = 4; + static const auto Kind = cv::GFluidKernel::Kind::Resize; - // this method is valid only for down-scale - GAPI_DbgAssert(inSz.width >= outSz.width); - GAPI_DbgAssert(inSz.height >= outSz.height); + static void initScratch(const cv::GMatDesc & in, + Size outSz, int /*interp*/, + cv::gapi::fluid::Buffer & scratch) { + initScratchLinear(in, outSz, scratch, 0); + } - int dwidth = outSz.width; - int dheight = outSz.height; + static void resetScratch(cv::gapi::fluid::Buffer& /*scratch*/) { + } + + static void run(const cv::gapi::fluid::View & in, Size /*sz*/, int /*interp*/, + cv::gapi::fluid::Buffer & out, cv::gapi::fluid::Buffer & scratch) { + calcRowLinear, + resizeLinearF32C1_suptypes>(in, out, scratch); + } +}; + +template +static inline void calcRowLinearC(const cv::gapi::fluid::View& in, + std::array, chs>& out, + cv::gapi::fluid::Buffer& scratch) { + GAPI_DbgAssert(is_cv_type_in_list(in.meta().depth)); - auto* maxdif = scratch.OutLine(); - int x_max_count = maxdif[0]; - int y_max_count = maxdif[1]; + auto inSz = in.meta().size; + auto outSz = out[0].get().meta().size; - auto* xsi = reinterpret_cast(maxdif + 2); - auto* ysi = xsi + dwidth; - auto* xalpha = ysi + dheight; - auto* yalpha = xalpha + dwidth*x_max_count + 8*16; - auto* vert_sum = yalpha + dheight*y_max_count; + auto inY = in.y(); + auto outY = out[0].get().y(); + auto lpi = out[0].get().lpi(); - int iny = in.y(); - int y = out.y(); + GAPI_DbgAssert(outY + lpi <= outSz.height); + GAPI_DbgAssert(lpi <= 4); - int lpi = out.lpi(); - GAPI_DbgAssert(y + lpi <= outSz.height); + linearScratchDesc scr(inSz.width, inSz.height, outSz.width, outSz.height, scratch.OutLineB()); - for (int l = 0; l < lpi; l++) { - int yin0 = ysi[y + l]; - int yin1 = yin0 + y_max_count; + const auto *alpha = scr.alpha; + const auto *clone = scr.clone; + const auto *mapsx = scr.mapsx; + const auto *beta0 = scr.beta; + const auto *mapsy = scr.mapsy; + auto *tmp = scr.tmp; - GAPI_Assert(yin1 - yin0 <= 32); - const uint8_t *src[32] = {}; + const auto *beta = beta0 + outY; + const T *src0[4]; + const T *src1[4]; + std::array, chs> dst; - for (int yin = yin0; yin < yin1 && yin < inSz.height; yin++) { - if (yalpha[(y+l)*y_max_count + yin - yin0] == 0) { - src[yin - yin0] = in.InLine(yin - iny - 1); - } else { - src[yin - yin0] = in.InLine(yin - iny); - } + for (int l = 0; l < lpi; l++) { + auto index0 = mapsy[outY + l] - inY; + auto index1 = mapsy[outSz.height + outY + l] - inY; + src0[l] = in.InLine(index0); + src1[l] = in.InLine(index1); + for (int c=0; c < chs; c++) { + dst[c][l] = out[c].get().template OutLine(l); } + } + auto length = out[0].get().length(); - uint8_t *dst = out.OutLine(l); + const auto rowFunc = type_dispatch(in.meta().depth, + cv_type_id{}, + typed_resizeLinearU8C3C4{}, + nullptr); + GAPI_DbgAssert(rowFunc); - calcRowArea_CVKL_U8_SSE42(src, dst, inSz, outSz, y + l, xsi, ysi, - xalpha, yalpha, x_max_count, y_max_count, vert_sum); - } + rowFunc(dst, src0, src1, alpha, clone, mapsx, beta, tmp, inSz, outSz, lpi, length); } -#endif // CVKL -//---------------------------------------------------------------------- - -GAPI_FLUID_KERNEL(FScalePlane8u, ScalePlane8u, true) { +GAPI_FLUID_KERNEL(FScalePlanes, ScalePlanes, true) { static const int Window = 1; static const int LPI = 4; static const auto Kind = cv::GFluidKernel::Kind::Resize; - static void initScratch(const cv::GMatDesc& in, + static void initScratch(const cv::GMatDesc& in, int, Size, Size outSz, int /*interp*/, cv::gapi::fluid::Buffer &scratch) { - initScratchLinear(in, outSz, scratch, LPI); + initScratchLinear(in, outSz, scratch, LPI); } static void resetScratch(cv::gapi::fluid::Buffer& /*scratch*/) { } - static void run(const cv::gapi::fluid::View& in, Size /*sz*/, int /*interp*/, - cv::gapi::fluid::Buffer& out, cv::gapi::fluid::Buffer &scratch) { - calcRowLinear(in, out, scratch); + static void run(const cv::gapi::fluid::View& in, int, Size, Size/*sz*/, int /*interp*/, + cv::gapi::fluid::Buffer& out1, + cv::gapi::fluid::Buffer& out2, + cv::gapi::fluid::Buffer& out3, + cv::gapi::fluid::Buffer& scratch) { + constexpr int numChan = 3; + std::array, numChan> out = {out1, out2, out3}; + calcRowLinearC(in, out, scratch); } }; -GAPI_FLUID_KERNEL(FUpscalePlaneArea8u, UpscalePlaneArea8u, true) { +GAPI_FLUID_KERNEL(FScalePlanes4, ScalePlanes4, true) { static const int Window = 1; static const int LPI = 4; static const auto Kind = cv::GFluidKernel::Kind::Resize; - static void initScratch(const cv::GMatDesc& in, + static void initScratch(const cv::GMatDesc& in, int, Size, Size outSz, int /*interp*/, cv::gapi::fluid::Buffer &scratch) { - initScratchLinear(in, outSz, scratch, LPI); + initScratchLinear(in, outSz, scratch, LPI); } static void resetScratch(cv::gapi::fluid::Buffer& /*scratch*/) { } - static void run(const cv::gapi::fluid::View& in, Size /*sz*/, int /*interp*/, - cv::gapi::fluid::Buffer& out, cv::gapi::fluid::Buffer &scratch) { - calcRowLinear(in, out, scratch); + static void run(const cv::gapi::fluid::View& in, int, Size, Size/*sz*/, int /*interp*/, + cv::gapi::fluid::Buffer& out1, + cv::gapi::fluid::Buffer& out2, + cv::gapi::fluid::Buffer& out3, + cv::gapi::fluid::Buffer& out4, + cv::gapi::fluid::Buffer& scratch) { + constexpr int numChan = 4; + std::array, numChan> out = {out1, out2, out3, out4}; + calcRowLinearC(in, out, scratch); } }; -GAPI_FLUID_KERNEL(FUpscalePlaneArea32f, UpscalePlaneArea32f, true) { - static const int Window = 1; - static const int LPI = 4; - static const auto Kind = cv::GFluidKernel::Kind::Resize; +#if defined __GNUC__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif - static void initScratch(const cv::GMatDesc& in, - Size outSz, int /*interp*/, - cv::gapi::fluid::Buffer &scratch) { - initScratchLinear(in, outSz, scratch, 0); - } +template +static inline void calcAreaRow(const cv::gapi::fluid::View& in, cv::gapi::fluid::Buffer& out, + cv::gapi::fluid::Buffer& scratch) { + using Unit = typename Mapper::Unit; + using alpha_type = typename Mapper::alpha_type; + using index_type = typename Mapper::index_type; + using work_type = typename Mapper::work_type; - static void resetScratch(cv::gapi::fluid::Buffer& /*scratch*/) { - } + Size inSz = in.meta().size; + Size outSz = out.meta().size; - static void run(const cv::gapi::fluid::View& in, Size /*sz*/, int /*interp*/, - cv::gapi::fluid::Buffer& out, cv::gapi::fluid::Buffer &scratch) { - calcRowLinear(in, out, scratch); + // this method is valid only for down-scale + GAPI_DbgAssert(inSz.width >= outSz.width); + GAPI_DbgAssert(inSz.height >= outSz.height); + + Mapper ymapper(inSz.height, outSz.height); + + auto *xmaxdf = scratch.OutLine(); + auto maxdif = xmaxdf[0]; + + auto *xindex = reinterpret_cast(xmaxdf + 1); + auto *xalpha = reinterpret_cast(xindex + outSz.width); + auto *vbuf_c = reinterpret_cast(xalpha + outSz.width * maxdif); + + auto *vbuf = const_cast(vbuf_c); + + int iny = in.y(); + int y = out.y(); + + int lpi = out.lpi(); + GAPI_DbgAssert(y + lpi <= outSz.height); + + const auto rowFunc = type_dispatch(in.meta().depth, + cv_type_id{}, + typed_resizeArea{}, + nullptr); + GAPI_DbgAssert(rowFunc); + constexpr int max_num = 32; + for (int l = 0; l < lpi; l++) { + Unit ymap = ymapper.map(y + l); + + GAPI_Assert(ymap.index1 - ymap.index0 <= max_num); + GAPI_Assert(ymap.index1 - ymap.index0 > 0); + const T *src[max_num] = {}; + + for (int yin = ymap.index0; yin < ymap.index1; yin++) { + src[yin - ymap.index0] = in.InLine(yin - iny); + } + + auto dst = out.OutLine(l); + + rowFunc(dst, src, inSz, outSz, ymapper.alpha, ymap, xmaxdf[0], xindex, xalpha, vbuf); } -}; -//---------------------------------------------------------------------- +} + +#if defined __GNUC__ +# pragma GCC diagnostic pop +#endif GAPI_FLUID_KERNEL(FScalePlaneArea32f, ScalePlaneArea32f, true) { static const int Window = 1; @@ -2027,7 +1799,7 @@ GAPI_FLUID_KERNEL(FScalePlaneArea32f, ScalePlaneArea32f, true) { static void initScratch(const cv::GMatDesc& in, Size outSz, int /*interp*/, - cv::gapi::fluid::Buffer &scratch) { + cv::gapi::fluid::Buffer& scratch) { initScratchArea(in, outSz, scratch); } @@ -2035,7 +1807,7 @@ GAPI_FLUID_KERNEL(FScalePlaneArea32f, ScalePlaneArea32f, true) { } static void run(const cv::gapi::fluid::View& in, Size /*sz*/, int /*interp*/, - cv::gapi::fluid::Buffer& out, cv::gapi::fluid::Buffer &scratch) { + cv::gapi::fluid::Buffer& out, cv::gapi::fluid::Buffer& scratch) { calcAreaRow(in, out, scratch); } }; @@ -2047,9 +1819,8 @@ GAPI_FLUID_KERNEL(FScalePlaneArea8u, ScalePlaneArea8u, true) { static void initScratch(const cv::GMatDesc& in, Size outSz, int /*interp*/, - cv::gapi::fluid::Buffer &scratch) { - #if USE_CVKL - #ifdef HAVE_SSE + cv::gapi::fluid::Buffer& scratch) { +#if USE_CVKL if (with_cpu_x86_sse42()) { const Size& inSz = in.size; if (inSz.width > outSz.width && inSz.height > outSz.height) { @@ -2058,8 +1829,7 @@ GAPI_FLUID_KERNEL(FScalePlaneArea8u, ScalePlaneArea8u, true) { return; } } - #endif // HAVE_SSE - #endif +#endif initScratchArea(in, outSz, scratch); } @@ -2068,11 +1838,10 @@ GAPI_FLUID_KERNEL(FScalePlaneArea8u, ScalePlaneArea8u, true) { } static void run(const cv::gapi::fluid::View& in, Size /*sz*/, int /*interp*/, - cv::gapi::fluid::Buffer& out, cv::gapi::fluid::Buffer &scratch) { - #if USE_CVKL - #ifdef HAVE_SSE + cv::gapi::fluid::Buffer& out, cv::gapi::fluid::Buffer& scratch) { +#if USE_CVKL if (with_cpu_x86_sse42()) { - auto inSz = in.meta().size; + auto inSz = in.meta().size; auto outSz = out.meta().size; if (inSz.width > outSz.width && inSz.height > outSz.height) { // CVKL's code supports only downscale @@ -2080,19 +1849,116 @@ GAPI_FLUID_KERNEL(FScalePlaneArea8u, ScalePlaneArea8u, true) { return; } } - #endif // HAVE_SSE - #endif +#endif calcAreaRow(in, out, scratch); } }; +}; + +namespace { +struct CC_and_MergeISA { + cv::gapi::GKernelPackage& pckg; + + CC_and_MergeISA(cv::gapi::GKernelPackage& _pckg) : pckg(_pckg) {} + + template + inline bool operator()(type_to_type) { + pckg.include::FI420toRGB>(); + pckg.include::FNV12toRGB>(); + pckg.include::FChanToPlane>(); + pckg.include::FMerge2>(); + pckg.include::FMerge3>(); + pckg.include::FMerge4>(); + //at the moment type_dispatch requires something to be returned by the lambda + return true; + } +}; + +struct Split_ResizeISA { + cv::gapi::GKernelPackage& pckg; + + Split_ResizeISA(cv::gapi::GKernelPackage& _pckg) : pckg(_pckg) {} + + template + inline bool operator()(type_to_type) { + pckg.include::FSplit2>(); + pckg.include::FSplit3>(); + pckg.include::FSplit4>(); + pckg.include::FScalePlane8u>(); + pckg.include::FScalePlane32f>(); + pckg.include::FScalePlanes>(); + pckg.include::FScalePlanes4>(); + pckg.include::FScalePlaneArea8u>(); + pckg.include::FScalePlaneArea32f>(); + pckg.include::FUpscalePlaneArea8u>(); + pckg.include::FUpscalePlaneArea32f>(); + //at the moment type_dispatch requires something to be returned by the lambda + return true; + } +}; +} //namespace + +inline cv::gapi::GKernelPackage FKernelsChooseISA() { + // At the moment AVX512 implementation of wide universal intrinsics is slower than AVX2. + // So, disable it for now. + using isas = remove_t; + + cv::gapi::GKernelPackage pckg1, pckg2; + CC_and_MergeISA ccISA{ pckg1 }; + Split_ResizeISA sISA{ pckg2 }; + + type_dispatch(is_isa_present{}, ccISA, false); + type_dispatch(is_isa_present{}, sISA, false); + + return combine(pckg1, pckg2); +} + +//---------------------------------------------------------------------- + +GAPI_COMPOUND_KERNEL(FScalePlane, ScalePlane) { + static cv::GMat expand(cv::GMat in, int type, const Size& szIn, const Size& szOut, int interp) { + GAPI_DbgAssert(CV_8UC1 == type || CV_32FC1 == type); + GAPI_DbgAssert(cv::INTER_AREA == interp || cv::INTER_LINEAR == interp); + + if (cv::INTER_AREA == interp) { + bool upscale = szIn.width < szOut.width || szIn.height < szOut.height; + if (CV_8UC1 == type) { + if (upscale) + return UpscalePlaneArea8u::on(in, szOut, interp); + else + return ScalePlaneArea8u::on(in, szOut, interp); + } + if (CV_32FC1 == type) { + if (upscale) + return UpscalePlaneArea32f::on(in, szOut, interp); + else + return ScalePlaneArea32f::on(in, szOut, interp); + } + } + + if (cv::INTER_LINEAR == interp) { + if (CV_8UC1 == type) { + return ScalePlane8u::on(in, szOut, interp); + } + if (CV_32FC1 == type) { + return ScalePlane32f::on(in, szOut, interp); + } + } + + GAPI_Assert(!"unsupported parameters"); + return {}; + } +}; + +//------------------------------------------------------------------------------ namespace { template void convert_precision(const uint8_t* src, uint8_t* dst, const int width) { const auto *in = reinterpret_cast(src); - auto *out = reinterpret_cast(dst); + auto *out = reinterpret_cast(dst); for (int i = 0; i < width; i++) { out[i] = saturate_cast(in[i]); @@ -2203,10 +2069,6 @@ cv::gapi::GKernelPackage preprocKernels() { FKernelsChooseISA(), cv::gapi::kernels < FScalePlane - , FUpscalePlaneArea8u - , FUpscalePlaneArea32f - , FScalePlaneArea8u - , FScalePlaneArea32f , FConvertDepth , FSubC , FDivC diff --git a/inference-engine/src/preprocessing/ie_preprocess_gapi_kernels_simd_impl.hpp b/inference-engine/src/preprocessing/ie_preprocess_gapi_kernels_simd_impl.hpp index 8ff918747f31f4..19b00e41f3103b 100644 --- a/inference-engine/src/preprocessing/ie_preprocess_gapi_kernels_simd_impl.hpp +++ b/inference-engine/src/preprocessing/ie_preprocess_gapi_kernels_simd_impl.hpp @@ -514,12 +514,11 @@ CV_ALWAYS_INLINE void downx(T dst[], int outWidth, int xmaxdf, const I xindex[], #undef HSUM } -template -CV_ALWAYS_INLINE void calcRowArea_impl(T dst[], const T *src[], const Size& inSz, - const Size& outSz, A yalpha, - const MapperUnit& ymap, int xmaxdf, - const I xindex[], const A xalpha[], - W vbuf[]) { +template +CV_ALWAYS_INLINE void calcRowAreaImpl(isa_tag_t, T dst[], const T *src[], + const Size& inSz, const Size& outSz, A yalpha, + const MapperUnit& ymap, int xmaxdf, + const I xindex[], const A xalpha[], W vbuf[]) { bool xRatioEq1 = inSz.width == outSz.width; bool yRatioEq1 = inSz.height == outSz.height; diff --git a/inference-engine/src/readers/ir_reader/ie_ir_parser.cpp b/inference-engine/src/readers/ir_reader/ie_ir_parser.cpp index 892c2e6bae4088..cc00ec77114e7c 100644 --- a/inference-engine/src/readers/ir_reader/ie_ir_parser.cpp +++ b/inference-engine/src/readers/ir_reader/ie_ir_parser.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -838,6 +839,7 @@ std::shared_ptr XmlDeserializer::createNode( } ngraphNode->set_arguments(inputs); XmlDeserializer visitor(node, weights, opsets, variables); + if (ngraphNode->visit_attributes(visitor)) { ngraphNode->constructor_validate_and_infer_types(); } @@ -900,6 +902,7 @@ V10Parser::V10Parser(const std::vector& exts) : _exts(exts) { opsets["opset5"] = ngraph::get_opset5(); opsets["opset6"] = ngraph::get_opset6(); opsets["opset7"] = ngraph::get_opset7(); + opsets["opset8"] = ngraph::get_opset8(); // Load custom opsets for (const auto& ext : exts) { diff --git a/inference-engine/src/readers/ir_reader_v7/CMakeLists.txt b/inference-engine/src/readers/ir_reader_v7/CMakeLists.txt index b79f630ed9d5a6..4ee39f31358348 100644 --- a/inference-engine/src/readers/ir_reader_v7/CMakeLists.txt +++ b/inference-engine/src/readers/ir_reader_v7/CMakeLists.txt @@ -16,7 +16,7 @@ source_group("src" FILES ${LIBRARY_SRC}) # Create module library -add_library(${TARGET_NAME} MODULE EXCLUDE_FROM_ALL ${LIBRARY_SRC}) +add_library(${TARGET_NAME} MODULE ${LIBRARY_SRC}) ie_faster_build(${TARGET_NAME} UNITY diff --git a/inference-engine/src/transformations/include/ngraph_ops/framework_node.hpp b/inference-engine/src/transformations/include/ngraph_ops/framework_node.hpp index c19a8500ecc754..8abda399c9c049 100644 --- a/inference-engine/src/transformations/include/ngraph_ops/framework_node.hpp +++ b/inference-engine/src/transformations/include/ngraph_ops/framework_node.hpp @@ -55,7 +55,7 @@ class TRANSFORMATIONS_API FrameworkNode : public Op { public: NGRAPH_RTTI_DECLARATION; - explicit FrameworkNode(const OutputVector& inputs); + explicit FrameworkNode(const OutputVector& inputs, size_t output_size = 1); void validate_and_infer_types() override; @@ -71,8 +71,11 @@ class TRANSFORMATIONS_API FrameworkNode : public Op { std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; + void cache_output_descriptor(); + private: std::vector> m_inputs_desc; + std::vector> m_output_desc; FrameworkNodeAttrs m_attrs; }; diff --git a/inference-engine/src/transformations/include/transformations/common_optimizations/eliminate_unsqueeze_gather.hpp b/inference-engine/src/transformations/include/transformations/common_optimizations/eliminate_unsqueeze_gather.hpp index 141ef7d774d9a9..012d78a477482d 100644 --- a/inference-engine/src/transformations/include/transformations/common_optimizations/eliminate_unsqueeze_gather.hpp +++ b/inference-engine/src/transformations/include/transformations/common_optimizations/eliminate_unsqueeze_gather.hpp @@ -14,6 +14,7 @@ namespace ngraph { namespace pass { class TRANSFORMATIONS_API EliminateUnsqueezeGather; +class TRANSFORMATIONS_API EliminateGatherUnsqueeze; } // namespace pass } // namespace ngraph @@ -29,3 +30,15 @@ class ngraph::pass::EliminateUnsqueezeGather : public ngraph::pass::MatcherPass NGRAPH_RTTI_DECLARATION; EliminateUnsqueezeGather(); }; + +/** + * @ingroup ie_transformation_common_api + * @brief Remove Gather -> Unsqueeze pair, if Gather takes a scalar and + * Unsqueeze makes it a 1D tensor + */ + +class ngraph::pass::EliminateGatherUnsqueeze : public ngraph::pass::MatcherPass { +public: + NGRAPH_RTTI_DECLARATION; + EliminateGatherUnsqueeze(); +}; diff --git a/inference-engine/src/transformations/include/transformations/common_optimizations/pad_fusion.hpp b/inference-engine/src/transformations/include/transformations/common_optimizations/pad_fusion.hpp index 7c11f1ee02a9a1..37c903de952e6a 100644 --- a/inference-engine/src/transformations/include/transformations/common_optimizations/pad_fusion.hpp +++ b/inference-engine/src/transformations/include/transformations/common_optimizations/pad_fusion.hpp @@ -12,6 +12,7 @@ namespace ngraph { namespace pass { class TRANSFORMATIONS_API PadFusion; +class TRANSFORMATIONS_API PadElimination; class TRANSFORMATIONS_API PadFusionAvgPool; class TRANSFORMATIONS_API PadFusionMaxPool; class TRANSFORMATIONS_API PadFusionConvolution; @@ -22,6 +23,16 @@ class TRANSFORMATIONS_API PadFusionGroupConvolutionBackpropData; } // namespace pass } // namespace ngraph +/** + * @ingroup ie_transformation_common_api + * @brief PadElimination eliminates pad that does nothing + */ +class ngraph::pass::PadElimination: public ngraph::pass::MatcherPass { +public: + NGRAPH_RTTI_DECLARATION; + PadElimination(); +}; + /** * @ingroup ie_transformation_common_api * @brief PadFusion transformation replaces following graph: @@ -113,5 +124,6 @@ class ngraph::pass::PadFusion: public ngraph::pass::GraphRewrite { add_matcher(); add_matcher(); add_matcher(); + add_matcher(); } }; diff --git a/inference-engine/src/transformations/include/transformations/common_optimizations/simplify_shape_of_sub_graph.hpp b/inference-engine/src/transformations/include/transformations/common_optimizations/simplify_shape_of_sub_graph.hpp new file mode 100644 index 00000000000000..85d8aa662da28f --- /dev/null +++ b/inference-engine/src/transformations/include/transformations/common_optimizations/simplify_shape_of_sub_graph.hpp @@ -0,0 +1,60 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +#include + +#include +#include +#include +#include + +namespace ngraph { +namespace pass { + +class TRANSFORMATIONS_API SimplifyShapeOfSubGraph; +class TRANSFORMATIONS_API SharedShapeOf; +class TRANSFORMATIONS_API GroupedGatherElimination; + +} // namespace pass +} // namespace ngraph + + +/** + * @ingroup ie_transformation_common_api + * @brief SharedShapeOf transformation replaces group of ShapeOf + * operations with the first ShapeOf in this group. All ShapeOfs in this group + * must be equal and consume the same output port. + */ +class ngraph::pass::SharedShapeOf: public ngraph::pass::FunctionPass { +public: + NGRAPH_RTTI_DECLARATION; + bool run_on_function(std::shared_ptr f) override; +}; + +/** + * @ingroup ie_transformation_common_api + * @brief GroupedGatherElimination transformation replaces group of Gather + * operations with the first Gather in this group and updated indices input + * in case all Gathers in the group are consumed by the same Concat in incremental order. + */ +class ngraph::pass::GroupedGatherElimination: public ngraph::pass::MatcherPass { +public: + NGRAPH_RTTI_DECLARATION; + GroupedGatherElimination(); +}; + +/** + * @ingroup ie_transformation_common_api + * @brief SimplifyShapeOfSubGraph transformation runs specific optimizations of shape sub-graphs + */ +class ngraph::pass::SimplifyShapeOfSubGraph: public ngraph::pass::FunctionPass { +public: + NGRAPH_RTTI_DECLARATION; + bool run_on_function(std::shared_ptr f) override; +}; diff --git a/inference-engine/src/transformations/include/transformations/op_conversions/convert_deformable_conv_v8_to_v1.hpp b/inference-engine/src/transformations/include/transformations/op_conversions/convert_deformable_conv_v8_to_v1.hpp new file mode 100644 index 00000000000000..f33f6b9a83ac8d --- /dev/null +++ b/inference-engine/src/transformations/include/transformations/op_conversions/convert_deformable_conv_v8_to_v1.hpp @@ -0,0 +1,27 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +#include + +namespace ngraph { +namespace pass { + +class TRANSFORMATIONS_API ConvertDeformableConv8To1; + +} // namespace pass +} // namespace ngraph + +/** + * @ingroup ie_transformation_common_api + * @brief ConvertDeformableConv8To1 converts v8::DeformableConvolution into v1::DeformableConvolution. + */ +class ngraph::pass::ConvertDeformableConv8To1 : public ngraph::pass::MatcherPass { +public: + NGRAPH_RTTI_DECLARATION; + ConvertDeformableConv8To1(); +}; diff --git a/inference-engine/src/transformations/src/ngraph_ops/framework_node.cpp b/inference-engine/src/transformations/src/ngraph_ops/framework_node.cpp index 567c54bf04dc31..94d0008c11064e 100644 --- a/inference-engine/src/transformations/src/ngraph_ops/framework_node.cpp +++ b/inference-engine/src/transformations/src/ngraph_ops/framework_node.cpp @@ -10,8 +10,9 @@ using namespace ngraph; NGRAPH_RTTI_DEFINITION(op::FrameworkNode, "FrameworkNode", 0); -op::FrameworkNode::FrameworkNode(const OutputVector& inputs) +op::FrameworkNode::FrameworkNode(const OutputVector& inputs, size_t output_size) : Op(inputs) { + set_output_size(output_size); constructor_validate_and_infer_types(); } @@ -25,31 +26,71 @@ shared_ptr op::FrameworkNode::clone_with_new_inputs(const OutputVector& ne return node; } +void op::FrameworkNode::cache_output_descriptor() { + for (size_t i = 0; i < get_output_size(); ++i) { + m_output_desc.emplace_back(get_output_partial_shape(i), get_output_element_type(i)); + } +} + void op::FrameworkNode::validate_and_infer_types() { INTERNAL_OP_SCOPE(FrameworkNode_validate_and_infer_types); // Save initial inputs descriptors bool initialize_input_desc = m_inputs_desc.empty(); + bool reset_output_shape_to_dynamic = false; + bool reset_output_shape_to_original = false; for (uint64_t i = 0; i < get_input_size(); i++) { // TODO: store constant values - const auto& new_input_desc = - std::make_tuple(get_input_partial_shape(i), get_input_element_type(i)); + const auto& input_pshape = get_input_partial_shape(i); + const auto& input_type = get_input_element_type(i); + const auto& rank = input_pshape.rank(); + + const auto & get_error_message = [&]() { + std::stringstream out; + out << "Input descriptor for " << get_friendly_name() + << " node has been changed:" << std::endl; + out << "Before: " << std::get<0>(m_inputs_desc[i]) << ", " + << std::get<1>(m_inputs_desc[i]) << std::endl; + out << "After: " << input_pshape << ", " + << input_type << std::endl; + out << "Please specify InferenceEngine Extensions to support this case."; + return out.str(); + }; if (initialize_input_desc) { - m_inputs_desc.push_back(new_input_desc); + m_inputs_desc.emplace_back(input_pshape, input_type); } else { - auto get_message = [&]() { - std::stringstream out; - out << "Input descriptor for " << get_friendly_name() - << " node has been changed:" << std::endl; - out << "Before: " << std::get<0>(m_inputs_desc[i]) << ", " - << std::get<1>(m_inputs_desc[i]) << std::endl; - out << "After: " << std::get<0>(new_input_desc) << ", " - << std::get<1>(new_input_desc) << std::endl; - out << "Please specify InferenceEngine Extensions to support this case."; - return out.str(); - }; - - NODE_VALIDATION_CHECK(this, m_inputs_desc[i] == new_input_desc, get_message()); + const auto& orig_input_pshape = std::get<0>(m_inputs_desc[i]); + if (orig_input_pshape == input_pshape) { + reset_output_shape_to_original = true; + } else if (input_pshape.rank().is_dynamic()) { + reset_output_shape_to_dynamic = true; + } else if (rank.is_static() && orig_input_pshape.rank().is_static() && + rank.get_length() == orig_input_pshape.rank().get_length()) { + for (int64_t dim = 0; dim < rank.get_length(); ++dim) { + NODE_VALIDATION_CHECK(this, input_pshape[dim].is_dynamic() || + (orig_input_pshape[dim].is_static() && + orig_input_pshape[dim].get_length() == input_pshape[dim].get_length()), + get_error_message()); + } + reset_output_shape_to_dynamic = true; + } else { + NODE_VALIDATION_CHECK(this, m_inputs_desc[i] == std::make_tuple(input_pshape, input_type), get_error_message()); + } + } + } + + if (reset_output_shape_to_dynamic) { + cache_output_descriptor(); + for (size_t i = 0; i < get_output_size(); ++i) { + if (get_output_partial_shape(i).rank().is_static()) { + set_output_type(i, get_output_element_type(i), PartialShape::dynamic()); + } + } + } + + if (reset_output_shape_to_original && !m_output_desc.empty()) { + for (size_t i = 0; i < get_output_size(); ++i) { + set_output_type(i, std::get<1>(m_output_desc[i]), std::get<0>(m_output_desc[i])); } } } diff --git a/inference-engine/src/transformations/src/transformations/common_optimizations/common_optimizations.cpp b/inference-engine/src/transformations/src/transformations/common_optimizations/common_optimizations.cpp index ffe80ec9639a80..415ecb11610901 100644 --- a/inference-engine/src/transformations/src/transformations/common_optimizations/common_optimizations.cpp +++ b/inference-engine/src/transformations/src/transformations/common_optimizations/common_optimizations.cpp @@ -72,10 +72,12 @@ #include "transformations/op_conversions/mvn6_decomposition.hpp" #include "transformations/op_conversions/simplify_ctc_greedy_decoder_seq_len.hpp" #include "transformations/op_conversions/gather_normalize_negative_indices.hpp" +#include "transformations/op_conversions/convert_deformable_conv_v8_to_v1.hpp" #include #include #include +#include NGRAPH_RTTI_DEFINITION(ngraph::pass::CommonOptimizations, "CommonOptimizations", 0); @@ -85,6 +87,7 @@ bool ngraph::pass::CommonOptimizations::run_on_function(std::shared_ptr(); + manager.register_pass(); manager.register_pass(); manager.register_pass(); // Resolves dynamism (replaces NonZero), CF needed @@ -178,6 +181,7 @@ bool ngraph::pass::CommonOptimizations::run_on_function(std::shared_ptr(); manager.register_pass(); manager.register_pass(); + manager.register_pass(); auto fq_fusions = manager.register_pass(); fq_fusions->add_matcher(); diff --git a/inference-engine/src/transformations/src/transformations/common_optimizations/eliminate_unsqueeze_gather.cpp b/inference-engine/src/transformations/src/transformations/common_optimizations/eliminate_unsqueeze_gather.cpp index fae3b71ac1eef4..ec3fafdea39774 100644 --- a/inference-engine/src/transformations/src/transformations/common_optimizations/eliminate_unsqueeze_gather.cpp +++ b/inference-engine/src/transformations/src/transformations/common_optimizations/eliminate_unsqueeze_gather.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "itt.hpp" NGRAPH_RTTI_DEFINITION(ngraph::pass::EliminateUnsqueezeGather, "EliminateUnsqueezeGather", 0); @@ -58,3 +59,36 @@ ngraph::pass::EliminateUnsqueezeGather::EliminateUnsqueezeGather() { auto m = std::make_shared(gather, "EliminateUnsqueezeGather"); register_matcher(m, callback); } + +NGRAPH_RTTI_DEFINITION(ngraph::pass::EliminateGatherUnsqueeze, "EliminateGatherUnsqueeze", 0); + +ngraph::pass::EliminateGatherUnsqueeze::EliminateGatherUnsqueeze() { + MATCHER_SCOPE(EliminateGatherUnsqueeze); + + const auto gather_indices_label = ngraph::pattern::wrap_type(pattern::rank_equals(0)); + const auto gather_axis_label = ngraph::pattern::wrap_type(); + const auto gather_label = ngraph::pattern::wrap_type( + {ngraph::pattern::any_input(), gather_indices_label, gather_axis_label}, pattern::rank_equals(0)); + + const auto unsqueeze_label = ngraph::pattern::wrap_type( + {gather_label, ngraph::pattern::any_input()}, pattern::rank_equals(1)); + + ngraph::matcher_pass_callback callback = [=](ngraph::pattern::Matcher& m) { + auto pattern_nodes = m.get_pattern_map(); + + auto& gather_indices = pattern_nodes.at(gather_indices_label); + auto& gather = pattern_nodes.at(gather_label); + auto& unsqueeze = pattern_nodes.at(unsqueeze_label); + + auto new_indices = ngraph::op::util::make_try_fold(gather_indices, opset6::Constant::create(element::i32, {1}, {1}), false); + auto new_gather = gather->clone_with_new_inputs({gather->input_value(0), new_indices, gather->input_value(2)}); + + new_gather->set_friendly_name(gather->get_friendly_name()); + ngraph::copy_runtime_info({unsqueeze, gather}, {new_gather, new_indices}); + ngraph::replace_node(unsqueeze, new_gather); + return true; + }; + + auto m = std::make_shared(unsqueeze_label, "EliminateGatherUnsqueeze"); + register_matcher(m, callback); +} diff --git a/inference-engine/src/transformations/src/transformations/common_optimizations/pad_fusion.cpp b/inference-engine/src/transformations/src/transformations/common_optimizations/pad_fusion.cpp index c8e53e74c1fdb8..b2655f8797cbdd 100644 --- a/inference-engine/src/transformations/src/transformations/common_optimizations/pad_fusion.cpp +++ b/inference-engine/src/transformations/src/transformations/common_optimizations/pad_fusion.cpp @@ -12,6 +12,7 @@ #include #include #include +#include using namespace ngraph; @@ -385,3 +386,34 @@ pass::PadFusionGroupConvolutionBackpropData::PadFusionGroupConvolutionBackpropDa auto m = std::make_shared(conv_pattern, matcher_name); this->register_matcher(m, callback); } + +NGRAPH_RTTI_DEFINITION(pass::PadElimination, "PadElimination", 0); + +pass::PadElimination::PadElimination() { + MATCHER_SCOPE(PadElimination); + auto pad_node_pattern = pattern::wrap_type(); + + matcher_pass_callback callback = [=](pattern::Matcher& m) { + auto pad = m.get_match_root(); + + auto pad_begin_const = ngraph::get_constant_from_source(pad->input_value(1)); + auto pad_end_const = ngraph::get_constant_from_source(pad->input_value(2)); + + if (!pad_begin_const || !pad_end_const) { + return false; + } + + const auto pad_begin_value = pad_begin_const->cast_vector(); + const auto pad_end_value = pad_end_const->cast_vector(); + + if (std::any_of(pad_begin_value.begin(), pad_begin_value.end(), [](int64_t value) { return value != 0; }) || + std::any_of(pad_end_value.begin(), pad_end_value.end(), [](int64_t value) { return value != 0; })) { + return false; + } + + return replace_output_update_name(pad->output(0), pad->input_value(0)); + }; + + auto m = std::make_shared(pad_node_pattern, matcher_name); + this->register_matcher(m, callback); +} \ No newline at end of file diff --git a/inference-engine/src/transformations/src/transformations/common_optimizations/simplify_shape_of_sub_graph.cpp b/inference-engine/src/transformations/src/transformations/common_optimizations/simplify_shape_of_sub_graph.cpp new file mode 100644 index 00000000000000..4aeae1d8f1444f --- /dev/null +++ b/inference-engine/src/transformations/src/transformations/common_optimizations/simplify_shape_of_sub_graph.cpp @@ -0,0 +1,101 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include + +#include "itt.hpp" +#include +#include +#include +#include +#include +#include +#include +#include + +NGRAPH_RTTI_DEFINITION(ngraph::pass::SharedShapeOf, "SharedShapeOf", 0); + +bool ngraph::pass::SharedShapeOf::run_on_function(std::shared_ptr f) { + RUN_ON_FUNCTION_SCOPE(SharedShapeOf); + bool graph_rewritten = false; + + std::map, std::vector>> source_to_shape_of; + for (const auto & node : f->get_ordered_ops()) { + // Recursively apply transformation for sub-graph based operations + if (auto sub_graph_node = std::dynamic_pointer_cast(node)) + if (auto sub_graph = sub_graph_node->get_function()) + graph_rewritten |= run_on_function(sub_graph); + + if (is_type(node) || is_type(node)) + source_to_shape_of[node->input_value(0)].push_back(node); + } + + for (const auto& pair : source_to_shape_of) { + if (pair.second.size() < 2) + continue; + const auto& root_ss = pair.second[0]; + for (const auto& child_ss : pair.second) + if (root_ss->get_instance_id() != child_ss->get_instance_id() && root_ss->get_output_element_type(0) == root_ss->get_output_element_type(0)) + graph_rewritten |= replace_output_update_name(child_ss->output(0), root_ss->output(0)); + } + return graph_rewritten; +} + +NGRAPH_RTTI_DEFINITION(ngraph::pass::GroupedGatherElimination, "GroupedGatherElimination", 0); + +ngraph::pass::GroupedGatherElimination::GroupedGatherElimination() { + MATCHER_SCOPE(GroupedGatherElimination); + auto concat_label = ngraph::pattern::wrap_type(pattern::rank_equals(1)); + + ngraph::matcher_pass_callback callback = [](pattern::Matcher& m) { + auto concat = m.get_match_root(); + OutputVector inputs = concat->input_values(); + NodeVector new_ops; + size_t i = 0, original_inputs_size = inputs.size(); + while (inputs.size() > i + 1) { + auto curr = inputs[i].get_node_shared_ptr(), next = inputs[i + 1].get_node_shared_ptr(); + if (curr->get_type_info() != next->get_type_info() || + (!is_type(curr) && !is_type(curr)) || + (curr->input_value(0) != next->input_value(0))) { + ++i; + continue; + } // curr and next are the same type of gather which takes data from the same source + auto joint_indices = ngraph::op::util::make_try_fold(OutputVector{curr->input_value(1), next->input_value(1)}, 0); + auto new_gather = curr->clone_with_new_inputs( + {curr->input_value(0), joint_indices, ngraph::opset1::Constant::create(element::i64, {}, {0})}); + new_ops.push_back(joint_indices); + new_ops.push_back(new_gather); + inputs.erase(inputs.begin() + i); + inputs[i] = new_gather->output(0); + } + if (original_inputs_size > inputs.size()) { + auto new_concat = std::make_shared(inputs, 0); + new_ops.push_back(new_concat); + new_concat->set_friendly_name(concat->get_friendly_name()); + ngraph::copy_runtime_info(concat, new_ops); + ngraph::replace_node(concat, new_concat); + return true; + } + return false; + }; + + auto m = std::make_shared(concat_label, matcher_name); + this->register_matcher(m, callback); +} + + +NGRAPH_RTTI_DEFINITION(ngraph::pass::SimplifyShapeOfSubGraph, "SimplifyShapeOfSubGraph", 0); + +bool ngraph::pass::SimplifyShapeOfSubGraph::run_on_function(std::shared_ptr f) { + RUN_ON_FUNCTION_SCOPE(GroupedGatherElimination); + ngraph::pass::Manager manager; + manager.set_per_pass_validation(false); + manager.register_pass(); + manager.register_pass(); + manager.register_pass(); + manager.register_pass(); + manager.run_passes(f); + return false; +} diff --git a/inference-engine/src/transformations/src/transformations/common_optimizations/softplus_fusion.cpp b/inference-engine/src/transformations/src/transformations/common_optimizations/softplus_fusion.cpp index 0c768800eea4d1..c9a19623352e4c 100644 --- a/inference-engine/src/transformations/src/transformations/common_optimizations/softplus_fusion.cpp +++ b/inference-engine/src/transformations/src/transformations/common_optimizations/softplus_fusion.cpp @@ -19,26 +19,20 @@ ngraph::pass::SoftPlusFusion::SoftPlusFusion() { // fuses ln(exp(x) + 1.0) operations into SoftPlus(x) auto input = ngraph::pattern::any_input(); auto exp = std::make_shared(input); - auto add_constant = ngraph::pattern::wrap_type(); + auto add_constant = ngraph::pattern::wrap_type( + pattern::type_matches_any({element::f32, element::f16})); auto add = std::make_shared(exp, add_constant); auto log = std::make_shared(add); ngraph::matcher_pass_callback callback = [=](ngraph::pattern::Matcher &m) { - auto &pattern_to_output = m.get_pattern_value_map(); + const auto &pattern_to_output = m.get_pattern_value_map(); auto exp_input = pattern_to_output.at(input); auto constant = std::dynamic_pointer_cast(pattern_to_output.at(add_constant).get_node_shared_ptr()); + if (!constant) return false; - if (constant == nullptr) { - return false; - } - - if (constant->get_element_type() == ngraph::element::f32 || constant->get_element_type() == ngraph::element::f16) { - auto data = constant->cast_vector(); - if (data.size() != 1 || data[0] != 1.0) { - return false; - } - } else { + auto data = constant->cast_vector(); + if (data.size() != 1 || data[0] != 1.0) { return false; } diff --git a/inference-engine/src/transformations/src/transformations/op_conversions/convert_deformable_conv_v8_to_v1.cpp b/inference-engine/src/transformations/src/transformations/op_conversions/convert_deformable_conv_v8_to_v1.cpp new file mode 100644 index 00000000000000..a5d2f8e123adc0 --- /dev/null +++ b/inference-engine/src/transformations/src/transformations/op_conversions/convert_deformable_conv_v8_to_v1.cpp @@ -0,0 +1,52 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "transformations/op_conversions/convert_deformable_conv_v8_to_v1.hpp" +#include +#include +#include +#include + +#include "itt.hpp" + +NGRAPH_RTTI_DEFINITION(ngraph::pass::ConvertDeformableConv8To1, "ConvertDeformableConv8To1", 0); + +ngraph::pass::ConvertDeformableConv8To1::ConvertDeformableConv8To1() { + MATCHER_SCOPE(ConvertDeformableConv8To1); + + auto deformable_conv_v8 = pattern::wrap_type(); + + ngraph::matcher_pass_callback callback = [=](pattern::Matcher& m) { + auto deformable_conv_v8_node = std::dynamic_pointer_cast(m.get_match_root()); + if (!deformable_conv_v8_node) + return false; + + if (deformable_conv_v8_node->get_input_size() != 3 + || deformable_conv_v8_node->get_bilinear_interpolation_pad()) + return false; + + auto arg = deformable_conv_v8_node->input_value(0); + auto offsets = deformable_conv_v8_node->input_value(1); + auto filters = deformable_conv_v8_node->input_value(2); + + auto deformable_conv_v1 = + std::make_shared(arg, + offsets, + filters, + deformable_conv_v8_node->get_strides(), + deformable_conv_v8_node->get_pads_begin(), + deformable_conv_v8_node->get_pads_end(), + deformable_conv_v8_node->get_dilations(), + deformable_conv_v8_node->get_auto_pad(), + deformable_conv_v8_node->get_group(), + deformable_conv_v8_node->get_deformable_group()); + deformable_conv_v1->set_friendly_name(deformable_conv_v8_node->get_friendly_name()); + ngraph::copy_runtime_info(deformable_conv_v8_node, deformable_conv_v1); + ngraph::replace_node(deformable_conv_v8_node, deformable_conv_v1); + return true; + }; + + auto m = std::make_shared(deformable_conv_v8, matcher_name); + register_matcher(m, callback); +} diff --git a/inference-engine/src/transformations/src/transformations/op_conversions/convert_topk3.cpp b/inference-engine/src/transformations/src/transformations/op_conversions/convert_topk3.cpp index 97d9031bd99f67..45eba021464ab7 100644 --- a/inference-engine/src/transformations/src/transformations/op_conversions/convert_topk3.cpp +++ b/inference-engine/src/transformations/src/transformations/op_conversions/convert_topk3.cpp @@ -40,6 +40,7 @@ ngraph::pass::ConvertTopK3::ConvertTopK3() { last1 = new_topk->output(1); new_topk->set_friendly_name(topk->get_friendly_name()); } else if (topk->get_output_target_inputs(0).size() == 0) { + last0 = topk->output(0); last1 = std::make_shared(new_topk->output(1), topk->get_index_element_type()); new_ops.push_back(last1.get_node_shared_ptr()); diff --git a/inference-engine/src/transformations/src/transformations/serialize.cpp b/inference-engine/src/transformations/src/transformations/serialize.cpp index 73b72313e5f48a..93f9c24e4b81bb 100644 --- a/inference-engine/src/transformations/src/transformations/serialize.cpp +++ b/inference-engine/src/transformations/src/transformations/serialize.cpp @@ -465,10 +465,10 @@ const std::vector create_edge_mapping( std::string get_opset_name( const ngraph::Node* n, const std::map& custom_opsets) { - auto opsets = std::array, 7>{ + auto opsets = std::array, 8>{ ngraph::get_opset1(), ngraph::get_opset2(), ngraph::get_opset3(), ngraph::get_opset4(), ngraph::get_opset5(), ngraph::get_opset6(), - ngraph::get_opset7()}; + ngraph::get_opset7(), ngraph::get_opset8()}; auto special_opset = get_special_opset_for_op(n->get_type_info()); if (!special_opset.empty()) { @@ -495,6 +495,7 @@ std::string get_opset_name( std::string get_precision_name(const ngraph::element::Type & elem_type) { switch (elem_type) { case ::ngraph::element::Type_t::undefined: + case ::ngraph::element::Type_t::dynamic: return "UNSPECIFIED"; case ::ngraph::element::Type_t::f16: return "FP16"; diff --git a/inference-engine/src/vpu/graph_transformer/src/frontend/ie_parsed_network.cpp b/inference-engine/src/vpu/graph_transformer/src/frontend/ie_parsed_network.cpp index 49ee5f1caaebbb..a8c0bc0a8f5987 100644 --- a/inference-engine/src/vpu/graph_transformer/src/frontend/ie_parsed_network.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/frontend/ie_parsed_network.cpp @@ -27,7 +27,6 @@ IeParsedNetwork parseNetwork(const ie::CNNNetwork& network) { out.networkOutputs = network.getOutputsInfo(); env.log->trace("Got %d inputs and %d outputs", out.networkInputs.size(), out.networkOutputs.size()); - IE_ASSERT(!out.networkInputs.empty()); IE_ASSERT(!out.networkOutputs.empty()); env.log->trace("Perform topological sort"); diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.cpp b/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.cpp index f2cd14bbb15fbc..3ddcc2fcc4529a 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.cpp +++ b/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.cpp @@ -7,6 +7,7 @@ #include #include +#include #include "exec_graph_info.hpp" #include #include @@ -25,7 +26,6 @@ namespace MyriadPlugin { ExecutableNetwork::ExecutableNetwork( std::shared_ptr mvnc, - std::vector& devicePool, const MyriadConfiguration& config, const std::shared_ptr core) : _config(config), @@ -40,10 +40,6 @@ ExecutableNetwork::ExecutableNetwork( defaultOutput(_config.pluginLogFilePath())); _executor = std::make_shared(_config.forceReset(), std::move(mvnc), logLevel, _log); - _device = _executor->openDevice(devicePool, _config); - - const auto& revision = _device->revision(); - _actualNumExecutors = config.compileConfig().numExecutors != -1 ? config.compileConfig().numExecutors : DefaultAllocation::numStreams(revision, config); _supportedMetrics = { METRIC_KEY(NETWORK_NAME), @@ -54,13 +50,19 @@ ExecutableNetwork::ExecutableNetwork( }; } +void ExecutableNetwork::openDevice(std::vector& devicePool) { + _device = _executor->openDevice(devicePool, _config); + const auto& revision = _device->revision(); + _actualNumExecutors = _config.compileConfig().numExecutors != -1 ? _config.compileConfig().numExecutors : DefaultAllocation::numStreams(revision, _config); +} + ExecutableNetwork::ExecutableNetwork( const ie::CNNNetwork& network, std::shared_ptr mvnc, std::vector& devicePool, const MyriadConfiguration& config, const std::shared_ptr core) : - ExecutableNetwork(std::move(mvnc), devicePool, config, core) { + ExecutableNetwork(std::move(mvnc), config, core) { VPU_PROFILE(ExecutableNetwork); const auto compilerLog = std::make_shared( @@ -68,11 +70,9 @@ ExecutableNetwork::ExecutableNetwork( _config.get(), defaultOutput(_config.compilerLogFilePath())); - if (_device == nullptr) - IE_THROW() << "No device was detected"; auto compiledGraph = compileNetwork( network, - _device->_platform, + NC_MYRIAD_X, _config, compilerLog, _core); @@ -84,12 +84,7 @@ ExecutableNetwork::ExecutableNetwork( _inputInfo = std::move(compiledGraph->inputInfo); _outputInfo = std::move(compiledGraph->outputInfo); - if (!_device->isBooted()) { - return; - } - const auto& networkName = network.getName(); - _executor->allocateGraph(_device, _graphDesc, _graphBlob, compiledGraph->blobHeader, compiledGraph->numActiveStages, networkName, _actualNumExecutors); if (_config.exclusiveAsyncRequests()) { ExecutorManager *executorManager = ExecutorManager::getInstance(); _taskExecutor = executorManager->getExecutor("MYRIAD"); @@ -100,6 +95,21 @@ ExecutableNetwork::ExecutableNetwork( idStream << networkName << "_TaskExecutorGetResult" << i; _taskExecutorGetResultIds.emplace(idStream.str()); } + if (_inputInfo.totalSize == 0) { + _isNetworkConstant = true; + const auto& nGraphFunc = network.getFunction(); + const auto& sortedLayers = nGraphFunc->get_ordered_ops(); + for (const auto& layer : sortedLayers) { + if (strcmp(layer->get_type_info().name, "Constant") == 0) { + const auto& constOp = std::dynamic_pointer_cast(layer); + auto name = constOp->get_friendly_name(); + _constDatas[name] = ie::details::shareWeights(constOp); + } + } + return; + } + openDevice(devicePool); + _executor->allocateGraph(_device, _graphDesc, _graphBlob, compiledGraph->blobHeader, compiledGraph->numActiveStages, networkName, _actualNumExecutors); } void ExecutableNetwork::Import(std::istream& strm, std::vector &devicePool, const MyriadConfiguration& configuration) { @@ -110,10 +120,6 @@ void ExecutableNetwork::Import(std::istream& strm, std::vector &devic strm.seekg(currentPos, strm.beg); strm.read(&_graphBlob[0], blobSize); - if (!_device->isBooted()) { - return; - } - std::string networkName = importedNetworkName; BlobReader blobReader; @@ -126,9 +132,8 @@ void ExecutableNetwork::Import(std::istream& strm, std::vector &devic _inputInfo = blobReader.getInputInfo(); _outputInfo = blobReader.getOutputInfo(); - + openDevice(devicePool); _executor->allocateGraph(_device, _graphDesc, _graphBlob, blobHeader, numStages, networkName, _actualNumExecutors); - _graphMetaData.stagesMeta.resize(numStages); for (auto &meta : _graphMetaData.stagesMeta) { meta.stageName = meta.stageType = meta.layerName = meta.layerType = "UNKNOWN"; @@ -147,9 +152,12 @@ void ExecutableNetwork::Import(std::istream& strm, std::vector &devic } } -ExecutableNetwork::ExecutableNetwork(std::istream& strm, std::shared_ptr mvnc, std::vector &devicePool, - const MyriadConfiguration& config, const std::shared_ptr core) : - ExecutableNetwork(std::move(mvnc), devicePool, config, core) { +ExecutableNetwork::ExecutableNetwork(std::istream& strm, + std::shared_ptr mvnc, + std::vector &devicePool, + const MyriadConfiguration& config, + const std::shared_ptr core) : + ExecutableNetwork(std::move(mvnc), config, core) { VPU_PROFILE(ExecutableNetwork); Import(strm, devicePool, config); } @@ -160,7 +168,7 @@ ExecutableNetwork::ExecutableNetwork( std::vector& devicePool, const MyriadConfiguration& config, const std::shared_ptr core) : - ExecutableNetwork(std::move(mvnc), devicePool, config, core) { + ExecutableNetwork(std::move(mvnc), config, core) { VPU_PROFILE(ExecutableNetwork); std::ifstream blobFile{blobFilename, std::ios::binary}; Import(blobFile, devicePool, config); diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.h b/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.h index 51f9d10ad567cc..94ed3e76b114c9 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.h +++ b/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.h @@ -44,7 +44,9 @@ class ExecutableNetwork : public ie::ExecutableNetworkThreadSafeDefault { virtual ~ExecutableNetwork() { try { - _executor->deallocateGraph(_device, _graphDesc); + if (_device != nullptr) { + _executor->deallocateGraph(_device, _graphDesc); + } } catch (...) { std::cerr << "ERROR ~ExecutableNetwork():\n" @@ -54,18 +56,19 @@ class ExecutableNetwork : public ie::ExecutableNetworkThreadSafeDefault { ie::IInferRequestInternal::Ptr CreateInferRequestImpl(ie::InputsDataMap networkInputs, ie::OutputsDataMap networkOutputs) override { - if (_device == nullptr || !_device->isBooted()) { + if (!_isNetworkConstant && (_device == nullptr || !_device->isBooted())) { IE_THROW() << "Can not create infer request: there is no available devices with platform " << _device->_platform; } return std::make_shared(_graphDesc, networkInputs, networkOutputs, _inputInfo, _outputInfo, - _graphMetaData.stagesMeta, _config, _log, _executor); + _graphMetaData.stagesMeta, _config, _log, _executor, + _constDatas, _isNetworkConstant); } ie::IInferRequestInternal::Ptr CreateInferRequest() override { - if (_device == nullptr || !_device->isBooted()) { + if (!_isNetworkConstant && (_device == nullptr || !_device->isBooted())) { IE_THROW() << "Can not create infer request: there is no available devices with platform " << _device->_platform; } @@ -73,7 +76,7 @@ class ExecutableNetwork : public ie::ExecutableNetworkThreadSafeDefault { auto syncRequestImpl = std::make_shared(_graphDesc, _networkInputs, _networkOutputs, _inputInfo, _outputInfo, _graphMetaData.stagesMeta, _config, _log, - _executor); + _executor, _constDatas, _isNetworkConstant); syncRequestImpl->setPointerToExecutableNetworkInternal(shared_from_this()); auto taskExecutorGetResult = getNextTaskExecutor(); return std::make_shared( @@ -84,6 +87,16 @@ class ExecutableNetwork : public ie::ExecutableNetworkThreadSafeDefault { model.write(_graphBlob.data(), _graphBlob.size()); } + void Export(const std::string &modelFileName) override { + std::ofstream modelFile(modelFileName, std::ios::out | std::ios::binary); + + if (modelFile.is_open()) { + Export(modelFile); + } else { + IE_THROW() << "The " << modelFileName << " file can not be opened for export"; + } + } + ie::Parameter GetMetric(const std::string &name) const override; ie::CNNNetwork GetExecGraphInfo() override; @@ -98,9 +111,11 @@ class ExecutableNetwork : public ie::ExecutableNetworkThreadSafeDefault { DevicePtr _device; GraphMetaInfo _graphMetaData; MyriadConfiguration _config; + bool _isNetworkConstant = false; const std::shared_ptr _core = nullptr; int _actualNumExecutors = 0; std::vector _supportedMetrics; + std::map _constDatas; DataInfo _inputInfo; DataInfo _outputInfo; @@ -109,9 +124,8 @@ class ExecutableNetwork : public ie::ExecutableNetworkThreadSafeDefault { std::queue _taskExecutorGetResultIds; ExecutableNetwork(std::shared_ptr mvnc, - std::vector &devicePool, - const MyriadConfiguration& config, - const std::shared_ptr core); + const MyriadConfiguration& config, + const std::shared_ptr core); ie::ITaskExecutor::Ptr getNextTaskExecutor() { std::string id = _taskExecutorGetResultIds.front(); @@ -124,6 +138,8 @@ class ExecutableNetwork : public ie::ExecutableNetworkThreadSafeDefault { return taskExecutor; } + + void openDevice(std::vector& devicePool); }; } // namespace MyriadPlugin diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_infer_request.cpp b/inference-engine/src/vpu/myriad_plugin/myriad_infer_request.cpp index 020a3d9e580a18..a3662543a0fccd 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_infer_request.cpp +++ b/inference-engine/src/vpu/myriad_plugin/myriad_infer_request.cpp @@ -33,11 +33,13 @@ MyriadInferRequest::MyriadInferRequest(GraphDesc &graphDesc, const std::vector &blobMetaData, const MyriadConfig& myriadConfig, const Logger::Ptr &log, - const MyriadExecutorPtr &executor) : + const MyriadExecutorPtr &executor, + std::map constDatas, + bool isNetworkConstant = true) : IInferRequestInternal(networkInputs, networkOutputs), _executor(executor), _log(log), _stagesMetaData(blobMetaData), _config(myriadConfig), _inputInfo(compilerInputsInfo), _outputInfo(compilerOutputsInfo), - _graphDesc(graphDesc) { + _graphDesc(graphDesc), _constDatas(constDatas), _isNetworkConstant(isNetworkConstant) { VPU_PROFILE(MyriadInferRequest); const auto& ioStrides = _config.compileConfig().ioStrides; @@ -83,7 +85,7 @@ MyriadInferRequest::MyriadInferRequest(GraphDesc &graphDesc, resultBuffer.resize(compilerOutputsInfo.totalSize); VPU_THROW_UNLESS( - !_networkOutputs.empty() && !_networkInputs.empty(), + !_networkOutputs.empty() && !(_networkInputs.empty() && !_isNetworkConstant), "No information about network's output/input"); } @@ -93,6 +95,9 @@ void MyriadInferRequest::InferImpl() { } void MyriadInferRequest::InferAsync() { + if (_isNetworkConstant) { + return; + } VPU_PROFILE(InferAsync); // execute input pre-processing @@ -104,7 +109,7 @@ void MyriadInferRequest::InferAsync() { auto getOffset = [&inputInfo] (const std::string& name) { const auto offsetIt = inputInfo.offset.find(name); IE_ASSERT(offsetIt != inputInfo.offset.end()) << "MyriadInferRequest::InferAsync()\n" - << "Input offset [" << name << "] is not provided."; + << "Input offset [" << name << "] is not provided."; return offsetIt->second; }; @@ -123,9 +128,9 @@ void MyriadInferRequest::InferAsync() { const auto byteSize = blob->byteSize(); const auto requiredSize = vpu::checked_cast(offset) + byteSize; IE_ASSERT(requiredSize <= inputBuffer.size()) << "MyriadInferRequest::InferAsync()\n" - << "Input offset is too big. " - << "Required size: " << requiredSize - << ", Input buffer size: " << inputBuffer.size(); + << "Input offset is too big. " + << "Required size: " << requiredSize + << ", Input buffer size: " << inputBuffer.size(); const auto foundBlob = getNetInputInfo(name); const auto vpuLayout = foundBlob->second->getTensorDesc().getLayout(); @@ -139,9 +144,8 @@ void MyriadInferRequest::InferAsync() { } _executor->queueInference(_graphDesc, inputBuffer.data(), - _inputInfo.totalSize, nullptr, 0); + _inputInfo.totalSize, nullptr, 0); } - static void copyBlobAccordingUpperBound( const Blob::Ptr& in, const Blob::Ptr& out) { @@ -199,10 +203,22 @@ void MyriadInferRequest::GetResult() { const auto getVpuLayout = [&networkOutputs] (const std::string& name){ const auto foundBlob = networkOutputs.find(name); IE_ASSERT(foundBlob != networkOutputs.end()) << "MyriadInferRequest::InferAsync()\n" - << "Output [" << name << "] is not provided."; + << "Output [" << name << "] is not provided."; return foundBlob->second->getTensorDesc().getLayout(); }; - + if (_isNetworkConstant) { + for (const auto& output : _outputs) { + const auto& ieBlobName = output.first; + const auto& ieBlob = output.second; + IE_ASSERT(_constDatas.find(ieBlobName) != _constDatas.end()) << + "Input [" << ieBlobName << "] is not provided."; + std::copy_n( + _constDatas[ieBlobName]->cbuffer().as(), + _constDatas[ieBlobName]->byteSize(), + ieBlob->buffer().as()); + } + return; + } // For networks with only one output if (_outputInfo.offset.size() == 1) { const auto& it = _outputs.begin(); @@ -224,12 +240,12 @@ void MyriadInferRequest::GetResult() { const auto resultOffset = [&](const std::string& name) { const auto offset_it = _outputInfo.offset.find(name); IE_ASSERT(offset_it != _outputInfo.offset.end()) << "MyriadInferRequest::InferAsync()\n" - << "Output offset [" << name << "] error."; + << "Output offset [" << name << "] error."; const auto offset = vpu::checked_cast(offset_it->second); IE_ASSERT(offset <= resultBuffer.size()) << "MyriadInferRequest::InferAsync()\n" - << "Input offset is too big." - << "Required offset: " << offset - << "Result buffer size: " << resultBuffer.size(); + << "Input offset is too big." + << "Required offset: " << offset + << "Result buffer size: " << resultBuffer.size(); return offset; }; diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_infer_request.h b/inference-engine/src/vpu/myriad_plugin/myriad_infer_request.h index 9373f771fb927a..194ce5fc990034 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_infer_request.h +++ b/inference-engine/src/vpu/myriad_plugin/myriad_infer_request.h @@ -34,6 +34,8 @@ class MyriadInferRequest : public InferenceEngine::IInferRequestInternal { GraphDesc _graphDesc; std::vector resultBuffer; std::vector inputBuffer; + std::map _constDatas; + bool _isNetworkConstant; public: typedef std::shared_ptr Ptr; @@ -46,7 +48,9 @@ class MyriadInferRequest : public InferenceEngine::IInferRequestInternal { const std::vector &blobMetaData, const MyriadConfig &myriadConfig, const Logger::Ptr &log, - const MyriadExecutorPtr &executor); + const MyriadExecutorPtr &executor, + std::map constDatas, + bool isNetworkConstant); void InferImpl() override; void InferAsync(); diff --git a/inference-engine/tests/functional/inference_engine/ir_serialization/deterministicity.cpp b/inference-engine/tests/functional/inference_engine/ir_serialization/deterministicity.cpp index 8fb248ed7dc0ca..cbcd1b3093dbd5 100644 --- a/inference-engine/tests/functional/inference_engine/ir_serialization/deterministicity.cpp +++ b/inference-engine/tests/functional/inference_engine/ir_serialization/deterministicity.cpp @@ -124,3 +124,49 @@ TEST_F(SerializationDeterministicityTest, ModelWithConstants) { ASSERT_TRUE(files_equal(xml_1, xml_2)); ASSERT_TRUE(files_equal(bin_1, bin_2)); } + +TEST_F(SerializationDeterministicityTest, SerializeToStream) { + const std::string model = + IR_SERIALIZATION_MODELS_PATH "add_abc_initializers.xml"; + const std::string weights = + IR_SERIALIZATION_MODELS_PATH "add_abc_initializers.bin"; + + std::stringstream m_out_xml_buf, m_out_bin_buf; + InferenceEngine::Blob::Ptr binBlob; + + InferenceEngine::Core ie; + auto expected = ie.ReadNetwork(model, weights); + expected.serialize(m_out_xml_buf, m_out_bin_buf); + + std::streambuf* pbuf = m_out_bin_buf.rdbuf(); + unsigned long bufSize = m_out_bin_buf.tellp(); + + InferenceEngine::TensorDesc tensorDesc(InferenceEngine::Precision::U8, + { bufSize }, InferenceEngine::Layout::C); + binBlob = InferenceEngine::make_shared_blob(tensorDesc); + binBlob->allocate(); + pbuf->sgetn(binBlob->buffer(), bufSize); + + auto result = ie.ReadNetwork(m_out_xml_buf.str(), binBlob); + + ASSERT_TRUE(expected.layerCount() == result.layerCount()); + ASSERT_TRUE(expected.getInputShapes() == result.getInputShapes()); +} + +TEST_F(SerializationDeterministicityTest, SerializeToBlob) { + const std::string model = + IR_SERIALIZATION_MODELS_PATH "add_abc_initializers.xml"; + const std::string weights = + IR_SERIALIZATION_MODELS_PATH "add_abc_initializers.bin"; + + std::stringstream m_out_xml_buf; + InferenceEngine::Blob::Ptr m_out_bin_buf; + + InferenceEngine::Core ie; + auto expected = ie.ReadNetwork(model, weights); + expected.serialize(m_out_xml_buf, m_out_bin_buf); + auto result = ie.ReadNetwork(m_out_xml_buf.str(), m_out_bin_buf); + + ASSERT_TRUE(expected.layerCount() == result.layerCount()); + ASSERT_TRUE(expected.getInputShapes() == result.getInputShapes()); +} diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/activation.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/activation.cpp index 371808cbbc5246..355afbaf687576 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/activation.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/activation.cpp @@ -37,6 +37,7 @@ const std::map>> activationTypes {Negative, {}}, {Acos, {}}, {Asin, {}}, + {Asinh, {}}, {Atan, {}}, {Cos, {}}, {Cosh, {}}, diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/prior_box.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/prior_box.cpp new file mode 100644 index 00000000000000..91def7d74c8831 --- /dev/null +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/prior_box.cpp @@ -0,0 +1,98 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "shared_test_classes/single_layer/prior_box.hpp" +#include "common_test_utils/test_constants.hpp" + +using namespace LayerTestDefinitions; + +namespace { + TEST_P(PriorBoxLayerTest, Serialize) { + Serialize(); + } + + const std::vector netPrecisions = { + InferenceEngine::Precision::I32, + InferenceEngine::Precision::U16 + }; + const std::vector> min_sizes = { + {16.f, 32.f} + }; + + const std::vector> max_sizes = { + {256.f, 512.f} + }; + + const std::vector> aspect_ratios = { + {0.66f, 1.56f} + }; + + const std::vector> densities = { + {0.55f} + }; + + const std::vector> fixed_ratios = { + {0.88f} + }; + + const std::vector> fixed_sizes = { + {1.25f} + }; + + const std::vector clips = { + true, false + }; + + const std::vector flips = { + true, false + }; + + const std::vector steps = { + 1.0f, 2.0f + }; + + const std::vector offsets = { + 0.0f, 0.5f + }; + + const std::vector> variances = { + {2.22f, 3.14f} + }; + + const std::vector scale_all_sizes = { + true, false + }; + + const std::vector inputShape = {128, 128}; + const std::vector imageShape = {50, 50}; + + const auto layerSpecificParams = ::testing::Combine( + ::testing::ValuesIn(min_sizes), + ::testing::ValuesIn(max_sizes), + ::testing::ValuesIn(aspect_ratios), + ::testing::ValuesIn(densities), + ::testing::ValuesIn(fixed_ratios), + ::testing::ValuesIn(fixed_sizes), + ::testing::ValuesIn(clips), + ::testing::ValuesIn(flips), + ::testing::ValuesIn(steps), + ::testing::ValuesIn(offsets), + ::testing::ValuesIn(variances), + ::testing::ValuesIn(scale_all_sizes)); + + INSTANTIATE_TEST_SUITE_P(smoke_PriorBox_Basic, PriorBoxLayerTest, + ::testing::Combine( + layerSpecificParams, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(inputShape), + ::testing::Values(imageShape), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), + PriorBoxLayerTest::getTestCaseName); +} // namespace diff --git a/inference-engine/tests/functional/inference_engine/transformations/convert_deformable_conv_v8_to_v1_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/convert_deformable_conv_v8_to_v1_test.cpp new file mode 100644 index 00000000000000..b80c9ce6dbfc25 --- /dev/null +++ b/inference-engine/tests/functional/inference_engine/transformations/convert_deformable_conv_v8_to_v1_test.cpp @@ -0,0 +1,160 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "common_test_utils/ngraph_test_utils.hpp" + +using namespace testing; +using namespace ngraph; + +TEST(TransformationTests, ConvertDeformableConv8to1) { + std::shared_ptr f(nullptr), f_ref(nullptr); + { + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + + const Shape input_shape{1, 1, 4, 4}; + const Shape filter_shape{1, 1, 2, 2}; + const Shape offsets_shape{1, 8, 3, 3}; + + auto data = std::make_shared(element::f32, input_shape); + auto filter = std::make_shared(element::f32, filter_shape); + auto offsets = std::make_shared(element::f32, offsets_shape); + + auto deformable_conv = std::make_shared(data, + offsets, + filter, + strides, + padding, + padding, + dilations); + + f = std::make_shared(NodeVector{deformable_conv}, ParameterVector{data, filter, offsets}); + + pass::Manager manager; + manager.register_pass(); + manager.register_pass(); + manager.run_passes(f); + ASSERT_NO_THROW(check_rt_info(f)); + } + + { + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + + const Shape input_shape{1, 1, 4, 4}; + const Shape filter_shape{1, 1, 2, 2}; + const Shape offsets_shape{1, 8, 3, 3}; + + auto data = std::make_shared(element::f32, input_shape); + auto filter = std::make_shared(element::f32, filter_shape); + auto offsets = std::make_shared(element::f32, offsets_shape); + + auto deformable_conv = std::make_shared(data, + offsets, + filter, + strides, + padding, + padding, + dilations); + + f_ref = std::make_shared(NodeVector{deformable_conv}, ParameterVector{data, filter, offsets}); + } + + auto res = compare_functions(f, f_ref); + ASSERT_TRUE(res.first) << res.second; +} + +TEST(TransformationTests, ConvertDeformableConv8to1_mask) { + std::shared_ptr f(nullptr), f_ref(nullptr); + { + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + + const Shape input_shape{1, 1, 4, 4}; + const Shape filter_shape{1, 1, 2, 2}; + const Shape offsets_shape{1, 8, 3, 3}; + const Shape mask_shape{1, 4, 3, 3}; + + auto data = std::make_shared(element::f32, input_shape); + auto filter = std::make_shared(element::f32, filter_shape); + auto offsets = std::make_shared(element::f32, offsets_shape); + auto mask = std::make_shared(element::f32, mask_shape); + + auto deformable_conv = std::make_shared(data, + offsets, + filter, + mask, + strides, + padding, + padding, + dilations); + + f = std::make_shared(NodeVector{deformable_conv}, ParameterVector{data, filter, + mask, offsets}); + + pass::Manager manager; + manager.register_pass(); + manager.register_pass(); + manager.run_passes(f); + ASSERT_NO_THROW(check_rt_info(f)); + } + // mask input is provided, DeformableConvolution-8 must remain + ASSERT_EQ(count_ops_of_type(f), 0); + ASSERT_EQ(count_ops_of_type(f), 1); +} + +TEST(TransformationTests, ConvertDeformableConv8to1_bilinear_interpolation_padding) { + std::shared_ptr f(nullptr), f_ref(nullptr); + { + const Strides strides{1, 1}; + const CoordinateDiff padding{0, 0}; + const Strides dilations{1, 1}; + + const Shape input_shape{1, 1, 4, 4}; + const Shape filter_shape{1, 1, 2, 2}; + const Shape offsets_shape{1, 8, 3, 3}; + + auto data = std::make_shared(element::f32, input_shape); + auto filter = std::make_shared(element::f32, filter_shape); + auto offsets = std::make_shared(element::f32, offsets_shape); + + auto deformable_conv = std::make_shared(data, + offsets, + filter, + strides, + padding, + padding, + dilations, + op::PadType::EXPLICIT, + 1, + 1, + true); + + f = std::make_shared(NodeVector{deformable_conv}, ParameterVector{data, filter, offsets}); + + pass::Manager manager; + manager.register_pass(); + manager.register_pass(); + manager.run_passes(f); + ASSERT_NO_THROW(check_rt_info(f)); + } + // use_bilinear_interpolation_padding is true, DeformableConvolution-8 must remain + ASSERT_EQ(count_ops_of_type(f), 0); + ASSERT_EQ(count_ops_of_type(f), 1); +} diff --git a/inference-engine/tests/functional/inference_engine/transformations/framework_node_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/framework_node_test.cpp new file mode 100644 index 00000000000000..a87bb245856baf --- /dev/null +++ b/inference-engine/tests/functional/inference_engine/transformations/framework_node_test.cpp @@ -0,0 +1,59 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include +#include +#include + +#include +#include + +#include "common_test_utils/ngraph_test_utils.hpp" + + +using namespace testing; +using namespace ngraph; + + +TEST(TransformationTests, FrameworkNode) { + auto param = std::make_shared(element::i64, Shape{1, 64}); + auto f_node = std::make_shared(OutputVector{param}); + f_node->set_output_type(0, element::i64, Shape{1, 64}); + + // Set partially dynamic shape + param->set_partial_shape(PartialShape{Dimension::dynamic(), 64}); + param->validate_and_infer_types(); + + ASSERT_NO_THROW(f_node->validate_and_infer_types()); + ASSERT_EQ(f_node->get_output_partial_shape(0), PartialShape::dynamic()); + + // Set dynamic shape + param->set_partial_shape(PartialShape::dynamic(2)); + param->validate_and_infer_types(); + + ASSERT_NO_THROW(f_node->validate_and_infer_types()); + ASSERT_EQ(f_node->get_output_partial_shape(0), PartialShape::dynamic()); + + // Set fully dynamic shape + param->set_partial_shape(PartialShape::dynamic()); + param->validate_and_infer_types(); + + ASSERT_NO_THROW(f_node->validate_and_infer_types()); + ASSERT_EQ(f_node->get_output_partial_shape(0), PartialShape::dynamic()); + + // Set original static shape + param->set_partial_shape(Shape{1, 64}); + param->validate_and_infer_types(); + + ASSERT_NO_THROW(f_node->validate_and_infer_types()); + ASSERT_EQ(f_node->get_output_partial_shape(0), PartialShape({1, 64})); + + // Set different static shape + param->set_partial_shape(Shape{2, 64}); + param->validate_and_infer_types(); + + ASSERT_THROW(f_node->validate_and_infer_types(), ngraph_error::exception); +} \ No newline at end of file diff --git a/inference-engine/tests/functional/inference_engine/transformations/pad_fusion.cpp b/inference-engine/tests/functional/inference_engine/transformations/pad_fusion.cpp index ea96555ea010a5..e3e6bc40081dcb 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/pad_fusion.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/pad_fusion.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include "common_test_utils/ngraph_test_utils.hpp" @@ -21,6 +22,42 @@ using namespace testing; using namespace ngraph; +TEST(TransformationTests, PadElimination) { + std::shared_ptr f(nullptr), f_ref(nullptr); + + Shape data_shape{1, 3, 14, 14}; + { + auto data = std::make_shared(element::i32, data_shape); + set_tensor_name(data, "param"); + auto pads_begin = opset5::Constant::create(element::i32, Shape{4}, {0, 0, 0, 0}); + auto pads_end = opset5::Constant::create(element::i32, Shape{4}, {0, 0, 0, 0}); + auto pad = std::make_shared(data, pads_begin, pads_end, op::PadMode::CONSTANT); + set_tensor_name(pad, "pad"); + auto filters = std::make_shared(element::i32, Shape{1, 3, 4, 4}); + auto conv = std::make_shared(pad, filters, Strides{1, 1}, + CoordinateDiff{0, 0}, CoordinateDiff{1, 1}, Shape{1, 1}); + set_tensor_name(conv, "conv"); + f = std::make_shared(NodeVector{conv}, ParameterVector{data, filters}); + pass::Manager m; + m.register_pass(); + m.register_pass(); + m.run_passes(f); + ASSERT_NO_THROW(check_rt_info(f)); + } + { + auto data = std::make_shared(element::i32, data_shape); + set_tensor_names(data, {"param", "pad"}); + auto filters = std::make_shared(element::i32, Shape{1, 3, 4, 4}); + auto conv = std::make_shared(data, filters, Strides{1, 1}, + CoordinateDiff{0, 0}, CoordinateDiff{1, 1}, Shape{1, 1}, + op::PadType::EXPLICIT); + set_tensor_name(conv, "conv"); + f_ref = std::make_shared(NodeVector{conv}, ParameterVector{data, filters}); + } + + auto res = compare_functions(f, f_ref); + ASSERT_TRUE(res.first) << res.second; +} TEST(TransformationTests, PadFusionAvgPoolExcludePad) { std::shared_ptr f(nullptr), f_ref(nullptr); @@ -155,9 +192,11 @@ TEST(TransformationTests, PadFusionConvolutionBackpropData) { auto pads_begin = opset5::Constant::create(element::i32, Shape{4}, {0, 0, 1, 1}); auto pads_end = opset5::Constant::create(element::i32, Shape{4}, {0, 0, 2, 2}); auto pad = std::make_shared(data, pads_begin, pads_end, op::PadMode::CONSTANT); + set_tensor_name(pad, "pad"); auto filters = std::make_shared(element::f32, Shape{3, 2, 5, 5}); auto conv = std::make_shared(pad, filters, Strides{1, 1}, CoordinateDiff{4, 4}, CoordinateDiff{3, 3}, Shape{1, 1}); + set_tensor_name(conv, "conv"); f = std::make_shared(NodeVector{conv}, ParameterVector{data, filters}); pass::Manager m; @@ -171,6 +210,7 @@ TEST(TransformationTests, PadFusionConvolutionBackpropData) { auto filters = std::make_shared(element::f32, Shape{3, 2, 5, 5}); auto conv = std::make_shared(data, filters, Strides{1, 1}, CoordinateDiff{3, 3}, CoordinateDiff{1, 1}, Shape{1, 1}); + set_tensor_name(conv, "conv"); f_ref = std::make_shared(NodeVector{conv}, ParameterVector{data, filters}); } @@ -389,12 +429,15 @@ TEST(TransformationTests, NegativePadFusionConvolutionBackpropDataTooSmallPad) { Shape data_shape{1, 3, 14, 14}; { auto data = std::make_shared(element::f32, data_shape); + set_tensor_name(data, "data"); auto pads_begin = opset5::Constant::create(element::i32, Shape{4}, {0, 0, 2, 2}); auto pads_end = opset5::Constant::create(element::i32, Shape{4}, {0, 0, 2, 2}); auto pad = std::make_shared(data, pads_begin, pads_end, op::PadMode::CONSTANT); + set_tensor_name(pad, "pad"); auto filters = std::make_shared(element::f32, Shape{3, 2, 5, 5}); auto conv = std::make_shared(pad, filters, Strides{1, 1}, CoordinateDiff{1, 1}, CoordinateDiff{1, 1}, Shape{1, 1}); + set_tensor_name(conv, "conv"); f = std::make_shared(NodeVector{conv}, ParameterVector{data, filters}); pass::Manager m; @@ -405,12 +448,15 @@ TEST(TransformationTests, NegativePadFusionConvolutionBackpropDataTooSmallPad) { } { auto data = std::make_shared(element::f32, data_shape); + set_tensor_name(data, "data"); auto pads_begin = opset5::Constant::create(element::i32, Shape{4}, {0, 0, 2, 2}); auto pads_end = opset5::Constant::create(element::i32, Shape{4}, {0, 0, 2, 2}); auto pad = std::make_shared(data, pads_begin, pads_end, op::PadMode::CONSTANT); + set_tensor_name(pad, "pad"); auto filters = std::make_shared(element::f32, Shape{3, 2, 5, 5}); auto conv = std::make_shared(pad, filters, Strides{1, 1}, CoordinateDiff{1, 1}, CoordinateDiff{1, 1}, Shape{1, 1}); + set_tensor_name(conv, "conv"); f_ref = std::make_shared(NodeVector{conv}, ParameterVector{data, filters}); } diff --git a/inference-engine/tests/functional/inference_engine/transformations/simplify_shape_of_sub_graph.cpp b/inference-engine/tests/functional/inference_engine/transformations/simplify_shape_of_sub_graph.cpp new file mode 100644 index 00000000000000..d4b0e166573597 --- /dev/null +++ b/inference-engine/tests/functional/inference_engine/transformations/simplify_shape_of_sub_graph.cpp @@ -0,0 +1,81 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "common_test_utils/ngraph_test_utils.hpp" + + +using namespace testing; +using namespace ngraph; + +auto gather = [](const std::shared_ptr input, std::vector indices, bool scalar = false) -> Output { + std::shared_ptr indices_node; + if (scalar) + indices_node = opset7::Constant::create(element::i64, {}, indices); + else + indices_node = opset7::Constant::create(element::i64, {indices.size()}, indices); + return std::make_shared( + input, indices_node, opset7::Constant::create(element::i64, {}, {0})); +}; + +TEST(TransformationTests, ShapeSubGraphTest) { + std::shared_ptr f(nullptr), f_ref(nullptr); + + Shape data_shape{1, 2, 3, 4}; + { + auto data = std::make_shared(element::f32, data_shape); + + auto shape_op_1 = std::make_shared(data); + auto gather_1 = gather(shape_op_1, {1}, true); + auto unsqueeze_1 = std::make_shared( + gather_1, opset7::Constant::create(element::i64, {1}, {0})); + + auto shape_op_2 = std::make_shared(data); + auto gather_2 = gather(shape_op_2, {2}, true); + auto unsqueeze_2 = std::make_shared( + gather_2, opset7::Constant::create(element::i64, {1}, {0})); + + auto const_1 = opset7::Constant::create(element::i64, Shape{1}, {2}); + auto const_2 = opset7::Constant::create(element::i64, Shape{1}, {2}); + + auto concat = std::make_shared(OutputVector{unsqueeze_1, unsqueeze_2, const_1, const_2}, 0); + + auto reshape = std::make_shared(data, concat, false); + f = std::make_shared(NodeVector{reshape}, ParameterVector{data}); + pass::Manager m; + m.register_pass(); + m.register_pass(); + m.run_passes(f); + ASSERT_NO_THROW(check_rt_info(f)); + ASSERT_EQ(reshape->get_output_partial_shape(0), PartialShape({2, 3, 2, 2})); + } + { + auto data = std::make_shared(element::f32, data_shape); + + auto shape_op_1 = std::make_shared(data); + auto gather_1 = gather(shape_op_1, {1, 2}); + + auto const_1 = opset7::Constant::create(element::i64, Shape{1}, {2}); + auto const_2 = opset7::Constant::create(element::i64, Shape{1}, {2}); + + auto concat = std::make_shared(OutputVector{gather_1, const_1, const_2}, 0); + + auto reshape = std::make_shared(data, concat, false); + f_ref = std::make_shared(NodeVector{reshape}, ParameterVector{data}); + } + + auto res = compare_functions(f, f_ref, true); + ASSERT_TRUE(res.first) << res.second; +} diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/add_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/add_transformation.cpp index f575a6cc2ec472..c2d0c9ccf0ccf6 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/add_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/add_transformation.cpp @@ -71,7 +71,7 @@ const std::vector params = { INSTANTIATE_TEST_SUITE_P(smoke_LPT, AddTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(params)), AddTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/clamp_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/clamp_transformation.cpp index 6f45a17b35214e..8b9a1c407c6807 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/clamp_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/clamp_transformation.cpp @@ -79,7 +79,7 @@ const std::vector params{ INSTANTIATE_TEST_SUITE_P(smoke_LPT, ClampTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(params)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_transformation.cpp index 60d5e1ff730589..ffd5c2b1d43d80 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_transformation.cpp @@ -44,7 +44,7 @@ const std::vector testValues = { }, }; -const std::vector shapes = { +const std::vector shapes = { ngraph::Shape({ 1, 3, 16, 16 }), ngraph::Shape({ 4, 3, 16, 16 }) }; diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_child_and_output.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_child_and_output.cpp index 0141d37d23a5ef..205e23656e41f7 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_child_and_output.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_child_and_output.cpp @@ -45,7 +45,7 @@ const std::vector testValues = { INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConcatWithChildAndOutputTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 6, 10, 10 })), + ::testing::Values(ngraph::PartialShape({ 1, 6, 10, 10 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(testValues), ::testing::ValuesIn(trasformationParamValues)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_different_precision_on_children.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_different_precision_on_children.cpp index dc7d9936e6af76..64b6b0b4d2a335 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_different_precision_on_children.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_different_precision_on_children.cpp @@ -48,7 +48,7 @@ const std::vector multiChannel = { true/*, false*/ }; INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConcatWithDifferentChildrenTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 6, 10, 10 })), + ::testing::Values(ngraph::PartialShape({ 1, 6, 10, 10 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(testValues), ::testing::ValuesIn(trasformationParamValues), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_intermediate_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_intermediate_transformation.cpp index 8c24e9cec2091d..0033b65b1c3e75 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_intermediate_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_intermediate_transformation.cpp @@ -26,7 +26,7 @@ const std::vector tras const std::vector transparentIntermediateValues = { true, false }; const std::vector multiChannelValues = { /*true,*/ false }; -const std::vector shapes = { +const std::vector shapes = { { 1, 3, 16, 16 }, { 4, 3, 16, 16 } }; diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_neighbors_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_neighbors_transformation.cpp index a0724e1bfe667c..8d41c2b4086206 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_neighbors_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_neighbors_transformation.cpp @@ -23,7 +23,7 @@ const std::vector tras LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8() }; -const std::vector shapes = { +const std::vector shapes = { { 1, 3, 16, 16 }, { 4, 3, 16, 16 } }; diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_split_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_split_transformation.cpp index f6d2f1c16b78fd..47dfa3385f671b 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_split_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_split_transformation.cpp @@ -48,7 +48,7 @@ const std::vector testValues = { INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConcatWithSplitTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 6, 10, 10 })), + ::testing::Values(ngraph::PartialShape({ 1, 6, 10, 10 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(testValues), ::testing::ValuesIn(trasformationParamValues)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp index 180ef107e02ebb..2aa5610a922837 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp @@ -100,7 +100,7 @@ const std::vector> inputShapes = { +const std::vector> inputShapes = { {{ 1, 8, 16, 16 }, true} }; diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_qdq_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_qdq_transformation.cpp index 5cb46fc2ee868c..61050800444a38 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_qdq_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_qdq_transformation.cpp @@ -233,7 +233,7 @@ const std::vector para }, }; -const std::vector shapes = { +const std::vector shapes = { { 1, 3, 4, 4 }, { 4, 3, 4, 4 } }; diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/depth_to_space_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/depth_to_space_transformation.cpp index d9057f66a92565..e016bb047867fd 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/depth_to_space_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/depth_to_space_transformation.cpp @@ -22,7 +22,7 @@ const std::vector modes = { DepthToSpace::DepthToSpaceMode::DEPTH_FIRST }; -const std::vector inputShapesBS2 = { +const std::vector inputShapesBS2 = { {1, 4, 3, 3}, {2, 16, 5, 4} }; @@ -36,7 +36,7 @@ const auto DepthToSpaceBS2 = ::testing::Combine( INSTANTIATE_TEST_SUITE_P(LPT_BS2, DepthToSpaceTransformation, DepthToSpaceBS2, DepthToSpaceTransformation::getTestCaseName); -const std::vector inputShapesBS3 = { +const std::vector inputShapesBS3 = { {1, 9, 3, 3}, {2, 27, 5, 4} }; diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_avg_pool_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_avg_pool_transformation.cpp index d0f2b614f43a89..b4d81223f58f8e 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_avg_pool_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_avg_pool_transformation.cpp @@ -29,7 +29,7 @@ const std::vector fakeQuantizes = INSTANTIATE_TEST_SUITE_P(smoke_LPT, FakeQuantizeAndAvgPoolTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), - ::testing::Values(ngraph::Shape({ 1, 32, 72, 48 })), + ::testing::Values(ngraph::PartialShape({ 1, 32, 72, 48 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(fakeQuantizes)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_max_pool_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_max_pool_transformation.cpp index 78df11d2f7853d..f0e626509dc589 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_max_pool_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_max_pool_transformation.cpp @@ -29,7 +29,7 @@ const std::vector fakeQuantizes = INSTANTIATE_TEST_SUITE_P(smoke_LPT, FakeQuantizeAndMaxPoolTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), - ::testing::Values(ngraph::Shape({ 1, 32, 72, 48 })), + ::testing::Values(ngraph::PartialShape({ 1, 32, 72, 48 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(fakeQuantizes)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp index adb79c659ecd32..2df5b908a0bf2b 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp @@ -31,7 +31,7 @@ const std::vector testValues = INSTANTIATE_TEST_SUITE_P(smoke_LPT, FakeQuantizeAndTwoOutputBranchesWithConvolutionTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 32, 72, 48 })), + ::testing::Values(ngraph::PartialShape({ 1, 32, 72, 48 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(testValues)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_precision_selection_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_precision_selection_transformation.cpp index f2e7df2acde38b..efced0be774171 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_precision_selection_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_precision_selection_transformation.cpp @@ -59,7 +59,7 @@ const std::vector testVa INSTANTIATE_TEST_SUITE_P(smoke_LPT, FakeQuantizePrecisionSelectionTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 32, 72, 48 })), + ::testing::Values(ngraph::PartialShape({ 1, 32, 72, 48 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(testValues)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_transformation.cpp index 69ce1065c206c1..52cf2b24ba749e 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_transformation.cpp @@ -62,7 +62,7 @@ const std::vector fakeQuantizeOnDataValues = { INSTANTIATE_TEST_SUITE_P(smoke_LPT, FakeQuantizeTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 32, 72, 48 })), + ::testing::Values(ngraph::PartialShape({ 1, 32, 72, 48 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(fakeQuantizeOnDataValues)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp index af1a82dcd41bfe..792323057f13cb 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp @@ -104,7 +104,7 @@ const std::vector fakeQuanti INSTANTIATE_TEST_SUITE_P(smoke_LPT, FakeQuantizeWithNotOptimalTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(fakeQuantizeOnDataValues)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fully_connected_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fully_connected_transformation.cpp index a285b41a53675f..26125f65ba4c19 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fully_connected_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fully_connected_transformation.cpp @@ -18,20 +18,20 @@ const std::vector netPrecisions = { const std::vector shapes = { { - ngraph::Shape{ 1, 16 }, - ngraph::Shape{ 16, 8 }, + ngraph::PartialShape{ 1, 16 }, + ngraph::PartialShape{ 16, 8 }, false, false }, { - ngraph::Shape{ 1, 16 }, - ngraph::Shape{ 8, 16 }, + ngraph::PartialShape{ 1, 16 }, + ngraph::PartialShape{ 8, 16 }, false, true }, { - ngraph::Shape{ 16, 1 }, - ngraph::Shape{ 16, 8 }, + ngraph::PartialShape{ 16, 1 }, + ngraph::PartialShape{ 16, 8 }, true, false }, diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_convert_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_convert_transformation.cpp index 8082ecfe96d7ec..d8c5370b37b76a 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_convert_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_convert_transformation.cpp @@ -12,8 +12,8 @@ const std::vector precisions = { element::f32 }; -const std::vector< ngraph::Shape > inputAndQuantizationShapes = { - Shape{ 1, 4, 16, 16 }, +const std::vector< ngraph::PartialShape > inputAndQuantizationShapes = { + { 1, 4, 16, 16 }, }; const std::vector deqOperations = { diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp index 8d4b127eb48ae0..791be4c2c5ad2b 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp @@ -36,7 +36,7 @@ const std::vector fakeQuantizeOnD INSTANTIATE_TEST_SUITE_P(smoke_LPT, FuseFakeQuantizeAndScaleShiftTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 9, 9 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 9, 9 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(fakeQuantizeOnDataValues)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_transformation.cpp index d1d38ed94d72fd..cf04e0e5b3ce53 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_transformation.cpp @@ -14,7 +14,7 @@ namespace { const std::vector testValues = { // 1) Multiply { - ngraph::Shape{1, 3, 16, 16}, + {1, 3, 16, 16}, LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), { ngraph::element::f32, @@ -26,7 +26,7 @@ const std::vector testValues = { } }, { - ngraph::Shape{128, 3}, + {128, 3}, LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), { ngraph::element::f32, @@ -39,7 +39,7 @@ const std::vector testValues = { }, // 1) Multiply by zero { - ngraph::Shape{1, 3, 16, 16}, + {1, 3, 16, 16}, LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), { ngraph::element::f32, @@ -52,7 +52,7 @@ const std::vector testValues = { }, // 1) Subtract + Multiply { - ngraph::Shape{1, 3, 16, 16}, + {1, 3, 16, 16}, LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), { ngraph::element::f32, @@ -65,7 +65,7 @@ const std::vector testValues = { }, // 1) Convert + Subtract + Multiply { - ngraph::Shape{1, 3, 16, 16}, + {1, 3, 16, 16}, LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), { ngraph::element::f32, @@ -78,7 +78,7 @@ const std::vector testValues = { }, // 1) Convert + Subtract + Multiply 2) Add { - ngraph::Shape{1, 3, 16, 16}, + {1, 3, 16, 16}, LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), { ngraph::element::f32, @@ -91,7 +91,7 @@ const std::vector testValues = { }, // issue #40611 for FP32 { - ngraph::Shape{1, 3, 16, 16}, + {1, 3, 16, 16}, LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), { { }, diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.cpp index 81674818d6bce2..25a9d1c74d8dd7 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.cpp @@ -14,7 +14,7 @@ namespace { const std::vector testValues = { { - Shape{1, 3, 16, 16}, + {1, 3, 16, 16}, LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), { { 256ul, {}, { 0.f }, { 2.55f }, { 0.f }, { 2.55f } }, @@ -22,7 +22,7 @@ const std::vector testValues } }, { - Shape{1, 3, 16, 16}, + {1, 3, 16, 16}, LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), { { 256ul, {}, { -1.28f }, { 1.27f }, { 10.f }, { 2.55f } }, diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.cpp index 4a65f1eb27bc4a..cfac0fe5fd7033 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.cpp @@ -14,7 +14,7 @@ namespace { const std::vector testValues = { { - Shape{1, 3, 16, 16}, + {1, 3, 16, 16}, LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), { { 256ul, {}, { 0.f }, { 2.55f }, { 10.f }, { 255.f } }, @@ -22,7 +22,7 @@ const std::vector testValues } }, { - Shape{1, 3, 16, 16}, + {1, 3, 16, 16}, LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), { { 256ul, {}, { -1.28f }, { 1.27f }, { 0.f }, { 255.f } }, diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/gemm_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/gemm_transformation.cpp index 242df59cfff1ae..4aef2c749c4888 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/gemm_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/gemm_transformation.cpp @@ -16,7 +16,7 @@ const std::vector netPrecisions = { // ngraph::element::f16 }; -const std::vector dimensions = { +const std::vector dimensions = { { 1, 3, 16, 16 } }; diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/group_convolution_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/group_convolution_transformation.cpp index d8a81076d61ce9..cc62ec4db63640 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/group_convolution_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/group_convolution_transformation.cpp @@ -23,8 +23,8 @@ const std::vector tras const std::vector params = { // group convolution, tensor quantization { - ngraph::Shape{ 1, 6, 24, 24 }, - ngraph::Shape{ 1, 24, 18, 18 }, + { 1, 6, 24, 24 }, + { 1, 24, 18, 18 }, 3ul, -1, { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 25.5f }, { 0.f }, { 25.5f } }, @@ -34,8 +34,8 @@ const std::vector pa }, // group convolution, tensor quantization { - ngraph::Shape{ 1, 6, 24, 24 }, - ngraph::Shape{ 1, 24, 18, 18 }, + { 1, 6, 24, 24 }, + { 1, 24, 18, 18 }, 3ul, 0, { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 25.5f }, { 0.f }, { 25.5f } }, @@ -45,8 +45,8 @@ const std::vector pa }, // group convolution, tensor quantization { - ngraph::Shape{ 1, 6, 24, 24 }, - ngraph::Shape{ 1, 24, 18, 18 }, + { 1, 6, 24, 24 }, + { 1, 24, 18, 18 }, 3ul, 1, { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 25.5f }, { 0.f }, { 25.5f } }, @@ -56,8 +56,8 @@ const std::vector pa }, // group convolution, per-channel quantization { - ngraph::Shape{ 1, 6, 24, 24 }, - ngraph::Shape{ 1, 24, 18, 18 }, + { 1, 6, 24, 24 }, + { 1, 24, 18, 18 }, 3ul, -1, { @@ -72,8 +72,8 @@ const std::vector pa }, // depth-wise convolution, tensor quantization { - ngraph::Shape{ 1, 6, 24, 24 }, - ngraph::Shape{ 1, 6, 18, 18 }, + { 1, 6, 24, 24 }, + { 1, 6, 18, 18 }, 6ul, -1, { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 25.5f }, { 0.f }, { 25.5f } }, @@ -81,8 +81,8 @@ const std::vector pa }, // depth-wise convolution, per-channel quantization { - ngraph::Shape{ 1, 6, 24, 24 }, - ngraph::Shape{ 1, 6, 18, 18 }, + { 1, 6, 24, 24 }, + { 1, 6, 18, 18 }, 6ul, -1, { diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/groupconvolution_qdq_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/groupconvolution_qdq_transformation.cpp index 74c60def9fc5c5..8a80f2b13b1ad8 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/groupconvolution_qdq_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/groupconvolution_qdq_transformation.cpp @@ -488,7 +488,7 @@ const std::vector }, }; -const std::vector shapes = { +const std::vector shapes = { { 1, 4, 7, 7 } }; diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/interpolate_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/interpolate_transformation.cpp index 7954fac1a232a0..769d78abf72019 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/interpolate_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/interpolate_transformation.cpp @@ -12,7 +12,7 @@ const std::vector precisions = { ngraph::element::f32 }; -const std::vector> shapes = { +const std::vector> shapes = { {{1, 4, 16, 16}, {32, 32}}, {{1, 2, 48, 80}, {50, 60}}, }; diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp index 2df46fe0bfc5c5..a3c782b39d00ea 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp @@ -45,7 +45,7 @@ std::vector testValues = { INSTANTIATE_TEST_SUITE_P(smoke_LPT, MatMulTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), - ::testing::Values(ngraph::Shape({ 1, 384, 1024 })), + ::testing::Values(ngraph::PartialShape({ 1, 384, 1024 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(testValues)), MatMulTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp index 76ec3422c0638d..dfad0664275e46 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp @@ -21,9 +21,9 @@ const std::vector> inputShapes = { - std::pair({ 1, 16 }, { 10, 16 }), - std::pair({ 1, 16 }, { 16, 10 }) +const std::vector> inputShapes = { + {{ 1, 16 }, { 10, 16 }}, + {{ 1, 16 }, { 16, 10 }} }; INSTANTIATE_TEST_SUITE_P(smoke_LPT, MatMulWithOptimizedConstantFakeQuantizeTransformation, diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_to_group_convolution_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_to_group_convolution_transformation.cpp index 39dc081f40265a..10f45879810315 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_to_group_convolution_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_to_group_convolution_transformation.cpp @@ -12,8 +12,8 @@ const std::vector precisions = { element::f32 }; -const std::vector< ngraph::Shape > inputShapes = { - Shape{ 1ul, 4ul, 16ul, 16ul }, Shape{ 1ul, 4ul, 16ul, 16ul, 16ul } +const std::vector< ngraph::PartialShape > inputShapes = { + { 1ul, 4ul, 16ul, 16ul }, { 1ul, 4ul, 16ul, 16ul, 16ul } }; const std::vector fqOnData = { diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_transformation.cpp index 8f791dc2e7cf5f..de85a663877607 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_transformation.cpp @@ -70,7 +70,7 @@ const std::vector params = { INSTANTIATE_TEST_SUITE_P(smoke_LPT, MultiplyTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(params)), MultiplyTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_with_one_parent_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_with_one_parent_transformation.cpp index 2c790eb7023473..0b483c5fecf0fa 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_with_one_parent_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_with_one_parent_transformation.cpp @@ -24,7 +24,7 @@ const std::vector values = { INSTANTIATE_TEST_SUITE_P(smoke_LPT, MultiplyWithOneParentTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(values)), MultiplyWithOneParentTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mvn_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mvn_transformation.cpp index 505fffa8d54424..1051ef8d15bfb1 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mvn_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mvn_transformation.cpp @@ -12,8 +12,8 @@ const std::vector precisions = { element::f32 }; -const std::vector< ngraph::Shape > inputAndQuantizationShapes = { - Shape{ 1ul, 4ul, 16ul, 16ul }, +const std::vector inputAndQuantizationShapes = { + { 1ul, 4ul, 16ul, 16ul }, }; const std::vector reductionAxes = { { 2, 3 }, { 1, 2, 3 } }; diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/normalize_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/normalize_transformation.cpp index 6a88af8938d97b..c1a8a31dd3ec6d 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/normalize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/normalize_transformation.cpp @@ -16,9 +16,9 @@ const std::vector precisions = { //ngraph::element::f16 }; -const std::vector > inputAndQuantizationShapes = { - { ngraph::Shape({ 1ul, 4ul, 16ul, 16ul }), ngraph::Shape({ 1ul }) }, - { ngraph::Shape({ 1ul, 4ul, 16ul, 16ul }), ngraph::Shape({ 1ul, 4ul, 1ul, 1ul }) }, +const std::vector > inputAndQuantizationShapes = { + { { 1ul, 4ul, 16ul, 16ul }, { 1ul } }, + { { 1ul, 4ul, 16ul, 16ul }, { 1ul, 4ul, 1ul, 1ul } }, }; const std::vector> axes = { diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/prelu_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/prelu_transformation.cpp index bb35f882e628c8..43878ff0fc5afa 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/prelu_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/prelu_transformation.cpp @@ -26,7 +26,7 @@ std::vector testValues = { INSTANTIATE_TEST_SUITE_P(smoke_LPT, PReluTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), - ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(testValues)), PReluTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/pull_reshape_through_dequantization_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/pull_reshape_through_dequantization_transformation.cpp index 0d8ca9c22840b9..6c064b4e70e019 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/pull_reshape_through_dequantization_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/pull_reshape_through_dequantization_transformation.cpp @@ -61,7 +61,7 @@ const std::vector params = { } }; -const std::vector inputShapes = { +const std::vector inputShapes = { { 1, 16, 9, 9 }, { 4, 16, 9, 9 } }; diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_max_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_max_transformation.cpp index a24ef762ea5db9..ec5a659c72b6f8 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_max_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_max_transformation.cpp @@ -107,7 +107,7 @@ const std::vector params = INSTANTIATE_TEST_SUITE_P(smoke_LPT, ReduceMaxTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 10, 10 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 10, 10 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(params)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_mean_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_mean_transformation.cpp index 7c6d1b60c6ba7c..d77121a8e5c093 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_mean_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_mean_transformation.cpp @@ -107,7 +107,7 @@ const std::vector params = INSTANTIATE_TEST_SUITE_P(smoke_LPT, ReduceMeanTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 10, 10 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 10, 10 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(params)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_min_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_min_transformation.cpp index af56b057a33084..0e92bfdc7a8210 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_min_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_min_transformation.cpp @@ -107,7 +107,7 @@ const std::vector params = INSTANTIATE_TEST_SUITE_P(smoke_LPT, ReduceMinTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 10, 10 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 10, 10 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(params)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_sum_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_sum_transformation.cpp index cf767b71e4d860..a7ca938ddbede7 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_sum_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reduce_sum_transformation.cpp @@ -93,7 +93,7 @@ const std::vector params = INSTANTIATE_TEST_SUITE_P(smoke_LPT, ReduceSumTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 10, 10 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 10, 10 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(params)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/relu_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/relu_transformation.cpp index 460d050f6aaa79..e618aa4719da5b 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/relu_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/relu_transformation.cpp @@ -27,7 +27,7 @@ std::vector testValues = { INSTANTIATE_TEST_SUITE_P(smoke_LPT, ReluTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), - ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(testValues)), ReluTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp index 599b3de32e6d2c..c8de61e3fd46e1 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp @@ -24,28 +24,28 @@ const std::vector tras const std::vector params = { // 3D -> 4D { - ngraph::Shape{ 1, 3, 32 }, + { 1, 3, 32 }, { 1, 3, 4, 8 }, { 256ul, ngraph::Shape{ 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, true }, // 4D -> 3D { - ngraph::Shape{ 1, 3, 16, 16 }, + { 1, 3, 16, 16 }, { 1, 3, 256 }, { 256ul, ngraph::Shape{ 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, true }, // 4D -> 3D { - ngraph::Shape{ 1, 3, 16, 16 }, + { 1, 3, 16, 16 }, { 0, 3, -1 }, { 256ul, ngraph::Shape{ 1, 3, 1, 1 }, { 0.f }, { 255.f }, { 0.f, 0.f, 0.f }, { 255.f, 25.5f, 2.55f } }, true }, // 4D -> 2D { - ngraph::Shape{ 1, 3, 4, 8 }, + { 1, 3, 4, 8 }, { 1, -1 }, { 256ul, ngraph::Shape{ 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, true diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/shuffle_channels_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/shuffle_channels_transformation.cpp index 2a214de6d3a2f1..c086cdb57672aa 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/shuffle_channels_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/shuffle_channels_transformation.cpp @@ -15,7 +15,7 @@ const std::vector netPrecisions = { // ngraph::element::f16 }; -const std::vector inputShapes = { +const std::vector inputShapes = { { 1, 3, 16, 16 }, { 4, 3, 16, 16 } }; diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/split_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/split_transformation.cpp index 56f3c7e2f256f9..6170a5c77af6f7 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/split_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/split_transformation.cpp @@ -87,7 +87,7 @@ const std::vector params = { INSTANTIATE_TEST_SUITE_P(smoke_LPT, SplitTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(params)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/strided_slice_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/strided_slice_transformation.cpp index a66106064a1a44..f184a6e7658611 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/strided_slice_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/strided_slice_transformation.cpp @@ -92,7 +92,7 @@ const std::vector params INSTANTIATE_TEST_SUITE_P(smoke_LPT, StridedSliceTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 24, 24 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 24, 24 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(params)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/subtract_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/subtract_transformation.cpp index 3a5d5d6a32f607..e2a82110508ea2 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/subtract_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/subtract_transformation.cpp @@ -25,7 +25,7 @@ const std::vector trasformationParamValues = { INSTANTIATE_TEST_SUITE_P(smoke_LPT, SubtractTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(trasformationParamValues)), SubtractTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/transpose_after_matmul_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/transpose_after_matmul_transformation.cpp index 98eb3cdde77033..4057c6bdd58ebf 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/transpose_after_matmul_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/transpose_after_matmul_transformation.cpp @@ -29,7 +29,7 @@ const std::vector transposeChannelDimValues = { true, false }; INSTANTIATE_TEST_SUITE_P(smoke_LPT, TransposeAfterMatMulTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(perTensorValues), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/transpose_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/transpose_transformation.cpp index 390daa853c254c..fb62c214a785e4 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/transpose_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/transpose_transformation.cpp @@ -18,7 +18,7 @@ const std::vector precisions = { const std::vector testValues = { // U8: per-tensor quantization { - ngraph::Shape({ 1, 1000, 1, 1}), + { 1, 1000, 1, 1}, { 0, 2, 3, 1}, LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), ngraph::element::f32, @@ -26,7 +26,7 @@ const std::vector testValues = { }, // U8: per-channel quantization { - ngraph::Shape({ 1, 3, 1, 1}), + { 1, 3, 1, 1}, { 0, 2, 3, 1}, LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), ngraph::element::f32, diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/variadic_split_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/variadic_split_transformation.cpp index 247dce334444f3..55924de077afd4 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/variadic_split_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/variadic_split_transformation.cpp @@ -93,7 +93,7 @@ const std::vector param INSTANTIATE_TEST_SUITE_P(smoke_LPT, VariadicSplitTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(params)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp index 11a2c41a68e52c..a1a62dcd2dc39f 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp @@ -38,6 +38,7 @@ const std::map>> activationTypes {Negative, {}}, {Acos, {}}, {Asin, {}}, + {Asinh, {}}, {Atan, {}}, {Cos, {}}, {Cosh, {}}, @@ -65,9 +66,12 @@ const std::map>> activationTypes // List of operations that should be tested also with integer precision const std::map>> intActivationTypes = { + {Asinh, {}}, + {Atan, {}}, {Negative, {}}, {Ceiling, {}}, {Cos, {}}, + {Sinh, {}}, {Sqrt, {}}, {Tanh, {}}, }; diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/batch_to_space.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/batch_to_space.cpp index cd81911f707bc9..0ebf53d7bedf84 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/batch_to_space.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/batch_to_space.cpp @@ -16,6 +16,39 @@ const std::vector net_precisions = { InferenceEngine::Precision::I32 }; +const std::vector> data_shapes_2D = { + {12, 4}, + {48, 3} +}; + +const std::vector> block_shapes_2D = { + {1, 2}, + {1, 6} +}; + +const std::vector> crops_2D = { + {0, 0}, + {0, 1} +}; + +const auto batch_to_space_2d_tests = ::testing::Combine( + ::testing::ValuesIn(block_shapes_2D), + ::testing::ValuesIn(crops_2D), + ::testing::ValuesIn(crops_2D), + ::testing::ValuesIn(data_shapes_2D), + ::testing::ValuesIn(net_precisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(CommonTestUtils::DEVICE_CPU)); + +INSTANTIATE_TEST_CASE_P( + smoke_BatchToSpace_2D, + BatchToSpaceLayerTest, + batch_to_space_2d_tests, + BatchToSpaceLayerTest::getTestCaseName); + const std::vector> data_shapes_4D = { {4, 1, 2, 2}, {4, 3, 2, 2}, @@ -39,7 +72,7 @@ const std::vector> crops_end_4D = { {0, 0, 0, 2} }; -const auto space_to_batch_4d_spatial_dims_tests = ::testing::Combine( +const auto batch_to_space_4d_spatial_dims_tests = ::testing::Combine( ::testing::Values(block_shapes_4D[0]), ::testing::ValuesIn(crops_begin_4D), ::testing::ValuesIn(crops_end_4D), @@ -51,7 +84,7 @@ const auto space_to_batch_4d_spatial_dims_tests = ::testing::Combine( ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(CommonTestUtils::DEVICE_CPU)); -const auto space_to_batch_4d_channel_dim_tests = ::testing::Combine( +const auto batch_to_space_4d_channel_dim_tests = ::testing::Combine( ::testing::Values(block_shapes_4D[1]), ::testing::Values(crops_begin_4D[0]), ::testing::Values(crops_end_4D[0]), @@ -66,13 +99,13 @@ const auto space_to_batch_4d_channel_dim_tests = ::testing::Combine( INSTANTIATE_TEST_CASE_P( smoke_BatchToSpace_4D_spatial_dims, BatchToSpaceLayerTest, - space_to_batch_4d_spatial_dims_tests, + batch_to_space_4d_spatial_dims_tests, BatchToSpaceLayerTest::getTestCaseName); INSTANTIATE_TEST_CASE_P( smoke_BatchToSpace_4D_channel_dim, BatchToSpaceLayerTest, - space_to_batch_4d_channel_dim_tests, + batch_to_space_4d_channel_dim_tests, BatchToSpaceLayerTest::getTestCaseName); const std::vector> data_shapes_5D = { @@ -96,7 +129,7 @@ const std::vector> crops_end_5D = { {0, 0, 0, 0, 1} }; -const auto space_to_batch_5d_spatial_dims_tests = ::testing::Combine( +const auto batch_to_space_5d_spatial_dims_tests = ::testing::Combine( ::testing::Values(block_shapes_5D[0]), ::testing::ValuesIn(crops_begin_5D), ::testing::ValuesIn(crops_end_5D), @@ -108,7 +141,7 @@ const auto space_to_batch_5d_spatial_dims_tests = ::testing::Combine( ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(CommonTestUtils::DEVICE_CPU)); -const auto space_to_batch_5d_channel_dim_tests = ::testing::Combine( +const auto batch_to_space_5d_channel_dim_tests = ::testing::Combine( ::testing::Values(block_shapes_5D[1]), ::testing::Values(crops_begin_5D[0]), ::testing::Values(crops_end_5D[0]), @@ -123,13 +156,13 @@ const auto space_to_batch_5d_channel_dim_tests = ::testing::Combine( INSTANTIATE_TEST_CASE_P( smoke_BatchToSpace_5D_spatial_dims, BatchToSpaceLayerTest, - space_to_batch_5d_spatial_dims_tests, + batch_to_space_5d_spatial_dims_tests, BatchToSpaceLayerTest::getTestCaseName); INSTANTIATE_TEST_CASE_P( smoke_BatchToSpace_5D_channel_dim, BatchToSpaceLayerTest, - space_to_batch_5d_channel_dim_tests, + batch_to_space_5d_channel_dim_tests, BatchToSpaceLayerTest::getTestCaseName); -} // namespace \ No newline at end of file +} // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convert.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convert.cpp index 70ed6c6512fc41..e7ac96b6540990 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convert.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convert.cpp @@ -14,13 +14,23 @@ namespace { const std::vector> inShape = {{1, 2, 3, 4}}; const std::vector precisions = { - Precision::U8, + // Ticket: 59594 + // Precision::I4, Precision::I8, - Precision::U16, Precision::I16, Precision::I32, - Precision::U64, Precision::I64, + // Ticket: 59594 + // Precision::BIN, + // Precision::BOOL, + // Precision::U4, + Precision::U8, + Precision::U16, + // Ticket: 59594 + // Precision::U32, + Precision::U64, + Precision::BF16, + Precision::FP16, Precision::FP32 }; @@ -34,4 +44,4 @@ INSTANTIATE_TEST_SUITE_P(smoke_ConvertLayerTest, ConvertLayerTest, ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConvertLayerTest::getTestCaseName); -} // namespace \ No newline at end of file +} // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/deformable_convolution.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/deformable_convolution.cpp index 7bf74fb3a82cd3..f83225145daa4c 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/deformable_convolution.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/deformable_convolution.cpp @@ -89,4 +89,30 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(std::vector({1, 4, 224, 224})), ::testing::Values(CommonTestUtils::DEVICE_CPU)), DeformableConvolutionLayerTest::getTestCaseName); + +/* ============= Single Test Case ============= */ +const std::vector> single_deform_vals = {{1, 54, 28, 28}}; +const std::vector> single_kernel = {{1, 3, 3, 3}}; +const std::vector single_deform_groups = {3}; + +const auto deformableConv2DParams_SingleTestCase = ::testing::Combine( + ::testing::ValuesIn(single_deform_vals), + ::testing::ValuesIn(single_kernel), ::testing::ValuesIn(strides), + ::testing::ValuesIn(padBegins), ::testing::ValuesIn(padEnds), + ::testing::ValuesIn(dilations), ::testing::ValuesIn(groups), + ::testing::ValuesIn(single_deform_groups), ::testing::ValuesIn(numOutChannels), + ::testing::Values(ngraph::op::PadType::EXPLICIT)); + +INSTANTIATE_TEST_SUITE_P( + smoke_DeformableConvolution2D_SingleTestCase, DeformableConvolutionLayerTest, + ::testing::Combine( + deformableConv2DParams_SingleTestCase, ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(std::vector({1, 3, 30, 30})), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), + DeformableConvolutionLayerTest::getTestCaseName); + } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/prior_box.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/prior_box.cpp new file mode 100644 index 00000000000000..d4c56aa00782db --- /dev/null +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/prior_box.cpp @@ -0,0 +1,81 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "single_layer_tests/prior_box.hpp" +#include "common_test_utils/test_constants.hpp" + +using namespace LayerTestDefinitions; + +const std::vector netPrecisions = { + InferenceEngine::Precision::I32, + InferenceEngine::Precision::U16}; +const std::vector> min_sizes = { + {256.0f}}; + +const std::vector> max_sizes = { + {315.0f}}; + +const std::vector> aspect_ratios = { + {2.0f}}; + +const std::vector> densities = { + {1.0f}}; + +const std::vector> fixed_ratios = { + {}}; + +const std::vector> fixed_sizes = { + {}}; + +const std::vector clips = { + false, true}; + +const std::vector flips = { + false, true}; + +const std::vector steps = { + 1.0f, +}; + +const std::vector offsets = { + 0.0f, +}; + +const std::vector> variances = { + {}}; + +const std::vector scale_all_sizes = { + false, true}; + +const std::vector inputShape = {300, 300}; +const std::vector imageShape = {32, 32}; + +const auto layerSpecificParams = ::testing::Combine( + ::testing::ValuesIn(min_sizes), + ::testing::ValuesIn(max_sizes), + ::testing::ValuesIn(aspect_ratios), + ::testing::ValuesIn(densities), + ::testing::ValuesIn(fixed_ratios), + ::testing::ValuesIn(fixed_sizes), + ::testing::ValuesIn(clips), + ::testing::ValuesIn(flips), + ::testing::ValuesIn(steps), + ::testing::ValuesIn(offsets), + ::testing::ValuesIn(variances), + ::testing::ValuesIn(scale_all_sizes)); + +INSTANTIATE_TEST_SUITE_P(smoke_PriorBox_Basic, PriorBoxLayerTest, + ::testing::Combine( + layerSpecificParams, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(inputShape), + ::testing::Values(imageShape), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), + PriorBoxLayerTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/activation.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/activation.cpp index f2e5a76e33c483..c7342e95517800 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/activation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/activation.cpp @@ -156,4 +156,4 @@ const auto basicCases5D = ::testing::Combine( INSTANTIATE_TEST_SUITE_P(smoke_Activation5D_Eltwise_CPU_BF16, ActivationLayerCPUTest, basicCases5D, ActivationLayerCPUTest::getTestCaseName); } // namespace -} // namespace CPULayerTestsDefinitions \ No newline at end of file +} // namespace CPULayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/gna/pass_tests/padded2valid_conv.cpp b/inference-engine/tests/functional/plugin/gna/pass_tests/convert_padded2valid_conv.cpp similarity index 98% rename from inference-engine/tests/functional/plugin/gna/pass_tests/padded2valid_conv.cpp rename to inference-engine/tests/functional/plugin/gna/pass_tests/convert_padded2valid_conv.cpp index 010bbd7a5c0b4b..0823567e578762 100644 --- a/inference-engine/tests/functional/plugin/gna/pass_tests/padded2valid_conv.cpp +++ b/inference-engine/tests/functional/plugin/gna/pass_tests/convert_padded2valid_conv.cpp @@ -247,10 +247,10 @@ const std::vector> configs2D = { }; const std::vector padTypes = { + op::PadType::VALID, op::PadType::EXPLICIT, op::PadType::SAME_LOWER, - op::PadType::SAME_UPPER, - op::PadType::VALID + op::PadType::SAME_UPPER }; const std::vector models = { @@ -277,14 +277,14 @@ const std::vector> maxpool1DPools = { {1, 2} }; const std::vector> maxpool1DStrides = { {1, 1} }; const std::vector> input2DNHWC = { {1, 16, 16, 32} }; -const std::vector> kernels2D = { {2, 2}, {4, 1}, {1, 3}}; +const std::vector> kernels2D = { {2, 2}, {4, 1}, {1, 3} }; const std::vector> strides2D = { {1, 1}, {1, 2}, {2, 1}, {2, 2} }; const std::vector> padBegins2D = { {1, 2} }; const std::vector> padEnds2D = { {3, 1} }; const std::vector> dilations2D = { {1, 1} }; -const std::vector numOutChannels2D = { 32 }; -const std::vector> biases2D = { {1, 32, 1, 1} }; -const std::vector> transpBiases2D = { {1, 1, 1, 32} }; +const std::vector numOutChannels2D = { 8 }; +const std::vector> biases2D = { {1, 8, 1, 1} }; +const std::vector> transpBiases2D = { {1, 1, 1, 8} }; const std::vector> maxpool2DPools = { {2, 2} }; const std::vector> maxpool2DStrides = { {2, 1} }; diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/skip_tests_config.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/skip_tests_config.cpp index a59ad83eaed76e..589ec41c83dd8d 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/skip_tests_config.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/skip_tests_config.cpp @@ -9,28 +9,12 @@ std::vector disabledTestPatterns() { return { - ".*TensorNamesTest\\.CheckAddOutput.*", // TODO: FIX BUG 31661 // TODO: support InferRequest in GNAPlugin ".*InferRequestTests\\.canRun3AsyncRequestsConsistentlyFromThreadsWithoutWait.*", - // TODO: FIX BUG 23740 - ".*InferRequestTests\\.CanCreateTwoExeNetworks.*", - // TODO: FIX BUG 26702 - ".*InferRequestTests\\.FailedAsyncInferWithNegativeTimeForWait.*", // TODO: FIX BUG 23741 ".*InferRequestTests\\.canRun3SyncRequestsConsistentlyFromThreads.*", - // TODO: FIX BUG 23742 - ".*InferRequestTests\\.canWaitWithotStartAsync.*", - // TODO: FIX BUG 23743 - ".*InferRequestTests\\.returnDeviceBusyOnSetBlobAfterAsyncInfer.*", - ".*InferRequestTests\\.returnDeviceBusyOnGetBlobAfterAsyncInfer.*", - ".*InferRequestTests\\.returnDeviceBusyOnGetPerformanceCountAfterAsyncInfer.*", - ".*InferRequestTests\\.returnDeviceBusyOnStartInferAfterAsyncInfer.*", - ".*InferRequestTests\\.returnDeviceBusyOnGetUserDataAfterAsyncInfer.*", - ".*InferRequestTests\\.returnDeviceBusyOnSetUserDataAfterAsyncInfer.*", - // TODO: FIX BUG 31661 - ".*InferRequestTests\\.canStartSeveralAsyncInsideCompletionCallbackNoSafeDtorWithoutWait.*", - // TODO: FIX BUG 31661 + // TODO: FIX BUG 59041 ".*Behavior.*CallbackThrowException.*", // TODO: FIX BUG 32210 R"(.*ActivationLayerTest.CompareWithRefs/(Sigmoid|Tanh|Exp|Log).*)", diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/add_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/add_transformation.cpp index 7b51e051339c3c..905103d681e0d1 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/add_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/add_transformation.cpp @@ -71,7 +71,7 @@ const std::vector params = { INSTANTIATE_TEST_SUITE_P(smoke_LPT, AddTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(params)), AddTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/clamp_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/clamp_transformation.cpp index 408cbb550714c0..59ba772fcca514 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/clamp_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/clamp_transformation.cpp @@ -79,7 +79,7 @@ const std::vector params = { INSTANTIATE_TEST_SUITE_P(smoke_LPT, ClampTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(params)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_transformation.cpp index f22eb9f63a142f..f7dab096215745 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_transformation.cpp @@ -42,7 +42,7 @@ const std::vector testValues = { INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConcatTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), - ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(testValues)), ConcatTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_child_and_output.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_child_and_output.cpp index f53eb289438546..841b2871b39138 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_child_and_output.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_child_and_output.cpp @@ -45,7 +45,7 @@ const std::vector testValues = { INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConcatWithChildAndOutputTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 6, 10, 10 })), + ::testing::Values(ngraph::PartialShape({ 1, 6, 10, 10 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(testValues), ::testing::ValuesIn(trasformationParamValues)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_different_precision_on_children.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_different_precision_on_children.cpp index d7605440afe6f5..71913315cfb567 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_different_precision_on_children.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_different_precision_on_children.cpp @@ -48,7 +48,7 @@ const std::vector multiChannel = { true/*, false*/ }; INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConcatWithDifferentChildrenTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 10, 10 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 10, 10 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(testValues), ::testing::ValuesIn(trasformationParamValues), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_intermediate_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_intermediate_transformation.cpp index 00f5467b33c714..13b0791ba90b3f 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_intermediate_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_intermediate_transformation.cpp @@ -29,7 +29,7 @@ const std::vector multiChannelValues = { /*true,*/ false }; INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConcatWithIntermediateTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(transparentIntermediateValues), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_neighbors_graph_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_neighbors_graph_transformation.cpp index 2dc3a2b4fdecd7..90790ca04b9d98 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_neighbors_graph_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_neighbors_graph_transformation.cpp @@ -26,7 +26,7 @@ const std::vector tras INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConcatWithNeighborsGraphTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), - ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues)), ConcatWithNeighborsGraphTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_split_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_split_transformation.cpp index 2c969a1775fd4d..418cf879fb8f06 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_split_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_split_transformation.cpp @@ -48,7 +48,7 @@ const std::vector testValues = { INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConcatWithSplitTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 6, 10, 10 })), + ::testing::Values(ngraph::PartialShape({ 1, 6, 10, 10 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(testValues), ::testing::ValuesIn(trasformationParamValues)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp index e656b6f3ff54e6..32adecae944e4a 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp @@ -102,7 +102,7 @@ const std::vector> inputShapes = { +const std::vector> inputShapes = { {{ 1, 8, 16, 16 }, false}, {{ 1, 32, 16, 16 }, true} }; diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_qdq_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_qdq_transformation.cpp index bb1bd0cb8dcb5e..b629703ae6dc56 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_qdq_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_qdq_transformation.cpp @@ -233,7 +233,7 @@ const std::vector para }, }; -const std::vector shapes = { +const std::vector shapes = { { 1, 3, 4, 4 }, { 4, 3, 4, 4 } }; diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/depth_to_space_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/depth_to_space_transformation.cpp index 85e076155cc443..3cc179973b3cdb 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/depth_to_space_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/depth_to_space_transformation.cpp @@ -22,7 +22,7 @@ const std::vector modes = { DepthToSpace::DepthToSpaceMode::DEPTH_FIRST }; -const std::vector inputShapesBS2 = { +const std::vector inputShapesBS2 = { {1, 4, 3, 3}, {2, 16, 5, 4} }; @@ -36,7 +36,7 @@ const auto DepthToSpaceBS2 = ::testing::Combine( INSTANTIATE_TEST_SUITE_P(LPT_BS2, DepthToSpaceTransformation, DepthToSpaceBS2, DepthToSpaceTransformation::getTestCaseName); -const std::vector inputShapesBS3 = { +const std::vector inputShapesBS3 = { {1, 9, 3, 3}, {2, 27, 5, 4} }; diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_avg_pool_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_avg_pool_transformation.cpp index ea2587340fff7b..0341ccf83574f4 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_avg_pool_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_avg_pool_transformation.cpp @@ -30,7 +30,7 @@ const std::vector fakeQuantizes = INSTANTIATE_TEST_SUITE_P(smoke_LPT, FakeQuantizeAndAvgPoolTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), - ::testing::Values(ngraph::Shape({ 1, 32, 72, 48 })), + ::testing::Values(ngraph::PartialShape({ 1, 32, 72, 48 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(fakeQuantizes)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_max_pool_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_max_pool_transformation.cpp index ba1bc5bb20a674..8a2e17bb04b004 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_max_pool_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_max_pool_transformation.cpp @@ -30,7 +30,7 @@ const std::vector fakeQuantizes = INSTANTIATE_TEST_SUITE_P(smoke_LPT, FakeQuantizeAndMaxPoolTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), - ::testing::Values(ngraph::Shape({ 1, 32, 72, 48 })), + ::testing::Values(ngraph::PartialShape({ 1, 32, 72, 48 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(fakeQuantizes)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp index fa47c845378a6d..77571dc66f07b2 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp @@ -31,7 +31,7 @@ const std::vector testValues = INSTANTIATE_TEST_SUITE_P(smoke_LPT, FakeQuantizeAndTwoOutputBranchesWithConvolutionTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 32, 72, 48 })), + ::testing::Values(ngraph::PartialShape({ 1, 32, 72, 48 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(testValues)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_precision_selection_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_precision_selection_transformation.cpp index 2b67ce0720cd28..86354110d54a51 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_precision_selection_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_precision_selection_transformation.cpp @@ -60,7 +60,7 @@ const std::vector testVa INSTANTIATE_TEST_SUITE_P(DISABLED_LPT, FakeQuantizePrecisionSelectionTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 32, 72, 48 })), + ::testing::Values(ngraph::PartialShape({ 1, 32, 72, 48 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(testValues)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_transformation.cpp index fe2ae3c55d6d7c..7cb9d409e9e3f5 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_transformation.cpp @@ -62,7 +62,7 @@ const std::vector fakeQuantizeOnDataValues = { INSTANTIATE_TEST_SUITE_P(smoke_LPT, FakeQuantizeTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 32, 72, 48 })), + ::testing::Values(ngraph::PartialShape({ 1, 32, 72, 48 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(fakeQuantizeOnDataValues)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp index 6e780a94ed2e09..f7b5f76aa327e1 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp @@ -104,7 +104,7 @@ const std::vector fakeQuanti INSTANTIATE_TEST_SUITE_P(smoke_LPT, FakeQuantizeWithNotOptimalTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(fakeQuantizeOnDataValues)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fully_connected_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fully_connected_transformation.cpp index 45bf73121d2bfa..b486eca6282de5 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fully_connected_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fully_connected_transformation.cpp @@ -18,20 +18,20 @@ const std::vector netPrecisions = { const std::vector shapes = { { - ngraph::Shape{ 1, 16 }, - ngraph::Shape{ 16, 8 }, + { 1, 16 }, + { 16, 8 }, false, false }, { - ngraph::Shape{ 1, 16 }, - ngraph::Shape{ 8, 16 }, + { 1, 16 }, + { 8, 16 }, false, true }, { - ngraph::Shape{ 16, 1 }, - ngraph::Shape{ 16, 8 }, + { 16, 1 }, + { 16, 8 }, true, false }, diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_convert_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_convert_transformation.cpp index 537f95363e17df..9a1fdd7526b0a5 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_convert_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_convert_transformation.cpp @@ -13,8 +13,8 @@ const std::vector precisions = { // element::f16 // TODO: temporarily commented due to failing in GPU Plugin on constant folding stage }; -const std::vector< ngraph::Shape > inputAndQuantizationShapes = { - Shape{ 1, 4, 16, 16 }, +const std::vectorinputAndQuantizationShapes = { + { 1, 4, 16, 16 }, }; const std::vector deqOperations = { diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp index f78feda5ce6443..36c09e796a41ce 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp @@ -37,7 +37,7 @@ const std::vector fakeQuantizeOnD INSTANTIATE_TEST_SUITE_P(smoke_LPT, FuseFakeQuantizeAndScaleShiftTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 9, 9 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 9, 9 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(fakeQuantizeOnDataValues)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_transformation.cpp index 07b0f0a8ad8cd5..fa3c80cdca6541 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_transformation.cpp @@ -13,7 +13,7 @@ namespace { const std::vector testValues = { // 1) Multiply { - ngraph::Shape{1, 3, 16, 16}, + {1, 3, 16, 16}, LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), { ngraph::element::f32, @@ -26,7 +26,7 @@ const std::vector testValues = { }, // 1) Multiply with different input and output shape { - ngraph::Shape{128, 3}, + {128, 3}, LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), { ngraph::element::f32, @@ -39,7 +39,7 @@ const std::vector testValues = { }, // 1) Multiply by zero { - ngraph::Shape{1, 3, 16, 16}, + {1, 3, 16, 16}, LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), { ngraph::element::f32, @@ -52,7 +52,7 @@ const std::vector testValues = { }, // 1) Subtract + Multiply { - ngraph::Shape{1, 3, 16, 16}, + {1, 3, 16, 16}, LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), { ngraph::element::f32, @@ -65,7 +65,7 @@ const std::vector testValues = { }, // 1) Convert + Subtract + Multiply { - ngraph::Shape{1, 3, 16, 16}, + {1, 3, 16, 16}, LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), { ngraph::element::f32, @@ -78,7 +78,7 @@ const std::vector testValues = { }, // 1) Convert + Subtract + Multiply 2) Add { - ngraph::Shape{1, 3, 16, 16}, + {1, 3, 16, 16}, LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), { ngraph::element::f32, @@ -91,7 +91,7 @@ const std::vector testValues = { }, // issue #40611 for FP32 { - ngraph::Shape{1, 3, 16, 16}, + {1, 3, 16, 16}, LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), { { }, diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.cpp index 58fee1528c2ad1..6e328d0d9cc298 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.cpp @@ -13,7 +13,7 @@ using namespace ngraph; namespace { const std::vector testValues = { { - Shape{1, 3, 16, 16}, + {1, 3, 16, 16}, LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), { { 256ul, {}, { 0.f }, { 2.55f }, { 0.f }, { 2.55f } }, @@ -21,7 +21,7 @@ namespace { } }, { - Shape{1, 3, 16, 16}, + {1, 3, 16, 16}, LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), { { 256ul, {}, { -1.28f }, { 1.27f }, { 10.f }, { 2.55f } }, diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.cpp index 0b25acfc569d04..5762ca291de3c8 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.cpp @@ -13,7 +13,7 @@ using namespace ngraph; namespace { const std::vector testValues = { { - Shape{1, 3, 16, 16}, + {1, 3, 16, 16}, LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), { { 256ul, {}, { 0.f }, { 2.55f }, { 10.f }, { 255.f } }, @@ -21,7 +21,7 @@ namespace { } }, { - Shape{1, 3, 16, 16}, + {1, 3, 16, 16}, LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), { { 256ul, {}, { -1.28f }, { 1.27f }, { 0.f }, { 255.f } }, diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/gemm_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/gemm_transformation.cpp index cd2b40ceb26e41..5708e2e64760b4 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/gemm_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/gemm_transformation.cpp @@ -16,7 +16,7 @@ const std::vector netPrecisions = { ngraph::element::f16 }; -const std::vector dimensions = { +const std::vector dimensions = { {1, 3, 16, 16} }; diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/group_convolution_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/group_convolution_transformation.cpp index 18325c824f4f49..9a404a11b89832 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/group_convolution_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/group_convolution_transformation.cpp @@ -23,7 +23,7 @@ const std::vector tras const std::vector params = { // group convolution, tensor quantization { - ngraph::Shape{ 1, 6, 24, 24 }, + { 1, 6, 24, 24 }, ngraph::Shape{ 1, 24, 18, 18 }, 3ul, -1, @@ -34,7 +34,7 @@ const std::vector pa }, // group convolution, tensor quantization { - ngraph::Shape{ 1, 6, 24, 24 }, + { 1, 6, 24, 24 }, ngraph::Shape{ 1, 24, 18, 18 }, 3ul, 0, @@ -45,7 +45,7 @@ const std::vector pa }, // group convolution, tensor quantization { - ngraph::Shape{ 1, 6, 24, 24 }, + { 1, 6, 24, 24 }, ngraph::Shape{ 1, 24, 18, 18 }, 3ul, 1, @@ -56,7 +56,7 @@ const std::vector pa }, // group convolution, per-channel quantization { - ngraph::Shape{ 1, 6, 24, 24 }, + { 1, 6, 24, 24 }, ngraph::Shape{ 1, 24, 18, 18 }, 3ul, -1, @@ -72,7 +72,7 @@ const std::vector pa }, // depthwise convolution, tensor quantization { - ngraph::Shape{ 1, 6, 24, 24 }, + { 1, 6, 24, 24 }, ngraph::Shape{ 1, 6, 18, 18 }, 6ul, -1, @@ -81,7 +81,7 @@ const std::vector pa }, // depthwise convolution, per-channel quantization { - ngraph::Shape{ 1, 6, 24, 24 }, + { 1, 6, 24, 24 }, ngraph::Shape{ 1, 6, 18, 18 }, 6ul, -1, diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/groupconvolution_qdq_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/groupconvolution_qdq_transformation.cpp index b95d0e7f8c6521..4f5977a99a5884 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/groupconvolution_qdq_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/groupconvolution_qdq_transformation.cpp @@ -488,7 +488,7 @@ const std::vector }, }; -const std::vector shapes = { +const std::vector shapes = { { 1, 4, 7, 7 } }; diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/interpolate_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/interpolate_transformation.cpp index 33135bb451a019..82a785cc02dc54 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/interpolate_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/interpolate_transformation.cpp @@ -13,7 +13,7 @@ const std::vector precisions = { ngraph::element::f16 }; -const std::vector> shapes = { +const std::vector> shapes = { {{1, 4, 16, 16}, {32, 32}}, {{1, 2, 48, 80}, {50, 60}}, }; diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp index 6d0df41c7f48ab..868fd742059097 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp @@ -33,7 +33,7 @@ std::vector testValues = { INSTANTIATE_TEST_SUITE_P(smoke_LPT, MatMulTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), - ::testing::Values(ngraph::Shape({ 1, 384, 1024 })), + ::testing::Values(ngraph::PartialShape({ 1, 384, 1024 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(testValues)), MatMulTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp index 8759d2903bc228..1fb29134b4cd94 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp @@ -22,9 +22,9 @@ const std::vector> inputShapes = { - std::pair({ 1, 16 }, { 10, 16 }), - std::pair({ 1, 16 }, { 16, 10 }) +const std::vector> inputShapes = { + {{ 1, 16 }, { 10, 16 }}, + {{ 1, 16 }, { 16, 10 }} }; INSTANTIATE_TEST_SUITE_P(smoke_LPT, MatMulWithOptimizedConstantFakeQuantizeTransformation, diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_to_group_convolution_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_to_group_convolution_transformation.cpp index 4f60cc1a3bb765..cee4583f67a78b 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_to_group_convolution_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_to_group_convolution_transformation.cpp @@ -13,8 +13,8 @@ const std::vector precisions = { element::f16 }; -const std::vector< ngraph::Shape > inputShapes = { - Shape{ 1ul, 4ul, 16ul, 16ul }, Shape{ 1ul, 4ul, 16ul, 16ul, 16ul } +const std::vectorinputShapes = { + { 1ul, 4ul, 16ul, 16ul }, { 1ul, 4ul, 16ul, 16ul, 16ul } }; const std::vector fqOnData = { diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_transformation.cpp index 6c294cb6d9c1d2..815f096e85ca80 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_transformation.cpp @@ -70,7 +70,7 @@ const std::vector params = { INSTANTIATE_TEST_SUITE_P(smoke_LPT, MultiplyTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(params)), MultiplyTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_with_one_parent_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_with_one_parent_transformation.cpp index 083b4e8357b7ff..99a9436995c5b4 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_with_one_parent_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_with_one_parent_transformation.cpp @@ -24,7 +24,7 @@ const std::vector values = { INSTANTIATE_TEST_SUITE_P(smoke_LPT, MultiplyWithOneParentTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(values)), MultiplyWithOneParentTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mvn_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mvn_transformation.cpp index da5fbff9e91836..8b23929625a3ba 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mvn_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mvn_transformation.cpp @@ -13,8 +13,8 @@ namespace { element::f16 }; - const std::vector inputAndQuantizationShapes = { - Shape{ 1ul, 4ul, 16ul, 16ul }, + const std::vector inputAndQuantizationShapes = { + { 1ul, 4ul, 16ul, 16ul }, }; const std::vector reductionAxes = { { 2, 3 }, { 1, 2, 3 } }; diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/normalize_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/normalize_transformation.cpp index fe30318107a6b6..9ceb37d6b5ba34 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/normalize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/normalize_transformation.cpp @@ -16,9 +16,9 @@ const std::vector precisions = { ngraph::element::f16 }; -const std::vector > inputAndQuantizationShapes = { - { ngraph::Shape({ 1ul, 4ul, 16ul, 16ul }), ngraph::Shape({ 1ul }) }, - { ngraph::Shape({ 1ul, 4ul, 16ul, 16ul }), ngraph::Shape({ 1ul, 4ul, 1ul, 1ul }) }, +const std::vector > inputAndQuantizationShapes = { + { { 1ul, 4ul, 16ul, 16ul }, { 1ul } }, + { { 1ul, 4ul, 16ul, 16ul }, { 1ul, 4ul, 1ul, 1ul } }, }; const std::vector> axes = { diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/prelu_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/prelu_transformation.cpp index aea8e1be969c10..ceb5294a4ffb5d 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/prelu_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/prelu_transformation.cpp @@ -28,7 +28,7 @@ std::vector testValues = { INSTANTIATE_TEST_SUITE_P(DISABLED_LPT, PReluTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), - ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(testValues)), PReluTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/pull_reshape_through_dequantization_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/pull_reshape_through_dequantization_transformation.cpp index 04c82dfaff6cca..9ad74ec60e05f1 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/pull_reshape_through_dequantization_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/pull_reshape_through_dequantization_transformation.cpp @@ -61,7 +61,7 @@ const std::vector params = { } }; -const std::vector inputShapes = { +const std::vector inputShapes = { { 1, 16, 9, 9 }, { 4, 16, 9, 9 } }; diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_max_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_max_transformation.cpp index f53880f5df795a..d3f24e78f99f19 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_max_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_max_transformation.cpp @@ -91,7 +91,7 @@ const std::vector params = INSTANTIATE_TEST_SUITE_P(smoke_LPT, ReduceMaxTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 10, 10 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 10, 10 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(params)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_mean_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_mean_transformation.cpp index 5b343f98747ee1..3b5ead6568f692 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_mean_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_mean_transformation.cpp @@ -91,7 +91,7 @@ const std::vector params = INSTANTIATE_TEST_SUITE_P(smoke_LPT, ReduceMeanTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 10, 10 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 10, 10 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(params)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_min_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_min_transformation.cpp index 89aeb83f875b27..1b1252c6dbfcd8 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_min_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_min_transformation.cpp @@ -91,7 +91,7 @@ const std::vector params = INSTANTIATE_TEST_SUITE_P(smoke_LPT, ReduceMinTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 10, 10 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 10, 10 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(params)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_sum_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_sum_transformation.cpp index 46cd094fcc13fc..d2cd0bff4c5523 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_sum_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reduce_sum_transformation.cpp @@ -81,7 +81,7 @@ const std::vector params = INSTANTIATE_TEST_SUITE_P(smoke_LPT, ReduceSumTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 10, 10 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 10, 10 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(params)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/relu_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/relu_transformation.cpp index a1d65bbf658c07..3621e570e234f3 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/relu_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/relu_transformation.cpp @@ -27,7 +27,7 @@ std::vector testValues = { INSTANTIATE_TEST_SUITE_P(smoke_LPT, ReluTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), - ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(testValues)), ReluTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp index a8d40ca957f76f..5dc8a2124122d1 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp @@ -24,28 +24,28 @@ const std::vector tras const std::vector params = { // 3D -> 4D { - ngraph::Shape{ 1, 3, 32 }, + { 1, 3, 32 }, { 1, 3, 4, 8 }, { 256ul, ngraph::Shape{ 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, true }, // 4D -> 3D { - ngraph::Shape{ 1, 3, 16, 16 }, + { 1, 3, 16, 16 }, { 1, 3, 256 }, { 256ul, ngraph::Shape{ 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, true }, // 4D -> 3D { - ngraph::Shape{ 1, 3, 16, 16 }, + { 1, 3, 16, 16 }, { 0, 3, -1 }, { 256ul, ngraph::Shape{ 1, 3, 1, 1 }, { 0.f }, { 255.f }, { 0.f, 0.f, 0.f }, { 255.f, 25.5f, 2.55f } }, true }, // 4D -> 2D { - ngraph::Shape{ 1, 3, 4, 8 }, + { 1, 3, 4, 8 }, { 1, -1 }, { 256ul, ngraph::Shape{ 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, true diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/shuffle_channels_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/shuffle_channels_transformation.cpp index 19a0cfbd01503a..2cbeedd9de11aa 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/shuffle_channels_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/shuffle_channels_transformation.cpp @@ -15,7 +15,7 @@ const std::vector netPrecisions = { ngraph::element::f16 }; -const std::vector inputShapes = { +const std::vector inputShapes = { { 1, 3, 16, 16 } }; diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/split_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/split_transformation.cpp index 18535a437dafee..5e0e56c0306458 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/split_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/split_transformation.cpp @@ -87,7 +87,7 @@ const std::vector params = { INSTANTIATE_TEST_SUITE_P(smoke_LPT, SplitTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(params)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/strided_slice_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/strided_slice_transformation.cpp index 477fb83a1587c3..5ca38dd35f5d54 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/strided_slice_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/strided_slice_transformation.cpp @@ -89,7 +89,7 @@ const std::vector params INSTANTIATE_TEST_SUITE_P(smoke_LPT, StridedSliceTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 24, 24 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 24, 24 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(params)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/subtract_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/subtract_transformation.cpp index f58f01d8fc5724..004dba7eb22211 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/subtract_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/subtract_transformation.cpp @@ -23,7 +23,7 @@ const std::vector trasformationParamValues = { INSTANTIATE_TEST_SUITE_P(smoke_LPT, SubtractTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues)), SubtractTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/transpose_after_matmul_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/transpose_after_matmul_transformation.cpp index 7377d54b6cd9e0..4b7147c0f7e2c1 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/transpose_after_matmul_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/transpose_after_matmul_transformation.cpp @@ -27,7 +27,7 @@ const std::vector transposeChannelDimValues = { true, false }; INSTANTIATE_TEST_SUITE_P(smoke_LPT, TransposeAfterMatMulTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(perTensorValues), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/transpose_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/transpose_transformation.cpp index b1913f592d1ff0..90a78c92b43f35 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/transpose_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/transpose_transformation.cpp @@ -18,7 +18,7 @@ const std::vector precisions = { const std::vector testValues = { // U8: per-tensor quantization { - ngraph::Shape({ 1, 1000, 1, 1}), + { 1, 1000, 1, 1}, { 0, 2, 3, 1}, LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), ngraph::element::f32, @@ -26,7 +26,7 @@ const std::vector testValues = { }, // U8: per-channel quantization { - ngraph::Shape({ 1, 3, 1, 1}), + { 1, 3, 1, 1}, { 0, 2, 3, 1}, LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), ngraph::element::f32, diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/variadic_split_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/variadic_split_transformation.cpp index 95f4e4487aa4d9..3cdded43eb6062 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/variadic_split_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/variadic_split_transformation.cpp @@ -93,7 +93,7 @@ const std::vector param INSTANTIATE_TEST_SUITE_P(smoke_LPT, VariadicSplitTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::PartialShape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(params)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/activation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/activation.cpp index c62641c0b4cab7..6bbf98451fe69d 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/activation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/activation.cpp @@ -35,6 +35,7 @@ const std::map>> activationTypes {Negative, {}}, {Acos, {}}, {Asin, {}}, + {Asinh, {}}, {Atan, {}}, {Cos, {}}, {Cosh, {}}, diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/gather.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/gather.cpp index 6af03cf397d85c..7cb4e1427e69d7 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/gather.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/gather.cpp @@ -154,6 +154,34 @@ INSTANTIATE_TEST_SUITE_P( Gather7LayerTest::getTestCaseName ); +INSTANTIATE_TEST_SUITE_P( + smoke_Gather7Axes4i4b1, + Gather8LayerTest, + GatherAxes4i4b1, + Gather8LayerTest::getTestCaseName +); + +INSTANTIATE_TEST_SUITE_P( + smoke_Gather7Axes4i4b2, + Gather8LayerTest, + GatherAxes4i4b1, + Gather8LayerTest::getTestCaseName +); + +INSTANTIATE_TEST_SUITE_P( + smoke_Gather7Axes4i8b1, + Gather8LayerTest, + GatherAxes4i8b1, + Gather8LayerTest::getTestCaseName +); + +INSTANTIATE_TEST_SUITE_P( + smoke_Gather7Axes4i8b2, + Gather8LayerTest, + GatherAxes4i8b2, + Gather8LayerTest::getTestCaseName +); + const std::vector> indices = { std::vector{0, 3, 2, 1}, }; diff --git a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_broadcast.cpp b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_broadcast.cpp index 78de9260c2db61..c58f283c6f72f4 100644 --- a/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_broadcast.cpp +++ b/inference-engine/tests/functional/plugin/myriad/ngraph/transformations/dynamic_to_static_shape_broadcast.cpp @@ -74,7 +74,6 @@ class DynamicToStaticShapeBroadcastExplicitTests const auto tensorWithTargetShapeParam = std::make_shared(tensorType, targetShape); const auto shapeOfNode = std::make_shared(tensorWithTargetShapeParam, shapeType); - shapeOfNode->set_is_foldable(false); ngraph::ParameterVector params{tensorParam, tensorWithTargetShapeParam}; @@ -197,7 +196,6 @@ class DynamicToStaticShapeBroadcastBidirectionalTests : public CommonTestUtils:: const auto tensorWithTargetShapeParam = std::make_shared(shapeType, targetShape); const auto shapeOfNode = std::make_shared(tensorWithTargetShapeParam, shapeType); - shapeOfNode->set_is_foldable(false); ngraph::ParameterVector params{tensorParam, tensorWithTargetShapeParam}; diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/skip_tests_config.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/skip_tests_config.cpp index bdb17b095056dc..d67ae3e62704c6 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/skip_tests_config.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/skip_tests_config.cpp @@ -23,8 +23,6 @@ std::vector disabledTestPatterns() { R"(.*IEClassGetAvailableDevices.*)", // TODO: Issue: 40473 R"(.*TopKLayerTest.*mode=min.*sort=index.*)", - // TODO: Issue: 40961 - R"(.*(ConstantResultSubgraphTest).*)", // TODO: Issue: 42828 R"(.*DSR_NonMaxSuppression.*NBoxes=(5|20|200).*)", // TODO: Issue: 42721 diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/subgraph_tests/constant_result.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/subgraph_tests/constant_result.cpp index 919fcdef3d05a1..2b47c8eb466f8d 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/subgraph_tests/constant_result.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/subgraph_tests/constant_result.cpp @@ -23,15 +23,7 @@ const std::vector shapes = { }; const std::vector precisions = { - Precision::U8, - Precision::I8, - Precision::U16, - Precision::I16, - Precision::I32, - Precision::U64, - Precision::I64, - Precision::FP32, - Precision::BOOL + Precision::FP32 }; INSTANTIATE_TEST_SUITE_P(smoke_Check, ConstantResultSubgraphTest, diff --git a/inference-engine/tests/functional/plugin/shared/include/behavior/core_integration.hpp b/inference-engine/tests/functional/plugin/shared/include/behavior/core_integration.hpp index adcd0e525b43bf..1064edaa570865 100644 --- a/inference-engine/tests/functional/plugin/shared/include/behavior/core_integration.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/behavior/core_integration.hpp @@ -62,6 +62,14 @@ namespace BehaviorTestsDefinitions { } +inline Core createCoreWithTemplate() { + Core ie; + std::string pluginName = "templatePlugin"; + pluginName += IE_BUILD_POSTFIX; + ie.RegisterPlugin(pluginName, "TEMPLATE"); + return ie; +} + class IEClassBasicTestP : public ::testing::Test, public WithParamInterface > { protected: std::string deviceName; @@ -211,20 +219,20 @@ TEST(IEClassBasicTest, smoke_createDefault) { TEST_P(IEClassBasicTestP, registerExistingPluginThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_THROW(ie.RegisterPlugin(pluginName, deviceName), Exception); } TEST_P(IEClassBasicTestP, registerNewPluginNoThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_NO_THROW(ie.RegisterPlugin(pluginName, "NEW_DEVICE_NAME")); ASSERT_NO_THROW(ie.GetMetric("NEW_DEVICE_NAME", METRIC_KEY(SUPPORTED_CONFIG_KEYS))); } TEST(IEClassBasicTest, smoke_registerExistingPluginFileThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_THROW(ie.RegisterPlugins("nonExistPlugins.xml"), Exception); } @@ -277,7 +285,7 @@ TEST_P(IEClassBasicTestP, smoke_registerPluginsXMLUnicodePath) { GTEST_COUT << "Test " << testIndex << std::endl; - Core ie; + Core ie = createCoreWithTemplate(); GTEST_COUT << "Core created " << testIndex << std::endl; ASSERT_NO_THROW(ie.RegisterPlugins(::FileUtils::wStringtoMBCSstringChar(pluginsXmlW))); CommonTestUtils::removeFile(pluginsXmlW); @@ -310,19 +318,19 @@ TEST_P(IEClassBasicTestP, smoke_registerPluginsXMLUnicodePath) { TEST_P(IEClassBasicTestP, getVersionsByExactDeviceNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_NO_THROW(ie.GetVersions(deviceName + ".0")); } TEST_P(IEClassBasicTestP, getVersionsByDeviceClassNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_NO_THROW(ie.GetVersions(deviceName)); } TEST_P(IEClassBasicTestP, getVersionsNonEmpty) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_EQ(2, ie.GetVersions(CommonTestUtils::DEVICE_HETERO + std::string(":") + deviceName).size()); } @@ -332,7 +340,7 @@ TEST_P(IEClassBasicTestP, getVersionsNonEmpty) { TEST_P(IEClassBasicTestP, unregisterExistingPluginNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); // device instance is not created yet ASSERT_THROW(ie.UnregisterPlugin(deviceName), Exception); @@ -344,7 +352,7 @@ TEST_P(IEClassBasicTestP, unregisterExistingPluginNoThrow) { TEST_P(IEClassBasicTestP, accessToUnregisteredPluginThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_THROW(ie.UnregisterPlugin(deviceName), Exception); ASSERT_NO_THROW(ie.GetVersions(deviceName)); ASSERT_NO_THROW(ie.UnregisterPlugin(deviceName)); @@ -355,7 +363,7 @@ TEST_P(IEClassBasicTestP, accessToUnregisteredPluginThrows) { TEST(IEClassBasicTest, smoke_unregisterNonExistingPluginThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_THROW(ie.UnregisterPlugin("unkown_device"), Exception); } @@ -365,45 +373,45 @@ TEST(IEClassBasicTest, smoke_unregisterNonExistingPluginThrows) { TEST_P(IEClassBasicTestP, SetConfigAllThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_NO_THROW(ie.SetConfig({{"unsupported_key", "4"}})); ASSERT_ANY_THROW(ie.GetVersions(deviceName)); } TEST_P(IEClassBasicTestP, SetConfigForUnRegisteredDeviceThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_THROW(ie.SetConfig({{"unsupported_key", "4"}}, "unregistered_device"), Exception); } TEST_P(IEClassBasicTestP, SetConfigNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_NO_THROW(ie.SetConfig({{KEY_PERF_COUNT, YES}}, deviceName)); } TEST_P(IEClassBasicTestP, SetConfigAllNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_NO_THROW(ie.SetConfig({{KEY_PERF_COUNT, YES}})); ASSERT_NO_THROW(ie.GetVersions(deviceName)); } TEST(IEClassBasicTest, smoke_SetConfigHeteroThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_NO_THROW(ie.SetConfig({{KEY_PERF_COUNT, YES}}, CommonTestUtils::DEVICE_HETERO)); } TEST_P(IEClassBasicTestP, SetConfigHeteroTargetFallbackThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_NO_THROW(ie.SetConfig({{"TARGET_FALLBACK", deviceName}}, CommonTestUtils::DEVICE_HETERO)); } TEST(IEClassBasicTest, smoke_SetConfigHeteroNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); bool value = false; ASSERT_NO_THROW(ie.SetConfig({{HETERO_CONFIG_KEY(DUMP_GRAPH_DOT), YES}}, CommonTestUtils::DEVICE_HETERO)); @@ -421,7 +429,7 @@ TEST(IEClassBasicTest, smoke_SetConfigHeteroNoThrow) { TEST_P(IEClassBasicTestP, ImportNetworkThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); if (deviceName == CommonTestUtils::DEVICE_CPU || deviceName == CommonTestUtils::DEVICE_GPU) { @@ -440,20 +448,20 @@ TEST_P(IEClassBasicTestP, ImportNetworkThrows) { TEST(IEClassBasicTest, smoke_ImportNetworkHeteroThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_THROW(ie.ImportNetwork("model", CommonTestUtils::DEVICE_HETERO), NetworkNotRead); } TEST(IEClassBasicTest, smoke_ImportNetworkMultiThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - InferenceEngine::Core ie; + InferenceEngine::Core ie = createCoreWithTemplate(); ASSERT_THROW(ie.ImportNetwork("model", CommonTestUtils::DEVICE_MULTI), NetworkNotRead); } TEST_P(IEClassBasicTestP, ImportNetworkWithNullContextThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); RemoteContext::Ptr context = nullptr; std::istringstream stream("None"); ASSERT_THROW(ie.ImportNetwork(stream, context, {}), Exception); @@ -465,19 +473,19 @@ TEST_P(IEClassBasicTestP, ImportNetworkWithNullContextThrows) { TEST_P(IEClassNetworkTestP, LoadNetworkActualNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_NO_THROW(ie.LoadNetwork(actualNetwork, deviceName)); } TEST_P(IEClassNetworkTestP, LoadNetworkActualHeteroDeviceNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_NO_THROW(ie.LoadNetwork(actualNetwork, CommonTestUtils::DEVICE_HETERO + std::string(":") + deviceName)); } TEST_P(IEClassNetworkTestP, LoadNetworkActualHeteroDevice2NoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_NO_THROW(ie.LoadNetwork(actualNetwork, CommonTestUtils::DEVICE_HETERO, {{"TARGET_FALLBACK", deviceName}})); } @@ -487,7 +495,7 @@ TEST_P(IEClassNetworkTestP, LoadNetworkActualHeteroDevice2NoThrow) { TEST_P(IEClassImportExportTestP, smoke_ImportNetworkThrowsIfNoDeviceName) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); std::stringstream strm; ExecutableNetwork executableNetwork; ASSERT_NO_THROW(executableNetwork = ie.LoadNetwork(actualNetwork, deviceName)); @@ -500,7 +508,7 @@ TEST_P(IEClassImportExportTestP, smoke_ImportNetworkThrowsIfNoDeviceName) { TEST_P(IEClassImportExportTestP, smoke_ImportNetworkNoThrowWithDeviceName) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); std::stringstream strm; ExecutableNetwork executableNetwork; ASSERT_NO_THROW(executableNetwork = ie.LoadNetwork(actualNetwork, deviceName)); @@ -511,7 +519,7 @@ TEST_P(IEClassImportExportTestP, smoke_ImportNetworkNoThrowWithDeviceName) { TEST_P(IEClassImportExportTestP, smoke_ExportUsingFileNameImportFromStreamNoThrowWithDeviceName) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ExecutableNetwork executableNetwork; std::string fileName{"ExportedNetwork"}; { @@ -534,13 +542,13 @@ TEST_P(IEClassImportExportTestP, smoke_ExportUsingFileNameImportFromStreamNoThro TEST_P(IEClassNetworkTestP, QueryNetworkActualThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_NO_THROW(ie.QueryNetwork(actualNetwork, CommonTestUtils::DEVICE_HETERO + std::string(":") + deviceName)); } TEST_P(IEClassNetworkTestP, QueryNetworkActualNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); try { ie.QueryNetwork(actualNetwork, deviceName); @@ -552,7 +560,7 @@ TEST_P(IEClassNetworkTestP, QueryNetworkActualNoThrow) { TEST_P(IEClassNetworkTestP, QueryNetworkWithKSO) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); try { auto rres = ie.QueryNetwork(ksoNetwork, deviceName); @@ -571,7 +579,7 @@ TEST_P(IEClassNetworkTestP, QueryNetworkWithKSO) { TEST_P(IEClassNetworkTestP, SetAffinityWithConstantBranches) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); try { std::shared_ptr func; @@ -623,7 +631,7 @@ TEST_P(IEClassNetworkTestP, SetAffinityWithConstantBranches) { TEST_P(IEClassNetworkTestP, SetAffinityWithKSO) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); try { auto rres = ie.QueryNetwork(ksoNetwork, deviceName); @@ -647,7 +655,7 @@ TEST_P(IEClassNetworkTestP, SetAffinityWithKSO) { TEST_P(IEClassNetworkTestP, QueryNetworkHeteroActualNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); QueryNetworkResult res; ASSERT_NO_THROW(res = ie.QueryNetwork(actualNetwork, CommonTestUtils::DEVICE_HETERO, {{"TARGET_FALLBACK", deviceName}})); ASSERT_LT(0, res.supportedLayersMap.size()); @@ -655,13 +663,13 @@ TEST_P(IEClassNetworkTestP, QueryNetworkHeteroActualNoThrow) { TEST_P(IEClassNetworkTestP, QueryNetworkMultiThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_THROW(ie.QueryNetwork(actualNetwork, CommonTestUtils::DEVICE_MULTI), Exception); } TEST(IEClassBasicTest, smoke_GetMetricSupportedMetricsHeteroNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; std::string deviceName = CommonTestUtils::DEVICE_HETERO; @@ -678,7 +686,7 @@ TEST(IEClassBasicTest, smoke_GetMetricSupportedMetricsHeteroNoThrow) { TEST(IEClassBasicTest, smoke_GetMetricSupportedConfigKeysHeteroNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; std::string deviceName = CommonTestUtils::DEVICE_HETERO; @@ -695,7 +703,7 @@ TEST(IEClassBasicTest, smoke_GetMetricSupportedConfigKeysHeteroNoThrow) { TEST(IEClassBasicTest, smoke_GetMetricSupportedConfigKeysHeteroThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); // TODO: check std::string targetDevice = CommonTestUtils::DEVICE_HETERO + std::string(":") + CommonTestUtils::DEVICE_CPU; ASSERT_THROW(ie.GetMetric(targetDevice, METRIC_KEY(SUPPORTED_CONFIG_KEYS)), Exception); @@ -703,7 +711,7 @@ TEST(IEClassBasicTest, smoke_GetMetricSupportedConfigKeysHeteroThrows) { TEST_P(IEClassGetMetricTest_SUPPORTED_METRICS, GetMetricAndPrintNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(SUPPORTED_METRICS))); @@ -719,7 +727,7 @@ TEST_P(IEClassGetMetricTest_SUPPORTED_METRICS, GetMetricAndPrintNoThrow) { TEST_P(IEClassGetMetricTest_SUPPORTED_CONFIG_KEYS, GetMetricAndPrintNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(SUPPORTED_CONFIG_KEYS))); @@ -735,7 +743,7 @@ TEST_P(IEClassGetMetricTest_SUPPORTED_CONFIG_KEYS, GetMetricAndPrintNoThrow) { TEST_P(IEClassGetMetricTest_AVAILABLE_DEVICES, GetMetricAndPrintNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(AVAILABLE_DEVICES))); @@ -751,7 +759,7 @@ TEST_P(IEClassGetMetricTest_AVAILABLE_DEVICES, GetMetricAndPrintNoThrow) { TEST_P(IEClassGetMetricTest_FULL_DEVICE_NAME, GetMetricAndPrintNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(FULL_DEVICE_NAME))); @@ -763,7 +771,7 @@ TEST_P(IEClassGetMetricTest_FULL_DEVICE_NAME, GetMetricAndPrintNoThrow) { TEST_P(IEClassGetMetricTest_OPTIMIZATION_CAPABILITIES, GetMetricAndPrintNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(OPTIMIZATION_CAPABILITIES))); @@ -779,7 +787,7 @@ TEST_P(IEClassGetMetricTest_OPTIMIZATION_CAPABILITIES, GetMetricAndPrintNoThrow) TEST_P(IEClassGetMetricTest_DEVICE_GOPS, GetMetricAndPrintNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(DEVICE_GOPS))); @@ -795,7 +803,7 @@ TEST_P(IEClassGetMetricTest_DEVICE_GOPS, GetMetricAndPrintNoThrow) { TEST_P(IEClassGetMetricTest_DEVICE_TYPE, GetMetricAndPrintNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(DEVICE_TYPE))); @@ -808,7 +816,7 @@ TEST_P(IEClassGetMetricTest_DEVICE_TYPE, GetMetricAndPrintNoThrow) { TEST_P(IEClassGetMetricTest_NUMBER_OF_WAITING_INFER_REQUESTS, GetMetricAndPrintNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(NUMBER_OF_WAITING_INFER_REQUESTS))); @@ -821,7 +829,7 @@ TEST_P(IEClassGetMetricTest_NUMBER_OF_WAITING_INFER_REQUESTS, GetMetricAndPrintN TEST_P(IEClassGetMetricTest_NUMBER_OF_EXEC_INFER_REQUESTS, GetMetricAndPrintNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(NUMBER_OF_EXEC_INFER_REQUESTS))); @@ -834,7 +842,7 @@ TEST_P(IEClassGetMetricTest_NUMBER_OF_EXEC_INFER_REQUESTS, GetMetricAndPrintNoTh TEST_P(IEClassGetMetricTest_RANGE_FOR_ASYNC_INFER_REQUESTS, GetMetricAndPrintNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(RANGE_FOR_ASYNC_INFER_REQUESTS))); @@ -857,7 +865,7 @@ TEST_P(IEClassGetMetricTest_RANGE_FOR_ASYNC_INFER_REQUESTS, GetMetricAndPrintNoT TEST_P(IEClassGetMetricTest_RANGE_FOR_STREAMS, GetMetricAndPrintNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(RANGE_FOR_STREAMS))); @@ -877,7 +885,7 @@ TEST_P(IEClassGetMetricTest_RANGE_FOR_STREAMS, GetMetricAndPrintNoThrow) { TEST_P(IEClassGetMetricTest_ThrowUnsupported, GetMetricThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_THROW(p = ie.GetMetric(deviceName, "unsupported_metric"), Exception); @@ -885,7 +893,7 @@ TEST_P(IEClassGetMetricTest_ThrowUnsupported, GetMetricThrow) { TEST_P(IEClassGetConfigTest, GetConfigNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(SUPPORTED_CONFIG_KEYS))); @@ -900,7 +908,7 @@ TEST_P(IEClassGetConfigTest, GetConfigNoThrow) { TEST_P(IEClassGetConfigTest, GetConfigHeteroNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(SUPPORTED_CONFIG_KEYS))); @@ -913,7 +921,7 @@ TEST_P(IEClassGetConfigTest, GetConfigHeteroNoThrow) { TEST_P(IEClassGetConfigTest_ThrowUnsupported, GetConfigHeteroThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_THROW(p = ie.GetConfig(CommonTestUtils::DEVICE_HETERO, "unsupported_config"), Exception); @@ -921,7 +929,7 @@ TEST_P(IEClassGetConfigTest_ThrowUnsupported, GetConfigHeteroThrow) { TEST_P(IEClassGetConfigTest_ThrowUnsupported, GetConfigHeteroWithDeviceThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_THROW(p = ie.GetConfig(CommonTestUtils::DEVICE_HETERO + std::string(":") + deviceName, HETERO_CONFIG_KEY(DUMP_GRAPH_DOT)), @@ -930,7 +938,7 @@ TEST_P(IEClassGetConfigTest_ThrowUnsupported, GetConfigHeteroWithDeviceThrow) { TEST_P(IEClassGetConfigTest_ThrowUnsupported, GetConfigThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_THROW(p = ie.GetConfig(deviceName, "unsupported_config"), Exception); @@ -938,7 +946,7 @@ TEST_P(IEClassGetConfigTest_ThrowUnsupported, GetConfigThrow) { TEST_P(IEClassGetAvailableDevices, GetAvailableDevicesNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); std::vector devices; ASSERT_NO_THROW(devices = ie.GetAvailableDevices()); @@ -962,7 +970,7 @@ TEST_P(IEClassGetAvailableDevices, GetAvailableDevicesNoThrow) { // TEST_P(IEClassExecutableNetworkGetMetricTest_SUPPORTED_CONFIG_KEYS, GetMetricNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ExecutableNetwork exeNetwork = ie.LoadNetwork(simpleNetwork, deviceName); @@ -981,7 +989,7 @@ TEST_P(IEClassExecutableNetworkGetMetricTest_SUPPORTED_CONFIG_KEYS, GetMetricNoT TEST_P(IEClassExecutableNetworkGetMetricTest_SUPPORTED_METRICS, GetMetricNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ExecutableNetwork exeNetwork = ie.LoadNetwork(simpleNetwork, deviceName); @@ -1000,7 +1008,7 @@ TEST_P(IEClassExecutableNetworkGetMetricTest_SUPPORTED_METRICS, GetMetricNoThrow TEST_P(IEClassExecutableNetworkGetMetricTest_NETWORK_NAME, GetMetricNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ExecutableNetwork exeNetwork = ie.LoadNetwork(simpleNetwork, deviceName); @@ -1015,7 +1023,7 @@ TEST_P(IEClassExecutableNetworkGetMetricTest_NETWORK_NAME, GetMetricNoThrow) { TEST_P(IEClassExecutableNetworkGetMetricTest_OPTIMAL_NUMBER_OF_INFER_REQUESTS, GetMetricNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ExecutableNetwork exeNetwork = ie.LoadNetwork(simpleNetwork, deviceName); @@ -1030,7 +1038,7 @@ TEST_P(IEClassExecutableNetworkGetMetricTest_OPTIMAL_NUMBER_OF_INFER_REQUESTS, G TEST_P(IEClassExecutableNetworkGetMetricTest_ThrowsUnsupported, GetMetricThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ExecutableNetwork exeNetwork = ie.LoadNetwork(simpleNetwork, deviceName); @@ -1040,7 +1048,7 @@ TEST_P(IEClassExecutableNetworkGetMetricTest_ThrowsUnsupported, GetMetricThrow) TEST_P(IEClassExecutableNetworkGetConfigTest, GetConfigNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ExecutableNetwork exeNetwork = ie.LoadNetwork(simpleNetwork, deviceName); @@ -1057,7 +1065,7 @@ TEST_P(IEClassExecutableNetworkGetConfigTest, GetConfigNoThrow) { TEST_P(IEClassExecutableNetworkGetConfigTest, GetConfigThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ExecutableNetwork exeNetwork = ie.LoadNetwork(simpleNetwork, deviceName); @@ -1067,7 +1075,7 @@ TEST_P(IEClassExecutableNetworkGetConfigTest, GetConfigThrows) { TEST_P(IEClassExecutableNetworkSetConfigTest, SetConfigThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ExecutableNetwork exeNetwork = ie.LoadNetwork(simpleNetwork, deviceName); @@ -1077,7 +1085,7 @@ TEST_P(IEClassExecutableNetworkSetConfigTest, SetConfigThrows) { TEST_P(IEClassExecutableNetworkSupportedConfigTest, SupportedConfigWorks) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ExecutableNetwork exeNetwork = ie.LoadNetwork(simpleNetwork, deviceName); @@ -1090,7 +1098,7 @@ TEST_P(IEClassExecutableNetworkSupportedConfigTest, SupportedConfigWorks) { TEST_P(IEClassExecutableNetworkUnsupportedConfigTest, UnsupportedConfigThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); ExecutableNetwork exeNetwork = ie.LoadNetwork(simpleNetwork, deviceName); @@ -1099,7 +1107,7 @@ TEST_P(IEClassExecutableNetworkUnsupportedConfigTest, UnsupportedConfigThrows) { TEST_P(IEClassExecutableNetworkGetConfigTest, GetConfigNoEmptyNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(SUPPORTED_CONFIG_KEYS))); @@ -1122,7 +1130,7 @@ TEST_P(IEClassExecutableNetworkGetConfigTest, GetConfigNoEmptyNoThrow) { TEST_P(IEClassHeteroExecutableNetworkGetMetricTest_SUPPORTED_CONFIG_KEYS, GetMetricNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter pHetero, pDevice; ExecutableNetwork heteroExeNetwork = ie.LoadNetwork(actualNetwork, heteroDeviceName); @@ -1156,7 +1164,7 @@ TEST_P(IEClassHeteroExecutableNetworkGetMetricTest_SUPPORTED_CONFIG_KEYS, GetMet TEST_P(IEClassHeteroExecutableNetworkGetMetricTest_SUPPORTED_METRICS, GetMetricNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter pHetero, pDevice; ExecutableNetwork heteroExeNetwork = ie.LoadNetwork(actualNetwork, heteroDeviceName); @@ -1196,7 +1204,7 @@ TEST_P(IEClassHeteroExecutableNetworkGetMetricTest_SUPPORTED_METRICS, GetMetricN TEST_P(IEClassHeteroExecutableNetworkGetMetricTest_NETWORK_NAME, GetMetricNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ExecutableNetwork exeNetwork = ie.LoadNetwork(actualNetwork, heteroDeviceName); @@ -1209,7 +1217,7 @@ TEST_P(IEClassHeteroExecutableNetworkGetMetricTest_NETWORK_NAME, GetMetricNoThro TEST_P(IEClassHeteroExecutableNetworkGetMetricTest_TARGET_FALLBACK, GetMetricNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; setHeteroNetworkAffinity(deviceName); @@ -1237,7 +1245,7 @@ bool supportsDeviceID(Core &ie, const std::string &deviceName) { TEST_P(IEClassQueryNetworkTest, QueryNetworkHETEROWithDeviceIDNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName)) { auto deviceIDs = ie.GetMetric(deviceName, METRIC_KEY(AVAILABLE_DEVICES)).as>(); @@ -1252,7 +1260,7 @@ TEST_P(IEClassQueryNetworkTest, QueryNetworkHETEROWithDeviceIDNoThrow) { TEST_P(IEClassQueryNetworkTest, QueryNetworkWithDeviceID) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName)) { try { @@ -1268,7 +1276,7 @@ TEST_P(IEClassQueryNetworkTest, QueryNetworkWithDeviceID) { TEST_P(IEClassQueryNetworkTest, QueryNetworkWithBigDeviceIDThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName)) { ASSERT_THROW(ie.QueryNetwork(actualNetwork, deviceName + ".110"), Exception); @@ -1279,7 +1287,7 @@ TEST_P(IEClassQueryNetworkTest, QueryNetworkWithBigDeviceIDThrows) { TEST_P(IEClassQueryNetworkTest, QueryNetworkWithInvalidDeviceIDThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName)) { ASSERT_THROW(ie.QueryNetwork(actualNetwork, deviceName + ".l0"), Exception); @@ -1290,7 +1298,7 @@ TEST_P(IEClassQueryNetworkTest, QueryNetworkWithInvalidDeviceIDThrows) { TEST_P(IEClassQueryNetworkTest, QueryNetworkHETEROWithBigDeviceIDThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName)) { ASSERT_THROW(ie.QueryNetwork(actualNetwork, CommonTestUtils::DEVICE_HETERO, @@ -1305,7 +1313,7 @@ TEST_P(IEClassQueryNetworkTest, QueryNetworkHETEROWithBigDeviceIDThrows) { // TEST_P(IEClassLoadNetworkTest, LoadNetworkHETEROWithDeviceIDNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName)) { auto deviceIDs = ie.GetMetric(deviceName, METRIC_KEY(AVAILABLE_DEVICES)).as>(); @@ -1320,7 +1328,7 @@ TEST_P(IEClassLoadNetworkTest, LoadNetworkHETEROWithDeviceIDNoThrow) { TEST_P(IEClassLoadNetworkTest, LoadNetworkWithDeviceIDNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName)) { auto deviceIDs = ie.GetMetric(deviceName, METRIC_KEY(AVAILABLE_DEVICES)).as>(); @@ -1334,7 +1342,7 @@ TEST_P(IEClassLoadNetworkTest, LoadNetworkWithDeviceIDNoThrow) { TEST_P(IEClassLoadNetworkTest, LoadNetworkWithBigDeviceIDThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName)) { ASSERT_THROW(ie.LoadNetwork(actualNetwork, deviceName + ".10"), Exception); @@ -1345,7 +1353,7 @@ TEST_P(IEClassLoadNetworkTest, LoadNetworkWithBigDeviceIDThrows) { TEST_P(IEClassLoadNetworkTest, LoadNetworkWithInvalidDeviceIDThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName)) { ASSERT_THROW(ie.LoadNetwork(actualNetwork, deviceName + ".l0"), Exception); @@ -1356,7 +1364,7 @@ TEST_P(IEClassLoadNetworkTest, LoadNetworkWithInvalidDeviceIDThrows) { TEST_P(IEClassLoadNetworkTest, LoadNetworkHETEROWithBigDeviceIDThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName)) { ASSERT_THROW(ie.LoadNetwork(actualNetwork, "HETERO", @@ -1368,7 +1376,7 @@ TEST_P(IEClassLoadNetworkTest, LoadNetworkHETEROWithBigDeviceIDThrows) { TEST_P(IEClassLoadNetworkTest, LoadNetworkHETEROAndDeviceIDThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName)) { ASSERT_THROW(ie.LoadNetwork(actualNetwork, CommonTestUtils::DEVICE_HETERO, @@ -1385,7 +1393,7 @@ TEST_P(IEClassLoadNetworkTest, LoadNetworkHETEROAndDeviceIDThrows) { TEST_P(IEClassLoadNetworkTest, LoadNetworkHETEROwithMULTINoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName) && supportsAvaliableDevices(ie, deviceName)) { std::string devices; auto availableDevices = ie.GetMetric(deviceName, METRIC_KEY(AVAILABLE_DEVICES)).as>(); @@ -1406,7 +1414,7 @@ TEST_P(IEClassLoadNetworkTest, LoadNetworkHETEROwithMULTINoThrow) { TEST_P(IEClassLoadNetworkTest, LoadNetworkMULTIwithHETERONoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName) && supportsAvaliableDevices(ie, deviceName)) { std::string devices; @@ -1431,7 +1439,7 @@ TEST_P(IEClassLoadNetworkTest, LoadNetworkMULTIwithHETERONoThrow) { TEST_P(IEClassLoadNetworkTest, QueryNetworkHETEROWithMULTINoThrow_V10) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName) && supportsAvaliableDevices(ie, deviceName)) { std::string devices; @@ -1466,7 +1474,7 @@ TEST_P(IEClassLoadNetworkTest, QueryNetworkHETEROWithMULTINoThrow_V10) { TEST_P(IEClassLoadNetworkTest, QueryNetworkMULTIWithHETERONoThrow_V10) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName) && supportsAvaliableDevices(ie, deviceName)) { std::string devices; @@ -1500,7 +1508,7 @@ TEST_P(IEClassLoadNetworkTest, QueryNetworkMULTIWithHETERONoThrow_V10) { TEST_P(IEClassLoadNetworkAfterCoreRecreateTest, LoadAfterRecreateCoresAndPlugins) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); { auto versions = ie.GetVersions(std::string(CommonTestUtils::DEVICE_MULTI) + ":" + deviceName + "," + CommonTestUtils::DEVICE_CPU); ASSERT_EQ(3, versions.size()); @@ -1510,7 +1518,7 @@ TEST_P(IEClassLoadNetworkAfterCoreRecreateTest, LoadAfterRecreateCoresAndPlugins config.insert({"CPU_THREADS_NUM", "3"}); } ASSERT_NO_THROW({ - Core ie; + Core ie = createCoreWithTemplate(); std::string name = actualNetwork.getInputsInfo().begin()->first; actualNetwork.getInputsInfo().at(name)->setPrecision(Precision::U8); auto executableNetwork = ie.LoadNetwork(actualNetwork, deviceName, config); diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/add_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/add_transformation.hpp index 1908d91413d962..37151d0b1bae86 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/add_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/add_transformation.hpp @@ -22,7 +22,7 @@ class AddTestValues{ typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, AddTestValues > AddTransformationParams; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/clamp_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/clamp_transformation.hpp index de7b31c9558d74..e11672d4973190 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/clamp_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/clamp_transformation.hpp @@ -19,7 +19,7 @@ class ClampTransformationParam { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ngraph::pass::low_precision::LayerTransformation::Params, ClampTransformationParam diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_transformation.hpp index 093944bf9565ff..11aeb6701dd9f5 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_transformation.hpp @@ -20,7 +20,7 @@ class ConcatTransformationTestValues { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ConcatTransformationTestValues> ConcatTransformationParams; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_child_and_output.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_child_and_output.hpp index 4c96976db6f43c..2ae292c8002795 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_child_and_output.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_child_and_output.hpp @@ -19,7 +19,7 @@ class ConcatWithChildAndOutputTransformationParam { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, // target device: CPU, GPU ConcatWithChildAndOutputTransformationParam, ngraph::pass::low_precision::LayerTransformation::Params // transformation parameters diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_different_precision_on_children.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_different_precision_on_children.hpp index 50ea25c73d2a02..385ba9216df8c4 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_different_precision_on_children.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_different_precision_on_children.hpp @@ -19,7 +19,7 @@ class ConcatWithDifferentChildrenTransformationParam { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, // target device: CPU, GPU ConcatWithDifferentChildrenTransformationParam, ngraph::pass::low_precision::LayerTransformation::Params, // transformation parameters diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_intermediate_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_intermediate_transformation.hpp index c560455b1c0e9d..a0881a3950a9b6 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_intermediate_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_intermediate_transformation.hpp @@ -13,7 +13,7 @@ namespace LayerTestsDefinitions { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, // target device: CPU, GPU ngraph::pass::low_precision::LayerTransformation::Params, // transformation parameters bool, // transparent intermediate diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_neighbors_graph_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_neighbors_graph_transformation.hpp index f3235572fb337c..c77dd2cb490701 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_neighbors_graph_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_neighbors_graph_transformation.hpp @@ -13,7 +13,7 @@ namespace LayerTestsDefinitions { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ngraph::pass::low_precision::LayerTransformation::Params> ConcatNeighboringGraphTransformationParams; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_split_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_split_transformation.hpp index f1d973410c58b0..2dfd8560650700 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_split_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_split_transformation.hpp @@ -19,7 +19,7 @@ class ConcatWithSplitTransformationParam { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ConcatWithSplitTransformationParam, ngraph::pass::low_precision::LayerTransformation::Params> ConcatWithSplitTransformationParams; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/convolution_backprop_data_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/convolution_backprop_data_transformation.hpp index 8b690e2df2eee3..738854ae315f18 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/convolution_backprop_data_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/convolution_backprop_data_transformation.hpp @@ -43,7 +43,7 @@ class ConvolutionBackpropDataTransformationParam { typedef std::tuple< ngraph::element::Type, // netPrecision - std::pair, // input shape and shape support flag + std::pair, // input shape and shape support flag ngraph::Shape, // outputShape std::string, // targetDevice ngraph::pass::low_precision::LayerTransformation::Params, diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/convolution_qdq_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/convolution_qdq_transformation.hpp index c3e7ea4c9e15f9..371349f7d55cc0 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/convolution_qdq_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/convolution_qdq_transformation.hpp @@ -47,7 +47,7 @@ inline std::ostream& operator<<(std::ostream& out, const ConvolutionQDqTransform typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ngraph::pass::low_precision::LayerTransformation::Params, ConvolutionQDqTransformationParam diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/depth_to_space_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/depth_to_space_transformation.hpp index d634e062e129ed..8b385dca96e52d 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/depth_to_space_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/depth_to_space_transformation.hpp @@ -13,7 +13,7 @@ namespace LayerTestsDefinitions { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ngraph::opset1::DepthToSpace::DepthToSpaceMode, size_t> DepthToSpaceTransformationParams; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_and_avg_pool_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_and_avg_pool_transformation.hpp index d7967203b7c11e..ed182705f2dedd 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_and_avg_pool_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_and_avg_pool_transformation.hpp @@ -14,7 +14,7 @@ namespace LayerTestsDefinitions { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ngraph::pass::low_precision::LayerTransformation::Params, ngraph::builder::subgraph::FakeQuantizeOnData> FakeQuantizeAndAvgPoolTransformationParams; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_and_max_pool_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_and_max_pool_transformation.hpp index 3644960ef1e6a9..29a85a20d26f43 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_and_max_pool_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_and_max_pool_transformation.hpp @@ -14,7 +14,7 @@ namespace LayerTestsDefinitions { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ngraph::pass::low_precision::LayerTransformation::Params, ngraph::builder::subgraph::FakeQuantizeOnData> FakeQuantizeAndMaxPoolTransformationParams; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.hpp index be6860353612c5..03a75530d23167 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.hpp @@ -22,7 +22,7 @@ class FakeQuantizeAndTwoOutputBranchesWithConvolution { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ngraph::pass::low_precision::LayerTransformation::Params, FakeQuantizeAndTwoOutputBranchesWithConvolution diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_precision_selection_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_precision_selection_transformation.hpp index 9b99e2f6f0983c..8f0da855be7a7f 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_precision_selection_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_precision_selection_transformation.hpp @@ -50,7 +50,7 @@ inline std::ostream& operator<<(std::ostream& out, const FakeQuantizePrecisionSe typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ngraph::pass::low_precision::LayerTransformation::Params, FakeQuantizePrecisionSelectionTransformationTestValues> FakeQuantizeTransformationParams; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_transformation.hpp index f2b82386c5e527..c43672edd57bd6 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_transformation.hpp @@ -20,7 +20,7 @@ class FakeQuantizeTransformationParam { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ngraph::pass::low_precision::LayerTransformation::Params, FakeQuantizeTransformationParam> FakeQuantizeTransformationParams; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_with_dq_not_optimal_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_with_dq_not_optimal_transformation.hpp index 7978fc26da6765..10521951e6c5ef 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_with_dq_not_optimal_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_with_dq_not_optimal_transformation.hpp @@ -50,7 +50,7 @@ inline std::ostream& operator<<(std::ostream& out, const FakeQuantizeWithNotOpti // ngraph::builder::subgraph::FakeQuantizeOnData typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ngraph::pass::low_precision::LayerTransformation::Params, FakeQuantizeWithNotOptimalTransformationTestValues> FakeQuantizeTransformationParams; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fully_connected_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fully_connected_transformation.hpp index 4e4d56bc01c27a..8e273f825ded99 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fully_connected_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fully_connected_transformation.hpp @@ -11,8 +11,8 @@ class MatMulShapes { public: - ngraph::Shape inputA; - ngraph::Shape inputB; + ngraph::PartialShape inputA; + ngraph::PartialShape inputB; bool transposeA; bool transposeB; }; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_convert_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_convert_transformation.hpp index cacacd09bd9ad1..9e87a6ecb099d1 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_convert_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_convert_transformation.hpp @@ -17,7 +17,7 @@ namespace LayerTestsDefinitions { typedef std::tuple < element::Type, - Shape, + PartialShape, std::string, ngraph::builder::subgraph::DequantizationOperations, bool> FuseConvertTransformationParams; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.hpp index 4b5ce627f6e55e..0d5036bb8e71a9 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.hpp @@ -13,7 +13,7 @@ namespace LayerTestsDefinitions { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ngraph::pass::low_precision::LayerTransformation::Params, ngraph::builder::subgraph::FakeQuantizeOnData> FuseFakeQuantizeAndScaleShiftTransformationParams; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_fake_quantize_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_fake_quantize_transformation.hpp index 84679690d53c99..0ef83d52947887 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_fake_quantize_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_fake_quantize_transformation.hpp @@ -26,7 +26,7 @@ class FuseFakeQuantizeTransformationTestValues { ngraph::builder::subgraph::FakeQuantizeOnDataWithConstant fakeQuantizeOnData; }; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; ngraph::pass::low_precision::LayerTransformation::Params params; Actual actual; }; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.hpp index 21d5024e8bb06d..d1ce8a01e5bfe7 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.hpp @@ -22,7 +22,7 @@ class FuseMultiplyToFakeQuantizeTransformationTestValues { ngraph::builder::subgraph::DequantizationOperations dequantization; }; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; ngraph::pass::low_precision::LayerTransformation::Params params; Actual actual; }; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.hpp index 3dab656bccad35..6c88512ea9bd65 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.hpp @@ -22,7 +22,7 @@ class FuseSubtractToFakeQuantizeTransformationTestValues { ngraph::builder::subgraph::DequantizationOperations dequantization; }; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; ngraph::pass::low_precision::LayerTransformation::Params params; Actual actual; }; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/gemm_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/gemm_transformation.hpp index 90eb782daac7b9..0e54077bb8335b 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/gemm_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/gemm_transformation.hpp @@ -13,7 +13,7 @@ namespace LayerTestsDefinitions { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ngraph::pass::low_precision::LayerTransformation::Params> GemmTransformationParams; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/group_convolution_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/group_convolution_transformation.hpp index b7d92417182a2a..506763418d86e7 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/group_convolution_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/group_convolution_transformation.hpp @@ -15,7 +15,7 @@ namespace LayerTestsDefinitions { class GroupConvolutionTransformationParam { public: - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; ngraph::Shape outputShape; size_t group; int groupCalculationDimention; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/groupconvolution_qdq_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/groupconvolution_qdq_transformation.hpp index 6caa548bc72cfb..99dffb4714f28d 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/groupconvolution_qdq_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/groupconvolution_qdq_transformation.hpp @@ -51,7 +51,7 @@ inline std::ostream& operator<<(std::ostream& out, const GroupConvolutionQDqTran typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ngraph::pass::low_precision::LayerTransformation::Params, GroupConvolutionQDqTransformationParam diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/interpolate_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/interpolate_transformation.hpp index 6a643ee2650e6d..83311f469296ff 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/interpolate_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/interpolate_transformation.hpp @@ -37,7 +37,7 @@ class interpAttributes { typedef std::tuple< ngraph::element::Type, - std::pair, + std::pair, std::string, interpAttributes> InterpolateTransformationParams; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mat_mul_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mat_mul_transformation.hpp index 65022a7bbaf5ce..37f8d88151bca4 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mat_mul_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mat_mul_transformation.hpp @@ -25,7 +25,7 @@ class MatMulTransformationTestValues { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, MatMulTransformationTestValues> MatMulTransformationParams; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mat_mul_with_constant_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mat_mul_with_constant_transformation.hpp index ed0ef0e99671c2..6c058727d69e92 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mat_mul_with_constant_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mat_mul_with_constant_transformation.hpp @@ -19,7 +19,7 @@ namespace LayerTestsDefinitions { class MatMulWithConstantTransformationTestValues { public: - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; ngraph::builder::subgraph::FakeQuantizeOnDataWithConstant fqOnData; ngraph::builder::subgraph::Constant weights; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.hpp index 71d175006ced86..ddb24903d3f513 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.hpp @@ -20,7 +20,7 @@ class MatMulWithOptimizedConstantFakeQuantizeTransformationTestValues { typedef std::tuple< ngraph::element::Type, - std::pair, + std::pair, std::string, MatMulWithOptimizedConstantFakeQuantizeTransformationTestValues > MatMulWithOptimizedConstantFakeQuantizeTransformationTransformationParams; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/multiply_to_group_convolution_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/multiply_to_group_convolution_transformation.hpp index ee49b11d892116..29827eeb0d9cf3 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/multiply_to_group_convolution_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/multiply_to_group_convolution_transformation.hpp @@ -17,7 +17,7 @@ namespace LayerTestsDefinitions { typedef std::tuple < element::Type, - Shape, + PartialShape, std::string, builder::subgraph::FakeQuantizeOnData> MultiplyToGroupConvolutionTransformationParams; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/multiply_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/multiply_transformation.hpp index 63d4d527f13009..db868f7438e8e5 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/multiply_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/multiply_transformation.hpp @@ -23,7 +23,7 @@ class MultiplyTestValues { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, MultiplyTestValues > MultiplyTransformationParams; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/multiply_with_one_parent_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/multiply_with_one_parent_transformation.hpp index a2dea7f9ec6dbc..4fa9d821e306d5 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/multiply_with_one_parent_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/multiply_with_one_parent_transformation.hpp @@ -19,7 +19,7 @@ class MultiplyWithOneParentTransformationValues { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, MultiplyWithOneParentTransformationValues > MultiplyWithOneParentTransformationParams; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mvn_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mvn_transformation.hpp index 6bb4fdcaf923c5..ac01efe9895124 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mvn_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mvn_transformation.hpp @@ -16,7 +16,7 @@ namespace LayerTestsDefinitions { typedef std::tuple < element::Type, - Shape, + PartialShape, std::string, AxisSet, bool> MVNTransformationParams; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/normalize_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/normalize_transformation.hpp index 8edae2282026f4..fefecb17becb63 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/normalize_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/normalize_transformation.hpp @@ -14,7 +14,7 @@ namespace LayerTestsDefinitions { typedef std::tuple < ngraph::element::Type, - std::pair, + std::pair, std::string, std::vector, bool, diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/prelu_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/prelu_transformation.hpp index a46ffef511ea62..493edfe3182b23 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/prelu_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/prelu_transformation.hpp @@ -19,7 +19,7 @@ class PReluTestValues { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, PReluTestValues> PReluTransformationParams; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/pull_reshape_through_dequantization_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/pull_reshape_through_dequantization_transformation.hpp index 61292175942ec9..198a879ff30dc7 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/pull_reshape_through_dequantization_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/pull_reshape_through_dequantization_transformation.hpp @@ -36,7 +36,7 @@ class PullReshapeThroughDequantizationTestValues { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ngraph::pass::low_precision::LayerTransformation::Params, ngraph::Shape, diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/reduce_max_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/reduce_max_transformation.hpp index 7a14601aebeec6..911b3d13f4f6ae 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/reduce_max_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/reduce_max_transformation.hpp @@ -20,7 +20,7 @@ class ReduceMaxTransformationParam { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ngraph::pass::low_precision::LayerTransformation::Params, ReduceMaxTransformationParam diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/reduce_mean_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/reduce_mean_transformation.hpp index 1e4e79c9551912..5ea346285307c4 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/reduce_mean_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/reduce_mean_transformation.hpp @@ -19,7 +19,7 @@ class ReduceMeanTransformationParam { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ngraph::pass::low_precision::LayerTransformation::Params, ReduceMeanTransformationParam diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/reduce_min_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/reduce_min_transformation.hpp index 74a2d90fc140bf..a52e4df34ebf2d 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/reduce_min_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/reduce_min_transformation.hpp @@ -20,7 +20,7 @@ class ReduceMinTransformationParam { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ngraph::pass::low_precision::LayerTransformation::Params, ReduceMinTransformationParam diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/reduce_sum_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/reduce_sum_transformation.hpp index 4bb6e8ea38d52f..ec7af415c10226 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/reduce_sum_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/reduce_sum_transformation.hpp @@ -20,7 +20,7 @@ class ReduceSumTransformationParam { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ngraph::pass::low_precision::LayerTransformation::Params, ReduceSumTransformationParam diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/relu_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/relu_transformation.hpp index 064aedd1c84c65..5155fd8f32b635 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/relu_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/relu_transformation.hpp @@ -19,7 +19,7 @@ class ReluTestValues { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ReluTestValues> ReluTransformationParams; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/reshape_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/reshape_transformation.hpp index 47d8a1876fdcac..912066a6e359b8 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/reshape_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/reshape_transformation.hpp @@ -14,7 +14,7 @@ namespace LayerTestsDefinitions { class ReshapeTransformationParam { public: - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::vector reshapeConstValues; ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize; bool isTransformed; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/shuffle_channels_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/shuffle_channels_transformation.hpp index 217eb2f7ea9a76..8439211c8395dd 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/shuffle_channels_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/shuffle_channels_transformation.hpp @@ -23,7 +23,7 @@ class ShuffleChannelsTransformationParam { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ngraph::pass::low_precision::LayerTransformation::Params, ShuffleChannelsTransformationParam diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/split_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/split_transformation.hpp index 6598bdfb59be6e..adcae0a25d8034 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/split_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/split_transformation.hpp @@ -17,7 +17,7 @@ class SplitTransformationParam { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ngraph::pass::low_precision::LayerTransformation::Params, SplitTransformationParam diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/squeeze_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/squeeze_transformation.hpp index b8aa50a11ce815..4ddb1178f1e81f 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/squeeze_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/squeeze_transformation.hpp @@ -16,7 +16,7 @@ class SqueezeTransformationParam { public: ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize; std::vector squeezeAxes; - ngraph::Shape shape; + ngraph::PartialShape shape; }; std::string stringifySqueezeArgs(const std::vector& axes); diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/strided_slice_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/strided_slice_transformation.hpp index 321a5bb37161ef..c2e769e1b04467 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/strided_slice_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/strided_slice_transformation.hpp @@ -24,7 +24,7 @@ class StridedSliceTransformationParam { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ngraph::pass::low_precision::LayerTransformation::Params, StridedSliceTransformationParam diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.hpp index 2a1cc62a91e4de..19fa50096be211 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.hpp @@ -14,7 +14,7 @@ namespace LayerTestsDefinitions { class SubtractMultiplyToMultiplyAddTransformationTestValues { public: - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; ngraph::element::Type precision; ngraph::builder::subgraph::FakeQuantizeOnData fqOnData; }; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/subtract_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/subtract_transformation.hpp index 5743a49d88553c..43a58471a946b8 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/subtract_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/subtract_transformation.hpp @@ -13,7 +13,7 @@ namespace LayerTestsDefinitions { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ngraph::pass::low_precision::LayerTransformation::Params > SubtractTransformationParams; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/transpose_after_matmul_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/transpose_after_matmul_transformation.hpp index 6c73e0198ff314..f2258619b7fe50 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/transpose_after_matmul_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/transpose_after_matmul_transformation.hpp @@ -13,7 +13,7 @@ namespace LayerTestsDefinitions { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ngraph::pass::low_precision::LayerTransformation::Params, bool, diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/transpose_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/transpose_transformation.hpp index 8701bdc2b2d1ad..6e26c6d6e7b826 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/transpose_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/transpose_transformation.hpp @@ -14,7 +14,7 @@ namespace LayerTestsDefinitions { class TransposeTransformationTestValues { public: - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::vector transposeConstValues; ngraph::pass::low_precision::LayerTransformation::Params params; ngraph::element::Type precisionBeforeFq; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/unsqueeze_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/unsqueeze_transformation.hpp index 416640b06df45b..3abee33a5b1205 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/unsqueeze_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/unsqueeze_transformation.hpp @@ -16,7 +16,7 @@ class UnsqueezeTransformationParam { public: ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize; std::vector unsqueezeAxes; - ngraph::Shape shape; + ngraph::PartialShape shape; }; typedef std::tuple< diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/variadic_split_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/variadic_split_transformation.hpp index 44205e2c7038dc..5f4665940fdeae 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/variadic_split_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/variadic_split_transformation.hpp @@ -17,7 +17,7 @@ class VariadicSplitTransformationParam { typedef std::tuple< ngraph::element::Type, - ngraph::Shape, + ngraph::PartialShape, std::string, ngraph::pass::low_precision::LayerTransformation::Params, VariadicSplitTransformationParam diff --git a/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/gather.hpp b/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/gather.hpp index 49191b69553ebe..69278816840d31 100644 --- a/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/gather.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/gather.hpp @@ -16,4 +16,8 @@ TEST_P(Gather7LayerTest, CompareWithRefs) { Run(); }; +TEST_P(Gather8LayerTest, CompareWithRefs) { + Run(); +}; + } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/prior_box.hpp b/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/prior_box.hpp new file mode 100644 index 00000000000000..2b1ab4780ab032 --- /dev/null +++ b/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/prior_box.hpp @@ -0,0 +1,15 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/single_layer/prior_box.hpp" + +namespace LayerTestDefinitions { + +TEST_P(PriorBoxLayerTest, CompareWithRefs) { + Run(); +} + +} // namespace LayerTestDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/src/behavior/cpp_holders.cpp b/inference-engine/tests/functional/plugin/shared/src/behavior/cpp_holders.cpp index f253ee322bf990..49d955c25f6d1b 100644 --- a/inference-engine/tests/functional/plugin/shared/src/behavior/cpp_holders.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/behavior/cpp_holders.cpp @@ -8,6 +8,13 @@ #include "behavior/cpp_holders.hpp" namespace BehaviorTestsDefinitions { + inline InferenceEngine::Core createCoreWithTemplate() { + InferenceEngine::Core ie; + std::string pluginName = "templatePlugin"; + pluginName += IE_BUILD_POSTFIX; + ie.RegisterPlugin(pluginName, "TEMPLATE"); + return ie; + } std::string HoldersTest::getTestCaseName(testing::TestParamInfo obj) { std::string targetDevice; std::vector order; @@ -47,7 +54,7 @@ namespace BehaviorTestsDefinitions { void release_order_test(std::vector order, const std::string &deviceName, std::shared_ptr function) { InferenceEngine::CNNNetwork cnnNet(function); - InferenceEngine::Core core; + InferenceEngine::Core core = createCoreWithTemplate(); auto exe_net = core.LoadNetwork(cnnNet, deviceName); auto request = exe_net.CreateInferRequest(); std::vector states = {}; @@ -60,7 +67,7 @@ namespace BehaviorTestsDefinitions { auto release = [&](int i) { switch (i) { case 0: - core = InferenceEngine::Core{}; + core = createCoreWithTemplate(); break; case 1: exe_net = {}; @@ -84,7 +91,7 @@ namespace BehaviorTestsDefinitions { std::vector order, const std::string &deviceName, std::shared_ptr function) { InferenceEngine::CNNNetwork cnnNet(function); - InferenceEngine::Core core; + InferenceEngine::Core core = createCoreWithTemplate(); std::stringstream stream; { auto exe_net = core.LoadNetwork(cnnNet, deviceName); @@ -142,7 +149,7 @@ namespace BehaviorTestsDefinitions { TEST_P(HoldersTestOnImportedNetwork, CreateRequestWithCoreRemoved) { InferenceEngine::CNNNetwork cnnNet(function); - InferenceEngine::Core core; + InferenceEngine::Core core = createCoreWithTemplate(); std::stringstream stream; { auto exe_net = core.LoadNetwork(cnnNet, targetDevice); diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/add_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/add_transformation.cpp index cffa033cc1b528..2448bf7984f557 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/add_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/add_transformation.cpp @@ -18,7 +18,7 @@ namespace LayerTestsDefinitions { std::string AddTransformation::getTestCaseName(testing::TestParamInfo< AddTransformationParams> obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShapes; + ngraph::PartialShape inputShapes; std::string targetDevice; auto params = LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(); AddTestValues param; @@ -50,7 +50,7 @@ std::string AddTransformation::getTestCaseName(testing::TestParamInfo< AddTransf void AddTransformation::SetUp() { ngraph::element::Type precision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; AddTestValues param; std::tie(precision, inputShape, targetDevice, param) = this->GetParam(); @@ -64,7 +64,7 @@ void AddTransformation::SetUp() { void AddTransformation::validate() { ngraph::element::Type precision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; AddTestValues param; std::tie(precision, inputShape, targetDevice, param) = this->GetParam(); diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/clamp_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/clamp_transformation.cpp index 7c0a07aeb0dfc3..d23da32cc56045 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/clamp_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/clamp_transformation.cpp @@ -14,7 +14,7 @@ namespace LayerTestsDefinitions { std::string ClampTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; ClampTransformationParam param;; @@ -30,7 +30,7 @@ std::string ClampTransformation::getTestCaseName(testing::TestParamInfoGetParam(); @@ -47,7 +47,7 @@ void ClampTransformation::SetUp() { void ClampTransformation::validate() { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; ClampTransformationParam param; diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_transformation.cpp index 0b4d3bfb1d9cb3..a2e6f85c7050ac 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_transformation.cpp @@ -18,7 +18,7 @@ namespace LayerTestsDefinitions { std::string ConcatTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type precision; - ngraph::Shape inputShapes; + ngraph::PartialShape inputShapes; std::string targetDevice; ConcatTransformationTestValues testValues; std::tie(precision, inputShapes, targetDevice, testValues) = obj.param; @@ -31,7 +31,7 @@ std::string ConcatTransformation::getTestCaseName(testing::TestParamInfoGetParam(); @@ -63,7 +63,7 @@ void ConcatTransformation::SetUp() { void ConcatTransformation::validate() { ngraph::element::Type precision; - ngraph::Shape inputShapes; + ngraph::PartialShape inputShapes; std::string targetDevice; ConcatTransformationTestValues testValues; std::tie(precision, inputShapes, targetDevice, testValues) = GetParam(); diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_child_and_output.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_child_and_output.cpp index 0d3bf4acfef6bd..debf6671ec0a09 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_child_and_output.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_child_and_output.cpp @@ -21,7 +21,7 @@ namespace LayerTestsDefinitions { std::string ConcatWithChildAndOutputTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShapes; + ngraph::PartialShape inputShapes; std::string targetDevice; ConcatWithChildAndOutputTransformationParam param; ngraph::pass::low_precision::LayerTransformation::Params params; @@ -47,7 +47,7 @@ std::string ConcatWithChildAndOutputTransformation::getTestCaseName(testing::Tes void ConcatWithChildAndOutputTransformation::SetUp() { ngraph::element::Type netPrecision; - ngraph::Shape inputShapes; + ngraph::PartialShape inputShapes; ConcatWithChildAndOutputTransformationParam param; ngraph::pass::low_precision::LayerTransformation::Params params; std::tie(netPrecision, inputShapes, targetDevice, param, params) = this->GetParam(); diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_different_precision_on_children.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_different_precision_on_children.cpp index 7688d4e7a8b2b4..c74d9740871a9e 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_different_precision_on_children.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_different_precision_on_children.cpp @@ -21,7 +21,7 @@ namespace LayerTestsDefinitions { std::string ConcatWithDifferentChildrenTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShapes; + ngraph::PartialShape inputShapes; std::string targetDevice; ConcatWithDifferentChildrenTransformationParam param; ngraph::pass::low_precision::LayerTransformation::Params params; @@ -38,7 +38,7 @@ std::string ConcatWithDifferentChildrenTransformation::getTestCaseName(testing:: InferenceEngine::Blob::Ptr ConcatWithDifferentChildrenTransformation::GenerateInput(const InferenceEngine::InputInfo &info) const { ngraph::element::Type netPrecision; - ngraph::Shape inputShapes; + ngraph::PartialShape inputShapes; std::string targetDevice; ConcatWithDifferentChildrenTransformationParam param; ngraph::pass::low_precision::LayerTransformation::Params params; @@ -51,7 +51,7 @@ InferenceEngine::Blob::Ptr ConcatWithDifferentChildrenTransformation::GenerateIn void ConcatWithDifferentChildrenTransformation::SetUp() { ngraph::element::Type netPrecision; - ngraph::Shape inputShapes; + ngraph::PartialShape inputShapes; ConcatWithDifferentChildrenTransformationParam param; ngraph::pass::low_precision::LayerTransformation::Params params; bool multiChannel; @@ -65,7 +65,7 @@ void ConcatWithDifferentChildrenTransformation::SetUp() { void ConcatWithDifferentChildrenTransformation::validate() { ngraph::element::Type netPrecision; - ngraph::Shape inputShapes; + ngraph::PartialShape inputShapes; std::string targetDevice; ConcatWithDifferentChildrenTransformationParam param; ngraph::pass::low_precision::LayerTransformation::Params params; diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_intermediate_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_intermediate_transformation.cpp index 2bf15a14c32158..12f3bf17565b59 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_intermediate_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_intermediate_transformation.cpp @@ -21,7 +21,7 @@ namespace LayerTestsDefinitions { std::string ConcatWithIntermediateTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShapes; + ngraph::PartialShape inputShapes; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; bool transparentIntermediate; @@ -39,7 +39,7 @@ std::string ConcatWithIntermediateTransformation::getTestCaseName(testing::TestP InferenceEngine::Blob::Ptr ConcatWithIntermediateTransformation::GenerateInput(const InferenceEngine::InputInfo &info) const { ngraph::element::Type netPrecision; - InferenceEngine::SizeVector inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params trasformationParams; bool transparentIntermediate; @@ -60,7 +60,7 @@ InferenceEngine::Blob::Ptr ConcatWithIntermediateTransformation::GenerateInput(c void ConcatWithIntermediateTransformation::SetUp() { ngraph::element::Type ngPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; ngraph::pass::low_precision::LayerTransformation::Params trasformationParams; bool transparentIntermediate; bool multichannel; @@ -78,7 +78,7 @@ void ConcatWithIntermediateTransformation::SetUp() { void ConcatWithIntermediateTransformation::validate() { ngraph::element::Type netPrecision; - InferenceEngine::SizeVector inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; bool transparentIntermediate; diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_neighbors_graph_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_neighbors_graph_transformation.cpp index 912982c2ea6847..2c7c1a100fa136 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_neighbors_graph_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_neighbors_graph_transformation.cpp @@ -18,7 +18,7 @@ namespace LayerTestsDefinitions { std::string ConcatWithNeighborsGraphTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type precision; - ngraph::Shape inputShapes; + ngraph::PartialShape inputShapes; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; std::tie(precision, inputShapes, targetDevice, params) = obj.param; @@ -28,7 +28,7 @@ std::string ConcatWithNeighborsGraphTransformation::getTestCaseName(testing::Tes InferenceEngine::Blob::Ptr ConcatWithNeighborsGraphTransformation::GenerateInput(const InferenceEngine::InputInfo &info) const { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; std::tie(netPrecision, inputShape, targetDevice, params) = this->GetParam(); @@ -43,7 +43,7 @@ InferenceEngine::Blob::Ptr ConcatWithNeighborsGraphTransformation::GenerateInput void ConcatWithNeighborsGraphTransformation::SetUp() { threshold = 2.e-2; ngraph::element::Type ngPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; ngraph::pass::low_precision::LayerTransformation::Params params; std::tie(ngPrecision, inputShape, targetDevice, params) = this->GetParam(); @@ -61,7 +61,7 @@ void ConcatWithNeighborsGraphTransformation::SetUp() { void ConcatWithNeighborsGraphTransformation::validate() { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; std::tie(netPrecision, inputShape, targetDevice, params) = this->GetParam(); diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_split_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_split_transformation.cpp index 3c67dd1b729371..728656b4e2845a 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_split_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_split_transformation.cpp @@ -21,7 +21,7 @@ namespace LayerTestsDefinitions { std::string ConcatWithSplitTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShapes; + ngraph::PartialShape inputShapes; std::string targetDevice; ConcatWithSplitTransformationParam param; ngraph::pass::low_precision::LayerTransformation::Params params; @@ -34,7 +34,7 @@ std::string ConcatWithSplitTransformation::getTestCaseName(testing::TestParamInf InferenceEngine::Blob::Ptr ConcatWithSplitTransformation::GenerateInput(const InferenceEngine::InputInfo &info) const { ngraph::element::Type netPrecision; - ngraph::Shape inputShapes; + ngraph::PartialShape inputShapes; std::string targetDevice; ConcatWithSplitTransformationParam param; ngraph::pass::low_precision::LayerTransformation::Params params; @@ -54,7 +54,7 @@ InferenceEngine::Blob::Ptr ConcatWithSplitTransformation::GenerateInput(const In void ConcatWithSplitTransformation::SetUp() { ngraph::element::Type netPrecision; - ngraph::Shape inputShapes; + ngraph::PartialShape inputShapes; ConcatWithSplitTransformationParam param; ngraph::pass::low_precision::LayerTransformation::Params params; std::tie(netPrecision, inputShapes, targetDevice, param, params) = this->GetParam(); diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_backprop_data_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_backprop_data_transformation.cpp index c8d15a5702e407..913ec3e39a69e2 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_backprop_data_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_backprop_data_transformation.cpp @@ -14,7 +14,7 @@ namespace LayerTestsDefinitions { std::string ConvolutionBackpropDataTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - std::pair inputShape; + std::pair inputShape; ngraph::Shape outputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; @@ -34,7 +34,7 @@ void ConvolutionBackpropDataTransformation::SetUp() { threshold = 0.1f; ngraph::element::Type netPrecision; - std::pair inputShapeAndHandling; + std::pair inputShapeAndHandling; ngraph::Shape outputShape; ngraph::pass::low_precision::LayerTransformation::Params params; ConvolutionBackpropDataTransformationParam param; @@ -43,14 +43,18 @@ void ConvolutionBackpropDataTransformation::SetUp() { std::shared_ptr weights; const auto inputShape = inputShapeAndHandling.first; + ngraph::Shape weightsShape(4, 1ul); + weightsShape[0] = inputShape[1].get_length(); + weightsShape[1] = inputShape[1].get_length() / 2; + if (!param.fakeQuantizeOnWeights.empty()) { weights = ngraph::builder::subgraph::ConvolutionBackpropDataFunction::getWeights( - ngraph::Shape{inputShape[1], inputShape[1] / 2, 1, 1}, + weightsShape, netPrecision, param.fakeQuantizeOnWeights); } else { weights = ngraph::builder::subgraph::ConvolutionBackpropDataFunction::getWeights( - ngraph::Shape{inputShape[1], inputShape[1] / 2, 1, 1}, + weightsShape, netPrecision, param.dequantizationOnWeights); } diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_qdq_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_qdq_transformation.cpp index a55cc05d2846c4..d90427b904b945 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_qdq_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_qdq_transformation.cpp @@ -22,7 +22,7 @@ namespace LayerTestsDefinitions { std::string ConvolutionQDqTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; ConvolutionQDqTransformationParam param; @@ -37,7 +37,7 @@ void ConvolutionQDqTransformation::SetUp() { // threshold = 0.1f; ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; ngraph::pass::low_precision::LayerTransformation::Params params; ConvolutionQDqTransformationParam param; std::tie(netPrecision, inputShape, targetDevice, params, param) = this->GetParam(); diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_transformation.cpp index f6e0a544fde271..221a7cd8a2a674 100755 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_transformation.cpp @@ -22,7 +22,7 @@ namespace LayerTestsDefinitions { std::string ConvolutionTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; ConvolutionTransformationParam param; @@ -39,7 +39,7 @@ void ConvolutionTransformation::SetUp() { threshold = 0.1f; ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; ngraph::pass::low_precision::LayerTransformation::Params params; ConvolutionTransformationParam param; std::tie(netPrecision, inputShape, targetDevice, params, param) = this->GetParam(); @@ -68,7 +68,7 @@ void ConvolutionTransformation::Run() { void ConvolutionTransformation::validate() { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; ConvolutionTransformationParam param; diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_with_incorrect_weights.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_with_incorrect_weights.cpp index 63087b13a43eb4..89d05397da3265 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_with_incorrect_weights.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_with_incorrect_weights.cpp @@ -22,7 +22,7 @@ namespace LayerTestsDefinitions { std::string ConvolutionWIthIncorrectWeightsTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; ConvolutionWIthIncorrectWeightsParam param; @@ -40,7 +40,7 @@ void ConvolutionWIthIncorrectWeightsTransformation::SetUp() { threshold = 0.1f; ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; ngraph::pass::low_precision::LayerTransformation::Params params; ConvolutionWIthIncorrectWeightsParam param; std::tie(netPrecision, inputShape, targetDevice, params, param) = this->GetParam(); @@ -57,7 +57,7 @@ void ConvolutionWIthIncorrectWeightsTransformation::SetUp() { void ConvolutionWIthIncorrectWeightsTransformation::validate() { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; ConvolutionWIthIncorrectWeightsParam param; diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/depth_to_space_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/depth_to_space_transformation.cpp index f3169ba9c6029b..28df2617b6a712 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/depth_to_space_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/depth_to_space_transformation.cpp @@ -39,7 +39,7 @@ std::string DepthToSpaceTransformation::getTestCaseName(testing::TestParamInfoGetParam(); - if (inputShape.size() != 4ul) { - IE_THROW() << "not supported input shape size " << inputShape.size(); + if (inputShape.rank().is_dynamic() || inputShape.rank().get_length() != 4) { + IE_THROW() << "not supported input shape size " << inputShape.rank(); } function = ngraph::builder::subgraph::DepthToSpaceFunction::getOriginal(precision, inputShape, mode, blockSize); @@ -71,7 +71,7 @@ void DepthToSpaceTransformation::SetUp() { void DepthToSpaceTransformation::validate() { ngraph::element::Type precision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; DepthToSpace::DepthToSpaceMode mode; size_t blockSize; diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_and_avg_pool_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_and_avg_pool_transformation.cpp index 368a0265dff8d3..de0e57153009d8 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_and_avg_pool_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_and_avg_pool_transformation.cpp @@ -18,7 +18,7 @@ namespace LayerTestsDefinitions { std::string FakeQuantizeAndAvgPoolTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type precision; - ngraph::Shape inputShapes; + ngraph::PartialShape inputShapes; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize; @@ -30,7 +30,7 @@ std::string FakeQuantizeAndAvgPoolTransformation::getTestCaseName(testing::TestP void FakeQuantizeAndAvgPoolTransformation::SetUp() { threshold = 0.5f; ngraph::element::Type precision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; ngraph::pass::low_precision::LayerTransformation::Params params; ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize; std::tie(precision, inputShape, targetDevice, params, fakeQuantize) = this->GetParam(); @@ -46,7 +46,7 @@ void FakeQuantizeAndAvgPoolTransformation::SetUp() { void FakeQuantizeAndAvgPoolTransformation::validate() { ngraph::element::Type precision; - ngraph::Shape inputShapes; + ngraph::PartialShape inputShapes; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize; diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_and_max_pool_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_and_max_pool_transformation.cpp index eda5c2911266cf..f71a4a6bba91f5 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_and_max_pool_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_and_max_pool_transformation.cpp @@ -18,7 +18,7 @@ namespace LayerTestsDefinitions { std::string FakeQuantizeAndMaxPoolTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type precision; - ngraph::Shape inputShapes; + ngraph::PartialShape inputShapes; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize; @@ -29,7 +29,7 @@ std::string FakeQuantizeAndMaxPoolTransformation::getTestCaseName(testing::TestP void FakeQuantizeAndMaxPoolTransformation::SetUp() { ngraph::element::Type precision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; ngraph::pass::low_precision::LayerTransformation::Params params; ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize; std::tie(precision, inputShape, targetDevice, params, fakeQuantize) = this->GetParam(); @@ -45,7 +45,7 @@ void FakeQuantizeAndMaxPoolTransformation::SetUp() { void FakeQuantizeAndMaxPoolTransformation::validate() { ngraph::element::Type precision; - ngraph::Shape inputShapes; + ngraph::PartialShape inputShapes; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize; diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp index 6c1d90e537d3b3..1ee2255a1ad6ba 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp @@ -22,7 +22,7 @@ namespace LayerTestsDefinitions { std::string FakeQuantizeAndTwoOutputBranchesWithConvolutionTransformation::getTestCaseName( testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; FakeQuantizeAndTwoOutputBranchesWithConvolution testValues; @@ -38,7 +38,7 @@ std::string FakeQuantizeAndTwoOutputBranchesWithConvolutionTransformation::getTe void FakeQuantizeAndTwoOutputBranchesWithConvolutionTransformation::SetUp() { threshold = 0.1f; ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; ngraph::pass::low_precision::LayerTransformation::Params params; FakeQuantizeAndTwoOutputBranchesWithConvolution testValues; std::tie(netPrecision, inputShape, targetDevice, params, testValues) = this->GetParam(); @@ -55,7 +55,7 @@ void FakeQuantizeAndTwoOutputBranchesWithConvolutionTransformation::SetUp() { void FakeQuantizeAndTwoOutputBranchesWithConvolutionTransformation::validate() { ngraph::element::Type precision; - ngraph::Shape inputShapes; + ngraph::PartialShape inputShapes; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; FakeQuantizeAndTwoOutputBranchesWithConvolution testValues; diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_precision_selection_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_precision_selection_transformation.cpp index bb2acd8bd64acf..321da6f49bbf3a 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_precision_selection_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_precision_selection_transformation.cpp @@ -17,7 +17,7 @@ namespace LayerTestsDefinitions { std::string FakeQuantizePrecisionSelectionTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; FakeQuantizePrecisionSelectionTransformationTestValues testValues; @@ -30,7 +30,7 @@ std::string FakeQuantizePrecisionSelectionTransformation::getTestCaseName(testin void FakeQuantizePrecisionSelectionTransformation::SetUp() { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; ngraph::pass::low_precision::LayerTransformation::Params params; FakeQuantizePrecisionSelectionTransformationTestValues testValues; std::tie(netPrecision, inputShape, targetDevice, params, testValues) = this->GetParam(); @@ -50,7 +50,7 @@ void FakeQuantizePrecisionSelectionTransformation::SetUp() { void FakeQuantizePrecisionSelectionTransformation::validate() { ngraph::element::Type precision; - ngraph::Shape inputShapes; + ngraph::PartialShape inputShapes; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; FakeQuantizePrecisionSelectionTransformationTestValues param; diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_transformation.cpp index 4f14e33a75783a..25d5f3760dd23d 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_transformation.cpp @@ -19,7 +19,7 @@ namespace LayerTestsDefinitions { std::string FakeQuantizeTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; FakeQuantizeTransformationParam testParams; @@ -32,7 +32,7 @@ std::string FakeQuantizeTransformation::getTestCaseName(testing::TestParamInfoGetParam(); diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp index 9667650a641ca6..4f726d8e217668 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp @@ -17,7 +17,7 @@ namespace LayerTestsDefinitions { std::string FakeQuantizeWithNotOptimalTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShapes; + ngraph::PartialShape inputShapes; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; FakeQuantizeWithNotOptimalTransformationTestValues testValues; @@ -29,7 +29,7 @@ std::string FakeQuantizeWithNotOptimalTransformation::getTestCaseName(testing::T } void FakeQuantizeWithNotOptimalTransformation::SetUp() { - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; ngraph::element::Type netPrecision; ngraph::pass::low_precision::LayerTransformation::Params params; FakeQuantizeWithNotOptimalTransformationTestValues testValues; diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fuse_convert_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fuse_convert_transformation.cpp index 84ddf440f3228f..0682f617127f00 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fuse_convert_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fuse_convert_transformation.cpp @@ -23,7 +23,7 @@ namespace LayerTestsDefinitions { std::string FuseConvertTransformation::getTestCaseName(testing::TestParamInfo obj) { std::string targetDevice; - ngraph::Shape shape; + ngraph::PartialShape shape; ngraph::element::Type precision; auto params = LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(); ngraph::builder::subgraph::DequantizationOperations deqOperations; @@ -37,7 +37,7 @@ std::string FuseConvertTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantizeOnData; @@ -29,7 +29,7 @@ std::string FuseFakeQuantizeAndScaleShiftTransformation::getTestCaseName(testing void FuseFakeQuantizeAndScaleShiftTransformation::SetUp() { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; ngraph::pass::low_precision::LayerTransformation::Params params; ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantizeOnData; std::tie(netPrecision, inputShape, targetDevice, params, fakeQuantizeOnData) = this->GetParam(); @@ -45,7 +45,7 @@ void FuseFakeQuantizeAndScaleShiftTransformation::SetUp() { void FuseFakeQuantizeAndScaleShiftTransformation::validate() { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantizeOnData; diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/gemm_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/gemm_transformation.cpp index aabc93f115a6bb..0657458f6be4dc 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/gemm_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/gemm_transformation.cpp @@ -23,7 +23,7 @@ namespace LayerTestsDefinitions { std::string GemmTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; std::tie(netPrecision, inputShape, targetDevice, params) = obj.param; @@ -33,7 +33,7 @@ std::string GemmTransformation::getTestCaseName(testing::TestParamInfoGetParam(); @@ -51,7 +51,7 @@ void GemmTransformation::SetUp() { void GemmTransformation::validate() { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; std::tie(netPrecision, inputShape, targetDevice, params) = this->GetParam(); diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/groupconvolution_qdq_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/groupconvolution_qdq_transformation.cpp index 454581e8b8ac07..40c4afae04fdb8 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/groupconvolution_qdq_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/groupconvolution_qdq_transformation.cpp @@ -22,7 +22,7 @@ namespace LayerTestsDefinitions { std::string GroupConvolutionQDqTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; GroupConvolutionQDqTransformationParam param; @@ -37,7 +37,7 @@ void GroupConvolutionQDqTransformation::SetUp() { // threshold = 0.1f; ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; ngraph::pass::low_precision::LayerTransformation::Params params; GroupConvolutionQDqTransformationParam param; std::tie(netPrecision, inputShape, targetDevice, params, param) = this->GetParam(); diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/interpolate_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/interpolate_transformation.cpp index 983e8ddb642551..5df9c905c9ee2c 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/interpolate_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/interpolate_transformation.cpp @@ -30,7 +30,7 @@ inline std::ostream& operator<<(std::ostream& os, const std::vector& values) std::string InterpolateTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type precision; - std::pair shapes; + std::pair shapes; std::string targetDevice; interpAttributes attributes; auto params = LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(); @@ -51,7 +51,7 @@ std::string InterpolateTransformation::getTestCaseName(testing::TestParamInfo shapes; + std::pair shapes; interpAttributes attributes; auto params = LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(); std::tie(precision, shapes, targetDevice, attributes) = this->GetParam(); @@ -71,7 +71,7 @@ void InterpolateTransformation::SetUp() { void InterpolateTransformation::validate() { ngraph::element::Type precision; - std::pair shapes; + std::pair shapes; std::string targetDevice; interpAttributes attributes; auto params = LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(); diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_transformation.cpp index 60a785ac920db1..cba7e5c048a430 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_transformation.cpp @@ -21,7 +21,7 @@ namespace LayerTestsDefinitions { std::string MatMulTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type precision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; MatMulTransformationTestValues testValues; std::tie(precision, inputShape, targetDevice, testValues) = obj.param; @@ -60,7 +60,7 @@ InferenceEngine::Blob::Ptr MatMulTransformation::GenerateInput(const InferenceEn void MatMulTransformation::SetUp() { ngraph::element::Type precision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; MatMulTransformationTestValues testValues; std::tie(precision, inputShape, targetDevice, testValues) = this->GetParam(); @@ -77,7 +77,7 @@ void MatMulTransformation::SetUp() { void MatMulTransformation::validate() { ngraph::element::Type precision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; MatMulTransformationTestValues testValues; std::tie(precision, inputShape, targetDevice, testValues) = this->GetParam(); diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp index da706b482f7131..6aa6de626560f9 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp @@ -23,7 +23,7 @@ namespace LayerTestsDefinitions { std::string MatMulWithOptimizedConstantFakeQuantizeTransformation::getTestCaseName( testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - std::pair shapes; + std::pair shapes; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; MatMulWithOptimizedConstantFakeQuantizeTransformationTestValues param; @@ -32,7 +32,7 @@ std::string MatMulWithOptimizedConstantFakeQuantizeTransformation::getTestCaseNa std::ostringstream result; result << netPrecision << "_" << - CommonTestUtils::vec2str(shapes.first) << "_" << CommonTestUtils::vec2str(shapes.second) << "_" << + shapes.first << "_" << shapes.second << "_" << targetDevice << "_" << param.fqOnData << "_" << param.fqOnWeights; @@ -43,7 +43,7 @@ void MatMulWithOptimizedConstantFakeQuantizeTransformation::SetUp() { threshold = 0.01f; ngraph::element::Type precision; - std::pair shapes; + std::pair shapes; ngraph::pass::low_precision::LayerTransformation::Params params; MatMulWithOptimizedConstantFakeQuantizeTransformationTestValues param; std::tie(precision, shapes, targetDevice, param) = this->GetParam(); @@ -60,7 +60,7 @@ void MatMulWithOptimizedConstantFakeQuantizeTransformation::SetUp() { void MatMulWithOptimizedConstantFakeQuantizeTransformation::validate() { ngraph::element::Type precision; - std::pair shapes; + std::pair shapes; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; MatMulWithOptimizedConstantFakeQuantizeTransformationTestValues param; diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/multiply_to_group_convolution_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/multiply_to_group_convolution_transformation.cpp index 6ef2bb26eb4d25..f9d62e4e1721b8 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/multiply_to_group_convolution_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/multiply_to_group_convolution_transformation.cpp @@ -24,7 +24,7 @@ namespace LayerTestsDefinitions { std::string MultiplyToGroupConvolutionTransformation::getTestCaseName(testing::TestParamInfo obj) { std::string targetDevice; ngraph::element::Type precision; - ngraph::Shape shape; + ngraph::PartialShape shape; auto params = LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(); builder::subgraph::FakeQuantizeOnData fqOnData; std::tie(precision, shape, targetDevice, fqOnData) = obj.param; @@ -35,7 +35,7 @@ std::string MultiplyToGroupConvolutionTransformation::getTestCaseName(testing::T } void MultiplyToGroupConvolutionTransformation::SetUp() { - ngraph::Shape shape; + ngraph::PartialShape shape; ngraph::element::Type precision; auto params = LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(); builder::subgraph::FakeQuantizeOnData fqOnData; diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/multiply_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/multiply_transformation.cpp index b2e9e9bdf597d8..48c0ea0f042833 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/multiply_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/multiply_transformation.cpp @@ -19,7 +19,7 @@ namespace LayerTestsDefinitions { std::string MultiplyTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type precision; - ngraph::Shape inputShapes; + ngraph::PartialShape inputShapes; std::string targetDevice; auto params = LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(); MultiplyTestValues param; @@ -51,7 +51,7 @@ std::string MultiplyTransformation::getTestCaseName(testing::TestParamInfoGetParam(); @@ -68,7 +68,7 @@ void MultiplyTransformation::SetUp() { void MultiplyTransformation::validate() { ngraph::element::Type precision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; MultiplyTestValues param; std::tie(precision, inputShape, targetDevice, param) = this->GetParam(); diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/multiply_with_one_parent_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/multiply_with_one_parent_transformation.cpp index ab16aa4c14b6b7..34a78299be7a95 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/multiply_with_one_parent_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/multiply_with_one_parent_transformation.cpp @@ -17,14 +17,14 @@ namespace LayerTestsDefinitions { std::string MultiplyWithOneParentTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; MultiplyWithOneParentTransformationValues values; std::tie(netPrecision, inputShape, targetDevice, values) = obj.param; std::ostringstream result; - result << netPrecision << "_" << CommonTestUtils::vec2str(inputShape); + result << netPrecision << "_" << inputShape; return result.str(); } @@ -32,7 +32,7 @@ void MultiplyWithOneParentTransformation::SetUp() { threshold = 0.01f; ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; ngraph::pass::low_precision::LayerTransformation::Params params; MultiplyWithOneParentTransformationValues values; std::tie(netPrecision, inputShape, targetDevice, values) = this->GetParam(); diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mvn_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mvn_transformation.cpp index 6c7afd6f970bf0..383f0a62a12c51 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mvn_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mvn_transformation.cpp @@ -23,7 +23,7 @@ namespace LayerTestsDefinitions { std::string MVNTransformation::getTestCaseName(testing::TestParamInfo obj) { std::string targetDevice; - ngraph::Shape shape; + ngraph::PartialShape shape; ngraph::element::Type precision; auto params = LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(); ngraph::AxisSet reductionAxes; @@ -37,7 +37,7 @@ std::string MVNTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - std::pair shapes; + std::pair shapes; std::string targetDevice; auto params = LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(); std::vector axes; @@ -45,7 +45,7 @@ std::string NormalizeL2Transformation::getTestCaseName(testing::TestParamInfo shapes; + std::pair shapes; ngraph::element::Type precision; auto params = LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(); std::vector axes; @@ -66,7 +66,7 @@ void NormalizeL2Transformation::SetUp() { void NormalizeL2Transformation::validate() { ngraph::element::Type precision; - std::pair shapes; + std::pair shapes; std::string targetDevice; std::vector axes; bool fuseMultiply; diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/prelu_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/prelu_transformation.cpp index 125de3e4ff02d9..56bbbe8a5ae267 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/prelu_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/prelu_transformation.cpp @@ -17,7 +17,7 @@ namespace LayerTestsDefinitions { std::string PReluTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type precision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; PReluTestValues testValues; std::tie(precision, inputShape, targetDevice, testValues) = obj.param; @@ -33,7 +33,7 @@ std::string PReluTransformation::getTestCaseName(testing::TestParamInfoGetParam(); @@ -48,7 +48,7 @@ InferenceEngine::Blob::Ptr PReluTransformation::GenerateInput(const InferenceEng void PReluTransformation::SetUp() { ngraph::element::Type precision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; PReluTestValues testValues; std::tie(precision, inputShape, targetDevice, testValues) = this->GetParam(); @@ -60,7 +60,7 @@ void PReluTransformation::SetUp() { void PReluTransformation::validate() { ngraph::element::Type precision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; PReluTestValues testValues; std::tie(precision, inputShape, targetDevice, testValues) = this->GetParam(); diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/pull_reshape_through_dequantization_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/pull_reshape_through_dequantization_transformation.cpp index fa9cdeeba909ae..2824a2adc3c3f5 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/pull_reshape_through_dequantization_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/pull_reshape_through_dequantization_transformation.cpp @@ -22,7 +22,7 @@ namespace LayerTestsDefinitions { std::string PullReshapeThroughDequantizationTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; ngraph::Shape elementwiseConstantShapes; @@ -45,7 +45,7 @@ void PullReshapeThroughDequantizationTransformation::SetUp() { // threshold = 0.1f; ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; ngraph::pass::low_precision::LayerTransformation::Params params; ngraph::Shape elementwiseConstantShapes; PullReshapeThroughDequantizationTestValues testValues; diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/reduce_max_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/reduce_max_transformation.cpp index b458d5055d94ec..3c7830a2c49a05 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/reduce_max_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/reduce_max_transformation.cpp @@ -14,7 +14,7 @@ namespace LayerTestsDefinitions { std::string ReduceMaxTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; ReduceMaxTransformationParam param;; @@ -32,7 +32,7 @@ std::string ReduceMaxTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; ReduceMeanTransformationParam param;; @@ -32,7 +32,7 @@ std::string ReduceMeanTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; ReduceMinTransformationParam param;; @@ -32,7 +32,7 @@ std::string ReduceMinTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; ReduceSumTransformationParam param;; @@ -32,7 +32,7 @@ std::string ReduceSumTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type precision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ReluTestValues testValues; std::tie(precision, inputShape, targetDevice, testValues) = obj.param; @@ -33,7 +33,7 @@ std::string ReluTransformation::getTestCaseName(testing::TestParamInfoGetParam(); @@ -48,7 +48,7 @@ InferenceEngine::Blob::Ptr ReluTransformation::GenerateInput(const InferenceEngi void ReluTransformation::SetUp() { ngraph::element::Type precision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; ReluTestValues testValues; std::tie(precision, inputShape, targetDevice, testValues) = this->GetParam(); @@ -60,7 +60,7 @@ void ReluTransformation::SetUp() { void ReluTransformation::validate() { ngraph::element::Type precision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ReluTestValues testValues; std::tie(precision, inputShape, targetDevice, testValues) = this->GetParam(); diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/shuffle_channels_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/shuffle_channels_transformation.cpp index 06d502a69d8ad1..476f30b6ad14e1 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/shuffle_channels_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/shuffle_channels_transformation.cpp @@ -20,7 +20,7 @@ namespace LayerTestsDefinitions { std::string ShuffleChannelsTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; ShuffleChannelsTransformationParam param; @@ -34,7 +34,7 @@ std::string ShuffleChannelsTransformation::getTestCaseName(testing::TestParamInf void ShuffleChannelsTransformation::SetUp() { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; ngraph::pass::low_precision::LayerTransformation::Params params; ShuffleChannelsTransformationParam param; std::tie(netPrecision, inputShape, targetDevice, params, param) = this->GetParam(); diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/split_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/split_transformation.cpp index 7c9eb6e8379240..95316108aa917e 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/split_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/split_transformation.cpp @@ -17,7 +17,7 @@ namespace LayerTestsDefinitions { std::string SplitTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShapes; + ngraph::PartialShape inputShapes; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; SplitTransformationParam param; @@ -31,7 +31,7 @@ std::string SplitTransformation::getTestCaseName(testing::TestParamInfoGetParam(); @@ -64,7 +64,7 @@ void SplitTransformation::SetUp() { void SplitTransformation::validate() { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; SplitTransformationParam param; diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/strided_slice_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/strided_slice_transformation.cpp index a0c4d48a9c2b8f..9712ebf01214d8 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/strided_slice_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/strided_slice_transformation.cpp @@ -26,7 +26,7 @@ inline std::ostream& operator<<(std::ostream& os, const std::vector& va std::string StridedSliceTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; StridedSliceTransformationParam param;; @@ -42,7 +42,7 @@ std::string StridedSliceTransformation::getTestCaseName(testing::TestParamInfoGetParam(); @@ -65,7 +65,7 @@ void StridedSliceTransformation::SetUp() { void StridedSliceTransformation::validate() { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; StridedSliceTransformationParam param; diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/subtract_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/subtract_transformation.cpp index afb24897f82907..55841cc8760ce0 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/subtract_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/subtract_transformation.cpp @@ -19,7 +19,7 @@ namespace LayerTestsDefinitions { std::string SubtractTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShapes; + ngraph::PartialShape inputShapes; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; std::tie(netPrecision, inputShapes, targetDevice, params) = obj.param; @@ -29,7 +29,7 @@ std::string SubtractTransformation::getTestCaseName(testing::TestParamInfoGetParam(); diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/transpose_after_matmul_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/transpose_after_matmul_transformation.cpp index d6682af481b575..7135ab31f318f4 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/transpose_after_matmul_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/transpose_after_matmul_transformation.cpp @@ -23,7 +23,7 @@ namespace LayerTestsDefinitions { std::string TransposeAfterMatMulTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShapes; + ngraph::PartialShape inputShapes; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; bool perTensor; @@ -39,7 +39,7 @@ std::string TransposeAfterMatMulTransformation::getTestCaseName(testing::TestPar void TransposeAfterMatMulTransformation::SetUp() { ngraph::element::Type precision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; ngraph::pass::low_precision::LayerTransformation::Params params; bool perTensor; bool transposeChannelDim; @@ -52,7 +52,7 @@ void TransposeAfterMatMulTransformation::SetUp() { void TransposeAfterMatMulTransformation::validate() { ngraph::element::Type precision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; bool perTensor; diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/variadic_split_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/variadic_split_transformation.cpp index 5c5444ee0fdcd0..10ed98080617aa 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/variadic_split_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/variadic_split_transformation.cpp @@ -17,7 +17,7 @@ namespace LayerTestsDefinitions { std::string VariadicSplitTransformation::getTestCaseName(testing::TestParamInfo obj) { ngraph::element::Type netPrecision; - ngraph::Shape inputShapes; + ngraph::PartialShape inputShapes; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; VariadicSplitTransformationParam param; @@ -38,7 +38,7 @@ std::string VariadicSplitTransformation::getTestCaseName(testing::TestParamInfo< InferenceEngine::Blob::Ptr VariadicSplitTransformation::GenerateInput(const InferenceEngine::InputInfo& info) const { ngraph::element::Type precision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; VariadicSplitTransformationParam param; @@ -54,7 +54,7 @@ InferenceEngine::Blob::Ptr VariadicSplitTransformation::GenerateInput(const Infe void VariadicSplitTransformation::SetUp() { ngraph::element::Type precision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; ngraph::pass::low_precision::LayerTransformation::Params params; VariadicSplitTransformationParam param; std::tie(precision, inputShape, targetDevice, params, param) = this->GetParam(); @@ -71,7 +71,7 @@ void VariadicSplitTransformation::SetUp() { void VariadicSplitTransformation::validate() { ngraph::element::Type netPrecision; - ngraph::Shape inputShape; + ngraph::PartialShape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; VariadicSplitTransformationParam param; diff --git a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/layer_test_utils.hpp b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/layer_test_utils.hpp index 9d13251574331f..72172e6992482a 100644 --- a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/layer_test_utils.hpp +++ b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/layer_test_utils.hpp @@ -101,7 +101,7 @@ class LayerTestsCommon : public CommonTestUtils::TestsCommon { double diff = static_cast(absoluteDifference) / max; if (max == 0 || (diff > static_cast(threshold)) || std::isnan(static_cast(res)) || std::isnan(static_cast(ref))) { - IE_THROW() << "Relative comparison of values expected: " << ref << " and actual: " << res + IE_THROW() << "Relative comparison of values expected: " << std::to_string(ref) << " and actual: " << std::to_string(res) << " at index " << i << " with threshold " << threshold << " failed"; } diff --git a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/low_precision_transformations/layer_transformation.hpp b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/low_precision_transformations/layer_transformation.hpp index 298c03f4e304fa..942e836d828bd2 100644 --- a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/low_precision_transformations/layer_transformation.hpp +++ b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/low_precision_transformations/layer_transformation.hpp @@ -57,7 +57,7 @@ class LayerTransformation : virtual public LayerTestsUtils::LayerTestsCommon { static std::string getTestCaseNameByParams( const ngraph::element::Type precision, - const ngraph::Shape& inputShapes, + const ngraph::PartialShape& inputShapes, const std::string& targetDevice, const ngraph::pass::low_precision::LayerTransformation::Params& params); }; diff --git a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/activation.hpp b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/activation.hpp index 684942ee184653..5a9c5226f6f398 100644 --- a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/activation.hpp +++ b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/activation.hpp @@ -40,6 +40,7 @@ static std::map activationNames = {ngraph::helpers::ActivationTypes::Negative, "Negative"}, {ngraph::helpers::ActivationTypes::Acos, "Acos"}, {ngraph::helpers::ActivationTypes::Asin, "Asin"}, + {ngraph::helpers::ActivationTypes::Asinh, "Asinh"}, {ngraph::helpers::ActivationTypes::Atan, "Atan"}, {ngraph::helpers::ActivationTypes::Cos, "Cos"}, {ngraph::helpers::ActivationTypes::Cosh, "Cosh"}, diff --git a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/gather.hpp b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/gather.hpp index 5fd19bbacdacec..abf7c2caa993be 100644 --- a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/gather.hpp +++ b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/gather.hpp @@ -63,4 +63,13 @@ class Gather7LayerTest : public testing::WithParamInterface, void SetUp() override; }; +class Gather8LayerTest : public testing::WithParamInterface, + virtual public LayerTestsUtils::LayerTestsCommon { +public: + static std::string getTestCaseName(const testing::TestParamInfo& obj); + +protected: + void SetUp() override; +}; + } // namespace LayerTestsDefinitions \ No newline at end of file diff --git a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/prior_box.hpp b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/prior_box.hpp new file mode 100644 index 00000000000000..15fcb6d1127f88 --- /dev/null +++ b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/prior_box.hpp @@ -0,0 +1,80 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "ie_core.hpp" +#include "ie_precision.hpp" + +#include "ngraph/opsets/opset1.hpp" + +#include "functional_test_utils/blob_utils.hpp" +#include "shared_test_classes/base/layer_test_utils.hpp" +#include "common_test_utils/common_utils.hpp" + +#include "ngraph_functions/utils/ngraph_helpers.hpp" +#include "ngraph_functions/builders.hpp" + +namespace LayerTestDefinitions { +using priorBoxSpecificParams = std::tuple< + std::vector, // min_size + std::vector, // max_size + std::vector, // aspect_ratio + std::vector, // density + std::vector, // fixed_ratio + std::vector, // fixed_size + bool, // clip + bool, // flip + float, // step + float, // offset + std::vector, // variance + bool>; // scale_all_sizes + +typedef std::tuple< + priorBoxSpecificParams, + InferenceEngine::Precision, // net precision + InferenceEngine::Precision, // Input precision + InferenceEngine::Precision, // Output precision + InferenceEngine::Layout, // Input layout + InferenceEngine::Layout, // Output layout + InferenceEngine::SizeVector, // input shape + InferenceEngine::SizeVector, // image shape + std::string> priorBoxLayerParams; + +class PriorBoxLayerTest + : public testing::WithParamInterface, + virtual public LayerTestsUtils::LayerTestsCommon { +public: + static std::string getTestCaseName(const testing::TestParamInfo& obj); +protected: + InferenceEngine::SizeVector inputShapes; + InferenceEngine::SizeVector imageShapes; + InferenceEngine::Precision netPrecision; + std::vector min_size; + std::vector max_size; + std::vector aspect_ratio; + std::vector density; + std::vector fixed_ratio; + std::vector fixed_size; + std::vector variance; + float step; + float offset; + bool clip; + bool flip; + bool scale_all_sizes; + + void SetUp() override; +}; + +} // namespace LayerTestDefinitions diff --git a/inference-engine/tests/functional/shared_test_classes/src/base/low_precision_transformations/layer_transformation.cpp b/inference-engine/tests/functional/shared_test_classes/src/base/low_precision_transformations/layer_transformation.cpp index 3a6dd4dc4eaf08..a3e110a9f970a4 100644 --- a/inference-engine/tests/functional/shared_test_classes/src/base/low_precision_transformations/layer_transformation.cpp +++ b/inference-engine/tests/functional/shared_test_classes/src/base/low_precision_transformations/layer_transformation.cpp @@ -103,7 +103,7 @@ std::string LayerTransformation::getTestCaseNameByParams( std::string LayerTransformation::getTestCaseNameByParams( const ngraph::element::Type precision, - const ngraph::Shape& inputShapes, + const ngraph::PartialShape& inputShapes, const std::string& targetDevice, const ngraph::pass::low_precision::LayerTransformation::Params& params) { std::ostringstream result; diff --git a/inference-engine/tests/functional/shared_test_classes/src/single_layer/gather.cpp b/inference-engine/tests/functional/shared_test_classes/src/single_layer/gather.cpp index 9f57e1d1be1695..84965158e13f64 100644 --- a/inference-engine/tests/functional/shared_test_classes/src/single_layer/gather.cpp +++ b/inference-engine/tests/functional/shared_test_classes/src/single_layer/gather.cpp @@ -93,4 +93,47 @@ void Gather7LayerTest::SetUp() { function = std::make_shared(results, functionParams, "gather"); } +std::string Gather8LayerTest::getTestCaseName(const testing::TestParamInfo& obj) { + std::tuple axis_batchIdx; + std::vector indices; + std::vector indicesShape, inputShape; + InferenceEngine::Precision netPrecision; + InferenceEngine::Precision inPrc, outPrc; + InferenceEngine::Layout inLayout, outLayout; + std::string targetName; + std::tie(inputShape, indicesShape, axis_batchIdx, netPrecision, inPrc, outPrc, inLayout, outLayout, targetName) = obj.param; + std::ostringstream result; + result << "IS=" << CommonTestUtils::vec2str(inputShape) << "_"; + result << "axis=" << std::get<0>(axis_batchIdx) << "_"; + result << "batchIdx=" << std::get<1>(axis_batchIdx) << "_"; + result << "indicesShape=" << CommonTestUtils::vec2str(indicesShape) << "_"; + result << "netPRC=" << netPrecision.name() << "_"; + result << "inPRC=" << inPrc.name() << "_"; + result << "outPRC=" << outPrc.name() << "_"; + result << "inL=" << inLayout << "_"; + result << "outL=" << outLayout << "_"; + result << "trgDev=" << targetName << "_"; + return result.str(); +} + +void Gather8LayerTest::SetUp() { + std::tuple axis_batchIdx; + std::vector indicesShape; + std::vector inputShape; + InferenceEngine::Precision netPrecision; + std::tie(inputShape, indicesShape, axis_batchIdx, netPrecision, inPrc, outPrc, inLayout, outLayout, targetDevice) = GetParam(); + int axis = std::get<0>(axis_batchIdx); + int batchIdx = std::get<1>(axis_batchIdx); + auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); + auto functionParams = ngraph::builder::makeParams(ngPrc, { inputShape }); + auto paramOuts = ngraph::helpers::convert2OutputVector(ngraph::helpers::castOps2Nodes(functionParams)); + auto indicesNode = ngraph::builder::makeConstant(ngraph::element::i64, indicesShape, {}, true, + inputShape[axis < 0 ? axis + inputShape.size() : axis] - 1, + 1 - static_cast(inputShape[axis < 0 ? axis + inputShape.size() : axis])); + auto axisNode = ngraph::opset8::Constant::create(ngraph::element::i64, ngraph::Shape({}), { axis }); + auto gather = std::make_shared(paramOuts[0], indicesNode, axisNode, batchIdx); + ngraph::ResultVector results{ std::make_shared(gather) }; + function = std::make_shared(results, functionParams, "gather"); +} + } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/shared_test_classes/src/single_layer/prior_box.cpp b/inference-engine/tests/functional/shared_test_classes/src/single_layer/prior_box.cpp new file mode 100644 index 00000000000000..f3b95141ae045c --- /dev/null +++ b/inference-engine/tests/functional/shared_test_classes/src/single_layer/prior_box.cpp @@ -0,0 +1,91 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "shared_test_classes/single_layer/prior_box.hpp" + +namespace LayerTestDefinitions { +std::string PriorBoxLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { + InferenceEngine::Precision netPrecision; + InferenceEngine::Precision inPrc, outPrc; + InferenceEngine::Layout inLayout, outLayout; + InferenceEngine::SizeVector inputShapes, imageShapes; + std::string targetDevice; + priorBoxSpecificParams specParams; + std::tie(specParams, + netPrecision, + inPrc, outPrc, inLayout, outLayout, + inputShapes, + imageShapes, + targetDevice) = obj.param; + + std::vector min_size, max_size, aspect_ratio, density, fixed_ratio, fixed_size, variance; + float step, offset; + bool clip, flip, scale_all_sizes; + std::tie(min_size, max_size, aspect_ratio, + density, fixed_ratio, fixed_size, clip, + flip, step, offset, variance, scale_all_sizes) = specParams; + + std::ostringstream result; + const char separator = '_'; + result << "IS=" << CommonTestUtils::vec2str(inputShapes) << separator; + result << "imageS=" << CommonTestUtils::vec2str(imageShapes) << separator; + result << "netPRC=" << netPrecision.name() << separator; + result << "inPRC=" << inPrc.name() << separator; + result << "outPRC=" << outPrc.name() << separator; + result << "inL=" << inLayout << separator; + result << "outL=" << outLayout << separator; + result << "min_s=" << CommonTestUtils::vec2str(min_size) << separator; + result << "max_s=" << CommonTestUtils::vec2str(max_size)<< separator; + result << "asp_r=" << CommonTestUtils::vec2str(aspect_ratio)<< separator; + result << "dens=" << CommonTestUtils::vec2str(density)<< separator; + result << "fix_r=" << CommonTestUtils::vec2str(fixed_ratio)<< separator; + result << "fix_s=" << CommonTestUtils::vec2str(fixed_size)<< separator; + result << "var=" << CommonTestUtils::vec2str(variance)<< separator; + result << "step=" << step << separator; + result << "off=" << offset << separator; + result << "clip=" << clip << separator; + result << "flip=" << flip<< separator; + result << "scale_all=" << scale_all_sizes << separator; + result << "trgDev=" << targetDevice; + + return result.str(); +} + +void PriorBoxLayerTest::SetUp() { + priorBoxSpecificParams specParams; + std::tie(specParams, netPrecision, + inPrc, outPrc, inLayout, outLayout, + inputShapes, imageShapes, targetDevice) = GetParam(); + + std::tie(min_size, max_size, aspect_ratio, + density, fixed_ratio, fixed_size, clip, + flip, step, offset, variance, scale_all_sizes) = specParams; + + auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); + auto params = ngraph::builder::makeParams(ngPrc, {inputShapes, imageShapes}); + + ngraph::op::PriorBoxAttrs attributes; + attributes.min_size = min_size; + attributes.max_size = max_size; + attributes.aspect_ratio = aspect_ratio; + attributes.density = density; + attributes.fixed_ratio = fixed_ratio; + attributes.fixed_size = fixed_size; + attributes.variance = variance; + attributes.step = step; + attributes.offset = offset; + attributes.clip = clip; + attributes.flip = flip; + + auto shape_of_1 = std::make_shared(params[0]); + auto shape_of_2 = std::make_shared(params[1]); + auto priorBox = std::make_shared( + shape_of_1, + shape_of_2, + attributes); + + ngraph::ResultVector results{std::make_shared(priorBox)}; + function = std::make_shared (results, params, "PriorBoxFunction"); +} +} // namespace LayerTestDefinitions diff --git a/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.cpp b/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.cpp index 3d0ec47531d326..1af6642ba878bd 100644 --- a/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.cpp +++ b/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.cpp @@ -779,6 +779,14 @@ void check_rt_info(const std::shared_ptr& f) { } } +void set_tensor_name(ngraph::Output output, const std::string & name) { + output.get_tensor_ptr()->set_names({name}); +} + +void set_tensor_names(ngraph::Output output, const std::unordered_set & names) { + output.get_tensor_ptr()->set_names(names); +} + NGRAPH_RTTI_DEFINITION(TestOpMultiOut, "TestOp", 0); namespace attributes { diff --git a/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.hpp b/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.hpp index ab636060af1264..116226da962452 100644 --- a/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.hpp +++ b/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.hpp @@ -101,6 +101,10 @@ inline std::pair compare_functions( void check_rt_info(const std::shared_ptr& f); +void set_tensor_name(ngraph::Output output, const std::string & name); + +void set_tensor_names(ngraph::Output output, const std::unordered_set & names); + namespace ngraph { namespace pass { class InjectionPass; diff --git a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py index 0f923e35d5934a..3241dfd7013b1f 100644 --- a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py +++ b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py @@ -6,6 +6,7 @@ 'Acos-1', 'Add-1', 'Asin-1', + 'Asinh-3', 'Assign-6', 'AvgPool-1', 'BatchNormInference-5', @@ -23,6 +24,7 @@ 'Convolution-1', 'Constant-1', 'Cos-1', + 'Cosh-1', 'DeformableConvolution-1', 'DeformablePSROIPooling-1', 'DetectionOutput-1', @@ -60,9 +62,10 @@ 'NonMaxSuppression-4', 'NonMaxSuppression-5', 'NonZero-3', - 'PSROIPooling-1', + 'PriorBox-1', 'Proposal-1', 'Proposal-4', + 'PSROIPooling-1', 'RNNSequence-5', 'ROIAlign-3', 'ROIPooling-2', @@ -89,6 +92,7 @@ 'ShapeOf-3', 'Sigmoid-1', 'Sin-1', + 'Sinh-1' 'SoftPlus-4', 'Softmax-1', 'Split-1', diff --git a/inference-engine/tests/ie_test_utils/functional_test_utils/src/plugin_cache.cpp b/inference-engine/tests/ie_test_utils/functional_test_utils/src/plugin_cache.cpp index 95b8e29eff417d..95c7e18a18115c 100644 --- a/inference-engine/tests/ie_test_utils/functional_test_utils/src/plugin_cache.cpp +++ b/inference-engine/tests/ie_test_utils/functional_test_utils/src/plugin_cache.cpp @@ -49,6 +49,13 @@ std::shared_ptr PluginCache::ie(const std::string &device } assert(0 != ie_core.use_count()); + // register template plugin if it is needed + try { + std::string pluginName = "templatePlugin"; + pluginName += IE_BUILD_POSTFIX; + ie_core->RegisterPlugin(pluginName, "TEMPLATE"); + } catch (...) {} + if (!deviceToCheck.empty()) { std::vector metrics = ie_core->GetMetric(deviceToCheck, METRIC_KEY(SUPPORTED_METRICS)); @@ -61,11 +68,13 @@ std::shared_ptr PluginCache::ie(const std::string &device std::exit(EXIT_FAILURE); } +#ifndef NDEBUG std::cout << "Available devices for " << deviceToCheck << ":" << std::endl; for (const auto &device : availableDevices) { std::cout << " " << device << std::endl; } +#endif } } return ie_core; diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_icnn_network.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_icnn_network.hpp index a3f7d337dd0bba..3d157842b4dd50 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_icnn_network.hpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_icnn_network.hpp @@ -48,4 +48,8 @@ class MockICNNNetwork final : public InferenceEngine::ICNNNetwork { (const, noexcept)); MOCK_METHOD(InferenceEngine::StatusCode, serialize, (const std::string &, const std::string &, InferenceEngine::ResponseDesc*), (const, noexcept)); + MOCK_METHOD(InferenceEngine::StatusCode, serialize, + (std::ostream &, std::ostream &, InferenceEngine::ResponseDesc*), (const, noexcept)); + MOCK_METHOD(InferenceEngine::StatusCode, serialize, + (std::ostream &, InferenceEngine::Blob::Ptr &, InferenceEngine::ResponseDesc*), (const, noexcept)); }; diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_not_empty_icnn_network.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_not_empty_icnn_network.hpp index f9ffeab2f2ddad..d861ded519a863 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_not_empty_icnn_network.hpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_not_empty_icnn_network.hpp @@ -43,6 +43,10 @@ class MockNotEmptyICNNNetwork final : public ICNNNetwork { MOCK_METHOD(StatusCode, reshape, (const ICNNNetwork::InputShapes &, ResponseDesc *), (noexcept)); MOCK_METHOD(StatusCode, serialize, (const std::string &, const std::string &, InferenceEngine::ResponseDesc*), (const, noexcept)); + MOCK_METHOD(StatusCode, serialize, + (std::ostream &, std::ostream &, InferenceEngine::ResponseDesc*), (const, noexcept)); + MOCK_METHOD(StatusCode, serialize, + (std::ostream &, Blob::Ptr &, InferenceEngine::ResponseDesc*), (const, noexcept)); }; IE_SUPPRESS_DEPRECATED_END diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/add_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/add_function.hpp index aa9cb1e0e71d90..b0b4e9ad693e19 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/add_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/add_function.hpp @@ -71,7 +71,7 @@ class AddFunction { static std::shared_ptr getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const bool broadcast, const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData1, const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData2); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/avg_pool_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/avg_pool_function.hpp index c48330a806c156..3b411e3621f286 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/avg_pool_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/avg_pool_function.hpp @@ -27,7 +27,7 @@ class AvgPoolFunction { static std::shared_ptr getOriginal( const ngraph::element::Type originalFunctionPrecision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const FakeQuantizeOnData& fakeQuantizeOnData); static std::shared_ptr getReference( diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/clamp_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/clamp_function.hpp index c09cf4b60dd31d..e48f1aa0575644 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/clamp_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/clamp_function.hpp @@ -27,7 +27,7 @@ class ClampFunction { static std::shared_ptr getOriginal( const ngraph::element::Type originalFunctionPrecision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize, const double clampLowConst, const double clampHighConst); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/concat_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/concat_function.hpp index 21b3289d513306..e3456ad2a4bfec 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/concat_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/concat_function.hpp @@ -19,7 +19,7 @@ class ConcatFunction { public: static std::shared_ptr getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const FakeQuantizeOnData& fakeQuantize1, const FakeQuantizeOnData& fakeQuantize2); @@ -31,7 +31,7 @@ class ConcatFunction { static std::shared_ptr getOriginalWithChildAndOutput( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const FakeQuantizeOnData& fakeQuantize1, const FakeQuantizeOnData& fakeQuantize2); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/convolution_backprop_data_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/convolution_backprop_data_function.hpp index e276c15cc9e098..77fd6d53cb9677 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/convolution_backprop_data_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/convolution_backprop_data_function.hpp @@ -29,7 +29,7 @@ class ConvolutionBackpropDataFunction { const std::shared_ptr& value = nullptr); static std::shared_ptr get( const element::Type netPrecision, - const Shape& inputShape, + const PartialShape& inputShape, const Shape& outputShape, const builder::subgraph::FakeQuantizeOnData& fqOnData, const std::shared_ptr& weights); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/convolution_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/convolution_function.hpp index 85ec80922a496a..0bff29ac9c3782 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/convolution_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/convolution_function.hpp @@ -34,7 +34,7 @@ class ConvolutionFunction { bool isCrorrect); static std::shared_ptr getOriginalWithIncorrectWeights( - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, ngraph::element::Type precision, ngraph::builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights, ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantizeOnData, diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/depth_to_space_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/depth_to_space_function.hpp index 6eb90026e19e4a..2c24f740f7ae8c 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/depth_to_space_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/depth_to_space_function.hpp @@ -21,7 +21,7 @@ class DepthToSpaceFunction { public: static std::shared_ptr getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ngraph::opset1::DepthToSpace::DepthToSpaceMode mode, const size_t blockSize); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fake_quantize_and_convolution_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fake_quantize_and_convolution_function.hpp index a0c8718a5f3db6..8823779f6134b4 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fake_quantize_and_convolution_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fake_quantize_and_convolution_function.hpp @@ -25,7 +25,7 @@ class FakeQuantizeAndConvolutionFunction { // TODO: move to ConvolutionFunction static std::shared_ptr get( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const FakeQuantizeOnData& fakeQuantizeOnData, const FakeQuantizeOnWeights& fakeQuantizeOnWeights); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fake_quantize_and_two_output_branches_with_convolution_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fake_quantize_and_two_output_branches_with_convolution_function.hpp index 74c471a04b7828..49f613818f8da6 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fake_quantize_and_two_output_branches_with_convolution_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fake_quantize_and_two_output_branches_with_convolution_function.hpp @@ -20,7 +20,7 @@ class FakeQuantizeAndTwoOutputBranchesWithConvolutionFunction { public: static std::shared_ptr getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const FakeQuantizeOnData& fqOnData, const FakeQuantizeOnWeights fqOnWeights1, FakeQuantizeOnWeights fqOnWeights2); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fake_quantize_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fake_quantize_function.hpp index 3c2cda0e7fd153..d1a212490daac6 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fake_quantize_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fake_quantize_function.hpp @@ -25,7 +25,7 @@ class FakeQuantizeFunction { static std::shared_ptr getOriginalWithMaxPool( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const FakeQuantizeOnData& fakeQuantizeOnData); static std::shared_ptr getReference( diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fake_quantize_precision_selection_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fake_quantize_precision_selection_function.hpp index f0775e4a383296..18422faaf622f8 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fake_quantize_precision_selection_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fake_quantize_precision_selection_function.hpp @@ -35,7 +35,7 @@ class FakeQuantizePrecisionSelectionFunction { static std::shared_ptr getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ActualValues& values); static std::shared_ptr getReference( diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fuse_convert_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fuse_convert_function.hpp index 22d37e2796257d..0530422e09799b 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fuse_convert_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fuse_convert_function.hpp @@ -23,7 +23,7 @@ class FuseConvertFunction { const bool constInput); static std::shared_ptr getWithFQ( - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ngraph::element::Type inputPrecision, const ngraph::builder::subgraph::DequantizationOperations& dequantization, const bool constInput); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fuse_fake_quantize_and_scale_shift_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fuse_fake_quantize_and_scale_shift_function.hpp index 30c28261f014cb..2ac798cc0f2ef1 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fuse_fake_quantize_and_scale_shift_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fuse_fake_quantize_and_scale_shift_function.hpp @@ -17,7 +17,7 @@ class FuseFakeQuantizeAndScaleShiftFunction { public: static std::shared_ptr getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const FakeQuantizeOnData& fakeQuantizeOnData); }; diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fuse_fake_quantize_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fuse_fake_quantize_function.hpp index 9cb401132c5540..4de97eb813bb86 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fuse_fake_quantize_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fuse_fake_quantize_function.hpp @@ -46,7 +46,7 @@ class FuseFakeQuantizeFunction { const FakeQuantizeOnDataWithConstant& fqOnData); static std::shared_ptr get( - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const std::vector& branches, const ngraph::element::Type precisionFqOnData, const FakeQuantizeOnData& fqOnData); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/group_convolution_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/group_convolution_function.hpp index dd9d8ae32a98c5..e4f4499e26c3e1 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/group_convolution_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/group_convolution_function.hpp @@ -29,7 +29,7 @@ class GroupConvolutionFunction { static std::shared_ptr getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ngraph::Shape& outputShape, const size_t groupCount, const int groupCalculationDimention, diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/interpolate_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/interpolate_function.hpp index 5ba5d38eeeb700..b0fff2eedc4431 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/interpolate_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/interpolate_function.hpp @@ -23,7 +23,7 @@ class InterpolateFunction { static std::shared_ptr getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ngraph::Shape& outputShape, const ngraph::op::InterpolateAttrs& interpAttrs); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/mat_mul_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/mat_mul_function.hpp index 89bf9d291253d6..803eedaccae3d7 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/mat_mul_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/mat_mul_function.hpp @@ -19,14 +19,14 @@ class MatMulFunction { public: static std::shared_ptr getOriginal( const ngraph::element::Type precision, - const ngraph::Shape inputShape, + const ngraph::PartialShape inputShape, const float low, const float high); static std::shared_ptr getOriginal( const ngraph::element::Type precision, - const ngraph::Shape inputShape1, - const ngraph::Shape inputShape2, + const ngraph::PartialShape inputShape1, + const ngraph::PartialShape inputShape2, const bool transpose1, const bool transpose2); @@ -75,7 +75,7 @@ class MatMulFunction { static std::shared_ptr getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const FakeQuantizeOnDataWithConstant& fqOnData, const Constant& weights, const FakeQuantizeOnDataWithConstant& fqOnWeights, diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/mat_mul_with_optimized_constant_fake_quantize_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/mat_mul_with_optimized_constant_fake_quantize_function.hpp index e77c1e1d1cc8ef..80b311b16a9753 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/mat_mul_with_optimized_constant_fake_quantize_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/mat_mul_with_optimized_constant_fake_quantize_function.hpp @@ -16,8 +16,8 @@ class MatMulWithOptimizedConstantFakeQuantizeFunction { public: static std::shared_ptr getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape1, - const ngraph::Shape& inputShape2, + const ngraph::PartialShape& inputShape1, + const ngraph::PartialShape& inputShape2, const FakeQuantizeOnData& fqOnData, const FakeQuantizeOnData& fqOnWeights); }; diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/max_pool_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/max_pool_function.hpp index 268c23f9e14526..330aa6904013eb 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/max_pool_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/max_pool_function.hpp @@ -18,7 +18,7 @@ class MaxPoolFunction { public: static std::shared_ptr getOriginal( const ngraph::element::Type originalFunctionPrecision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const FakeQuantizeOnData& fakeQuantizeOnData); static std::shared_ptr get( diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/multiply_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/multiply_function.hpp index 0a4087f8c3663b..96c1b387e34ba7 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/multiply_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/multiply_function.hpp @@ -45,7 +45,7 @@ class MultiplyFunction { static std::shared_ptr getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const bool broadcast, const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData1, const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData2); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/multiply_to_group_convolution_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/multiply_to_group_convolution_function.hpp index 060ec7309f2b53..0c366a5637fd25 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/multiply_to_group_convolution_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/multiply_to_group_convolution_function.hpp @@ -25,7 +25,7 @@ class MultiplyToGroupConvolutionFunction { static std::shared_ptr getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const FakeQuantizeOnData& fqOnData); static std::shared_ptr getReference( diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/multiply_with_one_parent_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/multiply_with_one_parent_function.hpp index 3aab5f89747916..49dcc4f56c2675 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/multiply_with_one_parent_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/multiply_with_one_parent_function.hpp @@ -16,7 +16,7 @@ class MultiplyWithOneParentFunction { public: static std::shared_ptr getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const FakeQuantizeOnData& fakeQuantize); }; diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/mvn_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/mvn_function.hpp index cba5c68893df3c..6fe7c6b2f79e50 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/mvn_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/mvn_function.hpp @@ -25,7 +25,7 @@ class MVNFunction { static std::shared_ptr getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const AxisSet& reductionAxes, const bool& normalizeVariance); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/normalize_l2_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/normalize_l2_function.hpp index 41fdd7917d2db7..d37d2ddfd544fe 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/normalize_l2_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/normalize_l2_function.hpp @@ -21,7 +21,7 @@ class NormalizeL2Function { public: static std::shared_ptr getOriginal( const ngraph::element::Type precision, - const std::pair& shapes, + const std::pair& shapes, const ngraph::element::Type precisionOnActivation, const std::vector& axes, const bool fuseMultiply, diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/prelu_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/prelu_function.hpp index a098b4c8b17278..d1bf93feac37d8 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/prelu_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/prelu_function.hpp @@ -20,7 +20,7 @@ class PReluFunction { const ngraph::builder::subgraph::DequantizationOperations& dequantization); static std::shared_ptr getOriginal( - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ngraph::element::Type precisionBeforeFq, const FakeQuantizeOnData& fqOnData); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/reduce_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/reduce_function.hpp index deba5d14a3464f..c9f9162b8d6d0a 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/reduce_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/reduce_function.hpp @@ -54,7 +54,7 @@ class ReduceFunction { template static std::shared_ptr getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData, const std::vector& constantValues, const bool keepDims) { diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/relu_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/relu_function.hpp index d343899d5db265..56b05246342b59 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/relu_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/relu_function.hpp @@ -20,7 +20,7 @@ class ReluFunction { const ngraph::builder::subgraph::DequantizationOperations& dequantization); static std::shared_ptr getOriginal( - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ngraph::element::Type precisionBeforeFq, const FakeQuantizeOnData& fqOnData); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/reshape_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/reshape_function.hpp index 17ef54ed450ca8..44d817051bd2e5 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/reshape_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/reshape_function.hpp @@ -23,7 +23,7 @@ class ReshapeFunction { const ngraph::builder::subgraph::DequantizationOperations& dequantization); static std::shared_ptr getOriginal( - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const std::vector& reshapeConstValues, const ngraph::element::Type precisionBeforeFq, const FakeQuantizeOnData& fqOnData); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/shuffle_channels_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/shuffle_channels_function.hpp index 0d9cc65fec94de..8d1a87c11a97cc 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/shuffle_channels_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/shuffle_channels_function.hpp @@ -26,7 +26,7 @@ class ShuffleChannelsFunction { static std::shared_ptr getOriginal( const ngraph::element::Type inputPrecision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData, const std::int64_t axis, const std::int64_t group); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/split_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/split_function.hpp index 73b1ef7dfd873c..4300fdd172cc7e 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/split_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/split_function.hpp @@ -30,7 +30,7 @@ class SplitFunction { static std::shared_ptr getOriginal( const ngraph::element::Type originalFunctionPrecision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize, const int64_t splitedAxis, const size_t numSplit); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/squeeze_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/squeeze_function.hpp index dddf8e6802dcb0..13f68240343596 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/squeeze_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/squeeze_function.hpp @@ -22,7 +22,7 @@ class SqueezeFunction { static std::shared_ptr getOriginal( const ngraph::element::Type originalFunctionPrecision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const FakeQuantizeOnData& fakeQuantizeOnData, const std::vector& axes); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/strided_slice_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/strided_slice_function.hpp index 3c048da6044bd8..aaead6e245a933 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/strided_slice_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/strided_slice_function.hpp @@ -32,7 +32,7 @@ class StridedSliceFunction { static std::shared_ptr getOriginal( const ngraph::element::Type inputPrecision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ngraph::builder::subgraph::FakeQuantizeOnData& fakeQuantize, const std::vector& begin, const std::vector& end, diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/subtract_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/subtract_function.hpp index 2de725ca64e2c9..c849d46b3f32ab 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/subtract_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/subtract_function.hpp @@ -19,7 +19,7 @@ class SubtractFunction { public: static std::shared_ptr getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape); + const ngraph::PartialShape& inputShape); }; } // namespace subgraph diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/subtract_multiply_to_multiply_add_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/subtract_multiply_to_multiply_add_function.hpp index b88da01c1839ce..4617455d674bd5 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/subtract_multiply_to_multiply_add_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/subtract_multiply_to_multiply_add_function.hpp @@ -26,7 +26,7 @@ class SubtractMultiplyToMultiplyAddFunction { const ngraph::element::Type precisionAfterDequantization); static std::shared_ptr getOriginal( - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ngraph::element::Type precision, const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/transpose_after_mat_mul_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/transpose_after_mat_mul_function.hpp index e8a1307407866b..544444b7e2a8d9 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/transpose_after_mat_mul_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/transpose_after_mat_mul_function.hpp @@ -19,7 +19,7 @@ class TransposeAfterMatMulFunction { public: static std::shared_ptr getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape); + const ngraph::PartialShape& inputShape); }; } // namespace subgraph diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/transpose_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/transpose_function.hpp index c61e67756e93b3..51de8537d7b41e 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/transpose_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/transpose_function.hpp @@ -23,7 +23,7 @@ class TransposeFunction { const ngraph::builder::subgraph::DequantizationOperations& dequantization); static std::shared_ptr getOriginal( - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const std::vector& transposeConstValues, const ngraph::element::Type precisionBeforeFq, const FakeQuantizeOnData& fqOnData); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/unsqueeze_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/unsqueeze_function.hpp index 2e450e561926c3..bc472fbad6de24 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/unsqueeze_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/unsqueeze_function.hpp @@ -22,7 +22,7 @@ class UnsqueezeFunction { static std::shared_ptr getOriginal( const ngraph::element::Type originalFunctionPrecision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const FakeQuantizeOnData& fakeQuantizeOnData, const std::vector& axes); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/variadic_split_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/variadic_split_function.hpp index 51bde4c98152d4..01bef64c4bf91c 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/variadic_split_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/variadic_split_function.hpp @@ -28,7 +28,7 @@ class VariadicSplitFunction { static std::shared_ptr getOriginal( const ngraph::element::Type originalFunctionPrecision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize, const int64_t splitedAxis, const std::vector& splitLengths); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/add_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/add_function.cpp index 56aadb2a2498e0..438af17ff92680 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/add_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/add_function.cpp @@ -152,11 +152,11 @@ std::shared_ptr AddFunction::getOriginal( std::shared_ptr AddFunction::getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const bool broadcast, const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData1, const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData2) { - ngraph::Shape inputShape2 = inputShape; + ngraph::PartialShape inputShape2 = inputShape; if (broadcast) { inputShape2[2] = 1; diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/avg_pool_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/avg_pool_function.cpp index cf22df3b01badf..ea3bccd1322107 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/avg_pool_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/avg_pool_function.cpp @@ -62,9 +62,9 @@ std::shared_ptr AvgPoolFunction::getOriginal( std::shared_ptr AvgPoolFunction::getOriginal( const ngraph::element::Type originalFunctionPrecision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const FakeQuantizeOnData& fakeQuantizeOnData) { - const auto input = std::make_shared(originalFunctionPrecision, ngraph::Shape(inputShape)); + const auto input = std::make_shared(originalFunctionPrecision, inputShape); const auto fakeQuantize = ngraph::builder::makeFakeQuantize( input, originalFunctionPrecision, fakeQuantizeOnData.quantizationLevel, fakeQuantizeOnData.constantShape, diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/clamp_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/clamp_function.cpp index d61d9dbc359b42..cddaa740283bda 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/clamp_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/clamp_function.cpp @@ -33,7 +33,7 @@ std::shared_ptr ClampFunction::getOriginal( std::shared_ptr ClampFunction::getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize, const double clampLowConst, const double clampHighConst) { diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/concat_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/concat_function.cpp index 257f5535095140..1b5a9d863a3fe4 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/concat_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/concat_function.cpp @@ -20,15 +20,15 @@ using namespace ngraph::pass; std::shared_ptr ConcatFunction::getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const FakeQuantizeOnData& fqOnData1, const FakeQuantizeOnData& fqOnData2) { const auto input1 = std::make_shared(precision, inputShape); input1->set_friendly_name("input1"); const auto fakeQuantize1 = makeFakeQuantize(input1, precision, fqOnData1); - const std::vector inputShape2 = inputShape; - const auto input2 = std::make_shared(precision, ngraph::Shape(inputShape2)); + const auto inputShape2 = inputShape; + const auto input2 = std::make_shared(precision, inputShape2); input2->set_friendly_name("input2"); const auto fakeQuantize2 = makeFakeQuantize(input2, precision, fqOnData2); @@ -79,7 +79,7 @@ std::shared_ptr ConcatFunction::getOriginal( std::shared_ptr ConcatFunction::getOriginalWithChildAndOutput( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const FakeQuantizeOnData& fqOnData1, const FakeQuantizeOnData& fqOnData2) { const auto input1 = std::make_shared(precision, inputShape); @@ -87,8 +87,8 @@ std::shared_ptr ConcatFunction::getOriginalWithChildAndOutput( const auto fakeQuantize1 = makeFakeQuantize(input1, precision, fqOnData1); std::shared_ptr res1; - const std::vector inputShape2 = inputShape; - const auto input2 = std::make_shared(precision, ngraph::Shape(inputShape2)); + const auto inputShape2 = inputShape; + const auto input2 = std::make_shared(precision, inputShape2); input2->set_friendly_name("input2"); const auto fakeQuantize2 = makeFakeQuantize(input2, precision, fqOnData2); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/convolution_backprop_data_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/convolution_backprop_data_function.cpp index 8e78c677819e54..2e841c399d9deb 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/convolution_backprop_data_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/convolution_backprop_data_function.cpp @@ -24,7 +24,7 @@ namespace subgraph { std::shared_ptr ConvolutionBackpropDataFunction::get( const element::Type netPrecision, - const Shape& inputShape, + const PartialShape& inputShape, const Shape& outputShape, const builder::subgraph::FakeQuantizeOnData& fqOnData, const std::shared_ptr& weights) { diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/convolution_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/convolution_function.cpp index ea42797a427465..2295010e12bd57 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/convolution_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/convolution_function.cpp @@ -122,20 +122,20 @@ std::shared_ptr ConvolutionFunction::getOriginalWithIncorrectW } std::shared_ptr ConvolutionFunction::getOriginalWithIncorrectWeights( - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, ngraph::element::Type precision, ngraph::builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights, ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantizeOnData, bool isCorrect) { - const auto input = std::make_shared(precision, ngraph::Shape(inputShape)); + const auto input = std::make_shared(precision, inputShape); const auto fqOnData = fakeQuantizeOnData.empty() ? nullptr : ngraph::builder::makeFakeQuantize( input, precision, fakeQuantizeOnData.quantizationLevel, fakeQuantizeOnData.constantShape, fakeQuantizeOnData.inputLowValues, fakeQuantizeOnData.inputHighValues, fakeQuantizeOnData.outputLowValues, fakeQuantizeOnData.outputHighValues); - const size_t inputChannelsCount = inputShape[1]; - const size_t outputChannelsCount = 2 * inputShape[1]; + const size_t inputChannelsCount = inputShape[1].get_length(); + const size_t outputChannelsCount = 2 * inputShape[1].get_length(); const auto weights = ngraph::opset1::Constant::create( precision, ngraph::Shape{ outputChannelsCount, inputChannelsCount, 1, 1 }, diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/depth_to_space_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/depth_to_space_function.cpp index 8eb721f23dfdbd..6ec71836c8e696 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/depth_to_space_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/depth_to_space_function.cpp @@ -13,7 +13,7 @@ namespace subgraph { std::shared_ptr DepthToSpaceFunction::getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ngraph::opset1::DepthToSpace::DepthToSpaceMode mode, const size_t blockSize) { const float low = 0.f; diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_and_convolution_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_and_convolution_function.cpp index a70b40ff74d93a..88b70645bd7f0c 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_and_convolution_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_and_convolution_function.cpp @@ -16,19 +16,19 @@ namespace subgraph { // TODO: remove, reuse mode extended method std::shared_ptr FakeQuantizeAndConvolutionFunction::get( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const FakeQuantizeOnData& fqOnData, const FakeQuantizeOnWeights& fqOnWeights) { - const auto input = std::make_shared(precision, ngraph::Shape(inputShape)); + const auto input = std::make_shared(precision, inputShape); const auto fakeQuantizeOnActivations = fqOnData.empty() ? nullptr : ngraph::builder::makeFakeQuantize( input, precision, fqOnData.quantizationLevel, fqOnData.constantShape, fqOnData.inputLowValues, fqOnData.inputHighValues, fqOnData.outputLowValues, fqOnData.outputHighValues); - const size_t inputChannelsCount = inputShape[1]; - const size_t outputChannelsCount = 2 * inputShape[1]; + const size_t inputChannelsCount = inputShape[1].get_length(); + const size_t outputChannelsCount = 2 * inputShape[1].get_length(); const auto weights = ngraph::opset1::Constant::create( precision, ngraph::Shape{ outputChannelsCount, inputChannelsCount, 1, 1 }, diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_and_two_output_branches_with_convolution_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_and_two_output_branches_with_convolution_function.cpp index 650e88b698c732..c2283e33fd45ca 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_and_two_output_branches_with_convolution_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_and_two_output_branches_with_convolution_function.cpp @@ -16,12 +16,12 @@ namespace subgraph { std::shared_ptr createConvolution( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const std::shared_ptr& parent, const FakeQuantizeOnWeights& fqOnWeights, bool typeRelaxed) { - const size_t inputChannelsCount = inputShape[1]; - const size_t outputChannelsCount = 2 * inputShape[1]; + const size_t inputChannelsCount = inputShape[1].get_length(); + const size_t outputChannelsCount = 2 * inputShape[1].get_length(); const auto weights = ngraph::opset1::Constant::create( precision, ngraph::Shape{ outputChannelsCount, inputChannelsCount, 1, 1 }, @@ -56,7 +56,7 @@ std::shared_ptr createConvolution( std::shared_ptr FakeQuantizeAndTwoOutputBranchesWithConvolutionFunction::getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const FakeQuantizeOnData& fqOnData, const FakeQuantizeOnWeights fqOnWeights1, FakeQuantizeOnWeights fqOnWeights2) { diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_function.cpp index 40554f46d65ae4..e7ab4fe73ba139 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_function.cpp @@ -22,9 +22,9 @@ using namespace ngraph::pass; std::shared_ptr FakeQuantizeFunction::getOriginalWithMaxPool( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const FakeQuantizeOnData& fakeQuantizeOnData) { - const auto input = std::make_shared(precision, ngraph::Shape(inputShape)); + const auto input = std::make_shared(precision, inputShape); input->set_friendly_name("input"); const auto fakeQuantize = ngraph::builder::makeFakeQuantize( diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_precision_selection_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_precision_selection_function.cpp index 20c71967588250..cb645f11401e3a 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_precision_selection_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_precision_selection_function.cpp @@ -18,9 +18,9 @@ using namespace ngraph::pass; std::shared_ptr FakeQuantizePrecisionSelectionFunction::getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ActualValues& values) { - const auto input = std::make_shared(precision, ngraph::Shape(inputShape)); + const auto input = std::make_shared(precision, inputShape); input->set_friendly_name("input"); std::shared_ptr parent = input; @@ -48,8 +48,8 @@ std::shared_ptr FakeQuantizePrecisionSelectionFunction::getOri std::make_shared(element::f32, Shape{}, std::vector{ 0.01 })), element::f32); - const size_t inputChannelsCount = inputShape[1]; - const size_t outputChannelsCount = 2 * inputShape[1]; + const size_t inputChannelsCount = inputShape[1].get_length(); + const size_t outputChannelsCount = 2 * inputShape[1].get_length(); const auto weights = ngraph::opset1::Constant::create( precision, diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fuse_convert_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fuse_convert_function.cpp index f4f4721267bf07..09f6577e6ccbdc 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fuse_convert_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fuse_convert_function.cpp @@ -40,18 +40,18 @@ std::shared_ptr FuseConvertFunction::get( } std::shared_ptr FuseConvertFunction::getWithFQ( - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ngraph::element::Type inputPrecision, const ngraph::builder::subgraph::DequantizationOperations& dequantization, const bool constInput) { std::shared_ptr parent; std::shared_ptr input1; if (constInput) { - parent = std::make_shared(inputPrecision, inputShape, std::vector{ 128.f }); + parent = std::make_shared(inputPrecision, inputShape.to_shape(), std::vector{ 128.f }); } else { input1 = std::make_shared( inputPrecision, - ngraph::Shape(inputShape)); + inputShape); parent = input1; } auto deqStructure = dequantization; @@ -60,7 +60,7 @@ std::shared_ptr FuseConvertFunction::getWithFQ( std::shared_ptr input2 = std::make_shared( inputPrecision, - ngraph::Shape(inputShape)); + inputShape); const auto fakeQuantizeOnActivations = ngraph::builder::makeFakeQuantize( input2, inputPrecision, 256ul, { 1ul }, diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fuse_fake_quantize_and_scale_shift_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fuse_fake_quantize_and_scale_shift_function.cpp index 6bb28eff007053..48126da8baf153 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fuse_fake_quantize_and_scale_shift_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fuse_fake_quantize_and_scale_shift_function.cpp @@ -15,9 +15,9 @@ using namespace ngraph::pass; std::shared_ptr FuseFakeQuantizeAndScaleShiftFunction::getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const FakeQuantizeOnData& fakeQuantizeOnData) { - const auto input = std::make_shared(precision, ngraph::Shape(inputShape)); + const auto input = std::make_shared(precision, inputShape); input->set_friendly_name("input"); const std::shared_ptr fakeQuantize = ngraph::builder::makeFakeQuantize( diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fuse_fake_quantize_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fuse_fake_quantize_function.cpp index 0ba9bdc5fd9725..9befe4588580cb 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fuse_fake_quantize_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fuse_fake_quantize_function.cpp @@ -86,7 +86,7 @@ std::shared_ptr FuseFakeQuantizeFunction::getOriginal( } std::shared_ptr FuseFakeQuantizeFunction::get( - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const std::vector& branches, const ngraph::element::Type precisionFqOnData, const FakeQuantizeOnData& fqOnData) { @@ -101,7 +101,7 @@ std::shared_ptr FuseFakeQuantizeFunction::get( ngraph::ParameterVector inputs; std::vector> lastDequantizations; for (const Branch& branch : branches) { - const auto input = std::make_shared(branch.precisionBeforeDequantization, ngraph::Shape(inputShape)); + const auto input = std::make_shared(branch.precisionBeforeDequantization, inputShape); inputs.push_back(input); const std::shared_ptr lastDequantization = makeDequantization(input, branch.dequantization); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/group_convolution_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/group_convolution_function.cpp index 5d41f680410e5e..6946e6219b1820 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/group_convolution_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/group_convolution_function.cpp @@ -129,13 +129,13 @@ std::shared_ptr GroupConvolutionFunction::getOriginal( std::shared_ptr GroupConvolutionFunction::getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ngraph::Shape& outputShape, const size_t groupCount, const int groupCalculationDimention, const FakeQuantizeOnData& fakeQuantizeOnData, const FakeQuantizeOnWeights& fakeQuantizeOnWeights) { - const auto input = std::make_shared(precision, ngraph::Shape(inputShape)); + const auto input = std::make_shared(precision, inputShape); std::shared_ptr fakeQuantizeOnActivations; if (fakeQuantizeOnData.empty()) { @@ -154,7 +154,7 @@ std::shared_ptr GroupConvolutionFunction::getOriginal( //const size_t groupCount = 3ul; const size_t outputChannelsCount = outputShape[1]; const size_t kernelSize = 5ul; - const size_t inputChannelsCount = inputShape[1]; + const size_t inputChannelsCount = inputShape[1].get_length(); std::vector weightsValues = { 1.f }; std::shared_ptr weights = createWeightsOriginal( diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/interpolate_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/interpolate_function.cpp index ba4491cb5d0e51..96a6782441db93 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/interpolate_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/interpolate_function.cpp @@ -30,7 +30,7 @@ std::shared_ptr InterpolateFunction::getOriginal( std::shared_ptr InterpolateFunction::getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ngraph::Shape& outputShape, const ngraph::op::InterpolateAttrs& interpAttrs) { float k = 50.f; diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/mat_mul_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/mat_mul_function.cpp index e4e6c55472c408..a1004ad01c9cf7 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/mat_mul_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/mat_mul_function.cpp @@ -19,16 +19,16 @@ namespace subgraph { std::shared_ptr MatMulFunction::getOriginal( const ngraph::element::Type precision, - const ngraph::Shape inputShape, + const ngraph::PartialShape inputShape, const float low, const float high) { - const auto input1 = std::make_shared(precision, ngraph::Shape(inputShape)); + const auto input1 = std::make_shared(precision, inputShape); const auto fakeQuantize1 = ngraph::builder::makeFakeQuantize( input1, precision, 256ul, { 1ul }, { low / 4.f }, { high / 4.f }, { low / 4.f }, { high / 4.f }); fakeQuantize1->set_friendly_name("fakeQuantize1"); - const auto input2 = std::make_shared(precision, ngraph::Shape(inputShape)); + const auto input2 = std::make_shared(precision, inputShape); const auto fakeQuantize2 = ngraph::builder::makeFakeQuantize( input2, precision, 256ul, { 1ul }, { low / 8.f }, { high / 8.f }, { low / 8.f }, { high / 8.f }); @@ -51,12 +51,12 @@ std::shared_ptr MatMulFunction::getOriginal( std::shared_ptr MatMulFunction::getOriginal( const ngraph::element::Type precision, - const ngraph::Shape inputShape1, - const ngraph::Shape inputShape2, + const ngraph::PartialShape inputShape1, + const ngraph::PartialShape inputShape2, const bool transpose1, const bool transpose2) { const auto paramNode = std::make_shared(precision, inputShape1); - const std::vector constShapes(inputShape1.size(), 1ul); + const std::vector constShapes(inputShape1.rank().get_length(), 1ul); const auto fakeQuantizeOnAcitvations = ngraph::builder::makeFakeQuantize( paramNode, precision, 256ul, constShapes, { 0.f }, { 255.f / 4.f }, { 0.f }, { 255.f / 4.f }); @@ -64,7 +64,7 @@ std::shared_ptr MatMulFunction::getOriginal( auto weightsConst = std::make_shared( precision, - inputShape2, + inputShape2.to_shape(), std::vector({ 1.f })); const auto fakeQuantizeOnWeights = ngraph::builder::makeFakeQuantize( weightsConst, precision, 256ul, { 1ul, 1ul }, @@ -298,7 +298,7 @@ std::shared_ptr MatMulFunction::getReference( std::shared_ptr MatMulFunction::getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const FakeQuantizeOnDataWithConstant& fqOnData, const Constant& weights, const FakeQuantizeOnDataWithConstant& fqOnWeights, diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/mat_mul_with_optimized_constant_fake_quantize_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/mat_mul_with_optimized_constant_fake_quantize_function.cpp index 066eeb8226bfc9..2522a2a18764e3 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/mat_mul_with_optimized_constant_fake_quantize_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/mat_mul_with_optimized_constant_fake_quantize_function.cpp @@ -13,11 +13,11 @@ namespace subgraph { std::shared_ptr MatMulWithOptimizedConstantFakeQuantizeFunction::getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape1, - const ngraph::Shape& inputShape2, + const ngraph::PartialShape& inputShape1, + const ngraph::PartialShape& inputShape2, const FakeQuantizeOnData& fqOnData, const FakeQuantizeOnData& fqOnWeights) { - const auto input = std::make_shared(precision, ngraph::Shape(inputShape1)); + const auto input = std::make_shared(precision, inputShape1); const auto lowConstantOnActivations = std::make_shared(precision, fqOnData.constantShape, fqOnData.inputLowValues); const auto highConstantOnActivations = std::make_shared(precision, fqOnData.constantShape, fqOnData.inputHighValues); @@ -29,7 +29,7 @@ std::shared_ptr MatMulWithOptimizedConstantFakeQuantizeFunctio highConstantOnActivations, fqOnWeights.quantizationLevel); - const ngraph::Shape weightsShape = { inputShape2[0], inputShape1[1] }; + const ngraph::Shape weightsShape = { static_cast(inputShape2[0].get_length()), static_cast(inputShape1[1].get_length()) }; const std::vector weigths(weightsShape[0] * weightsShape[1], 10.f); const auto weightsConst = std::make_shared(precision, weightsShape, weigths); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/max_pool_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/max_pool_function.cpp index 3a010e011d8b1b..8132d4cfec2d8f 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/max_pool_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/max_pool_function.cpp @@ -16,9 +16,9 @@ namespace subgraph { std::shared_ptr MaxPoolFunction::getOriginal( const ngraph::element::Type originalFunctionPrecision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const FakeQuantizeOnData& fakeQuantizeOnData) { - const auto input = std::make_shared(originalFunctionPrecision, ngraph::Shape(inputShape)); + const auto input = std::make_shared(originalFunctionPrecision, inputShape); const auto fakeQuantize = ngraph::builder::makeFakeQuantize( input, originalFunctionPrecision, fakeQuantizeOnData.quantizationLevel, fakeQuantizeOnData.constantShape, diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/multiply_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/multiply_function.cpp index af50d3717e7171..1d36d0f8e3576a 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/multiply_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/multiply_function.cpp @@ -94,11 +94,11 @@ std::shared_ptr MultiplyFunction::get( std::shared_ptr MultiplyFunction::getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const bool broadcast, const ngraph::builder::subgraph::FakeQuantizeOnData& fq1, const ngraph::builder::subgraph::FakeQuantizeOnData& fq2) { - ngraph::Shape inputShape2 = inputShape; + auto inputShape2 = inputShape; if (broadcast) { inputShape2[2] = 1; diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/multiply_to_group_convolution_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/multiply_to_group_convolution_function.cpp index 4ae1873092f19d..e86d74ee7c7048 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/multiply_to_group_convolution_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/multiply_to_group_convolution_function.cpp @@ -37,13 +37,13 @@ std::shared_ptr MultiplyToGroupConvolutionFunction::getOrigina std::shared_ptr MultiplyToGroupConvolutionFunction::getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const FakeQuantizeOnData& fqOnData) { const auto input = std::make_shared(precision, inputShape); const auto fakeQuantizeOnActivations = makeFakeQuantize(input, precision, fqOnData); const auto reshape = std::make_shared( fakeQuantizeOnActivations, - std::make_shared(element::i32, Shape{ inputShape.size() }, inputShape), + std::make_shared(element::i32, Shape{ static_cast(inputShape.rank().get_length()) }, inputShape.to_shape()), true); reshape->set_friendly_name("output"); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/multiply_with_one_parent_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/multiply_with_one_parent_function.cpp index f23b0e6d66f80d..9cbeb8f2abdae1 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/multiply_with_one_parent_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/multiply_with_one_parent_function.cpp @@ -13,9 +13,9 @@ namespace subgraph { std::shared_ptr MultiplyWithOneParentFunction::getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const FakeQuantizeOnData& fqOnData) { - const auto input = std::make_shared(precision, ngraph::Shape(inputShape)); + const auto input = std::make_shared(precision, inputShape); const auto fakeQuantize = ngraph::builder::makeFakeQuantize( input, precision, fqOnData.quantizationLevel, fqOnData.constantShape, diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/mvn_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/mvn_function.cpp index 5820582492fcbf..b18ce6557115d3 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/mvn_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/mvn_function.cpp @@ -45,7 +45,7 @@ std::shared_ptr MVNFunction::getOriginal( std::shared_ptr MVNFunction::getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const AxisSet& reductionAxes, const bool& normalizeVariance) { float k = 50.f; diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/normalize_l2_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/normalize_l2_function.cpp index cd0a05e13718ce..693a042115ddeb 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/normalize_l2_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/normalize_l2_function.cpp @@ -16,7 +16,7 @@ namespace subgraph { std::shared_ptr NormalizeL2Function::getOriginal( const ngraph::element::Type precision, - const std::pair& shapes, + const std::pair& shapes, const ngraph::element::Type precisionOnActivation, const std::vector& axes, const bool fuseMultiply, @@ -43,8 +43,11 @@ std::shared_ptr NormalizeL2Function::getOriginal( ngraph::ResultVector results; if (fuseMultiply) { - const auto multiplyConst = std::make_shared( - precision, ngraph::Shape{ shapes.first[0], shapes.first[1], 1ul, 1ul }, std::vector{ 2.f }); + ngraph::Shape constantShape(4ul, 1ul); + constantShape[0] = shapes.first[0].get_length(); + constantShape[1] = shapes.first[1].get_length(); + + const auto multiplyConst = std::make_shared(precision, constantShape, std::vector{ 2.f }); multiplyConst->set_friendly_name("multiplyConst"); const auto multiply = std::make_shared(normalizeL2->output(0), multiplyConst); multiply->set_friendly_name("output"); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/prelu_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/prelu_function.cpp index f962d60e010806..aefbfe3c0cfe67 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/prelu_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/prelu_function.cpp @@ -32,12 +32,10 @@ std::shared_ptr PReluFunction::getOriginal( } std::shared_ptr PReluFunction::getOriginal( - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ngraph::element::Type precisionBeforeFq, const FakeQuantizeOnData& fqOnData) { - const std::shared_ptr input = std::make_shared( - precisionBeforeFq, - ngraph::Shape(inputShape)); + const auto input = std::make_shared(precisionBeforeFq, inputShape); const std::shared_ptr quantizationOp = fqOnData.empty() ? std::dynamic_pointer_cast(input) : diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/relu_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/relu_function.cpp index 4a3c5a0e3415d8..f7690715879f11 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/relu_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/relu_function.cpp @@ -30,12 +30,10 @@ std::shared_ptr ReluFunction::getOriginal( } std::shared_ptr ReluFunction::getOriginal( - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ngraph::element::Type precisionBeforeFq, const FakeQuantizeOnData& fqOnData) { - const std::shared_ptr input = std::make_shared( - precisionBeforeFq, - ngraph::Shape(inputShape)); + const auto input = std::make_shared(precisionBeforeFq, inputShape); const std::shared_ptr quantizationOp = fqOnData.empty() ? std::dynamic_pointer_cast(input) : diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/reshape_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/reshape_function.cpp index a425d0ddfa1f8d..e03dae4b27af42 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/reshape_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/reshape_function.cpp @@ -31,13 +31,11 @@ std::shared_ptr ReshapeFunction::getOriginal( } std::shared_ptr ReshapeFunction::getOriginal( - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const std::vector& reshapeConstValues, const ngraph::element::Type precisionBeforeFq, const FakeQuantizeOnData& fqOnData) { - const auto input = std::make_shared( - precisionBeforeFq, - ngraph::Shape(inputShape)); + const auto input = std::make_shared(precisionBeforeFq, inputShape); const std::shared_ptr quantizationOp = fqOnData.empty() ? std::dynamic_pointer_cast(input) : diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/shuffle_channels_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/shuffle_channels_function.cpp index ab77765b47be18..7884372138c8da 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/shuffle_channels_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/shuffle_channels_function.cpp @@ -35,7 +35,7 @@ std::shared_ptr ShuffleChannelsFunction::getOriginal( std::shared_ptr ShuffleChannelsFunction::getOriginal( const ngraph::element::Type inputPrecision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData, const std::int64_t axis, const std::int64_t group) { diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/split_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/split_function.cpp index 641555d971874b..044c490c3c6eb2 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/split_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/split_function.cpp @@ -48,7 +48,7 @@ std::shared_ptr SplitFunction::getOriginal( std::shared_ptr SplitFunction::getOriginal( const ngraph::element::Type originalFunctionPrecision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize, int64_t splitedAxis, size_t numSplit) { const auto input = std::make_shared(originalFunctionPrecision, inputShape); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/squeeze_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/squeeze_function.cpp index d584f2c64c604b..3799349f7731cb 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/squeeze_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/squeeze_function.cpp @@ -33,10 +33,10 @@ std::shared_ptr SqueezeFunction::getOriginal( std::shared_ptr SqueezeFunction::getOriginal( const ngraph::element::Type originalFunctionPrecision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const FakeQuantizeOnData& fakeQuantizeOnData, const std::vector& axes) { - const auto input = std::make_shared(originalFunctionPrecision, ngraph::Shape(inputShape)); + const auto input = std::make_shared(originalFunctionPrecision, inputShape); const auto fakeQuantize = fakeQuantizeOnData.empty() ? nullptr : diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/strided_slice_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/strided_slice_function.cpp index b12019355c1ff9..aa2e5421b62605 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/strided_slice_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/strided_slice_function.cpp @@ -54,7 +54,7 @@ std::shared_ptr StridedSliceFunction::getOriginal( std::shared_ptr StridedSliceFunction::getOriginal( const ngraph::element::Type inputPrecision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ngraph::builder::subgraph::FakeQuantizeOnData& fakeQuantize, const std::vector& begin, const std::vector& end, diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/subtract_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/subtract_function.cpp index c90d774a042d81..cf2726ac7767d2 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/subtract_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/subtract_function.cpp @@ -16,18 +16,19 @@ namespace builder { namespace subgraph { std::shared_ptr SubtractFunction::getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape) { + const ngraph::PartialShape& inputShape) { const float k = 50.f; - const auto input = std::make_shared(precision, ngraph::Shape(inputShape)); + const auto input = std::make_shared(precision, inputShape); const auto fakeQuantizeOnActivations = ngraph::builder::makeFakeQuantize( input, precision, 256ul, { 1ul }, { 0.f }, { 255.f / k }, { 0.f }, { 255.f / k }); + const size_t channelsValue = inputShape[1].get_length(); const auto weights = ngraph::opset1::Constant::create( precision, - ngraph::Shape{ inputShape[1], inputShape[1], 1, 1 }, - std::vector(inputShape[1] * inputShape[1], 1)); + ngraph::Shape{ channelsValue, channelsValue, 1, 1 }, + std::vector(channelsValue * channelsValue, 1)); const auto convolution = std::make_shared( fakeQuantizeOnActivations == nullptr ? input : fakeQuantizeOnActivations, diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/subtract_multiply_to_multiply_add_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/subtract_multiply_to_multiply_add_function.cpp index 9317d199be24ec..d34ed6198fb47b 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/subtract_multiply_to_multiply_add_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/subtract_multiply_to_multiply_add_function.cpp @@ -30,13 +30,10 @@ std::shared_ptr SubtractMultiplyToMultiplyAddFunction::getOrig } std::shared_ptr SubtractMultiplyToMultiplyAddFunction::getOriginal( - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ngraph::element::Type precision, const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData) { - const std::shared_ptr input = std::make_shared( - precision, - ngraph::Shape(inputShape)); - + const auto input = std::make_shared(precision, inputShape); const std::shared_ptr fq = makeFakeQuantize(input, precision, fqOnData); const std::shared_ptr reshape1 = std::make_shared( @@ -44,12 +41,12 @@ std::shared_ptr SubtractMultiplyToMultiplyAddFunction::getOrig std::make_shared( ngraph::element::i64, Shape({ 3 }), - std::vector({ static_cast(inputShape[0]), static_cast(inputShape[1]), -1 })), + std::vector({ inputShape[0].get_length(), inputShape[1].get_length(), -1 })), false); const std::shared_ptr reshape2 = std::make_shared( reshape1, - std::make_shared(ngraph::element::i64, Shape({ 4 }), inputShape), + std::make_shared(ngraph::element::i64, Shape({ 4 }), inputShape.to_shape()), false); ngraph::ResultVector results{ std::make_shared(reshape2) }; diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/transpose_after_mat_mul_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/transpose_after_mat_mul_function.cpp index 4e698c7908b9c7..250f5de0c07174 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/transpose_after_mat_mul_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/transpose_after_mat_mul_function.cpp @@ -16,7 +16,7 @@ namespace builder { namespace subgraph { std::shared_ptr TransposeAfterMatMulFunction::getOriginal( const ngraph::element::Type precision, - const ngraph::Shape& inputShape) { + const ngraph::PartialShape& inputShape) { const auto input1 = std::make_shared(precision, inputShape); input1->set_friendly_name("input1"); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/transpose_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/transpose_function.cpp index ea02fbe0bebcdb..892cb19f2316ca 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/transpose_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/transpose_function.cpp @@ -30,13 +30,11 @@ std::shared_ptr TransposeFunction::getOriginal( } std::shared_ptr TransposeFunction::getOriginal( - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const std::vector& transposeConstValues, const ngraph::element::Type precisionBeforeFq, const FakeQuantizeOnData& fqOnData) { - const std::shared_ptr input = std::make_shared( - precisionBeforeFq, - ngraph::Shape(inputShape)); + const auto input = std::make_shared(precisionBeforeFq, inputShape); const std::shared_ptr quantizationOp = fqOnData.empty() ? std::dynamic_pointer_cast(input) : diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/unsqueeze_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/unsqueeze_function.cpp index b272acf01e23b6..7b2928717945d4 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/unsqueeze_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/unsqueeze_function.cpp @@ -33,10 +33,10 @@ namespace subgraph { std::shared_ptr UnsqueezeFunction::getOriginal( const ngraph::element::Type originalFunctionPrecision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const FakeQuantizeOnData& fakeQuantizeOnData, const std::vector& axes) { - const auto input = std::make_shared(originalFunctionPrecision, ngraph::Shape(inputShape)); + const auto input = std::make_shared(originalFunctionPrecision, inputShape); const auto fakeQuantize = fakeQuantizeOnData.empty() ? nullptr : diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/variadic_split_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/variadic_split_function.cpp index c60acbbb237595..a9ffe853d8e8b5 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/variadic_split_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/variadic_split_function.cpp @@ -37,7 +37,7 @@ namespace subgraph { std::shared_ptr VariadicSplitFunction::getOriginal( const ngraph::element::Type originalFunctionPrecision, - const ngraph::Shape& inputShape, + const ngraph::PartialShape& inputShape, const ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize, const int64_t splitedAxis, const std::vector& splitLengths) { diff --git a/inference-engine/tests/ngraph_helpers/ngraph_functions/include/ngraph_functions/builders.hpp b/inference-engine/tests/ngraph_helpers/ngraph_functions/include/ngraph_functions/builders.hpp index 3ed4058808a87a..d1e94b78f1eb06 100644 --- a/inference-engine/tests/ngraph_helpers/ngraph_functions/include/ngraph_functions/builders.hpp +++ b/inference-engine/tests/ngraph_helpers/ngraph_functions/include/ngraph_functions/builders.hpp @@ -14,6 +14,7 @@ #include #include #include +#include #include "ngraph_functions/utils/data_utils.hpp" diff --git a/inference-engine/tests/ngraph_helpers/ngraph_functions/include/ngraph_functions/utils/ngraph_helpers.hpp b/inference-engine/tests/ngraph_helpers/ngraph_functions/include/ngraph_functions/utils/ngraph_helpers.hpp index de2dbab061289d..47405a8e51c4f5 100644 --- a/inference-engine/tests/ngraph_helpers/ngraph_functions/include/ngraph_functions/utils/ngraph_helpers.hpp +++ b/inference-engine/tests/ngraph_helpers/ngraph_functions/include/ngraph_functions/utils/ngraph_helpers.hpp @@ -100,6 +100,7 @@ enum ActivationTypes { Negative, Acos, Asin, + Asinh, Atan, Cos, Cosh, diff --git a/inference-engine/tests/ngraph_helpers/ngraph_functions/src/activation.cpp b/inference-engine/tests/ngraph_helpers/ngraph_functions/src/activation.cpp index 97dea94963aad8..d8dce877b0f1df 100644 --- a/inference-engine/tests/ngraph_helpers/ngraph_functions/src/activation.cpp +++ b/inference-engine/tests/ngraph_helpers/ngraph_functions/src/activation.cpp @@ -48,6 +48,8 @@ std::shared_ptr makeActivation(const ngraph::Output &in, return std::make_shared(in); case ngraph::helpers::ActivationTypes::Asin: return std::make_shared(in); + case ngraph::helpers::ActivationTypes::Asinh: + return std::make_shared(in); case ngraph::helpers::ActivationTypes::Atan: return std::make_shared(in); case ngraph::helpers::ActivationTypes::Cos: diff --git a/inference-engine/tests/unit/gna/ngraph/transformations/gna_convert_padded2valid_conv.cpp b/inference-engine/tests/unit/gna/ngraph/transformations/gna_convert_padded2valid_conv.cpp new file mode 100644 index 00000000000000..b8259bf3d848f9 --- /dev/null +++ b/inference-engine/tests/unit/gna/ngraph/transformations/gna_convert_padded2valid_conv.cpp @@ -0,0 +1,453 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include + +#include "transformations/convert_padded2valid_conv.hpp" +#include "common_test_utils/ngraph_test_utils.hpp" +#include +#include +#include +#include + +namespace testing { + +namespace { + +enum class modelType { + TranspConvTransp = 0, /* Transpose(NHWC->NCHW) => Conv => Transpose(NCHW->NHWC) */ + TranspConvBcastAddTransp, /* Transpose(NHWC->NCHW) => Conv => Broadcasted Add (Bias) => Transpose(NCHW->NHWC) */ + TranspConvBcastAddMaxPoolTransp, /* Transpose(NHWC->NCHW) => Conv => Broadcasted Add (Bias) => MaxPooling => Transpose(NCHW->NHWC) (2D Max Pool case) */ + TranspConvBcastAddActTransp, /* Transpose(NHWC->NCHW) => Conv => Broadcasted Add (Bias) => Activation Function => Transpose(NCHW->NHWC) */ + TranspConvBcastAddMaxPoolActTransp, /* Transpose(NHWC->NCHW) => Conv => Broadcasted Add (Bias) => MaxPool => Activation Function => Transpose(NCHW->NHWC) */ + TranspConvTranspBcastAdd, /* Transpose(NHWC->NCHW) => conv => Transpose(NCHW->NHWC) => Bias */ + TranspConvTranspBcastAddAct /* Transpose(NHWC->NCHW) => Conv => Transpose(NCHW->NHWC) => Bias => Activation Function */ +}; + +struct ConvData { + size_t input_height; + size_t input_width; + size_t input_channel_count; + size_t pads_begin_width; + size_t pads_begin_height; + size_t pads_end_width; + size_t pads_end_height; +}; + +void GetConvParams(std::shared_ptr conv, ConvData& conv_data) { + conv_data.input_channel_count = conv->input_value(0).get_shape()[1]; + conv_data.input_height = conv->input_value(0).get_shape()[2]; + conv_data.input_width = conv->input_value(0).get_shape()[3]; + conv_data.pads_begin_height = conv->get_pads_begin()[0]; + conv_data.pads_begin_width = conv->get_pads_begin()[1]; + conv_data.pads_end_height = conv->get_pads_end()[0]; + conv_data.pads_end_width = conv->get_pads_end()[1]; +} + +std::shared_ptr createFunction(const modelType& model, + const ngraph::Output& input_node, + const ngraph::Shape& filters_shape, + const ngraph::Strides& conv_stride, + const ngraph::CoordinateDiff& pads_begin, + const ngraph::CoordinateDiff& pads_end, + const ngraph::Strides& conv_dilation, + const ngraph::Shape& bias_shape, + const ngraph::Strides& maxpool_stride, + const ngraph::Shape& maxpool_shape, + const ngraph::op::PadType& pad_type, + ConvData* conv_data) { + auto transpose_in_order = std::make_shared(ngraph::element::i64, ngraph::Shape{4}, ngraph::Shape{0, 3, 1, 2}); + auto transpose_in = std::make_shared(input_node, transpose_in_order); + auto filters = std::make_shared(ngraph::element::i64, + ngraph::Shape{4, input_node.get_shape()[3], filters_shape[0], filters_shape[1]}); + auto conv = std::make_shared(transpose_in, filters, conv_stride, pads_begin, pads_end, conv_dilation, pad_type); + if (conv_data) + GetConvParams(conv, *conv_data); + auto transpose_out_order = std::make_shared(ngraph::element::i64, ngraph::Shape{4}, ngraph::Shape{0, 2, 3, 1}); + auto bias_const = std::make_shared(ngraph::element::i64, bias_shape); + ngraph::Output last_op = std::make_shared(conv, transpose_out_order); + + switch (model) { + case modelType::TranspConvBcastAddTransp: + { + auto bcast_add = std::make_shared(conv, bias_const); + last_op = std::make_shared(bcast_add, transpose_out_order); + } + break; + + case modelType::TranspConvBcastAddMaxPoolTransp: + { + auto bcast_add = std::make_shared(conv, bias_const); + auto maxpool = std::make_shared(bcast_add, maxpool_stride, ngraph::Shape{0, 0}, ngraph::Shape{0, 0}, maxpool_shape, + ngraph::op::RoundingType::FLOOR, ngraph::op::PadType::VALID); + auto transpose = std::make_shared(maxpool, transpose_out_order); + last_op = std::make_shared(transpose); + } + break; + + case modelType::TranspConvBcastAddActTransp: + { + auto bcast_add = std::make_shared(conv, bias_const); + auto activation = std::make_shared(bcast_add); + last_op = std::make_shared(activation, transpose_out_order); + } + break; + + case modelType::TranspConvBcastAddMaxPoolActTransp: + { + auto bcast_add = std::make_shared(conv, bias_const); + auto maxpool = std::make_shared(bcast_add, maxpool_stride, ngraph::Shape{0, 0}, ngraph::Shape{0, 0}, maxpool_shape, + ngraph::op::RoundingType::FLOOR, ngraph::op::PadType::VALID); + auto activation = std::make_shared(maxpool); + last_op = std::make_shared(activation, transpose_out_order); + } + break; + + case modelType::TranspConvTranspBcastAdd: + { + last_op = std::make_shared(last_op, bias_const); + } + break; + + case modelType::TranspConvTranspBcastAddAct: + { + auto bcast_add = std::make_shared(last_op, bias_const); + last_op = std::make_shared(bcast_add); + } + break; + + case modelType::TranspConvTransp: + default: + break; + } + + return std::make_shared(last_op); +} + +std::shared_ptr get_initial_function(const modelType& model, + const ngraph::PartialShape& input_shape, + const ngraph::Shape& filters_shape, + const ngraph::Strides& conv_stride, + const ngraph::CoordinateDiff& pads_begin, + const ngraph::CoordinateDiff& pads_end, + const ngraph::Strides& conv_dilation, + const ngraph::Shape& bias_shape, + const ngraph::Strides& maxpool_stride, + const ngraph::Shape& maxpool_shape, + const ngraph::op::PadType& pad_type, + ConvData& conv_data) { + auto inputParams = std::make_shared(ngraph::element::i64, input_shape); + auto result = createFunction(model, inputParams, filters_shape, conv_stride, pads_begin, pads_end, conv_dilation, bias_shape, + maxpool_stride, maxpool_shape, pad_type, &conv_data); + return std::make_shared(ngraph::ResultVector{result}, ngraph::ParameterVector{inputParams}); +} + +// --------------------------------------------------------------------------------------------------------------------- + +class ConvertPadded2ValidConvTestInvalidFixture : public CommonTestUtils::TestsCommon, + public ::testing::WithParamInterface> { +public: + void SetUp() override; +public: + std::shared_ptr function, reference_function; + modelType model; +}; + +void ConvertPadded2ValidConvTestInvalidFixture::SetUp() { + ngraph::PartialShape input_shape; + ngraph::Shape filters_shape, bias_shape, maxpool_shape; + ngraph::Strides conv_stride, conv_dilation, maxpool_stride; + ngraph::CoordinateDiff pads_begin, pads_end; + ngraph::op::PadType pad_type; + ConvData conv_data; + std::tie(model, input_shape, filters_shape, conv_stride, pads_begin, pads_end, conv_dilation, + bias_shape, maxpool_stride, maxpool_shape, pad_type) = this->GetParam(); + + function = get_initial_function(model, input_shape, filters_shape, conv_stride, pads_begin, pads_end, conv_dilation, + bias_shape, maxpool_stride, maxpool_shape, pad_type, conv_data); + reference_function = get_initial_function(model, input_shape, filters_shape, conv_stride, pads_begin, pads_end, conv_dilation, + bias_shape, maxpool_stride, maxpool_shape, pad_type, conv_data); +} + +// --------------------------------------------------------------------------------------------------------------------- + +class ConvertPadded2ValidConvTestFixture: public CommonTestUtils::TestsCommon, + public ::testing::WithParamInterface> { +public: + void SetUp() override; + std::shared_ptr get_reference(const modelType& model, + const ngraph::PartialShape& input_shape, + const ngraph::Shape& filters_shape, + const ngraph::Strides& conv_stride, + const ngraph::CoordinateDiff& pads_begin, + const ngraph::CoordinateDiff& pads_end, + const ngraph::Strides& conv_dilation, + const ngraph::Shape& bias_shape, + const ngraph::Strides& maxpool_stride, + const ngraph::Shape& maxpool_shape, + const ngraph::op::PadType& pad_type, + const ConvData& conv_data); +public: + std::shared_ptr function, reference_function; + modelType model; +}; + +void ConvertPadded2ValidConvTestFixture::SetUp() { + ngraph::PartialShape input_shape; + ngraph::Shape filters_shape, bias_shape, maxpool_shape; + ngraph::Strides conv_stride, conv_dilation, maxpool_stride; + ngraph::CoordinateDiff pads_begin, pads_end; + ngraph::op::PadType pad_type; + ConvData conv_data; + std::tie(model, input_shape, filters_shape, conv_stride, pads_begin, pads_end, conv_dilation, + bias_shape, maxpool_stride, maxpool_shape, pad_type) = this->GetParam(); + + function = get_initial_function(model, input_shape, filters_shape, conv_stride, pads_begin, pads_end, conv_dilation, + bias_shape, maxpool_stride, maxpool_shape, pad_type, conv_data); + reference_function = get_reference(model, input_shape, filters_shape, conv_stride, pads_begin, pads_end, conv_dilation, + bias_shape, maxpool_stride, maxpool_shape, pad_type, conv_data); +} + +std::shared_ptr FlatCrop(ngraph::Output input, size_t offset, size_t size) { + return std::make_shared( + input, // data + ngraph::opset7::Constant::create(ngraph::element::i64, ngraph::Shape{2}, {(size_t)0, offset}), // begin sice index + ngraph::opset7::Constant::create(ngraph::element::i64, ngraph::Shape{2}, {(size_t)0, offset + size}), // end slice index + ngraph::opset7::Constant::create(ngraph::element::i64, ngraph::Shape{2}, {(size_t)1, (size_t)1}), // strides + std::vector{1, 0}, // begin mask + std::vector{1, 0}); // end mask +} + +void InsertPadding(ngraph::OutputVector& input_rows_to_concat, size_t size, + const std::shared_ptr padding_const, size_t biggest_padding) { + + if (size == biggest_padding) { + input_rows_to_concat.push_back(padding_const); + } else { + auto slice = FlatCrop(padding_const, 0, size); + input_rows_to_concat.push_back(slice); + } +} + +std::shared_ptr CreatePaddedNet(const ngraph::Output& input_node, + const ConvData& conv_data) { + size_t flat_left_padding = conv_data.input_channel_count * conv_data.pads_begin_width; + size_t flat_right_padding = conv_data.input_channel_count * conv_data.pads_end_width; + size_t padded_row_size = flat_left_padding + conv_data.input_channel_count * conv_data.input_width + flat_right_padding; + size_t flat_top_padding = padded_row_size * conv_data.pads_begin_height; + size_t flat_bottom_padding = padded_row_size * conv_data.pads_end_height; + size_t biggest_padding = std::max(std::max(flat_left_padding, flat_right_padding), std::max(flat_top_padding, flat_bottom_padding)); + + if (conv_data.input_height > 1 && (flat_top_padding > 1 || flat_bottom_padding > 1)) { + biggest_padding = biggest_padding > padded_row_size ? biggest_padding : padded_row_size; + } + + if (!biggest_padding) + return nullptr; + + auto flat_input = std::make_shared(input_node, + ngraph::opset7::Constant::create(ngraph::element::i64, ngraph::Shape{2}, + ngraph::Shape{1ull, shape_size(input_node.get_shape())}), false); + + // Constant with zero padding + auto const_holding_padding = std::make_shared(ngraph::element::i64, ngraph::Shape{1, biggest_padding}, 0); + + std::shared_ptr original_row = flat_input; + ngraph::OutputVector input_rows_to_concat; + + // Add top padding + for (size_t p = 0; p < conv_data.pads_begin_height; p++) { + InsertPadding(input_rows_to_concat, padded_row_size, const_holding_padding, biggest_padding); + } + + if (flat_left_padding || flat_right_padding) { + // Pad every row of input plain if neccessary + for (size_t h = 0; h < conv_data.input_height; h++) { + // left padding input right padding + // | | | + // +--------------+-----------+ + // | + // concat + + if (conv_data.input_height > 1) + original_row = FlatCrop(flat_input, h * conv_data.input_width * conv_data.input_channel_count, + conv_data.input_width * conv_data.input_channel_count); + + ngraph::OutputVector single_row_concat_inputs; + if (flat_left_padding) { + InsertPadding(single_row_concat_inputs, flat_left_padding, const_holding_padding, biggest_padding); + } + single_row_concat_inputs.push_back(original_row); + if (flat_right_padding) { + InsertPadding(single_row_concat_inputs, flat_right_padding, const_holding_padding, biggest_padding); + } + auto padded_row_concat = std::make_shared(single_row_concat_inputs, 1); + + input_rows_to_concat.push_back(padded_row_concat); + } + } else { + input_rows_to_concat.push_back(original_row); + } + + // Bottom padding + for (size_t p = 0; p < conv_data.pads_end_height; p++) { + InsertPadding(input_rows_to_concat, padded_row_size, const_holding_padding, biggest_padding); + } + + auto padded_input_plane = std::make_shared(input_rows_to_concat, 1); + return padded_input_plane; +} + +std::shared_ptr ConvertPadded2ValidConvTestFixture::get_reference(const modelType& model, + const ngraph::PartialShape& input_shape, + const ngraph::Shape& filters_shape, + const ngraph::Strides& conv_stride, + const ngraph::CoordinateDiff& pads_begin, + const ngraph::CoordinateDiff& pads_end, + const ngraph::Strides& conv_dilation, + const ngraph::Shape& bias_shape, + const ngraph::Strides& maxpool_stride, + const ngraph::Shape& maxpool_shape, + const ngraph::op::PadType& pad_type, + const ConvData& conv_data) { + auto inputParams = std::make_shared(ngraph::element::i64, input_shape); + + // Add padding where neccessary + + // padding + // padding + // ... row ... + // ... row ... + // ........... + // ... row ... + // padding + // padding + auto padded_input_plane = CreatePaddedNet(inputParams, conv_data); + std::shared_ptr result; + + if (padded_input_plane) { + auto shape_const = std::make_shared(ngraph::element::i64, ngraph::Shape{4}, + ngraph::Shape{static_cast(1), + conv_data.pads_begin_height + conv_data.input_height + conv_data.pads_end_height, + conv_data.pads_begin_width + conv_data.input_width + conv_data.pads_end_width, + conv_data.input_channel_count}); + auto padded_input_plane_reshaped = std::make_shared(padded_input_plane, shape_const, false); + result = createFunction(model, padded_input_plane_reshaped, filters_shape, conv_stride, + ngraph::CoordinateDiff{0, 0}, ngraph::CoordinateDiff{0, 0}, conv_dilation, bias_shape, + maxpool_stride, maxpool_shape, ngraph::op::PadType::EXPLICIT, nullptr); + } else { + // Valid padding + result = createFunction(model, inputParams, filters_shape, conv_stride, pads_begin, pads_end, conv_dilation, bias_shape, + maxpool_stride, maxpool_shape, pad_type, nullptr); + } + + return std::make_shared(ngraph::ResultVector{result}, ngraph::ParameterVector{inputParams}); +} + +// --------------------------------------------------------------------------------------------------------------------- + +void execute_test(const modelType& model, std::shared_ptr function, std::shared_ptr reference_function) { + ngraph::pass::Manager manager; + manager.register_pass(); + + switch (model) { + default: + case modelType::TranspConvTransp: + manager.register_pass(); + break; + case modelType::TranspConvBcastAddTransp: + manager.register_pass(); + break; + case modelType::TranspConvBcastAddMaxPoolTransp: + manager.register_pass(); + break; + case modelType::TranspConvBcastAddActTransp: + manager.register_pass(); + break; + case modelType::TranspConvBcastAddMaxPoolActTransp: + manager.register_pass(); + break; + case modelType::TranspConvTranspBcastAdd: + manager.register_pass(); + break; + case modelType::TranspConvTranspBcastAddAct: + manager.register_pass(); + break; + } + + manager.run_passes(function); + const FunctionsComparator func_comparator = FunctionsComparator::with_default().enable(FunctionsComparator::ATTRIBUTES); + const FunctionsComparator::Result result = func_comparator(function, reference_function); + ASSERT_TRUE(result.valid); +} + +TEST_P(ConvertPadded2ValidConvTestFixture, CompareFunctions) { + execute_test(model, function, reference_function); +} + +INSTANTIATE_TEST_SUITE_P(ConvertPadded2ValidConvTestSuite, ConvertPadded2ValidConvTestFixture, + ::testing::Values( + std::make_tuple(modelType::TranspConvTransp, ngraph::PartialShape{1, 1, 16, 8}, ngraph::Shape{1, 2}, ngraph::Strides{1, 1}, + ngraph::CoordinateDiff{0, 2}, ngraph::CoordinateDiff{0, 3}, ngraph::Strides{1, 1}, + ngraph::Shape{1, 4, 1, 1}, ngraph::Strides{1, 1}, ngraph::Shape{1, 2}, ngraph::op::PadType::EXPLICIT), + std::make_tuple(modelType::TranspConvBcastAddTransp, ngraph::PartialShape{1, 1, 16, 8}, ngraph::Shape{1, 2}, ngraph::Strides{1, 1}, + ngraph::CoordinateDiff{0, 2}, ngraph::CoordinateDiff{0, 3}, ngraph::Strides{1, 1}, + ngraph::Shape{1, 4, 1, 1}, ngraph::Strides{1, 1}, ngraph::Shape{1, 2}, ngraph::op::PadType::EXPLICIT), + std::make_tuple(modelType::TranspConvBcastAddMaxPoolTransp, ngraph::PartialShape{1, 1, 16, 8}, ngraph::Shape{1, 2}, ngraph::Strides{1, 1}, + ngraph::CoordinateDiff{0, 2}, ngraph::CoordinateDiff{0, 3}, ngraph::Strides{1, 1}, + ngraph::Shape{1, 4, 1, 1}, ngraph::Strides{1, 1}, ngraph::Shape{1, 2}, ngraph::op::PadType::EXPLICIT), + std::make_tuple(modelType::TranspConvBcastAddActTransp, ngraph::PartialShape{1, 1, 16, 8}, ngraph::Shape{1, 2}, ngraph::Strides{1, 1}, + ngraph::CoordinateDiff{0, 2}, ngraph::CoordinateDiff{0, 3}, ngraph::Strides{1, 1}, + ngraph::Shape{1, 4, 1, 1}, ngraph::Strides{1, 1}, ngraph::Shape{1, 2}, ngraph::op::PadType::SAME_LOWER), + std::make_tuple(modelType::TranspConvBcastAddMaxPoolActTransp, ngraph::PartialShape{1, 1, 16, 8}, ngraph::Shape{1, 2}, ngraph::Strides{1, 1}, + ngraph::CoordinateDiff{0, 2}, ngraph::CoordinateDiff{0, 3}, ngraph::Strides{1, 1}, + ngraph::Shape{1, 4, 1, 1}, ngraph::Strides{1, 1}, ngraph::Shape{1, 2}, ngraph::op::PadType::SAME_UPPER), + std::make_tuple(modelType::TranspConvTranspBcastAdd, ngraph::PartialShape{1, 1, 16, 8}, ngraph::Shape{1, 2}, ngraph::Strides{1, 1}, + ngraph::CoordinateDiff{0, 2}, ngraph::CoordinateDiff{0, 3}, ngraph::Strides{1, 1}, + ngraph::Shape{1, 1, 1, 4}, ngraph::Strides{1, 1}, ngraph::Shape{1, 2}, ngraph::op::PadType::EXPLICIT), + std::make_tuple(modelType::TranspConvTranspBcastAddAct, ngraph::PartialShape{1, 1, 16, 8}, ngraph::Shape{1, 2}, ngraph::Strides{1, 1}, + ngraph::CoordinateDiff{0, 2}, ngraph::CoordinateDiff{0, 3}, ngraph::Strides{1, 1}, + ngraph::Shape{1, 1, 1, 4}, ngraph::Strides{1, 1}, ngraph::Shape{1, 2}, ngraph::op::PadType::EXPLICIT))); + +TEST_P(ConvertPadded2ValidConvTestInvalidFixture, CompareFunctions) { + execute_test(model, function, reference_function); +} + +INSTANTIATE_TEST_SUITE_P(ConvertPadded2ValidConvInvalidTestSuite, ConvertPadded2ValidConvTestInvalidFixture, + ::testing::Values( + std::make_tuple(modelType::TranspConvTransp, ngraph::PartialShape{2, 1, 16, 8}, ngraph::Shape{1, 2}, ngraph::Strides{1, 1}, + ngraph::CoordinateDiff{0, 2}, ngraph::CoordinateDiff{0, 3}, ngraph::Strides{1, 1}, + ngraph::Shape{1, 4, 1, 1}, ngraph::Strides{1, 1}, ngraph::Shape{1, 2}, ngraph::op::PadType::SAME_UPPER), + std::make_tuple(modelType::TranspConvBcastAddTransp, ngraph::PartialShape{2, 1, 16, 8}, ngraph::Shape{1, 2}, ngraph::Strides{1, 1}, + ngraph::CoordinateDiff{0, 2}, ngraph::CoordinateDiff{0, 3}, ngraph::Strides{1, 1}, + ngraph::Shape{1, 4, 1, 1}, ngraph::Strides{1, 1}, ngraph::Shape{1, 2}, ngraph::op::PadType::EXPLICIT), + std::make_tuple(modelType::TranspConvBcastAddMaxPoolTransp, ngraph::PartialShape{2, 16, 16, 8}, ngraph::Shape{1, 2}, ngraph::Strides{1, 1}, + ngraph::CoordinateDiff{0, 2}, ngraph::CoordinateDiff{0, 3}, ngraph::Strides{1, 1}, + ngraph::Shape{1, 4, 1, 1}, ngraph::Strides{1, 1}, ngraph::Shape{5, 1}, ngraph::op::PadType::EXPLICIT), + std::make_tuple(modelType::TranspConvBcastAddActTransp, ngraph::PartialShape{2, 1, 16, 8}, ngraph::Shape{1, 2}, ngraph::Strides{1, 1}, + ngraph::CoordinateDiff{0, 2}, ngraph::CoordinateDiff{0, 3}, ngraph::Strides{1, 1}, + ngraph::Shape{1, 4, 1, 1}, ngraph::Strides{1, 1}, ngraph::Shape{1, 2}, ngraph::op::PadType::SAME_LOWER), + std::make_tuple(modelType::TranspConvBcastAddMaxPoolActTransp, ngraph::PartialShape{2, 1, 16, 8}, ngraph::Shape{1, 2}, ngraph::Strides{1, 1}, + ngraph::CoordinateDiff{0, 5}, ngraph::CoordinateDiff{0, 3}, ngraph::Strides{1, 1}, + ngraph::Shape{1, 4, 1, 1}, ngraph::Strides{1, 1}, ngraph::Shape{1, 4}, ngraph::op::PadType::SAME_UPPER), + std::make_tuple(modelType::TranspConvTranspBcastAdd, ngraph::PartialShape{2, 1, 16, 8}, ngraph::Shape{1, 2}, ngraph::Strides{1, 1}, + ngraph::CoordinateDiff{0, 2}, ngraph::CoordinateDiff{0, 3}, ngraph::Strides{1, 1}, + ngraph::Shape{1, 1, 1, 4}, ngraph::Strides{1, 1}, ngraph::Shape{1, 2}, ngraph::op::PadType::EXPLICIT), + std::make_tuple(modelType::TranspConvTranspBcastAddAct, ngraph::PartialShape{2, 1, 16, 8}, ngraph::Shape{1, 2}, ngraph::Strides{1, 1}, + ngraph::CoordinateDiff{0, 2}, ngraph::CoordinateDiff{0, 3}, ngraph::Strides{1, 1}, + ngraph::Shape{1, 1, 1, 4}, ngraph::Strides{1, 1}, ngraph::Shape{1, 2}, ngraph::op::PadType::EXPLICIT))); + +} // namespace + +} // namespace testing diff --git a/inference-engine/tests/unit/gna/ngraph/transformations/gna_remove_extra_reshapes.cpp b/inference-engine/tests/unit/gna/ngraph/transformations/gna_remove_extra_reshapes.cpp new file mode 100644 index 00000000000000..51f6828d44cb04 --- /dev/null +++ b/inference-engine/tests/unit/gna/ngraph/transformations/gna_remove_extra_reshapes.cpp @@ -0,0 +1,89 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "transformations/remove_extra_reshapes.hpp" + +#include "common_test_utils/ngraph_test_utils.hpp" +#include +#include +#include +#include + +namespace testing { + +TEST(TransformationTests, RemoveExtraReshapesTestReshapeNotEqualInputOutput) { + std::shared_ptr func(nullptr), reference_func(nullptr); + const ngraph::Shape data_shape{1, 3, 64, 64}; + + { + auto input_params = std::make_shared(ngraph::element::f32, data_shape); + auto new_shape = ngraph::opset7::Constant::create(ngraph::element::i64, ngraph::Shape{3}, {1, 3, 64 * 64}); + auto reshape_operation = std::make_shared(input_params, new_shape, true); + auto max_pool_operation = std::make_shared(reshape_operation, + ngraph::Strides{1}, + ngraph::Shape{0}, + ngraph::Shape{0}, + ngraph::Shape{3}); + auto result = std::make_shared(max_pool_operation); + func = std::make_shared(ngraph::ResultVector{result}, + ngraph::ParameterVector{input_params}); + + reference_func = ngraph::clone_function(*func); + + ngraph::pass::Manager m; + m.register_pass(); + m.register_pass(); + m.run_passes(func); + ASSERT_NO_THROW(check_rt_info(func)); + } + + const FunctionsComparator func_comparator = FunctionsComparator::with_default().enable(FunctionsComparator::ATTRIBUTES); + const FunctionsComparator::Result result = func_comparator(func, reference_func); + ASSERT_TRUE(result.valid); +} + +TEST(TransformationTests, RemoveExtraReshapesTestReshapeEqualInputOutput) { + std::shared_ptr func(nullptr), reference_func(nullptr); + const ngraph::Shape data_shape{1, 3, 64, 64}; + + { + auto input_params = std::make_shared(ngraph::element::f32, data_shape); + auto new_shape = ngraph::opset7::Constant::create(ngraph::element::i64, ngraph::Shape{4}, {1, 3, 64, 64}); + auto reshape_operation = std::make_shared(input_params, new_shape, true); + auto max_pool_operation = std::make_shared(reshape_operation, + ngraph::Strides{1, 1}, + ngraph::Shape{0, 0}, + ngraph::Shape{0, 0}, + ngraph::Shape{3, 3}); + auto result = std::make_shared(max_pool_operation); + func = std::make_shared(ngraph::ResultVector{result}, + ngraph::ParameterVector{input_params}); + + ngraph::pass::Manager m; + m.register_pass(); + m.register_pass(); + m.run_passes(func); + ASSERT_NO_THROW(check_rt_info(func)); + } + + { + auto input_params = std::make_shared(ngraph::element::f32, data_shape); + auto max_pool_operation = std::make_shared(input_params, + ngraph::Strides{1, 1}, + ngraph::Shape{0, 0}, + ngraph::Shape{1, 1}, + ngraph::Shape{4, 4}); + auto result = std::make_shared(max_pool_operation); + reference_func = std::make_shared(ngraph::ResultVector{result}, + ngraph::ParameterVector{input_params}); + } + + const FunctionsComparator func_comparator = FunctionsComparator::with_default(); + const FunctionsComparator::Result result = func_comparator(func, reference_func); + ASSERT_TRUE(result.valid); +} + +} // namespace testing diff --git a/inference-engine/thirdparty/clDNN/api/cldnn/primitives/gather.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/gather.hpp index 483a1a40b31104..18bc947b1e32ad 100644 --- a/inference-engine/thirdparty/clDNN/api/cldnn/primitives/gather.hpp +++ b/inference-engine/thirdparty/clDNN/api/cldnn/primitives/gather.hpp @@ -35,6 +35,7 @@ struct gather : public primitive_base { /// @param axis Gathering axis. /// @param output_shape Output shape. /// @param batch_dim Batch_dim + /// @param support_neg_ind Support negative indexes gather(const primitive_id& id, const primitive_id& dict, const primitive_id& idx, @@ -42,8 +43,11 @@ struct gather : public primitive_base { const format& output_format, const tensor& output_shape, const int64_t batch_dim = 0, - const padding& output_padding = padding()) - : primitive_base(id, {dict, idx}, output_padding), axis(axis), output_format(output_format), output_shape(output_shape), batch_dim(batch_dim) {} + const bool support_neg_ind = false, + const padding& output_padding = padding() + ) + : primitive_base(id, {dict, idx}, output_padding), axis(axis), output_format(output_format), + output_shape(output_shape), batch_dim(batch_dim), support_neg_ind(support_neg_ind) {} /// @brief Gathering axis gather_axis axis; @@ -53,6 +57,8 @@ struct gather : public primitive_base { tensor output_shape; /// @brief Gathering batch_dim int64_t batch_dim; + /// @brief Support negative indexes + bool support_neg_ind; }; /// @} /// @} diff --git a/inference-engine/thirdparty/clDNN/api/cldnn/runtime/debug_configuration.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/debug_configuration.hpp index 469993a4691fd2..c16eb97862fcde 100644 --- a/inference-engine/thirdparty/clDNN/api/cldnn/runtime/debug_configuration.hpp +++ b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/debug_configuration.hpp @@ -24,8 +24,13 @@ class debug_configuration { debug_configuration(); public: static const char *prefix; - int verbose; - std::string dump_graphs; + int verbose; // Verbose execution + int print_multi_kernel_perf; // Print execution time of each kernel in multi-kernel primitimive + int disable_usm; // Disable usm usage + std::string dump_graphs; // Dump optimized graph + std::string dump_layers_path; // Enable dumping intermediate buffers and set the dest path + std::string dump_layers; // Dump intermediate buffers of specified layers only, separated by space + int dump_layers_dst_only; // Dump only output of layers static const debug_configuration *get_instance(); }; diff --git a/inference-engine/thirdparty/clDNN/api/cldnn/runtime/engine.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/engine.hpp index b81f626c5e64f4..446aa9ba5b2322 100644 --- a/inference-engine/thirdparty/clDNN/api/cldnn/runtime/engine.hpp +++ b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/engine.hpp @@ -16,6 +16,10 @@ #include #include +#define CLDNN_THREADING_SEQ 0 +#define CLDNN_THREADING_TBB 1 +#define CLDNN_THREADING_THREADPOOL 2 + namespace cldnn { class stream; diff --git a/inference-engine/thirdparty/clDNN/api/cldnn/runtime/kernel_args.hpp b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/kernel_args.hpp index f70d04ee33a771..14e068d4973918 100644 --- a/inference-engine/thirdparty/clDNN/api/cldnn/runtime/kernel_args.hpp +++ b/inference-engine/thirdparty/clDNN/api/cldnn/runtime/kernel_args.hpp @@ -127,7 +127,8 @@ struct kernel_string { kernel_string() : str(""), jit(""), undefs(""), options(""), entry_point(""), batch_compilation(false) {} - std::string get_hash() { return str + jit + undefs + options + entry_point; } + std::string get_str() const { return str + jit + undefs + options + entry_point; } + size_t get_hash() const { return std::hash()(get_str()); } }; } // namespace cldnn diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/activation/activation_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/activation/activation_kernel_base.cpp index 2a24a9f18dfb53..a8d25d6b906e49 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/activation/activation_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/activation/activation_kernel_base.cpp @@ -69,11 +69,10 @@ KernelsData ActivationKernelBase::GetCommonKernelsData(const Params& params, con KernelData kd = KernelData::Default(params); activation_params& newParams = *static_cast(kd.params.get()); - const std::string kernel_id = GetEntryPoint(kernelName, params.layerID, options); auto dispatchData = SetDefault(newParams); auto cldnn_jit = GetJitConstants(newParams, dispatchData); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/arg_max_min/arg_max_min_kernel_axis.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/arg_max_min/arg_max_min_kernel_axis.cpp index 734dd1c9ebb8cb..7c02191576ec76 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/arg_max_min/arg_max_min_kernel_axis.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/arg_max_min/arg_max_min_kernel_axis.cpp @@ -86,7 +86,7 @@ KernelsData ArgMaxMinKernelAxis::GetKernelsData(const Params& params, const opti KernelData kd = KernelData::Default(params); auto cldnn_jit = GetJitConstants(orgParams); - auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/arg_max_min/arg_max_min_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/arg_max_min/arg_max_min_kernel_base.cpp index 236da961e4ed9b..b25f92fe301043 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/arg_max_min/arg_max_min_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/arg_max_min/arg_max_min_kernel_base.cpp @@ -45,7 +45,7 @@ KernelsData ArgMaxMinKernelBase::GetCommonKernelsData(const Params& params, cons KernelData kd = KernelData::Default(params); auto cldnn_jit = GetJitConstants(orgParams); - auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/arg_max_min/arg_max_min_kernel_opt.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/arg_max_min/arg_max_min_kernel_opt.cpp index 7ff5f8d189c036..d31abbd679ed4f 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/arg_max_min/arg_max_min_kernel_opt.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/arg_max_min/arg_max_min_kernel_opt.cpp @@ -47,7 +47,7 @@ KernelsData ArgMaxMinKernelOpt::GetKernelsData(const Params& params, const optio auto& kernel = kd.kernels[i]; DispatchData dispatchData = SetDefault(newParams); auto cldnnJit = GetJitConstants(newParams); - auto entryPoint = GetEntryPoint(kernelName, newParams.layerID, options); + auto entryPoint = GetEntryPoint(kernelName, newParams.layerID, params, options); auto jit = CreateJit(kernelName, cldnnJit, entryPoint); dispatchData.gws = { Align(size, 16), orgParams.inputs[0].Batch().v, 1 }; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/average_unpooling/average_unpooling_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/average_unpooling/average_unpooling_kernel_base.cpp index c3a21a139e44c5..fe864e5f788e55 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/average_unpooling/average_unpooling_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/average_unpooling/average_unpooling_kernel_base.cpp @@ -65,7 +65,7 @@ KernelsData AverageUnpoolingKernelBase::GetCommonKernelsData(const Params& param KernelData kd = KernelData::Default(params); auto cldnn_jit = GetJitConstants(orgParams); - auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/batch_to_space/batch_to_space_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/batch_to_space/batch_to_space_kernel_base.cpp index cef13342302795..a28500034e27b9 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/batch_to_space/batch_to_space_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/batch_to_space/batch_to_space_kernel_base.cpp @@ -79,7 +79,7 @@ KernelsData BatchToSpaceKernelBase::GetCommonKernelsData(const Params& params, c } auto dispatchData = SetDefault(newParams, options); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); auto cldnn_jit = GetJitConstants(newParams); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/binary_convolution/binary_convolution_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/binary_convolution/binary_convolution_kernel_base.cpp index d7a7ba3ec37800..142fda4352fbd6 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/binary_convolution/binary_convolution_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/binary_convolution/binary_convolution_kernel_base.cpp @@ -130,7 +130,7 @@ KernelsData BinaryConvolutionKernelBase::GetCommonKernelsData(const Params& para auto finalKernelName = GetKernelName(newParams); auto cldnnJit = GetJitConstants(newParams, dispatchData); - auto entryPoint = GetEntryPoint(finalKernelName, newParams.layerID, options); + auto entryPoint = GetEntryPoint(finalKernelName, newParams.layerID, params, options); auto jit = CreateJit(finalKernelName, cldnnJit, entryPoint); auto& kernel = kd.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/border/border_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/border/border_kernel_base.cpp index efeb5a1d8f3bc5..e63a56b1947f01 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/border/border_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/border/border_kernel_base.cpp @@ -40,7 +40,7 @@ KernelsData BorderKernelBase::GetCommonKernelsData(const Params& params, KernelData k_data = KernelData::Default(params); auto cldnn_jit = GetJitConstants(prim_params); - auto entry_point = GetEntryPoint(kernelName, prim_params.layerID, options); + auto entry_point = GetEntryPoint(kernelName, prim_params.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = k_data.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/broadcast/broadcast_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/broadcast/broadcast_kernel_base.cpp index db7b26a07a48f1..23b7bfcf54f9ea 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/broadcast/broadcast_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/broadcast/broadcast_kernel_base.cpp @@ -37,7 +37,7 @@ KernelsData BroadcastKernelBase::GetCommonKernelsData(const Params& params, KernelData k_data = KernelData::Default(params); auto cldnn_jit = GetJitConstants(prim_params); - auto entry_point = GetEntryPoint(kernelName, prim_params.layerID, options); + auto entry_point = GetEntryPoint(kernelName, prim_params.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = k_data.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/concatenation/concatenation_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/concatenation/concatenation_kernel_base.cpp index f1c20f88767c33..73255a4bc1b63a 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/concatenation/concatenation_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/concatenation/concatenation_kernel_base.cpp @@ -108,7 +108,7 @@ KernelsData ConcatenationKernelBase::GetCommonKernelsData(const Params& params, auto& kernel = kd.kernels[i]; DispatchData dispatchData = SetDefault(newParams); auto cldnnJit = GetJitConstants(newParams); - auto entryPoint = GetEntryPoint(kernelName, newParams.layerID, options); + auto entryPoint = GetEntryPoint(kernelName, newParams.layerID, params, options, i); auto jit = CreateJit(kernelName, cldnnJit, entryPoint); kernel.code.kernelString = GetKernelString(kernelName, jit, entryPoint, params.engineInfo); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/concatenation/concatenation_kernel_fs_b_yx_fsv32.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/concatenation/concatenation_kernel_fs_b_yx_fsv32.cpp index 26397613b41245..4dd35435db37c4 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/concatenation/concatenation_kernel_fs_b_yx_fsv32.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/concatenation/concatenation_kernel_fs_b_yx_fsv32.cpp @@ -105,7 +105,7 @@ KernelsData ConcatenationKernel_fs_b_yx_fsv32::GetKernelsData(const Params& para auto& kernel = kd.kernels[i]; DispatchData dispatchData = SetDefault(newParams); auto cldnnJit = GetJitConstants(newParams); - auto entryPoint = GetEntryPoint(kernelName, newParams.layerID, optParams); + auto entryPoint = GetEntryPoint(kernelName, newParams.layerID, params, optParams, i); auto jit = CreateJit(kernelName, cldnnJit, entryPoint); kernel.code.kernelString = GetKernelString(kernelName, jit, entryPoint, params.engineInfo); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/convolution/convolution_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/convolution/convolution_kernel_base.cpp index a5674f56f55167..ca7c2dab7fef6a 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/convolution/convolution_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/convolution/convolution_kernel_base.cpp @@ -214,7 +214,7 @@ KernelsData ConvolutionKernelBase::GetCommonKernelsData(const Params& params, auto finalKernelName = GetKernelName(newParams); auto cldnnJit = GetJitConstants(newParams, dispatchData); - auto entryPoint = GetEntryPoint(finalKernelName, newParams.layerID, options); + auto entryPoint = GetEntryPoint(finalKernelName, newParams.layerID, params, options); auto jit = CreateJit(finalKernelName, cldnnJit, entryPoint); auto& kernel = kd.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/convolution/convolution_kernel_bfyx_os_iyx_osv16.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/convolution/convolution_kernel_bfyx_os_iyx_osv16.cpp index a80696c0b60a02..bef3794a65779f 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/convolution/convolution_kernel_bfyx_os_iyx_osv16.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/convolution/convolution_kernel_bfyx_os_iyx_osv16.cpp @@ -9,7 +9,6 @@ namespace kernel_selector { // Sub-group size used by "kernel_name_bfyx_os_iyx_osv16" kernel. -constexpr size_t sub_group_size = 16; ConvolutionKernel_bfyx_os_iyx_osv16::ConvolutionKernel_bfyx_os_iyx_osv16() : ConvolutionKernelBase("convolution_gpu_bfyx_os_iyx_osv16") { @@ -94,6 +93,9 @@ static void shrink_blocks_to_output_size(size_t output_x, size_t output_y, size_ block_x -= unused_x / simds_x; block_y -= unused_y / simds_y; + + block_x = Align(block_x, 2); + block_y = Align(block_y, 2); } ConvolutionKernel_bfyx_os_iyx_osv16::AutoTuneOption ConvolutionKernel_bfyx_os_iyx_osv16::GetAutoTuneOptions( @@ -107,9 +109,11 @@ ConvolutionKernel_bfyx_os_iyx_osv16::AutoTuneOption ConvolutionKernel_bfyx_os_iy const convolution_params& cp = static_cast(p); + const auto& sub_group_size = GetSubGroupSize(cp); + if (cp.stride.x == 1 && cp.stride.y == 1) { if (cp.filterSize.x == 1 && cp.filterSize.y == 1) { - option.blockWidth = 16; + option.blockWidth = sub_group_size; option.blockHeight = 1; option.prefetch = 4; // if less than 16 values is required to compute one single row of output @@ -143,13 +147,13 @@ ConvolutionKernel_bfyx_os_iyx_osv16::AutoTuneOption ConvolutionKernel_bfyx_os_iy if (cp.filterSize.x != 1 || cp.filterSize.y != 1 || cp.output.Batch().v != 1) { shrink_blocks_to_output_size(cp.output.X().v, cp.output.Y().v, option.blockWidth, option.blockHeight); } - return option; } ConvolutionKernelBase::DispatchData ConvolutionKernel_bfyx_os_iyx_osv16::SetDefault(const convolution_params& cp, int autoTuneIndex) const { DispatchData dispatchData = ConvolutionKernelBase::SetDefault(cp); + const auto& sub_group_size = GetSubGroupSize(cp); const auto of_maps = cp.output.Feature().v; const auto of_maps_per_group = of_maps / cp.groups; @@ -196,6 +200,9 @@ bool ConvolutionKernel_bfyx_os_iyx_osv16::Validate(const Params& p, const option JitConstants ConvolutionKernel_bfyx_os_iyx_osv16::GetJitConstants(const convolution_params& params, const DispatchData& dispatchData) const { + const convolution_params& cp = static_cast(params); + const auto& sub_group_size = GetSubGroupSize(cp); + const auto of_maps = params.output.Feature().v; const auto of_maps_per_group = of_maps / params.groups; const size_t of_threads_per_batch = RoundUp(of_maps_per_group, sub_group_size); @@ -209,7 +216,7 @@ JitConstants ConvolutionKernel_bfyx_os_iyx_osv16::GetJitConstants(const convolut jit.Merge(MakeFusedOpsJitConstants(params, {conf_scalar})); } - + jit.AddConstant(MakeJitConstant("OSV_SIZE", 16)); jit.AddConstant(MakeJitConstant("SUB_GROUP_SIZE", dispatchData.lws[2])); jit.AddConstant(MakeJitConstant("OUTPUT_BLOCK_WIDTH", dispatchData.cldnnStyle.blockWidth)); jit.AddConstant(MakeJitConstant("OUTPUT_BLOCK_HEIGHT", dispatchData.cldnnStyle.blockHeight)); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/convolution/convolution_kernel_bfyx_os_iyx_osv16.h b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/convolution/convolution_kernel_bfyx_os_iyx_osv16.h index 6bc617bb3f3e6b..9da526096365fb 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/convolution/convolution_kernel_bfyx_os_iyx_osv16.h +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/convolution/convolution_kernel_bfyx_os_iyx_osv16.h @@ -4,6 +4,7 @@ #pragma once +#include "api/cldnn/runtime/device_info.hpp" #include "convolution_kernel_base.h" #include #include @@ -34,6 +35,16 @@ class ConvolutionKernel_bfyx_os_iyx_osv16 : public ConvolutionKernelBase { bool Validate(const Params& p, const optional_params& o) const override; bool NeedPaddedInput() const override { return true; } DispatchData SetDefault(const convolution_params& arg, int autoTuneIndex = -1) const override; + size_t GetSubGroupSize(const convolution_params& params) const { + if (params.engineInfo.computeUnitsCount <= 24) { + // Smaller # EU tends to be computation bounds. + // In such case, using larger worksize will result in larger computational inefficiency + // w.r.t the unalined output feature + return (params.output.Feature().v > 8) ? 16 : 8; + } else { + return 16; + } + } private: struct AutoTuneOption { diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/convolution/deformable_convolution_kernel_bfyx_interp.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/convolution/deformable_convolution_kernel_bfyx_interp.cpp index e337b9b68e7d22..0ee694b097491c 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/convolution/deformable_convolution_kernel_bfyx_interp.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/convolution/deformable_convolution_kernel_bfyx_interp.cpp @@ -81,7 +81,7 @@ KernelsData DeformableConvolutionKernel_bfyx_interp::GetKernelsData(const Params convolution_params& newParams = *static_cast(kd.params.get()); CommonDispatchData dispatchData = SetDefault(newParams); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); auto cldnn_jit = GetJitConstants(newParams); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/ctc_greedy_decoder/ctc_greedy_decoder_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/ctc_greedy_decoder/ctc_greedy_decoder_kernel_base.cpp index 664ed70fabc64b..ea825b5ce23a96 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/ctc_greedy_decoder/ctc_greedy_decoder_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/ctc_greedy_decoder/ctc_greedy_decoder_kernel_base.cpp @@ -56,7 +56,7 @@ KernelsData CTCGreedyDecoderKernelBase::GetCommonKernelsData(const Params& param KernelData kd = KernelData::Default(params); auto cldnn_jit = GetJitConstants(orgParams, dispatchData); - auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/cum_sum/cum_sum_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/cum_sum/cum_sum_kernel_base.cpp index 0fc8b0cbb1da5f..42b573e5c61043 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/cum_sum/cum_sum_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/cum_sum/cum_sum_kernel_base.cpp @@ -90,7 +90,7 @@ KernelsData CumSumKernelBase::GetCommonKernelsData(const Params& params, } auto dispatchData = SetDefault(newParams); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); auto cldnn_jit = GetJitConstants(newParams, dispatchData); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/cum_sum/cum_sum_kernel_partial_sum.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/cum_sum/cum_sum_kernel_partial_sum.cpp index 87d2a3cedccc5c..51689796288d87 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/cum_sum/cum_sum_kernel_partial_sum.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/cum_sum/cum_sum_kernel_partial_sum.cpp @@ -40,7 +40,7 @@ KernelsData CumSumKernelPartialSum::GetMultiStageKernelsData(const Params& param // partial sum auto cldnn_jit = GetJitConstants(newParams, dispatchData.stage_1); cldnn_jit.AddConstant(MakeJitConstant("CUM_SUM_PARTIAL_SUM", 1)); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[0]; FillCLKernelData(kernel, dispatchData.stage_1, params.engineInfo, kernelName, jit, entry_point); @@ -51,7 +51,7 @@ KernelsData CumSumKernelPartialSum::GetMultiStageKernelsData(const Params& param } { // Final - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options, 1); auto cldnn_jit = GetJitConstants(newParams, dispatchData.stage_final); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/deconvolution/deconvolution_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/deconvolution/deconvolution_kernel_base.cpp index 383427b6075ebd..0552bd22152313 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/deconvolution/deconvolution_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/deconvolution/deconvolution_kernel_base.cpp @@ -122,7 +122,7 @@ KernelsData DeconvolutionKernelBase::GetKernelsData(const Params& params, const } auto cldnn_jit = GetJitConstants(newParams); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/depth_to_space/depth_to_space_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/depth_to_space/depth_to_space_kernel_base.cpp index 75c686d4604db4..2a1631d8d02a59 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/depth_to_space/depth_to_space_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/depth_to_space/depth_to_space_kernel_base.cpp @@ -61,7 +61,7 @@ KernelsData DepthToSpaceKernelBase::GetCommonKernelsData(const Params& params, c } auto dispatchData = SetDefault(newParams); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); auto cldnn_jit = GetJitConstants(newParams); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_b_fs_yx_fsv16.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_b_fs_yx_fsv16.cpp index 5e23b070865f92..1df3371f722e1c 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_b_fs_yx_fsv16.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_b_fs_yx_fsv16.cpp @@ -326,7 +326,7 @@ KernelsData EltwiseKernel_b_fs_yx_fsv16::GetKernelsData(const Params& params, co KernelData kd = KernelData::Default(params); eltwise_params& newParams = *static_cast(kd.params.get()); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); auto cldnn_jit = GetJitConstants(newParams); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_b_fs_yx_fsv4.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_b_fs_yx_fsv4.cpp index 264386cdc1b9ca..401452d5516fa2 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_b_fs_yx_fsv4.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_b_fs_yx_fsv4.cpp @@ -39,7 +39,7 @@ KernelsData EltwiseKernel_b_fs_yx_fsv4::GetKernelsData(const Params& params, con KernelData kd = KernelData::Default(params); eltwise_params& newParams = *static_cast(kd.params.get()); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); auto cldnn_jit = GetJitConstants(newParams); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_base.cpp index 25cab6841ff0be..42fee4026ace2a 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_base.cpp @@ -613,7 +613,7 @@ KernelsData EltwiseKernelBase::GetCommonKernelsData(const Params& params, const KernelData kd = KernelData::Default(params); eltwise_params& newParams = *static_cast(kd.params.get()); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); auto cldnn_jit = GetJitConstants(newParams); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_fs_b_yx_fsv32.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_fs_b_yx_fsv32.cpp index 91975fde6f1a09..d973d9d262e36c 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_fs_b_yx_fsv32.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_fs_b_yx_fsv32.cpp @@ -78,7 +78,7 @@ KernelsData EltwiseKernel_fs_b_yx_fsv32::GetKernelsData(const Params& params, co std::pair jit; - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); try { auto cldnn_jit = GetJitConstants(newParams); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_mixed_byxf_and_fs_b_yx_fsv32.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_mixed_byxf_and_fs_b_yx_fsv32.cpp index bf2ee1076120a3..7a2877c0e113a4 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_mixed_byxf_and_fs_b_yx_fsv32.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_mixed_byxf_and_fs_b_yx_fsv32.cpp @@ -72,7 +72,7 @@ KernelsData EltwiseKernel_mixed_byxf_and_fs_b_yx_fsv32::GetKernelsData(const Par std::pair jit; - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); try { auto cldnn_jit = GetJitConstants(newParams); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_vload8.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_vload8.cpp index a9470fbb0b7b42..b5f6b40c5fc533 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_vload8.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/eltwise/eltwise_kernel_vload8.cpp @@ -95,7 +95,7 @@ KernelsData EltwiseKernel_vload8::GetKernelsData(const Params& params, const opt std::pair jit; - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); try { auto cldnn_jit = GetJitConstants(newParams); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/embedding_bag/embedding_bag_kernel_ref.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/embedding_bag/embedding_bag_kernel_ref.cpp index 1d80c4af4d1db0..e8d228023c6174 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/embedding_bag/embedding_bag_kernel_ref.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/embedding_bag/embedding_bag_kernel_ref.cpp @@ -50,7 +50,7 @@ KernelsData EmbeddingBagKernelRef::GetKernelsData(const Params& params, const op } auto dispatchData = SetDefault(newParams); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); auto cldnn_jit = GetJitConstants(newParams); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/extract_image_patches/extract_image_patches_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/extract_image_patches/extract_image_patches_kernel_base.cpp index 470024159ad442..38a89e948bbc0d 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/extract_image_patches/extract_image_patches_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/extract_image_patches/extract_image_patches_kernel_base.cpp @@ -63,7 +63,7 @@ KernelsData ExtractImagePatchesKernelBase::GetCommonKernelsData(const Params& pa KernelData kd = KernelData::Default(params); auto cldnn_jit = GetJitConstants(prim_params); - auto entry_point = GetEntryPoint(kernelName, prim_params.layerID, options); + auto entry_point = GetEntryPoint(kernelName, prim_params.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/fully_connected/fully_connected_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/fully_connected/fully_connected_kernel_base.cpp index 2a902dd0f8773a..691babd7603074 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/fully_connected/fully_connected_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/fully_connected/fully_connected_kernel_base.cpp @@ -83,7 +83,7 @@ KernelsData FullyConnectedKernelBase::GetCommonKernelsData(const Params ¶ms, kd.kernels.resize(1); - auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, params, options); const DispatchData dispatchData = SetDefault(newParams, autoTuneIndex); auto cldnn_jit = GetJitConstants(newParams, dispatchData); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/fused_conv_eltwise/fused_conv_eltwise_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/fused_conv_eltwise/fused_conv_eltwise_kernel_base.cpp index a1d86baf9a22c3..c628dc98fdd782 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/fused_conv_eltwise/fused_conv_eltwise_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/fused_conv_eltwise/fused_conv_eltwise_kernel_base.cpp @@ -268,7 +268,7 @@ KernelsData fused_conv_eltwise_kernel_base::GetCommonKernelsData(const Params& p auto finalKernelName = GetKernelName(newParams); auto cldnnJit = GetJitConstants(newParams, dispatchData); - auto entryPoint = GetEntryPoint(finalKernelName, newParams.layerID, options); + auto entryPoint = GetEntryPoint(finalKernelName, newParams.layerID, params, options); auto jit = CreateJit(finalKernelName, cldnnJit, entryPoint); auto& kernel = kd.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_kernel_ref.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_kernel_ref.cpp index 23d897d32e70ce..1a4a1f69e51525 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_kernel_ref.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_kernel_ref.cpp @@ -79,6 +79,10 @@ static int64_t GetGatherBatchDim(const gather_params& params) { return params.batch_dim; } +static inline std::string GetGatherMaxIndexDim(const gather_params& params) { + return std::to_string(params.inputs[0].GetDims().at(params.inputs[0].GetDims().size() - GetGatherChannelIndex(params) - 1).v); +} + static inline std::string GetOrderString(std::vector& order) { std::string order_str = order[0]; for (size_t i = 1; i < order.size(); i++) @@ -168,6 +172,8 @@ JitConstants GatherKernelRef::GetJitConstants(const gather_params& params) const jit.AddConstant(MakeJitConstant("DICTIONARY_INDEX_ORDER", GetDictionaryIndexOrder(params, GetGatherChannelIndex(params)))); jit.AddConstant(MakeJitConstant("INDICES_INDEX_ORDER", GetIndecesIdxOrder(params, GetGatherChannelIndex(params), GetGatherBatchDim(params)))); + if (params.support_neg_ind) + jit.AddConstant(MakeJitConstant("INDEX_DIM", GetGatherMaxIndexDim(params))); if (!params.fused_ops.empty()) { std::vector idx_order = GetOrder(params.inputs[0].GetDims().size()); @@ -203,7 +209,7 @@ KernelsData GatherKernelRef::GetKernelsData(const Params& params, const optional gather_params& newParams = *static_cast(kd.params.get()); auto dispatchData = SetDefault(newParams, options); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); auto cldnn_jit = GetJitConstants(newParams); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_kernel_ref.h b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_kernel_ref.h index 38f058e4e67053..623912bbdbf49f 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_kernel_ref.h +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_kernel_ref.h @@ -11,10 +11,11 @@ namespace kernel_selector { // gather_params //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// struct gather_params : public base_params { - gather_params() : base_params(KernelType::GATHER), axis(GatherAxis::BATCH), batch_dim(0) {} + gather_params() : base_params(KernelType::GATHER), axis(GatherAxis::BATCH), batch_dim(0), support_neg_ind(false) {} GatherAxis axis; int64_t batch_dim; + bool support_neg_ind; virtual ParamsKey GetParamsKey() const { return base_params::GetParamsKey(); } }; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_nd_kernel_ref.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_nd_kernel_ref.cpp index fa523d35ef97e7..4ffd87439a0143 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_nd_kernel_ref.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather/gather_nd_kernel_ref.cpp @@ -187,7 +187,7 @@ KernelsData GatherNDKernelRef::GetKernelsData(const Params& params, const option auto dispatchData = SetDefault(newParams, options); auto cldnn_jit = GetJitConstants(newParams); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[0]; FillCLKernelData(kernel, dispatchData, params.engineInfo, kernelName, jit, entry_point, "", false, false, 2, GetFusedPrimitiveInputsCount(params)); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather_tree/gather_tree_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather_tree/gather_tree_kernel_base.cpp index a374db7ba73169..d87e8ada5c3350 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather_tree/gather_tree_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gather_tree/gather_tree_kernel_base.cpp @@ -34,7 +34,7 @@ KernelsData GatherTreeKernelBase::GetCommonKernelsData(const Params& params, auto dispatchData = SetDefault(gt_params); auto kernel_data = KernelData::Default(params); auto cldnn_jit = GetJitConstants(gt_params); - auto entry_point = GetEntryPoint(kernelName, gt_params.layerID, options); + auto entry_point = GetEntryPoint(kernelName, gt_params.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); FillCLKernelData(kernel_data.kernels[0], dispatchData, diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gemm/gemm_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gemm/gemm_kernel_base.cpp index 5a78ea1ab247b0..f4f5ac150ca78d 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gemm/gemm_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gemm/gemm_kernel_base.cpp @@ -45,7 +45,7 @@ KernelsData GemmKernelBase::GetCommonKernelsData(const Params& params, KernelData k_data = KernelData::Default(params); auto cldnn_jit = GetJitConstants(prim_params); - auto entry_point = GetEntryPoint(kernelName, prim_params.layerID, options); + auto entry_point = GetEntryPoint(kernelName, prim_params.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = k_data.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gemm/gemm_kernel_mmad_int8.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gemm/gemm_kernel_mmad_int8.cpp index e1334d4b82a35a..9e5eb462441378 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gemm/gemm_kernel_mmad_int8.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gemm/gemm_kernel_mmad_int8.cpp @@ -137,7 +137,7 @@ KernelsData GemmKernelMMADint8::GetKernelsData(const Params& params, const optio KernelData k_data = KernelData::Default(params); auto cldnn_jit = GetJitConstants(prim_params); - auto entry_point = GetEntryPoint(kernelName, prim_params.layerID, options); + auto entry_point = GetEntryPoint(kernelName, prim_params.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = k_data.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gemm/gemm_kernel_mmad_int8_slm.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gemm/gemm_kernel_mmad_int8_slm.cpp index 17a4952af2c591..a9cb0652730cec 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gemm/gemm_kernel_mmad_int8_slm.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gemm/gemm_kernel_mmad_int8_slm.cpp @@ -107,7 +107,7 @@ KernelsData GemmKernelMMADslmInt8::GetKernelsData(const Params& params, const op KernelData k_data = KernelData::Default(params); auto cldnn_jit = GetJitConstants(prim_params); - auto entry_point = GetEntryPoint(kernelName, prim_params.layerID, options); + auto entry_point = GetEntryPoint(kernelName, prim_params.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = k_data.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gemm/gemm_kernel_tiled_opt.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gemm/gemm_kernel_tiled_opt.cpp index 47025a0838df3c..93df406663cc6f 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gemm/gemm_kernel_tiled_opt.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gemm/gemm_kernel_tiled_opt.cpp @@ -48,6 +48,8 @@ GemmKernelBase::DispatchData GemmKernelTiledOpt::SetDefault(const gemm_params& p GemmKernelTiledOpt::GemmTuningData GemmKernelTiledOpt::SetTuningParams(const gemm_params& params) const { const auto& output = params.output; + GemmKernelTiledOpt::GemmTuningData tuning_data; + auto m_size = output.Y().v; auto n_size = output.X().v; auto k_size = params.transpose_input0 ? params.inputs[0].Y().v : params.inputs[0].X().v; @@ -83,6 +85,7 @@ JitConstants GemmKernelTiledOpt::GetJitConstants(const gemm_params& params) cons JitConstants jit = Parent::GetJitConstants(params); const auto& output = params.output; + GemmTuningData tuning_data = SetTuningParams(params); auto m_size = output.Y().v; auto n_size = output.X().v; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gemm/gemm_kernel_tiled_opt.h b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gemm/gemm_kernel_tiled_opt.h index 089e928c131601..6d2b096b54fa8a 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gemm/gemm_kernel_tiled_opt.h +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/gemm/gemm_kernel_tiled_opt.h @@ -12,12 +12,12 @@ class GemmKernelTiledOpt : public GemmKernelBase { public: using Parent = GemmKernelBase; - mutable struct GemmTuningData { + struct GemmTuningData { size_t simd_size = 8; size_t tile_m_size = 1; size_t tile_k_size = 1; size_t tile_n_size = 1; - } tuning_data; + }; GemmKernelTiledOpt() : GemmKernelBase("gemm_tiled_opt") {} diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/grn/grn_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/grn/grn_kernel_base.cpp index 8598999df30960..3e332e0cff23d0 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/grn/grn_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/grn/grn_kernel_base.cpp @@ -38,7 +38,7 @@ KernelsData GRNKernelBase::GetCommonKernelsData(const Params& params, KernelData kd = KernelData::Default(params); auto cldnn_jit = GetJitConstants(orgParams, dispatchData); - auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lrn/lrn_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lrn/lrn_kernel_base.cpp index 40600e6c40ca34..85702e695d1361 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lrn/lrn_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lrn/lrn_kernel_base.cpp @@ -87,7 +87,7 @@ KernelsData LRNKernelBase::GetCommonKernelsData(const Params& params, KernelData kd = KernelData::Default(params); auto cldnnJit = GetJitConstants(orgParams, dispatchData); - auto entryPoint = GetEntryPoint(kernelName, orgParams.layerID, options); + auto entryPoint = GetEntryPoint(kernelName, orgParams.layerID, params, options); auto jit = CreateJit(kernelName, cldnnJit, entryPoint); auto fused_deps_total = GetFusedPrimitiveInputsCount(params); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm/lstm_elt_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm/lstm_elt_kernel_base.cpp index 587832da828038..daeaed8fa78844 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm/lstm_elt_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm/lstm_elt_kernel_base.cpp @@ -77,7 +77,7 @@ KernelsData LSTMEltKernelBase::GetCommonKernelsData(const Params& params, const auto& kernel = kd.kernels[0]; auto cldnnJit = GetJitConstants(newParams); - auto entryPoint = GetEntryPoint(kernelName, newParams.layerID, options); + auto entryPoint = GetEntryPoint(kernelName, newParams.layerID, params, options); auto jit = CreateJit(kernelName, cldnnJit, entryPoint); kernel.params.workGroups.global = {out.X().v, out.Batch().v, 1}; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm/lstm_gemm_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm/lstm_gemm_kernel_base.cpp index e4b547deacbcc5..9aa3bfa10c657c 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm/lstm_gemm_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm/lstm_gemm_kernel_base.cpp @@ -47,7 +47,7 @@ KernelsData LSTMGemmKernelBase::GetCommonKernelsData(const Params& params, const // TODO: reorder weights if needed auto& kernel = kd.kernels[0]; auto cldnnJit = GetJitConstants(newParams); - auto entryPoint = GetEntryPoint(kernelName, newParams.layerID, options); + auto entryPoint = GetEntryPoint(kernelName, newParams.layerID, params, options); auto jit = CreateJit(kernelName, cldnnJit, entryPoint); kernel.params.workGroups.global = {out.X().v, out.Batch().v, 1}; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm_dynamic/lstm_dynamic_input_bfyx_opt.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm_dynamic/lstm_dynamic_input_bfyx_opt.cpp index dfd13d8ce5bc83..ad73129bff5fce 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm_dynamic/lstm_dynamic_input_bfyx_opt.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm_dynamic/lstm_dynamic_input_bfyx_opt.cpp @@ -85,7 +85,7 @@ KernelsData LSTM_DynamicInputKernelBfyxOpt::GetKernelsData(const Params& params, } auto cldnn_jit = GetJitConstants(dlstm_params); - auto entry_point = GetEntryPoint(kernelName, dlstm_params.layerID, options); + auto entry_point = GetEntryPoint(kernelName, dlstm_params.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm_dynamic/lstm_dynamic_input_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm_dynamic/lstm_dynamic_input_kernel_base.cpp index 2a1491fb41b583..cdfbe15aa26b6b 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm_dynamic/lstm_dynamic_input_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm_dynamic/lstm_dynamic_input_kernel_base.cpp @@ -57,7 +57,7 @@ KernelsData LSTM_DynamicInputKernelBase::GetCommonKernelsData(const Params& para KernelData k_data = KernelData::Default(params, 1); auto cldnn_jit = GetJitConstants(orgParams); - auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = k_data.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm_dynamic/lstm_dynamic_timeloop_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm_dynamic/lstm_dynamic_timeloop_kernel_base.cpp index 8327a025c8e985..a78e8ce5724174 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm_dynamic/lstm_dynamic_timeloop_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/lstm_dynamic/lstm_dynamic_timeloop_kernel_base.cpp @@ -118,7 +118,7 @@ KernelsData LSTM_DynamicTimeloopKernelBase::GetCommonKernelsData(const Params& p KernelData k_data = KernelData::Default(params, 1); auto cldnn_jit = GetJitConstants(org_params); - auto entry_point = GetEntryPoint(kernelName, org_params.layerID, options); + auto entry_point = GetEntryPoint(kernelName, org_params.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = k_data.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/max_unpooling/max_unpooling_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/max_unpooling/max_unpooling_kernel_base.cpp index 5534217a9ce900..f00dcbc0deaf19 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/max_unpooling/max_unpooling_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/max_unpooling/max_unpooling_kernel_base.cpp @@ -65,7 +65,7 @@ KernelsData MaxUnpoolingKernelBase::GetCommonKernelsData(const Params& params, KernelData kd = KernelData::Default(params); auto cldnn_jit = GetJitConstants(orgParams); - auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/mvn/mvn_kernel_b_fs_yx_fsv16_imad.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/mvn/mvn_kernel_b_fs_yx_fsv16_imad.cpp index 32fd8e5744cc4c..031963920e38d9 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/mvn/mvn_kernel_b_fs_yx_fsv16_imad.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/mvn/mvn_kernel_b_fs_yx_fsv16_imad.cpp @@ -182,11 +182,12 @@ KernelsData MVNKernel_b_fs_yx_fsv16_imad::GetMultiStageKernelsData(const mvn_par KernelData kd = KernelData::Default(params, kernels_num); auto finalKernelName = GetKernelName(orgParams); + size_t entry_part_id = 0; { // Mean first stage auto cldnn_jit = GetJitConstants(orgParams, dispatchData.stage_1); cldnn_jit.AddConstant(MakeJitConstant("MVN_KERNEL_MEAN_1", 1)); - auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, options); + auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, options, entry_part_id++); auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[0]; FillCLKernelData(kernel, @@ -210,7 +211,7 @@ KernelsData MVNKernel_b_fs_yx_fsv16_imad::GetMultiStageKernelsData(const mvn_par // Mean second stage auto cldnn_jit = GetJitConstants(orgParams, dispatchData.stage_2); cldnn_jit.AddConstant(MakeJitConstant("MVN_KERNEL_MEAN_2", 1)); - auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, options); + auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, options, entry_part_id++); auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[1]; FillCLKernelData(kernel, @@ -234,7 +235,7 @@ KernelsData MVNKernel_b_fs_yx_fsv16_imad::GetMultiStageKernelsData(const mvn_par // Variance first stage auto cldnn_jit = GetJitConstants(orgParams, dispatchData.stage_1); cldnn_jit.AddConstant(MakeJitConstant("MVN_KERNEL_VAR_1", 1)); - auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, options); + auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, options, entry_part_id++); auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[2]; FillCLKernelData(kernel, @@ -257,7 +258,7 @@ KernelsData MVNKernel_b_fs_yx_fsv16_imad::GetMultiStageKernelsData(const mvn_par // Variance second stage auto cldnn_jit = GetJitConstants(orgParams, dispatchData.stage_2); cldnn_jit.AddConstant(MakeJitConstant("MVN_KERNEL_VAR_2", 1)); - auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, options); + auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, options, entry_part_id++); auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[3]; FillCLKernelData(kernel, @@ -282,7 +283,7 @@ KernelsData MVNKernel_b_fs_yx_fsv16_imad::GetMultiStageKernelsData(const mvn_par cldnn_jit.AddConstant(MakeJitConstant("MVN_KERNEL_MAIN", 1)); cldnn_jit.AddConstant(MakeJitConstant("PRECALC_MEAN", 1)); cldnn_jit.AddConstant(MakeJitConstant("PRECALC_VARIANCE", params.mvnNormalizeVariance)); - auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, options); + auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, options, entry_part_id); auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[kernels_num - 1]; FillCLKernelData(kernel, diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/mvn/mvn_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/mvn/mvn_kernel_base.cpp index 8e85c733ec2c15..3a602a8eb3ff4f 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/mvn/mvn_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/mvn/mvn_kernel_base.cpp @@ -62,7 +62,7 @@ KernelsData MVNKernelBase::GetCommonKernelsData(const Params& params, auto finalKernelName = GetKernelName(orgParams); auto cldnn_jit = GetJitConstants(orgParams, dispatchData); - auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, options); + auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, options); auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/normalize/normalize_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/normalize/normalize_kernel_base.cpp index a5c6dde629d8c7..881c548568be6b 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/normalize/normalize_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/normalize/normalize_kernel_base.cpp @@ -56,7 +56,7 @@ KernelsData NormalizeKernelBase::GetCommonKernelsData(const Params& params, KernelData kd = KernelData::Default(params); auto cldnn_jit = GetJitConstants(orgParams); - auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/one_hot/one_hot_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/one_hot/one_hot_kernel_base.cpp index cfe546a8406734..1b18f86367f5e9 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/one_hot/one_hot_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/one_hot/one_hot_kernel_base.cpp @@ -45,7 +45,7 @@ KernelsData OneHotKernelBase::GetCommonKernelsData(const Params& params, KernelData k_data = KernelData::Default(params); auto cldnn_jit = GetJitConstants(prim_params); - auto entry_point = GetEntryPoint(kernelName, prim_params.layerID, options); + auto entry_point = GetEntryPoint(kernelName, prim_params.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = k_data.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/permute/permute_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/permute/permute_kernel_base.cpp index bda85cfc41554a..eb44d1d35ca578 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/permute/permute_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/permute/permute_kernel_base.cpp @@ -36,7 +36,7 @@ KernelsData PermuteKernelBase::GetKernelsData(const Params& params, const option auto dispatchData = SetDefault(newParams); auto cldnn_jit = GetJitConstants(newParams, dispatchData); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); std::pair jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[0]; FillCLKernelData(kernel, dispatchData, params.engineInfo, kernelName, jit, entry_point, "", false, false, 1, GetFusedPrimitiveInputsCount(params)); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/pooling/pooling_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/pooling/pooling_kernel_base.cpp index eb42f283703225..5ea0c3753d23d2 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/pooling/pooling_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/pooling/pooling_kernel_base.cpp @@ -175,7 +175,7 @@ KernelsData PoolingKernelBase::GetCommonKernelsData(const Params& params, KernelData kd = KernelData::Default(params); auto cldnn_jit = GetJitConstants(orgParams, dispatchData); - auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/pyramid_roi_align/pyramid_roi_align_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/pyramid_roi_align/pyramid_roi_align_kernel_base.cpp index dc651a42d1d558..bad255be02a28e 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/pyramid_roi_align/pyramid_roi_align_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/pyramid_roi_align/pyramid_roi_align_kernel_base.cpp @@ -36,7 +36,7 @@ KernelsData PyramidROIAlignKernelBase::GetCommonKernelsData(const Params& params auto dispatchData = SetDefault(prim_params); KernelData k_data = KernelData::Default(params); auto cldnn_jit = GetJitConstants(prim_params); - auto entry_point = GetEntryPoint(kernelName, prim_params.layerID, options); + auto entry_point = GetEntryPoint(kernelName, prim_params.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = k_data.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/quantize/quantize_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/quantize/quantize_kernel_base.cpp index b6a6a6a71dba8b..4a3e50d55e33ce 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/quantize/quantize_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/quantize/quantize_kernel_base.cpp @@ -62,7 +62,7 @@ KernelsData QuantizeKernelBase::GetKernelsData(const Params& params, const optio } auto dispatchData = SetDefault(newParams, options); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); auto cldnn_jit = GetJitConstants(newParams, dispatchData); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reduce/reduce_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reduce/reduce_kernel_base.cpp index b814f23b01eaee..6d10fd05a314aa 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reduce/reduce_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reduce/reduce_kernel_base.cpp @@ -231,7 +231,7 @@ KernelsData ReduceKernelBase::GetCommonKernelsData(const Params& p, KernelData kd = KernelData::Default(params); auto cldnn_jit = GetJitConstants(params); - auto entry_point = GetEntryPoint(kernelName, params.layerID, options); + auto entry_point = GetEntryPoint(kernelName, params.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/region_yolo/region_yolo_kernel_ref.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/region_yolo/region_yolo_kernel_ref.cpp index fed2ac12b37505..eb9c12a7ebcfc8 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/region_yolo/region_yolo_kernel_ref.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/region_yolo/region_yolo_kernel_ref.cpp @@ -80,7 +80,7 @@ KernelsData RegionYoloKernelRef::GetKernelsData(const Params& params, const opti KernelData kd = KernelData::Default(params); auto cldnn_jit = GetJitConstants(orgParams); - auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reorder/reorder_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reorder/reorder_kernel_base.cpp index 9629aa2dbc1039..70a178a314baa0 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reorder/reorder_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reorder/reorder_kernel_base.cpp @@ -198,7 +198,7 @@ KernelsData ReorderKernelBase::GetCommonKernelsData(const reorder_weights_params dispatchData = SetDefault(newParams); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); auto cldnn_jit = GetJitConstants(newParams); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); @@ -222,7 +222,7 @@ KernelsData ReorderKernelBase::GetCommonKernelsData(const reorder_params& params DispatchData dispatchData = SetDefault(newParams); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); auto cldnn_jit = GetJitConstants(newParams); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reorg_yolo/reorg_yolo_kernel_ref.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reorg_yolo/reorg_yolo_kernel_ref.cpp index 056d1e5af3ae79..7a07f52d351447 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reorg_yolo/reorg_yolo_kernel_ref.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reorg_yolo/reorg_yolo_kernel_ref.cpp @@ -52,7 +52,7 @@ KernelsData ReorgYoloKernelRef::GetKernelsData(const Params& params, const optio KernelData kd = KernelData::Default(params); auto cldnn_jit = GetJitConstants(orgParams); - auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/resample/resample_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/resample/resample_kernel_base.cpp index 97fee3f405c1c8..7b8079c0770e8a 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/resample/resample_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/resample/resample_kernel_base.cpp @@ -221,7 +221,7 @@ KernelsData ResampleKernelBase::GetCommonKernelsData(const Params& params, const resample_params& newParams = *static_cast(kd.params.get()); auto dispatchData = SetDefault(newParams); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); auto cldnn_jit = GetJitConstants(newParams); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reshape/reshape_kernel_ref.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reshape/reshape_kernel_ref.cpp index 401ffc73d9cf89..b3df228548be35 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reshape/reshape_kernel_ref.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reshape/reshape_kernel_ref.cpp @@ -37,7 +37,7 @@ KernelsData ReshapeKernelRef::GetKernelsData(const Params& params, const optiona KernelData kd = KernelData::Default(params); reshape_params& newParams = *static_cast(kd.params.get()); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); auto cldnn_jit = MakeBaseParamsJitConstants(newParams); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reverse_sequence/reverse_sequence_kernel_ref.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reverse_sequence/reverse_sequence_kernel_ref.cpp index da20e77c031c01..78f92d798fb853 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reverse_sequence/reverse_sequence_kernel_ref.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/reverse_sequence/reverse_sequence_kernel_ref.cpp @@ -58,7 +58,7 @@ KernelsData ReverseSequenceKernelRef::GetKernelsData(const Params& params, const assert(params.GetType() == KernelType::REVERSE_SEQUENCE); auto dispatchData = SetDefault(newParams, options); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); auto cldnn_jit = GetJitConstants(newParams); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/roi_pooling/roi_pooling_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/roi_pooling/roi_pooling_kernel_base.cpp index 271929559c42cc..2298d78c2d58d4 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/roi_pooling/roi_pooling_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/roi_pooling/roi_pooling_kernel_base.cpp @@ -50,7 +50,7 @@ KernelsData ROIPoolingKernelBase::GetCommonKernelsData(const Params& params, KernelData kd = KernelData::Default(params); auto cldnn_jit = GetJitConstants(orgParams); - auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/scatter_update/scatter_elements_update_kernel_ref.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/scatter_update/scatter_elements_update_kernel_ref.cpp index d3c4b93a837950..20645fb0f82741 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/scatter_update/scatter_elements_update_kernel_ref.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/scatter_update/scatter_elements_update_kernel_ref.cpp @@ -145,7 +145,7 @@ KernelsData ScatterElementsUpdateKernelRef::GetKernelsData(const Params& params, for (int i = 0; i < 2; i++) { auto dispatchData = SetDefault(newParams, options, (i == 1)); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options, i); if (i == 1) { cldnn_jit.AddConstant(MakeJitConstant("IS_SECOND_ITER", "true")); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/scatter_update/scatter_nd_update_kernel_ref.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/scatter_update/scatter_nd_update_kernel_ref.cpp index 6c13dd74a0cc11..a3803a38db79da 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/scatter_update/scatter_nd_update_kernel_ref.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/scatter_update/scatter_nd_update_kernel_ref.cpp @@ -162,7 +162,7 @@ KernelsData ScatterNDUpdateKernelRef::GetKernelsData(const Params& params, const // Second iter - update values specified by updates at specific index position specified by indices for (int i = 0; i < 2; i++) { auto dispatchData = SetDefault(newParams, options, (i == 1)); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options, i); if (i == 1) { cldnn_jit.AddConstant(MakeJitConstant("IS_SECOND_ITER", "true")); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/scatter_update/scatter_update_kernel_ref.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/scatter_update/scatter_update_kernel_ref.cpp index 4ccb8ca55a875b..2cc46ca7d00975 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/scatter_update/scatter_update_kernel_ref.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/scatter_update/scatter_update_kernel_ref.cpp @@ -269,7 +269,7 @@ KernelsData ScatterUpdateKernelRef::GetKernelsData(const Params& params, const o for (int i = start_with_iteration; i < 2; i++) { auto dispatchData = SetDefault(newParams, options, (i == 1)); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options, i); if (i == 1) { cldnn_jit.AddConstant(MakeJitConstant("IS_SECOND_ITER", "true")); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/select/select_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/select/select_kernel_base.cpp index d02c6a720280e9..68d0229dedcbd8 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/select/select_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/select/select_kernel_base.cpp @@ -123,7 +123,7 @@ KernelsData SelectKernelBase::GetCommonKernelsData(const Params& params, const o KernelData kd = KernelData::Default(params); select_params& newParams = *static_cast(kd.params.get()); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); auto cldnn_jit = GetJitConstants(newParams); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/shuffle_channels/shuffle_channels_kernel_ref.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/shuffle_channels/shuffle_channels_kernel_ref.cpp index 3f234fa89ed2d3..0c2c2d795526be 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/shuffle_channels/shuffle_channels_kernel_ref.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/shuffle_channels/shuffle_channels_kernel_ref.cpp @@ -89,7 +89,7 @@ KernelsData ShuffleChannelsKernelRef::GetKernelsData(const Params& params, const assert(params.GetType() == KernelType::SHUFFLE_CHANNELS); auto dispatchData = SetDefault(newParams, options); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); auto cldnn_jit = GetJitConstants(newParams); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/softmax/softmax_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/softmax/softmax_kernel_base.cpp index 7336f3cab13f7e..ef0a19d737388f 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/softmax/softmax_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/softmax/softmax_kernel_base.cpp @@ -62,7 +62,7 @@ KernelsData SoftmaxKernelBase::GetCommonKernelsData(const Params& params, const auto dispatchData = SetDefault(orgParams, options); auto cldnn_jit = GetJitConstants(orgParams, dispatchData); - auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, orgParams.layerID, params, options); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); auto& kernel = kd.kernels[0]; diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/space_to_batch/space_to_batch_kernel_base.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/space_to_batch/space_to_batch_kernel_base.cpp index 830b3bfd9cdc4d..83b58c277743a2 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/space_to_batch/space_to_batch_kernel_base.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/space_to_batch/space_to_batch_kernel_base.cpp @@ -79,7 +79,7 @@ KernelsData SpaceToBatchKernelBase::GetCommonKernelsData(const Params& params, c } auto dispatchData = SetDefault(newParams, options); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); auto cldnn_jit = GetJitConstants(newParams); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/space_to_depth/space_to_depth_kernel_ref.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/space_to_depth/space_to_depth_kernel_ref.cpp index 14316395776138..2975c1c40f08d2 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/space_to_depth/space_to_depth_kernel_ref.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/space_to_depth/space_to_depth_kernel_ref.cpp @@ -91,7 +91,7 @@ KernelsData SpaceToDepthKernelRef::GetKernelsData(const Params& params, const op } auto dispatchData = SetDefault(newParams, options); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); auto cldnn_jit = GetJitConstants(newParams); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/strided_slice/strided_slice_kernel_ref.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/strided_slice/strided_slice_kernel_ref.cpp index 495292b4f45f3f..46dd741815bd46 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/strided_slice/strided_slice_kernel_ref.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/strided_slice/strided_slice_kernel_ref.cpp @@ -155,7 +155,7 @@ KernelsData StridedSliceKernelRef::GetKernelsData(const Params& params, const op assert(params.GetType() == KernelType::STRIDED_SLICE); auto dispatchData = SetDefault(newParams, options); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); auto cldnn_jit = GetJitConstants(newParams); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/tile/tile_kernel_ref.cpp b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/tile/tile_kernel_ref.cpp index d82835b5bc193c..40a81b62a5c9d3 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/tile/tile_kernel_ref.cpp +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/actual_kernels/tile/tile_kernel_ref.cpp @@ -55,7 +55,7 @@ KernelsData TileKernelRef::GetKernelsData(const Params& params, const optional_p tile_params& newParams = *static_cast(kd.params.get()); auto dispatchData = SetDefault(newParams, options); - auto entry_point = GetEntryPoint(kernelName, newParams.layerID, options); + auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options); auto cldnn_jit = GetJitConstants(newParams); auto jit = CreateJit(kernelName, cldnn_jit, entry_point); diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/cl_kernels/convolution_gpu_bfyx_os_iyx_osv16.cl b/inference-engine/thirdparty/clDNN/kernel_selector/core/cl_kernels/convolution_gpu_bfyx_os_iyx_osv16.cl index 679fa45de520bf..b622f1c1698560 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/cl_kernels/convolution_gpu_bfyx_os_iyx_osv16.cl +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/cl_kernels/convolution_gpu_bfyx_os_iyx_osv16.cl @@ -83,12 +83,11 @@ KERNEL(convolution_gpu_bfyx_os_iyx_osv16)( uint fmg = feature_idx / SUB_GROUP_SIZE; const uint g = split_idx; #endif - UNIT_TYPE in[IN_BLOCK_ARRAY_SIZE]; UNIT_TYPE out[OUTPUT_BLOCK_WIDTH * OUTPUT_BLOCK_HEIGHT]; UNIT_TYPE w[PREFETCH]; uint in_addr; - uint weight_addr = fmg * FILTER_IFM_NUM * FILTER_SIZE_X * FILTER_SIZE_Y * SUB_GROUP_SIZE + lid; + uint weight_addr = fmg * FILTER_IFM_NUM * FILTER_SIZE_X * FILTER_SIZE_Y * OSV_SIZE + lid; #if GROUPED weight_addr += g * FILTER_GROUPS_PITCH; @@ -156,7 +155,7 @@ KERNEL(convolution_gpu_bfyx_os_iyx_osv16)( in_addr += INPUT0_FEATURE_PITCH; for(int pf=0; pf GetSupportedFusedOps() const; virtual JitConstants MakeFusedOpsJitConstants(const base_params ¶ms, const std::vector &conf) const; virtual JitConstants MakeFusedOpsDeclsJitConstants(const base_params ¶ms, const std::vector &conf) const; - -private: - static thread_local size_t counter; }; } // namespace kernel_selector diff --git a/inference-engine/thirdparty/clDNN/kernel_selector/core/kernel_selector_params.h b/inference-engine/thirdparty/clDNN/kernel_selector/core/kernel_selector_params.h index ce5d9062c46b8e..67b393e6e10af6 100644 --- a/inference-engine/thirdparty/clDNN/kernel_selector/core/kernel_selector_params.h +++ b/inference-engine/thirdparty/clDNN/kernel_selector/core/kernel_selector_params.h @@ -404,6 +404,7 @@ struct Params { std::string layerID; std::string forceImplementation; EngineInfo engineInfo; + std::string uniqueID; virtual std::string to_string() const; virtual std::string to_cache_string_v2() const; diff --git a/inference-engine/thirdparty/clDNN/runtime/debug_configuration.cpp b/inference-engine/thirdparty/clDNN/runtime/debug_configuration.cpp index 5182fd14e4866a..4f07f5e1f09459 100644 --- a/inference-engine/thirdparty/clDNN/runtime/debug_configuration.cpp +++ b/inference-engine/thirdparty/clDNN/runtime/debug_configuration.cpp @@ -16,23 +16,45 @@ const char *debug_configuration::prefix = "GPU_Debug: "; static void print_option(std::string option_name, std::string option_value) { GPU_DEBUG_COUT << "Config " << option_name << " = " << option_value << std::endl; } + +static void get_int_env(const std::string &var, int &val) { + if (const auto env_var = std::getenv(var.c_str())) { + val = std::stoi(env_var); + print_option(var, std::to_string(val)); + } +} + +static void get_str_env(const std::string &var, std::string &val) { + if (const auto env_var = std::getenv(var.c_str())) { + val = env_var; + print_option(var, val); + } +} + #endif debug_configuration::debug_configuration() : verbose(0) - , dump_graphs(std::string()) { + , print_multi_kernel_perf(0) + , disable_usm(0) + , dump_graphs(std::string()) + , dump_layers_path(std::string()) + , dump_layers(std::string()) + , dump_layers_dst_only(0) { #ifdef GPU_DEBUG_CONFIG - const std::string OV_GPU_VERBOSE("OV_GPU_Verbose"); - const std::string OV_GPU_DUMP_GRAPHS("OV_GPU_DumpGraphs"); - if (const auto env_var = std::getenv(OV_GPU_VERBOSE.c_str())) { - verbose = std::stoi(env_var); - print_option(OV_GPU_VERBOSE, std::to_string(verbose)); - } - - if (const auto env_var = std::getenv(OV_GPU_DUMP_GRAPHS.c_str())) { - dump_graphs = env_var; - print_option(OV_GPU_DUMP_GRAPHS, dump_graphs); + get_int_env("OV_GPU_Verbose", verbose); + get_int_env("OV_GPU_PrintMultiKernelPerf", print_multi_kernel_perf); + get_int_env("OV_GPU_DisableUsm", disable_usm); + get_str_env("OV_GPU_DumpGraphs", dump_graphs); + get_str_env("OV_GPU_DumpLayersPath", dump_layers_path); + get_str_env("OV_GPU_DumpLayers", dump_layers); + get_int_env("OV_GPU_DumpLayersDstOnly", dump_layers_dst_only); + if (dump_layers_path.length() > 0 && !disable_usm) { + disable_usm = 1; + GPU_DEBUG_COUT << "DisableUsm=1 because of DumpLayersPath" << std::endl; } + if (dump_layers.length() > 0) + dump_layers = " " + dump_layers + " "; // Insert delimiter for easier parsing when used #endif } diff --git a/inference-engine/thirdparty/clDNN/runtime/engine.cpp b/inference-engine/thirdparty/clDNN/runtime/engine.cpp index 561f38f00f4231..d1c81a1fbd3ea2 100644 --- a/inference-engine/thirdparty/clDNN/runtime/engine.cpp +++ b/inference-engine/thirdparty/clDNN/runtime/engine.cpp @@ -7,6 +7,7 @@ #include "cldnn/runtime/memory.hpp" #include "cldnn/runtime/stream.hpp" #include "cldnn/runtime/device_query.hpp" +#include "cldnn/runtime/debug_configuration.hpp" #include "ocl/ocl_engine_factory.hpp" @@ -32,6 +33,10 @@ const device::ptr engine::get_device() const { } bool engine::use_unified_shared_memory() const { + GPU_DEBUG_GET_INSTANCE(debug_config); + GPU_DEBUG_IF(debug_config->disable_usm) { + return false; + } if (_device->get_mem_caps().supports_usm() && _configuration.use_unified_shared_memory) { return true; } diff --git a/inference-engine/thirdparty/clDNN/runtime/kernels_cache.cpp b/inference-engine/thirdparty/clDNN/runtime/kernels_cache.cpp index 014486841f04bc..ed1353697673ea 100644 --- a/inference-engine/thirdparty/clDNN/runtime/kernels_cache.cpp +++ b/inference-engine/thirdparty/clDNN/runtime/kernels_cache.cpp @@ -5,6 +5,7 @@ #include "kernels_factory.hpp" #include "kernels_cache.hpp" #include "ocl/ocl_engine.hpp" +#include "cldnn/runtime/debug_configuration.hpp" #include #include @@ -241,7 +242,7 @@ kernels_cache::kernels_cache(engine& engine) : _engine(engine) { } kernel_id kernels_cache::set_kernel_source( const std::shared_ptr& kernel_string, bool dump_custom_program) { - + std::lock_guard lock(_mutex); // we need unique id in order to avoid conflict across topologies. const auto kernel_num = _kernels.size() + _kernels_code.size(); kernel_id id = kernel_string->entry_point + "_" + std::to_string(kernel_num); @@ -372,6 +373,10 @@ void kernels_cache::build_batch(const engine& build_engine, const batch_program& dump_file << "*/\n"; } if (!err_log.empty()) { + GPU_DEBUG_GET_INSTANCE(debug_config); + GPU_DEBUG_IF(debug_config->verbose) { + std::cout << err_log << std::endl; + } throw std::runtime_error("Program build failed. You may enable OCL source dump to see the error log.\n"); } } diff --git a/inference-engine/thirdparty/clDNN/runtime/kernels_cache.hpp b/inference-engine/thirdparty/clDNN/runtime/kernels_cache.hpp index 931d267e955513..df0d85f5b9ddac 100644 --- a/inference-engine/thirdparty/clDNN/runtime/kernels_cache.hpp +++ b/inference-engine/thirdparty/clDNN/runtime/kernels_cache.hpp @@ -13,11 +13,7 @@ #include #include #include -#include - -#define CLDNN_THREADING_SEQ 0 -#define CLDNN_THREADING_TBB 1 -#define CLDNN_THREADING_THREADPOOL 2 +#include #if (CLDNN_THREADING == CLDNN_THREADING_TBB) #include @@ -111,26 +107,28 @@ class kernels_cache { std::shared_ptr kernel_strings; std::string id; bool dump_custom_program; + size_t hash_value; kernel_code(const std::shared_ptr& _kernel_strings, const std::string& _id, bool _dump_custom_program) : kernel_strings(_kernel_strings), id(_id), - dump_custom_program(_dump_custom_program) {} + dump_custom_program(_dump_custom_program), + hash_value(_kernel_strings->get_hash()) {} - bool operator == (const kernel_code& c2) const { - return kernel_strings->get_hash() == c2.kernel_strings->get_hash(); + bool operator == (const kernel_code& rhs) const { + return (hash_value == rhs.hash_value); } }; - struct hash_kernel_code { - size_t operator()(const kernel_code& x) const { - return std::hash()(x.kernel_strings->get_hash()); + struct cmp_kernel_code { + bool operator()(const kernel_code& x1, const kernel_code& x2) const { + return (x1.hash_value < x2.hash_value); } }; - using kernels_code = std::unordered_set; + using kernels_code = std::set; private: static std::mutex _mutex; diff --git a/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_event.cpp b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_event.cpp index 76e3c8f94ffc73..d40dbf7dfa1cb0 100644 --- a/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_event.cpp +++ b/inference-engine/thirdparty/clDNN/runtime/ocl/ocl_event.cpp @@ -3,6 +3,7 @@ // #include "ocl_event.hpp" +#include "cldnn/runtime/debug_configuration.hpp" #include #include @@ -175,6 +176,17 @@ bool ocl_events::get_profiling_info_impl(std::listprint_multi_kernel_perf) { + if (0 == strcmp(period.name, "executing")) { + GPU_DEBUG_COUT << "Multi-kernel time: "; + for (auto& duration : all_durations[period.name]) + std::cout << " " << (duration.second - duration.first) / 1000; + std::cout << " Total " << sum / 1000 << std::endl; + } + } + info.push_back(get_profiling_interval(period.name, 0, sum)); } diff --git a/inference-engine/thirdparty/clDNN/src/gpu/gather_gpu.cpp b/inference-engine/thirdparty/clDNN/src/gpu/gather_gpu.cpp index e0d51b3f0009ba..d9791de4f2d9d9 100644 --- a/inference-engine/thirdparty/clDNN/src/gpu/gather_gpu.cpp +++ b/inference-engine/thirdparty/clDNN/src/gpu/gather_gpu.cpp @@ -49,6 +49,7 @@ struct gather_gpu : typed_primitive_gpu_impl { gather_params.axis = convert_axis(arg.get_primitive()->axis); gather_params.batch_dim = size_t(arg.get_primitive()->batch_dim); + gather_params.support_neg_ind = arg.get_primitive()->support_neg_ind; gather_params.inputs.push_back(convert_data_tensor(arg.input(1).get_output_layout())); diff --git a/inference-engine/thirdparty/clDNN/src/graph_optimizer/compile_graph.cpp b/inference-engine/thirdparty/clDNN/src/graph_optimizer/compile_graph.cpp index 8c3335aecbb5bb..2a89322c62045c 100644 --- a/inference-engine/thirdparty/clDNN/src/graph_optimizer/compile_graph.cpp +++ b/inference-engine/thirdparty/clDNN/src/graph_optimizer/compile_graph.cpp @@ -10,17 +10,49 @@ #include "program_node.h" #include "cldnn/runtime/engine.hpp" #include "runtime/cldnn_itt.hpp" +#include +#include +#include + +#if (CLDNN_THREADING == CLDNN_THREADING_TBB) +#include +#include +#endif using namespace cldnn; void compile_graph::run(program_impl& p) { OV_ITT_SCOPED_TASK(itt::domains::CLDNN, "CLDNN::pass::CompileGraph"); + size_t order_idx = 0; for (auto& node : p.get_processing_order()) { + node->set_unique_id(std::to_string(order_idx++)); if (!node->is_type()) { node->get_output_layout(); - if (!node->is_type() && !(node->is_type() && node->get_dependencies().empty())) { - node->selected_impl = node->type()->choose_impl(p.get_engine(), *node); + } + } + +#if (CLDNN_THREADING == CLDNN_THREADING_TBB) + const auto n_threads = p.get_engine().configuration().n_threads; + auto arena = std::unique_ptr(new tbb::task_arena()); + arena->initialize(n_threads); + arena->execute([this, &p] { + auto& proc_order = p.get_processing_order(); + tbb::parallel_for(tbb::blocked_range(0, proc_order.size()), [&proc_order, &p](const tbb::blocked_range& r) { + for (auto i = r.begin(); i != r.end(); ++i) { + auto& node = *(std::next(proc_order.begin(), i)); + node->set_unique_id(std::to_string(i)); + if (!node->is_type() && !(node->is_type() && node->get_dependencies().empty())) { + node->selected_impl = node->type()->choose_impl(p.get_engine(), *node); + } } + }); + }); + arena.reset(); +#else + for (auto& node : p.get_processing_order()) { + if (!node->is_type() && !(node->is_type() && node->get_dependencies().empty())) { + node->selected_impl = node->type()->choose_impl(p.get_engine(), *node); } } +#endif } diff --git a/inference-engine/thirdparty/clDNN/src/graph_optimizer/post_input_reorder.cpp b/inference-engine/thirdparty/clDNN/src/graph_optimizer/post_input_reorder.cpp index b4371112d11767..29581b50e92544 100644 --- a/inference-engine/thirdparty/clDNN/src/graph_optimizer/post_input_reorder.cpp +++ b/inference-engine/thirdparty/clDNN/src/graph_optimizer/post_input_reorder.cpp @@ -59,6 +59,7 @@ void post_input_reorder::run(program_impl& p) { input_layout.size, input_layout.data_padding); auto& reorder = add_reorder(p, input, node, current_layout); + reorder.set_unique_id(node->get_unique_id() + "_input_reorder"); reorder.get_output_layout(false); node->set_output_layout(previous_layout, false); reorder.set_selected_impl(reorder.type()->choose_impl(p.get_engine(), reorder)); diff --git a/inference-engine/thirdparty/clDNN/src/graph_optimizer/remove_redundant_reorders.cpp b/inference-engine/thirdparty/clDNN/src/graph_optimizer/remove_redundant_reorders.cpp index 5d1fc6e6977bd2..2e484c00beb653 100644 --- a/inference-engine/thirdparty/clDNN/src/graph_optimizer/remove_redundant_reorders.cpp +++ b/inference-engine/thirdparty/clDNN/src/graph_optimizer/remove_redundant_reorders.cpp @@ -28,6 +28,7 @@ void remove_redundant_reorders::run(program_impl& p) { return; auto& eng = p.get_engine(); + node.set_unique_id(node.get_unique_id() + "_reorder"); auto new_impl = node.type()->choose_impl(eng, node); node.set_selected_impl(std::move(new_impl)); }; diff --git a/inference-engine/thirdparty/clDNN/src/include/program_node.h b/inference-engine/thirdparty/clDNN/src/include/program_node.h index d0e904d3c56379..bbb1748c8abbfb 100644 --- a/inference-engine/thirdparty/clDNN/src/include/program_node.h +++ b/inference-engine/thirdparty/clDNN/src/include/program_node.h @@ -305,7 +305,12 @@ struct program_node { bool need_lockable_memory() const; + std::string get_unique_id() const { return unique_id; } + void set_unique_id(std::string id) { unique_id = id; } + protected: + std::string unique_id; + std::shared_ptr desc; program_impl& myprog; diff --git a/inference-engine/thirdparty/clDNN/src/kernel_selector_helper.cpp b/inference-engine/thirdparty/clDNN/src/kernel_selector_helper.cpp index 716b5fa49eb494..cdcc65d95fdfba 100644 --- a/inference-engine/thirdparty/clDNN/src/kernel_selector_helper.cpp +++ b/inference-engine/thirdparty/clDNN/src/kernel_selector_helper.cpp @@ -734,6 +734,7 @@ void set_params(const program_node& node, kernel_selector::params& params) { const auto& program = node.get_program(); const auto& device_info = program.get_engine().get_device_info(); + params.uniqueID = std::to_string(program.get_id()) + "_" + node.get_unique_id(); params.engineInfo.bSubGroupSupport = device_info.supports_subgroups; params.engineInfo.bSubGroupShortSupport = device_info.supports_subgroups_short; params.engineInfo.bSubGroupCharSupport = device_info.supports_subgroups_char; diff --git a/inference-engine/thirdparty/clDNN/src/network.cpp b/inference-engine/thirdparty/clDNN/src/network.cpp index 0677ea5fbbe250..a5ab53da745a1a 100644 --- a/inference-engine/thirdparty/clDNN/src/network.cpp +++ b/inference-engine/thirdparty/clDNN/src/network.cpp @@ -33,15 +33,9 @@ #include #include -// #define DEBUG_DUMP_PATH "cldnn_dump/" - -#ifdef DEBUG_DUMP_PATH +#ifdef GPU_DEBUG_CONFIG #include #include - -#define DUMP_VERBOSE 0 -#define DUMP_SINGLE_LAYER 0 -#define DUMP_LAYER_NAME "" #endif namespace cldnn { @@ -131,7 +125,7 @@ std::map network::execute(const std::vector static void dump(memory::ptr mem, stream& stream, std::ofstream& file_stream) { auto&& size = mem->get_layout().size; @@ -189,6 +196,8 @@ static void dump(memory::ptr mem, stream& stream, std::ofstream& file_stream) { mem_lock lock(mem, stream); auto mem_ptr = lock.data(); + auto x_pitch = get_x_pitch(mem->get_layout()); + std::stringstream buffer; for (cldnn::tensor::value_type g = 0; g < size.group[0]; ++g) { for (cldnn::tensor::value_type b = 0; b < size.batch[0]; ++b) { @@ -196,10 +205,11 @@ static void dump(memory::ptr mem, stream& stream, std::ofstream& file_stream) { for (cldnn::tensor::value_type w = 0; w < size.spatial[3]; ++w) { for (cldnn::tensor::value_type z = 0; z < size.spatial[2]; ++z) { for (cldnn::tensor::value_type y = 0; y < size.spatial[1]; ++y) { - for (cldnn::tensor::value_type x = 0; x < size.spatial[0]; ++x) { - cldnn::tensor t(cldnn::group(g), cldnn::batch(b), cldnn::feature(f), cldnn::spatial(x, y, z, w)); - size_t input_it = mem->get_layout().get_linear_offset(t); - file_stream << std::fixed << std::setprecision(6) << convert_element(mem_ptr[input_it]) << std::endl; + cldnn::tensor t(cldnn::group(g), cldnn::batch(b), cldnn::feature(f), cldnn::spatial(0, y, z, w)); + size_t input_it = mem->get_layout().get_linear_offset(t); + + for (cldnn::tensor::value_type x = 0; x < size.spatial[0]; ++x, input_it += x_pitch) { + buffer << std::fixed << std::setprecision(6) << convert_element(mem_ptr[input_it]) << std::endl; } } } @@ -207,6 +217,7 @@ static void dump(memory::ptr mem, stream& stream, std::ofstream& file_stream) { } } } + file_stream << buffer.str(); } template <> void dump(memory::ptr mem, stream& stream, std::ofstream& file_stream) { @@ -238,12 +249,13 @@ void dump(memory::ptr mem, stream& stream, std::ofstream& file_stream) } static void log_memory_to_file(memory::ptr mem, stream& stream, std::string layerName) { + GPU_DEBUG_GET_INSTANCE(debug_config); std::string filename = layerName; std::replace(filename.begin(), filename.end(), '\\', '_'); std::replace(filename.begin(), filename.end(), '/', '_'); std::replace(filename.begin(), filename.end(), ' ', '_'); std::replace(filename.begin(), filename.end(), ':', '_'); - filename = DEBUG_DUMP_PATH + filename + ".txt"; + filename = debug_config->dump_layers_path + filename + ".txt"; std::ofstream file_stream(filename); auto mem_dt = mem->get_layout().data_type; @@ -260,6 +272,12 @@ static void log_memory_to_file(memory::ptr mem, stream& stream, std::string laye else if (mem_dt == cldnn::data_types::u8) dump(mem, stream, file_stream); } +#else +static void log_memory_to_file(memory::ptr mem, stream& stream, std::string layerName) { + (void)mem; + (void)stream; + (void)layerName; +} #endif /* Network_impl will always have net_id = 0 when it will be cldnn internal micronetwork (created i.e by propagate_constants @@ -487,25 +505,24 @@ void network_impl::execute(const std::vector& events) { set_arguments(); for (auto& inst : _exec_order) { -#ifdef DEBUG_DUMP_PATH - auto& node = _program->get_node(inst->id()); + GPU_DEBUG_IF(debug_config->dump_layers_path.length() > 0) { + auto& node = _program->get_node(inst->id()); + std::string layer_name = node.id(); + GPU_DEBUG_IF(debug_config->verbose >= 2) { + std::cerr << get_primitive_info(inst->id()) << std::endl; + } - std::string layer_name = node.id(); -#if DUMP_VERBOSE - std::cerr << get_primitive_info(inst->id()) << std::endl; -#endif -#if DUMP_SINGLE_LAYER - if (layer_name == DUMP_LAYER_NAME) { -#endif - std::cerr << "Dump " << layer_name << " layer" << std::endl; - for (size_t i = 0; i < get_primitive(inst->id())->dependencies().size(); i++) { - log_memory_to_file(get_primitive(inst->id())->dep_memory_ptr(i), get_stream(), - layer_name + "_src_" + std::to_string(i)); + GPU_DEBUG_IF(debug_config->dump_layers_dst_only == 0 && + (debug_config->dump_layers.length() == 0 || + (debug_config->dump_layers.length() != 0 && debug_config->dump_layers.find(" " + layer_name + " ") != std::string::npos))) { + std::cout << "Dump " << layer_name << " layer src" << std::endl; + for (size_t i = 0; i < get_primitive(inst->id())->dependencies().size(); i++) { + log_memory_to_file(get_primitive(inst->id())->dep_memory_ptr(i), get_stream(), + layer_name + "_src_" + std::to_string(i)); + } } -#if DUMP_SINGLE_LAYER } -#endif -#endif + GPU_DEBUG_IF(debug_config->verbose >= 1) { GPU_DEBUG_COUT << "Execute " << inst->id() << std::endl; } @@ -517,16 +534,16 @@ void network_impl::execute(const std::vector& events) { } execute_primitive(inst, events); -#ifdef DEBUG_DUMP_PATH - get_stream().finish(); -#if DUMP_SINGLE_LAYER - if (layer_name == DUMP_LAYER_NAME) -#endif - { - log_memory_to_file(get_primitive(inst->id())->output_memory_ptr(), get_stream(), layer_name + "_dst_0"); + GPU_DEBUG_IF(debug_config->dump_layers_path.length() > 0) { + get_stream().finish(); + auto& node = _program->get_node(inst->id()); + std::string layer_name = node.id(); + GPU_DEBUG_IF(debug_config->dump_layers.length() == 0 || + (debug_config->dump_layers.length() != 0 && debug_config->dump_layers.find(" " + layer_name + " ") != std::string::npos)) { + std::cout << "Dump " << layer_name << " layer dst" << std::endl; + log_memory_to_file(get_primitive(inst->id())->output_memory_ptr(), get_stream(), layer_name + "_dst_0"); + } } - -#endif } for (auto& inst : _program->get_processing_order()) { diff --git a/inference-engine/thirdparty/clDNN/src/program.cpp b/inference-engine/thirdparty/clDNN/src/program.cpp index 1bd903640287cd..62bbf38d317cf8 100644 --- a/inference-engine/thirdparty/clDNN/src/program.cpp +++ b/inference-engine/thirdparty/clDNN/src/program.cpp @@ -94,7 +94,6 @@ program_impl::program_impl(engine& engine_ref, tuning_cache(nullptr), is_body_program(is_body_program) { init_primitives(); - kernel_selector::KernelBase::ResetCounter(); set_options(); pm = std::unique_ptr(new pass_manager(*this)); prepare_nodes(topology); diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/debug_config_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/debug_config_gpu_test.cpp new file mode 100644 index 00000000000000..4f9fe3d603d13d --- /dev/null +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/debug_config_gpu_test.cpp @@ -0,0 +1,20 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "test_utils/test_utils.h" +#include "cldnn/runtime/debug_configuration.hpp" + +using namespace cldnn; +using namespace ::tests; + +TEST(debug_config_test, check_debug_config_off_on_release) { +#ifdef NDEBUG + GPU_DEBUG_GET_INSTANCE(debug_config); + GPU_DEBUG_IF(1) { + GTEST_FAIL(); /* This should be disabled in case of release build */ + } +#endif +} diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/gather_gpu_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/gather_gpu_test.cpp index c0387763873953..a6471f4b13af93 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/gather_gpu_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/gather_gpu_test.cpp @@ -12,6 +12,136 @@ using namespace cldnn; using namespace ::tests; +TEST(gather8_gpu_fp16, d323_axisY_bdim_m1) { + // Dictionary : 3x2x3x4x2 + // Indexes : 3x2x3x1 + // Axis : 3 + // batch_dim : -1 + // Output : 3x2x3x3x2 + // Input values in fp16 + + // Indexes: + // 0.f, 0.f, 0.f, 3.f, -3.f, 0.f, 1.f, -3.f, 1.f, -2.f, 0.f, 3.f, -1.f, 1.f, 0.f, 2.f, 0.f, 1.f + // + // Dictionary: + // 1.f 2.f 3.f 4.f 5.f 6.f 7.f 8.f 9.f 10.f 11.f 12.f 13.f 14.f 15.f 16.f 17.f 18.f + // 19.f 20.f 21.f 22.f 23.f 24.f 25.f 26.f 27.f 28.f 29.f 30.f 31.f 32.f 33.f 34.f 35.f 36.f + // 37.f 38.f 39.f 40.f 41.f 42.f 43.f 44.f 45.f 46.f 47.f 48.f 49.f 50.f 51.f 52.f 53.f 54.f + // 55.f 56.f 57.f 58.f 59.f 60.f 61.f 62.f 63.f 64.f 65.f 66.f 67.f 68.f 69.f 70.f 71.f 72.f + // 73.f 74.f 75.f 76.f 77.f 78.f 79.f 80.f 81.f 82.f 83.f 84.f 85.f 86.f 87.f 88.f 89.f 90.f + // 91.f 92.f 93.f 94.f 95.f 96.f 97.f 98.f 99.f 100.f 101.f 102.f 103.f 104.f 105.f 106.f 107.f 108.f + // 109.f 110.f 111.f 112.f 113.f 114.f 115.f 116.f 117.f 118.f 119.f 120.f 121.f 122.f 123.f 124.f 125.f 126.f + // 127.f 128.f 129.f 130.f 131.f 132.f 133.f 134.f 135.f 136.f 137.f 138.f 139.f 140.f 141.f 142.f 143.f 144.f + // + // Output: + // 1.f 2.f 1.f 2.f 1.f 2.f 9.f 10.f 9.f 10.f 9.f 10.f + // 17.f 18.f 17.f 18.f 17.f 18.f 31.f 32.f 27.f 28.f 25.f 26.f + // 39.f 40.f 35.f 6.f 33.f 34.f 47.f 48.f 43.f 44.f 41.f 42.f + // 51.f 52.f 51.f 52.f 51.f 52.f 59.f 60.f 59.f 60.f 59.f 60.f + // 67.f 68.f 67.f 68.f 67.f 68.f 77.f 78.f 73.f 74.f 79.f 80.f + // 85.f 86.f 81.f 82.f 87.f 88.f 93.f 94.f 89.f 90.f 95.f 96.f + // 103.f 104.f 99.f 100.f 97.f 98.f 111.f 112.f 107.f 108.f 105.f 106.f + // 119.f 120.f 115.f 116.f 113.f 114.f 125.f 126.f 121.f 122.f 123.f 124.f + // 133.f 134.f 129.f 130.f 131.f 132.f 141.f 142.f 137.f 138.f 139.f 140.f + + auto& engine = get_test_engine(); + + auto input1 = engine.allocate_memory({ data_types::f16, format::bfzyx, { 3, 2, 2, 4, 3} }); // Dictionary + auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, { 3, 2, 1, 3 } }); // Indexes + auto axis = cldnn::gather::gather_axis::along_y; + int64_t batch_dim = -1; + bool negative_indexes = true; + + set_values(input1, { + FLOAT16(1.f), FLOAT16(2.f), FLOAT16(3.f), FLOAT16(4.f), FLOAT16(5.f), FLOAT16(6.f), FLOAT16(7.f), FLOAT16(8.f), + FLOAT16(9.f), FLOAT16(10.f), FLOAT16(11.f), FLOAT16(12.f), FLOAT16(13.f), FLOAT16(14.f), FLOAT16(15.f), FLOAT16(16.f), + FLOAT16(17.f), FLOAT16(18.f), FLOAT16(19.f), FLOAT16(20.f), FLOAT16(21.f), FLOAT16(22.f), FLOAT16(23.f), FLOAT16(24.f), + + FLOAT16(25.f), FLOAT16(26.f), FLOAT16(27.f), FLOAT16(28.f), FLOAT16(29.f), FLOAT16(30.f), FLOAT16(31.f), FLOAT16(32.f), + FLOAT16(33.f), FLOAT16(34.f), FLOAT16(35.f), FLOAT16(36.f), FLOAT16(37.f), FLOAT16(38.f), FLOAT16(39.f), FLOAT16(40.f), + FLOAT16(41.f), FLOAT16(42.f), FLOAT16(43.f), FLOAT16(44.f), FLOAT16(45.f), FLOAT16(46.f), FLOAT16(47.f), FLOAT16(48.f), + + + FLOAT16(49.f), FLOAT16(50.f), FLOAT16(51.f), FLOAT16(52.f), FLOAT16(53.f), FLOAT16(54.f), FLOAT16(55.f), FLOAT16(56.f), + FLOAT16(57.f), FLOAT16(58.f), FLOAT16(59.f), FLOAT16(60.f), FLOAT16(61.f), FLOAT16(62.f), FLOAT16(63.f), FLOAT16(64.f), + FLOAT16(65.f), FLOAT16(66.f), FLOAT16(67.f), FLOAT16(68.f), FLOAT16(69.f), FLOAT16(70.f), FLOAT16(71.f), FLOAT16(72.f), + + FLOAT16(73.f), FLOAT16(74.f), FLOAT16(75.f), FLOAT16(76.f), FLOAT16(77.f), FLOAT16(78.f), FLOAT16(79.f), FLOAT16(80.f), + FLOAT16(81.f), FLOAT16(82.f), FLOAT16(83.f), FLOAT16(84.f), FLOAT16(85.f), FLOAT16(86.f), FLOAT16(87.f), FLOAT16(88.f), + FLOAT16(89.f), FLOAT16(90.f), FLOAT16(91.f), FLOAT16(92.f), FLOAT16(93.f), FLOAT16(94.f), FLOAT16(95.f), FLOAT16(96.f), + + + FLOAT16(97.f), FLOAT16(98.f), FLOAT16(99.f), FLOAT16(100.f), FLOAT16(101.f), FLOAT16(102.f), FLOAT16(103.f), FLOAT16(104.f), + FLOAT16(105.f), FLOAT16(106.f), FLOAT16(107.f), FLOAT16(108.f), FLOAT16(109.f), FLOAT16(110.f), FLOAT16(111.f), FLOAT16(112.f), + FLOAT16(113.f), FLOAT16(114.f), FLOAT16(115.f), FLOAT16(116.f), FLOAT16(117.f), FLOAT16(118.f), FLOAT16(119.f), FLOAT16(120.f), + + FLOAT16(121.f), FLOAT16(122.f), FLOAT16(123.f), FLOAT16(124.f), FLOAT16(125.f), FLOAT16(126.f), FLOAT16(127.f), FLOAT16(128.f), + FLOAT16(129.f), FLOAT16(130.f), FLOAT16(131.f), FLOAT16(132.f), FLOAT16(133.f), FLOAT16(134.f), FLOAT16(135.f), FLOAT16(136.f), + FLOAT16(137.f), FLOAT16(138.f), FLOAT16(139.f), FLOAT16(140.f), FLOAT16(141.f), FLOAT16(142.f), FLOAT16(143.f), FLOAT16(144.f) + }); + + set_values(input2, { + 0.f, 0.f, 0.f, + 3.f, -3.f, 0.f, + + 1.f, -3.f, 1.f, + -2.f, 0.f, 3.f, + + -1.f, 1.f, 0.f, + 2.f, 0.f, 1.f + }); + + topology topology; + topology.add(input_layout("InputDictionary", input1->get_layout())); + topology.add(input_layout("InputText", input2->get_layout())); + topology.add( + gather("gather", "InputDictionary", "InputText", axis, format::bfzyx, tensor(3, 2, 2, 3, 3), batch_dim, negative_indexes) + ); + + network network(engine, topology); + + network.set_input_data("InputDictionary", input1); + network.set_input_data("InputText", input2); + + auto outputs = network.execute(); + + auto output = outputs.at("gather").get_memory(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + + std::vector expected_results = { + 1.f, 2.f, 1.f, 2.f, 1.f, 2.f, + 9.f, 10.f, 9.f, 10.f, 9.f, 10.f, + 17.f, 18.f, 17.f, 18.f, 17.f, 18.f, + + 31.f, 32.f, 27.f, 28.f, 25.f, 26.f, + 39.f, 40.f, 35.f, 36.f, 33.f, 34.f, + 47.f, 48.f, 43.f, 44.f, 41.f, 42.f, + + + 51.f, 52.f, 51.f, 52.f, 51.f, 52.f, + 59.f, 60.f, 59.f, 60.f, 59.f, 60.f, + 67.f, 68.f, 67.f, 68.f, 67.f, 68.f, + + 77.f, 78.f, 73.f, 74.f, 79.f, 80.f, + 85.f, 86.f, 81.f, 82.f, 87.f, 88.f, + 93.f, 94.f, 89.f, 90.f, 95.f, 96.f, + + + 103.f, 104.f, 99.f, 100.f, 97.f, 98.f, + 111.f, 112.f, 107.f, 108.f, 105.f, 106.f, + 119.f, 120.f, 115.f, 116.f, 113.f, 114.f, + + 125.f, 126.f, 121.f, 122.f, 123.f, 124.f, + 133.f, 134.f, 129.f, 130.f, 131.f, 132.f, + 141.f, 142.f, 137.f, 138.f, 139.f, 140.f + }; + + for (size_t i = 0; i < expected_results.size(); ++i) { + EXPECT_EQ(expected_results[i], float16_to_float32(output_ptr[i])); + } +} + + TEST(gather7_gpu_fp16, d222_axisX_bdim_m1) { // Dictionary : 2x2x2x2x2x2 // Indexes : 2x2x2x1 diff --git a/model-optimizer/CMakeLists.txt b/model-optimizer/CMakeLists.txt index 60860d7a7aad7a..19056e1b60c688 100644 --- a/model-optimizer/CMakeLists.txt +++ b/model-optimizer/CMakeLists.txt @@ -1,10 +1,8 @@ # Copyright (C) 2018-2021 Intel Corporation # SPDX-License-Identifier: Apache-2.0 -if (NOT NGRAPH_PYTHON_BUILD_ENABLE) - message(WARNING "Please enable nGraph Python API (_pyngraph) target to enable Model Optimizer target") -elseif(NOT ENABLE_PYTHON) - message(WARNING "Please enable IE Python API (ie_api and offline_transformations_api) targets to enable Model Optimizer target") +if(NOT ENABLE_PYTHON) + message(WARNING "Please enable IE & nGraph Python API (ie_api and offline_transformations_api) targets to enable Model Optimizer target") else() add_custom_target(model_optimizer DEPENDS ie_api offline_transformations_api inference_engine_ir_reader) if(ENABLE_TESTS) diff --git a/model-optimizer/automation/package_BOM.txt b/model-optimizer/automation/package_BOM.txt index 6f04528816844a..4adb1e22aa2e2d 100644 --- a/model-optimizer/automation/package_BOM.txt +++ b/model-optimizer/automation/package_BOM.txt @@ -175,7 +175,6 @@ extensions/front/kaldi/tdnn_component_replacer.py extensions/front/LayerNorm.py extensions/front/Log1p.py extensions/front/MatMul_normalizer.py -extensions/front/Mish_fusion.py extensions/front/MoveEmbeddedInputsToInputs.py extensions/front/mxnet/__init__.py extensions/front/mxnet/activation.py @@ -213,6 +212,8 @@ extensions/front/mxnet/instance_norm_ext.py extensions/front/mxnet/leaky_relu.py extensions/front/mxnet/lrn_ext.py extensions/front/mxnet/max_ext.py +extensions/front/mxnet/modulated_deformable_conv_ext.py +extensions/front/mxnet/modulated_deformable_conv_replacer.py extensions/front/mxnet/multibox_detection_ext.py extensions/front/mxnet/mx_reshape_reverse.py extensions/front/mxnet/mx_reshape_to_reshape.py @@ -329,12 +330,10 @@ extensions/front/onnx/priorbox_clustered_ext.py extensions/front/onnx/priorbox_ext.py extensions/front/onnx/priorgridgenerator_ext.py extensions/front/onnx/proposal_ext.py -extensions/front/onnx/quantize_dequantize_linear.py extensions/front/onnx/quantize_ext.py extensions/front/onnx/quantize_linear_ext.py extensions/front/onnx/range_ext.py extensions/front/onnx/reduce_ext.py -extensions/front/onnx/remove_filtering_boxes_by_size.py extensions/front/onnx/reshape_ext.py extensions/front/onnx/resize_ext.py extensions/front/onnx/reverse_sequence_ext.py @@ -371,13 +370,11 @@ extensions/front/RollWithEmptyAxesReplacer.py extensions/front/scatter_normalizer.py extensions/front/SizeReplacer.py extensions/front/softmax.py -extensions/front/Softplus_fusion.py extensions/front/softsign_replacer.py extensions/front/sparse_to_dense_replacer.py extensions/front/split_normalizer.py extensions/front/SqueezeNormalize.py extensions/front/sub.py -extensions/front/Swish_fusion.py extensions/front/tf/__init__.py extensions/front/tf/activation_ext.py extensions/front/tf/argmax_ext.py diff --git a/model-optimizer/extensions/back/blob_normalizer.py b/model-optimizer/extensions/back/blob_normalizer.py index 53f1118eac51cc..4c35de5634eb8d 100644 --- a/model-optimizer/extensions/back/blob_normalizer.py +++ b/model-optimizer/extensions/back/blob_normalizer.py @@ -46,7 +46,7 @@ def replace_pattern(self, graph: Graph, match: dict): def find_and_replace_pattern(self, graph: Graph): for node in graph.get_op_nodes(): if node.soft_get('type').lower() not in OpVersioning.opset_1_types and \ - not node.soft_get('version') in ["opset2", "opset3", "opset4"]: + not node.soft_get('version') in ["opset2", "opset3", "opset4", "opset8"]: continue for _, d in node.in_edges().items(): diff --git a/model-optimizer/extensions/back/op_versioning.py b/model-optimizer/extensions/back/op_versioning.py index f8a8141a8c0895..5afd10a5d12a7c 100644 --- a/model-optimizer/extensions/back/op_versioning.py +++ b/model-optimizer/extensions/back/op_versioning.py @@ -33,7 +33,6 @@ class OpVersioning(BackReplacementPattern): "ConvolutionBackpropData", "Cos", "Cosh", - "DeformableConvolution", "DeformablePSROIPooling", "DepthToSpace", "DetectionOutput", diff --git a/model-optimizer/extensions/front/Mish_fusion.py b/model-optimizer/extensions/front/Mish_fusion.py deleted file mode 100644 index f86ea349944159..00000000000000 --- a/model-optimizer/extensions/front/Mish_fusion.py +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright (C) 2018-2021 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 - -from extensions.front.Softplus_fusion import SoftplusFusion -from extensions.ops.activation_ops import Mish -from mo.front.common.replacement import FrontReplacementSubgraph -from mo.front.subgraph_matcher import SubgraphMatch -from mo.graph.graph import Graph, rename_nodes - - -class MishFusion(FrontReplacementSubgraph): - """ - The transformation looks for the pattern with Softplus defining the Mish function: Mish(x) = x * tanh(SoftPlus(x)). - """ - enabled = True - - def run_after(self): - return [SoftplusFusion] - - def pattern(self): - return dict( - nodes=[ - ('mul', dict(op='Mul')), - ('tanh', dict(op='Tanh')), - ('softplus', dict(op='SoftPlus')), - ], - edges=[ - ('softplus', 'tanh'), - ('tanh', 'mul'), - ]) - - def replace_sub_graph(self, graph: Graph, match: [dict, SubgraphMatch]): - mul = match['mul'] - mul_name = mul.soft_get('name', mul.id) - softplus = match['softplus'] - - # determine the input port of Mul which gets the 'input' node output - input_port_idx = int(mul.in_port(0).get_connection().get_source().node.soft_get('op') == 'Tanh') - - # check that the same tensor provided as input to Mul and SoftPlus - if mul.in_port(input_port_idx).get_source() != softplus.in_port(0).get_source(): - return - - mish = Mish(graph, {}).create_node() - mish.in_port(0).connect(mul.in_port(input_port_idx).get_source()) - mul.out_port(0).get_connection().set_source(mish.out_port(0)) - - rename_nodes([(mul, mul_name + '/TBR'), (mish, mul_name)]) diff --git a/model-optimizer/extensions/front/Softplus_fusion.py b/model-optimizer/extensions/front/Softplus_fusion.py deleted file mode 100644 index 4d600e1b969b77..00000000000000 --- a/model-optimizer/extensions/front/Softplus_fusion.py +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright (C) 2018-2021 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 - -import numpy as np - -from extensions.ops.activation_ops import SoftPlus -from mo.front.common.replacement import FrontReplacementSubgraph -from mo.front.subgraph_matcher import SubgraphMatch -from mo.graph.graph import Graph, rename_nodes -from mo.middle.pattern_match import check_value - - -class SoftplusFusion(FrontReplacementSubgraph): - """ - The transformation looks for the pattern for the Softplus function: Softplus(x) = ln(1 + e^x) - """ - enabled = True - - def pattern(self): - return dict( - nodes=[ - ('exp', dict(op='Exp')), - ('add', dict(op='Add')), - ('const_1', dict(op='Const', value=lambda v: check_value(v, lambda x: np.allclose(x, 1.0, atol=1e-6)))), - ('ln', dict(op='Log')), - ], - edges=[ - ('exp', 'add', {}), - ('const_1', 'add', {}), - ('add', 'ln', {}), - ]) - - def replace_sub_graph(self, graph: Graph, match: [dict, SubgraphMatch]): - ln = match['ln'] - exp = match['exp'] - - ln_name = ln.soft_get('name', ln.id) - - softplus = SoftPlus(graph, {}).create_node() - softplus.in_port(0).connect(exp.in_port(0).get_source()) - ln.out_port(0).get_connection().set_source(softplus.out_port(0)) - - rename_nodes([(ln, ln_name + '/TBR'), (softplus, ln_name)]) diff --git a/model-optimizer/extensions/front/Swish_fusion.py b/model-optimizer/extensions/front/Swish_fusion.py deleted file mode 100644 index 48cc69ca540fb5..00000000000000 --- a/model-optimizer/extensions/front/Swish_fusion.py +++ /dev/null @@ -1,87 +0,0 @@ -# Copyright (C) 2018-2021 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 - -from extensions.ops.activation_ops import Swish -from mo.front.common.replacement import FrontReplacementSubgraph -from mo.front.subgraph_matcher import SubgraphMatch -from mo.graph.graph import Graph, rename_nodes - - -class SwishWithSigmoidWithoutBeta(FrontReplacementSubgraph): - """ - The transformation looks for the pattern with Sigmoid defining the Swish function: Swish(x) = x * Sigmoid(x) - """ - enabled = True - - def pattern(self): - return dict( - nodes=[ - ('sigmoid', dict(op='Sigmoid')), - ('mul', dict(op='Mul')), - ], - edges=[ - ('sigmoid', 'mul', {}), - ]) - - def replace_sub_graph(self, graph: Graph, match: [dict, SubgraphMatch]): - sigmoid = match['sigmoid'] - mul = match['mul'] - mul_name = mul.soft_get('name', mul.id) - - # determine the input port of Mul which gets the 'input' node output - mul_input_port_idx = int(mul.in_port(0).get_connection().get_source().node.soft_get('op') == 'Sigmoid') - - # check that the same tensor provided as input to Mul and Sigmoid - if mul.in_port(mul_input_port_idx).get_source() != sigmoid.in_port(0).get_source(): - return - - swish = Swish(graph, {}).create_node() - swish.in_port(0).connect(sigmoid.in_port(0).get_source()) - mul.out_port(0).get_connection().set_source(swish.out_port(0)) - - rename_nodes([(mul, mul_name + '/TBR'), (swish, mul_name)]) - - -class SwishWithSigmoidWithBeta(FrontReplacementSubgraph): - """ - The transformation looks for the pattern with Sigmoid defining the Swish function: Swish(x) = x * Sigmoid(x * beta) - """ - enabled = True - - def pattern(self): - return dict( - nodes=[ - ('sigmoid', dict(op='Sigmoid')), - ('beta', dict()), - ('mul_beta', dict(op='Mul')), - ('mul', dict(op='Mul')), - ], - edges=[ - ('beta', 'mul_beta', {}), - ('mul_beta', 'sigmoid', {}), - ('sigmoid', 'mul', {}), - ]) - - def replace_sub_graph(self, graph: Graph, match: [dict, SubgraphMatch]): - beta = match['beta'] - mul = match['mul'] - mul_beta = match['mul_beta'] - mul_name = mul.soft_get('name', mul.id) - - # determine the input port of Muls which get the 'input' node output - mul_beta_input_port_idx = int(mul_beta.in_port(0).get_connection().get_source().node.id == beta.id) - mul_input_port_idx = int(mul.in_port(0).get_connection().get_source().node.soft_get('op') == 'Sigmoid') - - # check that the same tensor provided as input to Mul and MulBeta - if mul.in_port(mul_input_port_idx).get_source() != mul_beta.in_port(mul_beta_input_port_idx).get_source(): - return - - swish = Swish(graph, {}).create_node() - swish.in_port(0).connect(mul_beta.in_port(mul_beta_input_port_idx).get_source()) - - # connect Beta value - swish.in_port(1).connect(mul_beta.in_port(1 - mul_beta_input_port_idx).get_source()) - - mul.out_port(0).get_connection().set_source(swish.out_port(0)) - - rename_nodes([(mul, mul_name + '/TBR'), (swish, mul_name)]) diff --git a/model-optimizer/extensions/front/mxnet/modulated_deformable_conv_ext.py b/model-optimizer/extensions/front/mxnet/modulated_deformable_conv_ext.py new file mode 100644 index 00000000000000..cee2d111c98154 --- /dev/null +++ b/model-optimizer/extensions/front/mxnet/modulated_deformable_conv_ext.py @@ -0,0 +1,61 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import numpy as np + +from mo.front.extractor import FrontExtractorOp +from mo.front.mxnet.extractors.utils import get_mxnet_layer_attrs +from mo.ops.deformable_convolution import DeformableConvolution + + +class ModulatedDeformableConvolutionExtractor(FrontExtractorOp): + op = '_contrib_ModulatedDeformableConvolution' + enabled = True + + @classmethod + def extract(cls, node): + attr = get_mxnet_layer_attrs(node.symbol_dict) + + kernel = attr.tuple("kernel", int, None) + stride = attr.tuple("stride", int, tuple(np.ones(len(kernel), dtype=np.int64))) + padding = attr.tuple("pad", int, tuple(np.zeros(len(kernel), dtype=np.int64))) + dilate = attr.tuple("dilate", int, tuple(np.ones(len(kernel), dtype=np.int64))) + num_deformable_group = attr.int("num_deformable_group", 1) + num_group = attr.int("num_group", 1) + output = attr.int("num_filter", None) + bias_term = attr.str("no_bias", 'False') == 'False' + + final_dilations = np.array([1, 1, *[d for d in dilate]], dtype=np.int64) if dilate is not None else None + + node_attrs = { + 'op': __class__.op, + 'bias_addable': True, + 'bias_term': bias_term, + 'pad': np.array([[0, 0], [0, 0], *[[pad, pad] for pad in padding]], dtype=np.int64), + 'pad_spatial_shape': np.array([[pad, pad] for pad in padding], dtype=np.int64), + 'dilation': final_dilations, + 'output_spatial_shape': None, + 'output_shape': None, + 'stride': np.array([1, 1, *[s for s in stride]], dtype=np.int64), + 'group': num_group, + 'deformable_group': num_deformable_group, + 'output': output, + 'kernel_spatial': np.array([k for k in kernel], dtype=np.int64), + 'bilinear_interpolation_pad': True, + + 'input_feature_channel': 1, + 'output_feature_channel': 0, + 'kernel_spatial_idx': None, + 'reshape_kernel': True, + 'weights_index': 2, + 'in_ports_count': 4, + + 'spatial_dims': None, + 'channel_dims': np.array([1], dtype=np.int64), + 'batch_dims': np.array([0], dtype=np.int64), + 'layout': 'NCHW', + } + + # update the attributes of the node + DeformableConvolution.update_node_stat(node, node_attrs) + return cls.enabled diff --git a/model-optimizer/extensions/front/mxnet/modulated_deformable_conv_replacer.py b/model-optimizer/extensions/front/mxnet/modulated_deformable_conv_replacer.py new file mode 100644 index 00000000000000..e3f95fc0f5a835 --- /dev/null +++ b/model-optimizer/extensions/front/mxnet/modulated_deformable_conv_replacer.py @@ -0,0 +1,22 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +from mo.front.common.replacement import FrontReplacementPattern +from mo.graph.graph import Graph + + +class DeformableConvolutionReplacer(FrontReplacementPattern): + # swap mask and weights inputs for ModulatedDeformableConvolution according to the specification + enabled = True + + def find_and_replace_pattern(self, graph: Graph): + + for deform_conv in graph.get_op_nodes(type='DeformableConvolution'): + if len(deform_conv.get_inputs()) != 4: + return + + m_source = deform_conv.in_port(2).get_source() + deform_conv.in_port(2).disconnect() + + deform_conv.in_port(3).get_connection().set_destination(deform_conv.in_port(2)) + m_source.connect(deform_conv.in_port(3)) diff --git a/model-optimizer/extensions/front/onnx/quantize_dequantize_linear.py b/model-optimizer/extensions/front/onnx/quantize_dequantize_linear.py deleted file mode 100644 index 5607c336cd16ec..00000000000000 --- a/model-optimizer/extensions/front/onnx/quantize_dequantize_linear.py +++ /dev/null @@ -1,87 +0,0 @@ -# Copyright (C) 2018-2021 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 - -import logging as log - -import numpy as np - -from extensions.ops.fakequantize import FakeQuantize -from mo.front.common.replacement import FrontReplacementSubgraph -from mo.front.subgraph_matcher import SubgraphMatch -from mo.graph.graph import Graph, rename_nodes -from mo.ops.const import Const -from mo.utils.error import Error - - -class QuantizeDequantizeLinear(FrontReplacementSubgraph): - """ - Fuses QuantizeLinear and DequantizeLinear nodes into single FakeQuantize. - Covers cases when the values for zero point and scale are same in both QuantizeLinear and DequantizeLinear. - """ - enabled = True - - def pattern(self): - return dict( - nodes=[ - ('quantize', dict(op='QuantizeLinear')), - ('dequantize', dict(op='DequantizeLinear')), - ], - edges=[ - ('quantize', 'dequantize', {'in': 0}), - ] - ) - - def replace_sub_graph(self, graph: Graph, match: [dict, SubgraphMatch]): - - q = match['quantize'] - dq = match['dequantize'] - - q_scale = q.in_port(1).get_source().node - q_zerop = q.in_port(2).get_source().node - dq_scale = dq.in_port(1).get_source().node - dq_zerop = dq.in_port(2).get_source().node - - inp_port = q.in_port(0).get_source() - name = inp_port.node.soft_get('name', inp_port.node.id) - - # only constant as for zero_point/scale supported - if q_scale.soft_get('type') == 'Const' and dq_scale.soft_get('type') == 'Const' and \ - q_zerop.soft_get('type') == 'Const' and dq_zerop.soft_get('type') == 'Const': - - # only patterns with same scale/zero_point values for Q and DQ are supported - if q_scale.value == dq_scale.value and q_zerop.value == dq_zerop.value: - log.debug('Found Q-DQ pattern after {}'.format(name)) - - zero_point_type = q_zerop.value.dtype - # data type affects range of output values: [-128..127] or [0..255] - if zero_point_type == np.int8: - output_min_value = -128.0 - output_max_value = 127.0 - elif zero_point_type == np.uint8: - output_min_value = 0.0 - output_max_value = 255.0 - else: - raise Error('Not supported type {} for zero point value in node {}'.format( - zero_point_type, q_zerop.soft_get('name'))) - min_value = q_scale.value * (output_min_value - q_zerop.value) - max_value = q_scale.value * (output_max_value - q_zerop.value) - input_min = Const(graph, {'value': np.array(min_value)}).create_node() - input_max = Const(graph, {'value': np.array(max_value)}).create_node() - - FQ = FakeQuantize(graph, { - 'levels': 256, - 'name': match['quantize'].name + '_Dequantize/FakeQuantize' - }).create_node() - - FQ.in_port(0).connect(match['quantize'].in_port(0).get_source()) - FQ.in_port(1).connect(input_min.out_port(0)) - FQ.in_port(2).connect(input_max.out_port(0)) - FQ.in_port(3).connect(input_min.out_port(0)) - FQ.in_port(4).connect(input_max.out_port(0)) - - match['dequantize'].out_port(0).get_connection().set_source(FQ.out_port(0)) - dq_name = match['dequantize'].soft_get('name', match['dequantize'].id) - rename_nodes([(match['dequantize'], dq_name + '/to_be_removed'), (FQ, dq_name)]) - else: - raise Error('QuantizeLinear and DequantizeLinear (after {}) have different scale or zero-point values, ' - 'cannot fuse into FakeQuantize!'.format(name)) diff --git a/model-optimizer/extensions/front/onnx/remove_filtering_boxes_by_size.py b/model-optimizer/extensions/front/onnx/remove_filtering_boxes_by_size.py deleted file mode 100644 index 01755ea4636c49..00000000000000 --- a/model-optimizer/extensions/front/onnx/remove_filtering_boxes_by_size.py +++ /dev/null @@ -1,117 +0,0 @@ -# Copyright (C) 2018-2021 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 - -from extensions.front.split_normalizer import AttributedVariadicSplitToVariadicSplit -from extensions.ops.range import Range -from mo.front.common.partial_infer.utils import int64_array -from mo.front.common.replacement import FrontReplacementSubgraph -from mo.front.tf.graph_utils import create_op_node_with_second_input -from mo.graph.graph import Graph -from mo.graph.graph import Node -from mo.ops.const import Const -from mo.ops.shape import Shape -from mo.ops.squeeze import Squeeze -from mo.utils.shape import node_to_get_batch_value - - -def skip_nodes_by_condition(current_node: Node, condition: callable): - while condition(current_node): - current_node = current_node.in_node() - return current_node - - -class RemoveFilteringBoxesBySize(FrontReplacementSubgraph): - """ - The transformation looks for a sub-graph that selects boxes with nonzero height and width. The output node of this - sub-graph is a Cast node that produces indices of nodes to be preserved. The transformation creates a new sub-graph - that produces a tensor with values from 0 to input.shape[0] to select all boxes. The output of this sub-graph will - be used in the NonMaxSuppression so the implementation of this layer should ignore boxes with negative sizes. - """ - enabled = True - force_clean_up = True - - def run_after(self): - return [AttributedVariadicSplitToVariadicSplit] - - def pattern(self): - return dict( - nodes=[ - ('split', dict(op='VariadicSplit')), - ('sub_1', dict(op='Sub')), - ('sub_2', dict(op='Sub')), - ('add_1', dict(op='Add')), - ('add_2', dict(op='Add')), - ('concat', dict(op='Concat')), - ('split_2', dict(op='VariadicSplit')), - ('squeeze_1', dict(op='Squeeze')), - ('squeeze_2', dict(op='Squeeze')), - ('less_1', dict(op='Less')), - ('less_2', dict(op='Less')), - ('not_1', dict(op='LogicalNot')), - ('not_2', dict(op='LogicalNot')), - ('cast_11', dict(op='Cast')), - ('cast_12', dict(op='Cast')), - ('cast_21', dict(op='Cast')), - ('cast_22', dict(op='Cast')), - ('and', dict(op='LogicalAnd')), - ('cast_31', dict(op='Cast')), - ('cast_32', dict(op='Cast')), - ('nonzero', dict(op='NonZero')), - ('transpose', dict(op='Transpose')), - ('squeeze', dict(op='Squeeze')), - ('cast', dict(op='Cast')), - ], - edges=[ - ('split', 'sub_1', {'in': 0, 'out': 2}), - ('split', 'sub_1', {'in': 1, 'out': 0}), - ('split', 'sub_2', {'in': 0, 'out': 3}), - ('split', 'sub_2', {'in': 1, 'out': 1}), - ('sub_1', 'add_1', {}), - ('sub_2', 'add_2', {}), - ('split', 'concat', {'in': 0, 'out': 0}), - ('split', 'concat', {'in': 1, 'out': 1}), - ('add_1', 'concat', {'in': 2, 'out': 0}), - ('add_2', 'concat', {'in': 3, 'out': 0}), - ('concat', 'split_2', {}), - ('split_2', 'squeeze_1', {'in': 0, 'out': 2}), - ('split_2', 'squeeze_2', {'in': 0, 'out': 3}), - ('squeeze_1', 'less_1', {}), - ('squeeze_2', 'less_2', {}), - ('less_1', 'not_1', {}), - ('less_2', 'not_2', {}), - ('not_1', 'cast_11', {}), - ('cast_11', 'cast_12', {}), - ('not_2', 'cast_21', {}), - ('cast_21', 'cast_22', {}), - ('cast_12', 'and', {}), - ('cast_22', 'and', {}), - ('and', 'cast_31', {}), - ('cast_31', 'cast_32', {}), - ('cast_32', 'nonzero', {}), - ('nonzero', 'transpose', {}), - ('transpose', 'squeeze', {}), - ('squeeze', 'cast', {}), - ]) - - def replace_sub_graph(self, graph: Graph, match: dict): - source_connection = match['split'].in_port(0).get_connection() - source_node = source_connection.get_source().node - cast_node = match['cast'] - - range_node = Range(graph, {'name': source_node.id + '/Range'}).create_node() - start_node = Const(graph, {'name': range_node.id + '/Start', 'value': int64_array(0)}).create_node() - - step_node = Const(graph, {'name': range_node.id + '/Step', 'value': int64_array(1)}).create_node() - input_shape_node = Shape(graph, {'name': start_node.id + '/Shape'}).create_node() - input_shape_node.in_port(0).connect(source_node.out_port(0)) - - limit_node_1D = node_to_get_batch_value(input_shape_node) - limit_node = create_op_node_with_second_input(graph, Squeeze, int64_array([0]), - {'name': source_node.id + '/batch_0D_value'}, limit_node_1D) - - range_node.in_port(0).connect(start_node.out_port(0)) - range_node.in_port(1).connect(limit_node.out_port(0)) - range_node.in_port(2).connect(step_node.out_port(0)) - cast_node.out_port(0).get_connection().set_source(range_node.out_port(0)) - - graph.remove_nodes_from([node.id for node in match.values()]) diff --git a/model-optimizer/extensions/middle/ConvertGroupedStridedSlice.py b/model-optimizer/extensions/middle/ConvertGroupedStridedSlice.py index b6ad3a295e95f9..68b8ff54e9805a 100644 --- a/model-optimizer/extensions/middle/ConvertGroupedStridedSlice.py +++ b/model-optimizer/extensions/middle/ConvertGroupedStridedSlice.py @@ -154,7 +154,7 @@ def find_and_replace_pattern(self, graph: Graph): size_splits.append(l - prev_r) shape[split_channel_dim] = l - prev_r data_node = Op._create_data_node(graph, 'fake_data_'+out_nodes[0].name, {'shape': shape}) - add_opoutput(graph, data_node.id, 0, False) + add_opoutput(graph, data_node.id, 0, False, keep_output_port=True) final_data_nodes_list.append(data_node) prev_r = r @@ -167,7 +167,7 @@ def find_and_replace_pattern(self, graph: Graph): shape[split_channel_dim] = input_shape[split_channel_dim] - prev_r size_splits.append(input_shape[split_channel_dim] - prev_r) data_node = Op._create_data_node(graph, 'fake_data_'+out_nodes[0].name, {'shape': shape}) - add_opoutput(graph, data_node.id, 0, False) + add_opoutput(graph, data_node.id, 0, False, keep_output_port=True) final_data_nodes_list.append(data_node) for node in out_nodes: diff --git a/model-optimizer/install_prerequisites/install_prerequisites.bat b/model-optimizer/install_prerequisites/install_prerequisites.bat index ac756ad490507f..7d2aca04fc9fbe 100644 --- a/model-optimizer/install_prerequisites/install_prerequisites.bat +++ b/model-optimizer/install_prerequisites/install_prerequisites.bat @@ -6,6 +6,8 @@ :: Check if Python is installed setlocal +set ROOT_DIR=%~dp0 + python --version 2>NUL if errorlevel 1 ( echo Error^: Python is not installed. Please install Python 3.5 ^(64-bit^) or higher from https://www.python.org/downloads/ @@ -35,10 +37,16 @@ if not "%python_ver%"=="okay" ( :: install Python modules +set USE_VENV="false" +set VENV_DIR=%USERPROFILE%\Documents\Intel\OpenVINO\venv_openvino IF /I "%1%" EQU "" ( set postfix= ) ELSE ( + IF /I "%1%" EQU "venv" ( + set postfix= + set USE_VENV="true" + ) ELSE ( IF /I "%1%" EQU "caffe" ( set postfix=_caffe ) ELSE ( @@ -59,6 +67,7 @@ IF /I "%1%" EQU "" ( ) ELSE ( echo Unsupported framework goto error + ) ) ) ) @@ -67,10 +76,20 @@ IF /I "%1%" EQU "" ( ) ) -pip3 install --user -r ..\requirements%postfix%.txt +IF /I "%2%" EQU "venv" ( + set USE_VENV="true" +) + +IF %USE_VENV% == "true" ( + python -m venv "%VENV_DIR%" + call "%VENV_DIR%\Scripts\activate.bat" +) + +python -m pip install -U pip +python -m pip install -r "%ROOT_DIR%..\requirements%postfix%.txt" :: Chek MO version -set python_command='python "%~dp0..\mo\utils\extract_release_version.py"' +set python_command='python "%ROOT_DIR%..\mo\utils\extract_release_version.py"' FOR /F "delims=" %%i IN (%python_command%) DO set mo_release_version=%%i IF "%mo_release_version%" == "None.None" ( set mo_is_custom="true" @@ -80,12 +99,12 @@ IF "%mo_release_version%" == "None.None" ( :: Check if existing IE Python bindings satisfy requirements set errorlevel= -python "%~dp0..\mo\utils\find_ie_version.py" +python "%ROOT_DIR%..\mo\utils\find_ie_version.py" IF %errorlevel% EQU 0 goto ie_search_end :: Check if OV already installed via pip set errorlevel= -pip3 show openvino +python -m pip show openvino IF %errorlevel% EQU 0 ( IF %mo_is_custom% == "true" ( echo [ WARNING ] OpenVINO ^(TM^) Toolkit version installed in pip is incompatible with the Model Optimizer @@ -110,7 +129,7 @@ IF %mo_is_custom% == "true" ( ) set errorlevel= -pip3 install openvino==%mo_release_version% +python -m pip install openvino==%mo_release_version% IF %errorlevel% NEQ 0 ( echo [ WARNING ] Could not find the OpenVINO ^(TM^) toolkit version %mo_release_version% in pip echo [ WARNING ] The highest OpenVINO ^(TM^) toolkit version will be installed ^(may be incompatible with current Model Optimizer version^) @@ -119,17 +138,17 @@ IF %errorlevel% NEQ 0 ( ) set errorlevel= -python "%~dp0..\mo\utils\find_ie_version.py" +python "%ROOT_DIR%..\mo\utils\find_ie_version.py" IF %errorlevel% EQU 0 goto ie_search_end echo [ WARNING ] The installed OpenVINO ^(TM^) toolkit version %mo_release_version% does not work as expected. Uninstalling... -pip3 uninstall -y openvino +python -m pip uninstall -y openvino echo [ WARNING ] Consider building the Inference Engine Python API from sources goto ie_search_end :install_last_ov set errorlevel= -pip3 install openvino +python -m pip install openvino IF %errorlevel% NEQ 0 ( echo [ WARNING ] Could not find OpenVINO ^(TM^) toolkit version available in pip for installation echo [ WARNING ] Consider building the Inference Engine Python API from sources @@ -137,16 +156,26 @@ IF %errorlevel% NEQ 0 ( ) set errorlevel= -python "%~dp0..\mo\utils\find_ie_version.py" +python "%ROOT_DIR%..\mo\utils\find_ie_version.py" IF %errorlevel% EQU 0 goto ie_search_end echo [ WARNING ] The installed highest OpenVINO ^(TM^) toolkit version doesn't work as expected. Uninstalling... -pip3 uninstall -y openvino +python -m pip uninstall -y openvino echo [ WARNING ] Consider building the Inference Engine Python API from sources goto ie_search_end :ie_search_end +IF %USE_VENV% == "true" ( + echo. + echo Before running the Model Optimizer, please activate virtualenv environment by running "%VENV_DIR%\Scripts\activate.bat" +) ELSE ( + echo. + echo [ WARNING ] All Model Optimizer dependencies are installed globally. + echo [ WARNING ] If you want to keep Model Optimizer in separate sandbox + echo [ WARNING ] run install_prerequisites.bat "{caffe|tf|tf2|mxnet|kaldi|onnx}" venv +) + echo ***************************************************************************************** echo Optional: To speed up model conversion process, install protobuf-*.egg located in the echo "model-optimizer\install_prerequisites" folder or building protobuf library from sources. diff --git a/model-optimizer/install_prerequisites/install_prerequisites.sh b/model-optimizer/install_prerequisites/install_prerequisites.sh index bd2deb23ae50b3..17c26201cf1a68 100755 --- a/model-optimizer/install_prerequisites/install_prerequisites.sh +++ b/model-optimizer/install_prerequisites/install_prerequisites.sh @@ -35,6 +35,7 @@ for ((i=1;i <= $#;i++)) { esac } +VENV_DIR="$HOME/venv_openvino" SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]-$0}" )" && pwd )" if [[ -f /etc/centos-release ]]; then @@ -53,23 +54,8 @@ if [[ $DISTRO == "centos" ]]; then elif command -v python3.5 >/dev/null 2>&1; then python_binary=python3.5 fi - - if [ -z "$python_binary" ]; then - sudo -E yum install -y https://centos7.iuscommunity.org/ius-release.rpm - sudo -E yum install -y python36u python36u-pip - sudo -E pip3.6 install virtualenv - python_binary=python3.6 - fi - # latest pip is needed to install tensorflow - sudo -E "$python_binary" -m pip install --upgrade pip -elif [[ $DISTRO == "ubuntu" ]]; then - sudo -E apt update - sudo -E apt -y --no-install-recommends install python3-pip python3-venv - python_binary=python3 - sudo -E "$python_binary" -m pip install --upgrade pip -elif [[ "$OSTYPE" == "darwin"* ]]; then +else python_binary=python3 - python3 -m pip install --upgrade pip fi install_latest_ov() { @@ -181,21 +167,21 @@ find_ie_bindings() { } if [[ $V_ENV -eq 1 ]]; then - "$python_binary" -m venv "$SCRIPTDIR/../venv${postfix}" - source "$SCRIPTDIR/../venv${postfix}/bin/activate" - venv_python_binary="$SCRIPTDIR/../venv${postfix}/bin/$python_binary" - $venv_python_binary -m pip install -r "$SCRIPTDIR/../requirements${postfix}.txt" + "$python_binary" -m venv "$VENV_DIR" + source "$VENV_DIR/bin/activate" + venv_python_binary="$VENV_DIR/bin/$python_binary" + # latest pip is needed to install tensorflow + "$venv_python_binary" -m pip install --upgrade pip + "$venv_python_binary" -m pip install -r "$SCRIPTDIR/../requirements${postfix}.txt" find_ie_bindings "$venv_python_binary" false echo - echo "Before running the Model Optimizer, please activate virtualenv environment by running \"source ${SCRIPTDIR}/../venv${postfix}/bin/activate\"" + echo "Before running the Model Optimizer, please activate virtualenv environment by running \"source $VENV_DIR/bin/activate\"" else - if [[ "$OSTYPE" == "darwin"* ]]; then - python3 -m pip install -r "$SCRIPTDIR/../requirements${postfix}.txt" - find_ie_bindings python3 false - else - sudo -E $python_binary -m pip install -r "$SCRIPTDIR/../requirements${postfix}.txt" - find_ie_bindings $python_binary true - fi + # latest pip is needed to install tensorflow + "$python_binary" -m pip install --upgrade pip + "$python_binary" -m pip install -r "$SCRIPTDIR/../requirements${postfix}.txt" + find_ie_bindings "$python_binary" false + echo echo "[WARNING] All Model Optimizer dependencies are installed globally." echo "[WARNING] If you want to keep Model Optimizer in separate sandbox" echo "[WARNING] run install_prerequisites.sh \"{caffe|tf|tf2|mxnet|kaldi|onnx}\" venv" diff --git a/model-optimizer/mo/front/tf/extractors/utils.py b/model-optimizer/mo/front/tf/extractors/utils.py index c8fac1de697972..c9d07083b38ce4 100644 --- a/model-optimizer/mo/front/tf/extractors/utils.py +++ b/model-optimizer/mo/front/tf/extractors/utils.py @@ -70,8 +70,18 @@ def tf_tensor_content(tf_dtype, shape, pb_tensor): log.error(decode_err_msg, extra={'is_warning': True}) value = np.array(type_helper[1](pb_tensor)) - if len(shape) == 0 or shape.prod() == 0: - if len(value) == 1: + # Ignore an empty value, if len(shape) > 1 + # For example, value = [] and shape = [1, 1, 0] + # This is needed to reshape this value later and to return reshaped value = [[[]]] + # Otherwise there can be failures during partial inference, because we are storing an empty value with incorrect + # shape + if len(shape) == 0 or (len(shape) == 1 and shape.prod() == 0): + try: + value_length = len(value) + except TypeError: + # case, when value is a scalar + value_length = 0 + if value_length == 1: # return scalar if shape is [] otherwise broadcast according to shape try: return np.array(value[0], dtype=type_helper[0]) diff --git a/model-optimizer/mo/graph/graph.py b/model-optimizer/mo/graph/graph.py index c00b68ff8101be..aa1bef5e3e91ba 100644 --- a/model-optimizer/mo/graph/graph.py +++ b/model-optimizer/mo/graph/graph.py @@ -1032,21 +1032,24 @@ def dict_includes(big: dict, sub_dict: dict, skip_attr_names=[]): ) -def add_opoutput(graph: Graph, node_name: str, port: int, cut: bool = True): +def add_opoutput(graph: Graph, node_name: str, port: int, cut: bool = True, keep_output_port: bool = False): """ Creates and connects Result node to node_name port. Cuts existing port if requested. :param graph: graph to operate with :param node_name: name of existing node in the graph that we want to add Result to :param port: output port of node to connect Result to :param cut: determines way of operating with edge specified by node_name and port + :param keep_output_port: special attribute determines if this operation is saved in IR or not """ # we import it here because Op imports add_attrs_props and update_ie_fields from this file from mo.ops.result import Result node = Node(graph, node_name) if cut and len(node.out_edges()) != 0: - opoutput_node = Result(graph).create_node_on_port(node, port, {'name': node_name + '/sink_port_' + str(port)}) + opoutput_node = Result(graph).create_node_on_port(node, port, {'name': node_name + '/sink_port_' + str(port), + 'keep_output_port': keep_output_port}) else: - opoutput_node = Result(graph).create_node([(node, port)], {'name': node_name + '/sink_port_' + str(port)}) + opoutput_node = Result(graph).create_node([(node, port)], {'name': node_name + '/sink_port_' + str(port), + 'keep_output_port': keep_output_port}) opoutput_node.in_edge()['data_attrs'] = ['fw_tensor_debug_info'] log.debug('Sink: {} for node {}'.format(opoutput_node.id, node_name)) diff --git a/model-optimizer/mo/ops/convolution.py b/model-optimizer/mo/ops/convolution.py index aa884b347210cf..ee24fcd137069a 100644 --- a/model-optimizer/mo/ops/convolution.py +++ b/model-optimizer/mo/ops/convolution.py @@ -102,7 +102,6 @@ def infer(node: Node): node['bias_term'] = len(node.in_nodes()) == 3 weights_index = node.weights_index if node.has_valid('weights_index') else 1 - # Reshape weights kernel to original shape # In case of caffe or MXNet framework, values for weights have no structured shape like OIHW # so we have to reshape weights to normal shape @@ -237,6 +236,8 @@ def infer(node: Node): for n in node.out_nodes(): node.out_node(n).shape = output_shape + # bin attribute is used for pre-processing, but it will be deleted in BlobNormalizer transformation + # and the blobs (weights, biases) will be represented as inputs to the node mark_input_bins(node, start_port=1 if node.type != 'DeformableConvolution' else 2) assign_dims_to_weights(node.in_node(weights_index), node.kernel_spatial_idx, node.input_feature_channel, node.output_feature_channel, len(kernel_shape)) diff --git a/model-optimizer/mo/ops/deformable_convolution.py b/model-optimizer/mo/ops/deformable_convolution.py index f219208cbc03f4..5eb573fb2147f1 100644 --- a/model-optimizer/mo/ops/deformable_convolution.py +++ b/model-optimizer/mo/ops/deformable_convolution.py @@ -13,7 +13,7 @@ def __init__(self, graph: Graph, attrs: dict): super().__init__(graph, { 'type': __class__.op, 'op': __class__.op, - 'version': 'opset1', + 'version': 'opset8', 'infer': Convolution.infer, 'group': 1, 'deformable_group': 1, @@ -21,8 +21,10 @@ def __init__(self, graph: Graph, attrs: dict): 'multiplication_transparent_ports': [(0, 0), (2, 0)], 'in_ports_count': 3, 'out_ports_count': 1, + 'bilinear_interpolation_pad': False, }, attrs) def backend_attrs(self): - # the same attributes as in a regular convolution and one additional attribute 'deformable_group' and 'group' - return Convolution(self.graph, {}).backend_attrs() + ['deformable_group', 'group'] + # the same attributes as in a regular convolution and additional attributes 'deformable_group', 'group' + # and 'bilinear_interpolation_pad' + return Convolution(self.graph, {}).backend_attrs() + ['deformable_group', 'group', 'bilinear_interpolation_pad'] diff --git a/model-optimizer/unit_tests/extensions/front/Mish_fusion_test.py b/model-optimizer/unit_tests/extensions/front/Mish_fusion_test.py deleted file mode 100644 index 10e48daefad2cd..00000000000000 --- a/model-optimizer/unit_tests/extensions/front/Mish_fusion_test.py +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright (C) 2018-2021 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 - -import unittest - -from extensions.front.Mish_fusion import MishFusion -from mo.utils.ir_engine.compare_graphs import compare_graphs -from unit_tests.utils.graph import build_graph, regular_op, result, build_graph_with_edge_attrs - -ref_nodes = {**regular_op('input', {'type': 'Parameter'}), - **regular_op('mish', {'type': 'Mish', 'name': 'final_mul'}), - **result('result') - } -ref_edges = [('input', 'mish'), ('mish', 'result')] - - -class MishFusionTest(unittest.TestCase): - nodes = { - **regular_op('input', {'type': 'Parameter'}), - **regular_op('softplus', {'op': 'SoftPlus'}), - **regular_op('tanh', {'op': 'Tanh'}), - **regular_op('mul', {'op': 'Mul', 'name': 'final_mul'}), - **result('result'), - } - - edges = [('input', 'softplus', {'in': 0, 'out': 0}), - ('input', 'mul', {'in': 0, 'out': 0}), - ('softplus', 'tanh', {'in': 0, 'out': 0}), - ('tanh', 'mul', {'in': 1, 'out': 0}), - ('mul', 'result', {'in': 0, 'out': 0})] - - def test_mish_fusion(self): - graph = build_graph_with_edge_attrs(self.nodes, self.edges, {}) - - graph_ref = build_graph(ref_nodes, ref_edges) - graph.stage = 'front' - - MishFusion().find_and_replace_pattern(graph) - - (flag, resp) = compare_graphs(graph, graph_ref, 'result') - self.assertTrue(flag, resp) - self.assertTrue(len(graph.get_op_nodes(name='final_mul')) == 1 and - graph.get_op_nodes(name='final_mul')[0].op == 'Mish') - - def test_mish_fusion_different_source(self): - # check case when different tensors goes to Mul and SoftPlus - graph = build_graph_with_edge_attrs({ - **regular_op('input', {'type': 'Parameter'}), - **regular_op('input_2', {'type': 'Parameter'}), - **regular_op('softplus', {'op': 'SoftPlus'}), - **regular_op('tanh', {'op': 'Tanh'}), - **regular_op('mul', {'op': 'Mul', 'name': 'final_mul'}), - **result('result'), - }, [('input', 'softplus', {'in': 0, 'out': 0}), - ('input_2', 'mul', {'in': 0, 'out': 0}), - ('softplus', 'tanh', {'in': 0, 'out': 0}), - ('tanh', 'mul', {'in': 1, 'out': 0}), - ('mul', 'result', {'in': 0, 'out': 0})], {}) - - graph_ref = graph.copy() - graph.stage = 'front' - - MishFusion().find_and_replace_pattern(graph) - - (flag, resp) = compare_graphs(graph, graph_ref, 'result') - self.assertTrue(flag, resp) diff --git a/model-optimizer/unit_tests/extensions/front/Softplus_fusion_test.py b/model-optimizer/unit_tests/extensions/front/Softplus_fusion_test.py deleted file mode 100644 index 0dd93f8d95ce1d..00000000000000 --- a/model-optimizer/unit_tests/extensions/front/Softplus_fusion_test.py +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright (C) 2018-2021 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 - -import unittest - -from extensions.front.Softplus_fusion import SoftplusFusion -from mo.front.common.partial_infer.utils import float_array -from mo.utils.ir_engine.compare_graphs import compare_graphs -from unit_tests.utils.graph import build_graph, const, regular_op, result, build_graph_with_edge_attrs - -ref_nodes = {**regular_op('input', {'type': 'Parameter'}), - **regular_op('softplus', {'type': 'SoftPlus', 'name': 'final_log'}), - **result('result') - } -ref_edges = [('input', 'softplus'), ('softplus', 'result')] - - -class SoftplusFusionTest(unittest.TestCase): - nodes = { - **regular_op('input', {'type': 'Parameter'}), - **regular_op('exp', {'op': 'Exp'}), - **const('const_1', float_array([1.0])), - **regular_op('add', {'op': 'Add'}), - **regular_op('ln', {'op': 'Log', 'name': 'final_log'}), - **result('result'), - } - - edges = [('input', 'exp', {'in': 0, 'out': 0}), - ('const_1', 'add', {'in': 0, 'out': 0}), - ('exp', 'add', {'in': 1, 'out': 0}), - ('add', 'ln', {'in': 0, 'out': 0}), - ('ln', 'result', {'in': 0, 'out': 0})] - - def test_softplus_fusion_test(self): - graph = build_graph_with_edge_attrs(self.nodes, self.edges, {}) - - graph_ref = build_graph(ref_nodes, ref_edges) - graph.stage = 'front' - - SoftplusFusion().find_and_replace_pattern(graph) - - (flag, resp) = compare_graphs(graph, graph_ref, 'result') - self.assertTrue(flag, resp) - self.assertTrue(len(graph.get_op_nodes(name='final_log')) == 1 and - graph.get_op_nodes(name='final_log')[0].op == 'SoftPlus') - - def test_softplus_fusion_test_wrong_const(self): - graph = build_graph_with_edge_attrs(self.nodes, self.edges, {'const_1': {'value': float_array([0.9999])}}) - - graph_ref = graph.copy() - graph.stage = 'front' - - SoftplusFusion().find_and_replace_pattern(graph) - - (flag, resp) = compare_graphs(graph, graph_ref, 'result') - self.assertTrue(flag, resp) - diff --git a/model-optimizer/unit_tests/extensions/front/Swish_fusion_test.py b/model-optimizer/unit_tests/extensions/front/Swish_fusion_test.py deleted file mode 100644 index ccf9985536babc..00000000000000 --- a/model-optimizer/unit_tests/extensions/front/Swish_fusion_test.py +++ /dev/null @@ -1,119 +0,0 @@ -# Copyright (C) 2018-2021 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 - -import unittest - -from extensions.front.Swish_fusion import SwishWithSigmoidWithoutBeta, SwishWithSigmoidWithBeta -from mo.utils.ir_engine.compare_graphs import compare_graphs -from unit_tests.utils.graph import build_graph, regular_op, result, build_graph_with_edge_attrs - -ref_nodes = {**regular_op('input', {'type': 'Parameter'}), - **regular_op('swish', {'type': 'Swish', 'name': 'final_mul'}), - **result('result') - } -ref_edges = [('input', 'swish'), ('swish', 'result')] - - -class SwishWithSigmoidWithoutBetaTest(unittest.TestCase): - nodes = { - **regular_op('input', {'type': 'Parameter'}), - **regular_op('sigmoid', {'op': 'Sigmoid'}), - **regular_op('mul', {'op': 'Mul', 'name': 'final_mul'}), - **result('result'), - } - - edges = [('input', 'mul', {'in': 0, 'out': 0}), - ('input', 'sigmoid', {'in': 0, 'out': 0}), - ('sigmoid', 'mul', {'in': 1, 'out': 0}), - ('mul', 'result', {'in': 0, 'out': 0})] - - def test_swish_with_sigmoid_without_beta_test(self): - graph = build_graph_with_edge_attrs(self.nodes, self.edges, {}) - - graph_ref = build_graph(ref_nodes, ref_edges) - graph.stage = 'front' - - SwishWithSigmoidWithoutBeta().find_and_replace_pattern(graph) - - (flag, resp) = compare_graphs(graph, graph_ref, 'result') - self.assertTrue(flag, resp) - self.assertTrue(len(graph.get_op_nodes(name='final_mul')) == 1 and - graph.get_op_nodes(name='final_mul')[0].op == 'Swish') - - def test_swish_with_sigmoid_without_beta_different_tensors(self): - graph = build_graph_with_edge_attrs({ - **regular_op('input', {'type': 'Parameter'}), - **regular_op('input_2', {'type': 'Parameter'}), - **regular_op('sigmoid', {'op': 'Sigmoid'}), - **regular_op('mul', {'op': 'Mul', 'name': 'final_mul'}), - **result('result'), - }, [('input_2', 'mul', {'in': 0, 'out': 0}), - ('input', 'sigmoid', {'in': 0, 'out': 0}), - ('sigmoid', 'mul', {'in': 1, 'out': 0}), - ('mul', 'result', {'in': 0, 'out': 0})], {}) - - graph_ref = graph.copy() - graph.stage = 'front' - - SwishWithSigmoidWithoutBeta().find_and_replace_pattern(graph) - - (flag, resp) = compare_graphs(graph, graph_ref, 'result') - self.assertTrue(flag, resp) - - -class SwishWithSigmoidWithBetaTest(unittest.TestCase): - nodes = { - **regular_op('input', {'type': 'Parameter'}), - **regular_op('beta', {'type': 'Parameter'}), - **regular_op('mul_beta', {'op': 'Mul'}), - **regular_op('sigmoid', {'op': 'Sigmoid'}), - **regular_op('mul_2', {'op': 'Mul', 'name': 'final_mul'}), - **result('result'), - } - - edges = [('input', 'mul_beta', {'in': 0, 'out': 0}), - ('input', 'mul_2', {'in': 0, 'out': 0}), - ('beta', 'mul_beta', {'in': 1, 'out': 0}), - ('mul_beta', 'sigmoid', {'in': 0, 'out': 0}), - ('sigmoid', 'mul_2', {'in': 1, 'out': 0}), - ('mul_2', 'result', {'in': 0, 'out': 0})] - - def test_swish_with_sigmoid_with_beta_test(self): - graph = build_graph_with_edge_attrs(self.nodes, self.edges, {}) - - new_ref_nodes = ref_nodes.copy() - new_ref_nodes.update(**regular_op('beta', {'type': 'Parameter'})) - - graph_ref = build_graph(new_ref_nodes, ref_edges + [('beta', 'swish')]) - graph.stage = 'front' - - SwishWithSigmoidWithBeta().find_and_replace_pattern(graph) - - (flag, resp) = compare_graphs(graph, graph_ref, 'result') - self.assertTrue(flag, resp) - self.assertTrue(len(graph.get_op_nodes(name='final_mul')) == 1 and - graph.get_op_nodes(name='final_mul')[0].op == 'Swish') - - def test_swish_with_sigmoid_with_beta_different_tensors(self): - graph = build_graph_with_edge_attrs({ - **regular_op('input', {'type': 'Parameter'}), - **regular_op('input_2', {'type': 'Parameter'}), - **regular_op('beta', {'type': 'Parameter'}), - **regular_op('mul_beta', {'op': 'Mul'}), - **regular_op('sigmoid', {'op': 'Sigmoid'}), - **regular_op('mul_2', {'op': 'Mul', 'name': 'final_mul'}), - **result('result'), - }, [('input', 'mul_beta', {'in': 0, 'out': 0}), - ('input_2', 'mul_2', {'in': 0, 'out': 0}), - ('beta', 'mul_beta', {'in': 1, 'out': 0}), - ('mul_beta', 'sigmoid', {'in': 0, 'out': 0}), - ('sigmoid', 'mul_2', {'in': 1, 'out': 0}), - ('mul_2', 'result', {'in': 0, 'out': 0})], {}) - - graph_ref = graph.copy() - graph.stage = 'front' - - SwishWithSigmoidWithBeta().find_and_replace_pattern(graph) - - (flag, resp) = compare_graphs(graph, graph_ref, 'result') - self.assertTrue(flag, resp) diff --git a/model-optimizer/unit_tests/extensions/front/onnx/quantize_dequantize_linear_test.py b/model-optimizer/unit_tests/extensions/front/onnx/quantize_dequantize_linear_test.py deleted file mode 100644 index 3d07eb06236cda..00000000000000 --- a/model-optimizer/unit_tests/extensions/front/onnx/quantize_dequantize_linear_test.py +++ /dev/null @@ -1,115 +0,0 @@ -# Copyright (C) 2018-2021 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 - -import unittest - -import numpy as np - -from extensions.front.onnx.quantize_dequantize_linear import QuantizeDequantizeLinear -from mo.utils.ir_engine.compare_graphs import compare_graphs -from unit_tests.utils.graph import build_graph - -# quantize and dequantize share tensors with scale/zp -nodes0_attributes = { - 'input': {'kind': 'op', 'op': 'AnyOp'}, - 'quantize': {'kind': 'op', 'op': 'QuantizeLinear'}, - 'dequantize': {'kind': 'op', 'op': 'DequantizeLinear'}, - 'scale_param': {'kind': 'op', 'type': 'Const', 'op': 'Const'}, - 'zerop_param': {'kind': 'op', 'type': 'Const', 'op': 'Const'}, - 'out': {'kind': 'op', 'op': 'AnyOp'}, -} - -# quantize and dequantize do not share tensors with scale/zp -nodes1_attributes = { - 'input': {'kind': 'op', 'op': 'AnyOp'}, - 'quantize': {'kind': 'op', 'op': 'QuantizeLinear'}, - 'dequantize': {'kind': 'op', 'op': 'DequantizeLinear'}, - 'scale_param_q': {'kind': 'op', 'type': 'Const', 'op': 'Const'}, - 'zerop_param_q': {'kind': 'op', 'type': 'Const', 'op': 'Const'}, - 'scale_param_dq': {'kind': 'op', 'type': 'Const', 'op': 'Const'}, - 'zerop_param_dq': {'kind': 'op', 'type': 'Const', 'op': 'Const'}, - 'out': {'kind': 'op', 'op': 'AnyOp'}, -} - -nodes_ref_attributes = { - 'input': {'kind': 'op', 'op': 'AnyOp'}, - 'fq': {'kind': 'op', 'op': 'FakeQuantize'}, - 'min_param': {'kind': 'op', 'type': 'Const', 'op': 'Const'}, - 'max_param': {'kind': 'op', 'type': 'Const', 'op': 'Const'}, - 'out': {'kind': 'op', 'op': 'AnyOp'}, -} - - -class TestQuantizeDeQuantize2FakeQuantize(unittest.TestCase): - - def test_quantizedequantize2fakequantize_0(self): - # testing the code path with uint8 zero-point - graph = build_graph(nodes1_attributes, - [('input', 'quantize'), - ('quantize', 'dequantize'), - ('scale_param_q', 'quantize'), - ('zerop_param_q', 'quantize'), - ('scale_param_dq', 'dequantize'), - ('zerop_param_dq', 'dequantize'), - ('dequantize', 'out'), - ], - {'scale_param_q': {'shape': np.array([1]), 'value': np.float32(1.0 / 255)}, - 'zerop_param_q': {'shape': np.array([1]), 'value': np.uint8(0)}, - 'scale_param_dq': {'shape': np.array([1]), 'value': np.float32(1.0 / 255)}, - 'zerop_param_dq': {'shape': np.array([1]), 'value': np.uint8(0)}, - }, nodes_with_edges_only=True) - - graph_ref = build_graph(nodes_ref_attributes, - [('input', 'fq', {'in': 0}), - ('min_param', 'fq', {'out': 0, 'in': 1}), - ('min_param', 'fq', {'out': 0, 'in': 3}), - ('max_param', 'fq', {'out': 0, 'in': 2}), - ('max_param', 'fq', {'out': 0, 'in': 4}), - ('fq', 'out'), - ], - {'fq': {'levels': 256}, - 'min_param': {'value': np.float32(0.0)}, - 'max_param': {'value': np.float32(1.0)}, - }, nodes_with_edges_only=True) - - graph.stage = 'front' - tested_class = QuantizeDequantizeLinear() - tested_class.find_and_replace_pattern(graph) - - (flag, resp) = compare_graphs(graph, graph_ref, 'out', check_op_attrs=True) - self.assertTrue(flag, resp) - - def test_quantizedequantize2fakequantize_1(self): - # testing the code path with int8 zero-point - graph = build_graph(nodes0_attributes, - [('input', 'quantize'), - ('quantize', 'dequantize'), - ('scale_param', 'quantize'), - ('zerop_param', 'quantize'), - ('scale_param', 'dequantize'), - ('zerop_param', 'dequantize'), - ('dequantize', 'out'), - ], - {'scale_param': {'shape': np.array([1]), 'value': np.float32(1.0 / 255)}, - 'zerop_param': {'shape': np.array([1]), 'value': np.int8(0)}, - }, nodes_with_edges_only=True) - - graph_ref = build_graph(nodes_ref_attributes, - [('input', 'fq', {'in': 0}), - ('min_param', 'fq', {'out': 0, 'in': 1}), - ('min_param', 'fq', {'out': 0, 'in': 3}), - ('max_param', 'fq', {'out': 0, 'in': 2}), - ('max_param', 'fq', {'out': 0, 'in': 4}), - ('fq', 'out'), - ], - {'fq': {'levels': 256}, - 'min_param': {'value': np.float32(-128.0 / 255)}, - 'max_param': {'value': np.float32(127.0 / 255)}, - }, nodes_with_edges_only=True) - - graph.stage = 'front' - tested_class = QuantizeDequantizeLinear() - tested_class.find_and_replace_pattern(graph) - - (flag, resp) = compare_graphs(graph, graph_ref, 'out', check_op_attrs=True) - self.assertTrue(flag, resp) diff --git a/model-optimizer/unit_tests/extensions/middle/ConvertGroupedStridedSlice_test.py b/model-optimizer/unit_tests/extensions/middle/ConvertGroupedStridedSlice_test.py index 32fe29884b0cc0..71a957aff182f6 100644 --- a/model-optimizer/unit_tests/extensions/middle/ConvertGroupedStridedSlice_test.py +++ b/model-optimizer/unit_tests/extensions/middle/ConvertGroupedStridedSlice_test.py @@ -60,8 +60,8 @@ 'concat_1_data': {'value': None, 'shape': None, 'kind': 'data'}, 'op_output': {'kind': 'op', 'op': 'Result'}, - 'op_output_1': {'kind': 'op', 'op': 'Result'}, - 'op_output_2': {'kind': 'op', 'op': 'Result'}, + 'op_output_1': {'kind': 'op', 'op': 'Result', 'keep_output_port': True}, + 'op_output_2': {'kind': 'op', 'op': 'Result', 'keep_output_port': True}, # Squeeze layers 'sslice_1/Squeeze_shrink': {'type': None, 'value': None, 'kind': 'op', 'op': 'Squeeze'}, diff --git a/model-optimizer/unit_tests/mo/front/tf/extractors/utils_test.py b/model-optimizer/unit_tests/mo/front/tf/extractors/utils_test.py index b2ba651fba261a..d9d3fc329c8cb5 100644 --- a/model-optimizer/unit_tests/mo/front/tf/extractors/utils_test.py +++ b/model-optimizer/unit_tests/mo/front/tf/extractors/utils_test.py @@ -211,3 +211,30 @@ def test_str_decode_list(self): with self.assertLogs(log.getLogger(), level="ERROR") as cm: result = tf_tensor_content(pb_tensor.dtype, shape, pb_tensor) self.assertEqual([warning_message, warning_message], cm.output) + + def test_empty_value(self): + pb_tensor = PB({ + 'dtype': 1, + 'float_val': [] + }) + + shape = int64_array([1, 1, 0]) + tf_dtype = pb_tensor.dtype + ref = np.array([[[]]], dtype=np.float32) + res = tf_tensor_content(tf_dtype, shape, pb_tensor) + + self.assertEqual(res.shape, ref.shape) + self.assertTrue(np.all(res == ref)) + + def test_scalar_value(self): + pb_tensor = PB({ + 'dtype': 3, + 'int_val': 4 + }) + + shape = int64_array([]) + tf_dtype = pb_tensor.dtype + ref = np.array(4, dtype=np.int32) + res = tf_tensor_content(tf_dtype, shape, pb_tensor) + + self.assertEqual(ref, res) diff --git a/model-optimizer/unit_tests/mock_mo_frontend/mock_mo_python_api/CMakeLists.txt b/model-optimizer/unit_tests/mock_mo_frontend/mock_mo_python_api/CMakeLists.txt index 711f85ecc2f12b..1a94414055bf99 100644 --- a/model-optimizer/unit_tests/mock_mo_frontend/mock_mo_python_api/CMakeLists.txt +++ b/model-optimizer/unit_tests/mock_mo_frontend/mock_mo_python_api/CMakeLists.txt @@ -8,7 +8,7 @@ set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_OLD ${CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY} set(CMAKE_PDB_OUTPUT_DIRECTORY_OLD ${CMAKE_PDB_OUTPUT_DIRECTORY}) set(PYTHON_VERSION python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) -message("Python version=${PYTHON_VERSION}") +message(STATUS "Python version=${PYTHON_VERSION}") if(WIN32) set(PYTHON_BRIDGE_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$/python_api/${PYTHON_VERSION}/) diff --git a/ngraph/.gitignore b/ngraph/.gitignore index 967c8b0f6dde9f..588daa92a64ae7 100644 --- a/ngraph/.gitignore +++ b/ngraph/.gitignore @@ -110,8 +110,6 @@ python/share/* \#* \.#* -python/pybind11/ - # remnants from a failed in-source build CMakeCache.txt CMakeFiles/ diff --git a/ngraph/CMakeLists.txt b/ngraph/CMakeLists.txt index 385fee2f737aa7..20fe4a9af12a52 100644 --- a/ngraph/CMakeLists.txt +++ b/ngraph/CMakeLists.txt @@ -23,7 +23,6 @@ option(NGRAPH_DEBUG_ENABLE "Enable output for NGRAPH_DEBUG statements" OFF) option(NGRAPH_ONNX_IMPORT_ENABLE "Enable ONNX importer" OFF) option(NGRAPH_ONNX_EDITOR_ENABLE "Enable ONNX Editor" OFF) option(NGRAPH_PDPD_FRONTEND_ENABLE "Enable PaddlePaddle FrontEnd" OFF) -option(NGRAPH_PYTHON_BUILD_ENABLE "Enable build nGraph python package wheel" OFF) option(NGRAPH_USE_PROTOBUF_LITE "Compiles and links with protobuf-lite" OFF) if (NGRAPH_ONNX_IMPORT_ENABLE OR NGRAPH_PDPD_FRONTEND_ENABLE) @@ -37,7 +36,6 @@ message(STATUS "NGRAPH_DEBUG_ENABLE: ${NGRAPH_DEBUG_ENABLE}") message(STATUS "NGRAPH_ONNX_IMPORT_ENABLE: ${NGRAPH_ONNX_IMPORT_ENABLE}") message(STATUS "NGRAPH_ONNX_EDITOR_ENABLE: ${NGRAPH_ONNX_EDITOR_ENABLE}") message(STATUS "NGRAPH_PDPD_FRONTEND_ENABLE: ${NGRAPH_PDPD_FRONTEND_ENABLE}") -message(STATUS "NGRAPH_PYTHON_BUILD_ENABLE: ${NGRAPH_PYTHON_BUILD_ENABLE}") message(STATUS "NGRAPH_USE_PROTOBUF_LITE: ${NGRAPH_USE_PROTOBUF_LITE}") message(STATUS "NGRAPH_UNIT_TEST_ENABLE: ${NGRAPH_UNIT_TEST_ENABLE}") message(STATUS "NGRAPH_UNIT_TEST_BACKENDS_ENABLE: ${NGRAPH_UNIT_TEST_BACKENDS_ENABLE}") @@ -180,14 +178,14 @@ if (NGRAPH_ONNX_IMPORT_ENABLE OR USE_STATIC_PROTOBUF) set(BUILD_STANDALONE_STATIC OFF) if (NOT NGRAPH_USE_SYSTEM_PROTOBUF) - include(cmake/external_protobuf.cmake) + add_subdirectory(${CMAKE_SOURCE_DIR}/thirdparty/protobuf ${CMAKE_BINARY_DIR}/_deps/protobuf) else() - find_package(Protobuf 2.6.1 REQUIRED) + find_package(Protobuf REQUIRED) endif() if (NGRAPH_ONNX_IMPORT_ENABLE) # target onnx_proto will be shared lib, onnx static - include(cmake/external_onnx.cmake) + add_subdirectory(${CMAKE_SOURCE_DIR}/thirdparty/onnx ${CMAKE_BINARY_DIR}/_deps/onnx) if (TARGET ext_protobuf) add_dependencies(onnx ext_protobuf) endif() @@ -202,6 +200,6 @@ add_subdirectory(frontend) add_subdirectory(test) -if (NGRAPH_PYTHON_BUILD_ENABLE) +if (ENABLE_PYTHON) add_subdirectory(python) endif() diff --git a/ngraph/cmake/external_protobuf.cmake b/ngraph/cmake/external_protobuf.cmake deleted file mode 100644 index 021382da95ac64..00000000000000 --- a/ngraph/cmake/external_protobuf.cmake +++ /dev/null @@ -1,149 +0,0 @@ -# Copyright (C) 2018-2021 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 -# - -include(FetchContent) - -#------------------------------------------------------------------------------ -# Download and install Google Protobuf ... -#------------------------------------------------------------------------------ - -set(PUSH_CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE "${CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE}") -set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE OFF) - -if (MSVC) - set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "") -endif() - -# This version of PROTOBUF is required by Microsoft ONNX Runtime. -set(NGRAPH_PROTOBUF_GIT_REPO_URL "https://github.com/protocolbuffers/protobuf") - -if(CMAKE_CROSSCOMPILING) - find_program(SYSTEM_PROTOC protoc PATHS ENV PATH) - - if(SYSTEM_PROTOC) - execute_process( - COMMAND ${SYSTEM_PROTOC} --version - OUTPUT_VARIABLE PROTOC_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - - string(REPLACE " " ";" PROTOC_VERSION ${PROTOC_VERSION}) - list(GET PROTOC_VERSION -1 PROTOC_VERSION) - - message("Detected system protoc version: ${PROTOC_VERSION}") - - if(${PROTOC_VERSION} VERSION_EQUAL "3.0.0") - message(WARNING "Protobuf 3.0.0 detected switching to 3.0.2 due to bug in gmock url") - set(PROTOC_VERSION "3.0.2") - endif() - else() - message(FATAL_ERROR "System Protobuf is needed while cross-compiling") - endif() - - set(protobuf_BUILD_PROTOC_BINARIES OFF CACHE BOOL "Build libprotoc and protoc compiler" FORCE) -elseif(NGRAPH_USE_PROTOBUF_LITE) - set(PROTOC_VERSION "3.9.2") - if(ENABLE_LTO) - message(WARNING "Protobuf in version 3.8.0+ can throw runtime exceptions if LTO is enabled.") - endif() -else() - set(PROTOC_VERSION "3.7.1") -endif() - -set(NGRAPH_PROTOBUF_GIT_TAG "v${PROTOC_VERSION}") - - -if (CMAKE_GENERATOR STREQUAL "Ninja") - set(MAKE_UTIL make) -else() - set(MAKE_UTIL $(MAKE)) -endif() - -if(PROTOC_VERSION VERSION_LESS "3.9" AND NGRAPH_USE_PROTOBUF_LITE) - message(FATAL_ERROR "Minimum supported version of protobuf-lite library is 3.9.0") -else() - if(PROTOC_VERSION VERSION_GREATER_EQUAL "3.0") - if (NOT BUILD_STANDALONE_STATIC) - FetchContent_Declare( - ext_protobuf - GIT_REPOSITORY ${NGRAPH_PROTOBUF_GIT_REPO_URL} - GIT_TAG ${NGRAPH_PROTOBUF_GIT_TAG} - GIT_SHALLOW TRUE - ) - FetchContent_GetProperties(ext_protobuf) - if(NOT ext_protobuf_POPULATED) - FetchContent_Populate(ext_protobuf) - set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build tests") - set(protobuf_WITH_ZLIB OFF CACHE BOOL "Build with zlib support") - add_subdirectory(${ext_protobuf_SOURCE_DIR}/cmake ${ext_protobuf_BINARY_DIR} EXCLUDE_FROM_ALL) - endif() - endif() - if (USE_STATIC_PROTOBUF) - FetchContent_Declare( - ext_protobuf_static - GIT_REPOSITORY ${NGRAPH_PROTOBUF_GIT_REPO_URL} - GIT_TAG ${NGRAPH_PROTOBUF_GIT_TAG} - GIT_SHALLOW TRUE - ) - FetchContent_GetProperties(ext_protobuf_static) - if((NOT ext_protobuf_static_POPULATED) AND BUILD_STANDALONE_STATIC) - FetchContent_Populate(ext_protobuf_static) - set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build tests") - set(protobuf_WITH_ZLIB OFF CACHE BOOL "Build with zlib support") - add_subdirectory(${ext_protobuf_static_SOURCE_DIR}/cmake ${ext_protobuf_static_BINARY_DIR} EXCLUDE_FROM_ALL) - endif() - endif() - else() - message(FATAL_ERROR "Minimum supported version of protobuf library is 3.0.0") - endif() - - if (BUILD_STANDALONE_STATIC) - set(Protobuf_INCLUDE_DIRS ${ext_protobuf_static_SOURCE_DIR}/src) - else() - set(Protobuf_INCLUDE_DIRS ${ext_protobuf_SOURCE_DIR}/src) - endif() - if(NGRAPH_USE_PROTOBUF_LITE) - set(Protobuf_LIBRARIES libprotobuf-lite) - else() - set(Protobuf_LIBRARIES libprotobuf) - endif() - - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$") - set(_proto_libs ${Protobuf_LIBRARIES}) - if(TARGET libprotoc) - list(APPEND _proto_libs libprotoc) - target_compile_options(libprotoc PRIVATE -Wno-all -Wno-unused-variable) - endif() - set_target_properties(${_proto_libs} PROPERTIES - CXX_VISIBILITY_PRESET default - C_VISIBILITY_PRESET default - VISIBILITY_INLINES_HIDDEN OFF) - foreach(target libprotobuf libprotobuf-lite) - target_compile_options(${target} - PRIVATE -Wno-all -Wno-unused-variable -Wno-inconsistent-missing-override - PUBLIC -Wno-undef) - endforeach() - endif() - - if(NGRAPH_USE_PROTOBUF_LITE) - # if only libprotobuf-lite is used, both libprotobuf and libprotobuf-lite are built - # libprotoc target needs symbols from libprotobuf, even in libprotobuf-lite configuration - set_target_properties(libprotobuf PROPERTIES - CXX_VISIBILITY_PRESET default - C_VISIBILITY_PRESET default - VISIBILITY_INLINES_HIDDEN OFF) - endif() -endif() - -# Now make sure we restore the original flags -set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE "${PUSH_CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE}") - -if (NOT BUILD_STANDALONE_STATIC) - message("NGRAPH_INSTALL_LIB = ${NGRAPH_INSTALL_LIB}") - install(TARGETS ${Protobuf_LIBRARIES} - RUNTIME DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph - ARCHIVE DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph - LIBRARY DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph) - export(TARGETS ${Protobuf_LIBRARIES} NAMESPACE ngraph:: APPEND FILE "${NGRAPH_TARGETS_FILE}") -endif() diff --git a/ngraph/cmake/patches/onnx_patch.diff b/ngraph/cmake/patches/onnx_patch.diff deleted file mode 100644 index 23d7a8d7b412ac..00000000000000 --- a/ngraph/cmake/patches/onnx_patch.diff +++ /dev/null @@ -1,30 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 5254f7ee..e7a0ce2b 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -380,7 +380,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL "AIX") - # So, create a object library - add_library(onnx OBJECT ${ONNX_SRCS}) - else() -- add_library(onnx ${ONNX_SRCS}) -+ # onnx target doesn't export symbols -+ add_library(onnx STATIC ${ONNX_SRCS}) - endif() - - target_include_directories(onnx PUBLIC -diff --git a/onnx/onnx_pb.h b/onnx/onnx_pb.h -index 7dc68dea..c932b806 100644 ---- a/onnx/onnx_pb.h -+++ b/onnx/onnx_pb.h -@@ -40,9 +40,10 @@ - // - // This solution is similar to - // https://github.com/pytorch/pytorch/blob/master/caffe2/core/common.h --#if defined(ONNX_BUILD_SHARED_LIBS) || defined(ONNX_BUILD_MAIN_LIB) -+#if defined(ONNX_BUILD_MAIN_LIB) - #define ONNX_API ONNX_EXPORT - #else -+// OV as user of ONNX imports symbols - #define ONNX_API ONNX_IMPORT - #endif - diff --git a/ngraph/core/include/ngraph/descriptor/tensor.hpp b/ngraph/core/include/ngraph/descriptor/tensor.hpp index 676bd9eddd065c..381e528e531858 100644 --- a/ngraph/core/include/ngraph/descriptor/tensor.hpp +++ b/ngraph/core/include/ngraph/descriptor/tensor.hpp @@ -45,6 +45,7 @@ namespace ngraph const std::unordered_set& get_names() const; void set_names(const std::unordered_set& names); + void add_names(const std::unordered_set& names); void set_tensor_type(const element::Type& element_type, const PartialShape& pshape); void set_element_type(const element::Type& elemenet_type); void set_partial_shape(const PartialShape& partial_shape); diff --git a/ngraph/core/include/ngraph/op/asinh.hpp b/ngraph/core/include/ngraph/op/asinh.hpp index 1f781862b9d5dd..62a4eba36a4aad 100644 --- a/ngraph/core/include/ngraph/op/asinh.hpp +++ b/ngraph/core/include/ngraph/op/asinh.hpp @@ -19,8 +19,8 @@ namespace ngraph class NGRAPH_API Asinh : public util::UnaryElementwiseArithmetic { public: - static constexpr NodeTypeInfo type_info{"Asinh", 3}; - const NodeTypeInfo& get_type_info() const override { return type_info; } + NGRAPH_RTTI_DECLARATION; + /// \brief Constructs an Asinh operation. Asinh() = default; /// \brief Constructs an Asinh operation. diff --git a/ngraph/core/include/ngraph/op/atan.hpp b/ngraph/core/include/ngraph/op/atan.hpp index fc388cc228c15c..c15b4d0b60f9db 100644 --- a/ngraph/core/include/ngraph/op/atan.hpp +++ b/ngraph/core/include/ngraph/op/atan.hpp @@ -19,8 +19,7 @@ namespace ngraph class NGRAPH_API Atan : public util::UnaryElementwiseArithmetic { public: - static constexpr NodeTypeInfo type_info{"Atan", 0}; - const NodeTypeInfo& get_type_info() const override { return type_info; } + NGRAPH_RTTI_DECLARATION; /// \brief Constructs an arctan operation. Atan() = default; diff --git a/ngraph/core/include/ngraph/op/batch_to_space.hpp b/ngraph/core/include/ngraph/op/batch_to_space.hpp index 240ed2ba38eb66..b6e6afd584ae1c 100644 --- a/ngraph/core/include/ngraph/op/batch_to_space.hpp +++ b/ngraph/core/include/ngraph/op/batch_to_space.hpp @@ -5,7 +5,7 @@ #pragma once #include "ngraph/node.hpp" -#include "ngraph/op/util/fused_op.hpp" +#include "ngraph/op/op.hpp" namespace ngraph { @@ -27,8 +27,7 @@ namespace ngraph class NGRAPH_API BatchToSpace : public Op { public: - static constexpr NodeTypeInfo type_info{"BatchToSpace", 1}; - const NodeTypeInfo& get_type_info() const override { return type_info; } + NGRAPH_RTTI_DECLARATION; BatchToSpace() = default; /// \brief Constructs a BatchToSpace operation. /// diff --git a/ngraph/core/include/ngraph/op/cosh.hpp b/ngraph/core/include/ngraph/op/cosh.hpp index 7e52bf1679f703..6fcf30e8a0863a 100644 --- a/ngraph/core/include/ngraph/op/cosh.hpp +++ b/ngraph/core/include/ngraph/op/cosh.hpp @@ -16,8 +16,8 @@ namespace ngraph class NGRAPH_API Cosh : public util::UnaryElementwiseArithmetic { public: - static constexpr NodeTypeInfo type_info{"Cosh", 0}; - const NodeTypeInfo& get_type_info() const override { return type_info; } + NGRAPH_RTTI_DECLARATION; + /// \brief Constructs a hyperbolic cosine operation. Cosh() = default; /// \brief Constructs a hyperbolic cosine operation. diff --git a/ngraph/core/include/ngraph/op/deformable_convolution.hpp b/ngraph/core/include/ngraph/op/deformable_convolution.hpp index f55535cb28f96f..da6b18c22b5530 100644 --- a/ngraph/core/include/ngraph/op/deformable_convolution.hpp +++ b/ngraph/core/include/ngraph/op/deformable_convolution.hpp @@ -171,7 +171,7 @@ namespace ngraph } private: - int64_t m_bilinear_interpolation_pad; + bool m_bilinear_interpolation_pad; }; } // namespace v8 } // namespace op diff --git a/ngraph/core/include/ngraph/op/matrix_nms.hpp b/ngraph/core/include/ngraph/op/matrix_nms.hpp new file mode 100644 index 00000000000000..ca2800a921acca --- /dev/null +++ b/ngraph/core/include/ngraph/op/matrix_nms.hpp @@ -0,0 +1,102 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "ngraph/op/util/nms_base.hpp" + +namespace ngraph +{ + namespace op + { + namespace v8 + { + /// \brief MatrixNms operation + /// + class NGRAPH_API MatrixNms : public util::NmsBase + { + public: + NGRAPH_RTTI_DECLARATION; + + enum class DecayFunction + { + GAUSSIAN, + LINEAR + }; + + /// \brief Structure that specifies attributes of the operation + struct Attributes + { + // specifies order of output elements + SortResultType sort_result_type = SortResultType::NONE; + // specifies whenever it is necessary to sort selected boxes across batches or + // not + bool sort_result_across_batch = false; + // specifies the output tensor type + ngraph::element::Type output_type = ngraph::element::i64; + // specifies minimum score to consider box for the processing + float score_threshold = 0.0f; + // specifies maximum number of boxes to be selected per class, -1 meaning to + // keep all boxes + int nms_top_k = -1; + // specifies maximum number of boxes to be selected per batch element, -1 + // meaning to keep all boxes + int keep_top_k = -1; + // specifies the background class id, -1 meaning to keep all classes + int background_class = -1; + // specifies decay function used to decay scores + DecayFunction decay_function = DecayFunction::LINEAR; + // specifies gaussian_sigma parameter for gaussian decay_function + float gaussian_sigma = 2.0f; + // specifies threshold to filter out boxes with low confidence score after + // decaying + float post_threshold = 0.0f; + // specifies whether boxes are normalized or not + bool normalized = true; + }; + + MatrixNms(); + + /// \brief Constructs a MatrixNms operation + /// + /// \param boxes Node producing the box coordinates + /// \param scores Node producing the box scores + /// \param attrs Attributes of the operation + MatrixNms(const Output& boxes, + const Output& scores, + const Attributes& attrs); + + bool visit_attributes(AttributeVisitor& visitor) override; + + std::shared_ptr + clone_with_new_inputs(const OutputVector& new_args) const override; + + /// \brief Returns attributes of the operation MatrixNms + const Attributes& get_attrs() const { return m_attrs; } + + protected: + Attributes m_attrs; + + void validate() override; + }; + } // namespace v8 + } // namespace op + NGRAPH_API + std::ostream& operator<<(std::ostream& s, const op::v8::MatrixNms::DecayFunction& type); + + template <> + class NGRAPH_API AttributeAdapter + : public EnumAttributeAdapterBase + { + public: + AttributeAdapter(op::v8::MatrixNms::DecayFunction& value) + : EnumAttributeAdapterBase(value) + { + } + + static constexpr DiscreteTypeInfo type_info{ + "AttributeAdapter", 1}; + const DiscreteTypeInfo& get_type_info() const override { return type_info; } + }; +} // namespace ngraph diff --git a/ngraph/core/include/ngraph/op/multiclass_nms.hpp b/ngraph/core/include/ngraph/op/multiclass_nms.hpp new file mode 100644 index 00000000000000..1b351824ab8e0b --- /dev/null +++ b/ngraph/core/include/ngraph/op/multiclass_nms.hpp @@ -0,0 +1,75 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "ngraph/op/util/nms_base.hpp" + +namespace ngraph +{ + namespace op + { + namespace v8 + { + /// \brief MulticlassNms operation + /// + class NGRAPH_API MulticlassNms : public util::NmsBase + { + public: + NGRAPH_RTTI_DECLARATION; + + /// \brief Structure that specifies attributes of the operation + struct Attributes + { + // specifies order of output elements + SortResultType sort_result_type = SortResultType::NONE; + // specifies whenever it is necessary to sort selected boxes across batches or + // not + bool sort_result_across_batch = false; + // specifies the output tensor type + ngraph::element::Type output_type = ngraph::element::i64; + // specifies intersection over union threshold + float iou_threshold = 0.0f; + // specifies minimum score to consider box for the processing + float score_threshold = 0.0f; + // specifies maximum number of boxes to be selected per class, -1 meaning to + // keep all boxes + int nms_top_k = -1; + // specifies maximum number of boxes to be selected per batch element, -1 + // meaning to keep all boxes + int keep_top_k = -1; + // specifies the background class id, -1 meaning to keep all classes + int background_class = -1; + // specifies eta parameter for adpative NMS, in close range [0, 1.0] + float nms_eta = 1.0f; + // specifies whether boxes are normalized or not + bool normalized = true; + }; + + MulticlassNms(); + + /// \brief Constructs a MulticlassNms operation + /// + /// \param boxes Node producing the box coordinates + /// \param scores Node producing the box scores + /// \param attrs Attributes of the operation + MulticlassNms(const Output& boxes, + const Output& scores, + const Attributes& attrs); + + bool visit_attributes(AttributeVisitor& visitor) override; + + std::shared_ptr + clone_with_new_inputs(const OutputVector& new_args) const override; + + /// \brief Returns attributes of the operation MulticlassNms + const Attributes& get_attrs() const { return m_attrs; } + + protected: + Attributes m_attrs; + void validate() override; + }; + } // namespace v8 + } // namespace op +} // namespace ngraph diff --git a/ngraph/core/include/ngraph/op/shape_of.hpp b/ngraph/core/include/ngraph/op/shape_of.hpp index 1fb265480089d6..932ea4c56e0690 100644 --- a/ngraph/core/include/ngraph/op/shape_of.hpp +++ b/ngraph/core/include/ngraph/op/shape_of.hpp @@ -33,14 +33,6 @@ namespace ngraph // Overload collision with method on Node using Node::set_output_type; - // FOR CONSTANT FOLDING INTERNAL USAGE ONLY - // Constant folding for cases with static rank but dynamic shape create a subgraph - // which contains a Shape of. - // In this case we need to prevent constant folding from endless creation of these - // subgraphs. - // These metods should be removed if better solution will be designed. - void set_is_foldable(bool is_foldable) { m_is_foldable = is_foldable; } - bool get_is_foldable() const { return m_is_foldable; } bool evaluate(const HostTensorVector& output_values, const HostTensorVector& input_values) const override; bool has_evaluate() const override; @@ -50,7 +42,6 @@ namespace ngraph const OutputVector& input_values) override; private: - bool m_is_foldable = true; element::Type m_output_type; }; } // namespace v3 @@ -72,14 +63,6 @@ namespace ngraph void validate_and_infer_types() override; - // FOR CONSTANT FOLDING INTERNAL USAGE ONLY - // Constant folding for cases with static rank but dynamic shape create a subgraph - // which contains a Shape of. - // In this case we need to prevent constant folding from endless creation of these - // subgraphs. - // These metods should be removed if better solution will be designed. - void set_is_foldable(bool is_foldable) { m_is_foldable = is_foldable; } - bool get_is_foldable() const { return m_is_foldable; } bool evaluate(const HostTensorVector& output_values, const HostTensorVector& input_values) const override; bool has_evaluate() const override; @@ -87,9 +70,6 @@ namespace ngraph bool evaluate_upper(const HostTensorVector& output_values) const override; bool constant_fold(OutputVector& output_values, const OutputVector& input_values) override; - - private: - bool m_is_foldable = true; }; } // namespace v0 using v0::ShapeOf; diff --git a/ngraph/core/include/ngraph/op/sinh.hpp b/ngraph/core/include/ngraph/op/sinh.hpp index 6715e0cf682e58..1ca6c47ffecbae 100644 --- a/ngraph/core/include/ngraph/op/sinh.hpp +++ b/ngraph/core/include/ngraph/op/sinh.hpp @@ -16,8 +16,7 @@ namespace ngraph class NGRAPH_API Sinh : public util::UnaryElementwiseArithmetic { public: - static constexpr NodeTypeInfo type_info{"Sinh", 0}; - const NodeTypeInfo& get_type_info() const override { return type_info; } + NGRAPH_RTTI_DECLARATION; /// \brief Constructs a hyperbolic sine operation. /// /// \param arg Node that produces the input tensor. diff --git a/ngraph/core/include/ngraph/op/util/nms_base.hpp b/ngraph/core/include/ngraph/op/util/nms_base.hpp new file mode 100644 index 00000000000000..8983cbe7804f3a --- /dev/null +++ b/ngraph/core/include/ngraph/op/util/nms_base.hpp @@ -0,0 +1,93 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "ngraph/op/op.hpp" + +namespace ngraph +{ + namespace op + { + namespace util + { + /// \brief Base class for operations NmsBase and MatrixNms + /// + class NGRAPH_API NmsBase : public Op + { + public: + NGRAPH_RTTI_DECLARATION; + enum class SortResultType + { + CLASSID, // sort selected boxes by class id (ascending) in each batch element + SCORE, // sort selected boxes by score (descending) in each batch element + NONE // do not guarantee the order in each batch element + }; + + NmsBase() = delete; + + /// \brief Constructs a NmsBase operation + /// + /// \param output_type Specifies the output tensor type + /// \param nms_top_k Specifies maximum number of boxes to be selected per + /// class, -1 meaning to keep all boxes + /// \param keep_top_k Specifies maximum number of boxes to be selected per + /// batch element, -1 meaning to keep all boxes + NmsBase(ngraph::element::Type& output_type, int& nms_top_k, int& keep_top_k); + + /// \brief Constructs a NmsBase operation + /// + /// \param boxes Node producing the box coordinates + /// \param scores Node producing the box scores + /// \param output_type Specifies the output tensor type + /// \param nms_top_k Specifies maximum number of boxes to be selected per + /// class, -1 meaning to keep all boxes + /// \param keep_top_k Specifies maximum number of boxes to be selected per + /// batch element, -1 meaning to keep all boxes + NmsBase(const Output& boxes, + const Output& scores, + ngraph::element::Type& output_type, + int& nms_top_k, + int& keep_top_k); + + void validate_and_infer_types() override; + + const element::Type& get_output_type() const { return m_output_type; } + void set_output_type(const element::Type& output_type) + { + m_output_type = output_type; + } + using Node::set_output_type; + + int get_nms_top_k() const { return m_nms_top_k; } + + int get_keep_top_k() const { return m_keep_top_k; } + + protected: + ngraph::element::Type& m_output_type; + int& m_nms_top_k; + int& m_keep_top_k; + virtual void validate(); + }; + } // namespace util + } // namespace op + + NGRAPH_API + std::ostream& operator<<(std::ostream& s, const op::util::NmsBase::SortResultType& type); + + template <> + class NGRAPH_API AttributeAdapter + : public EnumAttributeAdapterBase + { + public: + AttributeAdapter(op::util::NmsBase::SortResultType& value) + : EnumAttributeAdapterBase(value) + { + } + + static constexpr DiscreteTypeInfo type_info{ + "AttributeAdapter", 1}; + const DiscreteTypeInfo& get_type_info() const override { return type_info; } + }; +} // namespace ngraph diff --git a/ngraph/core/include/ngraph/ops.hpp b/ngraph/core/include/ngraph/ops.hpp index 6999dc93c9de71..4701a2f733fa49 100644 --- a/ngraph/core/include/ngraph/ops.hpp +++ b/ngraph/core/include/ngraph/ops.hpp @@ -85,6 +85,7 @@ #include "ngraph/op/lstm_cell.hpp" #include "ngraph/op/lstm_sequence.hpp" #include "ngraph/op/matmul.hpp" +#include "ngraph/op/matrix_nms.hpp" #include "ngraph/op/max.hpp" #include "ngraph/op/max_pool.hpp" #include "ngraph/op/maximum.hpp" @@ -92,6 +93,7 @@ #include "ngraph/op/minimum.hpp" #include "ngraph/op/mish.hpp" #include "ngraph/op/mod.hpp" +#include "ngraph/op/multiclass_nms.hpp" #include "ngraph/op/multiply.hpp" #include "ngraph/op/mvn.hpp" #include "ngraph/op/negative.hpp" diff --git a/ngraph/core/include/ngraph/opsets/opset8_tbl.hpp b/ngraph/core/include/ngraph/opsets/opset8_tbl.hpp index ad4d641027d793..0004161dc48dd5 100644 --- a/ngraph/core/include/ngraph/opsets/opset8_tbl.hpp +++ b/ngraph/core/include/ngraph/opsets/opset8_tbl.hpp @@ -179,3 +179,5 @@ NGRAPH_OP(Gather, ngraph::op::v8) NGRAPH_OP(AdaptiveAvgPool, ngraph::op::v8) NGRAPH_OP(AdaptiveMaxPool, ngraph::op::v8) NGRAPH_OP(DeformableConvolution, ngraph::op::v8) +NGRAPH_OP(MatrixNms, ngraph::op::v8) +NGRAPH_OP(MulticlassNms, ngraph::op::v8) \ No newline at end of file diff --git a/ngraph/core/include/ngraph/slice_plan.hpp b/ngraph/core/include/ngraph/slice_plan.hpp index cc26285fd321af..6a1ac2dde03fd9 100644 --- a/ngraph/core/include/ngraph/slice_plan.hpp +++ b/ngraph/core/include/ngraph/slice_plan.hpp @@ -12,7 +12,7 @@ namespace ngraph { // - // In various places, like ConstantFolding and DynElimination, it is + // In various places, like ConstantFolding, it is // useful to transform DynSlice by converting it to a sequence of ops: // // Slice (to do the basic slicing) diff --git a/ngraph/core/include/ngraph/variant.hpp b/ngraph/core/include/ngraph/variant.hpp index 90b87cb5b37ce3..aeb67f79b9e204 100644 --- a/ngraph/core/include/ngraph/variant.hpp +++ b/ngraph/core/include/ngraph/variant.hpp @@ -22,6 +22,7 @@ namespace ngraph virtual std::shared_ptr init(const std::shared_ptr& node); virtual std::shared_ptr merge(const ngraph::NodeVector& nodes); + virtual std::string to_string() { return ""; } }; template diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/asinh.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/asinh.hpp index 02db44c13b4acd..9fc58a3dff4ed5 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/asinh.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/asinh.hpp @@ -13,7 +13,8 @@ namespace ngraph { namespace reference { - template + template ::value, bool>::type = true> void asinh(const T* arg, T* out, size_t count) { for (size_t i = 0; i < count; i++) @@ -21,6 +22,16 @@ namespace ngraph out[i] = std::asinh(arg[i]); } } + + template ::value, bool>::type = true> + void asinh(const T* arg, T* out, size_t count) + { + for (size_t i = 0; i < count; i++) + { + out[i] = std::roundl(std::asinh(arg[i])); + } + } } // namespace reference } // namespace runtime } // namespace ngraph diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/atan.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/atan.hpp index 03dcdf525f269c..a5e8f21c662300 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/atan.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/atan.hpp @@ -13,7 +13,8 @@ namespace ngraph { namespace reference { - template + template ::value, bool>::type = true> void atan(const T* arg, T* out, size_t count) { for (size_t i = 0; i < count; i++) @@ -21,6 +22,16 @@ namespace ngraph out[i] = std::atan(arg[i]); } } + + template ::value, bool>::type = true> + void atan(const T* arg, T* out, size_t count) + { + for (size_t i = 0; i < count; i++) + { + out[i] = std::roundl(std::atan(arg[i])); + } + } } // namespace reference } // namespace runtime } // namespace ngraph diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/cosh.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/cosh.hpp index 2529f9a8893cc3..a9a7e17982f485 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/cosh.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/cosh.hpp @@ -13,7 +13,8 @@ namespace ngraph { namespace reference { - template + template ::value, bool>::type = true> void cosh(const T* arg, T* out, size_t count) { for (size_t i = 0; i < count; i++) @@ -21,6 +22,16 @@ namespace ngraph out[i] = std::cosh(arg[i]); } } + + template ::value, bool>::type = true> + void cosh(const T* arg, T* out, size_t count) + { + for (size_t i = 0; i < count; i++) + { + out[i] = std::roundl(std::cosh(arg[i])); + } + } } // namespace reference } // namespace runtime } // namespace ngraph diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/deformable_convolution.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/deformable_convolution.hpp index c6ee668fbe020b..28f7ddc841e234 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/deformable_convolution.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/deformable_convolution.hpp @@ -99,14 +99,16 @@ namespace ngraph template void convolve_2D_channels(const ConvolutionParams& p, - const int64_t deformable_groups, const T* batch, const Shape& batch_shape, const T* offsets, const Shape& offset_shape, const T* filter, const Shape& filter_shape, - T* out) + T* out, + size_t group_idx, + int64_t groups, + int64_t deformable_groups) { const int input_size_y = batch_shape[1]; const int input_size_x = batch_shape[2]; @@ -121,7 +123,6 @@ namespace ngraph const int filter_channel_size = shape_size(shape_reduce(filter_shape)); const int offsets_size = shape_size(offset_shape); const int offsets_spatial_size = shape_size(shape_reduce(offset_shape)); - const int offsets_channel_size = 2 * offsets_spatial_size; const int filter_channels_count = filter_shape[0]; int out_idx = 0; @@ -136,42 +137,42 @@ namespace ngraph auto input_channel = batch; auto filter_channel = filter; T sum = 0; - auto group_offsets_channel = offsets; - for (int dg = 0; dg < deformable_groups; dg++) + for (int fc = 0; fc < filter_channels_count; fc++) { - for (int fc = 0; fc < filter_channels_count / deformable_groups; - fc++) + auto deformable_group_idx = + (filter_channels_count * group_idx + fc) / + (filter_channels_count * groups / deformable_groups); + for (int f_y = 0; f_y < filter_size_y; ++f_y) { - auto offsets_channel = group_offsets_channel; - for (int f_y = 0; f_y < filter_size_y; ++f_y) + for (int f_x = 0; f_x < filter_size_x; ++f_x) { - for (int f_x = 0; f_x < filter_size_x; ++f_x) - { - T y_offset = offsets_channel[out_idx]; - T x_offset = - offsets_channel[offsets_spatial_size + out_idx]; - T rel_i_y = i_y + (f_y * p.dilation[0]) + y_offset; - T rel_i_x = i_x + (f_x * p.dilation[1]) + x_offset; + T y_offset = offsets[deformable_group_idx * offsets_size + + (f_y * filter_size_x + f_x) * 2 * + offsets_spatial_size + + out_idx]; + T x_offset = offsets[deformable_group_idx * offsets_size + + ((f_y * filter_size_x + f_x) * 2 + 1) * + offsets_spatial_size + + out_idx]; + T rel_i_y = i_y + (f_y * p.dilation[0]) + y_offset; + T rel_i_x = i_x + (f_x * p.dilation[1]) + x_offset; - offsets_channel += offsets_channel_size; - bool padding = !(in_range(rel_i_x, {0, input_size_x}) && - in_range(rel_i_y, {0, input_size_y})); - if (padding) - continue; + bool padding = !(in_range(rel_i_x, {0, input_size_x}) && + in_range(rel_i_y, {0, input_size_y})); + if (padding) + continue; - int f_buf_idx = (f_y * filter_size_x) + f_x; - sum += bilinear_interpolation(input_channel, - rel_i_x, - rel_i_y, - input_size_x, - input_size_y) * - filter_channel[f_buf_idx]; - } + int f_buf_idx = (f_y * filter_size_x) + f_x; + sum += bilinear_interpolation(input_channel, + rel_i_x, + rel_i_y, + input_size_x, + input_size_y) * + filter_channel[f_buf_idx]; } - input_channel += input_channel_size; - filter_channel += filter_channel_size; } - group_offsets_channel += offsets_size / deformable_groups; + input_channel += input_channel_size; + filter_channel += filter_channel_size; } out[out_idx++] = sum; } @@ -218,11 +219,9 @@ namespace ngraph const Shape group_in_shape = shape_scale(shape_reduce(in_shape), groups); const size_t group_in_size = shape_size(group_in_shape); - const Shape group_offset_shape = shape_scale(shape_reduce(o_shape), groups); - const size_t group_offset_size = shape_size(group_offset_shape); + const Shape group_offset_shape = + shape_scale(shape_reduce(o_shape), deformable_groups); const size_t group_offset_batch_size = shape_size(shape_reduce(o_shape)); - const size_t deformable_groups_per_group = - std::ceil(static_cast(deformable_groups) / static_cast(groups)); const size_t group_filters_count = f_shape[filter_out_ch_axis] / groups; const Shape group_filter_shape = shape_reduce(f_shape); @@ -239,22 +238,20 @@ namespace ngraph for (size_t f_idx = 0; f_idx < group_filters_count; ++f_idx) { convolve_2D_channels(params, - deformable_groups_per_group, in, group_in_shape, group_offsets, group_offset_shape, group_filters, group_filter_shape, - out); + out, + group_idx, + groups, + deformable_groups); group_filters += group_filter_size; out += out_ch_size; } in += group_in_size; - if (deformable_groups > 1) - { - group_offsets += (deformable_groups_per_group * group_offset_size); - } } offsets += group_offset_batch_size; } diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/matrix_nms.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/matrix_nms.hpp new file mode 100644 index 00000000000000..c1c045e4349a31 --- /dev/null +++ b/ngraph/core/reference/include/ngraph/runtime/reference/matrix_nms.hpp @@ -0,0 +1,41 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ngraph/node.hpp" +#include "ngraph/op/matrix_nms.hpp" +#include "ngraph/op/util/op_types.hpp" +#include "ngraph/ops.hpp" +#include "ngraph/shape_util.hpp" + +namespace ngraph +{ + namespace runtime + { + namespace reference + { + void matrix_nms(const float* boxes_data, + const Shape& boxes_data_shape, + const float* scores_data, + const Shape& scores_data_shape, + const op::v8::MatrixNms::Attributes& attrs, + float* selected_outputs, + const Shape& selected_outputs_shape, + int64_t* selected_indices, + const Shape& selected_indices_shape, + int64_t* valid_outputs); + + } // namespace reference + } // namespace runtime +} // namespace ngraph diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/multiclass_nms.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/multiclass_nms.hpp new file mode 100644 index 00000000000000..fe14f29689aa4f --- /dev/null +++ b/ngraph/core/reference/include/ngraph/runtime/reference/multiclass_nms.hpp @@ -0,0 +1,41 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ngraph/node.hpp" +#include "ngraph/op/util/nms_base.hpp" +#include "ngraph/op/util/op_types.hpp" +#include "ngraph/ops.hpp" +#include "ngraph/shape_util.hpp" + +namespace ngraph +{ + namespace runtime + { + namespace reference + { + void multiclass_nms(const float* boxes_data, + const Shape& boxes_data_shape, + const float* scores_data, + const Shape& scores_data_shape, + const op::v8::MulticlassNms::Attributes& attrs, + float* selected_outputs, + const Shape& selected_outputs_shape, + int64_t* selected_indices, + const Shape& selected_indices_shape, + int64_t* valid_outputs); + + } // namespace reference + } // namespace runtime +} // namespace ngraph diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/sinh.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/sinh.hpp index 3712bcd36aad30..941ecd0f7f483b 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/sinh.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/sinh.hpp @@ -13,7 +13,8 @@ namespace ngraph { namespace reference { - template + template ::value, bool>::type = true> void sinh(const T* arg, T* out, size_t count) { for (size_t i = 0; i < count; i++) @@ -21,6 +22,15 @@ namespace ngraph out[i] = std::sinh(arg[i]); } } + template ::value, bool>::type = true> + void sinh(const T* arg, T* out, size_t count) + { + for (size_t i = 0; i < count; i++) + { + out[i] = std::roundl(std::sinh(arg[i])); + } + } } // namespace reference } // namespace runtime } // namespace ngraph diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/utils/nms_common.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/utils/nms_common.hpp new file mode 100644 index 00000000000000..b44e8dbaa41c51 --- /dev/null +++ b/ngraph/core/reference/include/ngraph/runtime/reference/utils/nms_common.hpp @@ -0,0 +1,88 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include +#include +#include "ngraph/type/element_type.hpp" + +namespace ngraph +{ + namespace runtime + { + namespace reference + { + namespace nms_common + { + struct Rectangle + { + Rectangle(float x_left, float y_left, float x_right, float y_right) + : x1{x_left} + , y1{y_left} + , x2{x_right} + , y2{y_right} + { + } + + Rectangle() = default; + + float x1 = 0.0f; + float y1 = 0.0f; + float x2 = 0.0f; + float y2 = 0.0f; + }; + + struct BoxInfo + { + BoxInfo(const Rectangle& r, + int64_t idx, + float sc, + int64_t suppress_idx, + int64_t batch_idx, + int64_t class_idx) + : box{r} + , index{idx} + , suppress_begin_index{suppress_idx} + , batch_index{batch_idx} + , class_index{class_idx} + , score{sc} + { + } + + BoxInfo() = default; + + inline bool operator<(const BoxInfo& rhs) const + { + return score < rhs.score || (score == rhs.score && index > rhs.index); + } + + inline bool operator>(const BoxInfo& rhs) const + { + return !(score < rhs.score || (score == rhs.score && index > rhs.index)); + } + + Rectangle box; + int64_t index = 0; + int64_t suppress_begin_index = 0; + int64_t batch_index = 0; + int64_t class_index = 0; + float score = 0.0f; + }; + + void nms_common_postprocessing(void* prois, + void* pscores, + void* pselected_num, + const ngraph::element::Type& output_type, + const std::vector& selected_outputs, + const std::vector& selected_indices, + const std::vector& valid_outputs); + + } // namespace nms_common + } // namespace reference + } // namespace runtime +} // namespace ngraph diff --git a/ngraph/core/reference/src/runtime/reference/matrix_nms.cpp b/ngraph/core/reference/src/runtime/reference/matrix_nms.cpp new file mode 100644 index 00000000000000..e82d0ee4de355d --- /dev/null +++ b/ngraph/core/reference/src/runtime/reference/matrix_nms.cpp @@ -0,0 +1,354 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "ngraph/op/matrix_nms.hpp" +#include +#include +#include +#include +#include +#include "ngraph/runtime/reference/matrix_nms.hpp" +#include "ngraph/runtime/reference/utils/nms_common.hpp" +#include "ngraph/shape.hpp" + +using namespace ngraph; +using namespace ngraph::runtime::reference; + +namespace ngraph +{ + namespace runtime + { + namespace reference + { + namespace matrix_nms_v8 + { + template + struct decay_score; + + template + struct decay_score + { + T operator()(T iou, T max_iou, T sigma) + { + return std::exp((max_iou * max_iou - iou * iou) * sigma); + } + }; + + template + struct decay_score + { + T operator()(T iou, T max_iou, T sigma) + { + return (1. - iou) / (1. - max_iou + 1e-10f); + } + }; + + template + static inline T BBoxArea(const T* box, const bool normalized) + { + if (box[2] < box[0] || box[3] < box[1]) + { + // If coordinate values are is invalid + // (e.g. xmax < xmin or ymax < ymin), return 0. + return static_cast(0.); + } + else + { + const T w = box[2] - box[0]; + const T h = box[3] - box[1]; + if (normalized) + { + return w * h; + } + else + { + // If coordinate values are not within range [0, 1]. + return (w + 1) * (h + 1); + } + } + } + + template + static inline T + intersectionOverUnion(const T* box1, const T* box2, const bool normalized) + { + if (box2[0] > box1[2] || box2[2] < box1[0] || box2[1] > box1[3] || + box2[3] < box1[1]) + { + return static_cast(0.); + } + else + { + const T inter_xmin = std::max(box1[0], box2[0]); + const T inter_ymin = std::max(box1[1], box2[1]); + const T inter_xmax = std::min(box1[2], box2[2]); + const T inter_ymax = std::min(box1[3], box2[3]); + T norm = normalized ? static_cast(0.) : static_cast(1.); + T inter_w = inter_xmax - inter_xmin + norm; + T inter_h = inter_ymax - inter_ymin + norm; + const T inter_area = inter_w * inter_h; + const T bbox1_area = BBoxArea(box1, normalized); + const T bbox2_area = BBoxArea(box2, normalized); + return inter_area / (bbox1_area + bbox2_area - inter_area); + } + } + } // namespace matrix_nms_v8 + + template + void nms_matrix(const T* boxes_data, + const Shape& boxes_data_shape, + const T* scores_data, + const Shape& scores_data_shape, + const T score_threshold, + const T post_threshold, + const float sigma, + const int64_t top_k, + const bool normalized, + std::vector* selected_indices, + std::vector* decayed_scores) + { + int64_t boxes_num = static_cast(boxes_data_shape[1]); + int64_t box_size = static_cast(boxes_data_shape[2]); + + std::vector candidate_index(boxes_num); + std::iota(candidate_index.begin(), candidate_index.end(), 0); + auto end = std::remove_if(candidate_index.begin(), + candidate_index.end(), + [&scores_data, score_threshold](int32_t idx) { + return scores_data[idx] <= score_threshold; + }); + + int64_t original_size = std::distance(candidate_index.begin(), end); + if (original_size <= 0) + { + return; + } + if (top_k > -1 && original_size > top_k) + { + original_size = top_k; + } + + std::partial_sort(candidate_index.begin(), + candidate_index.begin() + original_size, + end, + [&scores_data](int32_t a, int32_t b) { + return scores_data[a] > scores_data[b]; + }); + + std::vector iou_matrix((original_size * (original_size - 1)) >> 1); + std::vector iou_max(original_size); + + iou_max[0] = 0.; + for (int64_t i = 1; i < original_size; i++) + { + T max_iou = 0.; + auto idx_a = candidate_index[i]; + for (int64_t j = 0; j < i; j++) + { + auto idx_b = candidate_index[j]; + auto iou = + matrix_nms_v8::intersectionOverUnion(boxes_data + idx_a * box_size, + boxes_data + idx_b * box_size, + normalized); + max_iou = std::max(max_iou, iou); + iou_matrix[i * (i - 1) / 2 + j] = iou; + } + iou_max[i] = max_iou; + } + + if (scores_data[candidate_index[0]] > post_threshold) + { + selected_indices->push_back(candidate_index[0]); + decayed_scores->push_back(scores_data[candidate_index[0]]); + } + + matrix_nms_v8::decay_score decay_fn; + for (int64_t i = 1; i < original_size; i++) + { + T min_decay = 1.; + for (int64_t j = 0; j < i; j++) + { + auto max_iou = iou_max[j]; + auto iou = iou_matrix[i * (i - 1) / 2 + j]; + auto decay = decay_fn(iou, max_iou, sigma); + min_decay = std::min(min_decay, decay); + } + auto ds = min_decay * scores_data[candidate_index[i]]; + if (ds <= post_threshold) + continue; + selected_indices->push_back(candidate_index[i]); + decayed_scores->push_back(ds); + } + } + + void matrix_nms(const float* boxes_data, + const Shape& boxes_data_shape, + const float* scores_data, + const Shape& scores_data_shape, + const op::v8::MatrixNms::Attributes& attrs, + float* selected_outputs, + const Shape& selected_outputs_shape, + int64_t* selected_indices, + const Shape& selected_indices_shape, + int64_t* valid_outputs) + { + using Rectangle = runtime::reference::nms_common::Rectangle; + using BoxInfo = runtime::reference::nms_common::BoxInfo; + + // boxes shape: {num_batches, num_boxes, 4} + // scores shape: {num_batches, num_classes, num_boxes} + int64_t num_batches = static_cast(scores_data_shape[0]); + int64_t num_classes = static_cast(scores_data_shape[1]); + int64_t num_boxes = static_cast(boxes_data_shape[1]); + int64_t box_shape = static_cast(boxes_data_shape[2]); + + std::vector num_per_batch; + std::vector filtered_boxes; + filtered_boxes.reserve(6 * num_batches * num_classes * num_boxes); + + for (int64_t batch = 0; batch < num_batches; batch++) + { + const float* boxesPtr = boxes_data + batch * num_boxes * 4; + std::vector all_indices; + std::vector all_scores; + std::vector all_classes; + size_t num_det = 0; + + for (int64_t class_idx = 0; class_idx < num_classes; class_idx++) + { + if (class_idx == attrs.background_class) + continue; + const float* scoresPtr = + scores_data + batch * (num_classes * num_boxes) + class_idx * num_boxes; + if (attrs.decay_function == op::v8::MatrixNms::DecayFunction::GAUSSIAN) + { + nms_matrix(boxesPtr, + boxes_data_shape, + scoresPtr, + scores_data_shape, + attrs.score_threshold, + attrs.post_threshold, + attrs.gaussian_sigma, + attrs.nms_top_k, + attrs.normalized, + &all_indices, + &all_scores); + } + else + { + nms_matrix(boxesPtr, + boxes_data_shape, + scoresPtr, + scores_data_shape, + attrs.score_threshold, + attrs.post_threshold, + attrs.gaussian_sigma, + attrs.nms_top_k, + attrs.normalized, + &all_indices, + &all_scores); + } + for (size_t i = 0; i < all_indices.size() - num_det; i++) + { + all_classes.push_back(class_idx); + } + num_det = all_indices.size(); + } + + if (num_det <= 0) + { + break; + } + + if (attrs.keep_top_k > -1) + { + auto k = static_cast(attrs.keep_top_k); + if (num_det > k) + num_det = k; + } + + std::vector perm(all_indices.size()); + std::iota(perm.begin(), perm.end(), 0); + + std::partial_sort(perm.begin(), + perm.begin() + num_det, + perm.end(), + [&all_scores, &all_classes, &all_indices](int lhs, int rhs) { + return (all_scores[lhs] > all_scores[rhs]) || + (all_scores[lhs] == all_scores[rhs] && + all_classes[lhs] < all_classes[rhs]) || + (all_scores[lhs] == all_scores[rhs] && + all_classes[lhs] == all_classes[rhs] && + all_indices[lhs] < all_indices[rhs]); + }); + + for (size_t i = 0; i < num_det; i++) + { + auto p = perm[i]; + auto idx = all_indices[p]; + auto cls = all_classes[p]; + auto score = all_scores[p]; + auto bbox = boxesPtr + idx * box_shape; + + filtered_boxes.push_back( + BoxInfo{Rectangle{bbox[0], bbox[1], bbox[2], bbox[3]}, + batch * num_boxes + idx, + score, + 0, + batch, + cls}); + } + num_per_batch.push_back(num_det); + } + + if (attrs.sort_result_across_batch) + { /* sort across batch */ + if (attrs.sort_result_type == op::v8::MatrixNms::SortResultType::SCORE) + { + std::sort( + filtered_boxes.begin(), + filtered_boxes.end(), + [](const BoxInfo& l, const BoxInfo& r) { + return (l.score > r.score) || + (l.score == r.score && l.batch_index < r.batch_index) || + (l.score == r.score && l.batch_index == r.batch_index && + l.class_index < r.class_index) || + (l.score == r.score && l.batch_index == r.batch_index && + l.class_index == r.class_index && l.index < r.index); + }); + } + else if (attrs.sort_result_type == op::v8::MatrixNms::SortResultType::CLASSID) + { + std::sort(filtered_boxes.begin(), + filtered_boxes.end(), + [](const BoxInfo& l, const BoxInfo& r) { + return (l.class_index < r.class_index) || + (l.class_index == r.class_index && + l.batch_index < r.batch_index) || + (l.class_index == r.class_index && + l.batch_index == r.batch_index && + l.score > r.score) || + (l.class_index == r.class_index && + l.batch_index == r.batch_index && + l.score == r.score && l.index < r.index); + }); + } + } + + std::copy(num_per_batch.begin(), num_per_batch.end(), valid_outputs); + for (size_t i = 0; i < filtered_boxes.size(); i++) + { + selected_indices[i] = filtered_boxes[i].index; + auto selected_base = selected_outputs + i * 6; + selected_base[0] = filtered_boxes[i].class_index; + selected_base[1] = filtered_boxes[i].score; + selected_base[2] = filtered_boxes[i].box.x1; + selected_base[3] = filtered_boxes[i].box.y1; + selected_base[4] = filtered_boxes[i].box.x2; + selected_base[5] = filtered_boxes[i].box.y2; + } + } + } // namespace reference + } // namespace runtime +} // namespace ngraph diff --git a/ngraph/core/reference/src/runtime/reference/multiclass_nms.cpp b/ngraph/core/reference/src/runtime/reference/multiclass_nms.cpp new file mode 100644 index 00000000000000..3328de9c3aad9e --- /dev/null +++ b/ngraph/core/reference/src/runtime/reference/multiclass_nms.cpp @@ -0,0 +1,350 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "ngraph/op/multiclass_nms.hpp" +#include +#include +#include +#include +#include +#include "ngraph/runtime/reference/multiclass_nms.hpp" +#include "ngraph/runtime/reference/utils/nms_common.hpp" +#include "ngraph/shape.hpp" + +using namespace ngraph; +using namespace ngraph::runtime::reference; + +namespace ngraph +{ + namespace runtime + { + namespace reference + { + namespace multiclass_nms_v8 + { + using Rectangle = runtime::reference::nms_common::Rectangle; + using BoxInfo = runtime::reference::nms_common::BoxInfo; + static float intersectionOverUnion(const Rectangle& boxI, + const Rectangle& boxJ, + const bool normalized) + { + const float norm = static_cast(normalized == false); + + float areaI = (boxI.y2 - boxI.y1 + norm) * (boxI.x2 - boxI.x1 + norm); + float areaJ = (boxJ.y2 - boxJ.y1 + norm) * (boxJ.x2 - boxJ.x1 + norm); + + if (areaI <= 0.0f || areaJ <= 0.0f) + { + return 0.0f; + } + + float intersection_ymin = std::max(boxI.y1, boxJ.y1); + float intersection_xmin = std::max(boxI.x1, boxJ.x1); + float intersection_ymax = std::min(boxI.y2, boxJ.y2); + float intersection_xmax = std::min(boxI.x2, boxJ.x2); + + float intersection_area = + std::max(intersection_ymax - intersection_ymin + norm, 0.0f) * + std::max(intersection_xmax - intersection_xmin + norm, 0.0f); + + return intersection_area / (areaI + areaJ - intersection_area); + } + + struct SelectedIndex + { + SelectedIndex(int64_t batch_idx, int64_t box_idx, int64_t num_box) + : flattened_index(batch_idx * num_box + box_idx) + { + } + + SelectedIndex() = default; + + int64_t flattened_index = 0; + }; + + struct SelectedOutput + { + SelectedOutput( + float class_idx, float score, float x1, float y1, float x2, float y2) + : class_index{class_idx} + , box_score{score} + , xmin{x1} + , ymin{y1} + , xmax{x2} + , ymax{y2} + { + } + + SelectedOutput() = default; + + float class_index = 0.0f; + float box_score = 0.0f; + float xmin, ymin, xmax, ymax; + }; + } // namespace multiclass_nms_v8 + + void multiclass_nms(const float* boxes_data, + const Shape& boxes_data_shape, + const float* scores_data, + const Shape& scores_data_shape, + const op::v8::MulticlassNms::Attributes& attrs, + float* selected_outputs, + const Shape& selected_outputs_shape, + int64_t* selected_indices, + const Shape& selected_indices_shape, + int64_t* valid_outputs) + { + using SelectedIndex = multiclass_nms_v8::SelectedIndex; + using SelectedOutput = multiclass_nms_v8::SelectedOutput; + using BoxInfo = multiclass_nms_v8::BoxInfo; + using Rectangle = multiclass_nms_v8::Rectangle; + + auto func = [](float iou, float adaptive_threshold) { + return iou <= adaptive_threshold ? 1.0f : 0.0f; + }; + + // boxes shape: {num_batches, num_boxes, 4} + // scores shape: {num_batches, num_classes, num_boxes} + int64_t num_batches = static_cast(scores_data_shape[0]); + int64_t num_classes = static_cast(scores_data_shape[1]); + int64_t num_boxes = static_cast(boxes_data_shape[1]); + + SelectedIndex* selected_indices_ptr = + reinterpret_cast(selected_indices); + SelectedOutput* selected_scores_ptr = + reinterpret_cast(selected_outputs); + + std::vector filteredBoxes; // container for the whole batch + + for (int64_t batch = 0; batch < num_batches; batch++) + { + const float* boxesPtr = boxes_data + batch * num_boxes * 4; + Rectangle* r = reinterpret_cast(const_cast(boxesPtr)); + + int64_t num_dets = 0; + std::vector selected_boxes; // container for a batch element + + for (int64_t class_idx = 0; class_idx < num_classes; class_idx++) + { + if (class_idx == attrs.background_class) + continue; + + auto adaptive_threshold = attrs.iou_threshold; + + const float* scoresPtr = + scores_data + batch * (num_classes * num_boxes) + class_idx * num_boxes; + + std::vector candidate_boxes; + + for (int64_t box_idx = 0; box_idx < num_boxes; box_idx++) + { + if (scoresPtr[box_idx] >= + attrs.score_threshold) /* NOTE: ">=" instead of ">" used in PDPD */ + { + candidate_boxes.emplace_back( + r[box_idx], box_idx, scoresPtr[box_idx], 0, batch, class_idx); + } + } + + int candiate_size = candidate_boxes.size(); + + // threshold nms_top_k for each class + // NOTE: "nms_top_k" in PDPD not exactly equal to + // "max_output_boxes_per_class" in ONNX. + if (attrs.nms_top_k > -1 && attrs.nms_top_k < candiate_size) + { + candiate_size = attrs.nms_top_k; + } + + if (candiate_size <= 0) // early drop + { + continue; + } + + // sort by score in current class + std::partial_sort(candidate_boxes.begin(), + candidate_boxes.begin() + candiate_size, + candidate_boxes.end(), + std::greater()); + + std::priority_queue sorted_boxes(candidate_boxes.begin(), + candidate_boxes.begin() + + candiate_size, + std::less()); + + std::vector selected; // container for a class + + // Get the next box with top score, filter by iou_threshold + BoxInfo next_candidate; + float original_score; + + while (!sorted_boxes.empty()) + { + next_candidate = sorted_boxes.top(); + original_score = next_candidate.score; + sorted_boxes.pop(); + + bool should_hard_suppress = false; + for (int64_t j = static_cast(selected.size()) - 1; + j >= next_candidate.suppress_begin_index; + --j) + { + float iou = multiclass_nms_v8::intersectionOverUnion( + next_candidate.box, selected[j].box, attrs.normalized); + next_candidate.score *= func(iou, adaptive_threshold); + + if (iou >= adaptive_threshold) + { + should_hard_suppress = true; + break; + } + + if (next_candidate.score <= attrs.score_threshold) + { + break; + } + } + + next_candidate.suppress_begin_index = selected.size(); + + if (!should_hard_suppress) + { + if (attrs.nms_eta < 1 && adaptive_threshold > 0.5) + { + adaptive_threshold *= attrs.nms_eta; + } + if (next_candidate.score == original_score) + { + selected.push_back(next_candidate); + continue; + } + if (next_candidate.score > attrs.score_threshold) + { + sorted_boxes.push(next_candidate); + } + } + } + + for (const auto& box_info : selected) + { + selected_boxes.push_back(box_info); + } + num_dets += selected.size(); + } // for each class + + // sort inside batch element before go through keep_top_k + std::sort(selected_boxes.begin(), + selected_boxes.end(), + [](const BoxInfo& l, const BoxInfo& r) { + return ((l.batch_index == r.batch_index) && + ((l.score > r.score) || + ((std::fabs(l.score - r.score) < 1e-6) && + l.class_index < r.class_index) || + ((std::fabs(l.score - r.score) < 1e-6) && + l.class_index == r.class_index && l.index < r.index))); + }); + + // threshold keep_top_k for each batch element + if (attrs.keep_top_k > -1 && attrs.keep_top_k < num_dets) + { + num_dets = attrs.keep_top_k; + selected_boxes.resize(num_dets); + } + + // sort + if (!attrs.sort_result_across_batch) + { + if (attrs.sort_result_type == + op::v8::MulticlassNms::SortResultType::CLASSID) + { + std::sort( + selected_boxes.begin(), + selected_boxes.end(), + [](const BoxInfo& l, const BoxInfo& r) { + return ( + (l.batch_index == r.batch_index) && + ((l.class_index < r.class_index) || + ((l.class_index == r.class_index) && l.score > r.score) || + ((std::fabs(l.score - r.score) <= 1e-6) && + l.class_index == r.class_index && l.index < r.index))); + }); + } + // in case of "SCORE", pass through, as, + // it has already gurranteed. + } + + *valid_outputs++ = num_dets; + for (auto& v : selected_boxes) + { + filteredBoxes.push_back(v); + } + } // for each batch element + + if (attrs.sort_result_across_batch) + { /* sort across batch */ + if (attrs.sort_result_type == op::v8::MulticlassNms::SortResultType::SCORE) + { + std::sort( + filteredBoxes.begin(), + filteredBoxes.end(), + [](const BoxInfo& l, const BoxInfo& r) { + return (l.score > r.score) || + (l.score == r.score && l.batch_index < r.batch_index) || + (l.score == r.score && l.batch_index == r.batch_index && + l.class_index < r.class_index) || + (l.score == r.score && l.batch_index == r.batch_index && + l.class_index == r.class_index && l.index < r.index); + }); + } + else if (attrs.sort_result_type == + op::v8::MulticlassNms::SortResultType::CLASSID) + { + std::sort(filteredBoxes.begin(), + filteredBoxes.end(), + [](const BoxInfo& l, const BoxInfo& r) { + return (l.class_index < r.class_index) || + (l.class_index == r.class_index && + l.batch_index < r.batch_index) || + (l.class_index == r.class_index && + l.batch_index == r.batch_index && + l.score > r.score) || + (l.class_index == r.class_index && + l.batch_index == r.batch_index && + l.score == r.score && l.index < r.index); + }); + } + } + + /* output */ + + size_t max_num_of_selected_indices = selected_indices_shape[0]; + size_t output_size = std::min(filteredBoxes.size(), max_num_of_selected_indices); + + size_t idx; + for (idx = 0; idx < output_size; idx++) + { + const auto& box_info = filteredBoxes[idx]; + SelectedIndex selected_index{box_info.batch_index, box_info.index, num_boxes}; + SelectedOutput selected_score{static_cast(box_info.class_index), + box_info.score, + box_info.box.x1, + box_info.box.y1, + box_info.box.x2, + box_info.box.y2}; + + selected_indices_ptr[idx] = selected_index; + selected_scores_ptr[idx] = selected_score; + } + + SelectedIndex selected_index_filler{0, 0, 0}; + SelectedOutput selected_score_filler{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}; + for (; idx < max_num_of_selected_indices; idx++) + { + selected_indices_ptr[idx] = selected_index_filler; + selected_scores_ptr[idx] = selected_score_filler; + } + } + } // namespace reference + } // namespace runtime +} // namespace ngraph diff --git a/ngraph/core/reference/src/runtime/reference/utils/nms_common.cpp b/ngraph/core/reference/src/runtime/reference/utils/nms_common.cpp new file mode 100644 index 00000000000000..c658b0f0cad4b5 --- /dev/null +++ b/ngraph/core/reference/src/runtime/reference/utils/nms_common.cpp @@ -0,0 +1,72 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include +#include + +#include "ngraph/runtime/reference/utils/nms_common.hpp" + +namespace ngraph +{ + namespace runtime + { + namespace reference + { + namespace nms_common + { + void nms_common_postprocessing(void* prois, + void* pscores, + void* pselected_num, + const ngraph::element::Type& output_type, + const std::vector& selected_outputs, + const std::vector& selected_indices, + const std::vector& valid_outputs) + { + int64_t total_num = + std::accumulate(valid_outputs.begin(), valid_outputs.end(), 0); + + float* ptr = static_cast(prois); + memcpy(ptr, selected_outputs.data(), total_num * sizeof(float) * 6); + + if (pscores) + { + if (output_type == ngraph::element::i64) + { + int64_t* indices_ptr = static_cast(pscores); + memcpy( + indices_ptr, selected_indices.data(), total_num * sizeof(int64_t)); + } + else + { + int32_t* indices_ptr = static_cast(pscores); + for (int64_t i = 0; i < total_num; ++i) + { + indices_ptr[i] = static_cast(selected_indices[i]); + } + } + } + + if (pselected_num) + { + if (output_type == ngraph::element::i64) + { + int64_t* valid_outputs_ptr = static_cast(pselected_num); + std::copy( + valid_outputs.begin(), valid_outputs.end(), valid_outputs_ptr); + } + else + { + int32_t* valid_outputs_ptr = static_cast(pselected_num); + for (size_t i = 0; i < valid_outputs.size(); ++i) + { + valid_outputs_ptr[i] = static_cast(valid_outputs[i]); + } + } + } + } + } // namespace nms_common + } // namespace reference + } // namespace runtime +} // namespace ngraph diff --git a/ngraph/core/src/descriptor/tensor.cpp b/ngraph/core/src/descriptor/tensor.cpp index 58b06df90ad027..1d8335fee080dc 100644 --- a/ngraph/core/src/descriptor/tensor.cpp +++ b/ngraph/core/src/descriptor/tensor.cpp @@ -123,6 +123,14 @@ void descriptor::Tensor::set_names(const std::unordered_set& names) m_names = names; } +void descriptor::Tensor::add_names(const std::unordered_set& names) +{ + for (const auto& name : names) + { + m_names.insert(name); + } +} + ostream& operator<<(ostream& out, const descriptor::Tensor& tensor) { std::string names; diff --git a/ngraph/core/src/graph_util.cpp b/ngraph/core/src/graph_util.cpp index 12a439f17e32e1..901672723a1799 100644 --- a/ngraph/core/src/graph_util.cpp +++ b/ngraph/core/src/graph_util.cpp @@ -167,11 +167,9 @@ void ngraph::replace_node(std::shared_ptr target, // Change I's connected upstream output to O_rep for (size_t i = 0; i < target->get_output_size(); i++) { - for (auto& input : target->output(i).get_target_inputs()) - { - input.replace_source_output(replacement->output(output_order[i])); - } + target->output(i).replace(replacement->output(output_order[i])); } + replacement->add_node_control_dependents(target); replacement->add_node_control_dependencies(target); target->clear_control_dependents(); @@ -912,7 +910,15 @@ bool ngraph::replace_output_update_name(Output output, const Output& replacement.get_tensor().set_name(output.get_node()->get_friendly_name()); NGRAPH_SUPPRESS_DEPRECATED_END } + + // Save replacement tensor names before replacement as they will be + // overrided by the output tensor names + auto output_names = replacement.get_tensor_ptr()->get_names(); output.replace(replacement); + + // Restore back original replacement tensor names + replacement.get_tensor().add_names(output_names); + copy_runtime_info({replacement.get_node_shared_ptr(), output.get_node_shared_ptr()}, replacement.get_node_shared_ptr()); return true; diff --git a/ngraph/core/src/node_output.cpp b/ngraph/core/src/node_output.cpp index 9799c49b8fa216..e64dd472f3525f 100644 --- a/ngraph/core/src/node_output.cpp +++ b/ngraph/core/src/node_output.cpp @@ -76,6 +76,7 @@ namespace ngraph { input.replace_source_output(replacement); } + replacement.get_tensor_ptr()->set_names(get_tensor_ptr()->get_names()); } using RTMap = std::map>; diff --git a/ngraph/core/src/op/asinh.cpp b/ngraph/core/src/op/asinh.cpp index ed7b2191bd605e..16ea8b046d1885 100644 --- a/ngraph/core/src/op/asinh.cpp +++ b/ngraph/core/src/op/asinh.cpp @@ -7,6 +7,7 @@ #include "itt.hpp" #include "ngraph/op/asinh.hpp" +#include "ngraph/op/util/elementwise_args.hpp" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/runtime/reference/asinh.hpp" #include "ngraph/type/element_type.hpp" @@ -14,7 +15,7 @@ using namespace std; using namespace ngraph; -constexpr NodeTypeInfo op::v3::Asinh::type_info; +NGRAPH_RTTI_DEFINITION(op::v3::Asinh, "Asinh", 3, util::UnaryElementwiseArithmetic); op::v3::Asinh::Asinh(const Output& arg) : UnaryElementwiseArithmetic(arg) @@ -32,25 +33,26 @@ shared_ptr op::v3::Asinh::clone_with_new_inputs(const OutputVector& new_ar namespace asinhop { template - bool evaluate(const HostTensorPtr& arg0, const HostTensorPtr& out) + inline bool evaluate(const HostTensorPtr& arg0, const HostTensorPtr& out, const size_t count) { - runtime::reference::asinh( - arg0->get_data_ptr(), out->get_data_ptr(), shape_size(arg0->get_shape())); + runtime::reference::asinh(arg0->get_data_ptr(), out->get_data_ptr(), count); return true; } bool evaluate_asinh(const HostTensorPtr& arg0, const HostTensorPtr& out) { bool rc = true; + size_t count = shape_size(arg0->get_shape()); out->set_unary(arg0); + switch (arg0->get_element_type()) { - NGRAPH_TYPE_CASE(evaluate_asinh, i32, arg0, out); - NGRAPH_TYPE_CASE(evaluate_asinh, i64, arg0, out); - NGRAPH_TYPE_CASE(evaluate_asinh, u32, arg0, out); - NGRAPH_TYPE_CASE(evaluate_asinh, u64, arg0, out); - NGRAPH_TYPE_CASE(evaluate_asinh, f16, arg0, out); - NGRAPH_TYPE_CASE(evaluate_asinh, f32, arg0, out); + NGRAPH_TYPE_CASE(evaluate_asinh, i32, arg0, out, count); + NGRAPH_TYPE_CASE(evaluate_asinh, i64, arg0, out, count); + NGRAPH_TYPE_CASE(evaluate_asinh, u32, arg0, out, count); + NGRAPH_TYPE_CASE(evaluate_asinh, u64, arg0, out, count); + NGRAPH_TYPE_CASE(evaluate_asinh, f16, arg0, out, count); + NGRAPH_TYPE_CASE(evaluate_asinh, f32, arg0, out, count); default: rc = false; break; } return rc; @@ -65,7 +67,7 @@ bool op::v3::Asinh::evaluate(const HostTensorVector& outputs, const HostTensorVe bool op::v3::Asinh::has_evaluate() const { - NGRAPH_OP_SCOPE(v1_Asinh_has_evaluate); + NGRAPH_OP_SCOPE(v3_Asinh_has_evaluate); switch (get_input_element_type(0)) { case ngraph::element::i32: diff --git a/ngraph/core/src/op/atan.cpp b/ngraph/core/src/op/atan.cpp index c3f1cce9fb44ee..9344f7ea0b21df 100644 --- a/ngraph/core/src/op/atan.cpp +++ b/ngraph/core/src/op/atan.cpp @@ -23,7 +23,7 @@ using namespace std; using namespace ngraph; -constexpr NodeTypeInfo op::Atan::type_info; +NGRAPH_RTTI_DEFINITION(op::v0::Atan, "Atan", 0, util::UnaryElementwiseArithmetic); op::Atan::Atan(const Output& arg) : UnaryElementwiseArithmetic(arg) diff --git a/ngraph/core/src/op/batch_to_space.cpp b/ngraph/core/src/op/batch_to_space.cpp index 40feec4638429b..9ec3c0f7bd17fe 100644 --- a/ngraph/core/src/op/batch_to_space.cpp +++ b/ngraph/core/src/op/batch_to_space.cpp @@ -23,7 +23,7 @@ using namespace std; using namespace ngraph; -constexpr NodeTypeInfo op::v1::BatchToSpace::type_info; +NGRAPH_RTTI_DEFINITION(op::v1::BatchToSpace, "BatchToSpace", 1); ngraph::op::v1::BatchToSpace::BatchToSpace(const ngraph::Output& data, const ngraph::Output& block_shape, @@ -37,83 +37,135 @@ ngraph::op::v1::BatchToSpace::BatchToSpace(const ngraph::Output& d void op::v1::BatchToSpace::validate_and_infer_types() { NGRAPH_OP_SCOPE(v1_BatchToSpace_validate_and_infer_types); - PartialShape data_pshape = get_input_partial_shape(0); - const auto& data_type = get_input_element_type(0); - const auto& block_shape_type = get_input_element_type(1); - const auto& crops_begin_type = get_input_element_type(2); - const auto& crops_end_type = get_input_element_type(3); + const auto& data_et = get_input_element_type(0); + const auto& block_shape_et = get_input_element_type(1); + const auto& crops_begin_et = get_input_element_type(2); + const auto& crops_end_et = get_input_element_type(3); + + element::Type inputs_integer_et{}; + NODE_VALIDATION_CHECK( + this, + element::Type::merge(inputs_integer_et, crops_begin_et, crops_end_et) && + element::Type::merge(inputs_integer_et, inputs_integer_et, block_shape_et), + "block_shape, crops_begin and crops_end inputs must have same element type. Got: ", + block_shape_et, + ", ", + crops_begin_et, + " and ", + crops_end_et); NODE_VALIDATION_CHECK(this, - block_shape_type.is_integral_number(), - "block_shape must be an integral number but got (", - block_shape_type, - ")."); - + inputs_integer_et.is_integral_number(), + "block_shape and crops inputs must have integer element type. Got: ", + inputs_integer_et); + + const PartialShape& data_pshape = get_input_partial_shape(0); + const PartialShape& block_shape_ps = get_input_partial_shape(1); + const PartialShape& crops_begin_ps = get_input_partial_shape(2); + const PartialShape& crops_end_ps = get_input_partial_shape(3); + + PartialShape inputs_same_ps{PartialShape::dynamic()}; + NODE_VALIDATION_CHECK( + this, + PartialShape::merge_into(inputs_same_ps, crops_begin_ps) && + PartialShape::merge_into(inputs_same_ps, crops_end_ps) && + PartialShape::merge_into(inputs_same_ps, block_shape_ps), + "block_shape, crops_begin and crops_end inputs must have the same shape. Got: ", + block_shape_ps, + ", ", + crops_begin_ps, + " and ", + crops_end_ps); + + const Rank inputs_rank_one = inputs_same_ps.rank(); NODE_VALIDATION_CHECK(this, - crops_begin_type.is_integral_number(), - "crops_begin must be an integral number but got (", - crops_begin_type, - ")."); + inputs_rank_one.compatible(1), + "block_shape and crops inputs must have rank 1. Got: ", + inputs_rank_one); - NODE_VALIDATION_CHECK(this, - crops_end_type.is_integral_number(), - "crops_end must be an integral number but got (", - crops_end_type, - ")."); + const Rank data_rank = data_pshape.rank(); + if (data_rank.is_static()) + { + NODE_VALIDATION_CHECK(this, + (data_rank.get_length() >= 2), + "data input must have rank greater or equal than 2. Got: ", + data_rank.get_length()); - auto data = input_value(0); - auto block = input_value(1); - auto crops_begin = input_value(2); - auto crops_end = input_value(3); + if (inputs_same_ps.is_static()) + { + NODE_VALIDATION_CHECK(this, + data_rank.get_length() == inputs_same_ps[0].get_length(), + "block_shape and crop inputs must have same number of elements " + "as data input rank. Got: ", + inputs_same_ps[0], + " and ", + data_rank); + } + } - auto block_const = get_constant_from_source(block); - auto crops_begin_const = get_constant_from_source(crops_begin); - auto crops_end_const = get_constant_from_source(crops_end); + const auto block_const = get_constant_from_source(input_value(1)); + const auto crops_begin_const = get_constant_from_source(input_value(2)); + const auto crops_end_const = get_constant_from_source(input_value(3)); if (block_const && crops_begin_const && crops_end_const && data_pshape.is_static()) { - const auto& data_shape = data.get_shape(); - - NODE_VALIDATION_CHECK( - this, - (data_shape.size() >= 2), - "The data tensor with rank lower than 2 is not supported (data rank: ", - data_shape.size(), - ")"); + const Shape& data_sshape = data_pshape.to_shape(); auto block_val = block_const->cast_vector(); auto crops_begin_val = crops_begin_const->cast_vector(); auto crops_end_val = crops_end_const->cast_vector(); - int64_t block_prod = 1; - for (long val : block_val) - { - NODE_VALIDATION_CHECK(this, val > 0, "block_shape values must be greater than 0"); - block_prod *= val; - } + bool block_vals_valid = + std::all_of(begin(block_val), end(block_val), [](int64_t elem) { return elem >= 1; }); + NODE_VALIDATION_CHECK(this, + block_vals_valid, + "Elements of block_shape input must be greater or equal to one."); + + bool crops_begin_vals_valid = std::all_of( + begin(crops_begin_val), end(crops_begin_val), [](int64_t elem) { return elem >= 0; }); + bool crops_end_vals_valid = std::all_of( + begin(crops_end_val), end(crops_end_val), [](int64_t elem) { return elem >= 0; }); + NODE_VALIDATION_CHECK( + this, + crops_begin_vals_valid && crops_end_vals_valid, + "Elements of crops_begin and crops_end inputs must be greater or equal to zero."); + + int64_t block_prod = + std::accumulate(begin(block_val), end(block_val), 1, std::multiplies()); NODE_VALIDATION_CHECK(this, - data_shape.at(0) % block_prod == 0, - "BatchToSpace: The input data's 'batch' axis size: ", - data_shape.at(0), - " must be a multiple of ", + data_sshape[0] % block_prod == 0, + "The input data's 'batch' axis size: ", + data_sshape[0], + " must be a multiple of", " product of block_shape values: ", block_prod); - Shape output_shape = {static_cast(data_shape[0] / block_prod)}; - for (size_t idx = 1; idx < data_shape.size(); ++idx) + for (size_t idx = 0; idx < data_sshape.size(); idx++) + { + const bool is_valid_crops_and_shape = + crops_begin_val[idx] + crops_end_val[idx] <= + block_val[idx] * static_cast(data_sshape[idx]); + NODE_VALIDATION_CHECK(this, + is_valid_crops_and_shape, + "crops_begin[i] + crops_end[i] must be less or equal to " + "block_shape[i] * input_shape[i]"); + } + + Shape output_sshape = {static_cast(data_sshape[0] / block_prod)}; + for (size_t idx = 1; idx < data_sshape.size(); ++idx) { - output_shape.push_back(static_cast(data_shape[idx] * block_val[idx] - - crops_begin_val[idx] - crops_end_val[idx])); + output_sshape.push_back(static_cast(data_sshape[idx] * block_val[idx] - + crops_begin_val[idx] - crops_end_val[idx])); } set_output_size(1); - set_output_type(0, data_type, output_shape); + set_output_type(0, data_et, output_sshape); } else { - set_output_type(0, data_type, PartialShape::dynamic(data_pshape.rank())); + set_output_type(0, data_et, PartialShape::dynamic(data_rank)); } } @@ -144,16 +196,52 @@ namespace return false; } auto data_shape = data->get_shape(); - - if (!(data->get_shape().size() == 4 || data->get_shape().size() == 5)) + auto data_rank = data_shape.size(); + if (data_rank < 2) { return false; } + size_t block_values_size = shape_size(inputs[1]->get_shape()); + size_t crops_begin_size = shape_size(inputs[2]->get_shape()); + size_t crops_end_size = shape_size(inputs[3]->get_shape()); + NGRAPH_CHECK( + block_values_size == data_rank && crops_begin_size == data_rank && + crops_end_size == data_rank, + "Invalid block_shape/crops_begin/crops_end shape with respect to rank of data input"); + const auto* block_values = inputs[1]->get_data_ptr(); const auto* crops_begin_values = inputs[2]->get_data_ptr(); const auto* crops_end_values = inputs[3]->get_data_ptr(); + const bool block_vals_valid = std::all_of( + block_values, block_values + block_values_size, [](int64_t elem) { return elem >= 1; }); + NGRAPH_CHECK(block_vals_valid, "Invalid element values of block_shape input"); + + const bool crops_begin_vals_valid = std::all_of(crops_begin_values, + crops_begin_values + crops_begin_size, + [](int64_t elem) { return elem >= 0; }); + const bool crops_end_vals_valid = std::all_of(crops_end_values, + crops_end_values + crops_end_size, + [](int64_t elem) { return elem >= 0; }); + NGRAPH_CHECK(crops_begin_vals_valid && crops_end_vals_valid, + "Invalid element values of crops_begin/crops_end input/s"); + + const std::size_t block_prod = std::accumulate( + block_values, block_values + block_values_size, 1UL, std::multiplies()); + NGRAPH_CHECK(data_shape[0] % block_prod == 0, + "Invalid batch axis of data input with respect to block_shape values"); + + for (size_t i = 0; i < data_rank; i++) + { + const bool is_valid_crops_and_shape = + crops_begin_values[i] + crops_end_values[i] <= + block_values[i] * static_cast(data_shape[i]); + NGRAPH_CHECK( + is_valid_crops_and_shape, + "Invalid crops values (out of bounds) with respect to the shape of data input"); + } + Shape dispersed_shape(1); dispersed_shape.insert(dispersed_shape.end(), data_shape.begin(), data_shape.end()); std::vector axes_order(block_values_size + 1); @@ -249,14 +337,15 @@ namespace bool ngraph::op::v1::BatchToSpace::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { - NGRAPH_OP_SCOPE(v1_BatchToSpace); + NGRAPH_OP_SCOPE(v1_BatchToSpace_evaluate); + NGRAPH_CHECK(validate_host_tensor_vector(inputs, 4)); + NGRAPH_CHECK(validate_host_tensor_vector(outputs, 1)); return batch_to_space_evaluate(outputs, inputs); } bool ngraph::op::v1::BatchToSpace::has_evaluate() const { NGRAPH_OP_SCOPE(v1_BatchToSpace_has_evaluate); - return !get_input_partial_shape(0).is_dynamic() && - (get_input_shape(0).size() == 4 || get_input_shape(0).size() == 5) && + return !get_input_partial_shape(0).is_dynamic() && get_input_shape(0).size() >= 2 && get_input_shape(0).size() <= shape_size(get_input_shape(1)); } diff --git a/ngraph/core/src/op/cosh.cpp b/ngraph/core/src/op/cosh.cpp index d4f22bc6f46365..3a8d169a67f65a 100644 --- a/ngraph/core/src/op/cosh.cpp +++ b/ngraph/core/src/op/cosh.cpp @@ -5,16 +5,16 @@ #include "itt.hpp" #include "ngraph/op/cosh.hpp" -#include "ngraph/op/multiply.hpp" -#include "ngraph/op/sinh.hpp" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/runtime/reference/cosh.hpp" +#include "ngraph/validation_util.hpp" + using namespace std; using namespace ngraph; -constexpr NodeTypeInfo op::Cosh::type_info; +NGRAPH_RTTI_DEFINITION(op::v0::Cosh, "Cosh", 0, util::UnaryElementwiseArithmetic); op::Cosh::Cosh(const Output& arg) : UnaryElementwiseArithmetic(arg) @@ -68,6 +68,7 @@ namespace coshop bool op::Cosh::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { NGRAPH_OP_SCOPE(v0_Cosh_evaluate); + NGRAPH_CHECK(validate_host_tensor_vector(outputs, 1) && validate_host_tensor_vector(inputs, 1)); return coshop::evaluate_cosh(inputs[0], outputs[0], shape_size(get_output_shape(0))); } diff --git a/ngraph/core/src/op/matrix_nms.cpp b/ngraph/core/src/op/matrix_nms.cpp new file mode 100644 index 00000000000000..7d3731f3b114de --- /dev/null +++ b/ngraph/core/src/op/matrix_nms.cpp @@ -0,0 +1,92 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "ngraph/op/matrix_nms.hpp" +#include +#include +#include "itt.hpp" +#include "ngraph/attribute_visitor.hpp" +#include "ngraph/op/constant.hpp" +#include "ngraph/op/util/op_types.hpp" +#include "ngraph/runtime/reference/matrix_nms.hpp" +#include "ngraph/type/bfloat16.hpp" +#include "ngraph/type/float16.hpp" +#include "ngraph/util.hpp" + +using namespace ngraph; + +NGRAPH_RTTI_DEFINITION(op::v8::MatrixNms, "MatrixNms", 8, op::util::NmsBase); + +op::v8::MatrixNms::MatrixNms() + : NmsBase(m_attrs.output_type, m_attrs.nms_top_k, m_attrs.keep_top_k) +{ +} + +op::v8::MatrixNms::MatrixNms(const Output& boxes, + const Output& scores, + const Attributes& attrs) + : NmsBase(boxes, scores, m_attrs.output_type, m_attrs.nms_top_k, m_attrs.keep_top_k) + , m_attrs{attrs} +{ + constructor_validate_and_infer_types(); +} + +std::shared_ptr op::v8::MatrixNms::clone_with_new_inputs(const OutputVector& new_args) const +{ + NGRAPH_OP_SCOPE(v8_MatrixNms_clone_with_new_inputs); + check_new_args_count(this, new_args); + NODE_VALIDATION_CHECK(this, new_args.size() == 2, "Number of inputs must be 2"); + + return std::make_shared(new_args.at(0), new_args.at(1), m_attrs); +} + +void op::v8::MatrixNms::validate() +{ + NGRAPH_OP_SCOPE(v8_MatrixNms_validate); + NmsBase::validate(); + + NODE_VALIDATION_CHECK(this, + m_attrs.background_class >= -1, + "The 'background_class' must be great or equal -1. Got:", + m_attrs.background_class); +} + +bool ngraph::op::v8::MatrixNms::visit_attributes(AttributeVisitor& visitor) +{ + NGRAPH_OP_SCOPE(v8_MatrixNms_visit_attributes); + + visitor.on_attribute("sort_result_type", m_attrs.sort_result_type); + visitor.on_attribute("output_type", m_attrs.output_type); + visitor.on_attribute("nms_top_k", m_attrs.nms_top_k); + visitor.on_attribute("keep_top_k", m_attrs.keep_top_k); + visitor.on_attribute("sort_result_across_batch", m_attrs.sort_result_across_batch); + visitor.on_attribute("score_threshold", m_attrs.score_threshold); + visitor.on_attribute("background_class", m_attrs.background_class); + visitor.on_attribute("decay_function", m_attrs.decay_function); + visitor.on_attribute("gaussian_sigma", m_attrs.gaussian_sigma); + visitor.on_attribute("post_threshold", m_attrs.post_threshold); + visitor.on_attribute("normalized", m_attrs.normalized); + + return true; +} + +namespace ngraph +{ + template <> + EnumNames& EnumNames::get() + { + static auto enum_names = EnumNames( + "op::v8::MatrixNms::DecayFunction", + {{"gaussian", op::v8::MatrixNms::DecayFunction::GAUSSIAN}, + {"linear", op::v8::MatrixNms::DecayFunction::LINEAR}}); + return enum_names; + } + + constexpr DiscreteTypeInfo AttributeAdapter::type_info; + + std::ostream& operator<<(std::ostream& s, const op::v8::MatrixNms::DecayFunction& type) + { + return s << as_string(type); + } +} // namespace ngraph diff --git a/ngraph/core/src/op/multiclass_nms.cpp b/ngraph/core/src/op/multiclass_nms.cpp new file mode 100644 index 00000000000000..8f0e7cd53457b9 --- /dev/null +++ b/ngraph/core/src/op/multiclass_nms.cpp @@ -0,0 +1,77 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "ngraph/op/multiclass_nms.hpp" +#include +#include +#include "itt.hpp" +#include "ngraph/attribute_visitor.hpp" +#include "ngraph/op/constant.hpp" +#include "ngraph/op/util/op_types.hpp" +#include "ngraph/runtime/reference/multiclass_nms.hpp" +#include "ngraph/type/bfloat16.hpp" +#include "ngraph/type/float16.hpp" +#include "ngraph/util.hpp" + +using namespace ngraph; + +NGRAPH_RTTI_DEFINITION(op::v8::MulticlassNms, "MulticlassNms", 8, op::util::NmsBase); + +op::v8::MulticlassNms::MulticlassNms() + : NmsBase(m_attrs.output_type, m_attrs.nms_top_k, m_attrs.keep_top_k) +{ +} + +op::v8::MulticlassNms::MulticlassNms(const Output& boxes, + const Output& scores, + const Attributes& attrs) + : NmsBase(boxes, scores, m_attrs.output_type, m_attrs.nms_top_k, m_attrs.keep_top_k) + , m_attrs{attrs} +{ + constructor_validate_and_infer_types(); +} + +std::shared_ptr + op::v8::MulticlassNms::clone_with_new_inputs(const OutputVector& new_args) const +{ + NGRAPH_OP_SCOPE(v8_MulticlassNms_clone_with_new_inputs); + check_new_args_count(this, new_args); + NODE_VALIDATION_CHECK(this, new_args.size() == 2, "Number of inputs must be 2"); + + return std::make_shared(new_args.at(0), new_args.at(1), m_attrs); +} + +void op::v8::MulticlassNms::validate() +{ + NGRAPH_OP_SCOPE(v8_MulticlassNms_validate); + NmsBase::validate(); + + NODE_VALIDATION_CHECK(this, + m_attrs.background_class >= -1, + "The 'background_class' must be great or equal -1. Got:", + m_attrs.background_class); + + NODE_VALIDATION_CHECK(this, + m_attrs.nms_eta >= 0.0f && m_attrs.nms_eta <= 1.0f, + "The 'nms_eta' must be in close range [0, 1.0]. Got:", + m_attrs.nms_eta); +} + +bool ngraph::op::v8::MulticlassNms::visit_attributes(AttributeVisitor& visitor) +{ + NGRAPH_OP_SCOPE(v8_MulticlassNms_visit_attributes); + + visitor.on_attribute("sort_result_type", m_attrs.sort_result_type); + visitor.on_attribute("output_type", m_attrs.output_type); + visitor.on_attribute("nms_top_k", m_attrs.nms_top_k); + visitor.on_attribute("keep_top_k", m_attrs.keep_top_k); + visitor.on_attribute("sort_result_across_batch", m_attrs.sort_result_across_batch); + visitor.on_attribute("iou_threshold", m_attrs.iou_threshold); + visitor.on_attribute("score_threshold", m_attrs.score_threshold); + visitor.on_attribute("background_class", m_attrs.background_class); + visitor.on_attribute("nms_eta", m_attrs.nms_eta); + visitor.on_attribute("normalized", m_attrs.normalized); + + return true; +} diff --git a/ngraph/core/src/op/prior_box.cpp b/ngraph/core/src/op/prior_box.cpp index 3af4618296fae8..1b27ae401e4fb0 100644 --- a/ngraph/core/src/op/prior_box.cpp +++ b/ngraph/core/src/op/prior_box.cpp @@ -14,7 +14,7 @@ using namespace std; using namespace ngraph; -NGRAPH_RTTI_DEFINITION(op::PriorBox, "PriorBox", 0); +NGRAPH_RTTI_DEFINITION(op::v0::PriorBox, "PriorBox", 0); op::PriorBox::PriorBox(const Output& layer_shape, const Output& image_shape, @@ -69,7 +69,7 @@ void op::PriorBox::validate_and_infer_types() } else { - set_output_type(0, element::f32, PartialShape::dynamic()); + set_output_type(0, element::f32, PartialShape{2, Dimension::dynamic()}); } } diff --git a/ngraph/core/src/op/shape_of.cpp b/ngraph/core/src/op/shape_of.cpp index d929eb0c1c068f..792bad19bae59c 100644 --- a/ngraph/core/src/op/shape_of.cpp +++ b/ngraph/core/src/op/shape_of.cpp @@ -51,7 +51,6 @@ shared_ptr op::v3::ShapeOf::clone_with_new_inputs(const OutputVector& new_ NGRAPH_OP_SCOPE(v3_ShapeOf_clone_with_new_inputs); check_new_args_count(this, new_args); auto new_shape_of = make_shared(new_args.at(0), m_output_type); - new_shape_of->set_is_foldable(m_is_foldable); return new_shape_of; } @@ -82,8 +81,7 @@ namespace shape_of bool constant_fold_shape_of(Node* shape_of_node, Output& replacement, - const Output& shape_of_input, - bool is_foldable) + const Output& shape_of_input) { auto partial_shape = shape_of_input.get_partial_shape(); auto output_type = shape_of_node->get_output_element_type(0); @@ -100,46 +98,6 @@ namespace shape_of } return false; } - else if (partial_shape.rank().is_static() && is_foldable) - { - auto shape_of = shape_of_node->copy_with_new_inputs({shape_of_input}); - // Ugly - if (auto ps = as_type_ptr(shape_of)) - { - ps->set_is_foldable(false); - } - else if (auto ps = as_type_ptr(shape_of)) - { - ps->set_is_foldable(false); - } - auto dimensions = OutputVector{}; - auto output_dimensions = vector(partial_shape); - for (size_t i = 0; i < output_dimensions.size(); ++i) - { - if (output_dimensions[i].is_static()) - { - auto temp = std::make_shared( - output_type, - Shape{1}, - std::vector{output_dimensions[i].get_length()}); - temp->set_friendly_name("ConstDim/" + temp->get_name()); - dimensions.emplace_back(temp); - } - else - { - auto index = std::make_shared( - output_type, Shape{1}, std::vector{static_cast(i)}); - auto axis = std::make_shared( - element::i64, Shape{}, std::vector{0}); - auto temp = make_shared(shape_of, index, axis); - temp->set_friendly_name("DynDim/" + temp->get_name()); - dimensions.emplace_back(temp); - } - } - - replacement = std::make_shared(dimensions, 0); - return true; - } return false; } @@ -250,7 +208,7 @@ bool op::v3::ShapeOf::constant_fold(OutputVector& output_values, const OutputVec OV_ITT_SCOPED_TASK(itt::domains::nGraph, "op::v3::ShapeOf::constant_fold"); if (get_rt_info().count("DISABLED_CONSTANT_FOLDING")) return false; - return shape_of::constant_fold_shape_of(this, output_values[0], input_values[0], m_is_foldable); + return shape_of::constant_fold_shape_of(this, output_values[0], input_values[0]); } // op::v0::ShapeOf @@ -286,7 +244,6 @@ shared_ptr op::v0::ShapeOf::clone_with_new_inputs(const OutputVector& new_ description(), " operation with name ", get_friendly_name()); - new_shape_of->set_is_foldable(m_is_foldable); return new_shape_of; } @@ -318,7 +275,7 @@ bool op::v0::ShapeOf::constant_fold(OutputVector& output_values, const OutputVec OV_ITT_SCOPED_TASK(itt::domains::nGraph, "op::v0::ShapeOf::constant_fold"); if (get_rt_info().count("DISABLED_CONSTANT_FOLDING")) return false; - return shape_of::constant_fold_shape_of(this, output_values[0], input_values[0], m_is_foldable); + return shape_of::constant_fold_shape_of(this, output_values[0], input_values[0]); } bool op::v0::ShapeOf::evaluate_lower(const HostTensorVector& output_values) const diff --git a/ngraph/core/src/op/sinh.cpp b/ngraph/core/src/op/sinh.cpp index d19d6cbe4938f1..4cbe5bd13ab266 100644 --- a/ngraph/core/src/op/sinh.cpp +++ b/ngraph/core/src/op/sinh.cpp @@ -2,19 +2,16 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "itt.hpp" - -#include "ngraph/op/cosh.hpp" -#include "ngraph/op/multiply.hpp" #include "ngraph/op/sinh.hpp" - -#include "ngraph/runtime/host_tensor.hpp" +#include #include "ngraph/runtime/reference/sinh.hpp" +#include "itt.hpp" + using namespace std; using namespace ngraph; -constexpr NodeTypeInfo op::Sinh::type_info; +NGRAPH_RTTI_DEFINITION(op::v0::Sinh, "Sinh", 0, util::UnaryElementwiseArithmetic); op::Sinh::Sinh(const Output& arg) : UnaryElementwiseArithmetic(arg) @@ -68,6 +65,7 @@ namespace sinhop bool op::Sinh::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { NGRAPH_OP_SCOPE(v0_Sinh_evaluate); + NGRAPH_CHECK(validate_host_tensor_vector(outputs, 1) && validate_host_tensor_vector(inputs, 1)); return sinhop::evaluate_sinh(inputs[0], outputs[0], shape_size(get_output_shape(0))); } diff --git a/ngraph/core/src/op/util/nms_base.cpp b/ngraph/core/src/op/util/nms_base.cpp new file mode 100644 index 00000000000000..4fce4c46fc49f9 --- /dev/null +++ b/ngraph/core/src/op/util/nms_base.cpp @@ -0,0 +1,183 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "ngraph/op/util/nms_base.hpp" +#include +#include +#include "itt.hpp" +#include "ngraph/attribute_visitor.hpp" +#include "ngraph/op/constant.hpp" +#include "ngraph/op/util/op_types.hpp" +#include "ngraph/type/bfloat16.hpp" +#include "ngraph/type/float16.hpp" +#include "ngraph/util.hpp" + +using namespace ngraph; + +NGRAPH_RTTI_DEFINITION(op::util::NmsBase, "NmsBase", 0); + +op::util::NmsBase::NmsBase(ngraph::element::Type& output_type, int& nms_top_k, int& keep_top_k) + : m_output_type(output_type) + , m_nms_top_k(nms_top_k) + , m_keep_top_k(keep_top_k) +{ +} + +op::util::NmsBase::NmsBase(const Output& boxes, + const Output& scores, + ngraph::element::Type& output_type, + int& nms_top_k, + int& keep_top_k) + : Op({boxes, scores}) + , m_output_type(output_type) + , m_nms_top_k(nms_top_k) + , m_keep_top_k(keep_top_k) +{ +} + +namespace +{ + inline bool is_float_type_admissible(const element::Type& t) + { + return t == element::f32 || t == element::f16 || t == element::bf16; + } +} // namespace + +void op::util::NmsBase::validate() +{ + NGRAPH_OP_SCOPE(util_NmsBase_validate); + + const auto boxes_ps = get_input_partial_shape(0); + const auto scores_ps = get_input_partial_shape(1); + + NODE_VALIDATION_CHECK(this, + m_output_type == element::i64 || m_output_type == element::i32, + "Output type must be i32 or i64"); + + if (boxes_ps.is_dynamic() || scores_ps.is_dynamic()) + { + return; + } + + NODE_VALIDATION_CHECK(this, + is_float_type_admissible(get_input_element_type(0)), + "Expected bf16, fp16 or fp32 as element type for the 'boxes' input."); + + NODE_VALIDATION_CHECK(this, + is_float_type_admissible(get_input_element_type(1)), + "Expected bf16, fp16 or fp32 as element type for the 'scores' input."); + + NODE_VALIDATION_CHECK(this, + boxes_ps.rank().is_static() && boxes_ps.rank().get_length() == 3, + "Expected a 3D tensor for the 'boxes' input. Got: ", + boxes_ps); + + NODE_VALIDATION_CHECK(this, + boxes_ps[2].is_static() && boxes_ps[2].get_length() == 4, + "The third dimension of the 'boxes' must be 4. Got: ", + boxes_ps[2]); + + NODE_VALIDATION_CHECK(this, + scores_ps.rank().is_static() && scores_ps.rank().get_length() == 3, + "Expected a 3D tensor for the 'scores' input. Got: ", + scores_ps); + + NODE_VALIDATION_CHECK( + this, m_nms_top_k >= -1, "The 'nms_top_k' must be great or equal -1. Got:", m_nms_top_k); + + NODE_VALIDATION_CHECK( + this, m_keep_top_k >= -1, "The 'keep_top_k' must be great or equal -1. Got:", m_keep_top_k); + + const auto num_batches_boxes = boxes_ps[0]; + const auto num_batches_scores = scores_ps[0]; + + NODE_VALIDATION_CHECK(this, + num_batches_boxes.same_scheme(num_batches_scores), + "The first dimension of both 'boxes' and 'scores' must match. Boxes: ", + num_batches_boxes, + "; Scores: ", + num_batches_scores); + + const auto num_boxes_boxes = boxes_ps[1]; + const auto num_boxes_scores = scores_ps[2]; + NODE_VALIDATION_CHECK(this, + num_boxes_boxes.same_scheme(num_boxes_scores), + "'boxes' and 'scores' input shapes must match at the second and third " + "dimension respectively. Boxes: ", + num_boxes_boxes, + "; Scores: ", + num_boxes_scores); +} + +void op::util::NmsBase::validate_and_infer_types() +{ + NGRAPH_OP_SCOPE(util_NmsBase_validate_and_infer_types); + const auto boxes_ps = get_input_partial_shape(0); + const auto scores_ps = get_input_partial_shape(1); + + auto first_dim_shape = Dimension::dynamic(); + + validate(); + + if (boxes_ps.rank().is_static() && scores_ps.rank().is_static()) + { + const auto num_boxes_boxes = boxes_ps[1]; + if (num_boxes_boxes.is_static() && scores_ps[0].is_static() && scores_ps[1].is_static()) + { + const auto num_boxes = num_boxes_boxes.get_length(); + const auto num_classes = scores_ps[1].get_length(); + int64_t max_output_boxes_per_class = 0; + if (m_nms_top_k >= 0) + max_output_boxes_per_class = std::min(num_boxes, (int64_t)m_nms_top_k); + else + max_output_boxes_per_class = num_boxes; + + auto max_output_boxes_per_batch = max_output_boxes_per_class * num_classes; + if (m_keep_top_k >= 0) + max_output_boxes_per_batch = + std::min(max_output_boxes_per_batch, (int64_t)m_keep_top_k); + + first_dim_shape = Dimension(0, max_output_boxes_per_batch * scores_ps[0].get_length()); + } + } + + // 'selected_outputs' have the following format: + // [number of selected boxes, [class_id, box_score, xmin, ymin, xmax, ymax]] + set_output_type(0, element::f32, {first_dim_shape, 6}); + // 'selected_indices' have the following format: + // [number of selected boxes, ] + set_output_type(1, m_output_type, {first_dim_shape, 1}); + // 'selected_num' have the following format: + // [num_batches, ] + if (boxes_ps.rank().is_static() && boxes_ps.rank().get_length() > 0) + { + set_output_type(2, m_output_type, {boxes_ps[0]}); + } + else + { + set_output_type(2, m_output_type, {Dimension::dynamic()}); + } +} + +namespace ngraph +{ + template <> + EnumNames& + EnumNames::get() + { + static auto enum_names = EnumNames( + "op::util::NmsBase::SortResultType", + {{"classid", op::util::NmsBase::SortResultType::CLASSID}, + {"score", op::util::NmsBase::SortResultType::SCORE}, + {"none", op::util::NmsBase::SortResultType::NONE}}); + return enum_names; + } + + constexpr DiscreteTypeInfo AttributeAdapter::type_info; + + std::ostream& operator<<(std::ostream& s, const op::util::NmsBase::SortResultType& type) + { + return s << as_string(type); + } +} // namespace ngraph diff --git a/ngraph/core/src/op/util/scatter_nd_base.cpp b/ngraph/core/src/op/util/scatter_nd_base.cpp index c8a1d13931c843..9040645cdd21f1 100644 --- a/ngraph/core/src/op/util/scatter_nd_base.cpp +++ b/ngraph/core/src/op/util/scatter_nd_base.cpp @@ -57,11 +57,13 @@ void op::util::ScatterNDBase::validate_and_infer_types() NODE_VALIDATION_CHECK(this, inputs_rank.is_dynamic() || indices_rank.is_dynamic() || + indices_shape[indices_rank.get_length() - 1].is_dynamic() || indices_shape[indices_rank.get_length() - 1].get_length() <= inputs_rank.get_length(), "Last dimension of indices can be at most the rank of inputs"); - if (inputs_rank.is_static() && indices_rank.is_static() && updates_rank.is_static()) + if (inputs_rank.is_static() && indices_rank.is_static() && updates_rank.is_static() && + indices_shape[indices_rank.get_length() - 1].is_static()) { auto expected_updates_rank = indices_rank.get_length() + inputs_rank.get_length() - indices_shape[indices_rank.get_length() - 1].get_length() - 1; diff --git a/ngraph/core/src/opsets/opset.cpp b/ngraph/core/src/opsets/opset.cpp index ea09eec98c1487..c3b791995e31bb 100644 --- a/ngraph/core/src/opsets/opset.cpp +++ b/ngraph/core/src/opsets/opset.cpp @@ -115,3 +115,15 @@ const ngraph::OpSet& ngraph::get_opset7() }); return opset; } + +const ngraph::OpSet& ngraph::get_opset8() +{ + static OpSet opset; + static std::once_flag flag; + std::call_once(flag, [&]() { +#define NGRAPH_OP(NAME, NAMESPACE) opset.insert(); +#include "ngraph/opsets/opset8_tbl.hpp" +#undef NGRAPH_OP + }); + return opset; +} diff --git a/ngraph/core/src/pass/visualize_tree.cpp b/ngraph/core/src/pass/visualize_tree.cpp index dfed1d05640c30..b963c9fee98d48 100644 --- a/ngraph/core/src/pass/visualize_tree.cpp +++ b/ngraph/core/src/pass/visualize_tree.cpp @@ -16,6 +16,7 @@ #include "ngraph/pass/pass.hpp" #include "ngraph/pass/visualize_tree.hpp" #include "ngraph/util.hpp" +#include "ngraph/variant.hpp" using namespace ngraph; using namespace std; @@ -167,6 +168,24 @@ static std::string label_edge(const std::shared_ptr& /* src */, return ss.str(); } +static std::string + get_attribute_values(const std::map>& attributes, + const std::string& delimiter = ", ") +{ + stringstream ss; + bool first = true; + for (const auto& item : attributes) + { + ss << (first ? " " : delimiter) << item.first; + const auto attributeValue = item.second == nullptr ? "[EMPTY]" : item.second->to_string(); + if (!attributeValue.empty()) + ss << "{" << attributeValue << "}"; + + first = false; + } + return ss.str(); +} + NGRAPH_RTTI_DEFINITION(ngraph::pass::VisualizeTree, "ngraph::pass::VisualizeTree", 0); bool pass::VisualizeTree::run_on_function(std::shared_ptr f) @@ -481,6 +500,7 @@ string pass::VisualizeTree::get_attributes(shared_ptr node) static const bool nvtos = getenv_bool("NGRAPH_VISUALIZE_TREE_OUTPUT_SHAPES"); static const bool nvtot = getenv_bool("NGRAPH_VISUALIZE_TREE_OUTPUT_TYPES"); static const bool nvtio = getenv_bool("NGRAPH_VISUALIZE_TREE_IO"); + static const bool nvtrti = getenv_bool("NGRAPH_VISUALIZE_TREE_RUNTIME_INFO"); if (nvtos || nvtot || nvtio) { @@ -495,6 +515,11 @@ string pass::VisualizeTree::get_attributes(shared_ptr node) label << pretty_partial_shape(input.get_partial_shape()); label << ": " << node->get_input_node_ptr(input.get_index())->get_name() << ": out" << input.get_source_output().get_index(); + + if (nvtrti) + { + label << get_attribute_values(input.get_rt_info()); + } } } for (const auto& output : node->outputs()) @@ -505,6 +530,11 @@ string pass::VisualizeTree::get_attributes(shared_ptr node) label << "{" << output.get_element_type().get_type_name() << "}"; if (nvtos) label << pretty_partial_shape(output.get_partial_shape()); + + if (nvtrti) + { + label << get_attribute_values(output.get_rt_info()); + } } } @@ -544,11 +574,7 @@ string pass::VisualizeTree::get_node_name(shared_ptr node) const auto rt = node->get_rt_info(); if (!rt.empty()) { - rc += "\\nrt info: "; - for (const auto& item : rt) - { - rc += item.first + " "; - } + rc += "\\nrt info: " + get_attribute_values(rt, "\\n"); } } return rc; diff --git a/ngraph/frontend/CMakeLists.txt b/ngraph/frontend/CMakeLists.txt index 3f37edd60b4e02..b4afff783dbb94 100644 --- a/ngraph/frontend/CMakeLists.txt +++ b/ngraph/frontend/CMakeLists.txt @@ -3,9 +3,6 @@ # if(NOT WIN32) - message(${CMAKE_CURRENT_SOURCE_DIR}/cmake_static_protobuf) - message(BINARY ${CMAKE_CURRENT_BINARY_DIR}) - # There seems no suitable other way to identify exact output binary name for libprotobuf if(CMAKE_BUILD_TYPE STREQUAL "Debug") # Use 'protobufd' directly as it is done in the same way in protobuf cmake files @@ -15,13 +12,11 @@ if(NOT WIN32) set(PROTOBUF_STATIC_LIB_OUTPUT ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${CMAKE_STATIC_LIBRARY_PREFIX}protobuf${CMAKE_STATIC_LIBRARY_SUFFIX}) endif() - message("Static protobuf lib: ${PROTOBUF_STATIC_LIB_OUTPUT}") - file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/libprotobuf_static) add_custom_command( OUTPUT ${PROTOBUF_STATIC_LIB_OUTPUT} - COMMAND ${CMAKE_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/cmake_static_protobuf + COMMAND ${CMAKE_COMMAND} ${CMAKE_SOURCE_DIR}/thirdparty/cmake_static_protobuf -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} -DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=${CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY} diff --git a/ngraph/frontend/onnx_common/include/onnx_common/utils.hpp b/ngraph/frontend/onnx_common/include/onnx_common/utils.hpp index 499875cc26b685..c16d11f2a65339 100644 --- a/ngraph/frontend/onnx_common/include/onnx_common/utils.hpp +++ b/ngraph/frontend/onnx_common/include/onnx_common/utils.hpp @@ -5,7 +5,7 @@ namespace ONNX_NAMESPACE { - enum TensorProto_DataType; + enum TensorProto_DataType : int; } namespace ngraph diff --git a/ngraph/frontend/onnx_import/CMakeLists.txt b/ngraph/frontend/onnx_import/CMakeLists.txt index 0ddb78ad071510..bb6a4e7ff99580 100644 --- a/ngraph/frontend/onnx_import/CMakeLists.txt +++ b/ngraph/frontend/onnx_import/CMakeLists.txt @@ -45,7 +45,7 @@ if(COMMAND ie_faster_build) ) endif() -target_link_libraries(onnx_importer PRIVATE onnx_common ngraph::builder +target_link_libraries(onnx_importer PRIVATE onnx_common ngraph::builder inference_engine_transformations PUBLIC ngraph) target_include_directories(onnx_importer PUBLIC $ diff --git a/ngraph/frontend/onnx_import/include/onnx_import/core/node.hpp b/ngraph/frontend/onnx_import/include/onnx_import/core/node.hpp index c2a3e6b820cdbc..cb5d11fde31e5c 100644 --- a/ngraph/frontend/onnx_import/include/onnx_import/core/node.hpp +++ b/ngraph/frontend/onnx_import/include/onnx_import/core/node.hpp @@ -75,9 +75,8 @@ namespace ngraph bool has_attribute(const std::string& name) const; - Subgraph get_subgraph_from_attribute( - const std::string& name, - const std::map& carried_dependencies_map) const; + bool has_subgraph() const; + std::shared_ptr get_subgraph() const; template T get_attribute_value(const std::string& name, T default_value) const; diff --git a/ngraph/frontend/onnx_import/include/onnx_import/onnx_framework_node.hpp b/ngraph/frontend/onnx_import/include/onnx_import/onnx_framework_node.hpp new file mode 100644 index 00000000000000..bfa902a5ac449c --- /dev/null +++ b/ngraph/frontend/onnx_import/include/onnx_import/onnx_framework_node.hpp @@ -0,0 +1,100 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#pragma once + +#include +#include +#include +#include + +namespace ONNX_NAMESPACE +{ + // forward declaration + class ModelProto; +} // namespace ONNX_NAMESPACE + +namespace ngraph +{ + namespace onnx_import + { + class Model; + } + + namespace frontend + { + class ONNXFrameworkNode : public op::FrameworkNode + { + public: + NGRAPH_RTTI_DECLARATION; + + ONNXFrameworkNode(const onnx_import::Node& node) + : FrameworkNode(node.get_ng_inputs(), node.get_outputs_size()) + , m_node(node) + { + } + + ONNXFrameworkNode(const onnx_import::Node& node, const OutputVector& inputs) + : FrameworkNode(inputs, node.get_outputs_size()) + , m_node(node) + { + } + + const onnx_import::Node& get_onnx_node() const { return m_node; } + + virtual std::shared_ptr + clone_with_new_inputs(const OutputVector& inputs) const override; + + virtual bool visit_attributes(AttributeVisitor& visitor) override + { + // TODO: implement reading as well, now it work for serialization only + std::string domain = m_node.domain(); + std::string op_type = m_node.op_type(); + visitor.on_attribute("ONNX_META_domain", domain); + visitor.on_attribute("ONNX_META_type", op_type); + return true; + } + + private: + onnx_import::Node m_node; + }; + + class ONNXSubgraphFrameworkNode : public ONNXFrameworkNode + { + public: + NGRAPH_RTTI_DECLARATION; + + ONNXSubgraphFrameworkNode(const onnx_import::Node& node, const OutputVector& inputs) + : ONNXFrameworkNode(node, inputs) + { + } + + void infer_inputs_from_parent() + { + get_onnx_node().get_subgraph()->infer_inputs_from_parent(); + } + + std::shared_ptr get_subgraph_body() const + { + auto subgraph = get_onnx_node().get_subgraph(); + return std::make_shared(subgraph->get_ng_outputs(), + subgraph->get_ng_parameters(), + subgraph->get_name()); + } + }; + + } // namespace frontend +} // namespace ngraph diff --git a/ngraph/frontend/onnx_import/src/core/attribute.cpp b/ngraph/frontend/onnx_import/src/core/attribute.cpp index 8eaa8c93517d8e..1fd61931de9629 100644 --- a/ngraph/frontend/onnx_import/src/core/attribute.cpp +++ b/ngraph/frontend/onnx_import/src/core/attribute.cpp @@ -11,9 +11,7 @@ namespace ngraph { namespace onnx_import { - Subgraph Attribute::get_subgraph( - const Graph& parent_graph, - const std::map& carried_dependencies_map) const + Subgraph Attribute::get_subgraph(const Graph& parent_graph) const { if (m_attribute_proto->type() != ONNX_NAMESPACE::AttributeProto_AttributeType_GRAPH) { @@ -25,33 +23,6 @@ namespace ngraph const auto& graph = m_attribute_proto->g(); model_proto->mutable_graph()->CopyFrom(graph); - const std::size_t subgraph_inputs_count = - static_cast(model_proto->mutable_graph()->mutable_input()->size()); - // Use the `carried_dependencies_map` to infer the types for the subgraph inputs - for (const auto& carried_dependency : carried_dependencies_map) - { - if (carried_dependency.first >= subgraph_inputs_count) - { - NGRAPH_WARN << "Input with index: '" << carried_dependency.first - << "' was not found in the subgraph"; - } - else - { - const auto& parent_in = - parent_graph.get_ng_node_from_cache(carried_dependency.second); - const auto& carried_type = parent_in.get_element_type(); - auto subgraph_in = - model_proto->mutable_graph()->mutable_input(carried_dependency.first); - auto subgraph_in_tensor_type = - subgraph_in->mutable_type()->mutable_tensor_type(); - if (!subgraph_in_tensor_type->has_elem_type()) - { - subgraph_in_tensor_type->set_elem_type( - onnx_common::ng_to_onnx_data_type(carried_type)); - } - } - } - // set opset version and domain from the parent graph model_proto->mutable_opset_import()->CopyFrom(parent_graph.get_opset_imports()); auto model = common::make_unique(std::move(model_proto)); diff --git a/ngraph/frontend/onnx_import/src/core/attribute.hpp b/ngraph/frontend/onnx_import/src/core/attribute.hpp index bc192e7b392fcb..963dab22cb53de 100644 --- a/ngraph/frontend/onnx_import/src/core/attribute.hpp +++ b/ngraph/frontend/onnx_import/src/core/attribute.hpp @@ -316,9 +316,7 @@ namespace ngraph float get_float() const { return m_attribute_proto->f(); } int64_t get_integer() const { return m_attribute_proto->i(); } const std::string& get_string() const { return m_attribute_proto->s(); } - Subgraph get_subgraph( - const Graph& parent_graph, - const std::map& carried_dependencies_map) const; + Subgraph get_subgraph(const Graph& parent_graph) const; std::vector get_tensor_array() const { diff --git a/ngraph/frontend/onnx_import/src/core/graph.cpp b/ngraph/frontend/onnx_import/src/core/graph.cpp index c8f56327d6bb22..569d3849774859 100644 --- a/ngraph/frontend/onnx_import/src/core/graph.cpp +++ b/ngraph/frontend/onnx_import/src/core/graph.cpp @@ -14,6 +14,7 @@ #include "ngraph/node.hpp" #include "ngraph/provenance.hpp" #include "onnx_import/core/node.hpp" +#include "onnx_import/onnx_framework_node.hpp" #include "utils/common.hpp" #include "utils/provenance_tag.hpp" @@ -55,25 +56,6 @@ namespace ngraph Graph::Graph(std::unique_ptr&& model) : Graph(std::move(model), common::make_unique()) { - // Remove dangling Parameters - for (auto param_it = m_parameters.begin(); param_it != m_parameters.end();) - { - if ((*param_it)->get_output_target_inputs(0).size() == 0) - { - const auto& name = (*param_it)->get_friendly_name(); - auto out_it = std::find_if( - m_outputs.begin(), m_outputs.end(), [&name](const ValueInfo& info) { - return info.get_name() == name; - }); - if (out_it == m_outputs.end()) - { - m_cache->remove_node(name); - param_it = m_parameters.erase(param_it); - continue; - } - } - param_it++; - } } Graph::Graph(std::unique_ptr&& model, std::unique_ptr&& cache) @@ -174,14 +156,82 @@ namespace ngraph NGRAPH_CHECK(unknown_operators.empty(), "nGraph does not support the following ONNX operations: ", detail::to_string(unknown_operators)); + } + void Graph::convert_to_ngraph_nodes() + { // Process ONNX graph nodes, convert to nGraph nodes for (const auto& node_proto : m_model->get_graph().node()) { m_nodes.emplace_back(node_proto, *this); const Node& node{m_nodes.back()}; - + if (node.has_subgraph()) + { + auto subgraph = node.get_subgraph(); + auto body_func = subgraph->convert(); + } OutputVector ng_nodes{node.get_ng_nodes()}; + set_friendly_names(node, ng_nodes); + for (std::size_t i{0}; i < node.get_outputs_size(); ++i) + { + m_cache->emplace_node(node.output(i), std::move(ng_nodes.at(i))); + } + } + } + + void Graph::remove_dangling_parameters() + { + for (auto param_it = m_parameters.begin(); param_it != m_parameters.end();) + { + if ((*param_it)->get_output_target_inputs(0).size() == 0) + { + const auto& name = (*param_it)->get_friendly_name(); + auto out_it = std::find_if( + m_outputs.begin(), m_outputs.end(), [&name](const ValueInfo& info) { + return info.get_name() == name; + }); + if (out_it == m_outputs.end()) + { + m_cache->remove_node(name); + param_it = m_parameters.erase(param_it); + continue; + } + } + param_it++; + } + } + + std::shared_ptr Graph::convert() + { + convert_to_ngraph_nodes(); + remove_dangling_parameters(); + return create_function(); + } + + void Graph::decode_to_framework_nodes() + { + // Process ONNX graph nodes, convert to nGraph nodes + for (const auto& node_proto : m_model->get_graph().node()) + { + m_nodes.emplace_back(node_proto, *this); + const Node& node{m_nodes.back()}; + std::shared_ptr framework_node; + if (node.has_subgraph()) + { + auto subgraph = node.get_subgraph(); + auto body_func = subgraph->decode(); + auto inputs = node.get_ng_inputs(); + for (const auto& input : subgraph->get_inputs_from_parent()) + inputs.push_back(input); + framework_node = + std::make_shared(node, inputs); + } + else + { + framework_node = std::make_shared(node); + } + OutputVector ng_nodes{framework_node->outputs()}; + set_friendly_names(node, ng_nodes); // Iterate over the number of outputs for given node in graph. // Some of them may be optional and trimmed. See: // https://github.com/onnx/onnx/blob/master/docs/IR.md#optional-inputs-and-outputs @@ -192,12 +242,24 @@ namespace ngraph } } - const GraphCache& Graph::get_graph_cache() const { return *m_cache.get(); } - bool Graph::is_node_in_cache(const std::string& name) const + std::shared_ptr Graph::create_function() + { + auto function = std::make_shared(get_ng_outputs(), m_parameters, get_name()); + for (std::size_t i{0}; i < function->get_output_size(); ++i) + { + function->get_output_op(i)->set_friendly_name(m_outputs.at(i).get_name()); + } + return function; + } + + std::shared_ptr Graph::decode() { - return m_cache->contains(name); + decode_to_framework_nodes(); + return create_function(); } + const GraphCache& Graph::get_graph_cache() const { return *m_cache.get(); } + Output Graph::get_ng_node_from_cache(const std::string& name) const { return m_cache->get_node(name); @@ -247,6 +309,12 @@ namespace ngraph set_friendly_names(onnx_node, ng_node_vector); add_provenance_tags(onnx_node, ng_node_vector); + for (std::size_t i{0}; i < onnx_node.get_outputs_size(); ++i) + { + auto ng_node = ng_node_vector.at(i); + m_cache->emplace_node(onnx_node.output(i), std::move(ng_node)); + } + return ng_node_vector; } @@ -323,9 +391,21 @@ namespace ngraph } Subgraph::Subgraph(std::unique_ptr&& model, const Graph& parent_graph) - : Graph( - std::move(model), - std::unique_ptr(new SubgraphCache(parent_graph.get_graph_cache()))) + : Graph(std::move(model), common::make_unique()) + , m_parent_graph_cache(&parent_graph.get_graph_cache()) + { + } + + Output Subgraph::get_ng_node_from_cache(const std::string& name) const + { + if (m_cache->contains(name)) + { + return m_cache->get_node(name); + } + return m_parent_graph_cache->get_node(name); + } + + void Subgraph::find_inputs_from_parent() { // find all nodes on edge parent graph-subgraph // (it means input of node from parent graph, output from subgraph) @@ -334,16 +414,16 @@ namespace ngraph int input_index = 0; for (const auto& in_name : node_proto.input()) { - if (m_cache->node_scope(in_name) == NodeScope::ParentGraph) + if (m_parent_graph_cache->contains(in_name)) { - const auto& from_parent_node = m_cache->get_node(in_name); + const auto& from_parent_node = m_parent_graph_cache->get_node(in_name); // constants are skipped if (!ngraph::is_type( from_parent_node.get_node_shared_ptr())) { for (const auto& out_name : node_proto.output()) { - if (m_cache->node_scope(out_name) == NodeScope::SubGraph) + if (m_cache->contains(out_name)) { auto out_node_to_replace_input = m_cache->get_node(out_name); auto new_param = std::make_shared( @@ -353,8 +433,10 @@ namespace ngraph out_node_to_replace_input.get_node() ->input(input_index) .replace_source_output(new_param); + m_parameter_to_parent_node_map.insert({new_param, in_name}); + m_cache->emplace_node(in_name, new_param); m_parameters.push_back(new_param); - m_outputs_from_parent.push_back(from_parent_node); + m_inputs_from_parent.push_back(in_name); } } } @@ -364,11 +446,39 @@ namespace ngraph } } - const std::vector> Subgraph::get_outputs_from_parent() const + std::shared_ptr Subgraph::convert() { - return m_outputs_from_parent; + convert_to_ngraph_nodes(); + find_inputs_from_parent(); + return create_function(); } + void Subgraph::decode_to_framework_nodes() + { + Graph::decode_to_framework_nodes(); + find_inputs_from_parent(); + } + + const std::vector> Subgraph::get_inputs_from_parent() const + { + OutputVector result; + for (const auto& name : m_inputs_from_parent) + { + result.push_back(m_parent_graph_cache->get_node(name)); + } + return result; + } + + void Subgraph::infer_inputs_from_parent() + { + for (auto& it : m_parameter_to_parent_node_map) + { + const auto& node = m_parent_graph_cache->get_node(it.second); + auto& parameter = it.first; + parameter->set_element_type(node.get_element_type()); + parameter->set_partial_shape(node.get_partial_shape()); + } + } } // namespace onnx_import } // namespace ngraph diff --git a/ngraph/frontend/onnx_import/src/core/graph.hpp b/ngraph/frontend/onnx_import/src/core/graph.hpp index 6cbd880410984c..33c2be5d4d20e8 100644 --- a/ngraph/frontend/onnx_import/src/core/graph.hpp +++ b/ngraph/frontend/onnx_import/src/core/graph.hpp @@ -31,13 +31,14 @@ namespace ngraph Graph& operator=(const Graph&) = delete; Graph& operator=(Graph&&) = default; + virtual std::shared_ptr convert(); + std::shared_ptr decode(); const std::vector& get_nodes() const { return m_nodes; } const std::vector& get_inputs() const { return m_inputs; } const std::vector& get_outputs() const { return m_outputs; } OutputVector get_ng_outputs() const; const ParameterVector& get_ng_parameters() const { return m_parameters; } - bool is_node_in_cache(const std::string& name) const; - Output get_ng_node_from_cache(const std::string& name) const; + virtual Output get_ng_node_from_cache(const std::string& name) const; const std::string& get_name() const { return m_model->get_graph().name(); } OutputVector make_ng_nodes(const Node& onnx_node) const; const GraphCache& get_graph_cache() const; @@ -60,6 +61,11 @@ namespace ngraph const OutputVector& ng_node_vector) const; protected: + virtual void decode_to_framework_nodes(); + void convert_to_ngraph_nodes(); + void remove_dangling_parameters(); + std::shared_ptr create_function(); + ParameterVector m_parameters; std::unique_ptr m_model; std::unique_ptr m_cache; @@ -82,9 +88,11 @@ namespace ngraph /// \param[in] parent_graph The reference to the parent graph. Subgraph(std::unique_ptr&& model, const Graph& parent_graph); - /// \brief Return outputs which are on the edge the subgraph and the parent graph. + /// \brief Return nodes which are on the edge the subgraph and the parent graph. /// \return Vector of edge nodes from parent scope. - const std::vector> get_outputs_from_parent() const; + const std::vector> get_inputs_from_parent() const; + + std::shared_ptr convert() override; Subgraph() = delete; @@ -94,8 +102,17 @@ namespace ngraph Subgraph& operator=(const Subgraph&) = delete; Subgraph& operator=(Subgraph&&) = default; + Output get_ng_node_from_cache(const std::string& name) const override; + void infer_inputs_from_parent(); + private: - std::vector> m_outputs_from_parent; + void decode_to_framework_nodes() override; + void find_inputs_from_parent(); + + const GraphCache* m_parent_graph_cache; + std::vector m_inputs_from_parent; + std::unordered_map, std::string> + m_parameter_to_parent_node_map; }; inline std::ostream& operator<<(std::ostream& outs, const Graph& graph) diff --git a/ngraph/frontend/onnx_import/src/core/graph_cache.cpp b/ngraph/frontend/onnx_import/src/core/graph_cache.cpp index 9a0e0b59bbc42e..69593c062a3e69 100644 --- a/ngraph/frontend/onnx_import/src/core/graph_cache.cpp +++ b/ngraph/frontend/onnx_import/src/core/graph_cache.cpp @@ -39,55 +39,5 @@ namespace ngraph { return (m_graph_cache_map.count(name) > 0); } - - NodeScope GraphCache::node_scope(const std::string& name) const - { - return contains(name) ? NodeScope::ParentGraph : NodeScope::Lack; - } - - SubgraphCache::SubgraphCache(const GraphCache& parent_graph_cache) - : m_parent_graph_cache{&parent_graph_cache} - { - if (m_parent_graph_cache == nullptr) - { - throw ngraph_error("Parent graph cache is not initialized"); - } - } - - Output SubgraphCache::get_node(const std::string& name) const - { - // present in subgraph scope - if (GraphCache::contains(name)) - { - return GraphCache::get_node(name); - } - else // present in parent graph scope - { - return m_parent_graph_cache->get_node(name); - } - } - - bool SubgraphCache::contains(const std::string& name) const - { - // the node is in subgraph or in parent graph scope - return GraphCache::contains(name) || m_parent_graph_cache->contains(name); - } - - NodeScope SubgraphCache::node_scope(const std::string& name) const - { - if (GraphCache::contains(name)) - { - return NodeScope::SubGraph; - } - else if (m_parent_graph_cache->contains(name)) - { - return NodeScope::ParentGraph; - } - else - { - return NodeScope::Lack; - } - } - } // namespace onnx_import } // namespace ngraph diff --git a/ngraph/frontend/onnx_import/src/core/graph_cache.hpp b/ngraph/frontend/onnx_import/src/core/graph_cache.hpp index a59af9b4a9f146..556811a91df326 100644 --- a/ngraph/frontend/onnx_import/src/core/graph_cache.hpp +++ b/ngraph/frontend/onnx_import/src/core/graph_cache.hpp @@ -14,17 +14,6 @@ namespace ngraph { namespace onnx_import { - /// \brief Enum which determines scope (visibility) of nodes in GraphCache. - enum class NodeScope - { - // in parent graph scope - ParentGraph = 1, - // in subgraph scope - SubGraph, - // not available at all - Lack - }; - /// \brief GraphCache stores and provides access to ONNX graph initializers. class GraphCache { @@ -58,58 +47,10 @@ namespace ngraph /// \return true if the node named `name` exist in the cache, false otherwise. virtual bool contains(const std::string& name) const; - /// \brief Return NodeScope enum which determines scope of the node. - /// \note If the method is called on GraphCache the ParentGraph enum - /// value is retunred always. - /// - /// \param[in] name The name of the node. - /// - /// \return SubGraph if node belongs to SubgraphCache, ParentGraph if - /// is avalible in parent_graph_cache, otherwise Lack - virtual NodeScope node_scope(const std::string& name) const; - virtual ~GraphCache() = default; private: std::map> m_graph_cache_map; }; - - class SubgraphCache : public GraphCache - { - public: - /// \brief Constructs a SubgraphCache class object. - /// - /// \param[in] parent_graph_cache The reference to the parent graph. - SubgraphCache(const GraphCache& parent_graph_cache); - - /// \brief Get the node from the cache (subgraph or parent graph) - /// - /// \note If the node is not found the ngraph_error exception is thrown. - /// - /// \param[in] name The name of the node. - /// - /// \return The node named `name` from subgraph (as present) or from parent graph. - Output get_node(const std::string& name) const override; - - /// \brief Return true if the node named `name` exist in the cache. - /// - /// \param[in] name The name of the node. - /// - /// \return true if the node named `name` exist in the cache - /// (subgraph or parent graph), false otherwise. - bool contains(const std::string& name) const override; - - /// \brief Return NodeScope enum which determines scope of the node. - /// - /// \param[in] name The name of the node. - /// - /// \return SubGraph if the node belongs to SubgraphCache, ParentGraph if - /// is avalible in parent_graph_cache, otherwise Lack - NodeScope node_scope(const std::string& name) const override; - - private: - const GraphCache* m_parent_graph_cache; - }; - } // namespace onnx_import } // namespace ngraph diff --git a/ngraph/frontend/onnx_import/src/core/model.cpp b/ngraph/frontend/onnx_import/src/core/model.cpp index 452aea7b4775e4..2ddd3edac02e7a 100644 --- a/ngraph/frontend/onnx_import/src/core/model.cpp +++ b/ngraph/frontend/onnx_import/src/core/model.cpp @@ -6,6 +6,7 @@ #include "core/model.hpp" #include "ngraph/log.hpp" +#include "onnx_import/onnx_framework_node.hpp" #include "ops_bridge.hpp" namespace ngraph diff --git a/ngraph/frontend/onnx_import/src/core/node.cpp b/ngraph/frontend/onnx_import/src/core/node.cpp index 1361e802bbff24..b6f2797263b384 100644 --- a/ngraph/frontend/onnx_import/src/core/node.cpp +++ b/ngraph/frontend/onnx_import/src/core/node.cpp @@ -26,6 +26,29 @@ namespace ngraph , m_graph{&graph} , m_attributes{std::begin(node_proto.attribute()), std::end(node_proto.attribute())} , m_output_names{std::begin(node_proto.output()), std::end(node_proto.output())} + { + const auto it = + std::find_if(std::begin(m_attributes), + std::end(m_attributes), + [&](const Attribute& attribute) { return attribute.is_graph(); }); + m_has_subgraph = it != std::end(m_attributes); + if (m_has_subgraph) + { + m_subgraph = std::make_shared(it->get_subgraph(*m_graph)); + } + } + + Impl(const ONNX_NAMESPACE::NodeProto& node_proto, + const Graph& graph, + std::shared_ptr subgraph) + : m_node_proto{&node_proto} + , m_name{node_proto.has_name() ? node_proto.name() : ""} + , m_domain{get_node_domain(node_proto)} + , m_graph{&graph} + , m_attributes{std::begin(node_proto.attribute()), std::end(node_proto.attribute())} + , m_output_names{std::begin(node_proto.output()), std::end(node_proto.output())} + , m_has_subgraph(subgraph != nullptr) + , m_subgraph(subgraph) { } @@ -44,9 +67,8 @@ namespace ngraph bool has_attribute(const std::string& name) const; - Subgraph get_subgraph_from_attribute( - const std::string& name, - const std::map& carried_dependencies_map) const; + bool has_subgraph() const; + std::shared_ptr get_subgraph() const; template T get_attribute_value(const std::string& name, T default_value) const; @@ -58,6 +80,8 @@ namespace ngraph const Graph& graph() const; private: + Subgraph get_subgraph_from_attribute(const std::string& name) const; + const ONNX_NAMESPACE::NodeProto* m_node_proto; std::string m_name; std::string m_domain; @@ -65,6 +89,9 @@ namespace ngraph std::vector m_attributes; std::vector> m_output_names; mutable std::string m_description; + + bool m_has_subgraph; + std::shared_ptr m_subgraph; }; const ONNX_NAMESPACE::NodeProto& Node::Impl::node_proto() const { return *m_node_proto; } @@ -94,9 +121,7 @@ namespace ngraph return it != std::end(m_attributes); } - Subgraph Node::Impl::get_subgraph_from_attribute( - const std::string& name, - const std::map& carried_dependencies_map) const + Subgraph Node::Impl::get_subgraph_from_attribute(const std::string& name) const { auto it = std::find_if( std::begin(m_attributes), std::end(m_attributes), [&](const Attribute& attribute) { @@ -106,9 +131,13 @@ namespace ngraph { throw error::node::UnknownAttribute{this->name(), name}; } - return it->get_subgraph(graph(), carried_dependencies_map); + return it->get_subgraph(*m_graph); } + bool Node::Impl::has_subgraph() const { return m_has_subgraph; } + + std::shared_ptr Node::Impl::get_subgraph() const { return m_subgraph; } + template T Node::Impl::get_attribute_value(const std::string& name, T default_value) const { @@ -140,8 +169,7 @@ namespace ngraph template <> Subgraph Node::Impl::get_attribute_value(const std::string& name) const { - const std::map empty_map; - return get_subgraph_from_attribute(name, empty_map); + return get_subgraph_from_attribute(name); } OutputVector Node::Impl::get_ng_nodes(const Node& node) const @@ -196,7 +224,9 @@ namespace ngraph } Node::Node(const Node& other) - : m_pimpl{new Impl{other.m_pimpl->node_proto(), other.m_pimpl->graph()}, + : m_pimpl{new Impl{other.m_pimpl->node_proto(), + other.m_pimpl->graph(), + other.get_subgraph()}, [](Impl* impl) { delete impl; }} { } @@ -219,12 +249,9 @@ namespace ngraph return m_pimpl->has_attribute(name); } - Subgraph Node::get_subgraph_from_attribute( - const std::string& name, - const std::map& carried_dependencies_map) const - { - return m_pimpl->get_subgraph_from_attribute(name, carried_dependencies_map); - } + bool Node::has_subgraph() const { return m_pimpl->has_subgraph(); } + + std::shared_ptr Node::get_subgraph() const { return m_pimpl->get_subgraph(); } std::vector Node::get_attribute_names() const { @@ -462,7 +489,6 @@ namespace ngraph { return m_pimpl->template get_attribute_value>(name); } - } // namespace onnx_import } // namespace ngraph diff --git a/ngraph/frontend/onnx_import/src/core/null_node.hpp b/ngraph/frontend/onnx_import/src/core/null_node.hpp index c02a06ecfd2706..dd75770488c435 100644 --- a/ngraph/frontend/onnx_import/src/core/null_node.hpp +++ b/ngraph/frontend/onnx_import/src/core/null_node.hpp @@ -36,7 +36,10 @@ namespace ngraph public: static constexpr NodeTypeInfo type_info{"NullNode", 0}; const NodeTypeInfo& get_type_info() const override { return type_info; } - NullNode() = default; + NullNode() + : Node(1) + { + } virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; diff --git a/ngraph/frontend/onnx_import/src/core/value_info.hpp b/ngraph/frontend/onnx_import/src/core/value_info.hpp index 67f2c5f7e2b779..76b3357c6ab3bb 100644 --- a/ngraph/frontend/onnx_import/src/core/value_info.hpp +++ b/ngraph/frontend/onnx_import/src/core/value_info.hpp @@ -19,20 +19,6 @@ namespace ngraph { namespace onnx_import { - namespace error - { - namespace value_info - { - struct unspecified_element_type : ngraph_error - { - unspecified_element_type() - : ngraph_error{"value info has no element type specified"} - { - } - }; - } // namespace value_info - } // namespace error - class ValueInfo { public: @@ -65,12 +51,12 @@ namespace ngraph const PartialShape& get_shape() const { return m_partial_shape; } const element::Type& get_element_type() const { - if (!m_value_info_proto->type().tensor_type().has_elem_type()) + if (m_value_info_proto->type().tensor_type().has_elem_type()) { - throw error::value_info::unspecified_element_type{}; + return common::get_ngraph_element_type( + m_value_info_proto->type().tensor_type().elem_type()); } - return common::get_ngraph_element_type( - m_value_info_proto->type().tensor_type().elem_type()); + return ngraph::element::dynamic; } std::shared_ptr diff --git a/ngraph/frontend/onnx_import/src/onnx_framework_node.cpp b/ngraph/frontend/onnx_import/src/onnx_framework_node.cpp new file mode 100644 index 00000000000000..bf52a1a2c0b8a0 --- /dev/null +++ b/ngraph/frontend/onnx_import/src/onnx_framework_node.cpp @@ -0,0 +1,34 @@ +//***************************************************************************** +// Copyright 2017-2021 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#include + +namespace ngraph +{ + namespace frontend + { + NGRAPH_RTTI_DEFINITION(ONNXFrameworkNode, "ONNXFrameworkNode", 1); + + std::shared_ptr + ONNXFrameworkNode::clone_with_new_inputs(const OutputVector& inputs) const + { + return std::make_shared(m_node, inputs); + } + + NGRAPH_RTTI_DEFINITION(ONNXSubgraphFrameworkNode, "ONNXSubgraphFrameworkNode", 1); + + } // namespace frontend +} // namespace ngraph diff --git a/ngraph/frontend/onnx_import/src/op/loop.cpp b/ngraph/frontend/onnx_import/src/op/loop.cpp index 23ded7464e2d3b..dbe4f68d8c983a 100644 --- a/ngraph/frontend/onnx_import/src/op/loop.cpp +++ b/ngraph/frontend/onnx_import/src/op/loop.cpp @@ -77,10 +77,18 @@ namespace ngraph loop_carried_dependencies[i].get_node()->get_friendly_name(); } - const Subgraph& body_graph{ - node.get_subgraph_from_attribute("body", loop_carried_dependencies_map)}; - auto body_outputs = body_graph.get_ng_outputs(); - const auto& body_inputs = body_graph.get_ng_parameters(); + auto body_graph = node.get_subgraph(); + auto body_outputs = body_graph->get_ng_outputs(); + const auto& body_inputs = body_graph->get_ng_parameters(); + + // Infer loop body inputs' element type based on carried dependencies + for (size_t i = 0; i < loop_carried_dependencies.size(); i++) + { + body_inputs[i + 2]->set_element_type( + loop_carried_dependencies[i].get_element_type()); + body_inputs[i + 2]->set_partial_shape( + loop_carried_dependencies[i].get_partial_shape()); + } // optional inputs Output trip_count; @@ -190,22 +198,22 @@ namespace ngraph final_values.push_back(loop->get_iter_value(*body_outputs_it++, -1)); } - const auto& outputs_from_parent = body_graph.get_outputs_from_parent(); + const auto& inputs_from_parent = body_graph->get_inputs_from_parent(); CHECK_VALID_NODE( node, static_cast(std::distance(body_inputs_it, body_inputs.end())) == - outputs_from_parent.size(), + inputs_from_parent.size(), "Expected number of invariant parameters is" - " not equal number of provided outputs from parent scope"); + " not equal number of provided inputs from parent scope"); // Set-up parameters from parent graph which are not changed during Loop's // iterations - for (auto out_from_parent_it = outputs_from_parent.begin(); + for (auto in_from_parent_it = inputs_from_parent.begin(); body_inputs_it != body_inputs.end() && - out_from_parent_it != outputs_from_parent.end(); - ++body_inputs_it, ++out_from_parent_it) + in_from_parent_it != inputs_from_parent.end(); + ++body_inputs_it, ++in_from_parent_it) { - loop->set_invariant_input(*body_inputs_it, *out_from_parent_it); + loop->set_invariant_input(*body_inputs_it, *in_from_parent_it); } // Set-up scan outputs diff --git a/ngraph/frontend/onnx_import/src/utils/onnx_internal.cpp b/ngraph/frontend/onnx_import/src/utils/onnx_internal.cpp index 74bb4a72d5c19c..8e60171a198c91 100644 --- a/ngraph/frontend/onnx_import/src/utils/onnx_internal.cpp +++ b/ngraph/frontend/onnx_import/src/utils/onnx_internal.cpp @@ -6,7 +6,9 @@ #include "core/graph.hpp" #include "core/model.hpp" +#include "core/null_node.hpp" #include "core/transform.hpp" +#include "onnx_import/onnx_framework_node.hpp" #include "onnx_import/utils/onnx_internal.hpp" namespace ngraph @@ -15,21 +17,81 @@ namespace ngraph { namespace detail { - std::shared_ptr - convert_to_ng_function(const ONNX_NAMESPACE::ModelProto& model_proto) + void remove_dangling_parameters(std::shared_ptr& function) { - auto p_model_proto = common::make_unique(model_proto); - auto model = common::make_unique(std::move(p_model_proto)); + const auto parameters = function->get_parameters(); + for (auto parameter : parameters) + { + const auto parameter_users = parameter->get_users(); + // if a Parameter is connected to a ONNXFrameworkNode that was not converted + // during convert_function it means, this Parameter is dangling and we can + // remove it from function + const bool is_dangling_parameter = std::all_of( + parameter_users.begin(), + parameter_users.end(), + [](const std::shared_ptr& node) -> bool { + return std::dynamic_pointer_cast(node) != + nullptr; + }); + if (is_dangling_parameter) + { + function->remove_parameter(parameter); + } + } + } - Graph graph{std::move(model)}; - auto function = std::make_shared( - graph.get_ng_outputs(), graph.get_ng_parameters(), graph.get_name()); - for (std::size_t i{0}; i < function->get_output_size(); ++i) + void remove_dangling_results(std::shared_ptr& function) + { + const auto results = function->get_results(); + for (auto result : results) { - function->get_output_op(i)->set_friendly_name( - graph.get_outputs().at(i).get_name()); + // we can remove Result from function if after function conversion, + // Result is connected to NullNode only + const auto result_inputs = result->input_values(); + const bool is_dangling_result = + std::all_of(result_inputs.begin(), + result_inputs.end(), + [](const Output& node) -> bool { + return ngraph::op::is_null(node); + }); + if (is_dangling_result) + { + function->remove_result(result); + } } - return function; + } + + void convert_decoded_function(std::shared_ptr function) + { + for (const auto& node : function->get_ordered_ops()) + { + if (auto raw_node = + std::dynamic_pointer_cast(node)) + { + if (auto subgraph_node = + std::dynamic_pointer_cast( + node)) + { + subgraph_node->infer_inputs_from_parent(); + convert_decoded_function(subgraph_node->get_subgraph_body()); + } + const auto& onnx_node = raw_node->get_onnx_node(); + OutputVector ng_nodes{onnx_node.get_ng_nodes()}; + if (ng_nodes.size() > raw_node->get_output_size()) + { + ng_nodes.resize(raw_node->get_output_size()); + } + replace_node(raw_node, ng_nodes); + } + else + { + // Have to revalidate node because new intpus can affect shape/type + // propagation for already translated nodes + node->revalidate_and_infer_types(); + } + } + remove_dangling_parameters(function); + remove_dangling_results(function); } std::shared_ptr import_onnx_model(ONNX_NAMESPACE::ModelProto& model_proto, @@ -39,7 +101,10 @@ namespace ngraph transform::fixup_legacy_operators(model_proto); transform::update_external_data_paths(model_proto, model_path); - return detail::convert_to_ng_function(model_proto); + auto p_model_proto = common::make_unique(model_proto); + auto model = common::make_unique(std::move(p_model_proto)); + Graph graph{std::move(model)}; + return graph.convert(); } } // namespace detail } // namespace onnx_import diff --git a/ngraph/frontend/paddlepaddle/CMakeLists.txt b/ngraph/frontend/paddlepaddle/CMakeLists.txt index bb08e116de687c..cc6f300f8dabd2 100644 --- a/ngraph/frontend/paddlepaddle/CMakeLists.txt +++ b/ngraph/frontend/paddlepaddle/CMakeLists.txt @@ -29,8 +29,6 @@ else() set(PDPD_PROTOC_EXECUTABLE $) endif() -message("PDPD_PROTOC_EXECUTABLE is [${PDPD_PROTOC_EXECUTABLE}]") - foreach(INFILE ${proto_files}) get_filename_component(FILE_DIR ${INFILE} DIRECTORY) get_filename_component(FILE_WE ${INFILE} NAME_WE) @@ -64,10 +62,6 @@ if(NOT WIN32) add_dependencies(${TARGET_NAME} libprotobuf_static) endif() -if (TARGET ext_protobuf) - add_dependencies(${TARGET_NAME} ext_protobuf) -endif() - target_include_directories(${TARGET_NAME} PUBLIC $ diff --git a/ngraph/frontend/paddlepaddle/src/op/argmax.cpp b/ngraph/frontend/paddlepaddle/src/op/argmax.cpp new file mode 100644 index 00000000000000..7d8c069031d07f --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/argmax.cpp @@ -0,0 +1,57 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "argmax.hpp" +#include + +namespace ngraph +{ + namespace frontend + { + namespace pdpd + { + namespace op + { + NamedOutputs argmax(const NodeContext& node) + { + auto data = node.get_ng_input("X"); + bool flatten = node.get_attribute("flatten"); + const element::Type& index_element_type = element::i64; + const Output k = + ngraph::opset6::Constant::create(ngraph::element::i64, {}, {1}); + + if (!flatten) + { + auto axis = node.get_attribute("axis"); + const auto axis_to_remove = + ngraph::opset6::Constant::create(element::u64, Shape{}, {axis}); + auto node_topk = std::make_shared( + data, k, axis, "max", "index", index_element_type); + const auto reshaped_indices = std::make_shared( + node_topk->output(1), axis_to_remove); + return node.default_single_output_mapping( + {std::make_shared(reshaped_indices, + element::i64)}, + {"Out"}); + } + else + { + int64_t axis = 0; + const Output reshape_flatten = + ngraph::opset6::Constant::create(ngraph::element::i64, {1}, {-1}); + auto node_reshape = + std::make_shared(data, reshape_flatten, true); + auto node_topk = std::make_shared( + node_reshape, k, axis, "max", "index", index_element_type); + return node.default_single_output_mapping( + {std::make_shared(node_topk->output(1), + element::i64)}, + {"Out"}); + } + } + + } // namespace op + } // namespace pdpd + } // namespace frontend +} // namespace ngraph diff --git a/ngraph/frontend/paddlepaddle/src/op/argmax.hpp b/ngraph/frontend/paddlepaddle/src/op/argmax.hpp new file mode 100644 index 00000000000000..20d9db406be0cf --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/argmax.hpp @@ -0,0 +1,20 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once +#include "node_context.hpp" + +namespace ngraph +{ + namespace frontend + { + namespace pdpd + { + namespace op + { + NamedOutputs argmax(const NodeContext& node); + } + } // namespace pdpd + } // namespace frontend +} // namespace ngraph \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/op/assign_value.cpp b/ngraph/frontend/paddlepaddle/src/op/assign_value.cpp new file mode 100644 index 00000000000000..fb503abbba80e8 --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/assign_value.cpp @@ -0,0 +1,66 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "assign_value.hpp" +#include +namespace ngraph +{ + namespace frontend + { + namespace pdpd + { + namespace op + { + NamedOutputs assign_value(const NodeContext& node) + { + std::vector shape = node.get_attribute>("shape"); + auto dtype = node.get_attribute("dtype"); + std::shared_ptr const_node; + + switch (dtype) + { + case element::i32: + { + auto values = node.get_attribute>("int32_values"); + const_node = {opset6::Constant::create( + dtype, Shape{shape.begin(), shape.end()}, values)}; + break; + } + case element::f32: + { + std::vector values = + node.get_attribute>("fp32_values"); + const_node = {opset6::Constant::create( + dtype, Shape{shape.begin(), shape.end()}, values)}; + break; + } + case element::boolean: + { + auto values = node.get_attribute>("bool_values"); + const_node = {opset6::Constant::create( + dtype, Shape{shape.begin(), shape.end()}, values)}; + break; + } + case element::i64: + { + auto values = node.get_attribute>("int64_values"); + const_node = {opset6::Constant::create( + dtype, Shape{shape.begin(), shape.end()}, values)}; + break; + } + default: + { + PDPD_OP_VALIDATION_CHECK( + node, false, "assign_value only supports int32, int64, float32, bool"); + break; + } + } + + return node.default_single_output_mapping({const_node}, {"Out"}); + } + + } // namespace op + } // namespace pdpd + } // namespace frontend +} // namespace ngraph diff --git a/ngraph/frontend/paddlepaddle/src/op/assign_value.hpp b/ngraph/frontend/paddlepaddle/src/op/assign_value.hpp new file mode 100644 index 00000000000000..b954b3a04cce50 --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/assign_value.hpp @@ -0,0 +1,21 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "node_context.hpp" + +namespace ngraph +{ + namespace frontend + { + namespace pdpd + { + namespace op + { + NamedOutputs assign_value(const NodeContext& node); + } + } // namespace pdpd + } // namespace frontend +} // namespace ngraph diff --git a/ngraph/frontend/paddlepaddle/src/op/batch_norm.cpp b/ngraph/frontend/paddlepaddle/src/op/batch_norm.cpp new file mode 100644 index 00000000000000..c38c4189fa04a0 --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/batch_norm.cpp @@ -0,0 +1,64 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "batch_norm.hpp" +#include + +namespace ngraph +{ + namespace frontend + { + namespace pdpd + { + namespace op + { + NamedOutputs batch_norm(const NodeContext& node) + { + auto data = node.get_ng_input("X"); + auto gamma = node.get_ng_input("Scale"); + auto beta = node.get_ng_input("Bias"); + auto mean = node.get_ng_input("Mean"); + auto variance = node.get_ng_input("Variance"); + auto data_layout = node.get_attribute("data_layout"); + + PDPD_ASSERT((data_layout == "NCHW" || data_layout == "NHWC"), + "Not supported input data layout!"); + if (data_layout == "NCHW") + { + return node.default_single_output_mapping( + {std::make_shared( + data, + gamma, + beta, + mean, + variance, + node.get_attribute("epsilon"))}, + {"Y"}); + } + else + { + auto input_order = ngraph::opset6::Constant::create( + ngraph::element::i64, {4}, {0, 3, 1, 2}); + auto data_nchw = + std::make_shared(data, input_order); + auto node_batch_norm = std::make_shared( + data_nchw, + gamma, + beta, + mean, + variance, + node.get_attribute("epsilon")); + auto output_order = ngraph::opset6::Constant::create( + ngraph::element::i64, {4}, {0, 2, 3, 1}); + return node.default_single_output_mapping( + {std::make_shared(node_batch_norm, + output_order)}, + {"Y"}); + } + } + + } // namespace op + } // namespace pdpd + } // namespace frontend +} // namespace ngraph diff --git a/ngraph/frontend/paddlepaddle/src/op/batch_norm.hpp b/ngraph/frontend/paddlepaddle/src/op/batch_norm.hpp new file mode 100644 index 00000000000000..3757421bba65f5 --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/batch_norm.hpp @@ -0,0 +1,20 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once +#include "node_context.hpp" + +namespace ngraph +{ + namespace frontend + { + namespace pdpd + { + namespace op + { + NamedOutputs batch_norm(const NodeContext& node); + } + } // namespace pdpd + } // namespace frontend +} // namespace ngraph \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/op/cast.cpp b/ngraph/frontend/paddlepaddle/src/op/cast.cpp new file mode 100644 index 00000000000000..2cb181f0b24158 --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/cast.cpp @@ -0,0 +1,28 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "cast.hpp" +#include + +namespace ngraph +{ + namespace frontend + { + namespace pdpd + { + namespace op + { + NamedOutputs cast(const NodeContext& node) + { + auto data = node.get_ng_input("X"); + auto out_dtype = node.get_attribute("out_dtype"); + + return node.default_single_output_mapping( + {std::make_shared(data, out_dtype)}, {"Out"}); + } + + } // namespace op + } // namespace pdpd + } // namespace frontend +} // namespace ngraph \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/op/cast.hpp b/ngraph/frontend/paddlepaddle/src/op/cast.hpp new file mode 100644 index 00000000000000..1e3a19aaf5975c --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/cast.hpp @@ -0,0 +1,20 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once +#include "node_context.hpp" + +namespace ngraph +{ + namespace frontend + { + namespace pdpd + { + namespace op + { + NamedOutputs cast(const NodeContext& node); + } + } // namespace pdpd + } // namespace frontend +} // namespace ngraph \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/op/clip.cpp b/ngraph/frontend/paddlepaddle/src/op/clip.cpp new file mode 100644 index 00000000000000..1909e392eaf2f8 --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/clip.cpp @@ -0,0 +1,31 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "clip.hpp" +#include + +namespace ngraph +{ + namespace frontend + { + namespace pdpd + { + namespace op + { + NamedOutputs clip(const NodeContext& node) + { + auto data = node.get_ng_input("X"); + auto min = node.get_attribute("min"); + auto max = node.get_attribute("max"); + PDPD_OP_VALIDATION_CHECK( + node, max >= min, "clip: max value must greater than min value!"); + + return node.default_single_output_mapping( + {std::make_shared(data, min, max)}, {"Out"}); + } + + } // namespace op + } // namespace pdpd + } // namespace frontend +} // namespace ngraph \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/op/clip.hpp b/ngraph/frontend/paddlepaddle/src/op/clip.hpp new file mode 100644 index 00000000000000..babfa2ccd95bfd --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/clip.hpp @@ -0,0 +1,20 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once +#include "node_context.hpp" + +namespace ngraph +{ + namespace frontend + { + namespace pdpd + { + namespace op + { + NamedOutputs clip(const NodeContext& node); + } + } // namespace pdpd + } // namespace frontend +} // namespace ngraph \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/op/concat.cpp b/ngraph/frontend/paddlepaddle/src/op/concat.cpp new file mode 100644 index 00000000000000..a9c6fa6388d848 --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/concat.cpp @@ -0,0 +1,27 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "concat.hpp" +#include + +namespace ngraph +{ + namespace frontend + { + namespace pdpd + { + namespace op + { + NamedOutputs concat(const NodeContext& node) + { + auto data = node.get_ng_inputs("X"); + auto axis = node.get_attribute("axis"); + return node.default_single_output_mapping( + {std::make_shared(data, axis)}, {"Out"}); + } + + } // namespace op + } // namespace pdpd + } // namespace frontend +} // namespace ngraph \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/op/concat.hpp b/ngraph/frontend/paddlepaddle/src/op/concat.hpp new file mode 100644 index 00000000000000..0d32fa22f6e3bd --- /dev/null +++ b/ngraph/frontend/paddlepaddle/src/op/concat.hpp @@ -0,0 +1,20 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once +#include "node_context.hpp" + +namespace ngraph +{ + namespace frontend + { + namespace pdpd + { + namespace op + { + NamedOutputs concat(const NodeContext& node); + } + } // namespace pdpd + } // namespace frontend +} // namespace ngraph \ No newline at end of file diff --git a/ngraph/frontend/paddlepaddle/src/op_table.cpp b/ngraph/frontend/paddlepaddle/src/op_table.cpp index 411cfe8ecbf6d2..916737fc0c2ede 100644 --- a/ngraph/frontend/paddlepaddle/src/op_table.cpp +++ b/ngraph/frontend/paddlepaddle/src/op_table.cpp @@ -1,7 +1,12 @@ // Copyright (C) 2018-2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // - +#include "op/argmax.hpp" +#include "op/assign_value.hpp" +#include "op/batch_norm.hpp" +#include "op/cast.hpp" +#include "op/clip.hpp" +#include "op/concat.hpp" #include "op/conv2d.hpp" #include "op/elementwise_ops.hpp" #include "op/relu.hpp" @@ -18,7 +23,13 @@ namespace ngraph { std::map get_supported_ops() { - return {{"conv2d", op::conv2d}, + return {{"arg_max", op::argmax}, + {"assign_value", op::assign_value}, + {"batch_norm", op::batch_norm}, + {"cast", op::cast}, + {"clip", op::clip}, + {"concat", op::concat}, + {"conv2d", op::conv2d}, {"elementwise_add", op::elementwise_add}, {"elementwise_div", op::elementwise_div}, {"elementwise_max", op::elementwise_max}, diff --git a/ngraph/python/BUILDING.md b/ngraph/python/BUILDING.md index 5d4d9c72892b3c..18e395fc9d8718 100644 --- a/ngraph/python/BUILDING.md +++ b/ngraph/python/BUILDING.md @@ -48,7 +48,6 @@ set the mentioned flags to `ON`. Note the `CMAKE_INSTALL_PREFIX`, which defaults -DENABLE_OPENCV=OFF \ -DENABLE_VPU=OFF \ -DENABLE_PYTHON=ON \ - -DNGRAPH_PYTHON_BUILD_ENABLE=ON \ -DNGRAPH_ONNX_IMPORT_ENABLE=ON \ -DCMAKE_INSTALL_PREFIX="${OPENVINO_BASEDIR}/openvino_dist" @@ -111,7 +110,6 @@ cmake .. ^ -DENABLE_CLDNN=OFF ^ -DENABLE_OPENCV=OFF ^ -DENABLE_VPU=OFF ^ - -DNGRAPH_PYTHON_BUILD_ENABLE=ON ^ -DNGRAPH_ONNX_IMPORT_ENABLE=ON ^ -DENABLE_PYTHON=ON ^ -DCMAKE_CXX_COMPILER="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\Hostx64\x64" diff --git a/ngraph/python/CMakeLists.txt b/ngraph/python/CMakeLists.txt index 3231b4cacda4f5..2eb4b03a2e58b8 100644 --- a/ngraph/python/CMakeLists.txt +++ b/ngraph/python/CMakeLists.txt @@ -15,23 +15,11 @@ if(ngraph_FOUND) message("ngraph version = {${ngraph_VERSION}}") endif() -include(FetchContent) - -FetchContent_Declare( - pybind11 - GIT_REPOSITORY "https://github.com/pybind/pybind11.git" - GIT_TAG "v2.6.2" -) - -FetchContent_GetProperties(pybind11) -if(NOT pybind11_POPULATED) - FetchContent_Populate(pybind11) - add_subdirectory(${pybind11_SOURCE_DIR} ${pybind11_BINARY_DIR}) -endif() +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/pybind11 EXCLUDE_FROM_ALL) # PYTHON_VERSION_MAJOR and PYTHON_VERSION_MINOR are defined inside pybind11 set(PYTHON_VERSION python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) -message("Python version=${PYTHON_VERSION}") +message(STATUS "Python version=${PYTHON_VERSION}") set(LIBRARY_OUTPUT_DIRECTORY_BIN ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) if(OpenVINO_SOURCE_DIR) diff --git a/ngraph/python/pybind11 b/ngraph/python/pybind11 new file mode 160000 index 00000000000000..8de7772cc72dac --- /dev/null +++ b/ngraph/python/pybind11 @@ -0,0 +1 @@ +Subproject commit 8de7772cc72daca8e947b79b83fea46214931604 diff --git a/ngraph/python/setup.py b/ngraph/python/setup.py index e90cc66d6d173d..059ccd81acbdfa 100644 --- a/ngraph/python/setup.py +++ b/ngraph/python/setup.py @@ -155,7 +155,7 @@ def build_cmake(self, extension: Extension): ext_args = self.cmake_args.split() if self.cmake_args else [] self.spawn(["cmake", "-H" + root_dir, "-B" + self.build_temp, "-DCMAKE_BUILD_TYPE={}".format(self.config), - "-DNGRAPH_PYTHON_BUILD_ENABLE=ON", + "-DENABLE_PYTHON=ON", "-DNGRAPH_ONNX_IMPORT_ENABLE=ON"] + ext_args) self.announce("Building binaries", level=3) diff --git a/ngraph/python/src/ngraph/__init__.py b/ngraph/python/src/ngraph/__init__.py index f51c5cea130510..f7e498c4a60e0d 100644 --- a/ngraph/python/src/ngraph/__init__.py +++ b/ngraph/python/src/ngraph/__init__.py @@ -28,159 +28,159 @@ from ngraph.frontend import Place from ngraph.helpers import function_from_cnn from ngraph.helpers import function_to_cnn -from ngraph.opset7 import absolute -from ngraph.opset7 import absolute as abs -from ngraph.opset7 import acos -from ngraph.opset7 import acosh -from ngraph.opset7 import add -from ngraph.opset7 import asin -from ngraph.opset7 import asinh -from ngraph.opset7 import assign -from ngraph.opset7 import atan -from ngraph.opset7 import atanh -from ngraph.opset7 import avg_pool -from ngraph.opset7 import batch_norm_inference -from ngraph.opset7 import batch_to_space -from ngraph.opset7 import binary_convolution -from ngraph.opset7 import broadcast -from ngraph.opset7 import bucketize -from ngraph.opset7 import ceiling -from ngraph.opset7 import ceiling as ceil -from ngraph.opset7 import clamp -from ngraph.opset7 import concat -from ngraph.opset7 import constant -from ngraph.opset7 import convert -from ngraph.opset7 import convert_like -from ngraph.opset7 import convolution -from ngraph.opset7 import convolution_backprop_data -from ngraph.opset7 import cos -from ngraph.opset7 import cosh -from ngraph.opset7 import ctc_greedy_decoder -from ngraph.opset7 import ctc_greedy_decoder_seq_len -from ngraph.opset7 import ctc_loss -from ngraph.opset7 import cum_sum -from ngraph.opset7 import cum_sum as cumsum -from ngraph.opset7 import deformable_convolution -from ngraph.opset7 import deformable_psroi_pooling -from ngraph.opset7 import depth_to_space -from ngraph.opset7 import detection_output -from ngraph.opset7 import dft -from ngraph.opset7 import divide -from ngraph.opset7 import einsum -from ngraph.opset7 import elu -from ngraph.opset7 import embedding_bag_offsets_sum -from ngraph.opset7 import embedding_bag_packed_sum -from ngraph.opset7 import embedding_segments_sum -from ngraph.opset7 import extract_image_patches -from ngraph.opset7 import equal -from ngraph.opset7 import erf -from ngraph.opset7 import exp -from ngraph.opset7 import fake_quantize -from ngraph.opset7 import floor -from ngraph.opset7 import floor_mod -from ngraph.opset7 import gather -from ngraph.opset7 import gather_elements -from ngraph.opset7 import gather_nd -from ngraph.opset7 import gather_tree -from ngraph.opset7 import gelu -from ngraph.opset7 import greater -from ngraph.opset7 import greater_equal -from ngraph.opset7 import grn -from ngraph.opset7 import group_convolution -from ngraph.opset7 import group_convolution_backprop_data -from ngraph.opset7 import gru_cell -from ngraph.opset7 import gru_sequence -from ngraph.opset7 import hard_sigmoid -from ngraph.opset7 import hsigmoid -from ngraph.opset7 import hswish -from ngraph.opset7 import idft -from ngraph.opset7 import interpolate -from ngraph.opset7 import less -from ngraph.opset7 import less_equal -from ngraph.opset7 import log -from ngraph.opset7 import logical_and -from ngraph.opset7 import logical_not -from ngraph.opset7 import logical_or -from ngraph.opset7 import logical_xor -from ngraph.opset7 import log_softmax -from ngraph.opset7 import loop -from ngraph.opset7 import lrn -from ngraph.opset7 import lstm_cell -from ngraph.opset7 import lstm_sequence -from ngraph.opset7 import matmul -from ngraph.opset7 import max_pool -from ngraph.opset7 import maximum -from ngraph.opset7 import minimum -from ngraph.opset7 import mish -from ngraph.opset7 import mod -from ngraph.opset7 import multiply -from ngraph.opset7 import mvn -from ngraph.opset7 import negative -from ngraph.opset7 import non_max_suppression -from ngraph.opset7 import non_zero -from ngraph.opset7 import normalize_l2 -from ngraph.opset7 import not_equal -from ngraph.opset7 import one_hot -from ngraph.opset7 import pad -from ngraph.opset7 import parameter -from ngraph.opset7 import power -from ngraph.opset7 import prelu -from ngraph.opset7 import prior_box -from ngraph.opset7 import prior_box_clustered -from ngraph.opset7 import psroi_pooling -from ngraph.opset7 import proposal -from ngraph.opset7 import range -from ngraph.opset7 import read_value -from ngraph.opset7 import reduce_l1 -from ngraph.opset7 import reduce_l2 -from ngraph.opset7 import reduce_logical_and -from ngraph.opset7 import reduce_logical_or -from ngraph.opset7 import reduce_max -from ngraph.opset7 import reduce_mean -from ngraph.opset7 import reduce_min -from ngraph.opset7 import reduce_prod -from ngraph.opset7 import reduce_sum -from ngraph.opset7 import region_yolo -from ngraph.opset7 import reorg_yolo -from ngraph.opset7 import relu -from ngraph.opset7 import reshape -from ngraph.opset7 import result -from ngraph.opset7 import reverse_sequence -from ngraph.opset7 import rnn_cell -from ngraph.opset7 import rnn_sequence -from ngraph.opset7 import roi_align -from ngraph.opset7 import roi_pooling -from ngraph.opset7 import roll -from ngraph.opset7 import round -from ngraph.opset7 import scatter_elements_update -from ngraph.opset7 import scatter_update -from ngraph.opset7 import select -from ngraph.opset7 import selu -from ngraph.opset7 import shape_of -from ngraph.opset7 import shuffle_channels -from ngraph.opset7 import sigmoid -from ngraph.opset7 import sign -from ngraph.opset7 import sin -from ngraph.opset7 import sinh -from ngraph.opset7 import softmax -from ngraph.opset7 import softplus -from ngraph.opset7 import space_to_batch -from ngraph.opset7 import space_to_depth -from ngraph.opset7 import split -from ngraph.opset7 import sqrt -from ngraph.opset7 import squared_difference -from ngraph.opset7 import squeeze -from ngraph.opset7 import strided_slice -from ngraph.opset7 import subtract -from ngraph.opset7 import swish -from ngraph.opset7 import tan -from ngraph.opset7 import tanh -from ngraph.opset7 import tensor_iterator -from ngraph.opset7 import tile -from ngraph.opset7 import topk -from ngraph.opset7 import transpose -from ngraph.opset7 import unsqueeze -from ngraph.opset7 import variadic_split +from ngraph.opset8 import absolute +from ngraph.opset8 import absolute as abs +from ngraph.opset8 import acos +from ngraph.opset8 import acosh +from ngraph.opset8 import add +from ngraph.opset8 import asin +from ngraph.opset8 import asinh +from ngraph.opset8 import assign +from ngraph.opset8 import atan +from ngraph.opset8 import atanh +from ngraph.opset8 import avg_pool +from ngraph.opset8 import batch_norm_inference +from ngraph.opset8 import batch_to_space +from ngraph.opset8 import binary_convolution +from ngraph.opset8 import broadcast +from ngraph.opset8 import bucketize +from ngraph.opset8 import ceiling +from ngraph.opset8 import ceiling as ceil +from ngraph.opset8 import clamp +from ngraph.opset8 import concat +from ngraph.opset8 import constant +from ngraph.opset8 import convert +from ngraph.opset8 import convert_like +from ngraph.opset8 import convolution +from ngraph.opset8 import convolution_backprop_data +from ngraph.opset8 import cos +from ngraph.opset8 import cosh +from ngraph.opset8 import ctc_greedy_decoder +from ngraph.opset8 import ctc_greedy_decoder_seq_len +from ngraph.opset8 import ctc_loss +from ngraph.opset8 import cum_sum +from ngraph.opset8 import cum_sum as cumsum +from ngraph.opset8 import deformable_convolution +from ngraph.opset8 import deformable_psroi_pooling +from ngraph.opset8 import depth_to_space +from ngraph.opset8 import detection_output +from ngraph.opset8 import dft +from ngraph.opset8 import divide +from ngraph.opset8 import einsum +from ngraph.opset8 import elu +from ngraph.opset8 import embedding_bag_offsets_sum +from ngraph.opset8 import embedding_bag_packed_sum +from ngraph.opset8 import embedding_segments_sum +from ngraph.opset8 import extract_image_patches +from ngraph.opset8 import equal +from ngraph.opset8 import erf +from ngraph.opset8 import exp +from ngraph.opset8 import fake_quantize +from ngraph.opset8 import floor +from ngraph.opset8 import floor_mod +from ngraph.opset8 import gather +from ngraph.opset8 import gather_elements +from ngraph.opset8 import gather_nd +from ngraph.opset8 import gather_tree +from ngraph.opset8 import gelu +from ngraph.opset8 import greater +from ngraph.opset8 import greater_equal +from ngraph.opset8 import grn +from ngraph.opset8 import group_convolution +from ngraph.opset8 import group_convolution_backprop_data +from ngraph.opset8 import gru_cell +from ngraph.opset8 import gru_sequence +from ngraph.opset8 import hard_sigmoid +from ngraph.opset8 import hsigmoid +from ngraph.opset8 import hswish +from ngraph.opset8 import idft +from ngraph.opset8 import interpolate +from ngraph.opset8 import less +from ngraph.opset8 import less_equal +from ngraph.opset8 import log +from ngraph.opset8 import logical_and +from ngraph.opset8 import logical_not +from ngraph.opset8 import logical_or +from ngraph.opset8 import logical_xor +from ngraph.opset8 import log_softmax +from ngraph.opset8 import loop +from ngraph.opset8 import lrn +from ngraph.opset8 import lstm_cell +from ngraph.opset8 import lstm_sequence +from ngraph.opset8 import matmul +from ngraph.opset8 import max_pool +from ngraph.opset8 import maximum +from ngraph.opset8 import minimum +from ngraph.opset8 import mish +from ngraph.opset8 import mod +from ngraph.opset8 import multiply +from ngraph.opset8 import mvn +from ngraph.opset8 import negative +from ngraph.opset8 import non_max_suppression +from ngraph.opset8 import non_zero +from ngraph.opset8 import normalize_l2 +from ngraph.opset8 import not_equal +from ngraph.opset8 import one_hot +from ngraph.opset8 import pad +from ngraph.opset8 import parameter +from ngraph.opset8 import power +from ngraph.opset8 import prelu +from ngraph.opset8 import prior_box +from ngraph.opset8 import prior_box_clustered +from ngraph.opset8 import psroi_pooling +from ngraph.opset8 import proposal +from ngraph.opset8 import range +from ngraph.opset8 import read_value +from ngraph.opset8 import reduce_l1 +from ngraph.opset8 import reduce_l2 +from ngraph.opset8 import reduce_logical_and +from ngraph.opset8 import reduce_logical_or +from ngraph.opset8 import reduce_max +from ngraph.opset8 import reduce_mean +from ngraph.opset8 import reduce_min +from ngraph.opset8 import reduce_prod +from ngraph.opset8 import reduce_sum +from ngraph.opset8 import region_yolo +from ngraph.opset8 import reorg_yolo +from ngraph.opset8 import relu +from ngraph.opset8 import reshape +from ngraph.opset8 import result +from ngraph.opset8 import reverse_sequence +from ngraph.opset8 import rnn_cell +from ngraph.opset8 import rnn_sequence +from ngraph.opset8 import roi_align +from ngraph.opset8 import roi_pooling +from ngraph.opset8 import roll +from ngraph.opset8 import round +from ngraph.opset8 import scatter_elements_update +from ngraph.opset8 import scatter_update +from ngraph.opset8 import select +from ngraph.opset8 import selu +from ngraph.opset8 import shape_of +from ngraph.opset8 import shuffle_channels +from ngraph.opset8 import sigmoid +from ngraph.opset8 import sign +from ngraph.opset8 import sin +from ngraph.opset8 import sinh +from ngraph.opset8 import softmax +from ngraph.opset8 import softplus +from ngraph.opset8 import space_to_batch +from ngraph.opset8 import space_to_depth +from ngraph.opset8 import split +from ngraph.opset8 import sqrt +from ngraph.opset8 import squared_difference +from ngraph.opset8 import squeeze +from ngraph.opset8 import strided_slice +from ngraph.opset8 import subtract +from ngraph.opset8 import swish +from ngraph.opset8 import tan +from ngraph.opset8 import tanh +from ngraph.opset8 import tensor_iterator +from ngraph.opset8 import tile +from ngraph.opset8 import topk +from ngraph.opset8 import transpose +from ngraph.opset8 import unsqueeze +from ngraph.opset8 import variadic_split # Extend Node class to support binary operators diff --git a/ngraph/python/src/ngraph/opset8/__init__.py b/ngraph/python/src/ngraph/opset8/__init__.py new file mode 100644 index 00000000000000..6f2e8e707c7a6b --- /dev/null +++ b/ngraph/python/src/ngraph/opset8/__init__.py @@ -0,0 +1,156 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +from ngraph.opset1.ops import absolute +from ngraph.opset1.ops import absolute as abs +from ngraph.opset1.ops import acos +from ngraph.opset4.ops import acosh +from ngraph.opset1.ops import add +from ngraph.opset1.ops import asin +from ngraph.opset4.ops import asinh +from ngraph.opset3.ops import assign +from ngraph.opset1.ops import atan +from ngraph.opset4.ops import atanh +from ngraph.opset1.ops import avg_pool +from ngraph.opset5.ops import batch_norm_inference +from ngraph.opset2.ops import batch_to_space +from ngraph.opset1.ops import binary_convolution +from ngraph.opset3.ops import broadcast +from ngraph.opset3.ops import bucketize +from ngraph.opset1.ops import ceiling +from ngraph.opset1.ops import ceiling as ceil +from ngraph.opset1.ops import clamp +from ngraph.opset1.ops import concat +from ngraph.opset1.ops import constant +from ngraph.opset1.ops import convert +from ngraph.opset1.ops import convert_like +from ngraph.opset1.ops import convolution +from ngraph.opset1.ops import convolution_backprop_data +from ngraph.opset1.ops import cos +from ngraph.opset1.ops import cosh +from ngraph.opset1.ops import ctc_greedy_decoder +from ngraph.opset6.ops import ctc_greedy_decoder_seq_len +from ngraph.opset4.ops import ctc_loss +from ngraph.opset3.ops import cum_sum +from ngraph.opset3.ops import cum_sum as cumsum +from ngraph.opset8.ops import deformable_convolution +from ngraph.opset1.ops import deformable_psroi_pooling +from ngraph.opset1.ops import depth_to_space +from ngraph.opset1.ops import detection_output +from ngraph.opset7.ops import dft +from ngraph.opset1.ops import divide +from ngraph.opset7.ops import einsum +from ngraph.opset1.ops import elu +from ngraph.opset3.ops import embedding_bag_offsets_sum +from ngraph.opset3.ops import embedding_bag_packed_sum +from ngraph.opset3.ops import embedding_segments_sum +from ngraph.opset3.ops import extract_image_patches +from ngraph.opset1.ops import equal +from ngraph.opset1.ops import erf +from ngraph.opset1.ops import exp +from ngraph.opset1.ops import fake_quantize +from ngraph.opset1.ops import floor +from ngraph.opset1.ops import floor_mod +from ngraph.opset7.ops import gather +from ngraph.opset6.ops import gather_elements +from ngraph.opset5.ops import gather_nd +from ngraph.opset1.ops import gather_tree +from ngraph.opset7.ops import gelu +from ngraph.opset1.ops import greater +from ngraph.opset1.ops import greater_equal +from ngraph.opset1.ops import grn +from ngraph.opset1.ops import group_convolution +from ngraph.opset1.ops import group_convolution_backprop_data +from ngraph.opset3.ops import gru_cell +from ngraph.opset5.ops import gru_sequence +from ngraph.opset1.ops import hard_sigmoid +from ngraph.opset5.ops import hsigmoid +from ngraph.opset4.ops import hswish +from ngraph.opset7.ops import idft +from ngraph.opset1.ops import interpolate +from ngraph.opset1.ops import less +from ngraph.opset1.ops import less_equal +from ngraph.opset1.ops import log +from ngraph.opset1.ops import logical_and +from ngraph.opset1.ops import logical_not +from ngraph.opset1.ops import logical_or +from ngraph.opset1.ops import logical_xor +from ngraph.opset5.ops import log_softmax +from ngraph.opset5.ops import loop +from ngraph.opset1.ops import lrn +from ngraph.opset4.ops import lstm_cell +from ngraph.opset1.ops import lstm_sequence +from ngraph.opset1.ops import matmul +from ngraph.opset1.ops import max_pool +from ngraph.opset1.ops import maximum +from ngraph.opset1.ops import minimum +from ngraph.opset4.ops import mish +from ngraph.opset1.ops import mod +from ngraph.opset1.ops import multiply +from ngraph.opset6.ops import mvn +from ngraph.opset1.ops import negative +from ngraph.opset5.ops import non_max_suppression +from ngraph.opset3.ops import non_zero +from ngraph.opset1.ops import normalize_l2 +from ngraph.opset1.ops import not_equal +from ngraph.opset1.ops import one_hot +from ngraph.opset1.ops import pad +from ngraph.opset1.ops import parameter +from ngraph.opset1.ops import power +from ngraph.opset1.ops import prelu +from ngraph.opset1.ops import prior_box +from ngraph.opset1.ops import prior_box_clustered +from ngraph.opset1.ops import psroi_pooling +from ngraph.opset4.ops import proposal +from ngraph.opset1.ops import range +from ngraph.opset3.ops import read_value +from ngraph.opset4.ops import reduce_l1 +from ngraph.opset4.ops import reduce_l2 +from ngraph.opset1.ops import reduce_logical_and +from ngraph.opset1.ops import reduce_logical_or +from ngraph.opset1.ops import reduce_max +from ngraph.opset1.ops import reduce_mean +from ngraph.opset1.ops import reduce_min +from ngraph.opset1.ops import reduce_prod +from ngraph.opset1.ops import reduce_sum +from ngraph.opset1.ops import region_yolo +from ngraph.opset2.ops import reorg_yolo +from ngraph.opset1.ops import relu +from ngraph.opset1.ops import reshape +from ngraph.opset1.ops import result +from ngraph.opset1.ops import reverse_sequence +from ngraph.opset3.ops import rnn_cell +from ngraph.opset5.ops import rnn_sequence +from ngraph.opset3.ops import roi_align +from ngraph.opset2.ops import roi_pooling +from ngraph.opset7.ops import roll +from ngraph.opset5.ops import round +from ngraph.opset3.ops import scatter_elements_update +from ngraph.opset3.ops import scatter_update +from ngraph.opset1.ops import select +from ngraph.opset1.ops import selu +from ngraph.opset3.ops import shape_of +from ngraph.opset3.ops import shuffle_channels +from ngraph.opset1.ops import sigmoid +from ngraph.opset1.ops import sign +from ngraph.opset1.ops import sin +from ngraph.opset1.ops import sinh +from ngraph.opset1.ops import softmax +from ngraph.opset4.ops import softplus +from ngraph.opset2.ops import space_to_batch +from ngraph.opset1.ops import space_to_depth +from ngraph.opset1.ops import split +from ngraph.opset1.ops import sqrt +from ngraph.opset1.ops import squared_difference +from ngraph.opset1.ops import squeeze +from ngraph.opset1.ops import strided_slice +from ngraph.opset1.ops import subtract +from ngraph.opset4.ops import swish +from ngraph.opset1.ops import tan +from ngraph.opset1.ops import tanh +from ngraph.opset1.ops import tensor_iterator +from ngraph.opset1.ops import tile +from ngraph.opset3.ops import topk +from ngraph.opset1.ops import transpose +from ngraph.opset1.ops import unsqueeze +from ngraph.opset1.ops import variadic_split diff --git a/ngraph/python/src/ngraph/opset8/ops.py b/ngraph/python/src/ngraph/opset8/ops.py new file mode 100644 index 00000000000000..d375d752850e97 --- /dev/null +++ b/ngraph/python/src/ngraph/opset8/ops.py @@ -0,0 +1,101 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +"""Factory functions for all ngraph ops.""" +from functools import partial +from typing import Callable, Iterable, List, Optional, Set, Union + +import numpy as np +from ngraph.impl import Node, Shape +from ngraph.impl.op import Constant, Parameter +from ngraph.opset_utils import _get_node_factory +from ngraph.utils.decorators import binary_op, nameable_op, unary_op +from ngraph.utils.input_validation import ( + assert_list_of_ints, + check_valid_attributes, + is_non_negative_value, + is_positive_value, +) +from ngraph.utils.node_factory import NodeFactory +from ngraph.utils.tensor_iterator_types import ( + GraphBody, + TensorIteratorSliceInputDesc, + TensorIteratorMergedInputDesc, + TensorIteratorInvariantInputDesc, + TensorIteratorBodyOutputDesc, + TensorIteratorConcatOutputDesc, +) +from ngraph.utils.types import ( + NodeInput, + NumericData, + NumericType, + ScalarData, + TensorShape, + as_node, + as_nodes, + get_dtype, + get_element_type, + get_element_type_str, + make_constant_node, +) + +_get_node_factory_opset8 = partial(_get_node_factory, "opset8") + + +# -------------------------------------------- ops ------------------------------------------------ + + +@nameable_op +def deformable_convolution( + data: NodeInput, + offsets: NodeInput, + filters: NodeInput, + strides: List[int], + pads_begin: List[int], + pads_end: List[int], + dilations: List[int], + mask: Optional[NodeInput] = None, + auto_pad: str = "EXPLICIT", + group: int = 1, + deformable_group: int = 1, + bilinear_interpolation_pad: bool = False, + name: Optional[str] = None, +) -> Node: + """Return a node which performs deformable convolution operation. + + @param data: The node providing data batch tensor. + @param offsets: The node providing offset tensor. + @param filters: The node providing filters tensor. + @param strides: The distance (in pixels) to slide the filter on the feature map over the axes. + @param pads_begin: The number of pixels to add to the beginning along each axis. + @param pads_end: The number of pixels to add to the end along each axis. + @param dilations: The distance in width and height between elements (weights) in the filter. + @param mask: The node providing modulation scalar (mask) tensor. + @param auto_pad: The type of padding. Range of values: explicit, same_upper, same_lower, valid. + @param group: The number of groups which both output and input should be split into. + @param deformable_group: The number of groups which deformable values and output should be split + into along the channel axis. + @param bilinear_interpolation_pad: The flag that determines the mode of bilinear interpolation + execution. + @param name: The optional new name for output node. + @return New node performing deformable convolution operation. + """ + if mask is None: + inputs = as_nodes(data, offsets, filters) + else: + inputs = as_nodes(data, offsets, filters, mask) + + return _get_node_factory_opset8().create( + "DeformableConvolution", + inputs, + { + "strides": strides, + "pads_begin": pads_begin, + "pads_end": pads_end, + "dilations": dilations, + "auto_pad": auto_pad, + "group": group, + "deformable_group": deformable_group, + "bilinear_interpolation_pad": bilinear_interpolation_pad + }, + ) diff --git a/ngraph/python/src/ngraph/utils/node_factory.py b/ngraph/python/src/ngraph/utils/node_factory.py index bfac8c5bdca9a3..67e1825a4b32ba 100644 --- a/ngraph/python/src/ngraph/utils/node_factory.py +++ b/ngraph/python/src/ngraph/utils/node_factory.py @@ -8,7 +8,7 @@ from ngraph.impl import Node, Output -DEFAULT_OPSET = "opset6" +DEFAULT_OPSET = "opset8" class NodeFactory(object): diff --git a/ngraph/python/src/pyngraph/node_factory.cpp b/ngraph/python/src/pyngraph/node_factory.cpp index 0e90989dc3e7d3..0f3a10dde6971e 100644 --- a/ngraph/python/src/pyngraph/node_factory.cpp +++ b/ngraph/python/src/pyngraph/node_factory.cpp @@ -75,6 +75,7 @@ namespace {"opset5", OpsetFunction(ngraph::get_opset5)}, {"opset6", OpsetFunction(ngraph::get_opset6)}, {"opset7", OpsetFunction(ngraph::get_opset7)}, + {"opset8", OpsetFunction(ngraph::get_opset8)}, }; auto it = s_opsets.find(opset_ver); diff --git a/ngraph/python/tests/test_ngraph/test_create_op.py b/ngraph/python/tests/test_ngraph/test_create_op.py index 7d430782e42a13..e3a9c9a157e564 100644 --- a/ngraph/python/tests/test_ngraph/test_create_op.py +++ b/ngraph/python/tests/test_ngraph/test_create_op.py @@ -104,6 +104,31 @@ def test_ctc_greedy_decoder_seq_len(fp_dtype, int_dtype, int_ci, int_sl, merge_r assert list(node.get_output_shape(0)) == expected_shape +@pytest.mark.parametrize("dtype", np_types) +def test_deformable_convolution_opset1(dtype): + strides = np.array([1, 1]) + pads_begin = np.array([0, 0]) + pads_end = np.array([0, 0]) + dilations = np.array([1, 1]) + + input0_shape = [1, 1, 9, 9] + input1_shape = [1, 18, 7, 7] + input2_shape = [1, 1, 3, 3] + expected_shape = [1, 1, 7, 7] + + parameter_input0 = ng.parameter(input0_shape, name="Input0", dtype=dtype) + parameter_input1 = ng.parameter(input1_shape, name="Input1", dtype=dtype) + parameter_input2 = ng.parameter(input2_shape, name="Input2", dtype=dtype) + + node = ng_opset1.deformable_convolution( + parameter_input0, parameter_input1, parameter_input2, strides, pads_begin, pads_end, dilations, + ) + + assert node.get_type_name() == "DeformableConvolution" + assert node.get_output_size() == 1 + assert list(node.get_output_shape(0)) == expected_shape + + @pytest.mark.parametrize("dtype", np_types) def test_deformable_convolution(dtype): strides = np.array([1, 1]) @@ -129,6 +154,34 @@ def test_deformable_convolution(dtype): assert list(node.get_output_shape(0)) == expected_shape +@pytest.mark.parametrize("dtype", np_types) +def test_deformable_convolution_mask(dtype): + strides = np.array([1, 1]) + pads_begin = np.array([0, 0]) + pads_end = np.array([0, 0]) + dilations = np.array([1, 1]) + + input0_shape = [1, 1, 9, 9] + input1_shape = [1, 18, 7, 7] + input2_shape = [1, 1, 3, 3] + input3_shape = [1, 9, 7, 7] + expected_shape = [1, 1, 7, 7] + + parameter_input0 = ng.parameter(input0_shape, name="Input0", dtype=dtype) + parameter_input1 = ng.parameter(input1_shape, name="Input1", dtype=dtype) + parameter_input2 = ng.parameter(input2_shape, name="Input2", dtype=dtype) + parameter_input3 = ng.parameter(input3_shape, name="Input3", dtype=dtype) + + node = ng.deformable_convolution( + parameter_input0, parameter_input1, parameter_input2, strides, + pads_begin, pads_end, dilations, parameter_input3 + ) + + assert node.get_type_name() == "DeformableConvolution" + assert node.get_output_size() == 1 + assert list(node.get_output_shape(0)) == expected_shape + + @pytest.mark.parametrize("dtype", np_types) def test_deformable_psroi_pooling(dtype): output_dim = 8 diff --git a/ngraph/python/tests/test_onnx/test_ops_unary.py b/ngraph/python/tests/test_onnx/test_ops_unary.py index 01c9eeb9f55888..22d6b54f539c29 100644 --- a/ngraph/python/tests/test_onnx/test_ops_unary.py +++ b/ngraph/python/tests/test_onnx/test_ops_unary.py @@ -390,8 +390,7 @@ def test_cast_errors(): for name, value in zip(node.input, [input_data]) ] output_tensors = [ - make_tensor_value_info(name, onnx.TensorProto.FLOAT16, value.shape) - for name, value in zip(node.output, ()) + make_tensor_value_info(node.output[0], onnx.TensorProto.FLOAT16, input_data.shape) ] # type: ignore graph = make_graph([node], "compute_graph", input_tensors, output_tensors) @@ -406,8 +405,7 @@ def test_cast_errors(): for name, value in zip(node.input, [input_data]) ] output_tensors = [ - make_tensor_value_info(name, onnx.TensorProto.INT32, value.shape) - for name, value in zip(node.output, ()) + make_tensor_value_info(node.output[0], onnx.TensorProto.INT32, input_data.shape) ] # type: ignore graph = make_graph([node], "compute_graph", input_tensors, output_tensors) @@ -422,8 +420,7 @@ def test_cast_errors(): for name, value in zip(node.input, [input_data]) ] output_tensors = [ - make_tensor_value_info(name, onnx.TensorProto.INT32, value.shape) - for name, value in zip(node.output, ()) + make_tensor_value_info(node.output[0], onnx.TensorProto.INT32, input_data.shape) ] # type: ignore graph = make_graph([node], "compute_graph", input_tensors, output_tensors) @@ -438,8 +435,7 @@ def test_cast_errors(): for name, value in zip(node.input, [input_data]) ] output_tensors = [ - make_tensor_value_info(name, onnx.TensorProto.COMPLEX128, value.shape) - for name, value in zip(node.output, ()) + make_tensor_value_info(node.output[0], onnx.TensorProto.COMPLEX128, input_data.shape) ] # type: ignore graph = make_graph([node], "compute_graph", input_tensors, output_tensors) diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index 21eef623fbf911..bf39436175f7a8 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -75,13 +75,10 @@ set(SRC op_eval/strided_slice.cpp op_eval/transpose.cpp op_eval/variadic_split.cpp - op_is.cpp opset1.cpp partial_shape.cpp pass_config.cpp - pass_liveness.cpp pass_manager.cpp - pass_shape_relevance.cpp pattern.cpp provenance.cpp replace_node.cpp @@ -95,7 +92,9 @@ set(SRC type_prop/adaptive_avg_pool.cpp type_prop/adaptive_max_pool.cpp type_prop/asin.cpp + type_prop/asinh.cpp type_prop/assign.cpp + type_prop/atan.cpp type_prop/avg_pool.cpp type_prop/batch_norm.cpp type_prop/batch_to_space.cpp @@ -111,6 +110,7 @@ set(SRC type_prop/convolution.cpp type_prop/convolution_backprop_data.cpp type_prop/cos.cpp + type_prop/cosh.cpp type_prop/ctc_greedy_decoder.cpp type_prop/ctc_greedy_decoder_seq_len.cpp type_prop/ctc_loss.cpp @@ -156,11 +156,13 @@ set(SRC type_prop/lstm_sequence.cpp type_prop/loop.cpp type_prop/matmul.cpp + type_prop/matrix_nms.cpp type_prop/maximum.cpp type_prop/max_pool.cpp type_prop/minimum.cpp type_prop/mish.cpp type_prop/mod.cpp + type_prop/multiclass_nms.cpp type_prop/mvn.cpp type_prop/negative.cpp type_prop/non_max_suppression.cpp @@ -171,6 +173,7 @@ set(SRC type_prop/parameter.cpp type_prop/power.cpp type_prop/prelu.cpp + type_prop/prior_box.cpp type_prop/proposal.cpp type_prop/psroi_pooling.cpp type_prop/range.cpp @@ -204,6 +207,7 @@ set(SRC type_prop/shape_of.cpp type_prop/shuffle_channels.cpp type_prop/sin.cpp + type_prop/sinh.cpp type_prop/softmax.cpp type_prop/softplus.cpp type_prop/space_to_batch.cpp @@ -226,7 +230,10 @@ set(SRC visitors/value_map.cpp visitors/op/adaptive_avg_pool.cpp visitors/op/adaptive_max_pool.cpp + visitors/op/asinh.cpp + visitors/op/atan.cpp visitors/op/batch_norm.cpp + visitors/op/batch_to_space.cpp visitors/op/broadcast.cpp visitors/op/bucketize.cpp visitors/op/ceiling.cpp @@ -234,6 +241,7 @@ set(SRC visitors/op/convert.cpp visitors/op/convolution_backprop.cpp visitors/op/cos.cpp + visitors/op/cosh.cpp visitors/op/cum_sum.cpp visitors/op/deformable_convolution.cpp visitors/op/deformable_psroi_pooling.cpp @@ -255,9 +263,11 @@ set(SRC visitors/op/lstm_cell.cpp visitors/op/lstm_sequence.cpp visitors/op/matmul.cpp + visitors/op/matrix_nms.cpp visitors/op/max_pool.cpp visitors/op/mish.cpp visitors/op/mod.cpp + visitors/op/multiclass_nms.cpp visitors/op/mvn.cpp visitors/op/negative.cpp visitors/op/non_max_suppression.cpp @@ -290,6 +300,7 @@ set(SRC visitors/op/space_to_depth.cpp visitors/op/selu.cpp visitors/op/shuffle_channels.cpp + visitors/op/sinh.cpp visitors/op/softmax.cpp visitors/op/softplus.cpp visitors/op/space_to_batch.cpp @@ -368,6 +379,7 @@ set(MULTI_TEST_SRC backend/auto_broadcast.in.cpp backend/avg_pool.in.cpp backend/batch_norm.in.cpp + backend/batch_to_space.in.cpp backend/broadcast.in.cpp backend/bucketize.in.cpp backend/builder_reduce_ops_opset1.in.cpp @@ -375,7 +387,6 @@ set(MULTI_TEST_SRC backend/comparison.in.cpp backend/concat.in.cpp backend/constant.in.cpp - backend/convert.in.cpp backend/convert_like.in.cpp backend/convolution_backprop.in.cpp backend/convolution.in.cpp @@ -424,11 +435,13 @@ set(MULTI_TEST_SRC backend/logical_xor.in.cpp backend/lrn.in.cpp backend/matmul.in.cpp + backend/matrix_nms.in.cpp backend/maximum.in.cpp backend/max_pool.in.cpp backend/minimum.in.cpp backend/mish.in.cpp backend/mod.in.cpp + backend/multiclass_nms.in.cpp backend/multiple_backends.in.cpp backend/multiple_result.in.cpp backend/multiply.in.cpp @@ -444,6 +457,7 @@ set(MULTI_TEST_SRC backend/parameter_as_output.in.cpp backend/power.in.cpp backend/prelu.in.cpp + backend/prior_box.in.cpp backend/proposal.in.cpp backend/psroi_pooling.in.cpp backend/range.in.cpp @@ -533,27 +547,9 @@ set(SRC ${FRONTEND_SHARED_TESTS_SRC} ${SRC}) # ---- PaddlePaddle FrontEnd testing ------ if (NGRAPH_PDPD_FRONTEND_ENABLE) - find_package (PythonInterp 3 REQUIRED) - set(PDPD_PYTHON_OK TRUE) - if(NOT PYTHON_EXECUTABLE) - message("Python3 is required to build the PDPD frontend unit tests") - set(PDPD_PYTHON_OK FALSE) - endif() - - if (PDPD_PYTHON_OK) - execute_process( - COMMAND ${PYTHON_EXECUTABLE} -m pip show paddlepaddle - RESULT_VARIABLE PIP_EXIT_CODE - OUTPUT_QUIET - ) - - if (NOT ${PIP_EXIT_CODE} EQUAL 0) - message("Python paddlepaddle package is not installed. Please use \"pip install paddlepaddle==2.0.1\".") - set(PDPD_PYTHON_OK FALSE) - endif() - endif() + ie_check_pip_package(paddlepaddle WARNING) - if (PDPD_PYTHON_OK) + if(paddlepaddle_FOUND) file(GLOB FRONTEND_PDPD_TESTS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/frontend/paddlepaddle/*.cpp) set(SRC ${FRONTEND_PDPD_TESTS_SRC} ${SRC}) set(TEST_PDPD_MODELS ${CMAKE_CURRENT_BINARY_DIR}/pdpd_test_models/) @@ -583,6 +579,7 @@ add_executable(unit-test ${SRC}) target_include_directories(unit-test PRIVATE ".") target_include_directories(unit-test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/runtime) +target_include_directories(unit-test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/frontend/shared/include) add_definitions("-DCURDIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"") add_definitions("-DJSON_INCLUDES=\"${JSON_INCLUDE_DIR}\"") @@ -651,12 +648,13 @@ install(TARGETS unit-test ############ FRONTEND ############ target_include_directories(unit-test PRIVATE ${FRONTEND_INCLUDE_PATH}) target_link_libraries(unit-test PRIVATE frontend_manager) +target_link_libraries(unit-test PRIVATE cnpy) add_subdirectory(frontend) ### END FRONTEND ### #PaddlePaddle - test models generator -if (NGRAPH_PDPD_FRONTEND_ENABLE AND PDPD_PYTHON_OK) +if (NGRAPH_PDPD_FRONTEND_ENABLE AND paddlepaddle_FOUND) file(GLOB_RECURSE PDPD_GEN_SCRIPTS ${CMAKE_CURRENT_SOURCE_DIR}/files/paddlepaddle/gen_scripts/generate_*.py) set(OUT_FILES "") foreach(GEN_SCRIPT ${PDPD_GEN_SCRIPTS}) diff --git a/ngraph/test/backend/asinh.in.cpp b/ngraph/test/backend/asinh.in.cpp index 5cde50b53bbcfe..d3e8fe44c88c17 100644 --- a/ngraph/test/backend/asinh.in.cpp +++ b/ngraph/test/backend/asinh.in.cpp @@ -49,3 +49,18 @@ NGRAPH_TEST(${BACKEND_NAME}, asinh) test_case.add_expected_output(shape, expected); test_case.run(); } + +NGRAPH_TEST(${BACKEND_NAME}, asinh_i32) +{ + Shape shape{11}; + auto A = make_shared(element::i32, shape); + auto f = make_shared(make_shared(A), ParameterVector{A}); + + vector input{-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5}; + vector expected{-2, -2, -2, -1, -1, 0, 1, 1, 2, 2, 2}; + + auto test_case = test::TestCase(f); + test_case.add_input(input); + test_case.add_expected_output(shape, expected); + test_case.run(); +} diff --git a/ngraph/test/backend/atan.in.cpp b/ngraph/test/backend/atan.in.cpp index 8a8f29bd0abbf2..5c5e4f79bfcbff 100644 --- a/ngraph/test/backend/atan.in.cpp +++ b/ngraph/test/backend/atan.in.cpp @@ -31,7 +31,7 @@ using namespace ngraph; static string s_manifest = "${MANIFEST}"; using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); -NGRAPH_TEST(${BACKEND_NAME}, atan) +NGRAPH_TEST(${BACKEND_NAME}, atan_float) { Shape shape{11}; auto A = make_shared(element::f32, shape); @@ -53,3 +53,16 @@ NGRAPH_TEST(${BACKEND_NAME}, atan) 1.32581766f}); test_case.run(); } + +NGRAPH_TEST(${BACKEND_NAME}, atan_int) +{ + Shape shape{5}; + auto A = make_shared(element::i32, shape); + auto f = make_shared(make_shared(A), ParameterVector{A}); + + auto test_case = test::TestCase(f); + test_case.add_input({-2, -1, 0, 1, 2}); + test_case.add_expected_output(shape, + {-1, -1, 0, 1, 1}); + test_case.run(); +} diff --git a/ngraph/test/backend/batch_to_space.in.cpp b/ngraph/test/backend/batch_to_space.in.cpp new file mode 100644 index 00000000000000..91fbbafed53d2b --- /dev/null +++ b/ngraph/test/backend/batch_to_space.in.cpp @@ -0,0 +1,200 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" +#include "ngraph/ngraph.hpp" +#include "util/ndarray.hpp" +#include "util/test_case.hpp" +#include "util/engine/test_engines.hpp" +#include "util/test_control.hpp" + +using namespace std; +using namespace ngraph; + +static string s_manifest = "${MANIFEST}"; +using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); + +namespace +{ + template + struct BatchToSpaceParams + { + using Data = test::NDArrayBase; + using BlockShape = test::NDArrayBase; + using Crops = test::NDArrayBase; + + BatchToSpaceParams(Data in_data, + BlockShape block_shape, + Crops crops_begin, + Crops crops_end, + Data expected_output) + : m_data{std::move(in_data)} + , m_block_shape{std::move(block_shape)} + , m_crops_begin{std::move(crops_begin)} + , m_crops_end{std::move(crops_end)} + , m_expected_output{std::move(expected_output)} + { + } + + Data m_data; + BlockShape m_block_shape; + Crops m_crops_begin; + Crops m_crops_end; + Data m_expected_output; + }; + + template + static void BatchToSpaceTestExecute(const BatchToSpaceParams& params) + { + const auto data = + make_shared(element::from(), params.m_data.get_shape()); + + const auto block_shape = op::Constant::create( + element::i64, params.m_block_shape.get_shape(), params.m_block_shape.get_vector()); + + const auto crops_begin = op::Constant::create( + element::i64, params.m_crops_begin.get_shape(), params.m_crops_begin.get_vector()); + + const auto crops_end = op::Constant::create( + element::i64, params.m_crops_end.get_shape(), params.m_crops_end.get_vector()); + + const auto batch_to_space = + make_shared(data, block_shape, crops_begin, crops_end); + + auto f = make_shared(batch_to_space, ParameterVector{data}); + auto test_case = test::TestCase(f); + test_case.add_input(params.m_data.get_vector()); + test_case.add_expected_output(params.m_expected_output.get_vector()); + test_case.run_with_tolerance_as_fp(1e-4f); + } + + class BatchToSpaceTestFloat : public testing::TestWithParam> + { + }; +} // namespace + +NGRAPH_TEST_P(${BACKEND_NAME}, BatchToSpaceTestFloat, BatchToSpaceTestFloatCases) +{ + BatchToSpaceTestExecute(GetParam()); +} + +const test::NDArray input_with_shape_4x3( + {{1.0f, 2.0f, 3.0f}, + {4.0f, 5.0f, 6.0f}, + {7.0f, 8.0f, 9.0f}, + {10.0f, 11.0f, 12.0f}}); + +const test::NDArray zero_crops_2d({0, 0}); + +NGRAPH_INSTANTIATE_TEST_SUITE_P( + ${BACKEND_NAME}, + batch_to_space_2d_without_crops, + BatchToSpaceTestFloat, + testing::Values( + BatchToSpaceParams{input_with_shape_4x3, + test::NDArray({1, 2}), + zero_crops_2d, + zero_crops_2d, + test::NDArray( + {{1.0f, 7.0f, 2.0f, 8.0f, 3.0f, 9.0f}, + {4.0f, 10.0f, 5.0f, 11.0f, 6.0f, 12.0f}})})); + +const test::NDArray input_with_shape_4x1x1x3( + {{{{1.0f, 2.0f, 3.0f}}}, + {{{4.0f, 5.0f, 6.0f}}}, + {{{7.0f, 8.0f, 9.0f}}}, + {{{10.0f, 11.0f, 12.0f}}}}); + +const test::NDArray input_with_shape_4x1x2x3( + {{{{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, 21.0f}, {22.0f, 23.0f, 24.0f}}}}); + +const test::NDArray zero_crops_4d({0, 0, 0, 0}); + +NGRAPH_INSTANTIATE_TEST_SUITE_P( + ${BACKEND_NAME}, + batch_to_space_4d_without_crops, + BatchToSpaceTestFloat, + testing::Values( + BatchToSpaceParams{input_with_shape_4x1x1x3, + test::NDArray({1, 1, 1, 2}), + zero_crops_4d, + zero_crops_4d, + test::NDArray( + {{{{1.0f, 7.0f, 2.0f, 8.0f, 3.0f, 9.0f}}}, + {{{4.0f, 10.0f, 5.0f, 11.0f, 6.0f, 12.0f}}}})}, + BatchToSpaceParams{input_with_shape_4x1x1x3, + test::NDArray({1, 1, 2, 1}), + zero_crops_4d, + zero_crops_4d, + test::NDArray( + {{{{1.0f, 2.0f, 3.0f}, {7.0f, 8.0f, 9.0f}}}, + {{{4.0f, 5.0f, 6.0f}, {10.0f, 11.0f, 12.0f}}}})}, + BatchToSpaceParams{input_with_shape_4x1x1x3, + test::NDArray({1, 1, 2, 2}), + zero_crops_4d, + zero_crops_4d, + test::NDArray( + {{{{1.0f, 4.0f, 2.0f, 5.0f, 3.0f, 6.0f}, + {7.0f, 10.0f, 8.0f, 11.0f, 9.0f, 12.0f}}}})}, + BatchToSpaceParams{input_with_shape_4x1x2x3, + test::NDArray({1, 1, 1, 2}), + zero_crops_4d, + zero_crops_4d, + test::NDArray( + {{{{1.0f, 13.0f, 2.0f, 14.0f, 3.0f, 15.0f}, + {4.0f, 16.0f, 5.0f, 17.0f, 6.0f, 18.0f}}}, + {{{7.0f, 19.0f, 8.0f, 20.0f, 9.0f, 21.0f}, + {10.0f, 22.0f, 11.0f, 23.0f, 12.0f, 24.0f}}}})}, + BatchToSpaceParams{input_with_shape_4x1x2x3, + test::NDArray({1, 1, 2, 1}), + zero_crops_4d, + zero_crops_4d, + test::NDArray( + {{{{1.0f, 2.0f, 3.0f}, {13.0f, 14.0f, 15.0f}, + {4.0f, 5.0f, 6.0f}, {16.0f, 17.0f, 18.0f}}}, + {{{7.0f, 8.0f, 9.0f}, {19.0f, 20.0f, 21.0f}, + {10.0f, 11.0f, 12.0f}, {22.0f, 23.0f, 24.0f}}}})}, + BatchToSpaceParams{input_with_shape_4x1x2x3, + test::NDArray({1, 1, 2, 2}), + zero_crops_4d, + zero_crops_4d, + test::NDArray( + {{{{1.0f, 7.0f, 2.0f, 8.0f, 3.0f, 9.0f}, + {13.0f, 19.0f, 14.0f, 20.0f, 15.0f, 21.0f}, + {4.0f, 10.0f, 5.0f, 11.0f, 6.0f, 12.0f}, + {16.0f, 22.0f, 17.0f, 23.0f, 18.0f, 24.0f}}}})})); + +NGRAPH_INSTANTIATE_TEST_SUITE_P( + ${BACKEND_NAME}, + batch_to_space_4d_crops, + BatchToSpaceTestFloat, + testing::Values( + BatchToSpaceParams{input_with_shape_4x1x2x3, + test::NDArray({1, 1, 2, 2}), + test::NDArray({0, 0, 0, 0}), + test::NDArray({0, 0, 0, 2}), + test::NDArray( + {{{{1.0f, 7.0f, 2.0f, 8.0f}, + {13.0f, 19.0f, 14.0f, 20.0f}, + {4.0f, 10.0f, 5.0f, 11.0f}, + {16.0f, 22.0f, 17.0f, 23.0f}}}})}, + BatchToSpaceParams{input_with_shape_4x1x2x3, + test::NDArray({1, 1, 2, 2}), + test::NDArray({0, 0, 0, 2}), + test::NDArray({0, 0, 0, 0}), + test::NDArray( + {{{{2.0f, 8.0f, 3.0f, 9.0f}, + {14.0f, 20.0f, 15.0f, 21.0f}, + {5.0f, 11.0f, 6.0f, 12.0f}, + {17.0f, 23.0f, 18.0f, 24.0f}}}})}, + BatchToSpaceParams{input_with_shape_4x1x2x3, + test::NDArray({1, 1, 2, 2}), + test::NDArray({0, 0, 1, 0}), + test::NDArray({0, 0, 1, 0}), + test::NDArray( + {{{{13.0f, 19.0f, 14.0f, 20.0f, 15.0f, 21.0f}, + {4.0f, 10.0f, 5.0f, 11.0f, 6.0f, 12.0f}}}})})); diff --git a/ngraph/test/backend/convert.in.cpp b/ngraph/test/backend/convert.in.cpp deleted file mode 100644 index 20cb1d16953d20..00000000000000 --- a/ngraph/test/backend/convert.in.cpp +++ /dev/null @@ -1,1547 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" -#include "ngraph/runtime/reference/convert.hpp" -#include "ngraph/runtime/tensor.hpp" -#include "runtime/backend.hpp" -#include "util/all_close.hpp" -#include "util/all_close_f.hpp" -#include "util/engine/test_engines.hpp" -#include "util/ndarray.hpp" -#include "util/test_case.hpp" -#include "util/test_control.hpp" -#include "util/test_tools.hpp" - -using namespace std; -using namespace ngraph; - -static string s_manifest = "${MANIFEST}"; - -using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); -namespace -{ - std::shared_ptr CreateFunction(const Shape& input_shape, - const element::Type& input_type, - const element::Type& expected_output_type) - { - const auto in = make_shared(input_type, input_shape); - const auto convert = make_shared(in, expected_output_type); - return make_shared(NodeVector{convert}, ParameterVector{in}); - } - - template - void ConvertTest(const std::vector& input, - const Shape& input_shape, - const ngraph::element::Type& input_type, - const std::vector& expected_output, - const ngraph::element::Type& expected_output_type) - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto test_case = test::TestCase(f); - test_case.add_input(input); - test_case.add_expected_output(expected_output); - - test_case.run(); - } - - // TestCase doesn't support LP types - template - void LPConvertTest(const std::vector& input, - const Shape& input_shape, - const ngraph::element::Type& input_type, - const std::vector& expected_output, - const ngraph::element::Type& expected_output_type) - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(uint8_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} // namespace - -// destination: boolean -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_boolean) -{ - const uint8_t lowest = std::numeric_limits::lowest(); - const uint8_t max = std::numeric_limits::max(); - - const std::vector input{0, 12, 23, 0, lowest, max}; - const Shape input_shape{2, 3}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{0, 1, 1, 0, 0, 1}; - const element::Type expected_output_type = ngraph::element::boolean; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i32_to_boolean) -{ - const int32_t lowest = std::numeric_limits::lowest(); - const int32_t max = std::numeric_limits::max(); - - const std::vector input{0, -12, 23, 0, lowest, max}; - const Shape input_shape{2, 3}; - const element::Type input_type = ngraph::element::i32; - - const std::vector expected_output{0, 1, 1, 0, 1, 1}; - const element::Type expected_output_type = ngraph::element::boolean; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_f32_to_boolean) -{ - const float lowest = std::numeric_limits::lowest(); - const float max = std::numeric_limits::max(); - const float min = std::numeric_limits::min(); - const float pos_inf = std::numeric_limits::infinity(); - const float neg_inf = -std::numeric_limits::infinity(); - - const std::vector input{0.f, 1.5745f, 0.12352f, 0.f, lowest, max, min, pos_inf, neg_inf}; - const Shape input_shape{3, 3}; - const element::Type input_type = ngraph::element::f32; - - const std::vector expected_output{0, 1, 1, 0, 1, 1, 1, 1, 1}; - const element::Type expected_output_type = ngraph::element::boolean; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: bf16 -NGRAPH_TEST(${BACKEND_NAME}, convert_f32_to_bf16) -{ - const std::vector input{ - 0.5f, 1.5f, 0.5f, 2.5f, 1.5f, 0.5f, 3.5f, 2.5f, 0.5f, 0.5f, 2.5f, 0.5f, 0.5f, 0.5f, 1.5f}; - const Shape input_shape{1, 1, 3, 5}; - const element::Type input_type = ngraph::element::f32; - - const std::vector expected_output(std::begin(input), std::end(input)); - const element::Type expected_output_type = ngraph::element::bf16; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: f16 -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_f16) -{ - const std::vector input{0, 10, 15, 20, 43, 56, 78, 99, 102, 130, 142}; - const Shape input_shape{11}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{0, 10, 15, 20, 43, 56, 78, 99, 102, 130, 142}; - const element::Type expected_output_type = ngraph::element::f16; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: f32 -NGRAPH_TEST(${BACKEND_NAME}, convert_i4_to_f32) -{ - const std::vector input{0xFE, 0xF2}; - const Shape input_shape{2, 2}; - const element::Type input_type = ngraph::element::i4; - - const std::vector expected_output{-1.0f, -2.0f, -1.0f, 2.0f}; - const element::Type expected_output_type = ngraph::element::f32; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(float)); - EXPECT_TRUE(test::all_close_f(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i8_to_f32) -{ - const std::vector input{-127, -0, 0, 127}; - const Shape input_shape{2, 2}; - const element::Type input_type = ngraph::element::i8; - - const std::vector expected_output{-127.0f, -0.0f, 0.0f, 127.0f}; - const element::Type expected_output_type = ngraph::element::f32; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i16_to_f32) -{ - const std::vector input{-32000, -0, 0, 32000}; - const Shape input_shape{2, 2}; - const element::Type input_type = ngraph::element::i16; - - const std::vector expected_output{-32000.0f, -0.0f, 0.0f, 32000.0f}; - const element::Type expected_output_type = ngraph::element::f32; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i32_to_f32) -{ - const std::vector input{-64000, -0, 0, 64000}; - const Shape input_shape{2, 2}; - const element::Type input_type = ngraph::element::i32; - - const std::vector expected_output{-64000.0f, -0.0f, 0.0f, 64000.0f}; - const element::Type expected_output_type = ngraph::element::f32; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i64_to_f32) -{ - const std::vector input{-64000, -0, 0, 64000}; - const Shape input_shape{2, 2}; - const element::Type input_type = ngraph::element::i64; - - const std::vector expected_output{-64000.0f, -0.0f, 0.0f, 64000.0f}; - const element::Type expected_output_type = ngraph::element::f32; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u1_to_f32) -{ - const std::vector input{0xA0}; - const Shape input_shape{2, 2}; - const element::Type input_type = ngraph::element::u1; - - const std::vector expected_output{1.0f, 0.0f, 1.0f, 0.0f}; - const element::Type expected_output_type = ngraph::element::f32; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(float)); - EXPECT_TRUE(test::all_close_f(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u4_to_f32) -{ - const std::vector input{0xFB, 0x0A}; - const Shape input_shape{2, 2}; - const element::Type input_type = ngraph::element::u4; - - const std::vector expected_output{15.0f, 11.0f, 0.0f, 10.0f}; - const element::Type expected_output_type = ngraph::element::f32; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(float)); - EXPECT_TRUE(test::all_close_f(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_f32) -{ - const std::vector input{255, 128, 32, 0}; - const Shape input_shape{2, 2}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{255.0f, 128.0f, 32.0f, 0.0f}; - const element::Type expected_output_type = ngraph::element::f32; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u16_to_f32) -{ - const std::vector input{64000, 32000, 128, 0}; - const Shape input_shape{2, 2}; - const element::Type input_type = ngraph::element::u16; - - const std::vector expected_output{64000.0f, 32000.0f, 128.0f, 0.0f}; - const element::Type expected_output_type = ngraph::element::f32; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u32_to_f32) -{ - const std::vector input{4000000, 2000000, 128, 0}; - const Shape input_shape{2, 2}; - const element::Type input_type = ngraph::element::u32; - - const std::vector expected_output{4000000.0f, 2000000.0f, 128.0f, 0.0f}; - const element::Type expected_output_type = ngraph::element::f32; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u64_to_f32) -{ - const std::vector input{4000000, 2000000, 128, 0}; - const Shape input_shape{2, 2}; - const element::Type input_type = ngraph::element::u64; - - const std::vector expected_output{4000000.0f, 2000000.0f, 128.0f, 0.0f}; - const element::Type expected_output_type = ngraph::element::f32; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_bf16_to_f32) -{ - const std::vector input{ - 0.5, 1.5, 0.5, 2.5, 1.5, 0.5, 3.5, 2.5, 0.5, 0.5, 2.5, 0.5, 0.5, 0.5, 1.5}; - const Shape input_shape{1, 1, 3, 5}; - const element::Type input_type = ngraph::element::bf16; - - const std::vector expected_output(std::begin(input), std::end(input)); - const element::Type expected_output_type = ngraph::element::f32; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_f16_to_f32) -{ - const std::vector input{-20.5, -15, -10.5, -0.5, 0, 0.5, 10.5, 15, 20.5}; - const Shape input_shape{3, 3}; - const element::Type input_type = ngraph::element::f16; - - const std::vector expected_output{-20.5, -15, -10.5, -0.5, 0, 0.5, 10.5, 15, 20.5}; - const element::Type expected_output_type = ngraph::element::f32; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_f32_to_f32) -{ - const std::vector input{-20.5, -15, -10.5, -0.5, 0, 0.5, 10.5, 15, 20.5}; - const Shape input_shape{3, 3}; - const element::Type input_type = ngraph::element::f32; - - const std::vector expected_output{-20.5, -15, -10.5, -0.5, 0, 0.5, 10.5, 15, 20.5}; - const element::Type expected_output_type = ngraph::element::f32; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: i4 -NGRAPH_TEST(${BACKEND_NAME}, convert_u1_to_i4) -{ - const std::vector input{0xA0}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u1; - - const std::vector expected_output{0x10, 0x10}; - const element::Type expected_output_type = ngraph::element::i4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u4_to_i4) -{ - const std::vector input{0x12, 0x03}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u4; - - const std::vector expected_output{0x12, 0x03}; - const element::Type expected_output_type = ngraph::element::i4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_i4) -{ - const std::vector input{1, 2, 0, 3}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{0x12, 0x03}; - const element::Type expected_output_type = ngraph::element::i4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u16_to_i4) -{ - const std::vector input{1, 2, 0, 3}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u16; - - const std::vector expected_output{0x12, 0x03}; - const element::Type expected_output_type = ngraph::element::i4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u32_to_i4) -{ - const std::vector input{1, 2, 0, 3}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u32; - - const std::vector expected_output{0x12, 0x03}; - const element::Type expected_output_type = ngraph::element::i4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u64_to_i4) -{ - const std::vector input{1, 2, 0, 3}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u64; - - const std::vector expected_output{0x12, 0x03}; - const element::Type expected_output_type = ngraph::element::i4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i8_to_i4) -{ - const std::vector input{-1, -2, 2, 3}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i8; - - const std::vector expected_output{0xFE, 0x23}; - const element::Type expected_output_type = ngraph::element::i4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i16_to_i4) -{ - const std::vector input{-1, -2, 2, 3}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i16; - - const std::vector expected_output{0xFE, 0x23}; - const element::Type expected_output_type = ngraph::element::i4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i32_to_i4) -{ - const std::vector input{-1, -2, 2, 3}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i32; - - const std::vector expected_output{0xFE, 0x23}; - const element::Type expected_output_type = ngraph::element::i4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i64_to_i4) -{ - const std::vector input{-1, -2, 2, 3}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i64; - - const std::vector expected_output{0xFE, 0x23}; - const element::Type expected_output_type = ngraph::element::i4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_f16_to_i4) -{ - const std::vector input{-1, -2, 0, 3}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::f16; - - const std::vector expected_output{0xFE, 0x03}; - const element::Type expected_output_type = ngraph::element::i4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_bf16_to_i4) -{ - const std::vector input{-1, -2, 0, 3}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::bf16; - - const std::vector expected_output{0xFE, 0x03}; - const element::Type expected_output_type = ngraph::element::i4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_f32_to_i4) -{ - const std::vector input{-1, -2, 0, 3}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::f32; - - const std::vector expected_output{0xFE, 0x03}; - const element::Type expected_output_type = ngraph::element::i4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: i8 -NGRAPH_TEST(${BACKEND_NAME}, convert_u1_to_i8) -{ - const std::vector input{0x81}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u1; - - const std::vector expected_output{1, 0, 0, 0, 0, 0, 0, 1}; - const element::Type expected_output_type = ngraph::element::i8; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(int8_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u4_to_i8) -{ - const std::vector input{0x21, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u4; - - const std::vector expected_output{2, 1, 4, 3}; - const element::Type expected_output_type = ngraph::element::i8; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(int8_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i4_to_i8) -{ - const std::vector input{0xFE, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i4; - - const std::vector expected_output{-1, -2, 4, 3}; - const element::Type expected_output_type = ngraph::element::i8; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(int8_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_i8) -{ - const std::vector input{0, 10, 15, 20, 43, 56, 78, 99, 102, 110, 128}; - const Shape input_shape{11}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{0, 10, 15, 20, 43, 56, 78, 99, 102, 110, 127}; - const element::Type expected_output_type = ngraph::element::i8; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: i16 -NGRAPH_TEST(${BACKEND_NAME}, convert_u1_to_i16) -{ - const std::vector input{0x81}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u1; - - const std::vector expected_output{1, 0, 0, 0, 0, 0, 0, 1}; - const element::Type expected_output_type = ngraph::element::i16; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(int16_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u4_to_i16) -{ - const std::vector input{0x21, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u4; - - const std::vector expected_output{2, 1, 4, 3}; - const element::Type expected_output_type = ngraph::element::i16; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(int16_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i4_to_i16) -{ - const std::vector input{0xFE, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i4; - - const std::vector expected_output{-1, -2, 4, 3}; - const element::Type expected_output_type = ngraph::element::i16; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(int16_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_i16) -{ - const std::vector input{0, 10, 15, 20, 43, 56, 78, 99, 102, 130, 142}; - const Shape input_shape{11}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{0, 10, 15, 20, 43, 56, 78, 99, 102, 130, 142}; - const element::Type expected_output_type = ngraph::element::i16; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: i32 -NGRAPH_TEST(${BACKEND_NAME}, convert_u1_to_i32) -{ - const std::vector input{0x81}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u1; - - const std::vector expected_output{1, 0, 0, 0, 0, 0, 0, 1}; - const element::Type expected_output_type = ngraph::element::i32; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(int32_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u4_to_i32) -{ - const std::vector input{0x21, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u4; - - const std::vector expected_output{2, 1, 4, 3}; - const element::Type expected_output_type = ngraph::element::i32; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(int32_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i4_to_i32) -{ - const std::vector input{0xFE, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i4; - - const std::vector expected_output{-1, -2, 4, 3}; - const element::Type expected_output_type = ngraph::element::i32; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(int32_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_i32) -{ - const std::vector input{0, 10, 15, 20, 43, 56, 78, 99, 102, 130, 142}; - const Shape input_shape{11}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{0, 10, 15, 20, 43, 56, 78, 99, 102, 130, 142}; - const element::Type expected_output_type = ngraph::element::i32; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: i64 -NGRAPH_TEST(${BACKEND_NAME}, convert_u1_to_i64) -{ - const std::vector input{0x81}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u1; - - const std::vector expected_output{1, 0, 0, 0, 0, 0, 0, 1}; - const element::Type expected_output_type = ngraph::element::i64; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(int64_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u4_to_i64) -{ - const std::vector input{0x21, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u4; - - const std::vector expected_output{2, 1, 4, 3}; - const element::Type expected_output_type = ngraph::element::i64; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(int64_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i4_to_i64) -{ - const std::vector input{0xFE, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i4; - - const std::vector expected_output{-1, -2, 4, 3}; - const element::Type expected_output_type = ngraph::element::i64; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(int64_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_i64) -{ - const std::vector input{0, 10, 15, 20, 43, 56, 78, 99, 102, 130, 142}; - const Shape input_shape{11}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{0, 10, 15, 20, 43, 56, 78, 99, 102, 130, 142}; - const element::Type expected_output_type = ngraph::element::i64; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: u1 -NGRAPH_TEST(${BACKEND_NAME}, convert_u1_to_u1) -{ - const std::vector input{0xF0}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u1; - - const std::vector expected_output{0xF0}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u4_to_u1) -{ - const std::vector input{0x10, 0x01, 0x00, 0x00}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u4; - - const std::vector expected_output{0x90}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_u1) -{ - const std::vector input{1, 0, 1, 0, 0, 0, 0, 1}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{0xA1}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u16_to_u1) -{ - const std::vector input{1, 0, 1, 0, 0, 0, 0, 1}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u16; - - const std::vector expected_output{0xA1}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u32_to_u1) -{ - const std::vector input{1, 0, 1, 0, 0, 0, 0, 1}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u32; - - const std::vector expected_output{0xA1}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u64_to_u1) -{ - const std::vector input{1, 0, 1, 0, 0, 0, 0, 1}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u64; - - const std::vector expected_output{0xA1}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i4_to_u1) -{ - const std::vector input{0x10, 0x01, 0x00, 0x00}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u4; - - const std::vector expected_output{0x90}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i8_to_u1) -{ - const std::vector input{1, 0, 1, 0, 0, 0, 0, 1}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::i8; - - const std::vector expected_output{0xA1}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i16_to_u1) -{ - const std::vector input{1, 0, 1, 0, 0, 0, 0, 1}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::i16; - - const std::vector expected_output{0xA1}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i32_to_u1) -{ - const std::vector input{1, 0, 1, 0, 0, 0, 0, 1}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::i32; - - const std::vector expected_output{0xA1}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i64_to_u1) -{ - const std::vector input{1, 0, 1, 0, 0, 0, 0, 1}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::i64; - - const std::vector expected_output{0xA1}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_f16_to_u1) -{ - const std::vector input{1, 0, 1, 0, 0, 0, 0, 1}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::f16; - - const std::vector expected_output{0xA1}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_bf16_to_u1) -{ - const std::vector input{1, 0, 1, 0, 0, 0, 0, 1}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::bf16; - - const std::vector expected_output{0xA1}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_f32_to_u1) -{ - const std::vector input{1, 0, 1, 0, 0, 0, 0, 1}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::f32; - - const std::vector expected_output{0xA1}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: u4 -NGRAPH_TEST(${BACKEND_NAME}, convert_u1_to_u4) -{ - const std::vector input{0xF0}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u1; - - const std::vector expected_output{0x11, 0x11}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u4_to_u4) -{ - const std::vector input{0x22, 0x33}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u4; - - const std::vector expected_output{0x22, 0x33}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_u4) -{ - const std::vector input{7, 0, 1, 15}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{0x70, 0x1F}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u16_to_u4) -{ - const std::vector input{7, 0, 1, 15}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u16; - - const std::vector expected_output{0x70, 0x1F}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u32_to_u4) -{ - const std::vector input{7, 0, 1, 15}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u32; - - const std::vector expected_output{0x70, 0x1F}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u64_to_u4) -{ - const std::vector input{7, 0, 1, 15}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u64; - - const std::vector expected_output{0x70, 0x1F}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i4_to_u4) -{ - const std::vector input{0x22, 0x33}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i4; - - const std::vector expected_output{0x22, 0x33}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i8_to_u4) -{ - const std::vector input{7, 0, 1, 15}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i8; - - const std::vector expected_output{0x70, 0x1F}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i16_to_u4) -{ - const std::vector input{7, 0, 1, 15}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i16; - - const std::vector expected_output{0x70, 0x1F}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i32_to_u4) -{ - const std::vector input{7, 0, 1, 15}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i32; - - const std::vector expected_output{0x70, 0x1F}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i64_to_u4) -{ - const std::vector input{7, 0, 1, 15}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i64; - - const std::vector expected_output{0x70, 0x1F}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_f16_to_u4) -{ - const std::vector input{7, 0, 1, 15}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::f16; - - const std::vector expected_output{0x70, 0x1F}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_bf16_to_u4) -{ - const std::vector input{7, 0, 1, 15}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::bf16; - - const std::vector expected_output{0x70, 0x1F}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_f32_to_u4) -{ - const std::vector input{7, 0, 1, 15}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::f32; - - const std::vector expected_output{0x70, 0x1F}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: u8 -NGRAPH_TEST(${BACKEND_NAME}, convert_u1_to_u8) -{ - const std::vector input{0x81}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u1; - - const std::vector expected_output{1, 0, 0, 0, 0, 0, 0, 1}; - const element::Type expected_output_type = ngraph::element::u8; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(uint8_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u4_to_u8) -{ - const std::vector input{0x21, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u4; - - const std::vector expected_output{2, 1, 4, 3}; - const element::Type expected_output_type = ngraph::element::u8; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(uint8_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i4_to_u8) -{ - const std::vector input{0x12, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i4; - - const std::vector expected_output{1, 2, 4, 3}; - const element::Type expected_output_type = ngraph::element::u8; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(uint8_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_u8) -{ - const std::vector input{0, 10, 15, 20, 43, 56, 78, 99, 102, 110, 127}; - const Shape input_shape{11}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{0, 10, 15, 20, 43, 56, 78, 99, 102, 110, 127}; - const element::Type expected_output_type = ngraph::element::u8; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: u16 -NGRAPH_TEST(${BACKEND_NAME}, convert_u1_to_u16) -{ - const std::vector input{0x81}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u1; - - const std::vector expected_output{1, 0, 0, 0, 0, 0, 0, 1}; - const element::Type expected_output_type = ngraph::element::u16; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(uint16_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u4_to_u16) -{ - const std::vector input{0x21, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u4; - - const std::vector expected_output{2, 1, 4, 3}; - const element::Type expected_output_type = ngraph::element::u16; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(uint16_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i4_to_u16) -{ - const std::vector input{0x12, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i4; - - const std::vector expected_output{1, 2, 4, 3}; - const element::Type expected_output_type = ngraph::element::u16; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(uint16_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_u16) -{ - const std::vector input{0, 10, 15, 20, 43, 56, 78, 99, 102, 110, 127}; - const Shape input_shape{11}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{0, 10, 15, 20, 43, 56, 78, 99, 102, 110, 127}; - const element::Type expected_output_type = ngraph::element::u16; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: u32 -NGRAPH_TEST(${BACKEND_NAME}, convert_u1_to_u32) -{ - const std::vector input{0x81}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u1; - - const std::vector expected_output{1, 0, 0, 0, 0, 0, 0, 1}; - const element::Type expected_output_type = ngraph::element::u32; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(uint32_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u4_to_u32) -{ - const std::vector input{0x21, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u4; - - const std::vector expected_output{2, 1, 4, 3}; - const element::Type expected_output_type = ngraph::element::u32; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(uint32_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i4_to_u32) -{ - const std::vector input{0x12, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i4; - - const std::vector expected_output{1, 2, 4, 3}; - const element::Type expected_output_type = ngraph::element::u32; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(uint32_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_u32) -{ - const std::vector input{0, 10, 15, 20, 43, 56, 78, 99, 102, 110, 127}; - const Shape input_shape{11}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{0, 10, 15, 20, 43, 56, 78, 99, 102, 110, 127}; - const element::Type expected_output_type = ngraph::element::u32; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: u64 -NGRAPH_TEST(${BACKEND_NAME}, convert_u1_to_u64) -{ - const std::vector input{0x81}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u1; - - const std::vector expected_output{1, 0, 0, 0, 0, 0, 0, 1}; - const element::Type expected_output_type = ngraph::element::u64; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(uint64_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u4_to_u64) -{ - const std::vector input{0x21, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u4; - - const std::vector expected_output{2, 1, 4, 3}; - const element::Type expected_output_type = ngraph::element::u64; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(uint64_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i4_to_u64) -{ - const std::vector input{0x12, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i4; - - const std::vector expected_output{1, 2, 4, 3}; - const element::Type expected_output_type = ngraph::element::u64; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(uint64_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_u64) -{ - const std::vector input{0, 10, 15, 20, 43, 56, 78, 99, 102, 110, 127}; - const Shape input_shape{11}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{0, 10, 15, 20, 43, 56, 78, 99, 102, 110, 127}; - const element::Type expected_output_type = ngraph::element::u64; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// jit tests -NGRAPH_TEST(${BACKEND_NAME}, convert_float32_int8) -{ - std::vector f32vec = {-100.5, -20.5, -15, -10.5, -0.5, 0, 0.5, 10.5, 15, 20.5, 100.5}; - std::vector result(f32vec.size()); - std::vector i8vec(std::begin(f32vec), std::end(f32vec)); - runtime::reference::convert(f32vec.data(), result.data(), f32vec.size()); - EXPECT_EQ(result, i8vec); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_fp16_int8) -{ - std::vector f32vec = {-100.5, -20.5, -15, -10.5, -0.5, 0, 0.5, 10.5, 15, 20.5, 100.5}; - std::vector f16vec(std::begin(f32vec), std::end(f32vec)); - std::vector i8vec(std::begin(f16vec), std::end(f16vec)); - std::vector result(i8vec.size()); - runtime::reference::convert(f16vec.data(), result.data(), f16vec.size()); - EXPECT_EQ(result, i8vec); -} diff --git a/ngraph/test/backend/cosh.in.cpp b/ngraph/test/backend/cosh.in.cpp index 1877b50e6beefd..f0711c5f48fe7b 100644 --- a/ngraph/test/backend/cosh.in.cpp +++ b/ngraph/test/backend/cosh.in.cpp @@ -2,23 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include -#include -#include - -// clang-format off -#ifdef ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS -#define DEFAULT_FLOAT_TOLERANCE_BITS ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS -#endif - -#ifdef ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS -#define DEFAULT_DOUBLE_TOLERANCE_BITS ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS -#endif -// clang-format on - #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "util/engine/test_engines.hpp" @@ -31,7 +14,7 @@ using namespace ngraph; static string s_manifest = "${MANIFEST}"; using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); -NGRAPH_TEST(${BACKEND_NAME}, cosh) +NGRAPH_TEST(${BACKEND_NAME}, cosh_float) { Shape shape{6}; auto A = make_shared(element::f32, shape); @@ -49,3 +32,16 @@ NGRAPH_TEST(${BACKEND_NAME}, cosh) test_case.add_expected_output(shape, expected); test_case.run(); } + +NGRAPH_TEST(${BACKEND_NAME}, cosh_int) +{ + Shape shape{5}; + auto A = make_shared(element::i32, shape); + auto f = make_shared(make_shared(A), ParameterVector{A}); + + auto test_case = test::TestCase(f); + test_case.add_input({1, 5, 2, 3, 3}); + test_case.add_expected_output(shape, + {2, 74, 4, 10, 10}); + test_case.run(); +} diff --git a/ngraph/test/backend/matrix_nms.in.cpp b/ngraph/test/backend/matrix_nms.in.cpp new file mode 100644 index 00000000000000..0c691831356971 --- /dev/null +++ b/ngraph/test/backend/matrix_nms.in.cpp @@ -0,0 +1,667 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +// clang-format off +#ifdef ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS +#define DEFAULT_FLOAT_TOLERANCE_BITS ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS +#endif + +#ifdef ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS +#define DEFAULT_DOUBLE_TOLERANCE_BITS ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS +#endif +// clang-format on + +#include "gtest/gtest.h" +#include "ngraph/ngraph.hpp" +#include "util/engine/test_engines.hpp" +#include "util/test_case.hpp" +#include "util/test_control.hpp" + +using namespace std; +using namespace ngraph; + +static string s_manifest = "${MANIFEST}"; +using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); + +NGRAPH_TEST(${BACKEND_NAME}, matrix_nms_output_type_i64) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0}; + + std::vector scores_data = { + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3}; + + op::v8::MatrixNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MatrixNms::SortResultType::SCORE; + attrs.keep_top_k = -1; + attrs.background_class = 0; + + const auto boxes_shape = Shape{1, 6, 4}; // N 1, C 2, M 6 + const auto scores_shape = Shape{1, 2, 6}; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + attrs.decay_function = op::v8::MatrixNms::DecayFunction::LINEAR; + attrs.gaussian_sigma = 2.0f; + attrs.post_threshold = 0.0f; + + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {0, 3, 1}; + std::vector expected_selected_scores = {1.00, 0.95, 0.00, 0.00, 1.00, 1.00, + 1.00, 0.8, 0.00, 10.00, 1.00, 11.00, + 1.00, 0.13636364, 0.0, 0.1, 1.0, 1.1}; + std::vector expected_valid_outputs = {3}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({3, 6}, expected_selected_scores); + test_case.add_expected_output({3, 1}, expected_selected_indices); + test_case.add_expected_output({1}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, matrix_nms_output_type_i32) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0}; + + std::vector scores_data = { + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3}; + + op::v8::MatrixNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MatrixNms::SortResultType::SCORE; + attrs.keep_top_k = -1; + attrs.background_class = 0; + + const auto boxes_shape = Shape{1, 6, 4}; // N 1, C 2, M 6 + const auto scores_shape = Shape{1, 2, 6}; + attrs.decay_function = op::v8::MatrixNms::DecayFunction::LINEAR; + attrs.gaussian_sigma = 2.0f; + attrs.post_threshold = 0.0f; + attrs.output_type = ngraph::element::i32; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {0, 3, 1}; + std::vector expected_selected_scores = {1.00, 0.95, 0.00, 0.00, 1.00, 1.00, + 1.00, 0.8, 0.00, 10.00, 1.00, 11.00, + 1.00, 0.13636364, 0.0, 0.1, 1.0, 1.1}; + std::vector expected_valid_outputs = {3}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({3, 6}, expected_selected_scores); + test_case.add_expected_output({3, 1}, expected_selected_indices); + test_case.add_expected_output({1}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, matrix_nms_gaussian) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0}; + + std::vector scores_data = { + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3}; + + op::v8::MatrixNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MatrixNms::SortResultType::SCORE; + attrs.keep_top_k = -1; + attrs.background_class = 0; + + const auto boxes_shape = Shape{1, 6, 4}; // N 1, C 2, M 6 + const auto scores_shape = Shape{1, 2, 6}; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + attrs.decay_function = op::v8::MatrixNms::DecayFunction::GAUSSIAN; + attrs.gaussian_sigma = 2.0f; + attrs.post_threshold = 0.0f; + + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {0, 3, 1}; + std::vector expected_selected_scores = {1.00, 0.95, 0.00, 0.00, 1.00, 1.00, + 1.00, 0.8, 0.00, 10.00, 1.00, 11.00, + 1.00, 0.1966116, 0.0, 0.1, 1.0, 1.1}; + std::vector expected_valid_outputs = {3}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({3, 6}, expected_selected_scores); + test_case.add_expected_output({3, 1}, expected_selected_indices); + test_case.add_expected_output({1}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, matrix_nms_two_batches_two_classes) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0, // 0 + 0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0}; // 1 + + std::vector scores_data = { + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3, // 0 + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3}; // 1 + + op::v8::MatrixNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MatrixNms::SortResultType::SCORE; + attrs.keep_top_k = -1; + attrs.background_class = 0; + + const auto boxes_shape = Shape{2, 6, 4}; // N 2, C 2, M 6 + const auto scores_shape = Shape{2, 2, 6}; + attrs.decay_function = op::v8::MatrixNms::DecayFunction::LINEAR; + attrs.gaussian_sigma = 2.0f; + attrs.post_threshold = 0.0f; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {0, 3, 1, + 6, 9, 7}; + std::vector expected_selected_scores = {1.00, 0.95, 0.00, 0.00, 1.00, 1.00, + 1.00, 0.8, 0.00, 10.00, 1.00, 11.00, + 1.00, 0.13636364, 0.0, 0.1, 1.0, 1.1, + 1.00, 0.95, 0.00, 0.00, 1.00, 1.00, + 1.00, 0.8, 0.00, 10.00, 1.00, 11.00, + 1.00, 0.13636364, 0.0, 0.1, 1.0, 1.1}; + std::vector expected_valid_outputs = {3, 3}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({6, 6}, expected_selected_scores); + test_case.add_expected_output({6, 1}, expected_selected_indices); + test_case.add_expected_output({2}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, matrix_nms_two_batches_two_classes_by_score_cross_batch) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0, // 0 + 0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0}; // 1 + + std::vector scores_data = { + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3, // 0 + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3}; // 1 + + op::v8::MatrixNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MatrixNms::SortResultType::SCORE; + attrs.keep_top_k = -1; + attrs.background_class = -1; + + const auto boxes_shape = Shape{2, 6, 4}; // N 2, C 2, M 6 + const auto scores_shape = Shape{2, 2, 6}; + attrs.decay_function = op::v8::MatrixNms::DecayFunction::LINEAR; + attrs.gaussian_sigma = 2.0f; + attrs.post_threshold = 0.5; + attrs.sort_result_across_batch = true; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {3, 0, 9, 6, + 0, 6, 3, 9}; + std::vector expected_selected_scores = {0.00, 0.95, 0.00, 10.00, 1.00, 11.00, //3 + 1.00, 0.95, 0.00, 0.00, 1.00, 1.00, //0 + 0.00, 0.95, 0.00, 10.00, 1.00, 11.00, //9 + 1.00, 0.95, 0.00, 0.00, 1.00, 1.00, //6 + 0.00, 0.90, 0.00, 0.00, 1.00, 1.00, //0 + 0.00, 0.90, 0.00, 0.00, 1.00, 1.00, //6 + 1.00, 0.80, 0.00, 10.00, 1.00, 11.00, //3 + 1.00, 0.80, 0.00, 10.00, 1.00, 11.00}; // 9 + std::vector expected_valid_outputs = {4, 4}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({8, 6}, expected_selected_scores); + test_case.add_expected_output({8, 1}, expected_selected_indices); + test_case.add_expected_output({2}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, matrix_nms_two_batches_two_classes_by_classid_cross_batch) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0, // 0 + 0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0}; // 1 + + std::vector scores_data = { + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3, // 0 + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3}; // 1 + + op::v8::MatrixNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MatrixNms::SortResultType::CLASSID; + attrs.keep_top_k = -1; + attrs.background_class = -1; + + const auto boxes_shape = Shape{2, 6, 4}; // N 2, C 2, M 6 + const auto scores_shape = Shape{2, 2, 6}; + attrs.decay_function = op::v8::MatrixNms::DecayFunction::LINEAR; + attrs.gaussian_sigma = 2.0f; + attrs.post_threshold = 0.5; + attrs.sort_result_across_batch = true; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {3, 0, 9, 6, + 0, 3, 6, 9}; + std::vector expected_selected_scores = {0.00, 0.95, 0.00, 10.00, 1.00, 11.00, //3 + 0.00, 0.90, 0.00, 0.00, 1.00, 1.00, //0 + 0.00, 0.95, 0.00, 10.00, 1.00, 11.00, //9 + 0.00, 0.90, 0.00, 0.00, 1.00, 1.00, //6 + 1.00, 0.95, 0.00, 0.00, 1.00, 1.00, //0 + 1.00, 0.80, 0.00, 10.00, 1.00, 11.00, // 3 + 1.00, 0.95, 0.00, 0.00, 1.00, 1.00, //6 + 1.00, 0.80, 0.00, 10.00, 1.00, 11.00 }; // 9 + std::vector expected_valid_outputs = {4, 4}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({8, 6}, expected_selected_scores); + test_case.add_expected_output({8, 1}, expected_selected_indices); + test_case.add_expected_output({2}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, matrix_nms_by_keep_top_k) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0, // 0 + 0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0}; // 1 + + std::vector scores_data = { + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3, // 0 + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3}; // 1 + + op::v8::MatrixNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MatrixNms::SortResultType::CLASSID; + attrs.keep_top_k = 3; + attrs.background_class = 0; + + const auto boxes_shape = Shape{2, 6, 4}; // N 2, C 2, M 6 + const auto scores_shape = Shape{2, 2, 6}; + attrs.decay_function = op::v8::MatrixNms::DecayFunction::LINEAR; + attrs.gaussian_sigma = 2.0f; + attrs.post_threshold = 0.0f; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {0, 3, 1, + 6, 9, 7}; + std::vector expected_selected_scores = {1.00, 0.95, 0.00, 0.00, 1.00, 1.00, + 1.00, 0.8, 0.00, 10.00, 1.00, 11.00, + 1.00, 0.13636364, 0.0, 0.1, 1.0, 1.1, + 1.00, 0.95, 0.00, 0.00, 1.00, 1.00, + 1.00, 0.8, 0.00, 10.00, 1.00, 11.00, + 1.00, 0.13636364, 0.0, 0.1, 1.0, 1.1}; + std::vector expected_valid_outputs = {3, 3}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({6, 6}, expected_selected_scores); + test_case.add_expected_output({6, 1}, expected_selected_indices); + test_case.add_expected_output({2}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, matrix_nms_background) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0}; + + std::vector scores_data = { + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3}; + + op::v8::MatrixNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MatrixNms::SortResultType::SCORE; + attrs.keep_top_k = -1; + attrs.background_class = -1; + + const auto boxes_shape = Shape{1, 6, 4}; // N 1, C 2, M 6 + const auto scores_shape = Shape{1, 2, 6}; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + attrs.decay_function = op::v8::MatrixNms::DecayFunction::LINEAR; + attrs.gaussian_sigma = 2.0f; + attrs.post_threshold = 0.0f; + + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {3, 0, 0, 3, 1, 1}; + std::vector expected_selected_scores = {0.00, 0.95, 0.0, 10.0, 1.0, 11.0, + 1.00, 0.95, 0.0, 0.0, 1.0, 1.0, + 0.00, 0.9, 0.0, 0.0, 1.0, 1.0, + 1.00, 0.8, 0.0, 10.0, 1.0, 11.0, + 0.00, 0.13636364, 0.0, 0.1, 1.0, 1.1, + 1.00, 0.13636364, 0.0, 0.1, 1.0, 1.1}; + std::vector expected_valid_outputs = {6}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({6, 6}, expected_selected_scores); + test_case.add_expected_output({6, 1}, expected_selected_indices); + test_case.add_expected_output({1}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, matrix_nms_flipped_coordinates) +{ + std::vector boxes_data = {1.0, 1.0, 0.0, 0.0, 0.0, 0.1, 1.0, 1.1, + 0.0, 0.9, 1.0, -0.1, 0.0, 10.0, 1.0, 11.0, + 1.0, 10.1, 0.0, 11.1, 1.0, 101.0, 0.0, 100.0}; + + std::vector scores_data = {0.9, 0.75, 0.6, 0.95, 0.5, 0.3}; + + op::v8::MatrixNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MatrixNms::SortResultType::SCORE; + attrs.keep_top_k = -1; + attrs.background_class = -1; + + const auto boxes_shape = Shape{1, 6, 4}; // N 1, C 1, M 6 + const auto scores_shape = Shape{1, 1, 6}; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + attrs.decay_function = op::v8::MatrixNms::DecayFunction::LINEAR; + attrs.gaussian_sigma = 2.0f; + attrs.post_threshold = 0.0f; + + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {3, 0, 1}; + std::vector expected_selected_scores = {0.00, 0.95, 0.0, 10.0, 1.0, 11.0, + 0.00, 0.9, 1.0, 1.0, 0.0, 0.0, + 0.00, 0.75, 0.0, 0.1, 1.0, 1.1}; + std::vector expected_valid_outputs = {3}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({3, 6}, expected_selected_scores); + test_case.add_expected_output({3, 1}, expected_selected_indices); + test_case.add_expected_output({1}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, matrix_nms_post_threshold) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0}; + + std::vector scores_data = { + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3}; + + op::v8::MatrixNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.score_threshold = 0.00; + attrs.sort_result_type = op::v8::MatrixNms::SortResultType::SCORE; + attrs.keep_top_k = -1; + attrs.background_class = -1; + + const auto boxes_shape = Shape{1, 6, 4}; // N 1, C 2, M 6 + const auto scores_shape = Shape{1, 1, 6}; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + attrs.decay_function = op::v8::MatrixNms::DecayFunction::LINEAR; + attrs.gaussian_sigma = 2.0f; + attrs.post_threshold = 0.8; + + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {3, 0}; + std::vector expected_selected_scores = {0.00, 0.95, 0.00, 10.00, 1.00, 11.00, + 0.00, 0.9, 0.00, 0.00, 1.00, 1.00}; + std::vector expected_valid_outputs = {2}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({2, 6}, expected_selected_scores); + test_case.add_expected_output({2, 1}, expected_selected_indices); + test_case.add_expected_output({1}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, matrix_nms_identical_boxes) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, + 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, + 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, + 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0}; + + std::vector scores_data = {0.4, 0.01, 0.2, 0.09, 0.15, 0.05, 0.02, 0.03, 0.05, 0.0}; + + op::v8::MatrixNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MatrixNms::SortResultType::SCORE; + attrs.keep_top_k = -1; + attrs.background_class = -1; + + const auto boxes_shape = Shape{1, 10, 4}; // N 1, C 1, M 10 + const auto scores_shape = Shape{1, 1, 10}; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + attrs.decay_function = op::v8::MatrixNms::DecayFunction::LINEAR; + attrs.gaussian_sigma = 2.0f; + attrs.post_threshold = 0.3; + + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {0}; + std::vector expected_selected_scores = {0.00, 0.40, 0.00, 0.00, 1.00, 1.00}; + std::vector expected_valid_outputs = {1}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({1, 6}, expected_selected_scores); + test_case.add_expected_output({1, 1}, expected_selected_indices); + test_case.add_expected_output({1}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, matrix_nms_nms_top_k) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0}; + + std::vector scores_data = {0.9, 0.75, 0.6, 0.95, 0.5, 0.3}; + + op::v8::MatrixNms::Attributes attrs; + attrs.nms_top_k = 2; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MatrixNms::SortResultType::SCORE; + attrs.keep_top_k = -1; + attrs.background_class = -1; + + const auto boxes_shape = Shape{1, 6, 4}; + const auto scores_shape = Shape{1, 1, 6}; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + attrs.decay_function = op::v8::MatrixNms::DecayFunction::LINEAR; + attrs.gaussian_sigma = 2.0f; + attrs.post_threshold = 0.0f; + + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {3, 0}; + std::vector expected_selected_scores = {0.00, 0.95, 0.00, 10.00, 1.00, 11.00 , + 0.00, 0.90, 0.00, 0.00, 1.00, 1.00 }; + std::vector expected_valid_outputs = {2}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({2, 6}, expected_selected_scores); + test_case.add_expected_output({2, 1}, expected_selected_indices); + test_case.add_expected_output({1}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, matrix_nms_single_box) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0}; + + std::vector scores_data = {0.9}; + + op::v8::MatrixNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MatrixNms::SortResultType::SCORE; + attrs.keep_top_k = -1; + attrs.background_class = -1; + + const auto boxes_shape = Shape{1, 1, 4}; + const auto scores_shape = Shape{1, 1, 1}; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + attrs.decay_function = op::v8::MatrixNms::DecayFunction::LINEAR; + attrs.gaussian_sigma = 2.0f; + attrs.post_threshold = 0.0f; + + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {0}; + std::vector expected_selected_scores = {0.00, 0.90, 0.00, 0.00, 1.00, 1.00}; + std::vector expected_valid_outputs = {1}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({1, 6}, expected_selected_scores); + test_case.add_expected_output({1, 1}, expected_selected_indices); + test_case.add_expected_output({1}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, matrix_nms_no_output) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0}; + + std::vector scores_data = {0.9, 0.75, 0.6, 0.95, 0.5, 0.3}; + + op::v8::MatrixNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.score_threshold = 2.0f; + attrs.sort_result_type = op::v8::MatrixNms::SortResultType::SCORE; + attrs.keep_top_k = -1; + attrs.background_class = -1; + + const auto boxes_shape = Shape{1, 6, 4}; + const auto scores_shape = Shape{1, 1, 6}; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + attrs.decay_function = op::v8::MatrixNms::DecayFunction::LINEAR; + attrs.gaussian_sigma = 2.0f; + attrs.post_threshold = 0.0f; + + auto nms = make_shared(boxes, scores, attrs); + + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {}; + std::vector expected_selected_scores = {}; + std::vector expected_valid_outputs = {0}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({0, 6}, expected_selected_scores); + test_case.add_expected_output({0, 1}, expected_selected_indices); + test_case.add_expected_output({1}, expected_valid_outputs); + test_case.run(); +} diff --git a/ngraph/test/backend/multiclass_nms.in.cpp b/ngraph/test/backend/multiclass_nms.in.cpp new file mode 100644 index 00000000000000..3c0d3153765bde --- /dev/null +++ b/ngraph/test/backend/multiclass_nms.in.cpp @@ -0,0 +1,802 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +// clang-format off +#ifdef ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS +#define DEFAULT_FLOAT_TOLERANCE_BITS ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS +#endif + +#ifdef ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS +#define DEFAULT_DOUBLE_TOLERANCE_BITS ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS +#endif +// clang-format on + +#include "gtest/gtest.h" +#include "ngraph/ngraph.hpp" +#include "util/engine/test_engines.hpp" +#include "util/test_case.hpp" +#include "util/test_control.hpp" + +using namespace std; +using namespace ngraph; + +static string s_manifest = "${MANIFEST}"; +using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); + +NGRAPH_TEST(${BACKEND_NAME}, multiclass_nms_by_score) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0}; + + std::vector scores_data = { + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3}; + + op::v8::MulticlassNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.iou_threshold = 0.5f; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MulticlassNms::SortResultType::SCORE; + attrs.keep_top_k = -1; + attrs.background_class = -1; + attrs.nms_eta = 1.0f; + + const auto boxes_shape = Shape{1, 6, 4}; // N 1, C 2, M 6 + const auto scores_shape = Shape{1, 2, 6}; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {3, 0, 0, 3}; + std::vector expected_selected_scores = {0.00, 0.95, 0.00, 10.00, 1.00, 11.00 , + 1.00, 0.95, 0.00, 0.00, 1.00, 1.00 , + 0.00, 0.90, 0.00, 0.00, 1.00, 1.00, + 1.00, 0.80, 0.00, 10.00, 1.00, 11.00 }; + std::vector expected_valid_outputs = {4}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({4, 6}, expected_selected_scores); + test_case.add_expected_output({4, 1}, expected_selected_indices); + test_case.add_expected_output({1}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, multiclass_nms_by_class_id) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0}; + + std::vector scores_data = { + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3}; + + op::v8::MulticlassNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.iou_threshold = 0.5f; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MulticlassNms::SortResultType::CLASSID; + attrs.keep_top_k = -1; + attrs.background_class = -1; + attrs.nms_eta = 1.0f; + + const auto boxes_shape = Shape{1, 6, 4}; // N 1, C 2, M 6 + const auto scores_shape = Shape{1, 2, 6}; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {3, 0, 0, 3}; + std::vector expected_selected_scores = {0.00, 0.95, 0.00, 10.00, 1.00, 11.00 , + 0.00, 0.90, 0.00, 0.00, 1.00, 1.00 , + 1.00, 0.95, 0.00, 0.00, 1.00, 1.00 , + 1.00, 0.80, 0.00, 10.00, 1.00, 11.00 }; + std::vector expected_valid_outputs = {4}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({4, 6}, expected_selected_scores); + test_case.add_expected_output({4, 1}, expected_selected_indices); + test_case.add_expected_output({1}, expected_valid_outputs); + test_case.run(); + +} + +NGRAPH_TEST(${BACKEND_NAME}, multiclass_nms_output_type_i32) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0}; + + std::vector scores_data = { + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3}; + + op::v8::MulticlassNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.iou_threshold = 0.5f; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MulticlassNms::SortResultType::CLASSID; + attrs.keep_top_k = -1; + attrs.background_class = -1; + attrs.nms_eta = 1.0f; + attrs.output_type = element::i32; + + const auto boxes_shape = Shape{1, 6, 4}; // N 1, C 2, M 6 + const auto scores_shape = Shape{1, 2, 6}; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {3, 0, 0, 3}; + std::vector expected_selected_scores = {0.00, 0.95, 0.00, 10.00, 1.00, 11.00 , + 0.00, 0.90, 0.00, 0.00, 1.00, 1.00 , + 1.00, 0.95, 0.00, 0.00, 1.00, 1.00 , + 1.00, 0.80, 0.00, 10.00, 1.00, 11.00 }; + std::vector expected_valid_outputs = {4}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({4, 6}, expected_selected_scores); + test_case.add_expected_output({4, 1}, expected_selected_indices); + test_case.add_expected_output({1}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, multiclass_nms_two_batches_two_classes_by_score) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0, // 0 + 0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0 // 1 + }; + + std::vector scores_data = { + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3, // 0 + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3 // 1 + }; + + op::v8::MulticlassNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.iou_threshold = 0.5f; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MulticlassNms::SortResultType::SCORE; + attrs.keep_top_k = -1; + attrs.background_class = -1; + attrs.nms_eta = 1.0f; + + const auto boxes_shape = Shape{2, 6, 4}; // N 2, C 2, M 6 + const auto scores_shape = Shape{2, 2, 6}; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {3, 0, 0, 3, + 9, 6, 6, 9}; + std::vector expected_selected_scores = {0.00, 0.95, 0.00, 10.00, 1.00, 11.00, 1.00, 0.95, 0.00, 0.00, 1.00, 1.00, + 0.00, 0.90, 0.00, 0.00, 1.00, 1.00, 1.00, 0.80, 0.00, 10.00, 1.00, 11.00, // 0 + 0.00, 0.95, 0.00, 10.00, 1.00, 11.00, 1.00, 0.95, 0.00, 0.00, 1.00, 1.00, + 0.00, 0.90, 0.00, 0.00, 1.00, 1.00, 1.00, 0.80, 0.00, 10.00, 1.00, 11.00 }; // 1 + std::vector expected_valid_outputs = {4, 4}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({8, 6}, expected_selected_scores); + test_case.add_expected_output({8, 1}, expected_selected_indices); + test_case.add_expected_output({2}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, multiclass_nms_two_batches_two_classes_by_class_id) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0, // 0 + 0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0 // 1 + }; + + std::vector scores_data = { + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3, // 0 + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3 // 1 + }; + + op::v8::MulticlassNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.iou_threshold = 0.5f; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MulticlassNms::SortResultType::CLASSID; + attrs.keep_top_k = -1; + attrs.background_class = -1; + attrs.nms_eta = 1.0f; + + const auto boxes_shape = Shape{2, 6, 4}; // N 2, C 2, M 6 + const auto scores_shape = Shape{2, 2, 6}; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {3, 0, 0, 3, + 9, 6, 6, 9}; + std::vector expected_selected_scores = {0.00, 0.95, 0.00, 10.00, 1.00, 11.00, 0.00, 0.90, 0.00, 0.00, 1.00, 1.00, + 1.00, 0.95, 0.00, 0.00, 1.00, 1.00, 1.00, 0.80, 0.00, 10.00, 1.00, 11.00, // 0 + 0.00, 0.95, 0.00, 10.00, 1.00, 11.00, 0.00, 0.90, 0.00, 0.00, 1.00, 1.00, + 1.00, 0.95, 0.00, 0.00, 1.00, 1.00, 1.00, 0.80, 0.00, 10.00, 1.00, 11.00 }; // 1 + std::vector expected_valid_outputs = {4, 4}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({8, 6}, expected_selected_scores); + test_case.add_expected_output({8, 1}, expected_selected_indices); + test_case.add_expected_output({2}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, multiclass_nms_two_batches_two_classes_by_score_cross_batch) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0, // 0 + 0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0 // 1 + }; + + std::vector scores_data = { + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3, // 0 + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3 // 1 + }; + + op::v8::MulticlassNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.iou_threshold = 0.5f; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MulticlassNms::SortResultType::SCORE; + attrs.keep_top_k = -1; + attrs.background_class = -1; + attrs.nms_eta = 1.0f; + attrs.sort_result_across_batch = true; + + const auto boxes_shape = Shape{2, 6, 4}; // N 2, C 2, M 6 + const auto scores_shape = Shape{2, 2, 6}; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {3, 0, 9, 6, + 0, 6, 3, 9}; + std::vector expected_selected_scores = {0.00, 0.95, 0.00, 10.00, 1.00, 11.00, //3 + 1.00, 0.95, 0.00, 0.00, 1.00, 1.00, //0 + 0.00, 0.95, 0.00, 10.00, 1.00, 11.00, //9 + 1.00, 0.95, 0.00, 0.00, 1.00, 1.00, //6 + 0.00, 0.90, 0.00, 0.00, 1.00, 1.00, //0 + 0.00, 0.90, 0.00, 0.00, 1.00, 1.00, //6 + 1.00, 0.80, 0.00, 10.00, 1.00, 11.00, //3 + 1.00, 0.80, 0.00, 10.00, 1.00, 11.00 }; // 9 + std::vector expected_valid_outputs = {4, 4}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({8, 6}, expected_selected_scores); + test_case.add_expected_output({8, 1}, expected_selected_indices); + test_case.add_expected_output({2}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, multiclass_nms_two_batches_two_classes_by_class_id_cross_batch) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0, // 0 + 0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0 // 1 + }; + + std::vector scores_data = { + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3, // 0 + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3 // 1 + }; + + op::v8::MulticlassNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.iou_threshold = 0.5f; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MulticlassNms::SortResultType::CLASSID; + attrs.keep_top_k = -1; + attrs.background_class = -1; + attrs.nms_eta = 1.0f; + attrs.sort_result_across_batch = true; + + const auto boxes_shape = Shape{2, 6, 4}; // N 2, C 2, M 6 + const auto scores_shape = Shape{2, 2, 6}; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {3, 0, 9, 6, + 0, 3, 6, 9}; + std::vector expected_selected_scores = {0.00, 0.95, 0.00, 10.00, 1.00, 11.00, //3 + 0.00, 0.90, 0.00, 0.00, 1.00, 1.00, //0 + 0.00, 0.95, 0.00, 10.00, 1.00, 11.00, //9 + 0.00, 0.90, 0.00, 0.00, 1.00, 1.00, //6 + 1.00, 0.95, 0.00, 0.00, 1.00, 1.00, //0 + 1.00, 0.80, 0.00, 10.00, 1.00, 11.00, // 3 + 1.00, 0.95, 0.00, 0.00, 1.00, 1.00, //6 + 1.00, 0.80, 0.00, 10.00, 1.00, 11.00 }; // 9 + std::vector expected_valid_outputs = {4, 4}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({8, 6}, expected_selected_scores); + test_case.add_expected_output({8, 1}, expected_selected_indices); + test_case.add_expected_output({2}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, multiclass_nms_flipped_coordinates) +{ + std::vector boxes_data = {1.0, 1.0, 0.0, 0.0, 0.0, 0.1, 1.0, 1.1, + 0.0, 0.9, 1.0, -0.1, 0.0, 10.0, 1.0, 11.0, + 1.0, 10.1, 0.0, 11.1, 1.0, 101.0, 0.0, 100.0}; + + std::vector scores_data = {0.9, 0.75, 0.6, 0.95, 0.5, 0.3}; + + op::v8::MulticlassNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.iou_threshold = 0.5f; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MulticlassNms::SortResultType::SCORE; + attrs.keep_top_k = -1; + attrs.background_class = -1; + attrs.nms_eta = 1.0f; + + const auto boxes_shape = Shape{1, 6, 4}; // N 1, C 1, M 6 + const auto scores_shape = Shape{1, 1, 6}; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {3, 0, 1}; + std::vector expected_selected_scores = {0.00, 0.95, 0.00, 10.00, 1.00, 11.00 , + 0.00, 0.90, 1.00, 1.00, 0.00, 0.00 , + 0.00, 0.75, 0.00, 0.10, 1.00, 1.10}; + std::vector expected_valid_outputs = {3}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({3, 6}, expected_selected_scores); + test_case.add_expected_output({3, 1}, expected_selected_indices); + test_case.add_expected_output({1}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, multiclass_nms_identical_boxes) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, + 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, + 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, + 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0}; + + std::vector scores_data = {0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9}; + + op::v8::MulticlassNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.iou_threshold = 0.5f; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MulticlassNms::SortResultType::SCORE; + attrs.keep_top_k = -1; + attrs.background_class = -1; + attrs.nms_eta = 1.0f; + + const auto boxes_shape = Shape{1, 10, 4}; // N 1, C 1, M 10 + const auto scores_shape = Shape{1, 1, 10}; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {0}; + std::vector expected_selected_scores = {0.00, 0.90, 0.00, 0.00, 1.00, 1.00}; + std::vector expected_valid_outputs = {1}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({1, 6}, expected_selected_scores); + test_case.add_expected_output({1, 1}, expected_selected_indices); + test_case.add_expected_output({1}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, multiclass_nms_limit_output_size) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0}; + + std::vector scores_data = {0.9, 0.75, 0.6, 0.95, 0.5, 0.3}; + + op::v8::MulticlassNms::Attributes attrs; + attrs.nms_top_k = 2; + attrs.iou_threshold = 0.5f; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MulticlassNms::SortResultType::SCORE; + attrs.keep_top_k = -1; + attrs.background_class = -1; + attrs.nms_eta = 1.0f; + + const auto boxes_shape = Shape{1, 6, 4}; + const auto scores_shape = Shape{1, 1, 6}; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {3, 0}; + std::vector expected_selected_scores = {0.00, 0.95, 0.00, 10.00, 1.00, 11.00 , + 0.00, 0.90, 0.00, 0.00, 1.00, 1.00 }; + std::vector expected_valid_outputs = {2}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({2, 6}, expected_selected_scores); + test_case.add_expected_output({2, 1}, expected_selected_indices); + test_case.add_expected_output({1}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, multiclass_nms_single_box) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0}; + + std::vector scores_data = {0.9}; + + op::v8::MulticlassNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.iou_threshold = 0.5f; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MulticlassNms::SortResultType::SCORE; + attrs.keep_top_k = -1; + attrs.background_class = -1; + attrs.nms_eta = 1.0f; + + const auto boxes_shape = Shape{1, 1, 4}; + const auto scores_shape = Shape{1, 1, 1}; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {0}; + std::vector expected_selected_scores = {0.00, 0.90, 0.00, 0.00, 1.00, 1.00}; + std::vector expected_valid_outputs = {1}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({1, 6}, expected_selected_scores); + test_case.add_expected_output({1, 1}, expected_selected_indices); + test_case.add_expected_output({1}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, multiclass_nms_by_IOU) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0}; + + std::vector scores_data = {0.9, 0.75, 0.6, 0.95, 0.5, 0.3}; + + op::v8::MulticlassNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.iou_threshold = 0.2f; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MulticlassNms::SortResultType::SCORE; + attrs.keep_top_k = -1; + attrs.background_class = -1; + attrs.nms_eta = 1.0f; + + const auto boxes_shape = Shape{1, 6, 4}; + const auto scores_shape = Shape{1, 1, 6}; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {3, 0}; + std::vector expected_selected_scores = {0.00, 0.95, 0.00, 10.00, 1.00, 11.00 , + 0.00, 0.90, 0.00, 0.00, 1.00, 1.00}; + std::vector expected_valid_outputs = {2}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({2, 6}, expected_selected_scores); + test_case.add_expected_output({2, 1}, expected_selected_indices); + test_case.add_expected_output({1}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, multiclass_nms_by_IOU_and_scores) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0}; + + std::vector scores_data = {0.9, 0.75, 0.6, 0.95, 0.5, 0.3}; + + op::v8::MulticlassNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.iou_threshold = 0.5f; + attrs.score_threshold = 0.95f; + attrs.sort_result_type = op::v8::MulticlassNms::SortResultType::SCORE; + attrs.keep_top_k = -1; + attrs.background_class = -1; + attrs.nms_eta = 1.0f; + + const auto boxes_shape = Shape{1, 6, 4}; + const auto scores_shape = Shape{1, 1, 6}; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {3}; + std::vector expected_selected_scores = {0.00, 0.95, 0.00, 10.00, 1.00, 11.00}; + std::vector expected_valid_outputs = {1}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({1, 6}, expected_selected_scores); + test_case.add_expected_output({1, 1}, expected_selected_indices); + test_case.add_expected_output({1}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, multiclass_nms_no_output) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0}; + + std::vector scores_data = {0.9, 0.75, 0.6, 0.95, 0.5, 0.3}; + + op::v8::MulticlassNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.iou_threshold = 0.5f; + attrs.score_threshold = 2.0f; + attrs.sort_result_type = op::v8::MulticlassNms::SortResultType::SCORE; + attrs.keep_top_k = -1; + attrs.background_class = -1; + attrs.nms_eta = 1.0f; + + const auto boxes_shape = Shape{1, 6, 4}; + const auto scores_shape = Shape{1, 1, 6}; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {}; + std::vector expected_selected_scores = {}; + std::vector expected_valid_outputs = {0}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({0, 6}, expected_selected_scores); + test_case.add_expected_output({0, 1}, expected_selected_indices); + test_case.add_expected_output({1}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, multiclass_nms_by_background) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0, // 0 + 0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0 // 1 + }; + + std::vector scores_data = { + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3, // 0 + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3 // 1 + }; + + op::v8::MulticlassNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.iou_threshold = 0.5f; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MulticlassNms::SortResultType::CLASSID; + attrs.keep_top_k = -1; + attrs.background_class = 0; + attrs.nms_eta = 1.0f; + + const auto boxes_shape = Shape{2, 6, 4}; // N 2, C 2, M 6 + const auto scores_shape = Shape{2, 2, 6}; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {0, 3, 6, 9}; + std::vector expected_selected_scores = {1.00, 0.95, 0.00, 0.00, 1.00, 1.00, 1.00, 0.80, 0.00, 10.00, 1.00, 11.00, // 0 + 1.00, 0.95, 0.00, 0.00, 1.00, 1.00, 1.00, 0.80, 0.00, 10.00, 1.00, 11.00 }; // 1 + std::vector expected_valid_outputs = {2, 2}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({4, 6}, expected_selected_scores); + test_case.add_expected_output({4, 1}, expected_selected_indices); + test_case.add_expected_output({2}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, multiclass_nms_by_keep_top_k) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0, // 0 + 0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0 // 1 + }; + + std::vector scores_data = { + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3, // 0 + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3 // 1 + }; + + op::v8::MulticlassNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.iou_threshold = 0.5f; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MulticlassNms::SortResultType::CLASSID; + attrs.keep_top_k = 3; + attrs.background_class = -1; + attrs.nms_eta = 1.0f; + + const auto boxes_shape = Shape{2, 6, 4}; // N 2, C 2, M 6 + const auto scores_shape = Shape{2, 2, 6}; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {3, 0, 0, + 9, 6, 6}; + std::vector expected_selected_scores = {0.00, 0.95, 0.00, 10.00, 1.00, 11.00, 0.00, 0.90, 0.00, 0.00, 1.00, 1.00, + 1.00, 0.95, 0.00, 0.00, 1.00, 1.00, // 0 + 0.00, 0.95, 0.00, 10.00, 1.00, 11.00, 0.00, 0.90, 0.00, 0.00, 1.00, 1.00, + 1.00, 0.95, 0.00, 0.00, 1.00, 1.00 }; // 1 + std::vector expected_valid_outputs = {3, 3}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({6, 6}, expected_selected_scores); + test_case.add_expected_output({6, 1}, expected_selected_indices); + test_case.add_expected_output({2}, expected_valid_outputs); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, multiclass_nms_by_nms_eta) +{ + std::vector boxes_data = {0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0, // 0 + 0.0, 0.0, 1.0, 1.0, 0.0, 0.1, 1.0, 1.1, + 0.0, -0.1, 1.0, 0.9, 0.0, 10.0, 1.0, 11.0, + 0.0, 10.1, 1.0, 11.1, 0.0, 100.0, 1.0, 101.0 // 1 + }; + + std::vector scores_data = { + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3, // 0 + 0.9, 0.75, 0.6, 0.95, 0.5, 0.3, + 0.95, 0.75, 0.6, 0.80, 0.5, 0.3 // 1 + }; + + op::v8::MulticlassNms::Attributes attrs; + attrs.nms_top_k = -1; + attrs.iou_threshold = 1.0f; + attrs.score_threshold = 0.0f; + attrs.sort_result_type = op::v8::MulticlassNms::SortResultType::CLASSID; + attrs.keep_top_k = -1; + attrs.background_class = -1; + attrs.nms_eta = 0.1f; + + const auto boxes_shape = Shape{2, 6, 4}; // N 2, C 2, M 6 + const auto scores_shape = Shape{2, 2, 6}; + + const auto boxes = make_shared(element::f32, boxes_shape); + const auto scores = make_shared(element::f32, scores_shape); + auto nms = make_shared(boxes, scores, attrs); + + auto f = make_shared(nms, ParameterVector{boxes, scores}); + + std::vector expected_selected_indices = {3, 0, 5, 0, 3, 5, + 9, 6, 11, 6, 9, 11}; + std::vector expected_selected_scores = {0.00, 0.95, 0.00, 10.00, 1.00, 11.00 , + 0.00, 0.90, 0.00, 0.00, 1.00, 1.00 , + 0.00, 0.30, 0.00, 100.00, 1.00, 101.00 , + 1.00, 0.95, 0.00, 0.00, 1.00, 1.00 , + 1.00, 0.80, 0.00, 10.00, 1.00, 11.00 , + 1.00, 0.30, 0.00, 100.00, 1.00, 101.00 , + 0.00, 0.95, 0.00, 10.00, 1.00, 11.00 , + 0.00, 0.90, 0.00, 0.00, 1.00, 1.00 , + 0.00, 0.30, 0.00, 100.00, 1.00, 101.00 , + 1.00, 0.95, 0.00, 0.00, 1.00, 1.00 , + 1.00, 0.80, 0.00, 10.00, 1.00, 11.00 , + 1.00, 0.30, 0.00, 100.00, 1.00, 101.00 }; + std::vector expected_valid_outputs = {6, 6}; + + auto test_case = test::TestCase(f); + test_case.add_multiple_inputs({boxes_data, scores_data}); + test_case.add_expected_output({12, 6}, expected_selected_scores); + test_case.add_expected_output({12, 1}, expected_selected_indices); + test_case.add_expected_output({2}, expected_valid_outputs); + test_case.run(); +} diff --git a/ngraph/test/backend/prior_box.in.cpp b/ngraph/test/backend/prior_box.in.cpp new file mode 100644 index 00000000000000..f79130ee3f90c0 --- /dev/null +++ b/ngraph/test/backend/prior_box.in.cpp @@ -0,0 +1,47 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// +#include "gtest/gtest.h" + +#include "ngraph/ngraph.hpp" +#include "ngraph/op/prior_box.hpp" + +#include "util/engine/test_engines.hpp" +#include "util/test_case.hpp" +#include "util/test_control.hpp" + +using namespace std; +using namespace ngraph; + +static string s_manifest = "${MANIFEST}"; +using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); + +NGRAPH_TEST(${BACKEND_NAME}, prior_box) +{ + op::PriorBoxAttrs attrs; + attrs.min_size = {2.0f}; + attrs.aspect_ratio = {1.5f}; + attrs.scale_all_sizes = false; + + Shape layer_shape_shape{2}; + Shape image_shape_shape{2}; + vector layer_shape{2, 2}; + vector image_shape{10, 10}; + + auto LS = op::Constant::create(element::i64, layer_shape_shape, layer_shape); + auto IS = op::Constant::create(element::i64, image_shape_shape, image_shape); + auto f = make_shared(make_shared(LS, IS, attrs), ParameterVector{}); + const auto exp_shape = Shape{2, 32}; + vector out{-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}; + + auto test_case = test::TestCase(f); + test_case.add_expected_output(exp_shape, out); + test_case.run_with_tolerance_as_fp(1.0e-5f); +} diff --git a/ngraph/test/backend/sinh.in.cpp b/ngraph/test/backend/sinh.in.cpp index 903a2bf3649126..414c203766b322 100644 --- a/ngraph/test/backend/sinh.in.cpp +++ b/ngraph/test/backend/sinh.in.cpp @@ -20,38 +20,86 @@ // clang-format on #include "gtest/gtest.h" -#include "runtime/backend.hpp" -#include "ngraph/runtime/tensor.hpp" #include "ngraph/ngraph.hpp" -#include "util/all_close.hpp" -#include "util/all_close_f.hpp" -#include "util/ndarray.hpp" +#include "util/engine/test_engines.hpp" +#include "util/test_case.hpp" #include "util/test_control.hpp" -#include "util/test_tools.hpp" using namespace std; using namespace ngraph; static string s_manifest = "${MANIFEST}"; +using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); + NGRAPH_TEST(${BACKEND_NAME}, sinh) { - Shape shape{6}; + Shape shape{8}; + auto A = make_shared(element::f32, shape); + auto f = make_shared(make_shared(A), ParameterVector{A}); + + auto test_case = test::TestCase(f); + test_case.add_input({-4, -3, -2, -1, 0, 1, 2, 3}); + test_case.add_expected_output( + shape, {sinhf(-4), sinhf(-3), sinhf(-2), sinhf(-1), sinhf(0), sinhf(1), sinhf(2), sinhf(3)}); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, sinh_negative) +{ + Shape shape{5}; + auto A = make_shared(element::f32, shape); + auto f = make_shared(make_shared(A), ParameterVector{A}); + + auto test_case = test::TestCase(f); + test_case.add_input({-4, -3, -2, -1, -5}); + test_case.add_expected_output( + shape, {sinhf(-4), sinhf(-3), sinhf(-2), sinhf(-1), sinhf(-5)}); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, sinh_scalar) +{ + Shape shape{}; auto A = make_shared(element::f32, shape); auto f = make_shared(make_shared(A), ParameterVector{A}); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); + const vector a{13}; + + auto test_case = test::TestCase(f); + test_case.add_input({a}); + test_case.add_expected_output(shape, {sinhf(13)}); + test_case.run(DEFAULT_FLOAT_TOLERANCE_BITS + 2); +} + +NGRAPH_TEST(${BACKEND_NAME}, sinh_in_place) +{ + Shape shape{2}; + auto A = make_shared(element::f32, shape); + auto T = make_shared(A); + auto T2 = make_shared(T); + + auto f = make_shared(T2, ParameterVector{A}); + + const vector a{1, 3}; + + auto test_case = test::TestCase(f); + test_case.add_input({a}); + test_case.add_expected_output(shape, {sinhf(sinhf(1)), sinhf(sinhf(3))}); + test_case.run(DEFAULT_FLOAT_TOLERANCE_BITS + 2); +} - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape); - vector input{1.0f, 0.0f, -0.0f, -1.0f, 5.0f, -5.0f}; - copy_data(a, input); - auto result = backend->create_tensor(element::f32, shape); +NGRAPH_TEST(${BACKEND_NAME}, sinh_i32) +{ + Shape shape{5}; + auto A = make_shared(element::i32, shape);; + auto f = make_shared(make_shared(A), ParameterVector{A}); - std::transform( - input.begin(), input.end(), input.begin(), [](float x) -> float { return sinhf(x); }); + const vector input{2, 1, 0, -1, -2}; + const vector expected{4, 1, 0, -1, -4}; - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f(input, read_vector(result))); + auto test_case = test::TestCase(f); + test_case.add_input({input}); + test_case.add_expected_output(shape, {expected}); + test_case.run(); } diff --git a/ngraph/test/constant_folding.cpp b/ngraph/test/constant_folding.cpp index 0f5ce320531673..d7efe623708636 100644 --- a/ngraph/test/constant_folding.cpp +++ b/ngraph/test/constant_folding.cpp @@ -567,16 +567,11 @@ TEST(constant_folding, shape_of_dynamic_v0) pass_manager.register_pass(); pass_manager.run_passes(f); - ASSERT_EQ(count_ops_of_type(f), 1); - ASSERT_EQ(count_ops_of_type(f), 1); - ASSERT_EQ(count_ops_of_type(f), 1); - ASSERT_EQ(count_ops_of_type(f), 8); + ASSERT_EQ(f->get_ops().size(), 3); - auto result_as_concat = - as_type_ptr(f->get_results().at(0)->input_value(0).get_node_shared_ptr()); - ASSERT_TRUE(result_as_concat); - ASSERT_EQ(result_as_concat->get_friendly_name(), "test"); - ASSERT_EQ(result_as_concat->get_output_shape(0), Shape{7}); + auto result_shape_of = f->get_results().at(0)->get_input_node_shared_ptr(0); + ASSERT_EQ(result_shape_of, shape_of); + ASSERT_EQ(result_shape_of->get_friendly_name(), "test"); } TEST(constant_folding, shape_of_dynamic_v3) @@ -592,17 +587,11 @@ TEST(constant_folding, shape_of_dynamic_v3) pass_manager.register_pass(); pass_manager.run_passes(f); - ASSERT_EQ(count_ops_of_type(f), 1); - ASSERT_EQ(count_ops_of_type(f), 1); - ASSERT_EQ(count_ops_of_type(f), 1); - ASSERT_EQ(count_ops_of_type(f), 8); + ASSERT_EQ(f->get_ops().size(), 3); - auto result_as_concat = - as_type_ptr(f->get_results().at(0)->input_value(0).get_node_shared_ptr()); - ASSERT_TRUE(result_as_concat); - ASSERT_EQ(result_as_concat->get_friendly_name(), "test"); - ASSERT_EQ(result_as_concat->get_output_shape(0), Shape{7}); - ASSERT_EQ(result_as_concat->get_output_element_type(0), element::i64); + auto result_shape_of = f->get_results().at(0)->get_input_node_shared_ptr(0); + ASSERT_EQ(result_shape_of, shape_of); + ASSERT_EQ(result_shape_of->get_friendly_name(), "test"); } TEST(constant_folding, shape_of_dynamic_i32_v3) @@ -618,17 +607,11 @@ TEST(constant_folding, shape_of_dynamic_i32_v3) pass_manager.register_pass(); pass_manager.run_passes(f); - ASSERT_EQ(count_ops_of_type(f), 1); - ASSERT_EQ(count_ops_of_type(f), 1); - ASSERT_EQ(count_ops_of_type(f), 1); - ASSERT_EQ(count_ops_of_type(f), 8); + ASSERT_EQ(f->get_ops().size(), 3); - auto result_as_concat = - as_type_ptr(f->get_results().at(0)->input_value(0).get_node_shared_ptr()); - ASSERT_TRUE(result_as_concat); - ASSERT_EQ(result_as_concat->get_friendly_name(), "test"); - ASSERT_EQ(result_as_concat->get_output_shape(0), Shape{7}); - ASSERT_EQ(result_as_concat->get_output_element_type(0), element::i32); + auto result_shape_of = f->get_results().at(0)->get_input_node_shared_ptr(0); + ASSERT_EQ(result_shape_of, shape_of); + ASSERT_EQ(result_shape_of->get_friendly_name(), "test"); } // We need to be sure that constant folding won't be calculated endlessly. @@ -646,16 +629,11 @@ TEST(constant_folding, shape_of_dynamic_double_folding_v0) pass_manager.run_passes(f); pass_manager.run_passes(f); - ASSERT_EQ(count_ops_of_type(f), 1); - ASSERT_EQ(count_ops_of_type(f), 1); - ASSERT_EQ(count_ops_of_type(f), 1); - ASSERT_EQ(count_ops_of_type(f), 8); + ASSERT_EQ(f->get_ops().size(), 3); - auto result_as_concat = - as_type_ptr(f->get_results().at(0)->input_value(0).get_node_shared_ptr()); - ASSERT_TRUE(result_as_concat); - ASSERT_EQ(result_as_concat->get_friendly_name(), "test"); - ASSERT_EQ(result_as_concat->get_output_shape(0), Shape{7}); + auto result_shape_of = f->get_results().at(0)->get_input_node_shared_ptr(0); + ASSERT_EQ(result_shape_of, shape_of); + ASSERT_EQ(result_shape_of->get_friendly_name(), "test"); } TEST(constant_folding, shape_of_dynamic_double_folding_v3) @@ -672,16 +650,11 @@ TEST(constant_folding, shape_of_dynamic_double_folding_v3) pass_manager.run_passes(f); pass_manager.run_passes(f); - ASSERT_EQ(count_ops_of_type(f), 1); - ASSERT_EQ(count_ops_of_type(f), 1); - ASSERT_EQ(count_ops_of_type(f), 1); - ASSERT_EQ(count_ops_of_type(f), 8); + ASSERT_EQ(f->get_ops().size(), 3); - auto result_as_concat = - as_type_ptr(f->get_results().at(0)->input_value(0).get_node_shared_ptr()); - ASSERT_TRUE(result_as_concat); - ASSERT_EQ(result_as_concat->get_friendly_name(), "test"); - ASSERT_EQ(result_as_concat->get_output_shape(0), Shape{7}); + auto result_shape_of = f->get_results().at(0)->get_input_node_shared_ptr(0); + ASSERT_EQ(result_shape_of, shape_of); + ASSERT_EQ(result_shape_of->get_friendly_name(), "test"); } // Constant folding will not succeed on ShapeOf if the argument rank is dynamic. diff --git a/ngraph/test/dyn_elimination.cpp b/ngraph/test/dyn_elimination.cpp deleted file mode 100644 index 14a64c1d80bd5e..00000000000000 --- a/ngraph/test/dyn_elimination.cpp +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "gtest/gtest.h" - -#include "ngraph/ngraph.hpp" -#include "ngraph/pass/constant_folding.hpp" -#include "ngraph/pass/dyn_elimination.hpp" -#include "ngraph/pass/manager.hpp" -#include "pass/opset0_downgrade.hpp" -#include "util/all_close_f.hpp" -#include "util/test_tools.hpp" - -using namespace ngraph; -using namespace std; - -TEST(dyn_elimination, transpose) -{ - Shape shape_in{2, 4, 6, 8}; - auto param = make_shared(element::boolean, shape_in); - - auto constant_perm = - make_shared(element::i64, Shape{4}, vector{2, 3, 1, 0}); - - auto transpose = make_shared(param, constant_perm); - - auto f = make_shared(transpose, ParameterVector{param}); - - pass::Manager pass_manager; - pass_manager.register_pass(); - pass_manager.run_passes(f); - - ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); - - auto new_reshape = - as_type_ptr(f->get_results().at(0)->input_value(0).get_node_shared_ptr()); - ASSERT_TRUE(new_reshape); - - ASSERT_EQ(new_reshape->get_input_order(), (AxisVector{2, 3, 1, 0})); - ASSERT_EQ(new_reshape->get_output_shape(0), (Shape{6, 8, 4, 2})); - ASSERT_EQ(new_reshape->get_output_element_type(0), element::boolean); -} - -// For now, we can't handle the case where the input has dynamic shapes, -// because the classic Reshape op demands a Shape. Probably won't be able to -// deal with this until/unless we make a "StaticTranspose". Just make sure -// we don't crash or mangle the graph. -TEST(dyn_elimination, transpose_dyn_shape) -{ - PartialShape shape_in{2, 4, Dimension::dynamic(), 8}; - - auto param = make_shared(element::boolean, shape_in); - - auto constant_perm = - make_shared(element::i64, Shape{4}, vector{2, 3, 1, 0}); - - auto transpose = make_shared(param, constant_perm); - - auto f = make_shared(transpose, ParameterVector{param}); - - pass::Manager pass_manager; - pass_manager.register_pass(); - pass_manager.run_passes(f); - - ASSERT_EQ(count_ops_of_type(f), 1); - ASSERT_EQ(count_ops_of_type(f), 1); - - auto new_transpose = - as_type_ptr(f->get_results().at(0)->input_value(0).get_node_shared_ptr()); - ASSERT_TRUE(new_transpose); - - ASSERT_EQ(new_transpose->get_output_element_type(0), element::boolean); - ASSERT_TRUE(new_transpose->get_output_partial_shape(0).relaxes( - PartialShape{Dimension::dynamic(), 8, 4, 2})); -} - -TEST(dyn_elimination, range) -{ - auto constant_start = make_shared(element::i64, Shape{}, vector{0}); - auto constant_stop = make_shared(element::i64, Shape{}, vector{5}); - auto constant_step = make_shared(element::i64, Shape{}, vector{2}); - - auto range = make_shared(constant_start, constant_stop, constant_step); - - ASSERT_EQ(range->get_element_type(), element::i64); - ASSERT_EQ(range->get_shape(), (Shape{3})); - - auto f = make_shared(range, ParameterVector{}); - - pass::Manager pass_manager; - pass_manager.register_pass(); - pass_manager.run_passes(f); - - ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); - - auto replacement = - as_type_ptr(f->get_results().at(0)->input_value(0).get_node_shared_ptr()); - - ASSERT_NE(replacement, nullptr); - ASSERT_EQ(replacement->get_element_type(), element::i64); - ASSERT_EQ(replacement->get_shape(), (Shape{3})); - - auto vals = replacement->get_vector(); - - ASSERT_EQ(vals, (vector{0, 2, 4})); -} - -TEST(dyn_elimination, range_f64) -{ - auto constant_start = make_shared(element::f64, Shape{}, vector{-0.5}); - auto constant_stop = make_shared(element::f64, Shape{}, vector{2}); - auto constant_step = make_shared(element::f64, Shape{}, vector{0.25}); - - auto range = make_shared(constant_start, constant_stop, constant_step); - - ASSERT_EQ(range->get_element_type(), element::f64); - ASSERT_EQ(range->get_shape(), (Shape{10})); - - auto f = make_shared(range, ParameterVector{}); - - pass::Manager pass_manager; - pass_manager.register_pass(); - pass_manager.run_passes(f); - - ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); - - auto replacement = - as_type_ptr(f->get_results().at(0)->input_value(0).get_node_shared_ptr()); - - ASSERT_NE(replacement, nullptr); - ASSERT_EQ(replacement->get_element_type(), element::f64); - ASSERT_EQ(replacement->get_shape(), (Shape{10})); - - auto vals = replacement->get_vector(); - - ASSERT_TRUE(test::all_close_f( - vals, vector{-0.5, -0.25, 0, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75})); -} diff --git a/ngraph/test/files/paddlepaddle/gen_scripts/generate_argmax.py b/ngraph/test/files/paddlepaddle/gen_scripts/generate_argmax.py new file mode 100644 index 00000000000000..54b24364b2d481 --- /dev/null +++ b/ngraph/test/files/paddlepaddle/gen_scripts/generate_argmax.py @@ -0,0 +1,60 @@ +# +# pool2d paddle model generator +# +import numpy as np +from save_model import saveModel +import sys +data_type = 'float32' + + +def pdpd_argmax(name : str, x, axis): + import paddle as pdpd + pdpd.enable_static() + + with pdpd.static.program_guard(pdpd.static.Program(), pdpd.static.Program()): + node_x = pdpd.static.data(name='x', shape=x.shape, dtype='float32') + out = pdpd.argmax(x=node_x, axis=axis) + out = pdpd.cast(out, np.float32) + cpu = pdpd.static.cpu_places(1) + exe = pdpd.static.Executor(cpu[0]) + # startup program will call initializer to initialize the parameters. + exe.run(pdpd.static.default_startup_program()) + + outs = exe.run( + feed={'x': x}, + fetch_list=[out]) + + saveModel(name, exe, feedkeys=['x'], fetchlist=[out], inputs=[x], outputs=[outs[0]], target_dir=sys.argv[1]) + + return outs[0] + +def pdpd_argmax1(name : str, x): + import paddle as pdpd + pdpd.enable_static() + + with pdpd.static.program_guard(pdpd.static.Program(), pdpd.static.Program()): + node_x = pdpd.static.data(name='x', shape=x.shape, dtype='float32') + out = pdpd.argmax(x=node_x) + out = pdpd.cast(out, np.float32) + cpu = pdpd.static.cpu_places(1) + exe = pdpd.static.Executor(cpu[0]) + # startup program will call initializer to initialize the parameters. + exe.run(pdpd.static.default_startup_program()) + + outs = exe.run( + feed={'x': x}, + fetch_list=[out]) + + saveModel(name, exe, feedkeys=['x'], fetchlist=[out], inputs=[x], outputs=[outs[0]], target_dir=sys.argv[1]) + + return outs[0] + +def main(): + data = np.random.random([3,5,7,2]).astype("float32") + axis = 0 + pdpd_argmax("argmax", data, axis) + pdpd_argmax1("argmax1", data) + + +if __name__ == "__main__": + main() diff --git a/ngraph/test/files/paddlepaddle/gen_scripts/generate_assign_value.py b/ngraph/test/files/paddlepaddle/gen_scripts/generate_assign_value.py new file mode 100644 index 00000000000000..7d29574b2a92b4 --- /dev/null +++ b/ngraph/test/files/paddlepaddle/gen_scripts/generate_assign_value.py @@ -0,0 +1,58 @@ +import numpy as np +from save_model import saveModel +import sys + + +def pdpd_assign_value(name, test_x): + import paddle as pdpd + pdpd.enable_static() + main_program = pdpd.static.Program() + startup_program = pdpd.static.Program() + with pdpd.static.program_guard(main_program, startup_program): + node_x = pdpd.static.data(name='x', shape=test_x.shape, dtype=test_x.dtype if test_x.dtype != np.bool else np.int32) + node_x = pdpd.cast(node_x, dtype=test_x.dtype) + const_value = pdpd.assign(test_x, output=None) + result = pdpd.cast(pdpd.concat([node_x, const_value], 0), dtype=np.float32) + cpu = pdpd.static.cpu_places(1) + exe = pdpd.static.Executor(cpu[0]) + # startup program will call initializer to initialize the parameters. + exe.run(pdpd.static.default_startup_program()) + if test_x.dtype == np.bool: + test_x = test_x.astype(np.int32) + + outs = exe.run( + feed={'x': test_x}, + fetch_list=[result] + ) + + saveModel(name, exe, feedkeys=['x'], fetchlist=[result], inputs=[test_x], outputs=[outs[0]], target_dir=sys.argv[1]) + + print(outs[0]) + + +def compare(): + + test_cases = [ + { + "name": "assign_value_fp32", + "input": np.ones([1, 1, 4, 4]).astype(np.float32) + }, + { + "name": "assign_value_int32", + "input": np.ones([1, 1, 4, 4]).astype(np.int32) + }, + { + "name": "assign_value_int64", + "input": np.ones([1, 1, 4, 4]).astype(np.int64) + }, + { + "name": "assign_value_boolean", + "input": np.array([False, True, False]) + } + ] + for test in test_cases: + pdpd_assign_value(test['name'], test['input']) + + +if __name__ == "__main__": + compare() diff --git a/ngraph/test/files/paddlepaddle/gen_scripts/generate_batch_norm.py b/ngraph/test/files/paddlepaddle/gen_scripts/generate_batch_norm.py new file mode 100644 index 00000000000000..fbbba99160c4da --- /dev/null +++ b/ngraph/test/files/paddlepaddle/gen_scripts/generate_batch_norm.py @@ -0,0 +1,89 @@ +# +# pool2d paddle model generator +# +import numpy as np +from save_model import saveModel +import sys + + +def batch_norm1(name : str, x, scale, bias, mean, var, data_layout): + import paddle as pdpd + pdpd.enable_static() + + node_x = pdpd.static.data(name='x', shape=x.shape, dtype='float32') + scale_attr = pdpd.ParamAttr(name="scale1", initializer=pdpd.nn.initializer.Assign(scale)) + bias_attr = pdpd.ParamAttr(name="bias1", initializer=pdpd.nn.initializer.Assign(bias)) + + out = pdpd.static.nn.batch_norm(node_x, epsilon=1e-5, + param_attr=scale_attr, + bias_attr=bias_attr, + moving_mean_name="bn_mean1", + moving_variance_name="bn_variance1", + use_global_stats=True, + data_layout=data_layout) + + cpu = pdpd.static.cpu_places(1) + exe = pdpd.static.Executor(cpu[0]) + # startup program will call initializer to initialize the parameters. + exe.run(pdpd.static.default_startup_program()) + pdpd.static.global_scope().var("bn_mean1").get_tensor().set(mean, pdpd.CPUPlace()) + pdpd.static.global_scope().var("bn_variance1").get_tensor().set(var, pdpd.CPUPlace()) + + outs = exe.run( + feed={'x': x}, + fetch_list=[out]) + + saveModel(name, exe, feedkeys=['x'], fetchlist=[out], inputs=[x], outputs=[outs[0]], target_dir=sys.argv[1]) + + return outs[0] + +def batch_norm2(name : str, x, scale, bias, mean, var, data_layout): + import paddle as pdpd + pdpd.enable_static() + + node_x = pdpd.static.data(name='x', shape=x.shape, dtype='float32') + scale_attr = pdpd.ParamAttr(name="scale2", initializer=pdpd.nn.initializer.Assign(scale)) + bias_attr = pdpd.ParamAttr(name="bias2", initializer=pdpd.nn.initializer.Assign(bias)) + + out = pdpd.static.nn.batch_norm(node_x, epsilon=1e-5, + param_attr=scale_attr, + bias_attr=bias_attr, + moving_mean_name="bn_mean2", + moving_variance_name="bn_variance2", + use_global_stats=True, + data_layout=data_layout) + + cpu = pdpd.static.cpu_places(1) + exe = pdpd.static.Executor(cpu[0]) + # startup program will call initializer to initialize the parameters. + exe.run(pdpd.static.default_startup_program()) + pdpd.static.global_scope().var("bn_mean2").get_tensor().set(mean, pdpd.CPUPlace()) + pdpd.static.global_scope().var("bn_variance2").get_tensor().set(var, pdpd.CPUPlace()) + + outs = exe.run( + feed={'x': x}, + fetch_list=[out]) + + saveModel(name, exe, feedkeys=['x'], fetchlist=[out], inputs=[x], outputs=[outs[0]], target_dir=sys.argv[1]) + + return outs[0] + +def main(): + import paddle as pdpd + data = np.array([[[[-1, 0, 1]], [[2, 3, 4]]]]).astype(np.float32) + # data layout is NCHW + scale = np.array([1.0, 1.5]).astype(np.float32) + bias = np.array([0, 1]).astype(np.float32) + mean = np.array([0, 3]).astype(np.float32) + var = np.array([1, 1.5]).astype(np.float32) + batch_norm1("batch_norm_nchw", data, scale, bias, mean, var, "NCHW") + + # data layout is NHWC + scale = np.array([1.0, 1.5, 2.0]).astype(np.float32) + bias = np.array([0, 1, 2]).astype(np.float32) + mean = np.array([0.5, 1.5, 1.5]).astype(np.float32) + var = np.array([1, 1.5, 2]).astype(np.float32) + batch_norm2("batch_norm_nhwc", data, scale, bias, mean, var, "NHWC") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/ngraph/test/files/paddlepaddle/gen_scripts/generate_clip.py b/ngraph/test/files/paddlepaddle/gen_scripts/generate_clip.py new file mode 100644 index 00000000000000..55edd6c62dd0d2 --- /dev/null +++ b/ngraph/test/files/paddlepaddle/gen_scripts/generate_clip.py @@ -0,0 +1,39 @@ +# +# clip paddle model generator +# +import numpy as np +from save_model import saveModel +import sys + +def clip(name: str, x, min, max): + import paddle as pdpd + pdpd.enable_static() + + with pdpd.static.program_guard(pdpd.static.Program(), pdpd.static.Program()): + node_x = pdpd.static.data(name='x', shape=x.shape, dtype='float32') + out = pdpd.fluid.layers.clip(node_x, min=min, max=max) + + cpu = pdpd.static.cpu_places(1) + exe = pdpd.static.Executor(cpu[0]) + # startup program will call initializer to initialize the parameters. + exe.run(pdpd.static.default_startup_program()) + + outs = exe.run( + feed={'x': x}, + fetch_list=[out]) + + saveModel(name, exe, feedkeys=['x'], fetchlist=[out], inputs=[x], outputs=[outs[0]], target_dir=sys.argv[1]) + + return outs[0] + + +def main(): + data = np.random.random([2, 3, 4]).astype('float32') + min = 0 + max = 0.8 + + clip("clip", data, min, max) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/ngraph/test/frontend/paddlepaddle/op_fuzzy.cpp b/ngraph/test/frontend/paddlepaddle/op_fuzzy.cpp new file mode 100644 index 00000000000000..a2d29bfb6e6aa6 --- /dev/null +++ b/ngraph/test/frontend/paddlepaddle/op_fuzzy.cpp @@ -0,0 +1,40 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "util/engine/test_engines.hpp" +#include "util/test_control.hpp" +#include +#include "op_fuzzy.hpp" +#include "ngraph/ngraph.hpp" + +using namespace ngraph; +using namespace InferenceEngine; +using namespace ngraph; +using namespace ngraph::frontend; +using TestEngine = test::IE_CPU_Engine; + +static const std::string PDPD = "pdpd"; +using PDPDFuzzyOpTest = FrontEndFuzzyOpTest; + +static const std::vector models{ + std::string("argmax"), + std::string("argmax1"), + std::string("assign_value_boolean"), + std::string("assign_value_fp32"), + std::string("assign_value_int32"), + std::string("assign_value_int64"), + std::string("batch_norm_nchw"), + std::string("batch_norm_nhwc"), + std::string("clip"), + std::string("relu"), +}; + +INSTANTIATE_TEST_SUITE_P(PDPDFuzzyOpTest, + FrontEndFuzzyOpTest, + ::testing::Combine(::testing::Values(PDPD), + ::testing::Values(std::string(TEST_PDPD_MODELS)), + ::testing::ValuesIn(models)), + PDPDFuzzyOpTest::getTestCaseName); diff --git a/ngraph/test/frontend/shared/include/op_fuzzy.hpp b/ngraph/test/frontend/shared/include/op_fuzzy.hpp new file mode 100644 index 00000000000000..0d11df6c8b51b0 --- /dev/null +++ b/ngraph/test/frontend/shared/include/op_fuzzy.hpp @@ -0,0 +1,35 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +#include + +using FuzzyOpTestParam = std::tuple; // Model name + +class FrontEndFuzzyOpTest : public ::testing::TestWithParam +{ +public: + std::string m_feName; + std::string m_pathToModels; + std::string m_modelFile; + ngraph::frontend::FrontEndManager m_fem; + ngraph::frontend::FrontEnd::Ptr m_frontEnd; + ngraph::frontend::InputModel::Ptr m_inputModel; + + static std::string getTestCaseName(const testing::TestParamInfo& obj); + + void SetUp() override; + +protected: + void initParamTest(); + + void doLoadFromFile(); + + void runConvertedModel(const std::shared_ptr function, const std::string& model_file); +}; diff --git a/ngraph/test/frontend/shared/src/op_fuzzy.cpp b/ngraph/test/frontend/shared/src/op_fuzzy.cpp new file mode 100644 index 00000000000000..526207d25a66ce --- /dev/null +++ b/ngraph/test/frontend/shared/src/op_fuzzy.cpp @@ -0,0 +1,163 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "util/engine/test_engines.hpp" +#include "util/test_case.hpp" +#include "util/test_control.hpp" +#include "op_fuzzy.hpp" +#include "utils.hpp" + +using namespace ngraph; +using namespace InferenceEngine; + +using namespace ngraph; +using namespace ngraph::frontend; +using TestEngine = test::IE_CPU_Engine; + +std::string + FrontEndFuzzyOpTest::getTestCaseName(const testing::TestParamInfo& obj) +{ + std::string fe, path, fileName; + std::tie(fe, path, fileName) = obj.param; + return fe + "_" + FrontEndTestUtils::fileToTestName(fileName); +} + +void FrontEndFuzzyOpTest::SetUp() +{ + FrontEndTestUtils::setupTestEnv(); + m_fem = FrontEndManager(); // re-initialize after setting up environment + initParamTest(); +} + +void FrontEndFuzzyOpTest::initParamTest() +{ + std::tie(m_feName, m_pathToModels, m_modelFile) = GetParam(); + m_modelFile = m_pathToModels + m_modelFile; +} + +void FrontEndFuzzyOpTest::doLoadFromFile() +{ + std::vector frontends; + ASSERT_NO_THROW(frontends = m_fem.get_available_front_ends()); + ASSERT_NO_THROW(m_frontEnd = m_fem.load_by_framework(m_feName)); + ASSERT_NE(m_frontEnd, nullptr); + ASSERT_NO_THROW(m_inputModel = m_frontEnd->load_from_file(m_modelFile)); + ASSERT_NE(m_inputModel, nullptr); +} + +template +inline void addInputOutput(cnpy::NpyArray& npy_array, + test::TestCase& test_case, + bool is_input = true) +{ + T* npy_begin = npy_array.data(); + std::vector data(npy_begin, npy_begin + npy_array.num_vals); + if (is_input) + test_case.add_input(data); + else + test_case.add_expected_output(data); +} + +static bool ends_with(std::string const& value, std::string const& ending) +{ + if (ending.size() > value.size()) + return false; + return std::equal(ending.rbegin(), ending.rend(), value.rbegin()); +} + +static std::string getModelFolder(const std::string& modelFile) +{ + if (!ends_with(modelFile, ".pdmodel")) + return modelFile; + size_t found = modelFile.find_last_of("/\\"); + return modelFile.substr(0, found); +}; + +void FrontEndFuzzyOpTest::runConvertedModel(const std::shared_ptr function, + const std::string& modelFile) +{ + auto modelFolder = getModelFolder(modelFile); + + // run test + auto testCase = test::TestCase(function); + + const auto parameters = function->get_parameters(); + for (size_t i = 0; i < parameters.size(); i++) + { + // read input npy file + std::string dataFile = + modelFolder + "/input" + std::to_string((parameters.size() - 1) - i) + ".npy"; + cnpy::NpyArray input = cnpy::npy_load(dataFile); + auto input_dtype = parameters[i]->get_element_type(); + + if (input_dtype == element::f32) + { + addInputOutput(input, testCase, true); + } + else if (input_dtype == element::i32) + { + addInputOutput(input, testCase, true); + } + else if (input_dtype == element::i64) + { + addInputOutput(input, testCase, true); + } + else + { + throw std::runtime_error("not supported dtype in" + input_dtype.get_type_name()); + } + } + + const auto results = function->get_results(); + bool useFloatTest = false; + for (size_t i = 0; i < results.size(); i++) + { + // read expected output npy file + std::string dataFile = modelFolder + "/output" + std::to_string(i) + ".npy"; + cnpy::NpyArray output = cnpy::npy_load(dataFile); + auto outputDtype = results[i]->get_element_type(); + if (outputDtype == element::f32) + { + addInputOutput(output, testCase, false); + useFloatTest = true; + } + else if (outputDtype == element::i32) + { + addInputOutput(output, testCase, false); + } + else if (outputDtype == element::i64) + { + addInputOutput(output, testCase, false); + } + else + { + throw std::runtime_error("not supported dtype out " + outputDtype.get_type_name()); + } + } + + if (useFloatTest) + { + testCase.run_with_tolerance_as_fp(); + } + else + { + testCase.run(); + } +} + +TEST_P(FrontEndFuzzyOpTest, testOpFuzzy) +{ + // load + ASSERT_NO_THROW(doLoadFromFile()); + + // convert + std::shared_ptr function; + function = m_frontEnd->convert(m_inputModel); + ASSERT_NE(function, nullptr); + + // run + runConvertedModel(function, m_modelFile); +} diff --git a/ngraph/test/models/onnx/constant_fill_shape_attribute.prototxt b/ngraph/test/models/onnx/constant_fill_shape_attribute.prototxt index 806f01ffd89ddf..cdbbf99419a241 100644 --- a/ngraph/test/models/onnx/constant_fill_shape_attribute.prototxt +++ b/ngraph/test/models/onnx/constant_fill_shape_attribute.prototxt @@ -2,7 +2,6 @@ ir_version: 7 producer_name: "backend-test" graph { node { - input: "target_shape" output: "output" op_type: "ConstantFill" attribute { diff --git a/ngraph/test/op_is.cpp b/ngraph/test/op_is.cpp deleted file mode 100644 index a3f81b3d8003de..00000000000000 --- a/ngraph/test/op_is.cpp +++ /dev/null @@ -1,577 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "gtest/gtest.h" - -#include "ngraph/ngraph.hpp" -#include "ngraph/op/util/op_types.hpp" -#include "ngraph/validation_util.hpp" -#include "op/convolution.hpp" -#include "op/group_conv.hpp" -#include "util/test_tools.hpp" - -using namespace ngraph; - -NGRAPH_SUPPRESS_DEPRECATED_START - -namespace -{ - void op_is_Abs() - { - op::Abs node; - EXPECT_TRUE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Acos() - { - op::Acos node; - EXPECT_TRUE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Asin() - { - op::Asin node; - EXPECT_TRUE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Atan() - { - op::Atan node; - EXPECT_TRUE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_AvgPool() - { - op::AvgPool node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_BatchNormInference() - { - op::v0::BatchNormInference node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Broadcast() - { - op::v1::Broadcast node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Ceiling() - { - op::Ceiling node; - EXPECT_TRUE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Clamp() - { - op::Clamp node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Concat() - { - op::Concat node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Constant() - { - op::Constant node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Convert() - { - op::Convert node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Convolution() - { - op::v0::Convolution node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_ConvolutionBackpropData() - { - op::v0::ConvolutionBackpropData node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Cos() - { - op::Cos node; - EXPECT_TRUE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Cosh() - { - op::Cosh node; - EXPECT_TRUE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_CumSum() - { - op::CumSum node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_DepthToSpace() - { - op::DepthToSpace node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Elu() - { - op::Elu node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Erf() - { - op::Erf node; - EXPECT_TRUE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Exp() - { - op::Exp node; - EXPECT_TRUE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_FakeQuantize() - { - op::FakeQuantize node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Floor() - { - op::Floor node; - EXPECT_TRUE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_GRN() - { - op::GRN node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Gather() - { - op::v1::Gather node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Gelu() - { - op::Gelu node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_GroupConvolution() - { - op::v0::GroupConvolution node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_GroupConvolutionBackpropData() - { - op::v0::GroupConvolutionBackpropData node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_HardSigmoid() - { - op::HardSigmoid node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Interpolate() - { - op::v0::Interpolate node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Log() - { - op::Log node; - EXPECT_TRUE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_LRN() - { - op::LRN node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_LSTMSequence() - { - op::v0::LSTMSequence node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_MatMul() - { - op::MatMul node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_NormalizeL2() - { - op::v0::NormalizeL2 node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_MVN() - { - op::MVN node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Negative() - { - op::Negative node; - EXPECT_TRUE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Parameter() - { - op::Parameter node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_PRelu() - { - op::PRelu node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_PriorBox() - { - op::PriorBox node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Range() - { - op::Range node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Relu() - { - op::Relu node; - EXPECT_TRUE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Result() - { - op::Result node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_ReverseSequence() - { - op::ReverseSequence node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Selu() - { - op::Selu node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_ShapeOf() - { - op::ShapeOf node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_ShuffleChannels() - { - op::ShuffleChannels node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Sigmoid() - { - op::Sigmoid node; - EXPECT_TRUE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Sign() - { - op::Sign node; - EXPECT_TRUE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Sin() - { - op::Sin node; - EXPECT_TRUE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Sinh() - { - op::Sinh node; - EXPECT_TRUE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_SpaceToDepth() - { - op::SpaceToDepth node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Sqrt() - { - op::Sqrt node; - EXPECT_TRUE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_SquaredDifference() - { - op::SquaredDifference node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_TRUE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Squeeze() - { - op::Squeeze node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Tan() - { - op::Tan node; - EXPECT_TRUE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Tanh() - { - op::Tanh node; - EXPECT_TRUE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_TensorIterator() - { - op::TensorIterator node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Tile() - { - op::v0::Tile node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Unsqueeze() - { - op::v0::Unsqueeze node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - - void op_is_Xor() - { - op::Xor node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_TRUE(op::is_binary_elementwise_logical(&node)); - } -} // namespace - -TEST(op_is, check) -{ - NGRAPH_SUPPRESS_DEPRECATED_START -#define NGRAPH_OP(a, b) op_is_##a(); -#include "opset0_tbl.hpp" -#undef NGRAPH_OP - NGRAPH_SUPPRESS_DEPRECATED_END -} diff --git a/ngraph/test/pass_liveness.cpp b/ngraph/test/pass_liveness.cpp deleted file mode 100644 index 5c3553de38199b..00000000000000 --- a/ngraph/test/pass_liveness.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include -#include -#include - -#include "gtest/gtest.h" - -#include "ngraph/log.hpp" -#include "ngraph/ngraph.hpp" -#include "ngraph/pass/manager.hpp" -#include "ngraph/pass/visualize_tree.hpp" -#include "pass/liveness.hpp" - -#include "util/test_tools.hpp" - -using namespace std; -using namespace ngraph; -namespace ng = ngraph; - -TEST(liveness, constant) -{ - Shape shape{1}; - auto c = op::Constant::create(element::i32, shape, {5}); - auto f = make_shared(make_shared(c), ParameterVector{}); - - pass::Manager pass_manager; - pass_manager.register_pass(); - pass_manager.run_passes(f); - - auto tmp = f->get_ordered_ops(); - vector> sorted{tmp.begin(), tmp.end()}; - ASSERT_EQ(3, sorted.size()); - EXPECT_EQ(0, sorted[0]->liveness_new_list.size()); - EXPECT_EQ(0, sorted[0]->liveness_free_list.size()); - - // op::Negative is live on output to op::Result - // op::Negative is new - EXPECT_EQ(1, sorted[1]->liveness_new_list.size()); - EXPECT_EQ(0, sorted[1]->liveness_free_list.size()); - - // op::Negative is live on input to op::Result - EXPECT_EQ(0, sorted[2]->liveness_new_list.size()); - // op::Negative is freed - EXPECT_EQ(1, sorted[2]->liveness_free_list.size()); -} diff --git a/ngraph/test/pass_shape_relevance.cpp b/ngraph/test/pass_shape_relevance.cpp deleted file mode 100644 index d288f8d0b52206..00000000000000 --- a/ngraph/test/pass_shape_relevance.cpp +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include -#include -#include - -#include "gtest/gtest.h" - -#include "ngraph/ngraph.hpp" -#include "ngraph/pass/manager.hpp" -#include "pass/shape_relevance.hpp" - -NGRAPH_SUPPRESS_DEPRECATED_START - -using namespace ngraph; -using namespace std; - -TEST(shape_relevance, simple) -{ - auto param0 = make_shared(element::f32, Shape{4, 6}); - auto param1 = make_shared(element::f32, Shape{4, 6}); - auto x = make_shared(param0, param1); - - auto f = make_shared(x, ParameterVector{param0, param1}); - - pass::Manager manager; - manager.register_pass(); - manager.run_passes(f); - - ASSERT_FALSE(param0->is_relevant_to_shapes()); - ASSERT_FALSE(param1->is_relevant_to_shapes()); -} - -TEST(shape_relevance, param_direct) -{ - auto param0 = make_shared(element::f32, Shape{4, 6}); - auto param1 = make_shared(element::i64, Shape{4}); - auto x = make_shared(param0, param1, true); - - auto f = make_shared(x, ParameterVector{param0, param1}); - - pass::Manager manager; - manager.register_pass(); - manager.run_passes(f); - - ASSERT_FALSE(param0->is_relevant_to_shapes()); - ASSERT_TRUE(param1->is_relevant_to_shapes()); -} - -TEST(shape_relevance, param_indirect) -{ - auto param0 = make_shared(element::f32, Shape{4, 6}); - auto param1 = make_shared(element::i64, Shape{4}); - auto param2 = make_shared(element::i64, Shape{2}); - - auto c = make_shared(NodeVector{param1, param2}, 0); - auto x = make_shared(param0, c, true); - - auto f = make_shared(x, ParameterVector{param0, param1, param2}); - - pass::Manager manager; - manager.register_pass(); - manager.run_passes(f); - - ASSERT_FALSE(param0->is_relevant_to_shapes()); - ASSERT_TRUE(param1->is_relevant_to_shapes()); - ASSERT_TRUE(param2->is_relevant_to_shapes()); -} - -TEST(shape_relevance, param_shape_of_direct_v0) -{ - auto param0 = make_shared(element::f32, Shape{4, 6}); - - auto x = make_shared(param0, make_shared(param0), true); - - auto f = make_shared(x, ParameterVector{param0}); - - pass::Manager manager; - manager.register_pass(); - manager.run_passes(f); - - ASSERT_FALSE(param0->is_relevant_to_shapes()); -} - -TEST(shape_relevance, param_shape_of_direct_v3) -{ - auto param0 = make_shared(element::f32, Shape{4, 6}); - - auto x = make_shared(param0, make_shared(param0), true); - - auto f = make_shared(x, ParameterVector{param0}); - - pass::Manager manager; - manager.register_pass(); - manager.run_passes(f); - - ASSERT_FALSE(param0->is_relevant_to_shapes()); -} - -TEST(shape_relevance, param_shape_of_direct_i32_v3) -{ - auto param0 = make_shared(element::f32, Shape{4, 6}); - - auto x = make_shared( - param0, make_shared(param0, element::i32), true); - - auto f = make_shared(x, ParameterVector{param0}); - - pass::Manager manager; - manager.register_pass(); - manager.run_passes(f); - - ASSERT_FALSE(param0->is_relevant_to_shapes()); -} - -TEST(shape_relevance, param_shape_of_indirect_v0) -{ - auto param0 = make_shared(element::f32, Shape{4, 6}); - - auto s = make_shared(param0); - auto r = make_shared( - s, op::Constant::create(element::i64, {1}, {0}), op::v1::Reverse::Mode::INDEX); - auto x = make_shared(param0, r, true); - - auto f = make_shared(x, ParameterVector{param0}); - - pass::Manager manager; - manager.register_pass(); - manager.run_passes(f); - - ASSERT_FALSE(param0->is_relevant_to_shapes()); -} - -TEST(shape_relevance, param_shape_of_indirect_v3) -{ - auto param0 = make_shared(element::f32, Shape{4, 6}); - - auto s = make_shared(param0); - auto r = make_shared( - s, op::Constant::create(element::i64, {1}, {0}), op::v1::Reverse::Mode::INDEX); - auto x = make_shared(param0, r, true); - - auto f = make_shared(x, ParameterVector{param0}); - - pass::Manager manager; - manager.register_pass(); - manager.run_passes(f); - - ASSERT_FALSE(param0->is_relevant_to_shapes()); -} - -TEST(shape_relevance, param_shape_of_indirect_i32_v3) -{ - auto param0 = make_shared(element::f32, Shape{4, 6}); - - auto s = make_shared(param0, element::i32); - auto r = make_shared( - s, op::Constant::create(element::i64, {1}, {0}), op::v1::Reverse::Mode::INDEX); - auto x = make_shared(param0, r, true); - - auto f = make_shared(x, ParameterVector{param0}); - - pass::Manager manager; - manager.register_pass(); - manager.run_passes(f); - - ASSERT_FALSE(param0->is_relevant_to_shapes()); -} diff --git a/ngraph/test/provenance.cpp b/ngraph/test/provenance.cpp index c814eb55c1e1a9..f4878341ab7894 100644 --- a/ngraph/test/provenance.cpp +++ b/ngraph/test/provenance.cpp @@ -15,7 +15,6 @@ #include "ngraph/ngraph.hpp" #include "ngraph/pass/manager.hpp" #include "ngraph/provenance.hpp" -#include "pass/fused_op_decomposition.hpp" #include "util/provenance_enabler.hpp" using namespace std; @@ -380,61 +379,6 @@ TEST(provenance, builder) } } -TEST(provenance, fused_copy_origin_tags) -{ - test::ProvenanceEnabler provenance_enabler; - - auto p1 = make_shared(element::f32, PartialShape{2, 3, 4}); - p1->add_provenance_tag("P1"); - auto g = make_shared(p1); - g->add_provenance_tag("G"); - auto r = make_shared(g); - auto f = make_shared(ResultVector{r}, ParameterVector{p1}); - - pass::Manager manager; - manager.register_pass(); - manager.run_passes(f); - - traverse_nodes(f, [&](const std::shared_ptr& node) { - auto tags = node->get_provenance_tags(); - if (node == p1) - { - EXPECT_EQ(tags.size(), 1); - EXPECT_TRUE(tags.find("P1") != tags.end()); - } - else if (node == r) - { - } - else - { - EXPECT_TRUE(tags.find("G") != tags.end()); - EXPECT_TRUE(tags.find("") != tags.end()); - } - }); -} - -TEST(provenance, fused_decomposition_tag) -{ - test::ProvenanceEnabler provenance_enabler; - - auto p1 = make_shared(element::f32, PartialShape{2, 3, 4}); - auto fused_op = make_shared(p1); - auto result = make_shared(fused_op); - auto f = make_shared(ResultVector{result}, ParameterVector{p1}); - - pass::Manager manager; - manager.register_pass(); - manager.run_passes(f); - - const auto tag = ""; - auto tag_check = [&tag](std::shared_ptr node) { - auto tags = node->get_provenance_tags(); - EXPECT_TRUE(tags.find(tag) != tags.end()); - }; - const auto decomposed_op = f->get_result()->get_input_node_shared_ptr(0); - traverse_nodes(as_node_vector(decomposed_op->outputs()), tag_check, {p1}); -} - TEST(provenance, empty_group) { auto p1 = make_shared(element::i32, PartialShape{2, 3, 4}); diff --git a/ngraph/test/replace_node.cpp b/ngraph/test/replace_node.cpp index 498fb8ad1d72ba..c69b73d1623536 100644 --- a/ngraph/test/replace_node.cpp +++ b/ngraph/test/replace_node.cpp @@ -108,3 +108,63 @@ TEST(replace_node, replace_nodes) ASSERT_EQ(z_replacement->get_input_node_shared_ptr(0), x_replacement); ASSERT_EQ(z_replacement->get_input_node_shared_ptr(1), mul); } + +TEST(replace_node, simple_node_replacement) +{ + auto param = std::make_shared(element::i64, Shape{1, 64}); + param->output(0).get_tensor().set_names({"a", "b"}); + auto relu = std::make_shared(param); + relu->output(0).get_tensor().set_names({"c", "d"}); + + auto new_relu = std::make_shared(param); + new_relu->output(0).get_tensor().set_names({"f"}); + replace_node(relu, new_relu); + + ASSERT_EQ(new_relu->output(0).get_tensor().get_names(), std::unordered_set({"c", "d"})); +} + +TEST(replace_node, node_elimination) +{ + auto param = std::make_shared(element::i64, Shape{1, 64}); + param->output(0).get_tensor().set_names({"a", "b"}); + auto relu1 = std::make_shared(param); + relu1->output(0).get_tensor().set_names({"c", "d"}); + auto relu2 = std::make_shared(relu1); + relu2->output(0).get_tensor().set_names({"e", "f"}); + + ASSERT_TRUE(replace_output_update_name(relu2->output(0), relu2->input_value(0))); + ASSERT_EQ(relu1->output(0).get_tensor().get_names(), std::unordered_set({"c", "d", "e", "f"})); + ASSERT_EQ(param->output(0).get_tensor().get_names(), std::unordered_set({"a", "b"})); +} + +TEST(replace_node, output_replacement) +{ + auto param = std::make_shared(element::i64, Shape{1, 64}); + param->output(0).get_tensor().set_names({"a", "b"}); + auto relu = std::make_shared(param); + relu->output(0).get_tensor().set_names({"c", "d"}); + + auto new_relu = std::make_shared(param); + new_relu->output(0).get_tensor().set_names({"f"}); + + relu->output(0).replace(new_relu->output(0)); + + ASSERT_EQ(new_relu->output(0).get_tensor().get_names(), std::unordered_set({"c", "d"})); +} + +TEST(replace_node, source_replacement) +{ + auto param = std::make_shared(element::i64, Shape{1, 64}); + param->output(0).get_tensor().set_names({"a", "b"}); + + auto param1 = std::make_shared(element::i64, Shape{1, 64}); + param1->output(0).get_tensor().set_names({"c", "d"}); + + auto relu = std::make_shared(param); + relu->input(0).replace_source_output(param1->output(0)); + + ASSERT_EQ(param->output(0).get_tensor().get_names(), std::unordered_set({"a", "b"})); + ASSERT_EQ(param1->output(0).get_tensor().get_names(), std::unordered_set({"c", "d"})); +} + + diff --git a/ngraph/test/runtime/CMakeLists.txt b/ngraph/test/runtime/CMakeLists.txt index aa0ddfd69621c8..d17a37a8b7080a 100644 --- a/ngraph/test/runtime/CMakeLists.txt +++ b/ngraph/test/runtime/CMakeLists.txt @@ -14,26 +14,8 @@ set (SRC performance_counter.hpp dynamic/dynamic_backend.cpp dynamic/dynamic_backend.hpp - op/avg_pool.cpp - op/avg_pool.hpp - op/convolution.cpp - op/convolution.hpp - op/group_conv.cpp - op/group_conv.hpp pass/dyn_elimination.cpp pass/dyn_elimination.hpp - pass/fused_op_decomposition.cpp - pass/fused_op_decomposition.hpp - pass/implicit_broadcast_elimination.cpp - pass/implicit_broadcast_elimination.hpp - pass/liveness.cpp - pass/liveness.hpp - pass/opset0_downgrade.cpp - pass/opset0_downgrade.hpp - pass/opset1_downgrade.cpp - pass/opset1_downgrade.hpp - pass/opset1_upgrade.cpp - pass/opset1_upgrade.hpp pass/shape_relevance.cpp pass/shape_relevance.hpp ) diff --git a/ngraph/test/runtime/dynamic/dynamic_backend.cpp b/ngraph/test/runtime/dynamic/dynamic_backend.cpp index c7efd915b9e9dc..0ef1f65683760d 100644 --- a/ngraph/test/runtime/dynamic/dynamic_backend.cpp +++ b/ngraph/test/runtime/dynamic/dynamic_backend.cpp @@ -15,8 +15,6 @@ #include "ngraph/specialize_function.hpp" #include "ngraph/util.hpp" #include "pass/dyn_elimination.hpp" -#include "pass/opset0_downgrade.hpp" -#include "pass/opset1_downgrade.hpp" #include "pass/shape_relevance.hpp" using namespace std; @@ -239,10 +237,8 @@ bool runtime::dynamic::DynamicExecutable::call( pass::Manager passes; // Opset1Downgrade should be moved below DynElimination // when ConstantFolding for v3 ops will be ready - passes.register_pass(); passes.register_pass(); passes.register_pass(); - passes.register_pass(); // Converts dynamic v1 variants to v0 ops passes.set_per_pass_validation(false); // FIXME(amprocte): Vile, temporary hack: we need to do repeated rounds of diff --git a/ngraph/test/runtime/ie/ie_executable.cpp b/ngraph/test/runtime/ie/ie_executable.cpp index 419cd435380a94..cd31f1e0a7e0fa 100644 --- a/ngraph/test/runtime/ie/ie_executable.cpp +++ b/ngraph/test/runtime/ie/ie_executable.cpp @@ -8,7 +8,6 @@ #include "ngraph/pass/manager.hpp" #include "ngraph/shape.hpp" #include "ngraph/type/element_type.hpp" -#include "pass/opset1_upgrade.hpp" using namespace std; using namespace ngraph; @@ -63,7 +62,7 @@ namespace memcpy(blob_ptr, data, data_size * elem_type.size()); return blob; } -} +} // namespace namespace { @@ -78,21 +77,18 @@ namespace ie_ops.insert(opset4.begin(), opset4.end()); auto& opset5 = get_opset5().get_type_info_set(); ie_ops.insert(opset5.begin(), opset5.end()); - auto& opset6= get_opset6().get_type_info_set(); + auto& opset6 = get_opset6().get_type_info_set(); ie_ops.insert(opset6.begin(), opset6.end()); - auto& opset7= get_opset7().get_type_info_set(); + auto& opset7 = get_opset7().get_type_info_set(); ie_ops.insert(opset7.begin(), opset7.end()); return ie_ops; } -} +} // namespace runtime::ie::IE_Executable::IE_Executable(shared_ptr func, string device) : m_device{device} { static std::set ie_ops = get_ie_ops(); - pass::Manager passes; - passes.register_pass(); - passes.run_passes(func); for (const auto& node : func->get_ops()) { diff --git a/ngraph/test/runtime/ie/unit_test.manifest b/ngraph/test/runtime/ie/unit_test.manifest index 605b87d6d70c91..2ba258a77bb996 100644 --- a/ngraph/test/runtime/ie/unit_test.manifest +++ b/ngraph/test/runtime/ie/unit_test.manifest @@ -677,10 +677,6 @@ conv_bias_bprop_2d # Cannot cast ngraph node ConvolutionBiasAdd to CNNLayer! conv_bias_add_2d -# Unsupported primitive of type: SpaceToBatch -space_to_batch -batch_to_space - # [Validation] Argument must have rank >= 2 and <= 4 (argument shape: {1,2,2,2,3}) normalize_across_1axis_5d normalize_across_123axes_5d @@ -943,90 +939,6 @@ roll_3d_input roll_3d_input_negative_shift roll_negative_axes -# convert operation -IE_CPU.convert_u8_to_boolean -IE_CPU.convert_i32_to_boolean -IE_CPU.convert_f32_to_boolean -IE_CPU.convert_u8_to_f16 -IE_CPU.convert_u8_to_i16 -IE_CPU.convert_u8_to_i64 -IE_CPU.convert_u8_to_u16 -IE_CPU.convert_u8_to_u32 -IE_CPU.convert_u8_to_u64 -IE_CPU.convert_f16_to_f32 -IE_CPU.convert_u32_to_f32 -IE_CPU.convert_i4_to_f32 -IE_CPU.convert_u1_to_f32 -IE_CPU.convert_u4_to_f32 - -IE_CPU.convert_u1_to_u1 -IE_CPU.convert_u4_to_u1 -IE_CPU.convert_u8_to_u1 -IE_CPU.convert_u16_to_u1 -IE_CPU.convert_u32_to_u1 -IE_CPU.convert_u64_to_u1 -IE_CPU.convert_i4_to_u1 -IE_CPU.convert_i8_to_u1 -IE_CPU.convert_i16_to_u1 -IE_CPU.convert_i32_to_u1 -IE_CPU.convert_i64_to_u1 -IE_CPU.convert_f16_to_u1 -IE_CPU.convert_bf16_to_u1 -IE_CPU.convert_f32_to_u1 - -IE_CPU.convert_u1_to_i4 -IE_CPU.convert_u4_to_i4 -IE_CPU.convert_u8_to_i4 -IE_CPU.convert_u16_to_i4 -IE_CPU.convert_u32_to_i4 -IE_CPU.convert_u64_to_i4 -IE_CPU.convert_i8_to_i4 -IE_CPU.convert_i16_to_i4 -IE_CPU.convert_i32_to_i4 -IE_CPU.convert_i64_to_i4 -IE_CPU.convert_f16_to_i4 -IE_CPU.convert_bf16_to_i4 -IE_CPU.convert_f32_to_i4 - -IE_CPU.convert_u1_to_u4 -IE_CPU.convert_u4_to_u4 -IE_CPU.convert_u8_to_u4 -IE_CPU.convert_u16_to_u4 -IE_CPU.convert_u32_to_u4 -IE_CPU.convert_u64_to_u4 -IE_CPU.convert_i4_to_u4 -IE_CPU.convert_i8_to_u4 -IE_CPU.convert_i16_to_u4 -IE_CPU.convert_i32_to_u4 -IE_CPU.convert_i64_to_u4 -IE_CPU.convert_f16_to_u4 -IE_CPU.convert_bf16_to_u4 -IE_CPU.convert_f32_to_u4 - -IE_CPU.convert_u1_to_i8 -IE_CPU.convert_u4_to_i8 -IE_CPU.convert_i4_to_i8 -IE_CPU.convert_u1_to_i16 -IE_CPU.convert_u4_to_i16 -IE_CPU.convert_i4_to_i16 -IE_CPU.convert_u1_to_i32 -IE_CPU.convert_u4_to_i32 -IE_CPU.convert_i4_to_i32 -IE_CPU.convert_u1_to_i64 -IE_CPU.convert_u4_to_i64 -IE_CPU.convert_i4_to_i64 -IE_CPU.convert_u1_to_u8 -IE_CPU.convert_u4_to_u8 -IE_CPU.convert_i4_to_u8 -IE_CPU.convert_u1_to_u16 -IE_CPU.convert_u4_to_u16 -IE_CPU.convert_i4_to_u16 -IE_CPU.convert_u1_to_u32 -IE_CPU.convert_u4_to_u32 -IE_CPU.convert_i4_to_u32 -IE_CPU.convert_u1_to_u64 -IE_CPU.convert_u4_to_u64 -IE_CPU.convert_i4_to_u64 #------------------------------------------------------------------------------- # # Inference Engine CPU plugin excludes @@ -1110,6 +1022,41 @@ IE_CPU.onnx_model_nonmaxsuppression_center_point_box_format IE_CPU.onnx_model_nonmaxsuppression_single_box IE_CPU.nonmaxsuppression_suppress_by_IOU_and_scores_without_constants +# Unsupported dynamic op +IE_CPU.multiclass_nms_by_score +IE_CPU.multiclass_nms_by_class_id +IE_CPU.multiclass_nms_output_type_i32 +IE_CPU.multiclass_nms_two_batches_two_classes_by_score +IE_CPU.multiclass_nms_two_batches_two_classes_by_class_id +IE_CPU.multiclass_nms_two_batches_two_classes_by_score_cross_batch +IE_CPU.multiclass_nms_two_batches_two_classes_by_class_id_cross_batch +IE_CPU.multiclass_nms_no_output +IE_CPU.multiclass_nms_by_background +IE_CPU.multiclass_nms_by_keep_top_k +IE_CPU.multiclass_nms_by_nms_eta +IE_CPU.multiclass_nms_flipped_coordinates +IE_CPU.multiclass_nms_identical_boxes +IE_CPU.multiclass_nms_limit_output_size +IE_CPU.multiclass_nms_single_box +IE_CPU.multiclass_nms_by_IOU +IE_CPU.multiclass_nms_by_IOU_and_scores + +# Unsupported dynamic op +IE_CPU.matrix_nms_output_type_i64 +IE_CPU.matrix_nms_output_type_i32 +IE_CPU.matrix_nms_gaussian +IE_CPU.matrix_nms_two_batches_two_classes +IE_CPU.matrix_nms_two_batches_two_classes_by_score_cross_batch +IE_CPU.matrix_nms_two_batches_two_classes_by_classid_cross_batch +IE_CPU.matrix_nms_by_keep_top_k +IE_CPU.matrix_nms_background +IE_CPU.matrix_nms_flipped_coordinates +IE_CPU.matrix_nms_post_threshold +IE_CPU.matrix_nms_identical_boxes +IE_CPU.matrix_nms_nms_top_k +IE_CPU.matrix_nms_single_box +IE_CPU.matrix_nms_no_output + # Unsupported dynamic op IE_CPU.range_v4_trunc_inputs IE_CPU.onnx_model_reduce_sum_13_axes_as_input diff --git a/ngraph/test/runtime/interpreter/evaluates_map.cpp b/ngraph/test/runtime/interpreter/evaluates_map.cpp index eed12945bc1092..360adf4008acb7 100644 --- a/ngraph/test/runtime/interpreter/evaluates_map.cpp +++ b/ngraph/test/runtime/interpreter/evaluates_map.cpp @@ -49,7 +49,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -70,6 +72,7 @@ #include #include #include +#include using namespace ngraph; using namespace std; @@ -922,6 +925,285 @@ namespace return true; } + namespace matrix_nms_v8 + { + using SortResultType = op::v8::MatrixNms::SortResultType; + struct InfoForNMS + { + Shape selected_outputs_shape; + Shape selected_indices_shape; + Shape boxes_shape; + Shape scores_shape; + std::vector boxes_data; + std::vector scores_data; + size_t selected_outputs_shape_size; + size_t selected_indices_shape_size; + }; + + constexpr size_t boxes_port = 0; + constexpr size_t scores_port = 1; + + PartialShape + infer_selected_outputs_shape(const std::vector>& inputs, + int nms_top_k, int keep_top_k) + { + const auto boxes_ps = inputs[boxes_port]->get_partial_shape(); + const auto scores_ps = inputs[scores_port]->get_partial_shape(); + + PartialShape result = {Dimension::dynamic(), 6}; + + if (boxes_ps.rank().is_static() && scores_ps.rank().is_static()) + { + const auto num_boxes_boxes = boxes_ps[1]; + if (num_boxes_boxes.is_static() && scores_ps[0].is_static() && scores_ps[1].is_static()) + { + const auto num_boxes = num_boxes_boxes.get_length(); + const auto num_classes = scores_ps[1].get_length(); + int64_t max_output_boxes_per_class = 0; + if (nms_top_k >= 0) + max_output_boxes_per_class = std::min(num_boxes, (int64_t)nms_top_k); + else + max_output_boxes_per_class = num_boxes; + + auto max_output_boxes_per_batch = max_output_boxes_per_class * num_classes; + if (keep_top_k >= 0) + max_output_boxes_per_batch = + std::min(max_output_boxes_per_batch, (int64_t)keep_top_k); + + result[0] = max_output_boxes_per_batch * scores_ps[0].get_length(); + } + } + + return result; + } + + std::vector prepare_boxes_data(const std::shared_ptr& boxes, + const Shape& boxes_shape) + { + auto result = get_floats(boxes, boxes_shape); + return result; + } + + std::vector prepare_scores_data(const std::shared_ptr& scores, + const Shape& scores_shape) + { + auto result = get_floats(scores, scores_shape); + return result; + } + + InfoForNMS get_info_for_nms_eval(const std::shared_ptr& nms, + const std::vector>& inputs) + { + InfoForNMS result; + + auto selected_outputs_shape = + infer_selected_outputs_shape(inputs, nms->get_nms_top_k(), nms->get_keep_top_k()); + result.selected_outputs_shape = selected_outputs_shape.to_shape(); + result.selected_indices_shape = {result.selected_outputs_shape[0], 1}; + + result.boxes_shape = inputs[boxes_port]->get_shape(); + result.scores_shape = inputs[scores_port]->get_shape(); + + result.boxes_data = prepare_boxes_data(inputs[boxes_port], result.boxes_shape); + result.scores_data = prepare_scores_data(inputs[scores_port], result.scores_shape); + + result.selected_outputs_shape_size = shape_size(result.selected_outputs_shape); + result.selected_indices_shape_size = shape_size(result.selected_indices_shape); + + return result; + } + } // namespace matrix_nms_v8 + + template + bool evaluate(const shared_ptr& op, + const HostTensorVector& outputs, + const HostTensorVector& inputs) + { + auto info = matrix_nms_v8::get_info_for_nms_eval(op, inputs); + + std::vector selected_outputs(info.selected_outputs_shape_size); + std::vector selected_indices(info.selected_indices_shape_size); + std::vector valid_outputs(info.boxes_shape[0]); + + runtime::reference::matrix_nms(info.boxes_data.data(), + info.boxes_shape, + info.scores_data.data(), + info.scores_shape, + op->get_attrs(), + selected_outputs.data(), + info.selected_outputs_shape, + selected_indices.data(), + info.selected_indices_shape, + valid_outputs.data()); + + void* pscores = nullptr; + void* pselected_num = nullptr; + void* prois; + size_t num_selected = static_cast(std::accumulate(valid_outputs.begin(), valid_outputs.end(), 0)); + + outputs[0]->set_shape({num_selected, 6}); + prois = outputs[0]->get_data_ptr(); + + if (outputs.size() >= 2) + { + outputs[1]->set_shape({num_selected, 1}); + pscores = outputs[1]->get_data_ptr(); + } + if (outputs.size() >= 3) + { + pselected_num = outputs[2]->get_data_ptr(); + } + + runtime::reference::nms_common::nms_common_postprocessing(prois, + pscores, + pselected_num, + op->get_output_type(), + selected_outputs, + selected_indices, + valid_outputs); + return true; + } + + namespace multiclass_nms_v8 + { + using SortResultType = op::v8::MulticlassNms::SortResultType; + struct InfoForNMS + { + Shape selected_outputs_shape; + Shape selected_indices_shape; + Shape boxes_shape; + Shape scores_shape; + std::vector boxes_data; + std::vector scores_data; + size_t selected_outputs_shape_size; + size_t selected_indices_shape_size; + }; + + constexpr size_t boxes_port = 0; + constexpr size_t scores_port = 1; + + PartialShape + infer_selected_outputs_shape(const std::vector>& inputs, + int nms_top_k, int keep_top_k) + { + const auto boxes_ps = inputs[boxes_port]->get_partial_shape(); + const auto scores_ps = inputs[scores_port]->get_partial_shape(); + + PartialShape result = {Dimension::dynamic(), 6}; + + if (boxes_ps.rank().is_static() && scores_ps.rank().is_static()) + { + const auto num_boxes_boxes = boxes_ps[1]; + if (num_boxes_boxes.is_static() && scores_ps[0].is_static() && scores_ps[1].is_static()) + { + const auto num_boxes = num_boxes_boxes.get_length(); + const auto num_classes = scores_ps[1].get_length(); + int64_t max_output_boxes_per_class = 0; + if (nms_top_k >= 0) + max_output_boxes_per_class = std::min(num_boxes, (int64_t)nms_top_k); + else + max_output_boxes_per_class = num_boxes; + + auto max_output_boxes_per_batch = max_output_boxes_per_class * num_classes; + if (keep_top_k >= 0) + max_output_boxes_per_batch = + std::min(max_output_boxes_per_batch, (int64_t)keep_top_k); + + result[0] = max_output_boxes_per_batch * scores_ps[0].get_length(); + } + } + + return result; + } + + std::vector prepare_boxes_data(const std::shared_ptr& boxes, + const Shape& boxes_shape) + { + auto result = get_floats(boxes, boxes_shape); + return result; + } + + std::vector prepare_scores_data(const std::shared_ptr& scores, + const Shape& scores_shape) + { + auto result = get_floats(scores, scores_shape); + return result; + } + + InfoForNMS get_info_for_nms_eval(const std::shared_ptr& nms, + const std::vector>& inputs) + { + InfoForNMS result; + + auto selected_outputs_shape = + infer_selected_outputs_shape(inputs, nms->get_nms_top_k(), nms->get_keep_top_k()); + result.selected_outputs_shape = selected_outputs_shape.to_shape(); + result.selected_indices_shape = {result.selected_outputs_shape[0], 1}; + + result.boxes_shape = inputs[boxes_port]->get_shape(); + result.scores_shape = inputs[scores_port]->get_shape(); + + result.boxes_data = prepare_boxes_data(inputs[boxes_port], result.boxes_shape); + result.scores_data = prepare_scores_data(inputs[scores_port], result.scores_shape); + + result.selected_outputs_shape_size = shape_size(result.selected_outputs_shape); + result.selected_indices_shape_size = shape_size(result.selected_indices_shape); + + return result; + } + } // namespace multiclass_nms_v8 + + template + bool evaluate(const shared_ptr& op, + const HostTensorVector& outputs, + const HostTensorVector& inputs) + { + auto info = multiclass_nms_v8::get_info_for_nms_eval(op, inputs); + + std::vector selected_outputs(info.selected_outputs_shape_size); + std::vector selected_indices(info.selected_indices_shape_size); + std::vector valid_outputs(inputs[0]->get_shape()[0]); + + runtime::reference::multiclass_nms(info.boxes_data.data(), + info.boxes_shape, + info.scores_data.data(), + info.scores_shape, + op->get_attrs(), + selected_outputs.data(), + info.selected_outputs_shape, + selected_indices.data(), + info.selected_indices_shape, + valid_outputs.data()); + + void* pscores = nullptr; + void* pselected_num = nullptr; + void* prois; + size_t num_selected = static_cast(std::accumulate(valid_outputs.begin(), valid_outputs.end(), 0)); + + outputs[0]->set_shape({num_selected, 6}); + prois = outputs[0]->get_data_ptr(); + + if (outputs.size() >= 2) + { + outputs[1]->set_shape({num_selected, 1}); + pscores = outputs[1]->get_data_ptr(); + } + if (outputs.size() >= 3) + { + pselected_num = outputs[2]->get_data_ptr(); + } + + runtime::reference::nms_common::nms_common_postprocessing(prois, + pscores, + pselected_num, + op->get_output_type(), + selected_outputs, + selected_indices, + valid_outputs); + + return true; + } + namespace experimental_prior_grid { struct InfoForEDPriorGrid @@ -2586,16 +2868,14 @@ namespace for (size_t i = 1; i < node->outputs().size(); i++) { if ((is_type(node) || + is_type(node) || + is_type(node) || is_type(node) || is_type(node)) && - i == 1) + i == 1) { continue; } - if (element_type != node->get_output_element_type(i)) - { - throw std::logic_error("Output node element types is not equal"); - } } switch (element_type) { diff --git a/ngraph/test/runtime/interpreter/int_executable.hpp b/ngraph/test/runtime/interpreter/int_executable.hpp index d7edc790aab851..8c901cd93c5fd2 100644 --- a/ngraph/test/runtime/interpreter/int_executable.hpp +++ b/ngraph/test/runtime/interpreter/int_executable.hpp @@ -21,7 +21,6 @@ #include "ngraph/runtime/reference/reorg_yolo.hpp" #include "ngraph/runtime/reference/tensor_iterator.hpp" #include "ngraph/runtime/tensor.hpp" -#include "op/avg_pool.hpp" namespace ngraph { diff --git a/ngraph/test/runtime/interpreter/opset_int_tbl.hpp b/ngraph/test/runtime/interpreter/opset_int_tbl.hpp index 11e64dbab6f382..2893e716af5881 100644 --- a/ngraph/test/runtime/interpreter/opset_int_tbl.hpp +++ b/ngraph/test/runtime/interpreter/opset_int_tbl.hpp @@ -99,3 +99,5 @@ NGRAPH_OP(Roll, ngraph::op::v7) NGRAPH_OP(AdaptiveAvgPool, ngraph::op::v8) NGRAPH_OP(AdaptiveMaxPool, ngraph::op::v8) +NGRAPH_OP(MatrixNms, op::v8) +NGRAPH_OP(MulticlassNms, op::v8) diff --git a/ngraph/test/runtime/op/atan2.cpp b/ngraph/test/runtime/op/atan2.cpp deleted file mode 100644 index 4d0af74cba39a1..00000000000000 --- a/ngraph/test/runtime/op/atan2.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "atan2.hpp" -#include "ngraph/op/add.hpp" -#include "ngraph/op/divide.hpp" -#include "ngraph/op/multiply.hpp" -#include "ngraph/op/negative.hpp" -#include "ngraph/op/sqrt.hpp" -#include "ngraph/op/subtract.hpp" - -using namespace std; -using namespace ngraph; - -constexpr NodeTypeInfo op::v0::Atan2::type_info; - -op::v0::Atan2::Atan2(const Output& y, const Output& x, const AutoBroadcastSpec& autob) - : BinaryElementwiseArithmetic(y, x, autob) -{ - constructor_validate_and_infer_types(); -} - -shared_ptr op::v0::Atan2::clone_with_new_inputs(const OutputVector& new_args) const -{ - check_new_args_count(this, new_args); - return make_shared(new_args.at(0), new_args.at(1), this->get_autob()); -} - -bool op::v0::Atan2::visit_attributes(AttributeVisitor& visitor) -{ - BinaryElementwiseArithmetic::visit_attributes(visitor); - return true; -} diff --git a/ngraph/test/runtime/op/atan2.hpp b/ngraph/test/runtime/op/atan2.hpp deleted file mode 100644 index 683edc851623d5..00000000000000 --- a/ngraph/test/runtime/op/atan2.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -#include "backend_visibility.hpp" -#include "ngraph/op/util/binary_elementwise_arithmetic.hpp" - -namespace ngraph -{ - namespace op - { - namespace v0 - { - /// \brief Elementwise full arctan operation - class BACKEND_API Atan2 : public util::BinaryElementwiseArithmetic - { - public: - static constexpr NodeTypeInfo type_info{"Atan2", 0}; - const NodeTypeInfo& get_type_info() const override { return type_info; } - Atan2() - : util::BinaryElementwiseArithmetic(AutoBroadcastSpec::NONE) - { - } - - /// \brief atan2(y,x) is the angle from the origin to the point (x,y) (note reversed - /// order). - /// - /// \param y - /// \param x - Atan2(const Output& y, - const Output& x, - const AutoBroadcastSpec& autob = AutoBroadcastSpec()); - std::shared_ptr - clone_with_new_inputs(const OutputVector& new_args) const override; - bool visit_attributes(AttributeVisitor& visitor) override; - }; - } - } -} diff --git a/ngraph/test/runtime/op/avg_pool.cpp b/ngraph/test/runtime/op/avg_pool.cpp deleted file mode 100644 index d8f8d8bb0916b9..00000000000000 --- a/ngraph/test/runtime/op/avg_pool.cpp +++ /dev/null @@ -1,235 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "avg_pool.hpp" -#include "ngraph/attribute_visitor.hpp" -#include "ngraph/graph_util.hpp" -#include "ngraph/validation_util.hpp" - -using namespace std; -using namespace ngraph; - -// *** AvgPool OP SET 0 *** -constexpr NodeTypeInfo op::v0::AvgPool::type_info; - -op::v0::AvgPool::AvgPool(const Output& arg, - const Shape& window_shape, - const Strides& window_movement_strides, - const Shape& padding_below, - const Shape& padding_above, - bool include_padding_in_avg_computation, - const PadType& pad_type, - bool ceil_mode) - : Op({arg}) - , m_window_shape(window_shape) - , m_window_movement_strides(window_movement_strides) - , m_padding_below(padding_below) - , m_padding_above(padding_above) - , m_include_padding_in_avg_computation(include_padding_in_avg_computation) - , m_pad_type(pad_type) - , m_ceil_mode(ceil_mode) -{ - constructor_validate_and_infer_types(); -} - -op::v0::AvgPool::AvgPool(const Output& arg, - const Shape& window_shape, - const Strides& window_movement_strides, - const Shape& padding_below, - const Shape& padding_above, - bool include_padding_in_avg_computation, - const PadType& pad_type) - : AvgPool(arg, - window_shape, - window_movement_strides, - padding_below, - padding_above, - include_padding_in_avg_computation, - pad_type, - false) -{ -} - -op::v0::AvgPool::AvgPool(const Output& arg, - const Shape& window_shape, - const Strides& window_movement_strides, - const Shape& padding_below, - const Shape& padding_above, - bool include_padding_in_avg_computation) - : AvgPool(arg, - window_shape, - window_movement_strides, - padding_below, - padding_above, - include_padding_in_avg_computation, - PadType::EXPLICIT) -{ -} - -bool op::v0::AvgPool::visit_attributes(AttributeVisitor& visitor) -{ - visitor.on_attribute("window_shape", m_window_shape); - visitor.on_attribute("window_movement_strides", m_window_movement_strides); - visitor.on_attribute("padding_below", m_padding_below); - visitor.on_attribute("padding_above", m_padding_above); - visitor.on_attribute("include_padding_in_avg_computation", - m_include_padding_in_avg_computation); - visitor.on_attribute("pad_type", m_pad_type); - visitor.on_attribute("ceil_mode", m_ceil_mode); - return true; -} - -void op::v0::AvgPool::validate_and_infer_types() -{ - if (0 == m_window_movement_strides.size()) - { - m_window_movement_strides = Strides(m_window_shape.size(), 1); - } - - if (0 == m_padding_below.size()) - { - m_padding_below = Shape(m_window_shape.size(), 0); - } - - if (0 == m_padding_above.size()) - { - m_padding_above = Shape(m_window_shape.size(), 0); - } - - const PartialShape& arg_shape = get_input_partial_shape(0); - - if (m_pad_type == PadType::SAME_UPPER || m_pad_type == PadType::SAME_LOWER) - { - if (arg_shape.is_static()) - { - CoordinateDiff padding_above, padding_below; - infer_auto_padding(arg_shape.to_shape(), - m_window_shape, - m_window_movement_strides, - Strides(m_window_shape.size(), 1), // No dilation - m_pad_type, - padding_above, - padding_below); - m_padding_above = Shape(padding_above.begin(), padding_above.end()); - m_padding_below = Shape(padding_below.begin(), padding_below.end()); - } - } - - // infer_batched_forward_pooling wants CoordinateDiffs for these, while the pooling ops for - // now still take Shape (no negative padding). - CoordinateDiff padding_below(m_padding_below.begin(), m_padding_below.end()); - CoordinateDiff padding_above(m_padding_above.begin(), m_padding_above.end()); - - set_output_type(0, - get_input_element_type(0), - infer_batched_pooling_forward(this, - arg_shape, - padding_below, - padding_above, - m_window_shape, - m_window_movement_strides, - m_include_padding_in_avg_computation, - m_ceil_mode)); -} - -op::v0::AvgPool::AvgPool(const Output& arg, - const Shape& window_shape, - const Strides& window_movement_strides) - : AvgPool(arg, window_shape, window_movement_strides, Shape(), Shape(), false) -{ -} - -op::v0::AvgPool::AvgPool(const Output& arg, const Shape& window_shape) - : AvgPool(arg, window_shape, Strides(), Shape(), Shape(), false) -{ -} - -const Shape& op::v0::AvgPool::get_window_shape() const -{ - return m_window_shape; -} - -void op::v0::AvgPool::set_window_shape(const Shape& window_shape) -{ - m_window_shape = window_shape; -} - -const Strides& op::v0::AvgPool::get_window_movement_strides() const -{ - return m_window_movement_strides; -} - -void op::v0::AvgPool::set_window_movement_strides(const Strides& window_movement_strides) -{ - m_window_movement_strides = window_movement_strides; -} - -const Shape& op::v0::AvgPool::get_padding_below() const -{ - return m_padding_below; -} - -void op::v0::AvgPool::set_padding_below(const Shape& padding_below) -{ - m_padding_below = padding_below; -} - -const Shape& op::v0::AvgPool::get_padding_above() const -{ - return m_padding_above; -} - -void op::v0::AvgPool::set_padding_above(const Shape& padding_above) -{ - m_padding_above = padding_above; -} - -bool op::v0::AvgPool::get_include_padding_in_avg_computation() const -{ - return m_include_padding_in_avg_computation; -} - -void op::v0::AvgPool::set_include_padding_in_avg_computation( - bool include_padding_in_avg_computation) -{ - m_include_padding_in_avg_computation = include_padding_in_avg_computation; -} - -const op::PadType& op::v0::AvgPool::get_pad_type() const -{ - return m_pad_type; -} - -void op::v0::AvgPool::set_pad_type(const op::PadType& pad_type) -{ - m_pad_type = pad_type; -} - -bool op::v0::AvgPool::get_ceil_mode() const -{ - return m_ceil_mode; -} - -void op::v0::AvgPool::set_ceil_mode(bool ceil_mode) -{ - m_ceil_mode = ceil_mode; -} - -shared_ptr op::v0::AvgPool::clone_with_new_inputs(const OutputVector& new_args) const -{ - check_new_args_count(this, new_args); - return make_shared(new_args.at(0), - m_window_shape, - m_window_movement_strides, - m_padding_below, - m_padding_above, - m_include_padding_in_avg_computation, - m_pad_type, - m_ceil_mode); -} - -shared_ptr op::v0::AvgPool::get_default_value() const -{ - return Constant::create(get_element_type(), get_shape(), {0}); -} diff --git a/ngraph/test/runtime/op/avg_pool.hpp b/ngraph/test/runtime/op/avg_pool.hpp deleted file mode 100644 index 701b3e174f3f46..00000000000000 --- a/ngraph/test/runtime/op/avg_pool.hpp +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "backend_visibility.hpp" -#include "ngraph/op/op.hpp" -#include "ngraph/op/util/attr_types.hpp" - -namespace ngraph -{ - namespace op - { - namespace v0 - { - /// \brief Batched average pooling operation, with optional padding and window stride. - /// - class BACKEND_API AvgPool : public Op - { - public: - static constexpr NodeTypeInfo type_info{"AvgPool", 0}; - const NodeTypeInfo& get_type_info() const override { return type_info; } - /// \brief Constructs a batched average pooling operation. - AvgPool() = default; - - /// \brief Constructs a batched average pooling operation. - /// - /// \param arg The output producing the input data batch tensor.
- /// `[d1, dn]` - /// \param window_shape The window shape.
- /// `[n]` - /// \param window_movement_strides The window movement strides.
- /// `[n]` - /// \param padding_below The below-padding shape.
- /// `[n]` - /// \param padding_above The above-padding shape.
- /// `[n]` - /// \param include_padding_in_avg_computation If true then averages include padding - /// elements, each treated as the number zero. If false, padding elements are - /// entirely ignored when computing averages. \param pad_type Padding type to use - /// for additional padded dimensions \param ceil_mode Whether to use ceiling while - /// computing output shape. - AvgPool(const Output& arg, - const Shape& window_shape, - const Strides& window_movement_strides, - const Shape& padding_below, - const Shape& padding_above, - bool include_padding_in_avg_computation, - const PadType& pad_type, - bool ceil_mode); - - /// \brief Constructs a batched average pooling operation. - /// - /// \param arg The output producing the input data batch tensor.
- /// `[d1, dn]` - /// \param window_shape The window shape.
- /// `[n]` - /// \param window_movement_strides The window movement strides.
- /// `[n]` - /// \param padding_below The below-padding shape.
- /// `[n]` - /// \param padding_above The above-padding shape.
- /// `[n]` - /// \param include_padding_in_avg_computation If true then averages include padding - /// elements, each treated as the number zero. If false, padding elements are - /// entirely ignored when computing averages. \param pad_type Padding type to use - /// for additional padded dimensions - AvgPool(const Output& arg, - const Shape& window_shape, - const Strides& window_movement_strides, - const Shape& padding_below, - const Shape& padding_above, - bool include_padding_in_avg_computation, - const PadType& pad_type); - - /// \brief Constructs a batched average pooling operation. - /// - /// \param arg The output producing the input data batch tensor.
- /// `[d1, dn]` - /// \param window_shape The window shape.
- /// `[n]` - /// \param window_movement_strides The window movement strides.
- /// `[n]` - /// \param padding_below The below-padding shape.
- /// `[n]` - /// \param padding_above The above-padding shape.
- /// `[n]` - /// \param include_padding_in_avg_computation If true then averages include padding - /// elements, each treated as the number zero. If false, padding elements are - /// entirely ignored when computing averages. - AvgPool(const Output& arg, - const Shape& window_shape, - const Strides& window_movement_strides, - const Shape& padding_below, - const Shape& padding_above, - bool include_padding_in_avg_computation = false); - - /// \brief Constructs a batched, unpadded average pooling operation (i.e., all - /// padding shapes are set to 0). - /// - /// \param arg The output producing the input data batch tensor.
- /// `[d1, ..., dn]` - /// \param window_shape The window shape.
- /// `[n]` - /// \param window_movement_strides The window movement strides.
- /// `[n]` - AvgPool(const Output& arg, - const Shape& window_shape, - const Strides& window_movement_strides); - - /// \brief Constructs an unstrided batched convolution operation (i.e., all window - /// movement strides are 1 and all padding shapes are set to 0). - /// - /// \param arg The output producing the input data batch tensor.
- /// `[d1, ..., dn]` - /// \param window_shape The window shape.
- /// `[n]` - AvgPool(const Output& arg, const Shape& window_shape); - - bool visit_attributes(AttributeVisitor& visitor) override; - - void validate_and_infer_types() override; - - virtual std::shared_ptr - clone_with_new_inputs(const OutputVector& new_args) const override; - - /// \return The window shape. - const Shape& get_window_shape() const; - void set_window_shape(const Shape& window_shape); - /// \return The window movement strides. - const Strides& get_window_movement_strides() const; - void set_window_movement_strides(const Strides& window_movement_strides); - /// \return The below-padding shape. - const Shape& get_padding_below() const; - void set_padding_below(const Shape& padding_below); - /// \return The above-padding shape. - const Shape& get_padding_above() const; - void set_padding_above(const Shape& padding_above); - bool get_include_padding_in_avg_computation() const; - void - set_include_padding_in_avg_computation(bool include_padding_in_avg_computation); - /// \return The pad type for pooling. - const PadType& get_pad_type() const; - void set_pad_type(const PadType& pad_type); - bool get_ceil_mode() const; - void set_ceil_mode(bool ceil_mode); - /// \return The default value for AvgPool. - NGRAPH_SUPPRESS_DEPRECATED_START - virtual std::shared_ptr get_default_value() const override; - NGRAPH_SUPPRESS_DEPRECATED_END - - protected: - Shape m_window_shape; - Strides m_window_movement_strides; - Shape m_padding_below; - Shape m_padding_above; - bool m_include_padding_in_avg_computation{false}; - PadType m_pad_type{PadType::EXPLICIT}; - bool m_ceil_mode{false}; - }; - } // namespace v0 - } // namespace op -} // namespace ngraph diff --git a/ngraph/test/runtime/op/convolution.cpp b/ngraph/test/runtime/op/convolution.cpp deleted file mode 100644 index 1d4d8bea6c697e..00000000000000 --- a/ngraph/test/runtime/op/convolution.cpp +++ /dev/null @@ -1,343 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "convolution.hpp" -#include "ngraph/axis_vector.hpp" -#include "ngraph/coordinate_diff.hpp" -#include "ngraph/op/reshape.hpp" -#include "ngraph/util.hpp" -#include "ngraph/validation_util.hpp" - -using namespace std; -using namespace ngraph; - -// *** Convolution OP SET 0 *** -constexpr NodeTypeInfo op::v0::Convolution::type_info; - -op::v0::Convolution::Convolution(const Output& data_batch, - const Output& filters, - const Strides& window_movement_strides, - const Strides& window_dilation_strides, - const CoordinateDiff& padding_below, - const CoordinateDiff& padding_above, - const Strides& data_dilation_strides, - const PadType& pad_type) - : Op({data_batch, filters}) - , m_window_movement_strides(window_movement_strides) - , m_window_dilation_strides(window_dilation_strides) - , m_padding_below(padding_below) - , m_padding_above(padding_above) - , m_data_dilation_strides(data_dilation_strides) - , m_pad_type(pad_type) -{ - constructor_validate_and_infer_types(); -} - -bool op::v0::Convolution::visit_attributes(AttributeVisitor& visitor) -{ - visitor.on_attribute("window_movement_strides", m_window_movement_strides); - visitor.on_attribute("window_dilation_strides", m_window_dilation_strides); - visitor.on_attribute("data_dilation_strides", m_data_dilation_strides); - visitor.on_attribute("padding_below", m_padding_below); - visitor.on_attribute("padding_above", m_padding_above); - visitor.on_attribute("pad_type", m_pad_type); - return true; -} - -void op::v0::Convolution::validate_and_infer_types() -{ - const PartialShape& data_batch_shape = get_input_partial_shape(0); - element::Type data_batch_et = get_input_element_type(0); - const PartialShape& filters_shape = get_input_partial_shape(1); - element::Type filters_et = get_input_element_type(1); - - if (m_data_dilation_strides.size() == 0) - { - m_data_dilation_strides = conv_default_strides(this, data_batch_shape, filters_shape); - } - - if (m_window_movement_strides.size() == 0) - { - m_window_movement_strides = conv_default_strides(this, data_batch_shape, filters_shape); - } - - if (m_window_dilation_strides.size() == 0) - { - m_window_dilation_strides = conv_default_strides(this, data_batch_shape, filters_shape); - } - - if (m_padding_below.size() == 0) - { - m_padding_below = conv_default_padding(this, data_batch_shape, filters_shape); - } - - if (m_padding_above.size() == 0) - { - m_padding_above = conv_default_padding(this, data_batch_shape, filters_shape); - } - - if (m_pad_type == PadType::SAME_UPPER || m_pad_type == PadType::SAME_LOWER) - { - if (data_batch_shape.is_static() && filters_shape.is_static()) - { - // TODO: data dilation - m_padding_below.clear(); - m_padding_above.clear(); - auto filter_shape = filters_shape.to_shape(); - filter_shape.erase(filter_shape.begin(), filter_shape.begin() + 2); // Remove {O,I} - infer_auto_padding(data_batch_shape.to_shape(), - filter_shape, - m_window_movement_strides, - m_window_dilation_strides, - m_pad_type, - m_padding_above, - m_padding_below); - } - } - - element::Type result_et; - PartialShape result_shape; - - NODE_VALIDATION_CHECK( - this, - element::Type::merge(result_et, data_batch_et, filters_et), - "Element types for data batch and filters do not match (data batch element type: ", - data_batch_et, - ", filters element type: ", - filters_et, - ")."); - - result_shape = infer_convolution_forward(this, - data_batch_shape, - m_data_dilation_strides, - m_padding_below, - m_padding_above, - filters_shape, - m_window_movement_strides, - m_window_dilation_strides); - - set_output_type(0, result_et, result_shape); -} - -op::v0::Convolution::Convolution(const Output& data_batch, - const Output& filters, - const Strides& window_movement_strides, - const Strides& window_dilation_strides, - const CoordinateDiff& padding_below, - const CoordinateDiff& padding_above) - : Convolution(data_batch, - filters, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - Strides()) -{ -} - -op::v0::Convolution::Convolution(const Output& data_batch, - const Output& filters, - const Strides& window_movement_strides, - const Strides& window_dilation_strides) - : Convolution(data_batch, - filters, - window_movement_strides, - window_dilation_strides, - CoordinateDiff(), - CoordinateDiff()) -{ -} - -op::v0::Convolution::Convolution(const Output& data_batch, - const Output& filters, - const Strides& window_movement_strides) - : Convolution(data_batch, - filters, - window_movement_strides, - Strides(), - CoordinateDiff(), - CoordinateDiff()) -{ -} - -op::v0::Convolution::Convolution(const Output& data_batch, const Output& filters) - : Convolution(data_batch, filters, Strides(), Strides(), CoordinateDiff(), CoordinateDiff()) -{ -} - -shared_ptr op::v0::Convolution::clone_with_new_inputs(const OutputVector& new_args) const -{ - check_new_args_count(this, new_args); - return make_shared(new_args.at(0), - new_args.at(1), - m_window_movement_strides, - m_window_dilation_strides, - m_padding_below, - m_padding_above, - m_data_dilation_strides, - m_pad_type); -} - -constexpr NodeTypeInfo op::v0::ConvolutionBackpropData::type_info; -shared_ptr op::v0::Convolution::get_default_value() const -{ - return ngraph::make_constant_from_string("0", get_element_type(), get_shape()); -} - -op::v0::ConvolutionBackpropData::ConvolutionBackpropData( - const Shape& data_batch_shape, - const Output& filters, - const Output& output_delta, - const Strides& window_movement_strides_forward, - const Strides& window_dilation_strides_forward, - const CoordinateDiff& padding_below_forward, - const CoordinateDiff& padding_above_forward, - const Strides& data_dilation_strides_forward) - : Op({filters, output_delta}) - , m_data_batch_shape(data_batch_shape) - , m_window_movement_strides_forward(window_movement_strides_forward) - , m_window_dilation_strides_forward(window_dilation_strides_forward) - , m_padding_below_forward(padding_below_forward) - , m_padding_above_forward(padding_above_forward) - , m_data_dilation_strides_forward(data_dilation_strides_forward) -{ - constructor_validate_and_infer_types(); -} - -bool op::v0::ConvolutionBackpropData::visit_attributes(AttributeVisitor& visitor) -{ - visitor.on_attribute("data_batch_shape", m_data_batch_shape); - visitor.on_attribute("window_movement_strides_forward", m_window_movement_strides_forward); - visitor.on_attribute("window_dilation_strides_forward", m_window_dilation_strides_forward); - visitor.on_attribute("padding_below_forward", m_padding_below_forward); - visitor.on_attribute("padding_above_forward", m_padding_above_forward); - visitor.on_attribute("data_dilation_strides_forward", m_data_dilation_strides_forward); - return true; -} - -void op::v0::ConvolutionBackpropData::validate_and_infer_types() -{ - // Backprop to data is itself convolution, with inputs/outputs/attributes transmogrified as - // follows. - // - // Forward Backward - // "N" axis for data batch 0 0 - // "C" axis for data batch 1 1 - // "Co" axis for filters 0 0 - // "Ci" axis for filters 1 1 - // "N" axis for output 0 0 - // "C" axis for output 1 1 - // Data batch x delta - // Data batch shape S_x S_o - // Filters f reverse(f) [on spatial axes] - // Filters shape S_f S_f - // Window movement strides q_x p_x - // Window dilation strides p_f p_f - // Padding below a_x (S_f - 1)p_f - a_x - // Padding above b_x (S_f - 1)p_f + - // + ((a_x + (S_x - 1)p_x + b_x - (S_f - 1)p_f) - // % q_x) - // - b_x - // Data dilation strides p_x q_x - // Output shape S_o S_x - // - // To _validate_, we simply need to check/infer the output shape of the forward convolution, - // then check to make sure that the incoming delta has the same shape as the forward output. - const PartialShape& filters_shape = get_input_partial_shape(0); - element::Type filters_et = get_input_element_type(0); - const PartialShape& delta_shape = get_input_partial_shape(1); - element::Type delta_et = get_input_element_type(1); - - element::Type forward_result_et; - PartialShape forward_result_shape; - - NODE_VALIDATION_CHECK( - this, - element::Type::merge(forward_result_et, delta_et, filters_et), - "Element types for data batch and filters do not match (data batch element type: ", - delta_et, - ", filters element type: ", - filters_et, - ")."); - - forward_result_shape = infer_convolution_forward(this, - m_data_batch_shape, - m_data_dilation_strides_forward, - m_padding_below_forward, - m_padding_above_forward, - filters_shape, - m_window_movement_strides_forward, - m_window_dilation_strides_forward); - - NODE_VALIDATION_CHECK(this, - forward_result_shape.compatible(delta_shape), - "Inferred forward output shape (", - forward_result_shape, - ") does not match shape of ", - "delta (", - delta_shape, - ")."); - - set_output_type(0, forward_result_et, m_data_batch_shape); -} - -shared_ptr - op::v0::ConvolutionBackpropData::clone_with_new_inputs(const OutputVector& new_args) const -{ - check_new_args_count(this, new_args); - return make_shared(m_data_batch_shape, - new_args.at(0), - new_args.at(1), - m_window_movement_strides_forward, - m_window_dilation_strides_forward, - m_padding_below_forward, - m_padding_above_forward, - m_data_dilation_strides_forward); -} - -CoordinateDiff op::v0::ConvolutionBackpropData::compute_backward_delta_out_pad_below() const -{ - auto& in_shape = get_data_batch_shape(); - auto& filter_dilation = get_window_dilation_strides_forward(); - auto& filter_shape = get_input_shape(0); - auto& in_pad_below = get_padding_below_forward(); - size_t spatial_dim_count = static_cast(in_shape.size()) - 2; - - CoordinateDiff backward_delta_out_pad_below; - backward_delta_out_pad_below.resize(spatial_dim_count); - - for (size_t i = 0; i < spatial_dim_count; i++) - { - backward_delta_out_pad_below[i] = - (static_cast(filter_shape[i + 2]) - 1) * filter_dilation[i] - - in_pad_below[i]; - } - return backward_delta_out_pad_below; -} - -CoordinateDiff op::v0::ConvolutionBackpropData::compute_backward_delta_out_pad_above() const -{ - auto& in_shape = get_data_batch_shape(); - auto& filter_dilation = get_window_dilation_strides_forward(); - auto& filter_shape = get_input_shape(0); - auto& in_pad_below = get_padding_below_forward(); - auto& in_pad_above = get_padding_above_forward(); - auto& in_dilation = get_data_dilation_strides_forward(); - auto& stride = get_window_movement_strides_forward(); - size_t spatial_dim_count = static_cast(in_shape.size()) - 2; - - CoordinateDiff backward_delta_out_pad_above; - backward_delta_out_pad_above.resize(spatial_dim_count); - - for (size_t i = 0; i < spatial_dim_count; i++) - { - backward_delta_out_pad_above[i] = - (static_cast(filter_shape[i + 2]) - 1) * filter_dilation[i] + - ((in_pad_below[i] + ((in_shape[i + 2]) - 1) * in_dilation[i] + in_pad_above[i] - - (static_cast(filter_shape[i + 2]) - 1) * filter_dilation[i]) % - stride[i]) - - in_pad_above[i]; - } - return backward_delta_out_pad_above; -} diff --git a/ngraph/test/runtime/op/convolution.hpp b/ngraph/test/runtime/op/convolution.hpp deleted file mode 100644 index f5d45d269183af..00000000000000 --- a/ngraph/test/runtime/op/convolution.hpp +++ /dev/null @@ -1,304 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "backend_visibility.hpp" -#include "ngraph/coordinate_diff.hpp" -#include "ngraph/op/op.hpp" -#include "ngraph/op/util/attr_types.hpp" - -namespace ngraph -{ - namespace op - { - namespace v0 - { - /// \brief Batched convolution operation, with optional window dilation and stride. - /// - class BACKEND_API Convolution : public Op - { - public: - static constexpr NodeTypeInfo type_info{"Convolution", 0}; - const NodeTypeInfo& get_type_info() const override { return type_info; } - /// \brief Constructs a batched convolution operation. - Convolution() = default; - /// \brief Constructs a batched convolution operation. - /// - /// \param data_batch The node producing the input data batch tensor.
- /// `[N, C_IN, D1, ... Df]` - /// \param filters The node producing the filters tensor.
- /// `[C_OUT, C_IN, F1, ... Ff]` - /// \param window_movement_strides The window movement strides.
- /// `[f]` - /// \param window_dilation_strides The window dilation strides.
- /// `[f]` - /// \param padding_below The padding-below sizes.
- /// `[f]` - /// \param padding_above The padding-above sizes.
- /// `[f]` - /// \param data_dilation_strides The data dilation strides.
- /// `[f]` - /// \param pad_type The pad type for automatically computing padding sizes.
- /// `[f]` - /// - /// Output `[N, C_OUT, R1, ... Rf]` - /// - Convolution(const Output& data_batch, - const Output& filters, - const Strides& window_movement_strides, - const Strides& window_dilation_strides, - const CoordinateDiff& padding_below, - const CoordinateDiff& padding_above, - const Strides& data_dilation_strides, - const PadType& pad_type = PadType::EXPLICIT); - - /// \brief Constructs a batched convolution operation with no data dilation (i.e., - /// all - /// data dilation strides are 1). - /// ngraph/test/runtime/interpreter/unit_test.manifest - /// \param data_batch The node producing the input data batch tensor.
- /// `[N, C_IN, D1, ... Df]` - /// \param filters The node producing the filters tensor.
- /// `[C_OUT, C_IN, F1, ... Ff]` - /// \param window_movement_strides The window movement strides.
- /// `[f]` - /// \param window_dilation_strides The window dilation strides.
- /// `[f]` - /// \param padding_below The padding-below sizes.
- /// `[f]` - /// \param padding_above The padding-above sizes.
- /// `[f]` - /// - /// Output `[N, C_OUT, R1, ... Rf]` - /// - Convolution(const Output& data_batch, - const Output& filters, - const Strides& window_movement_strides, - const Strides& window_dilation_strides, - const CoordinateDiff& padding_below, - const CoordinateDiff& padding_above); - - /// \brief Constructs a batched convolution operation with no padding or data - /// dilation - /// (i.e., padding above and below are 0 everywhere, and all data dilation - /// strides are 1). - /// - /// \param data_batch The node producing the input data batch tensor.
- /// `[N, C_IN, D1, ... Df]` - /// \param filters The node producing the filters tensor.
- /// `[C_OUT, C_IN, F1, ... Ff]` - /// \param window_movement_strides The window movement strides.
- /// `[f]` - /// \param window_dilation_strides The window dilation strides.
- /// `[f]` - /// - /// Output `[N, C_OUT, R1, ... Rf]` - /// - Convolution(const Output& data_batch, - const Output& filters, - const Strides& window_movement_strides, - const Strides& window_dilation_strides); - - /// \brief Constructs a batched convolution operation with no window dilation, - /// padding, - /// or data dilation (i.e., padding above and below are 0 everywhere, and all - /// window/data dilation strides are 1). - /// - /// \param data_batch The node producing the input data batch tensor.
- /// `[N, C_IN, D1, ... Df]` - /// \param filters The node producing the filters tensor.
- /// `[C_OUT, C_IN, F1, ... Ff]` - /// \param window_movement_strides The window movement strides.
- /// `[f]` - /// - /// Output `[N, C_OUT, R1, ... Rf]` - /// - Convolution(const Output& data_batch, - const Output& filters, - const Strides& window_movement_strides); - - /// \brief Constructs a batched convolution operation with no window dilation or - /// movement stride (i.e., padding above and below are 0 everywhere, and all - /// window/data dilation strides and window movement strides are 1). - /// - /// \param data_batch The node producing the input data batch tensor.
- /// `[N, C_IN, D1, ... Df]` - /// \param filters The node producing the filters tensor.
- /// `[C_OUT, C_IN, F1, ... Ff]` - /// - /// Output `[N, C_OUT, R1, ... Rf]` - /// - Convolution(const Output& data_batch, const Output& filters); - - void validate_and_infer_types() override; - bool visit_attributes(AttributeVisitor& visitor) override; - - virtual std::shared_ptr - clone_with_new_inputs(const OutputVector& new_args) const override; - - /// \return The window movement strides. - const Strides& get_window_movement_strides() const - { - return m_window_movement_strides; - } - void set_window_movement_strides(const Strides& window_movement_strides) - { - m_window_movement_strides = window_movement_strides; - } - /// \return The window dilation strides. - const Strides& get_window_dilation_strides() const - { - return m_window_dilation_strides; - } - void set_window_dilation_strides(const Strides& window_dilation_strides) - { - m_window_dilation_strides = window_dilation_strides; - } - /// \return The padding-below sizes (possibly negative). - const CoordinateDiff& get_padding_below() const { return m_padding_below; } - void set_padding_below(const CoordinateDiff& padding_below) - { - m_padding_below = padding_below; - } - /// \return The padding-above sizes (possibly negative). - const CoordinateDiff& get_padding_above() const { return m_padding_above; } - void set_adding_above(const CoordinateDiff& padding_above) - { - m_padding_above = padding_above; - } - /// \return The input data dilation strides. - const Strides& get_data_dilation_strides() const { return m_data_dilation_strides; } - void set_data_dilation_strides(const Strides& data_dilation_strides) - { - m_data_dilation_strides = data_dilation_strides; - } - /// \return The pad type for convolution. - const PadType& get_pad_type() const { return m_pad_type; } - void set_pad_type(const PadType& pad_type) { m_pad_type = pad_type; } - /// \return The default value for Convolution. - NGRAPH_SUPPRESS_DEPRECATED_START - virtual std::shared_ptr get_default_value() const override; - NGRAPH_SUPPRESS_DEPRECATED_END - - protected: - Strides m_window_movement_strides; - Strides m_window_dilation_strides; - CoordinateDiff m_padding_below; - CoordinateDiff m_padding_above; - Strides m_data_dilation_strides; - PadType m_pad_type; - }; - - /// \brief Data batch backprop for batched convolution operation. - class BACKEND_API ConvolutionBackpropData : public Op - { - public: - static constexpr NodeTypeInfo type_info{"ConvolutionBackpropData", 0}; - const NodeTypeInfo& get_type_info() const override { return type_info; } - /// \brief Constructs a batched-convolution data batch-backprop operation. - ConvolutionBackpropData() = default; - /// - /// \brief Constructs a batched-convolution data batch-backprop operation. - /// - /// \param data_batch_shape The shape of the data batch from - /// forward-prop. - /// \param filters The node producing the filters from - /// forward-prop. - /// \param data The node producing output delta. - /// \param window_movement_strides_forward The window movement strides from - /// forward-prop. - /// \param window_dilation_strides_forward The window dilation strides from - /// forward-prop. - /// \param padding_below_forward The padding-below sizes from - /// forward-prop. - /// \param padding_above_forward The padding-above sizes from - /// forward-prop. - /// \param data_dilation_strides_forward The data dilation strides from - /// forward-prop. - /// - ConvolutionBackpropData(const Shape& data_batch_shape, - const Output& filters, - const Output& data, - const Strides& window_movement_strides_forward, - const Strides& window_dilation_strides_forward, - const CoordinateDiff& padding_below_forward, - const CoordinateDiff& padding_above_forward, - const Strides& data_dilation_strides_forward); - - void validate_and_infer_types() override; - bool visit_attributes(AttributeVisitor& visitor) override; - - virtual std::shared_ptr - clone_with_new_inputs(const OutputVector& new_args) const override; - - /// \return The data batch shape. - const Shape& get_data_batch_shape() const { return m_data_batch_shape; } - void set_data_batch_shape(const Shape& data_batch_shape) - { - m_data_batch_shape = data_batch_shape; - } - /// \return The window movement strides from the forward prop. - const Strides& get_window_movement_strides_forward() const - { - return m_window_movement_strides_forward; - } - void set_window_movement_strides_forward( - const Strides& window_movement_strides_forward) - { - m_window_movement_strides_forward = window_movement_strides_forward; - } - /// \return The window dilation strides from the forward prop. - const Strides& get_window_dilation_strides_forward() const - { - return m_window_dilation_strides_forward; - } - void set_window_dilation_strides_forward( - const Strides& window_dilation_strides_forward) - { - m_window_dilation_strides_forward = window_dilation_strides_forward; - } - /// \return The padding-below sizes (possibly negative) from the forward prop. - const CoordinateDiff& get_padding_below_forward() const - { - return m_padding_below_forward; - } - void set_padding_below_forward(const CoordinateDiff& padding_below_forward) - { - m_padding_below_forward = padding_below_forward; - } - /// \return The padding-above sizes (possibly negative) from the forward prop. - const CoordinateDiff& get_padding_above_forward() const - { - return m_padding_above_forward; - } - void set_padding_above_forward(const CoordinateDiff& padding_above_forward) - { - m_padding_above_forward = padding_above_forward; - } - /// \return The input data dilation strides from the forward prop. - const Strides& get_data_dilation_strides_forward() const - { - return m_data_dilation_strides_forward; - } - void set_data_dilation_strides_forward(const Strides& data_dilation_strides_forward) - { - m_data_dilation_strides_forward = data_dilation_strides_forward; - } - - // Compute the pad_above values to be used if in a convolution - CoordinateDiff compute_backward_delta_out_pad_above() const; - CoordinateDiff compute_backward_delta_out_pad_below() const; - - protected: - Shape m_data_batch_shape; - Strides m_window_movement_strides_forward; - Strides m_window_dilation_strides_forward; - CoordinateDiff m_padding_below_forward; - CoordinateDiff m_padding_above_forward; - Strides m_data_dilation_strides_forward; - }; - } // namespace v0 - } // namespace op -} // namespace ngraph diff --git a/ngraph/test/runtime/op/group_conv.cpp b/ngraph/test/runtime/op/group_conv.cpp deleted file mode 100644 index 1a9ce2b464a832..00000000000000 --- a/ngraph/test/runtime/op/group_conv.cpp +++ /dev/null @@ -1,319 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include - -#include "convolution.hpp" -#include "group_conv.hpp" -#include "ngraph/attribute_visitor.hpp" -#include "ngraph/builder/reshape.hpp" -#include "ngraph/builder/split.hpp" -#include "ngraph/op/concat.hpp" -#include "ngraph/op/convolution.hpp" -#include "ngraph/validation_util.hpp" - -using namespace std; -using namespace ngraph; - -NGRAPH_SUPPRESS_DEPRECATED_START - -//------------------------------------------------------------------------------ -// v0::GroupConvolution -//------------------------------------------------------------------------------ - -constexpr NodeTypeInfo op::v0::GroupConvolution::type_info; - -op::v0::GroupConvolution::GroupConvolution(const Output& data_batch, - const Output& filters, - const Strides& window_movement_strides, - const Strides& window_dilation_strides, - const CoordinateDiff& padding_below, - const CoordinateDiff& padding_above, - const Strides& data_dilation_strides, - const size_t groups, - const PadType& pad_type) - : FusedOp({data_batch, filters}) - , m_window_movement_strides(window_movement_strides) - , m_window_dilation_strides(window_dilation_strides) - , m_padding_below(padding_below) - , m_padding_above(padding_above) - , m_data_dilation_strides(data_dilation_strides) - , m_groups(groups) - , m_pad_type(pad_type) - , m_groups_in_filters(false) -{ - constructor_validate_and_infer_types(); -} - -op::v0::GroupConvolution::GroupConvolution(const Output& data_batch, - const Output& filters, - const Strides& window_movement_strides, - const Strides& window_dilation_strides, - const CoordinateDiff& padding_below, - const CoordinateDiff& padding_above, - const Strides& data_dilation_strides, - const PadType& pad_type) - : FusedOp({data_batch, filters}) - , m_window_movement_strides(window_movement_strides) - , m_window_dilation_strides(window_dilation_strides) - , m_padding_below(padding_below) - , m_padding_above(padding_above) - , m_data_dilation_strides(data_dilation_strides) - , m_groups(0) - , m_pad_type(pad_type) - , m_groups_in_filters(true) -{ - constructor_validate_and_infer_types(); -} - -void op::v0::GroupConvolution::pre_validate_and_infer_types() -{ - auto data_shape = get_input_partial_shape(0); - auto filters_shape = get_input_partial_shape(1); - - if (data_shape.is_static() && filters_shape.is_static()) - { - // Update groups - if (m_groups_in_filters) - { - m_groups = get_input_partial_shape(1)[0].get_length(); - } - - // Data channels - NODE_VALIDATION_CHECK(this, - data_shape.to_shape()[1] % get_groups() == 0, - "Data channels not a multiple of group size"); - // Output channels - NODE_VALIDATION_CHECK(this, - filters_shape.to_shape()[0] % get_groups() == 0, - "# Filters not a multiple of group size"); - - // Input Filters - NODE_VALIDATION_CHECK(this, - (filters_shape.to_shape()[m_groups_in_filters ? 2 : 1] * - get_groups()) == data_shape.to_shape()[1], - "Incorrect number of channels per filter"); - } - else - { - set_output_type(0, get_input_element_type(0), PartialShape::dynamic()); - } -} - -void op::v0::GroupConvolution::post_validate_and_infer_types() -{ - auto data_shape = get_input_partial_shape(0); - auto filters_shape = get_input_partial_shape(1); - if (data_shape.is_static() && filters_shape.is_static()) - { - if (m_pad_type == PadType::SAME_UPPER || m_pad_type == PadType::SAME_LOWER) - { - m_padding_below.clear(); - m_padding_above.clear(); - auto filter_shape = filters_shape.to_shape(); - filter_shape.erase(filter_shape.begin(), filter_shape.begin() + 2); // Remove {O,I} - infer_auto_padding(data_shape.to_shape(), - filter_shape, - m_window_movement_strides, - m_window_dilation_strides, - m_pad_type, - m_padding_above, - m_padding_below); - } - } -} - -Shape op::v0::GroupConvolution::get_weights_dimensions() const -{ - auto data_shape = get_input_shape(0); - auto weights_shape = get_input_shape(1); - // check if weights already includes groups - if (m_groups_in_filters) - { - return weights_shape; - } - // reshape weights into 5d tensors that includes groups - const size_t OC = 0; - const size_t OC_IN_OUTPUT = 1; - const size_t IC = 1; - Shape weights_shape_groups{weights_shape}; - // adjust output and channel given a number of groups - - weights_shape_groups.at(OC) = get_shape().at(OC_IN_OUTPUT) / get_groups(); - weights_shape_groups.at(IC) = data_shape.at(IC) / get_groups(); - // push_front the number of groups - weights_shape_groups.insert(weights_shape_groups.begin(), get_groups()); - return weights_shape_groups; -} - -shared_ptr op::v0::GroupConvolution::clone_with_new_inputs(const OutputVector& new_args) const -{ - check_new_args_count(this, new_args); - - if (m_groups_in_filters) - { - return make_shared(new_args.at(0), - new_args.at(1), - get_window_movement_strides(), - get_window_dilation_strides(), - get_padding_below(), - get_padding_above(), - get_data_dilation_strides(), - get_pad_type()); - } - else - { - return make_shared(new_args.at(0), - new_args.at(1), - get_window_movement_strides(), - get_window_dilation_strides(), - get_padding_below(), - get_padding_above(), - get_data_dilation_strides(), - get_groups(), - get_pad_type()); - } -} - -OutputVector op::v0::GroupConvolution::decompose_op() const -{ - auto data = input_value(0); - auto filters = input_value(1); - auto filters_shape = get_input_shape(1); - // Split one convolution op to N ops where N is the number of groups - // and concat results after computation. - NodeVector convolution_nodes; - - // slice data - auto sliced_data = builder::opset1::split(data, get_groups(), 1); - // slice filters - auto sliced_filters = builder::opset1::split(filters, get_groups(), 0); - auto shape = Shape(std::next(std::begin(filters_shape), 1), std::end(filters_shape)); - for (std::size_t group{0}; group < get_groups(); ++group) - { - auto sliced_filter = sliced_filters[group]; - if (m_groups_in_filters) - { - // Remove group dimension after slicing - sliced_filter = builder::opset1::reshape(sliced_filters[group], shape); - } - convolution_nodes.push_back( - std::make_shared(sliced_data[group], - sliced_filter, - m_window_movement_strides, - m_window_dilation_strides, - m_padding_below, - m_padding_above, - m_data_dilation_strides, - m_pad_type)); - } - std::size_t concatenation_axis = 1; - return {std::make_shared(convolution_nodes, concatenation_axis)}; -} - -//------------------------------------------------------------------------------ -// v0::GroupConvolutionBackpropData -//------------------------------------------------------------------------------ - -constexpr NodeTypeInfo op::v0::GroupConvolutionBackpropData::type_info; - -op::v0::GroupConvolutionBackpropData::GroupConvolutionBackpropData( - const Output& data_batch, - const Output& filters, - const Output& output_delta, - const Strides& window_movement_strides, - const Strides& window_dilation_strides, - const CoordinateDiff& padding_below, - const CoordinateDiff& padding_above, - const size_t groups) - : FusedOp({data_batch, filters, output_delta}) - , m_window_movement_strides(window_movement_strides) - , m_window_dilation_strides(window_dilation_strides) - , m_padding_below(padding_below) - , m_padding_above(padding_above) - , m_groups(groups) -{ - constructor_validate_and_infer_types(); -} - -void op::v0::GroupConvolutionBackpropData::pre_validate_and_infer_types() -{ - element::Type data_element_type = get_input_element_type(2); - element::Type filters_elem_type = get_input_element_type(1); - - NODE_VALIDATION_CHECK(this, - data_element_type.is_dynamic() || data_element_type.is_real(), - "Output delta element type must be f16, bf16, f32, f64 or dynamic (got ", - data_element_type, - ")."); - NODE_VALIDATION_CHECK(this, - filters_elem_type.is_dynamic() || filters_elem_type.is_real(), - "Filters element type must be f16, bf16, f32, f64 or dynamic (got ", - filters_elem_type, - ")."); - - PartialShape data_pshape = get_input_partial_shape(0); - PartialShape filters_pshape = get_input_partial_shape(1); - PartialShape delta_pshape = get_input_partial_shape(2); - - if (data_pshape.is_dynamic() || filters_pshape.is_dynamic() || delta_pshape.is_dynamic()) - { - set_output_type(0, data_element_type, PartialShape::dynamic()); - } -} - -shared_ptr - op::v0::GroupConvolutionBackpropData::clone_with_new_inputs(const OutputVector& new_args) const -{ - if (new_args.size() != 3) - { - throw ngraph_error("Incorrect number of new arguments"); - } - - return make_shared(new_args.at(0), - new_args.at(1), - new_args.at(2), - get_window_movement_strides(), - get_window_dilation_strides(), - get_padding_below(), - get_padding_above(), - get_groups()); -} - -OutputVector op::v0::GroupConvolutionBackpropData::decompose_op() const -{ - auto filters = input_value(1); - auto output_delta = input_value(2); - auto data_shape = get_input_shape(0); - - NodeVector sliced_inputs; - - auto groups = get_groups(); - // slice data shape - data_shape[1] /= groups; - // slice delta - auto sliced_delta = builder::opset1::split(output_delta, groups, 1); - // slice filters - auto sliced_filters = builder::opset1::split(filters, groups, 0); - - auto num_spatials = get_window_movement_strides().size(); - - for (size_t i = 0; i < groups; ++i) - { - auto sliced_conv = std::make_shared( - data_shape, - sliced_filters[i], - sliced_delta[i], - get_window_movement_strides(), - get_window_dilation_strides(), - get_padding_below(), - get_padding_above(), - Strides(num_spatials, 1)); // default data dilation strides - - sliced_inputs.push_back(sliced_conv); - } - - size_t concatenation_axis = 1; - return {std::make_shared(sliced_inputs, concatenation_axis)}; -} diff --git a/ngraph/test/runtime/op/group_conv.hpp b/ngraph/test/runtime/op/group_conv.hpp deleted file mode 100644 index 088d9ca4be6557..00000000000000 --- a/ngraph/test/runtime/op/group_conv.hpp +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "backend_visibility.hpp" -#include "ngraph/op/convolution.hpp" -#include "ngraph/op/op.hpp" -#include "ngraph/op/util/attr_types.hpp" -#include "ngraph/op/util/fused_op.hpp" - -NGRAPH_SUPPRESS_DEPRECATED_START - -namespace ngraph -{ - namespace op - { - namespace v0 - { - /// \brief Group Convolution - class BACKEND_API GroupConvolution : public ngraph::op::util::FusedOp - { - public: - static constexpr NodeTypeInfo type_info{"GroupConvolution", 0}; - const NodeTypeInfo& get_type_info() const override { return type_info; } - GroupConvolution() = default; - GroupConvolution(const Output& data_batch, - const Output& filters, - const Strides& window_movement_strides, - const Strides& window_dilation_strides, - const CoordinateDiff& padding_below, - const CoordinateDiff& padding_above, - const Strides& data_dilation_strides, - const size_t groups, - const PadType& pad_type = PadType::EXPLICIT); - - // constructor which accept groups included in filters shape. - GroupConvolution(const Output& data_batch, - const Output& filters, - const Strides& window_movement_strides, - const Strides& window_dilation_strides, - const CoordinateDiff& padding_below, - const CoordinateDiff& padding_above, - const Strides& data_dilation_strides, - const PadType& pad_type = PadType::EXPLICIT); - Shape get_weights_dimensions() const; - const Strides& get_window_movement_strides() const - { - return m_window_movement_strides; - } - const Strides& get_window_dilation_strides() const - { - return m_window_dilation_strides; - } - const CoordinateDiff& get_padding_below() const { return m_padding_below; } - const CoordinateDiff& get_padding_above() const { return m_padding_above; } - const Strides& get_data_dilation_strides() const { return m_data_dilation_strides; } - Output get_filters() { return input_value(1); } - Output get_data_batch() { return input_value(0); } - size_t get_groups() const { return m_groups; }; - const PadType& get_pad_type() const { return m_pad_type; } - virtual std::shared_ptr - clone_with_new_inputs(const OutputVector& new_args) const override; - - virtual OutputVector decompose_op() const override; - - virtual void pre_validate_and_infer_types() override; - virtual void post_validate_and_infer_types() override; - - bool has_groups_in_filters() const { return m_groups_in_filters; } - - protected: - Strides m_window_movement_strides; - Strides m_window_dilation_strides; - CoordinateDiff m_padding_below; - CoordinateDiff m_padding_above; - Strides m_data_dilation_strides; - size_t m_groups; - PadType m_pad_type{PadType::NOTSET}; - - private: - bool m_groups_in_filters; - }; - - /// \brief Group Convolution data batch backprop - class BACKEND_API GroupConvolutionBackpropData : public ngraph::op::util::FusedOp - { - public: - static constexpr NodeTypeInfo type_info{"GroupConvolutionBackpropData", 0}; - const NodeTypeInfo& get_type_info() const override { return type_info; } - GroupConvolutionBackpropData() = default; - GroupConvolutionBackpropData(const Output& data_batch, - const Output& filters, - const Output& output_delta, - const Strides& window_movement_strides, - const Strides& window_dilation_strides, - const CoordinateDiff& padding_below, - const CoordinateDiff& padding_above, - const size_t groups); - - const Strides& get_window_movement_strides() const - { - return m_window_movement_strides; - } - const Strides& get_window_dilation_strides() const - { - return m_window_dilation_strides; - } - const CoordinateDiff& get_padding_below() const { return m_padding_below; } - const CoordinateDiff& get_padding_above() const { return m_padding_above; } - size_t get_groups() const { return m_groups; }; - virtual std::shared_ptr - clone_with_new_inputs(const OutputVector& new_args) const override; - - virtual OutputVector decompose_op() const override; - - virtual void pre_validate_and_infer_types() override; - - protected: - Strides m_window_movement_strides; - Strides m_window_dilation_strides; - CoordinateDiff m_padding_below; - CoordinateDiff m_padding_above; - size_t m_groups; - }; - } - } // namespace op -} // namespace ngraph - -NGRAPH_SUPPRESS_DEPRECATED_END diff --git a/ngraph/test/runtime/opset0_tbl.hpp b/ngraph/test/runtime/opset0_tbl.hpp deleted file mode 100644 index d5eb01e1bfcad8..00000000000000 --- a/ngraph/test/runtime/opset0_tbl.hpp +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -// This collection contains one entry for each op. If an op is added it must be -// added to this list. -// -// In order to use this list you want to define a macro named exactly NGRAPH_OP -// When you are done you should undef the macro -// As an example if you wanted to make a list of all op names as strings you could do this: -// -// #define NGRAPH_OP(a,b) #a, -// std::vector op_names{ -// #include "this include file name" -// }; -// #undef NGRAPH_OP -// -// This sample expands to a list like this: -// "Abs", -// "Acos", -// ... -// -// #define NGRAPH_OP(a,b) b::a, -// std::vector op_names{ -// #include "this include file name" -// }; -// #undef NGRAPH_OP -// -// This sample expands to a list like this: -// ngraph::op::Abs, -// ngraph::op::Acos, -// ... -// -// It's that easy. You can use this for fun and profit. - -#ifndef NGRAPH_OP -#warning "NGRAPH_OP not defined" -#define NGRAPH_OP(x, y) -#endif - -NGRAPH_OP(Abs, ngraph::op) -NGRAPH_OP(Acos, ngraph::op) -NGRAPH_OP(Asin, ngraph::op) -NGRAPH_OP(Atan, ngraph::op) -NGRAPH_OP(AvgPool, ngraph::op::v0) -NGRAPH_OP(BatchNormInference, ngraph::op::v0) -NGRAPH_OP(Broadcast, ngraph::op::v1) -NGRAPH_OP(Ceiling, ngraph::op) -NGRAPH_OP(Clamp, ngraph::op) -NGRAPH_OP(Concat, ngraph::op) -NGRAPH_OP(Constant, ngraph::op) -NGRAPH_OP(Convert, ngraph::op) -NGRAPH_OP(Convolution, ngraph::op::v0) -NGRAPH_OP(ConvolutionBackpropData, ngraph::op::v0) -NGRAPH_OP(Cos, ngraph::op) -NGRAPH_OP(Cosh, ngraph::op) -NGRAPH_OP(CumSum, ngraph::op::v0) -NGRAPH_OP(DepthToSpace, ngraph::op) -NGRAPH_OP(Elu, ngraph::op) -NGRAPH_OP(Erf, ngraph::op) -NGRAPH_OP(Exp, ngraph::op) -NGRAPH_OP(FakeQuantize, ngraph::op) -NGRAPH_OP(Floor, ngraph::op) -NGRAPH_OP(GRN, ngraph::op) -NGRAPH_OP(Gather, ngraph::op::v1) -NGRAPH_OP(Gelu, ngraph::op) -NGRAPH_OP(GroupConvolution, ngraph::op::v0) -NGRAPH_OP(GroupConvolutionBackpropData, ngraph::op::v0) -NGRAPH_OP(HardSigmoid, ngraph::op) -NGRAPH_OP(Interpolate, ngraph::op::v0) -NGRAPH_OP(Log, ngraph::op) -NGRAPH_OP(LRN, ngraph::op) -NGRAPH_OP(LSTMSequence, ngraph::op::v0) -NGRAPH_OP(MatMul, ngraph::op) -NGRAPH_OP(MVN, ngraph::op) -NGRAPH_OP(Negative, ngraph::op) -NGRAPH_OP(NormalizeL2, ngraph::op::v0) -NGRAPH_OP(Parameter, ngraph::op) -NGRAPH_OP(PRelu, ngraph::op) -NGRAPH_OP(PriorBox, ngraph::op) -NGRAPH_OP(Range, ngraph::op) -NGRAPH_OP(Relu, ngraph::op) -NGRAPH_OP(Result, ngraph::op) -NGRAPH_OP(ReverseSequence, ngraph::op) -NGRAPH_OP(Selu, ngraph::op) -NGRAPH_OP(ShapeOf, ngraph::op) -NGRAPH_OP(ShuffleChannels, ngraph::op) -NGRAPH_OP(Sigmoid, ngraph::op) -NGRAPH_OP(Sign, ngraph::op) -NGRAPH_OP(Sin, ngraph::op) -NGRAPH_OP(Sinh, ngraph::op) -NGRAPH_OP(SpaceToDepth, ngraph::op) -NGRAPH_OP(Sqrt, ngraph::op) -NGRAPH_OP(SquaredDifference, ngraph::op) -NGRAPH_OP(Squeeze, ngraph::op) -NGRAPH_OP(Tan, ngraph::op) -NGRAPH_OP(Tanh, ngraph::op) -NGRAPH_OP(TensorIterator, ngraph::op) -NGRAPH_OP(Tile, ngraph::op::v0) -NGRAPH_OP(Unsqueeze, ngraph::op::v0) -NGRAPH_OP(Xor, ngraph::op) diff --git a/ngraph/test/runtime/pass/fused_op_decomposition.cpp b/ngraph/test/runtime/pass/fused_op_decomposition.cpp deleted file mode 100644 index 89cbba09536168..00000000000000 --- a/ngraph/test/runtime/pass/fused_op_decomposition.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "fused_op_decomposition.hpp" -#include "ngraph/graph_util.hpp" -#include "ngraph/op/util/op_types.hpp" -#include "ngraph/provenance.hpp" - -using namespace std; -using namespace ngraph; - -NGRAPH_SUPPRESS_DEPRECATED_START - -pass::FusedOpDecomposition::FusedOpDecomposition(op_query_t callback) - : m_has_direct_support{callback} -{ -} - -bool pass::FusedOpDecomposition::run_on_node(shared_ptr node) -{ - bool modified = false; - - if (op::supports_decompose(node)) - { - if (m_has_direct_support && m_has_direct_support(*node)) - { - // Op supported by backend. Do not decompose - return modified; - } - - OutputVector output_vector = node->decompose_op(); - NodeVector subgraph_outputs = as_node_vector(output_vector); - - if (ngraph::get_provenance_enabled()) - { - // Capture the input values as an edge for provenance - auto base_input_values = node->input_values(); - auto provenance_tags = node->get_provenance_tags(); - const std::string tag = "get_type_name()) + ">"; - provenance_tags.insert(tag); - - // Transfer the new provenance tags to the newly created ops - for (auto output_node : subgraph_outputs) - { - output_node->add_provenance_tags_above(base_input_values, provenance_tags); - } - } - - // Run recursively until no more fused ops - auto subgraph = extract_subgraph(subgraph_outputs, as_node_vector(node->input_values())); - for (auto subgraph_node : subgraph) - { - run_on_node(subgraph_node); - } - - size_t i = 0; - for (auto output_node : subgraph_outputs) - { - for (size_t j = 0; j < output_node->outputs().size(); j++, i++) - { - std::set> fop_users = node->outputs().at(i).get_target_inputs(); - for (auto fop_user : fop_users) - { - fop_user.replace_source_output(output_node->output(j)); - } - } - } - if (i != node->get_output_size()) - { - throw ngraph_error("While replacing " + node->get_name() + - ", mismatch between op output count and outputs of the decomposed " - "subgraph. Expected: " + - to_string(node->get_output_size()) + " Got: " + to_string(i)); - } - modified = true; - } - - return modified; -} diff --git a/ngraph/test/runtime/pass/fused_op_decomposition.hpp b/ngraph/test/runtime/pass/fused_op_decomposition.hpp deleted file mode 100644 index e1b7fdcfc352cf..00000000000000 --- a/ngraph/test/runtime/pass/fused_op_decomposition.hpp +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -#include "backend_visibility.hpp" -#include "ngraph/pass/pass.hpp" - -NGRAPH_SUPPRESS_DEPRECATED_START - -namespace ngraph -{ - namespace pass - { - /// \brief The FusedOpDecomposition pass is used to decompose a fused op - /// into a sub-graph of supported ops if the fused op is not supported by - /// the backend. - /// - /// \details By default, the pass decomposes a fused op if it is not - /// supported by the backend and runs recursively until no more fused ops - /// can be found or the new ops are supported by the backend. - /// If the backend supports a fused op, then it can provide a callback - /// function while registering the pass. The callback function can then - /// provide logic to prevent decomposing the supported op. - /// It also adds provenance tags along the way to each op for easy reference - /// and debugging. - /// - /// In the example shown below, the original graph has a fused GeLU op. - /// After applying this pass, the GeLU op is decomposed into group of ops which - /// together perform the same operation as GeLU. - /// - /// - /// - /// - /// - /// - /// - /// - ///
Before the pass After the pass
\image html decompose_gelu_pre.svg \image html decompose_gelu_post.svg
- class BACKEND_API FusedOpDecomposition : public NodePass - { - public: /// \brief Function signature type for callback used to check whether provided node - /// is supported by backend. - using op_query_t = std::function; - - /// - /// \brief Constructor for the Fused operation decomposition pass. - /// - /// \param[in] callback The function object used to determine whether current backend - /// provide direct support for passed node. Should have signature: - /// bool fn(const Node&) - /// - FusedOpDecomposition(op_query_t callback = nullptr); - bool run_on_node(std::shared_ptr node) override; - - private: - /// \brief A function returning whether provided Node is supported by current backend. - /// The returned bool value is used to control whether decompose operator or not. - op_query_t m_has_direct_support = nullptr; - }; - } -} - -NGRAPH_SUPPRESS_DEPRECATED_END diff --git a/ngraph/test/runtime/pass/implicit_broadcast_elimination.cpp b/ngraph/test/runtime/pass/implicit_broadcast_elimination.cpp deleted file mode 100644 index ce380781e791dd..00000000000000 --- a/ngraph/test/runtime/pass/implicit_broadcast_elimination.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "implicit_broadcast_elimination.hpp" - -#include "ngraph/builder/autobroadcast.hpp" -#include "ngraph/graph_util.hpp" -#include "ngraph/op/util/binary_elementwise_arithmetic.hpp" -#include "ngraph/op/util/binary_elementwise_comparison.hpp" -#include "ngraph/op/util/binary_elementwise_logical.hpp" -#include "ngraph/op/util/op_types.hpp" - -NGRAPH_SUPPRESS_DEPRECATED_START - -using namespace std; -using namespace ngraph; - -bool ngraph::pass::ImplicitBroadcastElimination::run_on_node(std::shared_ptr node) -{ - if (ngraph::op::supports_auto_broadcast(node)) - { - if (node->get_autob().m_type != op::AutoBroadcastType::NONE) - { - auto new_args = pass::explicit_broadcast(node); - for (size_t i = 0; i < new_args.size(); i++) - { - node->input(i).replace_source_output(new_args[i]->output(0)); - } - return true; - } - } - return false; -} - -NodeVector ngraph::pass::explicit_broadcast(std::shared_ptr& node) -{ - NodeVector rc; - if (ngraph::op::supports_auto_broadcast(node)) - { - auto autob = node->get_autob(); - if (autob.m_type == op::AutoBroadcastType::NONE) - { - for (auto& val : node->input_values()) - rc.emplace_back(val.get_node_shared_ptr()); - } - else if (autob.m_type == op::AutoBroadcastType::NUMPY) - { - rc = as_node_vector(builder::numpy_broadcast_outputs(node->input_values())); - } - else if (autob.m_type == op::AutoBroadcastType::PDPD) - { - rc = as_node_vector(builder::pdpd_broadcast(node->input_values(), autob.m_axis)); - } - else - { - throw ngraph_error("Unsupported implicit broadcast type"); - } - } - return rc; -} diff --git a/ngraph/test/runtime/pass/implicit_broadcast_elimination.hpp b/ngraph/test/runtime/pass/implicit_broadcast_elimination.hpp deleted file mode 100644 index 939c2b2073c652..00000000000000 --- a/ngraph/test/runtime/pass/implicit_broadcast_elimination.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "backend_visibility.hpp" -#include "ngraph/node.hpp" -#include "ngraph/pass/pass.hpp" - -NGRAPH_SUPPRESS_DEPRECATED_START - -namespace ngraph -{ - namespace pass - { - NodeVector explicit_broadcast(std::shared_ptr& node); - class ImplicitBroadcastElimination; - } -} - -class BACKEND_API ngraph::pass::ImplicitBroadcastElimination : public ngraph::pass::NodePass -{ -public: - bool run_on_node(std::shared_ptr node) override; -}; - -NGRAPH_SUPPRESS_DEPRECATED_END diff --git a/ngraph/test/runtime/pass/liveness.cpp b/ngraph/test/runtime/pass/liveness.cpp deleted file mode 100644 index bb0b9487a6e565..00000000000000 --- a/ngraph/test/runtime/pass/liveness.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include -#include - -#include "liveness.hpp" -#include "ngraph/descriptor/input.hpp" -#include "ngraph/descriptor/output.hpp" -#include "ngraph/function.hpp" -#include "ngraph/graph_util.hpp" -#include "ngraph/log.hpp" -#include "ngraph/node.hpp" -#include "ngraph/op/constant.hpp" -#include "ngraph/op/parameter.hpp" -#include "ngraph/op/result.hpp" -#include "ngraph/util.hpp" - -using namespace std; -using namespace ngraph; - -bool pass::Liveness::run_on_function(shared_ptr function) -{ - auto ops = function->get_ordered_ops(); - - unordered_set persistent_tensors; - unordered_set output_tensors; - for (const shared_ptr& node : function->get_parameters()) - { - for (auto& output : node->outputs()) - { - descriptor::Tensor& tensor = output.get_tensor(); - persistent_tensors.insert(&tensor); - } - } - for (const shared_ptr& node : function->get_results()) - { - for (auto& output : node->outputs()) - { - descriptor::Tensor& tensor = output.get_tensor(); - persistent_tensors.insert(&tensor); - output_tensors.insert(&tensor); - } - } - for (const shared_ptr& node : ops) - { - if (auto constant_node = as_type_ptr(node)) - { - for (auto& output : constant_node->outputs()) - { - descriptor::Tensor& tensor = output.get_tensor(); - persistent_tensors.insert(&tensor); - } - } - } - - unordered_set currently_live; - for (auto it = ops.rbegin(); it != ops.rend(); it++) - { - const shared_ptr& node = *it; - node->liveness_new_list.clear(); - node->liveness_free_list.clear(); - unordered_set input_tensor_decls; - for (auto& input : node->inputs()) - { - descriptor::Tensor& tensor = input.get_tensor(); - if (persistent_tensors.find(&tensor) == persistent_tensors.end()) - { - input_tensor_decls.insert(&tensor); - } - } - - unordered_set output_tensor_decls; - for (auto& output : node->outputs()) - { - descriptor::Tensor& tensor = output.get_tensor(); - if (persistent_tensors.find(&tensor) == persistent_tensors.end()) - { - output_tensor_decls.insert(&tensor); - } - } - - unordered_set free_tensor_decls; - unordered_set new_tensor_decls; - unordered_set all_tensor_decls = input_tensor_decls; - all_tensor_decls.insert(output_tensor_decls.begin(), output_tensor_decls.end()); - - for (descriptor::Tensor* tensor_decl : all_tensor_decls) - { - if (currently_live.find(tensor_decl) == currently_live.end()) - { - // this is the last node that value is seen in - // delete it at the end of the op - currently_live.insert(tensor_decl); - if (output_tensors.find(tensor_decl) == output_tensors.end()) - { - // Don't free output tensors - free_tensor_decls.insert(tensor_decl); - } - } - } - - for (descriptor::Tensor* output_decl : output_tensor_decls) - { - auto currently_live_it = currently_live.find(output_decl); - if (currently_live_it != currently_live.end()) - { - new_tensor_decls.insert(output_decl); - currently_live.erase(currently_live_it); - } - } - node->liveness_free_list = free_tensor_decls; - node->liveness_new_list = new_tensor_decls; - } - - return false; -} diff --git a/ngraph/test/runtime/pass/liveness.hpp b/ngraph/test/runtime/pass/liveness.hpp deleted file mode 100644 index 64aff0bc8e00c7..00000000000000 --- a/ngraph/test/runtime/pass/liveness.hpp +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "backend_visibility.hpp" -#include "ngraph/descriptor/tensor.hpp" -#include "ngraph/pass/pass.hpp" - -namespace ngraph -{ - namespace pass - { - class Liveness; - } -} - -class BACKEND_API ngraph::pass::Liveness : public FunctionPass -{ -public: - bool run_on_function(std::shared_ptr) override; -}; diff --git a/ngraph/test/runtime/pass/opset0_downgrade.cpp b/ngraph/test/runtime/pass/opset0_downgrade.cpp deleted file mode 100644 index 4d48854bf6b02b..00000000000000 --- a/ngraph/test/runtime/pass/opset0_downgrade.cpp +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include -#include -#include - -#include "ngraph/builder/autobroadcast.hpp" -#include "ngraph/builder/reshape.hpp" -#include "ngraph/graph_util.hpp" -#include "ngraph/node.hpp" -#include "ngraph/op/util/attr_types.hpp" -#include "ngraph/op/util/op_types.hpp" -#include "ngraph/ops.hpp" -#include "ngraph/provenance.hpp" -#include "ngraph/slice_plan.hpp" -#include "ngraph/type.hpp" -#include "ngraph/validation_util.hpp" -#include "op/avg_pool.hpp" -#include "pass/implicit_broadcast_elimination.hpp" -#include "pass/opset0_downgrade.hpp" - -NGRAPH_SUPPRESS_DEPRECATED_START - -using namespace std; -using namespace ngraph; - -namespace opset0_downgrade -{ - template - shared_ptr op_cast_binary_elementwise_node(const shared_ptr& node) - { - const auto input_arg0 = node->input_value(0); - const auto input_arg1 = node->input_value(1); - const auto autob = node->get_autob(); - auto replacement_node = make_shared(input_arg0, input_arg1, autob); - replace_node(node, replacement_node); - return replacement_node; - } - - template - shared_ptr op_cast_reduction_node(const shared_ptr& node) - { - auto replacement_node = make_shared(node->input_value(0), node->input_value(1)); - if (node->get_keep_dims()) - { - string v1_op_name = string{node->get_type_name()} + ":v1"; - string v0_op_name = string{OpV0{}.get_type_name()} + ":v0"; - - NGRAPH_CHECK(node->reduction_axes_constant(), - "Unable to convert ", - v1_op_name, - "to ", - v0_op_name, - " if reduction axes are not constant (for keep_dims=true). Node: ", - *node); - auto output_pshape = replacement_node->get_output_partial_shape(0); - NGRAPH_CHECK(output_pshape.is_static(), - "Unable to convert ", - v1_op_name, - "to ", - v0_op_name, - " if output shape is dynamic (for keep_dims=true). Node: ", - *node); - const auto output_shape = output_pshape.to_shape(); - auto reshaped_output_shape = output_shape; - for (const auto& axis : node->get_reduction_axes()) - { - reshaped_output_shape.insert(reshaped_output_shape.begin() + axis, 1); - } - auto shape_pattern = op::Constant::create( - element::u64, {reshaped_output_shape.size()}, reshaped_output_shape); - auto reshaped_product = - make_shared(replacement_node->output(0), shape_pattern, false); - return reshaped_product; - } - else - { - return replacement_node; - } - } - - // Default is that we did nothing - shared_ptr op_cast(shared_ptr node) { return nullptr; } - shared_ptr op_cast(shared_ptr node) - { - return op_cast_binary_elementwise_node(node); - } - - using DispatchMap = map node)>>; - - template - bool op_cast_thunk(shared_ptr node) - { - auto downgraded_node = op_cast(as_type_ptr(node)); - if (downgraded_node) - { - if (ngraph::get_provenance_enabled()) - { - const std::string provenance_tag = - "get_type_name()) + ")>"; - downgraded_node->add_provenance_tags_above(node->input_values(), {provenance_tag}); - } - return true; - } - return false; - } - - DispatchMap& get_dispatch_map() - { - static DispatchMap dispatch_map{ -#define NGRAPH_OP(NAME, NAMESPACE) {NAMESPACE::NAME::type_info, op_cast_thunk}, -#include "ngraph/opsets/opset1_tbl.hpp" -#undef NGRAPH_OP - }; - return dispatch_map; - } -} // namespace opset0_downgrade - -bool pass::Opset0Downgrade::run_on_node(shared_ptr node) -{ - bool modified = false; - auto& dispatch_map = opset0_downgrade::get_dispatch_map(); - auto it = dispatch_map.find(node->get_type_info()); - if (it != dispatch_map.end()) - { - modified = it->second(node); - } - return modified; -} diff --git a/ngraph/test/runtime/pass/opset0_downgrade.hpp b/ngraph/test/runtime/pass/opset0_downgrade.hpp deleted file mode 100644 index 96a831d9c9f259..00000000000000 --- a/ngraph/test/runtime/pass/opset0_downgrade.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "backend_visibility.hpp" -#include "ngraph/pass/pass.hpp" - -NGRAPH_SUPPRESS_DEPRECATED_START - -namespace ngraph -{ - namespace pass - { - class BACKEND_API Opset0Downgrade : public NodePass - { - public: - /// - /// \brief Constructor for the Opv1 downgrade transformation pass. - /// - /// \details This transformation pass iterates over all nodes in a graph - /// and updates version 1 ops to their version 0 equivalents. - /// All ops in the final graph have op version 0. - Opset0Downgrade() = default; - bool run_on_node(std::shared_ptr node) override; - }; - } -} - -NGRAPH_SUPPRESS_DEPRECATED_END diff --git a/ngraph/test/runtime/pass/opset1_downgrade.cpp b/ngraph/test/runtime/pass/opset1_downgrade.cpp deleted file mode 100644 index 1d77d39b8aaf2d..00000000000000 --- a/ngraph/test/runtime/pass/opset1_downgrade.cpp +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include - -#include "ngraph/node.hpp" -#include "ngraph/ops.hpp" -#include "ngraph/provenance.hpp" -#include "ngraph/validation_util.hpp" -#include "opset1_downgrade.hpp" - -using namespace std; -using namespace ngraph; - -namespace opset1_downgrade -{ - shared_ptr op_cast(shared_ptr node) - { - const auto data = node->input_value(0).get_node_shared_ptr(); - const auto target_shape = node->input_value(1).get_node_shared_ptr(); - - shared_ptr replacement_node; - switch (node->get_broadcast_spec().m_type) - { - case op::BroadcastType::BIDIRECTIONAL: - { - const auto const_filled_with_ones = make_shared( - op::Constant::create(data->get_element_type(), {}, {1}), target_shape); - if (const_filled_with_ones->get_element_type() == element::boolean) - { - replacement_node = make_shared(data, const_filled_with_ones); - } - else - { - replacement_node = make_shared(data, const_filled_with_ones); - } - break; - } - case op::BroadcastType::EXPLICIT: - { - const auto axes_mapping = node->input_value(2).get_node_shared_ptr(); - replacement_node = make_shared( - data, target_shape, axes_mapping, op::AutoBroadcastType::EXPLICIT); - break; - } - case op::BroadcastType::NUMPY: - { - replacement_node = - make_shared(data, target_shape, op::AutoBroadcastType::NUMPY); - break; - } - case op::BroadcastType::PDPD: - { - op::AutoBroadcastSpec broadcast_spec; - broadcast_spec.m_type = op::AutoBroadcastType::PDPD; - broadcast_spec.m_axis = node->get_broadcast_spec().m_axis; - replacement_node = make_shared(data, target_shape, broadcast_spec); - break; - } - default: - { - NGRAPH_CHECK( - true, - "Not supported broadcast type during Broadcast:v3 to Broadcast:v1 conversion. ", - "Node: ", - *node); - } - } - replace_node(node, replacement_node); - return replacement_node; - } - - shared_ptr op_cast(shared_ptr node) - { - const auto data = node->input_value(0); - const auto k = node->input_value(1); - const auto replacement_node = make_shared(data, - k, - node->get_axis(), - node->get_mode(), - node->get_sort_type(), - node->get_index_element_type()); - replace_node(node, replacement_node); - return replacement_node; - } - - using DispatchMap = map node)>>; - - template - bool op_cast_thunk(shared_ptr node) - { - auto downgraded_node = op_cast(as_type_ptr(node)); - if (downgraded_node) - { - if (ngraph::get_provenance_enabled()) - { - const std::string provenance_tag = - "get_type_name()) + ")>"; - downgraded_node->add_provenance_tags_above(node->input_values(), {provenance_tag}); - } - return true; - } - return false; - } - - DispatchMap& get_dispatch_map() - { - static DispatchMap dispatch_map{ -#define NGRAPH_OP(NAME, NAMESPACE) {NAMESPACE::NAME::type_info, op_cast_thunk}, - NGRAPH_OP(Broadcast, op::v3) NGRAPH_OP(TopK, op::v3) -#undef NGRAPH_OP - }; - return dispatch_map; - } -} // namespace opset1_downgrade - -bool pass::Opset1Downgrade::run_on_node(shared_ptr node) -{ - bool modified = false; - auto& dispatch_map = opset1_downgrade::get_dispatch_map(); - auto it = dispatch_map.find(node->get_type_info()); - if (it != dispatch_map.end()) - { - modified = it->second(node); - } - return modified; -} diff --git a/ngraph/test/runtime/pass/opset1_downgrade.hpp b/ngraph/test/runtime/pass/opset1_downgrade.hpp deleted file mode 100644 index 52e9d8397bc0c1..00000000000000 --- a/ngraph/test/runtime/pass/opset1_downgrade.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "backend_visibility.hpp" -#include "ngraph/pass/pass.hpp" - -NGRAPH_SUPPRESS_DEPRECATED_START - -namespace ngraph -{ - namespace pass - { - class BACKEND_API Opset1Downgrade : public NodePass - { - public: - /// - /// \brief Constructor for the Opv1 downgrade transformation pass. - /// - /// \details This transformation pass iterates over all nodes in a graph - /// and updates version 3 ops to their version 1 equivalents. - /// All ops in the final graph have op version 1. - Opset1Downgrade() = default; - bool run_on_node(std::shared_ptr node) override; - }; - } -} - -NGRAPH_SUPPRESS_DEPRECATED_END diff --git a/ngraph/test/runtime/pass/opset1_upgrade.cpp b/ngraph/test/runtime/pass/opset1_upgrade.cpp deleted file mode 100644 index 9c8f2d4c8e7cde..00000000000000 --- a/ngraph/test/runtime/pass/opset1_upgrade.cpp +++ /dev/null @@ -1,222 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "opset1_upgrade.hpp" - -#include -#include -#include -#include - -#include "ngraph/builder/autobroadcast.hpp" -#include "ngraph/builder/reshape.hpp" -#include "ngraph/graph_util.hpp" -#include "ngraph/op/util/op_types.hpp" -#include "ngraph/ops.hpp" -#include "ngraph/provenance.hpp" -#include "op/avg_pool.hpp" -#include "op/convolution.hpp" -#include "op/group_conv.hpp" - -NGRAPH_SUPPRESS_DEPRECATED_START - -using namespace std; -using namespace ngraph; - -namespace opset1_upgrade -{ - template - shared_ptr op_cast_binary_elementwise_node(const shared_ptr& node) - { - const auto autob = node->get_autob(); - auto replacement_node = - make_shared(node->input_value(0), node->input_value(1), autob); - replace_node(node, replacement_node); - return replacement_node; - } - - // Default is that we didn nothing - shared_ptr op_cast(shared_ptr node) { return nullptr; } - shared_ptr op_cast(shared_ptr node) - { - auto data_batch_shape = node->get_data_batch_shape(); - auto strides = node->get_window_movement_strides_forward(); - auto dilations = node->get_window_dilation_strides_forward(); - auto pads_begin = node->get_padding_below_forward(); - auto pads_end = node->get_padding_above_forward(); - auto data_dilation_strides = node->get_data_dilation_strides_forward(); - - bool is_dds_valid = all_of(data_dilation_strides.begin(), - data_dilation_strides.end(), - [](size_t value) { return value == 1; }); - - NGRAPH_CHECK(is_dds_valid, - "Unable to convert ConvolutionBackpropData:0 to ConvolutionBackpropData:1 " - "with data dilation strides " - "other than `1`. Node: ", - *node); - - auto replacement_node = make_shared( - node->input_value(1), // data - node->input_value(0), // filters - op::Constant::create( - element::i64, - Shape{data_batch_shape.size() - 2}, - vector(data_batch_shape.begin() + 2, data_batch_shape.end())), - strides, - pads_begin, - pads_end, - dilations); - replace_node(node, replacement_node); - return replacement_node; - } - - shared_ptr op_cast(shared_ptr node) - { - auto strides = node->get_window_movement_strides(); - auto dilations = node->get_window_dilation_strides(); - auto pads_begin = node->get_padding_below(); - auto pads_end = node->get_padding_above(); - auto data_dilation_strides = node->get_data_dilation_strides(); - auto auto_pad = node->get_pad_type(); - - bool is_dds_valid = all_of(data_dilation_strides.begin(), - data_dilation_strides.end(), - [](size_t value) { return value == 1; }); - - NGRAPH_CHECK(is_dds_valid, - "Unable to convert GroupConvolution:0 to GroupConvolution:1" - "with data dilation strides other than `1`. Node: ", - *node); - - shared_ptr replacement_node; - if (node->has_groups_in_filters()) - { - replacement_node = make_shared(node->input_value(0), - node->input_value(1), - strides, - pads_begin, - pads_end, - dilations, - auto_pad); - } - else - { - NGRAPH_CHECK(node->get_input_partial_shape(1).is_static(), - "Unable to convert GroupConvolution:0 to GroupConvolution:1" - "with dynamic filters shape. Node: ", - *node); - - auto filters_shape = node->get_input_shape(1); - auto groups = node->get_groups(); - filters_shape[0] /= groups; - filters_shape.insert(filters_shape.begin(), groups); - - auto reshaped_filters = builder::opset1::reshape(node->input_value(1), filters_shape); - - replacement_node = make_shared(node->input_value(0), - reshaped_filters, - strides, - pads_begin, - pads_end, - dilations, - auto_pad); - } - replace_node(node, replacement_node); - return replacement_node; - } - - shared_ptr op_cast(shared_ptr node) - { - const auto strides = node->get_window_movement_strides(); - const auto dilations = node->get_window_dilation_strides(); - const auto pads_begin = node->get_padding_below(); - const auto pads_end = node->get_padding_above(); - - const auto data_batch_pshape = node->get_input_partial_shape(0); - const auto filters_pshape = node->get_input_partial_shape(1); - - NGRAPH_CHECK(data_batch_pshape.is_static(), - "Unable to convert GroupConvolutionBackpropData:0 to " - "GroupConvolutionBackpropData:1 with dynamic data_batch shape. Node: ", - *node); - NGRAPH_CHECK(filters_pshape.is_static(), - "Unable to convert GroupConvolutionBackpropData:0 to " - "GroupConvolutionBackpropData:1 with dynamic filters shape. Node: ", - *node); - - auto data_batch_shape = data_batch_pshape.to_shape(); - // Remove N, C from output shape to preserve only spatial dimentions. - data_batch_shape.erase(std::begin(data_batch_shape), - std::next(std::begin(data_batch_shape), 2)); - auto filters_shape = filters_pshape.to_shape(); - auto groups = node->get_groups(); - - filters_shape[0] /= groups; - filters_shape.insert(filters_shape.begin(), groups); - auto reshaped_filters = builder::opset1::reshape(node->input_value(1), filters_shape); - - auto replacement_node = make_shared( - node->input_value(2), - reshaped_filters, - op::Constant::create(element::i64, Shape{data_batch_shape.size()}, data_batch_shape), - strides, - pads_begin, - pads_end, - dilations); - replace_node(node, replacement_node); - return replacement_node; - } - - shared_ptr op_cast(shared_ptr node) - { - auto replacement_node = make_shared( - node->input_value(0), node->input_value(1), node->get_autob()); - replace_node(node, replacement_node); - return replacement_node; - } - - using DispatchMap = map node)>>; - - template - bool op_cast_thunk(shared_ptr node) - { - auto upgraded_node = op_cast(as_type_ptr(node)); - if (upgraded_node) - { - if (ngraph::get_provenance_enabled()) - { - const std::string provenance_tag = - "get_type_name()) + ")>"; - upgraded_node->add_provenance_tags_above(node->input_values(), {provenance_tag}); - } - return true; - } - return false; - } - - DispatchMap& get_dispatch_map() - { - NGRAPH_SUPPRESS_DEPRECATED_START - static DispatchMap dispatch_map{ -#define NGRAPH_OP(NAME, NAMESPACE) {NAMESPACE::NAME::type_info, op_cast_thunk}, -#include "opset0_tbl.hpp" -#undef NGRAPH_OP - }; - return dispatch_map; - NGRAPH_SUPPRESS_DEPRECATED_END - } -} // namespace opset1_upgrade - -bool pass::Opset1Upgrade::run_on_node(shared_ptr node) -{ - bool modified = false; - auto& dispatch_map = opset1_upgrade::get_dispatch_map(); - auto it = dispatch_map.find(node->get_type_info()); - if (it != dispatch_map.end()) - { - modified = it->second(node); - } - return modified; -} diff --git a/ngraph/test/runtime/pass/opset1_upgrade.hpp b/ngraph/test/runtime/pass/opset1_upgrade.hpp deleted file mode 100644 index c1942626fe3b2d..00000000000000 --- a/ngraph/test/runtime/pass/opset1_upgrade.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "backend_visibility.hpp" -#include "ngraph/pass/pass.hpp" - -NGRAPH_SUPPRESS_DEPRECATED_START - -namespace ngraph -{ - namespace pass - { - class BACKEND_API Opset1Upgrade : public NodePass - { - public: - /// - /// \brief Constructor for the Opset1Upgrade transformation pass. - /// - /// \details This transformation pass iterates over all nodes in a graph - /// and updates version 0 ops to their version 1 equivalents. - /// All ops in the final graph have op version 1. - Opset1Upgrade() = default; - bool run_on_node(std::shared_ptr node) override; - }; - } -} - -NGRAPH_SUPPRESS_DEPRECATED_END diff --git a/ngraph/test/tensor.cpp b/ngraph/test/tensor.cpp index 6b4c3597eeb143..4deaadb3b752f6 100644 --- a/ngraph/test/tensor.cpp +++ b/ngraph/test/tensor.cpp @@ -13,7 +13,6 @@ #include "ngraph/ngraph.hpp" #include "ngraph/opsets/opset6.hpp" #include "ngraph/pass/manager.hpp" -#include "pass/liveness.hpp" #include "util/test_tools.hpp" NGRAPH_SUPPRESS_DEPRECATED_START @@ -21,66 +20,6 @@ NGRAPH_SUPPRESS_DEPRECATED_START using namespace std; using namespace ngraph; -TEST(tensor, size) -{ - pass::Manager pass_manager; - - pass_manager.register_pass(); - - { - auto arg0 = make_shared(element::f32, Shape{2, 3}); - auto add = make_shared(arg0, arg0); - auto f0 = make_shared(add, ParameterVector{arg0}); - - pass_manager.run_passes(f0); - - ASSERT_EQ(1, arg0->get_output_size()); - descriptor::Tensor& output = arg0->get_output_tensor(0); - EXPECT_EQ(2 * 3 * 4, output.size()); - } - - { - auto arg0 = make_shared(element::f32, Shape{}); - auto add = make_shared(arg0, arg0); - auto f0 = make_shared(add, ParameterVector{arg0}); - - pass_manager.run_passes(f0); - - ASSERT_EQ(1, arg0->get_output_size()); - descriptor::Tensor& output = arg0->get_output_tensor(0); - EXPECT_EQ(1 * 4, output.size()); - } - - { - auto arg0 = make_shared(element::f32, Shape{1}); - auto add = make_shared(arg0, arg0); - auto f0 = make_shared(add, ParameterVector{arg0}); - - pass_manager.run_passes(f0); - - ASSERT_EQ(1, arg0->get_output_size()); - descriptor::Tensor& output = arg0->get_output_tensor(0); - EXPECT_EQ(1 * 4, output.size()); - } -} - -TEST(tensor, output_flag) -{ - pass::Manager pass_manager; - pass_manager.register_pass(); - - auto arg0 = make_shared(element::f32, Shape{1}); - auto add = make_shared(arg0, arg0); - auto f0 = make_shared(add, ParameterVector{arg0}); - - pass_manager.run_passes(f0); - - for (size_t i = 0; i < f0->get_output_size(); ++i) - { - EXPECT_TRUE(op::is_output(f0->get_output_op(i))); - } -} - TEST(tensor, tensor_names) { auto arg0 = make_shared(element::f32, Shape{1}); diff --git a/ngraph/test/type_prop/asinh.cpp b/ngraph/test/type_prop/asinh.cpp new file mode 100644 index 00000000000000..e6592a35b810bf --- /dev/null +++ b/ngraph/test/type_prop/asinh.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" + +using Type = ::testing::Types; + +INSTANTIATE_TYPED_TEST_SUITE_P(type_prop_asinh, UnaryOperator, Type); diff --git a/ngraph/test/type_prop/atan.cpp b/ngraph/test/type_prop/atan.cpp new file mode 100644 index 00000000000000..3b21f2a686dde3 --- /dev/null +++ b/ngraph/test/type_prop/atan.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" + +using Type = ::testing::Types; + +INSTANTIATE_TYPED_TEST_SUITE_P(type_prop_atan, UnaryOperator, Type); diff --git a/ngraph/test/type_prop/batch_to_space.cpp b/ngraph/test/type_prop/batch_to_space.cpp index 885db5cd933793..54dfd3bfd9871c 100644 --- a/ngraph/test/type_prop/batch_to_space.cpp +++ b/ngraph/test/type_prop/batch_to_space.cpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "util/type_prop.hpp" @@ -9,15 +11,420 @@ using namespace std; using namespace ngraph; +namespace { + constexpr size_t data_input_idx = 0; + constexpr size_t block_shape_input_idx = 1; + constexpr size_t crops_begin_input_idx = 2; + constexpr size_t crops_end_input_idx = 3; + constexpr size_t batch_to_space_required_inputs = 4; + struct InputInfo + { + element::Type in_et; + PartialShape in_pshape; + }; + + using BatchToSpaceInputParams = std::array; + + std::shared_ptr makeBatchToSpaceOp(const BatchToSpaceInputParams& p) + { + if(p.size() != batch_to_space_required_inputs) + { + throw runtime_error("BatchToSpace requires 4 inputs"); + } + auto data = make_shared( + p.at(data_input_idx).in_et, p.at(data_input_idx).in_pshape); + auto block_shape = make_shared( + p.at(block_shape_input_idx).in_et, p.at(block_shape_input_idx).in_pshape); + auto crops_begin = make_shared( + p.at(crops_begin_input_idx).in_et, p.at(crops_begin_input_idx).in_pshape); + auto crops_end = make_shared( + p.at(crops_end_input_idx).in_et, p.at(crops_end_input_idx).in_pshape); + return make_shared(data, block_shape, crops_begin, crops_end); + } +} // namespace + +TEST(type_prop, batch_to_space_incompatible_input_element_types) +{ + element::Type float_et = element::f32; + element::Type integer64_et = element::i64; + element::Type integer32_et = element::i32; + + Shape data_sshape{10, 26}; + Shape inputs_sshape{2}; + + vector test_cases; + test_cases.push_back( + BatchToSpaceInputParams{ + InputInfo{float_et, data_sshape}, + InputInfo{integer64_et, inputs_sshape}, + InputInfo{integer32_et, inputs_sshape}, + InputInfo{integer32_et, inputs_sshape}}); + + test_cases.push_back( + BatchToSpaceInputParams{ + InputInfo{float_et, data_sshape}, + InputInfo{integer32_et, inputs_sshape}, + InputInfo{integer64_et, inputs_sshape}, + InputInfo{integer32_et, inputs_sshape}}); + + test_cases.push_back( + BatchToSpaceInputParams{ + InputInfo{float_et, data_sshape}, + InputInfo{integer64_et, inputs_sshape}, + InputInfo{float_et, inputs_sshape}, + InputInfo{float_et, inputs_sshape}}); + + for (const auto& test_case : test_cases) + { + try + { + auto batch_to_space = makeBatchToSpaceOp(test_case); + FAIL() << "Incompatible element types for block_shape/crops_begin/crops_end inputs not detected"; + } + catch(const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), + "block_shape, crops_begin and crops_end inputs must have same element type."); + } + catch (...) + { + FAIL() << "Element type check for block_shape/crops_begin/crops_end inputs failed for unexpected reason"; + } + } +} + +TEST(type_prop, batch_to_space_invalid_input_element_types) +{ + element::Type float_et = element::f32; + + Shape data_sshape{10, 26}; + Shape inputs_sshape{2}; + + const BatchToSpaceInputParams params{ + InputInfo{float_et, data_sshape}, + InputInfo{float_et, inputs_sshape}, + InputInfo{float_et, inputs_sshape}, + InputInfo{float_et, inputs_sshape}}; + + try + { + auto batch_to_space = makeBatchToSpaceOp(params); + FAIL() << "Invalid non-integer element type for block_shape/crops_begin/crops_end inputs not detected"; + } + catch(const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), + "block_shape and crops inputs must have integer element type."); + } + catch (...) + { + FAIL() << "Element type check for block_shape/crops_begin/crops_end inputs failed for unexpected reason"; + } +} + +TEST(type_prop, batch_to_space_invalid_data_input_rank) +{ + Shape data_sshape{4}; + element::Type data_et = element::f32; + + Shape inputs_sshape{2}; + element::Type inputs_et = element::i64; + + const BatchToSpaceInputParams params{ + InputInfo{data_et, data_sshape}, + InputInfo{inputs_et, inputs_sshape}, + InputInfo{inputs_et, inputs_sshape}, + InputInfo{inputs_et, inputs_sshape}}; + + try + { + auto batch_to_space = makeBatchToSpaceOp(params); + FAIL() << "Invalid rank of data input not detected"; + } + catch(const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), "data input must have rank greater or equal than 2."); + } + catch (...) + { + FAIL() << "Rank check for data input failed for unexpected reason"; + } +} + +TEST(type_prop, batch_to_space_incompatible_secondary_inputs_shapes) +{ + Shape data_sshape{10, 26}; + element::Type data_et = element::f32; + + Shape inputs_sshape_1D{2}; + Shape inputs_sshape_2D{2, 1}; + element::Type inputs_et = element::i64; + + vector test_cases; + test_cases.push_back( + BatchToSpaceInputParams{ + InputInfo{data_et, data_sshape}, + InputInfo{inputs_et, inputs_sshape_2D}, + InputInfo{inputs_et, inputs_sshape_1D}, + InputInfo{inputs_et, inputs_sshape_1D}}); + + test_cases.push_back( + BatchToSpaceInputParams{ + InputInfo{data_et, data_sshape}, + InputInfo{inputs_et, inputs_sshape_1D}, + InputInfo{inputs_et, inputs_sshape_2D}, + InputInfo{inputs_et, inputs_sshape_1D}}); + + test_cases.push_back( + BatchToSpaceInputParams{ + InputInfo{data_et, data_sshape}, + InputInfo{inputs_et, inputs_sshape_1D}, + InputInfo{inputs_et, inputs_sshape_2D}, + InputInfo{inputs_et, inputs_sshape_2D}}); + + for (const auto& test_case : test_cases) + { + try + { + auto batch_to_space = makeBatchToSpaceOp(test_case); + FAIL() << "Incompatible shapes for block_shape/crops_begin/crops_end inputs not detected"; + } + catch(const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), + "block_shape, crops_begin and crops_end inputs must have the same shape."); + } + catch (...) + { + FAIL() << "Shapes check for block_shape/crops_begin/crops_end inputs failed for unexpected reason"; + } + } +} + +TEST(type_prop, batch_to_space_invalid_secondary_inputs_rank) +{ + Shape data_sshape{10, 26}; + element::Type data_et = element::f32; + + Shape inputs_sshape_2D{2, 1}; + element::Type inputs_et = element::i64; + + const BatchToSpaceInputParams params{ + InputInfo{data_et, data_sshape}, + InputInfo{inputs_et, inputs_sshape_2D}, + InputInfo{inputs_et, inputs_sshape_2D}, + InputInfo{inputs_et, inputs_sshape_2D}}; + + try + { + auto batch_to_space = makeBatchToSpaceOp(params); + FAIL() << "Invalid rank for block_shape/crops_begin/crops_end inputs not detected"; + } + catch(const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), + "block_shape and crops inputs must have rank 1."); + } + catch (...) + { + FAIL() << "Rank check for block_shape/crops_begin/crops_end inputs failed for unexpected reason"; + } +} + +TEST(type_prop, batch_to_space_incompatible_data_and_secondary_inputs_shapes) +{ + Shape data_sshape{10, 26}; + element::Type data_et = element::f32; + + Shape inputs_sshape{5}; + element::Type inputs_et = element::i64; + + const BatchToSpaceInputParams params{ + InputInfo{data_et, data_sshape}, + InputInfo{inputs_et, inputs_sshape}, + InputInfo{inputs_et, inputs_sshape}, + InputInfo{inputs_et, inputs_sshape}}; + + try + { + auto batch_to_space = makeBatchToSpaceOp(params); + FAIL() << "Incompatible shapes for data and block_shape/crops_begin/crops_end inputs not detected"; + } + catch(const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), + "block_shape and crop inputs must have same number of elements " + "as data input rank."); + } + catch (...) + { + FAIL() << "Compatibility shape check for data and block_shape/crops_begin/crops_end inputs failed for unexpected reason"; + } +} + +TEST(type_prop, batch_to_space_invalid_block_shape_input) +{ + Shape data_sshape{100, 7, 13, 3}; + element::Type data_et = element::f32; + + Shape inputs_sshape{4}; + element::Type inputs_et = element::i64; + + auto data = make_shared(data_et, data_sshape); + auto block_shape = make_shared(inputs_et, inputs_sshape, vector{0, 10, 5, 1}); + auto crops_begin = make_shared(inputs_et, inputs_sshape, vector{0, 3, 1, 0}); + auto crops_end = make_shared(inputs_et, inputs_sshape, vector{0, 3, 0, 0}); + + try + { + auto batch_to_space = + make_shared(data, block_shape, crops_begin, crops_end); + FAIL() << "Invalid elements of block_shape input not detected"; + } + catch (const NodeValidationFailure& error) + { + + EXPECT_HAS_SUBSTRING(error.what(), + "Elements of block_shape input must be greater or equal to one."); + } + catch (...) + { + FAIL() << "Greater than zero elements of block_shape input check failed for unexpected reason"; + } +} + +TEST(type_prop, batch_to_space_invalid_crops_input_values) +{ + Shape data_sshape{100, 7, 13, 3}; + element::Type data_et = element::f32; + + Shape inputs_sshape{4}; + element::Type inputs_et = element::i64; + + try + { + auto data = make_shared(data_et, data_sshape); + auto block_shape = + make_shared(inputs_et, inputs_sshape, vector{1, 10, 5, 1}); + auto crops_begin = + make_shared(inputs_et, inputs_sshape, vector{0, 3, 1, -1}); + auto crops_end = + make_shared(inputs_et, inputs_sshape, vector{0, 3, 0, 0}); + auto batch_to_space = + make_shared(data, block_shape, crops_begin, crops_end); + FAIL() << "Invalid crops_begin input values not detected"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), + "Elements of crops_begin and crops_end inputs must be greater or equal to zero."); + } + catch (...) + { + FAIL() << "Non-negative element check of crops_begin input values failed for unexpected reason"; + } + + try + { + auto data = make_shared(data_et, data_sshape); + auto block_shape = + make_shared(inputs_et, inputs_sshape, vector{1, 10, 5, 1}); + auto crops_begin = + make_shared(inputs_et, inputs_sshape, vector{0, 3, 1, 0}); + auto crops_end = + make_shared(inputs_et, inputs_sshape, vector{0, 3, -1, 0}); + auto batch_to_space = + make_shared(data, block_shape, crops_begin, crops_end); + FAIL() << "Invalid crops_end input values not detected"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), + "Elements of crops_begin and crops_end inputs must be greater or equal to zero."); + } + catch (...) + { + FAIL() << "Non-negative element check of crops_end input values failed for unexpected reason"; + } +} + +TEST(type_prop, batch_to_space_incompatible_block_shape_input_values_with_data_shape) +{ + Shape data_sshape{80, 7, 13, 3}; + element::Type data_et = element::f32; + + Shape inputs_sshape{4}; + element::Type inputs_et = element::i64; + + auto data = make_shared(data_et, data_sshape); + auto block_shape = + make_shared(inputs_et, inputs_sshape, vector{1, 10, 5, 1}); + auto crops_begin = + make_shared(inputs_et, inputs_sshape, vector{0, 3, 1, 0}); + auto crops_end = + make_shared(inputs_et, inputs_sshape, vector{0, 3, 0, 0}); + + try + { + auto batch_to_space = + make_shared(data, block_shape, crops_begin, crops_end); + FAIL() << "Incompatible data shape and block_shape input values not detected"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), + "The input data's 'batch' axis size: 80 must be a multiple of product of block_shape values: 50"); + } + catch (...) + { + FAIL() << "Data shape and block_shape input values check failed for unexpected reason"; + } +} + +TEST(type_prop, batch_to_space_invalid_crops_out_of_bounds) +{ + Shape data_sshape{32, 4, 1, 3}; + element::Type data_et = element::f32; + + Shape inputs_sshape{4}; + element::Type inputs_et = element::i64; + + auto data = make_shared(data_et, data_sshape); + auto block_shape = + make_shared(inputs_et, inputs_sshape, vector{1, 2, 2, 1}); + auto crops_begin = + make_shared(inputs_et, inputs_sshape, vector{0, 3, 1, 2}); + auto crops_end = + make_shared(inputs_et, inputs_sshape, vector{0, 3, 0, 2}); + + try + { + auto batch_to_space = + make_shared(data, block_shape, crops_begin, crops_end); + FAIL() << "Invalid out of bound crops values not detected"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), + "crops_begin[i] + crops_end[i] must be less or equal to block_shape[i] * input_shape[i]"); + } + catch (...) + { + FAIL() << "Crops values check failed for unexpected reason"; + } +} + TEST(type_prop, batch_to_space_output_shape_2D) { auto data = make_shared(element::f32, Shape{10, 26}); - auto block_shape = make_shared(element::i64, Shape{2}, vector{1, 5}); - auto pads_begin = make_shared(element::i64, Shape{2}, vector{0, 2}); - auto pads_end = make_shared(element::i64, Shape{2}, vector{0, 0}); - + auto block_shape = + make_shared(element::i64, Shape{2}, vector{1, 5}); + auto crops_begin = + make_shared(element::i64, Shape{2}, vector{0, 2}); + auto crops_end = + make_shared(element::i64, Shape{2}, vector{0, 0}); auto batch_to_space = - make_shared(data, block_shape, pads_begin, pads_end); + make_shared(data, block_shape, crops_begin, crops_end); ASSERT_EQ(batch_to_space->get_element_type(), element::f32); ASSERT_EQ(batch_to_space->get_shape(), (Shape{10 / 5, 26 * 5 - 2})); @@ -28,12 +435,12 @@ TEST(type_prop, batch_to_space_output_shape_4D) auto data = make_shared(element::f32, Shape{100, 7, 13, 3}); auto block_shape = make_shared(element::i64, Shape{4}, vector{1, 10, 5, 1}); - auto pads_begin = + auto crops_begin = make_shared(element::i64, Shape{4}, vector{0, 3, 1, 0}); - auto pads_end = make_shared(element::i64, Shape{4}, vector{0, 3, 0, 0}); - + auto crops_end = + make_shared(element::i64, Shape{4}, vector{0, 3, 0, 0}); auto batch_to_space = - make_shared(data, block_shape, pads_begin, pads_end); + make_shared(data, block_shape, crops_begin, crops_end); ASSERT_EQ(batch_to_space->get_element_type(), element::f32); ASSERT_EQ(batch_to_space->get_shape(), (Shape{100 / (10 * 5), 7 * 10 - 3 - 3, 13 * 5 - 1, 3})); @@ -44,13 +451,12 @@ TEST(type_prop, batch_to_space_output_shape_5D) auto data = make_shared(element::f32, Shape{960, 6, 13, 128, 16}); auto block_shape = make_shared(element::i32, Shape{5}, vector{1, 6, 5, 1, 16}); - auto pads_begin = + auto crops_begin = make_shared(element::i32, Shape{5}, vector{0, 2, 0, 0, 0}); - auto pads_end = + auto crops_end = make_shared(element::i32, Shape{5}, vector{0, 2, 1, 0, 0}); - auto batch_to_space = - make_shared(data, block_shape, pads_begin, pads_end); + make_shared(data, block_shape, crops_begin, crops_end); ASSERT_EQ(batch_to_space->get_element_type(), element::f32); ASSERT_EQ(batch_to_space->get_shape(), @@ -62,19 +468,19 @@ TEST(type_prop, batch_to_space_and_space_to_batch) auto data = make_shared(element::f32, Shape{4800, 9, 11, 2}); auto block_shape = make_shared(element::i64, Shape{4}, vector{1, 12, 100, 2}); - auto pads_begin = + auto crops_begin = make_shared(element::i64, Shape{4}, vector{0, 3, 38, 1}); - auto pads_end = make_shared(element::i64, Shape{4}, vector{0, 5, 38, 0}); - + auto crops_end = + make_shared(element::i64, Shape{4}, vector{0, 5, 38, 0}); auto batch_to_space = - make_shared(data, block_shape, pads_begin, pads_end); + make_shared(data, block_shape, crops_begin, crops_end); ASSERT_EQ(batch_to_space->get_element_type(), element::f32); ASSERT_EQ(batch_to_space->get_shape(), (Shape{4800 / (12 * 100 * 2), 9 * 12 - 3 - 5, 11 * 100 - 38 - 38, 2 * 2 - 1})); auto space_to_batch = - make_shared(batch_to_space, block_shape, pads_begin, pads_end); + make_shared(batch_to_space, block_shape, crops_begin, crops_end); ASSERT_EQ(space_to_batch->get_element_type(), element::f32); ASSERT_EQ(space_to_batch->get_shape(), (Shape{4800, 9, 11, 2})); } @@ -84,12 +490,12 @@ TEST(type_prop, batch_to_space_dynamic_shape_static_rank) auto data = make_shared(element::f32, PartialShape::dynamic(4)); auto block_shape = make_shared(element::i64, Shape{4}, vector{1, 10, 5, 1}); - auto pads_begin = + auto crops_begin = make_shared(element::i64, Shape{4}, vector{0, 3, 1, 0}); - auto pads_end = make_shared(element::i64, Shape{4}, vector{0, 3, 0, 0}); - + auto crops_end = + make_shared(element::i64, Shape{4}, vector{0, 3, 0, 0}); auto batch_to_space = - make_shared(data, block_shape, pads_begin, pads_end); + make_shared(data, block_shape, crops_begin, crops_end); ASSERT_EQ(batch_to_space->get_element_type(), element::f32); ASSERT_EQ(batch_to_space->get_output_partial_shape(0), PartialShape::dynamic(4)); @@ -100,12 +506,12 @@ TEST(type_prop, batch_to_space_dynamic_shape_dynamic_rank) auto data = make_shared(element::f32, PartialShape::dynamic()); auto block_shape = make_shared(element::i64, Shape{4}, vector{1, 10, 5, 1}); - auto pads_begin = + auto crops_begin = make_shared(element::i64, Shape{4}, vector{0, 3, 1, 0}); - auto pads_end = make_shared(element::i64, Shape{4}, vector{0, 3, 0, 0}); - + auto crops_end = + make_shared(element::i64, Shape{4}, vector{0, 3, 0, 0}); auto batch_to_space = - make_shared(data, block_shape, pads_begin, pads_end); + make_shared(data, block_shape, crops_begin, crops_end); ASSERT_EQ(batch_to_space->get_element_type(), element::f32); ASSERT_EQ(batch_to_space->get_output_partial_shape(0), PartialShape::dynamic()); diff --git a/ngraph/test/type_prop/convolution.cpp b/ngraph/test/type_prop/convolution.cpp index fdd757da1a60d3..1e13c890a1e328 100644 --- a/ngraph/test/type_prop/convolution.cpp +++ b/ngraph/test/type_prop/convolution.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "op/convolution.hpp" #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" #include "util/type_prop.hpp" @@ -10,2234 +9,6 @@ using namespace std; using namespace ngraph; -TEST(type_prop, conv_1d_deduce) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{64, 3, 100}); - auto param1 = make_shared(element::f32, Shape{128, 3, 10}); - auto conv = make_shared(param0, param1); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), (Shape{64, 128, 91})); - - EXPECT_EQ(conv->get_window_movement_strides(), Strides{1}); - EXPECT_EQ(conv->get_window_dilation_strides(), Strides{1}); - EXPECT_EQ(conv->get_data_dilation_strides(), Strides{1}); - - EXPECT_EQ(conv->get_padding_below(), CoordinateDiff{0}); - EXPECT_EQ(conv->get_padding_above(), CoordinateDiff{0}); -} - -TEST(type_prop, conv_1d_deduce_padded) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{64, 3, 100}); - auto param1 = make_shared(element::f32, Shape{128, 3, 10}); - auto move_strides = Strides{1}; - auto dilation_strides = Strides{1}; - auto padding_below = CoordinateDiff{2}; - auto padding_above = CoordinateDiff{3}; - auto conv = make_shared( - param0, param1, move_strides, dilation_strides, padding_below, padding_above); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), (Shape{64, 128, 96})); - - EXPECT_EQ(conv->get_window_movement_strides(), Strides{1}); - EXPECT_EQ(conv->get_window_dilation_strides(), Strides{1}); - EXPECT_EQ(conv->get_data_dilation_strides(), Strides{1}); - - EXPECT_EQ(conv->get_padding_below(), CoordinateDiff{2}); - EXPECT_EQ(conv->get_padding_above(), CoordinateDiff{3}); -} - -TEST(type_prop, conv_1d_deduce_strided) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{64, 3, 100}); - auto param1 = make_shared(element::f32, Shape{128, 3, 10}); - auto move_strides = Strides{2}; - auto conv = make_shared(param0, param1, move_strides); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), (Shape{64, 128, 46})); - - EXPECT_EQ(conv->get_window_movement_strides(), Strides{2}); - EXPECT_EQ(conv->get_window_dilation_strides(), Strides{1}); - EXPECT_EQ(conv->get_data_dilation_strides(), Strides{1}); - - EXPECT_EQ(conv->get_padding_below(), CoordinateDiff{0}); - EXPECT_EQ(conv->get_padding_above(), CoordinateDiff{0}); -} - -TEST(type_prop, conv_1d_deduce_strided_padded) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{64, 3, 100}); - auto param1 = make_shared(element::f32, Shape{128, 3, 10}); - auto move_strides = Strides{2}; - auto dilation_strides = Strides{1}; - auto padding_below = CoordinateDiff{2}; - auto padding_above = CoordinateDiff{3}; - auto conv = make_shared( - param0, param1, move_strides, dilation_strides, padding_below, padding_above); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), (Shape{64, 128, 48})); - - EXPECT_EQ(conv->get_window_movement_strides(), Strides{2}); - EXPECT_EQ(conv->get_window_dilation_strides(), Strides{1}); - EXPECT_EQ(conv->get_data_dilation_strides(), Strides{1}); - - EXPECT_EQ(conv->get_padding_below(), CoordinateDiff{2}); - EXPECT_EQ(conv->get_padding_above(), CoordinateDiff{3}); -} - -TEST(type_prop, conv_1d_deduce_strided_small_uneven) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{64, 3, 5}); - auto param1 = make_shared(element::f32, Shape{128, 3, 2}); - auto move_strides = Strides{2}; - auto conv = make_shared(param0, param1, move_strides); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), (Shape{64, 128, 2})); - - EXPECT_EQ(conv->get_window_movement_strides(), Strides{2}); - EXPECT_EQ(conv->get_window_dilation_strides(), Strides{1}); - EXPECT_EQ(conv->get_data_dilation_strides(), Strides{1}); - - EXPECT_EQ(conv->get_padding_below(), CoordinateDiff{0}); - EXPECT_EQ(conv->get_padding_above(), CoordinateDiff{0}); -} - -TEST(type_prop, conv_1d_deduce_strided_small_even) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{64, 3, 6}); - auto param1 = make_shared(element::f32, Shape{128, 3, 2}); - auto move_strides = Strides{2}; - auto conv = make_shared(param0, param1, move_strides); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), (Shape{64, 128, 3})); - - EXPECT_EQ(conv->get_window_movement_strides(), Strides{2}); - EXPECT_EQ(conv->get_window_dilation_strides(), Strides{1}); - EXPECT_EQ(conv->get_data_dilation_strides(), Strides{1}); - - EXPECT_EQ(conv->get_padding_below(), CoordinateDiff{0}); - EXPECT_EQ(conv->get_padding_above(), CoordinateDiff{0}); -} - -TEST(type_prop, conv_1d_deduce_window_dilated) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{64, 3, 100}); - auto param1 = make_shared(element::f32, Shape{128, 3, 10}); - auto move_strides = Strides{1}; - auto dilate_strides = Strides{2}; - auto conv = make_shared(param0, param1, move_strides, dilate_strides); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), (Shape{64, 128, 82})); - - EXPECT_EQ(conv->get_window_movement_strides(), Strides{1}); - EXPECT_EQ(conv->get_window_dilation_strides(), Strides{2}); - EXPECT_EQ(conv->get_data_dilation_strides(), Strides{1}); - - EXPECT_EQ(conv->get_padding_below(), CoordinateDiff{0}); - EXPECT_EQ(conv->get_padding_above(), CoordinateDiff{0}); -} - -TEST(type_prop, conv_1d_deduce_window_dilated_padded) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{64, 3, 100}); - auto param1 = make_shared(element::f32, Shape{128, 3, 10}); - auto move_strides = Strides{1}; - auto dilate_strides = Strides{2}; - auto padding_below = CoordinateDiff{2}; - auto padding_above = CoordinateDiff{3}; - auto conv = make_shared( - param0, param1, move_strides, dilate_strides, padding_below, padding_above); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), (Shape{64, 128, 87})); - - EXPECT_EQ(conv->get_window_movement_strides(), Strides{1}); - EXPECT_EQ(conv->get_window_dilation_strides(), Strides{2}); - EXPECT_EQ(conv->get_data_dilation_strides(), Strides{1}); - - EXPECT_EQ(conv->get_padding_below(), CoordinateDiff{2}); - EXPECT_EQ(conv->get_padding_above(), CoordinateDiff{3}); -} - -TEST(type_prop, conv_1d_deduce_window_dilated_data_dilated_padded) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{64, 3, 100}); - auto param1 = make_shared(element::f32, Shape{128, 3, 10}); - auto move_strides = Strides{1}; - auto dilate_strides = Strides{2}; - auto padding_below = CoordinateDiff{2}; - auto padding_above = CoordinateDiff{3}; - auto data_dilate_strides = Strides{3}; - auto conv = make_shared(param0, - param1, - move_strides, - dilate_strides, - padding_below, - padding_above, - data_dilate_strides); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), (Shape{64, 128, 285})); - - EXPECT_EQ(conv->get_window_movement_strides(), Strides{1}); - EXPECT_EQ(conv->get_window_dilation_strides(), Strides{2}); - EXPECT_EQ(conv->get_data_dilation_strides(), Strides{3}); - - EXPECT_EQ(conv->get_padding_below(), CoordinateDiff{2}); - EXPECT_EQ(conv->get_padding_above(), CoordinateDiff{3}); -} - -TEST(type_prop, conv_2d_deduce) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{64, 3, 100, 150}); - auto param1 = make_shared(element::f32, Shape{128, 3, 10, 20}); - auto conv = make_shared(param0, param1); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), (Shape{64, 128, 91, 131})); - - EXPECT_EQ(conv->get_window_movement_strides(), (Strides{1, 1})); - EXPECT_EQ(conv->get_window_dilation_strides(), (Strides{1, 1})); - EXPECT_EQ(conv->get_data_dilation_strides(), (Strides{1, 1})); - - EXPECT_EQ(conv->get_padding_below(), (CoordinateDiff{0, 0})); - EXPECT_EQ(conv->get_padding_above(), (CoordinateDiff{0, 0})); -} - -TEST(type_prop, conv_2d_deduce_padded) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{64, 3, 100, 150}); - auto param1 = make_shared(element::f32, Shape{128, 3, 10, 20}); - auto move_strides = Strides{1, 1}; - auto dilate_strides = Strides{1, 1}; - auto padding_below = CoordinateDiff{2, 3}; - auto padding_above = CoordinateDiff{3, 4}; - auto conv = make_shared( - param0, param1, move_strides, dilate_strides, padding_below, padding_above); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), (Shape{64, 128, 96, 138})); - - EXPECT_EQ(conv->get_window_movement_strides(), (Strides{1, 1})); - EXPECT_EQ(conv->get_window_dilation_strides(), (Strides{1, 1})); - EXPECT_EQ(conv->get_data_dilation_strides(), (Strides{1, 1})); - - EXPECT_EQ(conv->get_padding_below(), (CoordinateDiff{2, 3})); - EXPECT_EQ(conv->get_padding_above(), (CoordinateDiff{3, 4})); -} - -TEST(type_prop, conv_2d_deduce_padded_neg) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{64, 3, 100, 150}); - auto param1 = make_shared(element::f32, Shape{128, 3, 10, 20}); - auto move_strides = Strides{1, 1}; - auto dilate_strides = Strides{1, 1}; - auto padding_below = CoordinateDiff{2, -3}; - auto padding_above = CoordinateDiff{3, -4}; - auto conv = make_shared( - param0, param1, move_strides, dilate_strides, padding_below, padding_above); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), (Shape{64, 128, 96, 124})); - - EXPECT_EQ(conv->get_window_movement_strides(), (Strides{1, 1})); - EXPECT_EQ(conv->get_window_dilation_strides(), (Strides{1, 1})); - EXPECT_EQ(conv->get_data_dilation_strides(), (Strides{1, 1})); - - EXPECT_EQ(conv->get_padding_below(), (CoordinateDiff{2, -3})); - EXPECT_EQ(conv->get_padding_above(), (CoordinateDiff{3, -4})); -} - -struct DeduceAutoPadTest - : ::testing::TestWithParam< - std::tuple> -{ -}; - -TEST_P(DeduceAutoPadTest, same_lower) -{ - auto image_shape = std::get<0>(GetParam()); - image_shape.insert(image_shape.begin(), {1, 1}); // Add {N, C} - auto filter_shape = std::get<1>(GetParam()); - filter_shape.insert(filter_shape.begin(), {1, 1}); // Add {O, I} - auto param0 = make_shared(element::f32, image_shape); - auto param1 = make_shared(element::f32, filter_shape); - - auto conv = make_shared(param0, - param1, - std::get<2>(GetParam()), - std::get<3>(GetParam()), - CoordinateDiff(), - CoordinateDiff(), - Strides(), - op::PadType::SAME_LOWER); - EXPECT_EQ(conv->get_padding_above(), std::get<4>(GetParam())); - EXPECT_EQ(conv->get_padding_below(), std::get<5>(GetParam())); -} - -INSTANTIATE_TEST_SUITE_P(type_prop, - DeduceAutoPadTest, - ::testing::Values(std::make_tuple(Shape{5, 6}, - Shape{3, 4}, - Strides{2, 1}, - Strides{1, 1}, - CoordinateDiff{1, 1}, - CoordinateDiff{1, 2}), - std::make_tuple(Shape{3, 3}, - Shape{2, 2}, - Strides{1, 1}, - Strides{1, 1}, - CoordinateDiff{0, 0}, - CoordinateDiff{1, 1}), - std::make_tuple(Shape{28, 28}, - Shape{3, 3}, - Strides{2, 2}, - Strides{1, 1}, - CoordinateDiff{0, 0}, - CoordinateDiff{1, 1}), - std::make_tuple(Shape{100, 150}, - Shape{10, 20}, - Strides{1, 1}, - Strides{1, 1}, - CoordinateDiff{4, 9}, - CoordinateDiff{5, 10}), - std::make_tuple(Shape{2}, - Shape{1}, - Strides{3}, - Strides{1}, - CoordinateDiff{0}, - CoordinateDiff{0}), - std::make_tuple(Shape{10, 1}, - Shape{4, 1}, - Strides{1, 1}, - Strides{2, 1}, - CoordinateDiff{3, 0}, - CoordinateDiff{3, 0}), - std::make_tuple(Shape{10, 5, 6}, - Shape{3, 3, 4}, - Strides{1, 2, 1}, - Strides{2, 1, 1}, - CoordinateDiff{2, 1, 1}, - CoordinateDiff{2, 1, 2}))); - -TEST(type_prop, conv_2d_deduce_strided) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{64, 3, 100, 150}); - auto param1 = make_shared(element::f32, Shape{128, 3, 10, 20}); - auto move_strides = Strides{2, 3}; - auto conv = make_shared(param0, param1, move_strides); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), (Shape{64, 128, 46, 44})); - - EXPECT_EQ(conv->get_window_movement_strides(), (Strides{2, 3})); - EXPECT_EQ(conv->get_window_dilation_strides(), (Strides{1, 1})); - EXPECT_EQ(conv->get_data_dilation_strides(), (Strides{1, 1})); - - EXPECT_EQ(conv->get_padding_below(), (CoordinateDiff{0, 0})); - EXPECT_EQ(conv->get_padding_above(), (CoordinateDiff{0, 0})); -} - -TEST(type_prop, conv_2d_deduce_strided_window_dilated) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{64, 3, 100, 150}); - auto param1 = make_shared(element::f32, Shape{128, 3, 10, 20}); - auto move_strides = Strides{2, 3}; - auto dilate_strides = Strides{3, 2}; - auto conv = make_shared(param0, param1, move_strides, dilate_strides); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), (Shape{64, 128, 37, 38})); - - EXPECT_EQ(conv->get_window_movement_strides(), (Strides{2, 3})); - EXPECT_EQ(conv->get_window_dilation_strides(), (Strides{3, 2})); - EXPECT_EQ(conv->get_data_dilation_strides(), (Strides{1, 1})); - - EXPECT_EQ(conv->get_padding_below(), (CoordinateDiff{0, 0})); - EXPECT_EQ(conv->get_padding_above(), (CoordinateDiff{0, 0})); -} - -TEST(type_prop, conv_2d_deduce_strided_window_dilated_data_dilated) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{64, 3, 100, 150}); - auto param1 = make_shared(element::f32, Shape{128, 3, 10, 20}); - auto move_strides = Strides{2, 3}; - auto dilate_strides = Strides{3, 2}; - auto padding_below = CoordinateDiff{0, 0}; - auto padding_above = CoordinateDiff{0, 0}; - auto data_dilate_strides = Strides{2, 3}; - auto conv = make_shared(param0, - param1, - move_strides, - dilate_strides, - padding_below, - padding_above, - data_dilate_strides); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), (Shape{64, 128, 86, 137})); - - EXPECT_EQ(conv->get_window_movement_strides(), (Strides{2, 3})); - EXPECT_EQ(conv->get_window_dilation_strides(), (Strides{3, 2})); - EXPECT_EQ(conv->get_data_dilation_strides(), (Strides{2, 3})); - - EXPECT_EQ(conv->get_padding_below(), (CoordinateDiff{0, 0})); - EXPECT_EQ(conv->get_padding_above(), (CoordinateDiff{0, 0})); -} - -TEST(type_prop, conv_2d_deduce_strided_window_dilated_small) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{64, 3, 7, 8}); - auto param1 = make_shared(element::f32, Shape{128, 3, 2, 3}); - auto move_strides = Strides{2, 3}; - auto dilate_strides = Strides{3, 2}; - auto conv = make_shared(param0, param1, move_strides, dilate_strides); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), (Shape{64, 128, 2, 2})); - - EXPECT_EQ(conv->get_window_movement_strides(), (Strides{2, 3})); - EXPECT_EQ(conv->get_window_dilation_strides(), (Strides{3, 2})); - EXPECT_EQ(conv->get_data_dilation_strides(), (Strides{1, 1})); - - EXPECT_EQ(conv->get_padding_below(), (CoordinateDiff{0, 0})); - EXPECT_EQ(conv->get_padding_above(), (CoordinateDiff{0, 0})); -} - -TEST(type_prop, conv_3d_deduce_strided_window_dilated_small) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{64, 3, 7, 8, 10}); - auto param1 = make_shared(element::f32, Shape{128, 3, 2, 3, 2}); - auto move_strides = Strides{2, 3, 4}; - auto dilate_strides = Strides{3, 2, 2}; - auto conv = make_shared(param0, param1, move_strides, dilate_strides); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), (Shape{64, 128, 2, 2, 2})); - - EXPECT_EQ(conv->get_window_movement_strides(), (Strides{2, 3, 4})); - EXPECT_EQ(conv->get_window_dilation_strides(), (Strides{3, 2, 2})); - EXPECT_EQ(conv->get_data_dilation_strides(), (Strides{1, 1, 1})); - - EXPECT_EQ(conv->get_padding_below(), (CoordinateDiff{0, 0, 0})); - EXPECT_EQ(conv->get_padding_above(), (CoordinateDiff{0, 0, 0})); -} - -TEST(type_prop, conv_3d_deduce_strided_window_dilated_data_dilated_small) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{64, 3, 7, 8, 10}); - auto param1 = make_shared(element::f32, Shape{128, 3, 2, 3, 2}); - auto move_strides = Strides{2, 3, 4}; - auto dilate_strides = Strides{3, 2, 2}; - auto padding_below = CoordinateDiff{0, 0, 0}; - auto padding_above = CoordinateDiff{0, 0, 0}; - auto data_dilate_strides = Strides{2, 3, 2}; - auto conv = make_shared(param0, - param1, - move_strides, - dilate_strides, - padding_below, - padding_above, - data_dilate_strides); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), (Shape{64, 128, 5, 6, 5})); - - EXPECT_EQ(conv->get_window_movement_strides(), (Strides{2, 3, 4})); - EXPECT_EQ(conv->get_window_dilation_strides(), (Strides{3, 2, 2})); - EXPECT_EQ(conv->get_data_dilation_strides(), (Strides{2, 3, 2})); - - EXPECT_EQ(conv->get_padding_below(), (CoordinateDiff{0, 0, 0})); - EXPECT_EQ(conv->get_padding_above(), (CoordinateDiff{0, 0, 0})); -} - -TEST(type_prop, conv_invalid_element_type_mismatch) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{3, 3, 3, 3}); - auto param1 = make_shared(element::i32, Shape{3, 3, 2, 2}); - try - { - auto conv = make_shared(param0, param1); - - // Should have thrown, so fail if it didn't - FAIL() << "Invalid input with element type mismatch not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING(error.what(), - std::string("Element types for data batch and filters do not match")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_invalid_0d_input) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{}); - auto param1 = make_shared(element::f32, Shape{}); - try - { - auto conv = make_shared(param0, param1); - - // Should have thrown, so fail if it didn't - FAIL() << "Invalid 0D input not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING(error.what(), - std::string("Data batch and filters must have rank of at least 3 " - "(one batch axis, one input-channel axis, " - "and at least one spatial dimension)")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_invalid_1d_input) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{2}); - auto param1 = make_shared(element::f32, Shape{2}); - try - { - auto conv = make_shared(param0, param1); - - // Should have thrown, so fail if it didn't - FAIL() << "Invalid 1D input not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING(error.what(), - std::string("Data batch and filters must have rank of at least 3 " - "(one batch axis, one input-channel axis, " - "and at least one spatial dimension)")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_invalid_2d_input) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{2, 6}); - auto param1 = make_shared(element::f32, Shape{2, 6}); - try - { - auto conv = make_shared(param0, param1); - - // Should have thrown, so fail if it didn't - FAIL() << "Invalid 2D input not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING(error.what(), - std::string("Data batch and filters must have rank of at least 3 " - "(one batch axis, one input-channel axis, " - "and at least one spatial dimension)")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_invalid_0_batch_size) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{0, 6, 1}); - auto param1 = make_shared(element::f32, Shape{0, 6, 1}); - try - { - auto conv = make_shared(param0, param1); - - // Should have thrown, so fail if it didn't - FAIL() << "Invalid input with 0 batch size not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING(error.what(), std::string("Batch size is zero")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_invalid_0_input_channels) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{6, 0, 1}); - auto param1 = make_shared(element::f32, Shape{5, 0, 1}); - try - { - auto conv = make_shared(param0, param1); - - // Should have thrown, so fail if it didn't - FAIL() << "Invalid input with 0 input channels not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING( - error.what(), - std::string("Data batch channel count and/or filter input channel count is zero")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_invalid_wrong_number_of_filter_dimensions_too_many) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{6, 2, 10, 10}); - auto param1 = make_shared(element::f32, Shape{5, 2, 3, 3, 3}); - try - { - auto conv = make_shared(param0, param1); - - // Should have thrown, so fail if it didn't - FAIL() << "Invalid input with too many filter dimensions not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING(error.what(), std::string("Data batch and filters rank do not match")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_invalid_wrong_number_of_filter_dimensions_too_few) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{6, 2, 10, 10}); - auto param1 = make_shared(element::f32, Shape{5, 2, 3}); - try - { - auto conv = make_shared(param0, param1); - - // Should have thrown, so fail if it didn't - FAIL() << "Invalid input with too few filter dimensions not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING(error.what(), std::string("Data batch and filters rank do not match")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_invalid_0_output_channels) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{6, 2, 10, 10}); - auto param1 = make_shared(element::f32, Shape{0, 2, 3, 3}); - try - { - auto conv = make_shared(param0, param1); - - // Should have thrown, so fail if it didn't - FAIL() << "Invalid input with 0 output channels not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING(error.what(), std::string("Filter output channel count is zero")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_invalid_input_channel_mismatch) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{6, 2, 10, 10}); - auto param1 = make_shared(element::f32, Shape{6, 3, 3, 3}); - try - { - auto conv = make_shared(param0, param1); - - // Should have thrown, so fail if it didn't - FAIL() << "Invalid input with channel count mismatch not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING( - error.what(), - std::string( - "Data batch channel count (2) does not match filter input channel count (3)")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_invalid_movement_stride_rank) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{6, 2, 10, 10}); - auto param1 = make_shared(element::f32, Shape{6, 2, 3, 3}); - try - { - auto conv = make_shared(param0, param1, Strides{2, 3, 8}); - - // Should have thrown, so fail if it didn't - FAIL() << "Invalid input with wrong movement stride rank not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING( - error.what(), - std::string("Ranks for data item shape/filters shape (data batch has shape " - "{6,2,10,10}, so data item rank is 2 and filters have shape {6,2,3,3}, so " - "filters spatial rank is 2), data dilation (Strides{1, 1}), padding below " - "(CoordinateDiff{0, 0}), padding above (CoordinateDiff{0, 0}), filter " - "strides (Strides{2, 3, 8}), and filter dilation (Strides{1, 1}) do not " - "match")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_invalid_window_dilation_stride_rank) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{6, 2, 10, 10}); - auto param1 = make_shared(element::f32, Shape{6, 2, 3, 3}); - try - { - auto conv = - make_shared(param0, param1, Strides{2, 3}, Strides{2, 3, 8}); - - // Should have thrown, so fail if it didn't - FAIL() << "Invalid input with wrong window dilation stride rank not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING( - error.what(), - std::string("Ranks for data item shape/filters shape (data batch has shape " - "{6,2,10,10}, so data item rank is 2 and filters have shape {6,2,3,3}, so " - "filters spatial rank is 2), data dilation (Strides{1, 1}), padding below " - "(CoordinateDiff{0, 0}), padding above (CoordinateDiff{0, 0}), filter " - "strides (Strides{2, 3}), and filter dilation (Strides{2, 3, 8}) do not " - "match")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_invalid_data_dilation_stride_rank) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{6, 2, 10, 10}); - auto param1 = make_shared(element::f32, Shape{6, 2, 3, 3}); - try - { - auto conv = make_shared(param0, - param1, - Strides{2, 3}, - Strides{2, 3}, - CoordinateDiff{0, 0}, - CoordinateDiff{0, 0}, - Strides{2, 3, 8}); - - // Should have thrown, so fail if it didn't - FAIL() << "Invalid input with wrong data dilation stride rank not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING( - error.what(), - std::string("Ranks for data item shape/filters shape (data batch has shape " - "{6,2,10,10}, so data item rank is 2 and filters have shape {6,2,3,3}, so " - "filters spatial rank is 2), data dilation (Strides{2, 3, 8}), padding " - "below (CoordinateDiff{0, 0}), padding above (CoordinateDiff{0, 0}), " - "filter strides (Strides{2, 3}), and filter dilation (Strides{2, 3}) do " - "not match")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_invalid_padding_below_rank) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{6, 2, 10, 10}); - auto param1 = make_shared(element::f32, Shape{6, 2, 3, 3}); - try - { - auto conv = make_shared(param0, - param1, - Strides{2, 3}, - Strides{1, 1}, - CoordinateDiff{0, 0, 0}, - CoordinateDiff{0, 0}); - - // Should have thrown, so fail if it didn't - FAIL() << "Invalid input with wrong padding-below rank not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING( - error.what(), - std::string( - "Ranks for data item shape/filters shape (data batch has shape " - "{6,2,10,10}, so data item rank is 2 and filters have shape {6,2,3,3}, so " - "filters spatial rank is 2), data dilation (Strides{1, 1}), padding below " - "(CoordinateDiff{0, 0, 0}), padding above (CoordinateDiff{0, 0}), filter " - "strides (Strides{2, 3}), and filter dilation (Strides{1, 1}) do not match")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_invalid_padding_above_rank) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{6, 2, 10, 10}); - auto param1 = make_shared(element::f32, Shape{6, 2, 3, 3}); - try - { - auto conv = make_shared(param0, - param1, - Strides{2, 3}, - Strides{2, 3}, - CoordinateDiff{0, 0}, - CoordinateDiff{0, 0, 0}); - - // Should have thrown, so fail if it didn't - FAIL() << "Invalid input with wrong padding-above rank not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING( - error.what(), - std::string( - "Ranks for data item shape/filters shape (data batch has shape " - "{6,2,10,10}, so data item rank is 2 and filters have shape {6,2,3,3}, so " - "filters spatial rank is 2), data dilation (Strides{1, 1}), padding below " - "(CoordinateDiff{0, 0}), padding above (CoordinateDiff{0, 0, 0}), filter " - "strides (Strides{2, 3}), and filter dilation (Strides{2, 3}) do not match")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_invalid_input_spatial_size_negative_after_padding) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{6, 2, 10, 10}); - auto param1 = make_shared(element::f32, Shape{6, 2, 3, 3}); - try - { - auto conv = make_shared(param0, - param1, - Strides{1, 1}, - Strides{1, 1}, - CoordinateDiff{-4, 0}, - CoordinateDiff{-7, 0}); - - // Should have thrown, so fail if it didn't - FAIL() << "Invalid input with negative-length post-padding spatial axis not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING(error.what(), - std::string("Data shape after padding and dilation has dimension less " - "than 1 (dim: -1) at axis 0")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_invalid_input_spatial_size_zero_after_padding) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{6, 2, 10, 10}); - auto param1 = make_shared(element::f32, Shape{6, 2, 3, 3}); - try - { - auto conv = make_shared(param0, - param1, - Strides{1, 1}, - Strides{1, 1}, - CoordinateDiff{-4, 0}, - CoordinateDiff{-6, 0}); - - // Should have thrown, so fail if it didn't - FAIL() << "Invalid input with zero-length post-padding spatial axis not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING(error.what(), - std::string("Data shape after padding and dilation has dimension less " - "than 1 (dim: 0) at axis 0")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_invalid_input_spatial_size_0) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{6, 2, 0, 10}); - auto param1 = make_shared(element::f32, Shape{6, 2, 3, 3}); - try - { - auto conv = make_shared(param0, param1); - - // Should have thrown, so fail if it didn't - FAIL() << "Invalid input with zero-length spatial axis not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING(error.what(), - std::string("Data shape after padding and dilation has " - "dimension less than 1 (dim: 0) at axis 0")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_invalid_window_size_0) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{6, 2, 10, 10}); - auto param1 = make_shared(element::f32, Shape{6, 2, 3, 0}); - try - { - auto conv = make_shared(param0, param1); - - // Should have thrown, so fail if it didn't - FAIL() << "Invalid input with zero-length window axis not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING( - error.what(), - std::string("Window after dilation has dimension less than 1 (dim: 0) at axis 1")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_invalid_window_dilation_stride_0) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{6, 2, 10, 10}); - auto param1 = make_shared(element::f32, Shape{6, 2, 3, 3}); - try - { - auto conv = make_shared(param0, param1, Strides{2, 3}, Strides{2, 0}); - - // Should have thrown, so fail if it didn't - FAIL() << "Invalid input with wrong 0-length window dilation stride axis not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING( - error.what(), - std::string("Window dilation (Strides{2, 0}) has zero dimension at axis 1")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_invalid_data_dilation_stride_0) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{6, 2, 10, 10}); - auto param1 = make_shared(element::f32, Shape{6, 2, 3, 3}); - try - { - auto conv = make_shared(param0, - param1, - Strides{2, 3}, - Strides{2, 3}, - CoordinateDiff{0, 0}, - CoordinateDiff{0, 0}, - Strides{2, 0}); - - // Should have thrown, so fail if it didn't - FAIL() << "Invalid input with wrong 0-length data dilation stride axis not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING( - error.what(), - std::string("Data dilation (Strides{2, 0}) has zero dimension at axis 1")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_invalid_dilated_window_too_large) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{6, 2, 8, 8}); - auto param1 = make_shared(element::f32, Shape{6, 2, 3, 3}); - try - { - auto conv = make_shared(param0, param1, Strides{1, 1}, Strides{4, 4}); - - // Should have thrown, so fail if it didn't - FAIL() << "Invalid input with oversized dilated window not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING(error.what(), - std::string("Window after dilation has dimension (dim: 9) larger than " - "the data shape after padding (dim: 8) at axis 0")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_invalid_movement_stride_0) -{ - // Deduce type - auto param0 = make_shared(element::f32, Shape{6, 2, 10, 10}); - auto param1 = make_shared(element::f32, Shape{6, 2, 3, 3}); - try - { - auto conv = make_shared(param0, param1, Strides{0, 1}); - - // Should have thrown, so fail if it didn't - FAIL() << "Invalid input with wrong 0-length movement stride axis not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING( - error.what(), - std::string("Window strides (Strides{0, 1}) has zero dimension at axis 0")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_partial_rank_dynamic_rank_dynamic_ok) -{ - PartialShape data_batch_shape{PartialShape::dynamic()}; - PartialShape filters_shape{PartialShape::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - ASSERT_EQ(conv->get_output_element_type(0), element::f32); - ASSERT_TRUE(conv->get_output_partial_shape(0).same_scheme(PartialShape::dynamic(4))); -} - -TEST(type_prop, conv_partial_rank_dynamic_rank_dynamic_window_strides_rank_wrong) -{ - PartialShape data_batch_shape{PartialShape::dynamic()}; - PartialShape filters_shape{PartialShape::dynamic()}; - Strides window_movement_strides{1, 1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - try - { - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - FAIL() << "Window stride rank mismatch not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING( - error.what(), - std::string("Ranks for data item shape/filters shape (data batch has shape ?, so data " - "item rank is ? and filters have shape ?, so filters spatial rank is ?), " - "data dilation (Strides{1, 1}), padding below (CoordinateDiff{0, 0}), " - "padding above (CoordinateDiff{0, 0}), filter strides (Strides{1, 1, 1}), " - "and filter dilation (Strides{1, 1}) do not match")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_partial_rank_dynamic_rank_dynamic_window_strides_dim_zero) -{ - PartialShape data_batch_shape{PartialShape::dynamic()}; - PartialShape filters_shape{PartialShape::dynamic()}; - Strides window_movement_strides{1, 0}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - try - { - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - FAIL() << "Window stride with dimension zero not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING( - error.what(), - std::string("Window strides (Strides{1, 0}) has zero dimension at axis 1")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_partial_rank_dynamic_rank_dynamic_window_dilation_rank_wrong) -{ - PartialShape data_batch_shape{PartialShape::dynamic()}; - PartialShape filters_shape{PartialShape::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - try - { - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - FAIL() << "Window dilation rank mismatch not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING( - error.what(), - std::string("Ranks for data item shape/filters shape (data batch has shape ?, so data " - "item rank is ? and filters have shape ?, so filters spatial rank is ?), " - "data dilation (Strides{1, 1}), padding below (CoordinateDiff{0, 0}), " - "padding above (CoordinateDiff{0, 0}), filter strides (Strides{1, 1}), and " - "filter dilation (Strides{1, 1, 1}) do not match")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_partial_rank_dynamic_rank_dynamic_window_dilation_dim_zero) -{ - PartialShape data_batch_shape{PartialShape::dynamic()}; - PartialShape filters_shape{PartialShape::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 0}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - try - { - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - FAIL() << "Window dilation with dimension zero not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING( - error.what(), - std::string("Window dilation (Strides{1, 0}) has zero dimension at axis 1")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_partial_rank_dynamic_rank_dynamic_padding_below_rank_wrong) -{ - PartialShape data_batch_shape{PartialShape::dynamic()}; - PartialShape filters_shape{PartialShape::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - try - { - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - FAIL() << "Padding below rank mismatch not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING( - error.what(), - std::string("Ranks for data item shape/filters shape (data batch has shape ?, so data " - "item rank is ? and filters have shape ?, so filters spatial rank is ?), " - "data dilation (Strides{1, 1}), padding below (CoordinateDiff{0, 0, 0}), " - "padding above (CoordinateDiff{0, 0}), filter strides (Strides{1, 1}), and " - "filter dilation (Strides{1, 1}) do not match")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_partial_rank_dynamic_rank_dynamic_padding_above_rank_wrong) -{ - PartialShape data_batch_shape{PartialShape::dynamic()}; - PartialShape filters_shape{PartialShape::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - try - { - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - FAIL() << "Padding above rank mismatch not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING( - error.what(), - std::string("Ranks for data item shape/filters shape (data batch has shape ?, so data " - "item rank is ? and filters have shape ?, so filters spatial rank is ?), " - "data dilation (Strides{1, 1}), padding below (CoordinateDiff{0, 0}), " - "padding above (CoordinateDiff{0, 0, 0}), filter strides (Strides{1, 1}), " - "and filter dilation (Strides{1, 1}) do not match")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_partial_rank_dynamic_rank_dynamic_data_dilation_rank_wrong) -{ - PartialShape data_batch_shape{PartialShape::dynamic()}; - PartialShape filters_shape{PartialShape::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - try - { - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - FAIL() << "Data dilation rank mismatch not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING( - error.what(), - std::string("Ranks for data item shape/filters shape (data batch has shape ?, so data " - "item rank is ? and filters have shape ?, so filters spatial rank is ?), " - "data dilation (Strides{1, 1, 1}), padding below (CoordinateDiff{0, 0}), " - "padding above (CoordinateDiff{0, 0}), filter strides (Strides{1, 1}), and " - "filter dilation (Strides{1, 1}) do not match")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_partial_rank_dynamic_rank_dynamic_data_dilation_dim_zero) -{ - PartialShape data_batch_shape{PartialShape::dynamic()}; - PartialShape filters_shape{PartialShape::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 0}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - try - { - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - FAIL() << "Data dilation with dimension zero not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING( - error.what(), - std::string("Data dilation (Strides{1, 0}) has zero dimension at axis 1")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_partial_rank_static_dynamic_rank_dynamic_ok) -{ - PartialShape data_batch_shape{PartialShape::dynamic(4)}; - PartialShape filters_shape{PartialShape::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - ASSERT_EQ(conv->get_output_element_type(0), element::f32); - ASSERT_TRUE(conv->get_output_partial_shape(0).same_scheme(PartialShape::dynamic(4))); -} - -TEST(type_prop, conv_partial_rank_static_dynamic_rank_dynamic_data_batch_rank_wrong) -{ - PartialShape data_batch_shape{PartialShape::dynamic(5)}; - PartialShape filters_shape{PartialShape::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - try - { - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - FAIL() << "Data batch rank mismatch not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING( - error.what(), - std::string("Ranks for data item shape/filters shape (data batch has shape " - "{?,?,?,?,?}, so data item rank is 3 and filters have shape ?, so filters " - "spatial rank is ?), data dilation (Strides{1, 1}), padding below " - "(CoordinateDiff{0, 0}), padding above (CoordinateDiff{0, 0}), filter " - "strides (Strides{1, 1}), and filter dilation (Strides{1, 1}) do not " - "match")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_partial_rank_static_dynamic_rank_dynamic_batch_size_known_ok) -{ - PartialShape data_batch_shape{ - 64, Dimension::dynamic(), Dimension::dynamic(), Dimension::dynamic()}; - PartialShape filters_shape{PartialShape::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - ASSERT_EQ(conv->get_output_element_type(0), element::f32); - ASSERT_TRUE(conv->get_output_partial_shape(0).same_scheme( - PartialShape{64, Dimension::dynamic(), Dimension::dynamic(), Dimension::dynamic()})); -} - -TEST(type_prop, conv_partial_rank_static_dynamic_rank_dynamic_batch_size_known_zero) -{ - PartialShape data_batch_shape{ - 0, Dimension::dynamic(), Dimension::dynamic(), Dimension::dynamic()}; - PartialShape filters_shape{PartialShape::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - try - { - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - FAIL() << "Zero batch size not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING(error.what(), std::string("Batch size is zero")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_partial_rank_static_dynamic_rank_dynamic_input_channel_count_known_ok) -{ - PartialShape data_batch_shape{ - Dimension::dynamic(), 3, Dimension::dynamic(), Dimension::dynamic()}; - PartialShape filters_shape{PartialShape::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - ASSERT_EQ(conv->get_output_element_type(0), element::f32); - ASSERT_TRUE(conv->get_output_partial_shape(0).same_scheme(PartialShape::dynamic(4))); -} - -TEST(type_prop, conv_partial_rank_static_dynamic_rank_dynamic_input_channel_count_known_zero) -{ - PartialShape data_batch_shape{ - Dimension::dynamic(), 0, Dimension::dynamic(), Dimension::dynamic()}; - PartialShape filters_shape{PartialShape::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - try - { - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - FAIL() << "Zero input channel count not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING( - error.what(), - std::string("Data batch channel count and/or filter input channel count is zero")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_partial_rank_dynamic_rank_static_dynamic_output_channel_count_known_ok) -{ - PartialShape data_batch_shape{PartialShape::dynamic(4)}; - PartialShape filters_shape{ - 32, Dimension::dynamic(), Dimension::dynamic(), Dimension::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - ASSERT_EQ(conv->get_output_element_type(0), element::f32); - ASSERT_TRUE(conv->get_output_partial_shape(0).same_scheme( - PartialShape{Dimension::dynamic(), 32, Dimension::dynamic(), Dimension::dynamic()})); -} - -TEST(type_prop, conv_partial_rank_dynamic_rank_static_dynamic_output_channel_count_known_zero) -{ - PartialShape data_batch_shape{PartialShape::dynamic(4)}; - PartialShape filters_shape{0, Dimension::dynamic(), Dimension::dynamic(), Dimension::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - try - { - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - FAIL() << "Zero output channel count not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING(error.what(), std::string("Filter output channel count is zero")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_partial_rank_dynamic_rank_static_dynamic_input_channel_count_known_ok) -{ - PartialShape data_batch_shape{PartialShape::dynamic(4)}; - PartialShape filters_shape{Dimension::dynamic(), 4, Dimension::dynamic(), Dimension::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - ASSERT_EQ(conv->get_output_element_type(0), element::f32); - ASSERT_TRUE(conv->get_output_partial_shape(0).same_scheme(PartialShape::dynamic(4))); -} - -TEST(type_prop, conv_partial_rank_dynamic_rank_static_dynamic_input_channel_count_known_zero) -{ - PartialShape data_batch_shape{PartialShape::dynamic(4)}; - PartialShape filters_shape{Dimension::dynamic(), 0, Dimension::dynamic(), Dimension::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - try - { - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - FAIL() << "Zero input channel count not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING( - error.what(), - std::string("Data batch channel count and/or filter input channel count is zero")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_partial_rank_static_dynamic_rank_static_dynamic_ok) -{ - PartialShape data_batch_shape{PartialShape::dynamic(4)}; - PartialShape filters_shape{PartialShape::dynamic(4)}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - ASSERT_EQ(conv->get_output_element_type(0), element::f32); - ASSERT_TRUE(conv->get_output_partial_shape(0).same_scheme(PartialShape::dynamic(4))); -} - -TEST(type_prop, conv_partial_rank_static_dynamic_rank_static_dynamic_arg_ranks_mismatch) -{ - PartialShape data_batch_shape{PartialShape::dynamic(5)}; - PartialShape filters_shape{PartialShape::dynamic(4)}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - try - { - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - FAIL() << "Argument rank mismatch not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING(error.what(), - std::string("Data batch and filters rank do not match (data batch " - "shape: {?,?,?,?,?}, filters shape: {?,?,?,?})")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_partial_rank_static_dynamic_rank_static_dynamic_input_channel_counts_known_ok) -{ - PartialShape data_batch_shape{ - Dimension::dynamic(), 3, Dimension::dynamic(), Dimension::dynamic()}; - PartialShape filters_shape{Dimension::dynamic(), 3, Dimension::dynamic(), Dimension::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - ASSERT_EQ(conv->get_output_element_type(0), element::f32); - ASSERT_TRUE(conv->get_output_partial_shape(0).same_scheme(PartialShape::dynamic(4))); -} - -TEST(type_prop, conv_partial_rank_static_dynamic_rank_static_dynamic_input_channel_counts_mismatch) -{ - PartialShape data_batch_shape{ - Dimension::dynamic(), 3, Dimension::dynamic(), Dimension::dynamic()}; - PartialShape filters_shape{ - Dimension::dynamic(), 22, Dimension::dynamic(), Dimension::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - try - { - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - FAIL() << "Input channel count mismatch not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING( - error.what(), - std::string( - "Data batch channel count (3) does not match filter input channel count (22)")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_partial_rank_static_dynamic_rank_static_dynamic_all_nonspatial_known_ok) -{ - PartialShape data_batch_shape{64, 3, Dimension::dynamic(), Dimension::dynamic()}; - PartialShape filters_shape{100, 3, Dimension::dynamic(), Dimension::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - ASSERT_EQ(conv->get_output_element_type(0), element::f32); - ASSERT_TRUE(conv->get_output_partial_shape(0).same_scheme( - PartialShape{64, 100, Dimension::dynamic(), Dimension::dynamic()})); -} - -TEST(type_prop, - conv_partial_rank_static_dynamic_rank_static_dynamic_all_nonspatial_some_spatial_known_ok) -{ - PartialShape data_batch_shape{64, 3, 200, Dimension::dynamic()}; - PartialShape filters_shape{100, 3, 5, Dimension::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - ASSERT_EQ(conv->get_output_element_type(0), element::f32); - ASSERT_TRUE(conv->get_output_partial_shape(0).same_scheme( - PartialShape{64, 100, 196, Dimension::dynamic()})); -} - -TEST( - type_prop, - conv_partial_rank_static_dynamic_rank_static_dynamic_all_nonspatial_some_spatial_known_filters_too_big) -{ - PartialShape data_batch_shape{64, 3, 200, Dimension::dynamic()}; - PartialShape filters_shape{100, 3, 201, Dimension::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - try - { - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - FAIL() << "Oversize filter not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING(error.what(), - std::string("Window after dilation has dimension (dim: 201) larger " - "than the data shape after padding (dim: 200) at axis 0")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST( - type_prop, - conv_partial_rank_static_dynamic_rank_static_dynamic_all_nonspatial_some_spatial_known_filters_not_too_big_after_padding) -{ - PartialShape data_batch_shape{64, 3, 200, Dimension::dynamic()}; - PartialShape filters_shape{100, 3, 201, Dimension::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{2, 0}; - CoordinateDiff padding_above{-1, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - ASSERT_EQ(conv->get_output_element_type(0), element::f32); - ASSERT_TRUE(conv->get_output_partial_shape(0).same_scheme( - PartialShape{64, 100, 1, Dimension::dynamic()})); -} - -TEST( - type_prop, - conv_partial_rank_static_dynamic_rank_static_dynamic_all_nonspatial_some_spatial_known_filters_not_too_big_after_data_dilation) -{ - PartialShape data_batch_shape{64, 3, 200, Dimension::dynamic()}; - PartialShape filters_shape{100, 3, 201, Dimension::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{2, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - ASSERT_EQ(conv->get_output_element_type(0), element::f32); - ASSERT_TRUE(conv->get_output_partial_shape(0).same_scheme( - PartialShape{64, 100, 199, Dimension::dynamic()})); -} - -TEST( - type_prop, - conv_partial_rank_static_dynamic_rank_static_dynamic_all_nonspatial_some_spatial_known_filters_not_too_big_after_data_dilation_strided) -{ - PartialShape data_batch_shape{64, 3, 200, Dimension::dynamic()}; - PartialShape filters_shape{100, 3, 201, Dimension::dynamic()}; - Strides window_movement_strides{3, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{2, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - ASSERT_EQ(conv->get_output_element_type(0), element::f32); - ASSERT_TRUE(conv->get_output_partial_shape(0).same_scheme( - PartialShape{64, 100, 67, Dimension::dynamic()})); -} - -TEST( - type_prop, - conv_partial_rank_static_dynamic_rank_static_dynamic_all_nonspatial_some_spatial_known_filters_too_big_after_filter_dilation) -{ - PartialShape data_batch_shape{64, 3, 200, Dimension::dynamic()}; - PartialShape filters_shape{100, 3, 101, Dimension::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{2, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - try - { - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - FAIL() << "Oversize filter after window dilation not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING(error.what(), - std::string("Window after dilation has dimension (dim: 201) larger " - "than the data shape after padding (dim: 200) at axis 0")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST( - type_prop, - conv_partial_rank_static_dynamic_rank_static_dynamic_all_nonspatial_some_spatial_zero_data_batch_dim) -{ - PartialShape data_batch_shape{64, 3, 200, 0}; - PartialShape filters_shape{100, 3, 5, Dimension::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - try - { - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - FAIL() << "Zero dimension in data batch not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING(error.what(), - std::string("Data shape after padding and dilation has " - "dimension less than 1 (dim: 0) at axis 1")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST( - type_prop, - conv_partial_rank_static_dynamic_rank_static_dynamic_all_nonspatial_some_spatial_positive_data_batch_dim_after_padding) -{ - PartialShape data_batch_shape{64, 3, 200, 0}; - PartialShape filters_shape{100, 3, 5, Dimension::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 2}; - CoordinateDiff padding_above{0, -1}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - ASSERT_EQ(conv->get_output_element_type(0), element::f32); - ASSERT_TRUE(conv->get_output_partial_shape(0).same_scheme( - PartialShape{64, 100, 196, Dimension::dynamic()})); -} - -TEST( - type_prop, - conv_partial_rank_static_dynamic_rank_static_dynamic_all_nonspatial_some_spatial_zero_data_batch_dim_after_padding) -{ - PartialShape data_batch_shape{64, 3, 200, 20}; - PartialShape filters_shape{100, 3, 5, Dimension::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, 0}; - CoordinateDiff padding_above{0, -20}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - try - { - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - FAIL() << "Zero padded dimension in data batch not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING(error.what(), - std::string("Data shape after padding and dilation has " - "dimension less than 1 (dim: 0) at axis 1")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST( - type_prop, - conv_partial_rank_static_dynamic_rank_static_dynamic_all_nonspatial_some_spatial_negative_data_batch_dim_after_padding) -{ - PartialShape data_batch_shape{64, 3, 200, 20}; - PartialShape filters_shape{100, 3, 5, Dimension::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{0, -1}; - CoordinateDiff padding_above{0, -20}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::f32, data_batch_shape); - auto param1 = make_shared(element::f32, filters_shape); - - try - { - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - FAIL() << "Negative padded dimension in data batch not detected"; - } - catch (const NodeValidationFailure& error) - { - EXPECT_HAS_SUBSTRING(error.what(), - std::string("Data shape after padding and dilation has dimension less " - "than 1 (dim: -1) at axis 1")); - } - catch (...) - { - FAIL() << "Deduced type check failed for unexpected reason"; - } -} - -TEST(type_prop, conv_partial_dynamic_et) -{ - // For this test the exact shape parameters are kind of arbitrary---just copied and pasted - // from some known-"OK" test above. We're only concerned about the element types. - PartialShape data_batch_shape{64, 3, 200, Dimension::dynamic()}; - PartialShape filters_shape{100, 3, 201, Dimension::dynamic()}; - Strides window_movement_strides{1, 1}; - Strides window_dilation_strides{1, 1}; - CoordinateDiff padding_below{2, 0}; - CoordinateDiff padding_above{-1, 0}; - Strides data_dilation_strides{1, 1}; - - auto param0 = make_shared(element::dynamic, data_batch_shape); - auto param1 = make_shared(element::dynamic, filters_shape); - - auto conv = make_shared(param0, - param1, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - data_dilation_strides); - - ASSERT_TRUE(conv->get_output_element_type(0).is_dynamic()); - ASSERT_TRUE(conv->get_output_partial_shape(0).same_scheme( - PartialShape{64, 100, 1, Dimension::dynamic()})); -} - TEST(type_prop, conv_v1_partial_rank) { PartialShape data_batch_shape{PartialShape::dynamic()}; diff --git a/ngraph/test/type_prop/convolution_backprop_data.cpp b/ngraph/test/type_prop/convolution_backprop_data.cpp index 3dfac03a1cb548..338044bcc98b9a 100644 --- a/ngraph/test/type_prop/convolution_backprop_data.cpp +++ b/ngraph/test/type_prop/convolution_backprop_data.cpp @@ -16,260 +16,11 @@ #include "gtest/gtest.h" #include "ngraph/ngraph.hpp" -#include "op/convolution.hpp" #include "util/type_prop.hpp" using namespace std; using namespace ngraph; -// ---------------------------- v0 ---------------------------- -TEST(type_prop, conv_backprop_data_v0_1d_batch_deduce) -{ - // Deduce type - Shape data_batch_shape{64, 3, 100}; - auto param0 = make_shared(element::f32, Shape{128, 3, 10}); // filters - auto param1 = make_shared(element::f32, Shape{64, 128, 91}); // output delta - auto conv = make_shared(data_batch_shape, - param0, - param1, - Strides{1}, - Strides{1}, - CoordinateDiff{0}, - CoordinateDiff{0}, - Strides{1}); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), data_batch_shape); - - EXPECT_EQ(conv->get_window_movement_strides_forward(), Strides{1}); - EXPECT_EQ(conv->get_window_dilation_strides_forward(), Strides{1}); - EXPECT_EQ(conv->get_data_dilation_strides_forward(), Strides{1}); - - EXPECT_EQ(conv->get_padding_below_forward(), CoordinateDiff{0}); - EXPECT_EQ(conv->get_padding_above_forward(), CoordinateDiff{0}); -} - -TEST(type_prop, conv_backprop_data_v0_1d_batch_deduce_padded) -{ - // Deduce type - Shape data_batch_shape{64, 3, 100}; - auto param0 = make_shared(element::f32, Shape{128, 3, 10}); // filters - auto param1 = make_shared(element::f32, Shape{64, 128, 96}); // output delta - auto move_strides = Strides{1}; - auto dilation_strides = Strides{1}; - auto padding_below = CoordinateDiff{2}; - auto padding_above = CoordinateDiff{3}; - auto conv = make_shared(data_batch_shape, - param0, - param1, - move_strides, - dilation_strides, - padding_below, - padding_above, - Strides{1}); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), data_batch_shape); - - EXPECT_EQ(conv->get_window_movement_strides_forward(), Strides{1}); - EXPECT_EQ(conv->get_window_dilation_strides_forward(), Strides{1}); - EXPECT_EQ(conv->get_data_dilation_strides_forward(), Strides{1}); - - EXPECT_EQ(conv->get_padding_below_forward(), CoordinateDiff{2}); - EXPECT_EQ(conv->get_padding_above_forward(), CoordinateDiff{3}); -} - -TEST(type_prop, conv_backprop_data_v0_1d_batch_deduce_strided) -{ - // Deduce type - Shape data_batch_shape{64, 3, 100}; - auto param0 = make_shared(element::f32, Shape{128, 3, 10}); // filters - auto param1 = make_shared(element::f32, Shape{64, 128, 46}); // output delta - auto move_strides = Strides{2}; - auto conv = make_shared(data_batch_shape, - param0, - param1, - move_strides, - Strides{1}, - CoordinateDiff{0}, - CoordinateDiff{0}, - Strides{1}); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), data_batch_shape); - - EXPECT_EQ(conv->get_window_movement_strides_forward(), Strides{2}); - EXPECT_EQ(conv->get_window_dilation_strides_forward(), Strides{1}); - EXPECT_EQ(conv->get_data_dilation_strides_forward(), Strides{1}); - - EXPECT_EQ(conv->get_padding_below_forward(), CoordinateDiff{0}); - EXPECT_EQ(conv->get_padding_above_forward(), CoordinateDiff{0}); -} - -TEST(type_prop, conv_backprop_data_v0_1d_batch_deduce_strided_padded) -{ - // Deduce type - Shape data_batch_shape{64, 3, 100}; - auto param0 = make_shared(element::f32, Shape{128, 3, 10}); // filters - auto param1 = make_shared(element::f32, Shape{64, 128, 48}); // output delta - auto move_strides = Strides{2}; - auto dilation_strides = Strides{1}; - auto padding_below = CoordinateDiff{2}; - auto padding_above = CoordinateDiff{3}; - auto conv = make_shared(data_batch_shape, - param0, - param1, - move_strides, - dilation_strides, - padding_below, - padding_above, - Strides{1}); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), data_batch_shape); - - EXPECT_EQ(conv->get_window_movement_strides_forward(), Strides{2}); - EXPECT_EQ(conv->get_window_dilation_strides_forward(), Strides{1}); - EXPECT_EQ(conv->get_data_dilation_strides_forward(), Strides{1}); - - EXPECT_EQ(conv->get_padding_below_forward(), CoordinateDiff{2}); - EXPECT_EQ(conv->get_padding_above_forward(), CoordinateDiff{3}); -} - -TEST(type_prop, conv_backprop_data_v0_1d_batch_deduce_strided_small_uneven) -{ - // Deduce type - Shape data_batch_shape{64, 3, 5}; - auto param0 = make_shared(element::f32, Shape{128, 3, 2}); // filters - auto param1 = make_shared(element::f32, Shape{64, 128, 2}); // output delta - auto move_strides = Strides{2}; - auto conv = make_shared(data_batch_shape, - param0, - param1, - move_strides, - Strides{1}, - CoordinateDiff{0}, - CoordinateDiff{0}, - Strides{1}); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), data_batch_shape); - - EXPECT_EQ(conv->get_window_movement_strides_forward(), Strides{2}); - EXPECT_EQ(conv->get_window_dilation_strides_forward(), Strides{1}); - EXPECT_EQ(conv->get_data_dilation_strides_forward(), Strides{1}); - - EXPECT_EQ(conv->get_padding_below_forward(), CoordinateDiff{0}); - EXPECT_EQ(conv->get_padding_above_forward(), CoordinateDiff{0}); -} - -TEST(type_prop, conv_backprop_data_v0_1d_batch_deduce_strided_small_even) -{ - // Deduce type - Shape data_batch_shape{64, 3, 6}; - auto param0 = make_shared(element::f32, Shape{128, 3, 2}); // filters - auto param1 = make_shared(element::f32, Shape{64, 128, 3}); // output delta - auto move_strides = Strides{2}; - auto conv = make_shared(data_batch_shape, - param0, - param1, - move_strides, - Strides{1}, - CoordinateDiff{0}, - CoordinateDiff{0}, - Strides{1}); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), data_batch_shape); - - EXPECT_EQ(conv->get_window_movement_strides_forward(), Strides{2}); - EXPECT_EQ(conv->get_window_dilation_strides_forward(), Strides{1}); - EXPECT_EQ(conv->get_data_dilation_strides_forward(), Strides{1}); - - EXPECT_EQ(conv->get_padding_below_forward(), CoordinateDiff{0}); - EXPECT_EQ(conv->get_padding_above_forward(), CoordinateDiff{0}); -} - -TEST(type_prop, conv_backprop_data_v0_1d_batch_deduce_window_dilated) -{ - // Deduce type - Shape data_batch_shape{64, 3, 100}; - auto param0 = make_shared(element::f32, Shape{128, 3, 10}); // filters - auto param1 = make_shared(element::f32, Shape{64, 128, 82}); // output delta - auto move_strides = Strides{1}; - auto dilate_strides = Strides{2}; - auto conv = make_shared(data_batch_shape, - param0, - param1, - move_strides, - dilate_strides, - CoordinateDiff{0}, - CoordinateDiff{0}, - Strides{1}); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), data_batch_shape); - - EXPECT_EQ(conv->get_window_movement_strides_forward(), Strides{1}); - EXPECT_EQ(conv->get_window_dilation_strides_forward(), Strides{2}); - EXPECT_EQ(conv->get_data_dilation_strides_forward(), Strides{1}); - - EXPECT_EQ(conv->get_padding_below_forward(), CoordinateDiff{0}); - EXPECT_EQ(conv->get_padding_above_forward(), CoordinateDiff{0}); -} - -TEST(type_prop, conv_backprop_data_v0_1d_batch_deduce_window_dilated_padded) -{ - // Deduce type - Shape data_batch_shape{64, 3, 100}; - auto param0 = make_shared(element::f32, Shape{128, 3, 10}); // filters - auto param1 = make_shared(element::f32, Shape{64, 128, 87}); // output delta - auto move_strides = Strides{1}; - auto dilate_strides = Strides{2}; - auto padding_below = CoordinateDiff{2}; - auto padding_above = CoordinateDiff{3}; - auto conv = make_shared(data_batch_shape, - param0, - param1, - move_strides, - dilate_strides, - padding_below, - padding_above, - Strides{1}); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), data_batch_shape); - - EXPECT_EQ(conv->get_window_movement_strides_forward(), Strides{1}); - EXPECT_EQ(conv->get_window_dilation_strides_forward(), Strides{2}); - EXPECT_EQ(conv->get_data_dilation_strides_forward(), Strides{1}); - - EXPECT_EQ(conv->get_padding_below_forward(), CoordinateDiff{2}); - EXPECT_EQ(conv->get_padding_above_forward(), CoordinateDiff{3}); -} - -TEST(type_prop, conv_backprop_data_v0_1d_batch_deduce_window_dilated_data_dilated_padded) -{ - // Deduce type - Shape data_batch_shape{64, 3, 100}; - auto param0 = make_shared(element::f32, Shape{128, 3, 10}); // filters - auto param1 = make_shared(element::f32, Shape{64, 128, 285}); // output delta - auto move_strides = Strides{1}; - auto dilate_strides = Strides{2}; - auto padding_below = CoordinateDiff{2}; - auto padding_above = CoordinateDiff{3}; - auto data_dilate_strides = Strides{3}; - auto conv = make_shared(data_batch_shape, - param0, - param1, - move_strides, - dilate_strides, - padding_below, - padding_above, - data_dilate_strides); - EXPECT_EQ(conv->get_element_type(), element::f32); - EXPECT_EQ(conv->get_shape(), data_batch_shape); - - EXPECT_EQ(conv->get_window_movement_strides_forward(), Strides{1}); - EXPECT_EQ(conv->get_window_dilation_strides_forward(), Strides{2}); - EXPECT_EQ(conv->get_data_dilation_strides_forward(), Strides{3}); - - EXPECT_EQ(conv->get_padding_below_forward(), CoordinateDiff{2}); - EXPECT_EQ(conv->get_padding_above_forward(), CoordinateDiff{3}); -} - // ---------------------------- v1 ---------------------------- TEST(type_prop, convolution_backprop_data_partial_auto_padding_upper) { @@ -338,7 +89,7 @@ TEST(type_prop, convolution_backprop_data_auto_pad_explicit_with_output_padding) auto filters = make_shared(inputs_et, filters_pshape); auto conv_backprop = make_shared( data, filters, strides, padding_begin, padding_end, dilations, auto_pad, output_padding); - + ASSERT_TRUE(conv_backprop->get_output_partial_shape(0).same_scheme(PartialShape{1, 6, 4, 4})); ASSERT_EQ(conv_backprop->get_pads_begin(), (CoordinateDiff{1, 1})); ASSERT_EQ(conv_backprop->get_pads_end(), (CoordinateDiff{1, 1})); @@ -361,9 +112,16 @@ TEST(type_prop, convolution_backprop_data_auto_pad_same_with_output_padding_and_ auto data = make_shared(inputs_et, data_pshape); auto filters = make_shared(inputs_et, filters_pshape); auto output_shape = op::Constant::create(element::i64, Shape{2}, {3, 3}); - auto conv_backprop = make_shared( - data, filters, output_shape, strides, padding_begin, padding_end, dilations, auto_pad, output_padding); - + auto conv_backprop = make_shared(data, + filters, + output_shape, + strides, + padding_begin, + padding_end, + dilations, + auto_pad, + output_padding); + ASSERT_TRUE(conv_backprop->get_output_partial_shape(0).same_scheme(PartialShape{1, 6, 3, 3})); ASSERT_EQ(conv_backprop->get_pads_begin(), (CoordinateDiff{1, 1})); ASSERT_EQ(conv_backprop->get_pads_end(), (CoordinateDiff{2, 2})); @@ -807,13 +565,15 @@ TEST(type_prop, convolution_backprop_data_invalid_et_inputs) // output shape input element type must be of integer type FAIL() << "Invalid element type of output_shape input not detected"; } - catch(const NodeValidationFailure& error) + catch (const NodeValidationFailure& error) { - EXPECT_HAS_SUBSTRING(error.what(), "Element type for output shape should be of integer type"); + EXPECT_HAS_SUBSTRING(error.what(), + "Element type for output shape should be of integer type"); } catch (...) { - FAIL() << "Element type of output_shape input validation check failed for unexpected reason"; + FAIL() + << "Element type of output_shape input validation check failed for unexpected reason"; } } @@ -899,9 +659,8 @@ TEST(type_prop, convolution_backprop_data_invalid_input_ranks) } catch (const NodeValidationFailure& error) { - EXPECT_HAS_SUBSTRING( - error.what(), - std::string("Spatial shape of output input must be of rank 1")); + EXPECT_HAS_SUBSTRING(error.what(), + std::string("Spatial shape of output input must be of rank 1")); } catch (...) { @@ -930,7 +689,9 @@ TEST(type_prop, convolution_backprop_data_invalid_input_channel_dims) } catch (const NodeValidationFailure& error) { - EXPECT_HAS_SUBSTRING(error.what(), std::string("Input channels dimension of data and filters inputs must be equal")); + EXPECT_HAS_SUBSTRING( + error.what(), + std::string("Input channels dimension of data and filters inputs must be equal")); } catch (...) { @@ -1159,4 +920,4 @@ TEST(type_prop, convolution_backprop_data_invalid_conv_param_spatial_dims) { FAIL() << "Output padding spatial dimensions validation check failed for unexpected reason"; } -} \ No newline at end of file +} diff --git a/ngraph/test/type_prop/cosh.cpp b/ngraph/test/type_prop/cosh.cpp new file mode 100644 index 00000000000000..6db9dababb319e --- /dev/null +++ b/ngraph/test/type_prop/cosh.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" + +using Type = ::testing::Types; + +INSTANTIATE_TYPED_TEST_SUITE_P(type_prop_cosh, UnaryOperator, Type); diff --git a/ngraph/test/type_prop/matrix_nms.cpp b/ngraph/test/type_prop/matrix_nms.cpp new file mode 100644 index 00000000000000..6817786cd1fc7b --- /dev/null +++ b/ngraph/test/type_prop/matrix_nms.cpp @@ -0,0 +1,263 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" +#include "ngraph/ngraph.hpp" +#include "util/type_prop.hpp" + +using namespace std; +using namespace ngraph; + +TEST(type_prop, matrix_nms_incorrect_boxes_rank) +{ + try + { + const auto boxes = make_shared(element::f32, Shape{1, 2, 3, 4}); + const auto scores = make_shared(element::f32, Shape{1, 2, 3}); + + make_shared(boxes, scores, op::v8::MatrixNms::Attributes()); + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), "Expected a 3D tensor for the 'boxes' input"); + } +} + +TEST(type_prop, matrix_nms_incorrect_scores_rank) +{ + try + { + const auto boxes = make_shared(element::f32, Shape{1, 2, 4}); + const auto scores = make_shared(element::f32, Shape{1, 2}); + + make_shared(boxes, scores, op::v8::MatrixNms::Attributes()); + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), "Expected a 3D tensor for the 'scores' input"); + } +} + +TEST(type_prop, matrix_nms_incorrect_scheme_num_batches) +{ + try + { + const auto boxes = make_shared(element::f32, Shape{1, 2, 4}); + const auto scores = make_shared(element::f32, Shape{2, 2, 3}); + + make_shared(boxes, scores, op::v8::MatrixNms::Attributes()); + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), + "The first dimension of both 'boxes' and 'scores' must match"); + } +} + +TEST(type_prop, matrix_nms_incorrect_scheme_num_boxes) +{ + try + { + const auto boxes = make_shared(element::f32, Shape{1, 2, 4}); + const auto scores = make_shared(element::f32, Shape{1, 2, 3}); + + make_shared(boxes, scores, op::v8::MatrixNms::Attributes()); + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), + "'boxes' and 'scores' input shapes must match at the second and third " + "dimension respectively"); + } +} + +TEST(type_prop, matrix_nms_incorrect_boxes_rank2) +{ + try + { + const auto boxes = make_shared(element::f32, Shape{1, 2, 3}); + const auto scores = make_shared(element::f32, Shape{2, 2, 2}); + + make_shared(boxes, scores, op::v8::MatrixNms::Attributes()); + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), + "The third dimension of the 'boxes' must be 4"); + } +} + +TEST(type_prop, matrix_nms_incorrect_output_type) +{ + try + { + const auto boxes = make_shared(element::f32, Shape{1, 2, 4}); + const auto scores = make_shared(element::f32, Shape{1, 2, 2}); + op::v8::MatrixNms::Attributes attrs; + attrs.output_type = ngraph::element::f32; + + make_shared(boxes, scores, attrs); + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), + "Output type must be i32 or i64"); + } +} + +TEST(type_prop, matrix_nms_incorrect_nms_topk) +{ + try + { + const auto boxes = make_shared(element::f32, Shape{1, 2, 4}); + const auto scores = make_shared(element::f32, Shape{1, 2, 2}); + op::v8::MatrixNms::Attributes attrs; + attrs.nms_top_k = -2; + + make_shared(boxes, scores, attrs); + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), + "The 'nms_top_k' must be great or equal -1"); + } +} + +TEST(type_prop, matrix_nms_incorrect_keep_topk) +{ + try + { + const auto boxes = make_shared(element::f32, Shape{1, 2, 4}); + const auto scores = make_shared(element::f32, Shape{1, 2, 2}); + op::v8::MatrixNms::Attributes attrs; + attrs.keep_top_k = -2; + + make_shared(boxes, scores, attrs); + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), + "The 'keep_top_k' must be great or equal -1"); + } +} + +TEST(type_prop, matrix_nms_incorrect_background_class) +{ + try + { + const auto boxes = make_shared(element::f32, Shape{1, 2, 4}); + const auto scores = make_shared(element::f32, Shape{1, 2, 2}); + op::v8::MatrixNms::Attributes attrs; + attrs.background_class = -2; + + make_shared(boxes, scores, attrs); + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), + "The 'background_class' must be great or equal -1"); + } +} + +TEST(type_prop, matrix_nms_output_shape_1dim_dynamic) +{ + const auto boxes = make_shared(element::f32, Shape{5, 2, 4}); + const auto scores = make_shared(element::f32, Shape{5, 3, 2}); + + const auto nms = make_shared(boxes, scores, op::v8::MatrixNms::Attributes()); + + ASSERT_TRUE( + nms->get_output_partial_shape(0).same_scheme(PartialShape{Dimension::dynamic(), 6})); + ASSERT_TRUE( + nms->get_output_partial_shape(1).same_scheme(PartialShape{Dimension::dynamic(), 1})); + + EXPECT_EQ(nms->get_output_shape(2), (Shape{5})); +} + +TEST(type_prop, matrix_nms_output_shape_1dim_max_out) +{ + const auto boxes = make_shared(element::f32, Shape{2, 7, 4}); + const auto scores = make_shared(element::f32, Shape{2, 5, 7}); + + const auto nms = make_shared(boxes, scores, op::v8::MatrixNms::Attributes()); + + ASSERT_EQ(nms->get_output_element_type(0), element::f32); + ASSERT_EQ(nms->get_output_element_type(1), element::i64); + ASSERT_EQ(nms->get_output_element_type(2), element::i64); + + // batch * class * box + EXPECT_EQ(nms->get_output_partial_shape(0), PartialShape({Dimension(0, 2 * 5 * 7), Dimension(6)})); + EXPECT_EQ(nms->get_output_partial_shape(1), PartialShape({Dimension(0, 2 * 5 * 7), 1})); + EXPECT_EQ(nms->get_output_shape(2), (Shape{2})); +} + +TEST(type_prop, matrix_nms_output_shape_1dim_nms_topk) +{ + const auto boxes = make_shared(element::f32, Shape{2, 7, 4}); + const auto scores = make_shared(element::f32, Shape{2, 5, 7}); + op::v8::MatrixNms::Attributes attrs; + attrs.nms_top_k = 3; + + const auto nms = make_shared(boxes, scores, attrs); + + ASSERT_EQ(nms->get_output_element_type(0), element::f32); + ASSERT_EQ(nms->get_output_element_type(1), element::i64); + ASSERT_EQ(nms->get_output_element_type(2), element::i64); + // batch * class * min(nms_topk, box) + EXPECT_EQ(nms->get_output_partial_shape(0), PartialShape({Dimension(0, 2 * 5 * 3), Dimension(6)})); + EXPECT_EQ(nms->get_output_partial_shape(1), PartialShape({Dimension(0, 2 * 5 * 3), 1})); + EXPECT_EQ(nms->get_output_shape(2), (Shape{2})); +} + +TEST(type_prop, matrix_nms_output_shape_1dim_keep_topk) +{ + const auto boxes = make_shared(element::f32, Shape{2, 7, 4}); + const auto scores = make_shared(element::f32, Shape{2, 5, 7}); + op::v8::MatrixNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.keep_top_k = 8; + + const auto nms = make_shared(boxes, scores, attrs); + + ASSERT_EQ(nms->get_output_element_type(0), element::f32); + ASSERT_EQ(nms->get_output_element_type(1), element::i64); + ASSERT_EQ(nms->get_output_element_type(2), element::i64); + // batch * min(keep_topk, class * box)) + EXPECT_EQ(nms->get_output_partial_shape(0), PartialShape({Dimension(0, 2 * 8), Dimension(6)})); + EXPECT_EQ(nms->get_output_partial_shape(1), PartialShape({Dimension(0, 2 * 8), 1})); + EXPECT_EQ(nms->get_output_shape(2), (Shape{2})); +} + +TEST(type_prop, matrix_nms_output_shape_i32) +{ + const auto boxes = make_shared(element::f32, Shape{2, 7, 4}); + const auto scores = make_shared(element::f32, Shape{2, 5, 7}); + op::v8::MatrixNms::Attributes attrs; + attrs.output_type = ngraph::element::i32; + + const auto nms = make_shared(boxes, scores, attrs); + + ASSERT_EQ(nms->get_output_element_type(0), element::f32); + ASSERT_EQ(nms->get_output_element_type(1), element::i32); + ASSERT_EQ(nms->get_output_element_type(2), element::i32); + // batch * class * box + EXPECT_EQ(nms->get_output_partial_shape(0), PartialShape({Dimension(0, 2 * 5 * 7), Dimension(6)})); + EXPECT_EQ(nms->get_output_partial_shape(1), PartialShape({Dimension(0, 2 * 5 * 7), 1})); + EXPECT_EQ(nms->get_output_shape(2), (Shape{2})); +} + +TEST(type_prop, matrix_nms_dynamic_boxes_and_scores) +{ + const auto boxes = make_shared(element::f32, PartialShape::dynamic()); + const auto scores = make_shared(element::f32, PartialShape::dynamic()); + + const auto nms = make_shared(boxes, scores, op::v8::MatrixNms::Attributes()); + + ASSERT_EQ(nms->get_output_element_type(0), element::f32); + ASSERT_EQ(nms->get_output_element_type(1), element::i64); + ASSERT_EQ(nms->get_output_element_type(2), element::i64); + EXPECT_EQ(nms->get_output_partial_shape(0), PartialShape({Dimension::dynamic(), 6})); + EXPECT_EQ(nms->get_output_partial_shape(1), PartialShape({Dimension::dynamic(), 1})); + EXPECT_EQ(nms->get_output_partial_shape(2), PartialShape({Dimension::dynamic()})); +} diff --git a/ngraph/test/type_prop/multiclass_nms.cpp b/ngraph/test/type_prop/multiclass_nms.cpp new file mode 100644 index 00000000000000..ad13d8e2dec001 --- /dev/null +++ b/ngraph/test/type_prop/multiclass_nms.cpp @@ -0,0 +1,281 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" +#include "ngraph/ngraph.hpp" +#include "util/type_prop.hpp" + +using namespace std; +using namespace ngraph; + +TEST(type_prop, multiclass_nms_incorrect_boxes_rank) +{ + try + { + const auto boxes = make_shared(element::f32, Shape{1, 2, 3, 4}); + const auto scores = make_shared(element::f32, Shape{1, 2, 3}); + + make_shared(boxes, scores, op::v8::MulticlassNms::Attributes()); + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), "Expected a 3D tensor for the 'boxes' input"); + } +} + +TEST(type_prop, multiclass_nms_incorrect_scores_rank) +{ + try + { + const auto boxes = make_shared(element::f32, Shape{1, 2, 4}); + const auto scores = make_shared(element::f32, Shape{1, 2}); + + make_shared(boxes, scores, op::v8::MulticlassNms::Attributes()); + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), "Expected a 3D tensor for the 'scores' input"); + } +} + +TEST(type_prop, multiclass_nms_incorrect_scheme_num_batches) +{ + try + { + const auto boxes = make_shared(element::f32, Shape{1, 2, 4}); + const auto scores = make_shared(element::f32, Shape{2, 2, 3}); + + make_shared(boxes, scores, op::v8::MulticlassNms::Attributes()); + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), + "The first dimension of both 'boxes' and 'scores' must match"); + } +} + +TEST(type_prop, multiclass_nms_incorrect_scheme_num_boxes) +{ + try + { + const auto boxes = make_shared(element::f32, Shape{1, 2, 4}); + const auto scores = make_shared(element::f32, Shape{1, 2, 3}); + + make_shared(boxes, scores, op::v8::MulticlassNms::Attributes()); + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), + "'boxes' and 'scores' input shapes must match at the second and third " + "dimension respectively"); + } +} + +TEST(type_prop, multiclass_nms_incorrect_boxes_rank2) +{ + try + { + const auto boxes = make_shared(element::f32, Shape{1, 2, 3}); + const auto scores = make_shared(element::f32, Shape{2, 2, 2}); + + make_shared(boxes, scores, op::v8::MulticlassNms::Attributes()); + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), + "The third dimension of the 'boxes' must be 4"); + } +} + +TEST(type_prop, multiclass_nms_incorrect_output_type) +{ + try + { + const auto boxes = make_shared(element::f32, Shape{1, 2, 4}); + const auto scores = make_shared(element::f32, Shape{1, 2, 2}); + op::v8::MulticlassNms::Attributes attrs; + attrs.output_type = ngraph::element::f32; + + make_shared(boxes, scores, attrs); + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), + "Output type must be i32 or i64"); + } +} + +TEST(type_prop, multiclass_nms_incorrect_nms_topk) +{ + try + { + const auto boxes = make_shared(element::f32, Shape{1, 2, 4}); + const auto scores = make_shared(element::f32, Shape{1, 2, 2}); + op::v8::MulticlassNms::Attributes attrs; + attrs.nms_top_k = -2; + + make_shared(boxes, scores, attrs); + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), + "The 'nms_top_k' must be great or equal -1"); + } +} + +TEST(type_prop, multiclass_nms_incorrect_keep_topk) +{ + try + { + const auto boxes = make_shared(element::f32, Shape{1, 2, 4}); + const auto scores = make_shared(element::f32, Shape{1, 2, 2}); + op::v8::MulticlassNms::Attributes attrs; + attrs.keep_top_k = -2; + + make_shared(boxes, scores, attrs); + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), + "The 'keep_top_k' must be great or equal -1"); + } +} + +TEST(type_prop, multiclass_nms_incorrect_background_class) +{ + try + { + const auto boxes = make_shared(element::f32, Shape{1, 2, 4}); + const auto scores = make_shared(element::f32, Shape{1, 2, 2}); + op::v8::MulticlassNms::Attributes attrs; + attrs.background_class = -2; + + make_shared(boxes, scores, attrs); + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), + "The 'background_class' must be great or equal -1"); + } +} + +TEST(type_prop, multiclass_nms_incorrect_eta) +{ + try + { + const auto boxes = make_shared(element::f32, Shape{1, 2, 4}); + const auto scores = make_shared(element::f32, Shape{1, 2, 2}); + op::v8::MulticlassNms::Attributes attrs; + attrs.nms_eta = 2.0f; + + make_shared(boxes, scores, attrs); + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), + "The 'nms_eta' must be in close range [0, 1.0]"); + } +} + +TEST(type_prop, multiclass_nms_output_shape_1dim_dynamic) +{ + const auto boxes = make_shared(element::f32, Shape{5, 2, 4}); + const auto scores = make_shared(element::f32, Shape{5, 3, 2}); + + const auto nms = make_shared(boxes, scores, op::v8::MulticlassNms::Attributes()); + + ASSERT_TRUE( + nms->get_output_partial_shape(0).same_scheme(PartialShape{Dimension::dynamic(), 6})); + ASSERT_TRUE( + nms->get_output_partial_shape(1).same_scheme(PartialShape{Dimension::dynamic(), 1})); + + EXPECT_EQ(nms->get_output_shape(2), (Shape{5})); +} + +TEST(type_prop, multiclass_nms_output_shape_1dim_max_out) +{ + const auto boxes = make_shared(element::f32, Shape{2, 7, 4}); + const auto scores = make_shared(element::f32, Shape{2, 5, 7}); + + const auto nms = make_shared(boxes, scores, op::v8::MulticlassNms::Attributes()); + + ASSERT_EQ(nms->get_output_element_type(0), element::f32); + ASSERT_EQ(nms->get_output_element_type(1), element::i64); + ASSERT_EQ(nms->get_output_element_type(2), element::i64); + + // batch * class * box + EXPECT_EQ(nms->get_output_partial_shape(0), PartialShape({Dimension(0, 2 * 5 * 7), Dimension(6)})); + EXPECT_EQ(nms->get_output_partial_shape(1), PartialShape({Dimension(0, 2 * 5 * 7), 1})); + EXPECT_EQ(nms->get_output_shape(2), (Shape{2})); +} + +TEST(type_prop, multiclass_nms_output_shape_1dim_nms_topk) +{ + const auto boxes = make_shared(element::f32, Shape{2, 7, 4}); + const auto scores = make_shared(element::f32, Shape{2, 5, 7}); + op::v8::MulticlassNms::Attributes attrs; + attrs.nms_top_k = 3; + + const auto nms = make_shared(boxes, scores, attrs); + + ASSERT_EQ(nms->get_output_element_type(0), element::f32); + ASSERT_EQ(nms->get_output_element_type(1), element::i64); + ASSERT_EQ(nms->get_output_element_type(2), element::i64); + // batch * class * min(nms_topk, box) + EXPECT_EQ(nms->get_output_partial_shape(0), PartialShape({Dimension(0, 2 * 5 * 3), Dimension(6)})); + EXPECT_EQ(nms->get_output_partial_shape(1), PartialShape({Dimension(0, 2 * 5 * 3), 1})); + EXPECT_EQ(nms->get_output_shape(2), (Shape{2})); +} + +TEST(type_prop, multiclass_nms_output_shape_1dim_keep_topk) +{ + const auto boxes = make_shared(element::f32, Shape{2, 7, 4}); + const auto scores = make_shared(element::f32, Shape{2, 5, 7}); + op::v8::MulticlassNms::Attributes attrs; + attrs.nms_top_k = 3; + attrs.keep_top_k = 8; + + const auto nms = make_shared(boxes, scores, attrs); + + ASSERT_EQ(nms->get_output_element_type(0), element::f32); + ASSERT_EQ(nms->get_output_element_type(1), element::i64); + ASSERT_EQ(nms->get_output_element_type(2), element::i64); + // batch * min(keep_topk, class * box)) + EXPECT_EQ(nms->get_output_partial_shape(0), PartialShape({Dimension(0, 2 * 8), Dimension(6)})); + EXPECT_EQ(nms->get_output_partial_shape(1), PartialShape({Dimension(0, 2 * 8), 1})); + EXPECT_EQ(nms->get_output_shape(2), (Shape{2})); +} + +TEST(type_prop, multiclass_nms_output_shape_i32) +{ + const auto boxes = make_shared(element::f32, Shape{2, 7, 4}); + const auto scores = make_shared(element::f32, Shape{2, 5, 7}); + op::v8::MulticlassNms::Attributes attrs; + attrs.output_type = ngraph::element::i32; + + const auto nms = make_shared(boxes, scores, attrs); + + ASSERT_EQ(nms->get_output_element_type(0), element::f32); + ASSERT_EQ(nms->get_output_element_type(1), element::i32); + ASSERT_EQ(nms->get_output_element_type(2), element::i32); + // batch * class * box + EXPECT_EQ(nms->get_output_partial_shape(0), PartialShape({Dimension(0, 2 * 5 * 7), Dimension(6)})); + EXPECT_EQ(nms->get_output_partial_shape(1), PartialShape({Dimension(0, 2 * 5 * 7), 1})); + EXPECT_EQ(nms->get_output_shape(2), (Shape{2})); +} + +TEST(type_prop, multiclass_nms_dynamic_boxes_and_scores) +{ + const auto boxes = make_shared(element::f32, PartialShape::dynamic()); + const auto scores = make_shared(element::f32, PartialShape::dynamic()); + + const auto nms = make_shared(boxes, scores, op::v8::MulticlassNms::Attributes()); + + ASSERT_EQ(nms->get_output_element_type(0), element::f32); + ASSERT_EQ(nms->get_output_element_type(1), element::i64); + ASSERT_EQ(nms->get_output_element_type(2), element::i64); + EXPECT_EQ(nms->get_output_partial_shape(0), PartialShape({Dimension::dynamic(), 6})); + EXPECT_EQ(nms->get_output_partial_shape(1), PartialShape({Dimension::dynamic(), 1})); + EXPECT_EQ(nms->get_output_partial_shape(2), PartialShape({Dimension::dynamic()})); +} diff --git a/ngraph/test/type_prop/prior_box.cpp b/ngraph/test/type_prop/prior_box.cpp new file mode 100644 index 00000000000000..4304593844c05c --- /dev/null +++ b/ngraph/test/type_prop/prior_box.cpp @@ -0,0 +1,51 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" + +#include "ngraph/ngraph.hpp" +#include "ngraph/op/prior_box.hpp" + +using namespace ngraph; + +TEST(type_prop, prior_box1) +{ + op::PriorBoxAttrs attrs; + attrs.min_size = {2.0f, 3.0f}; + attrs.aspect_ratio = {1.5f, 2.0f, 2.5f}; + attrs.scale_all_sizes = false; + + auto layer_shape = op::Constant::create(element::i64, Shape{2}, {32, 32}); + auto image_shape = op::Constant::create(element::i64, Shape{2}, {300, 300}); + auto pb = std::make_shared(layer_shape, image_shape, attrs); + ASSERT_EQ(pb->get_shape(), (Shape{2, 20480})); +} + +TEST(type_prop, prior_box2) +{ + op::PriorBoxAttrs attrs; + attrs.min_size = {2.0f, 3.0f}; + attrs.aspect_ratio = {1.5f, 2.0f, 2.5f}; + attrs.flip = true; + attrs.scale_all_sizes = false; + + auto layer_shape = op::Constant::create(element::i64, Shape{2}, {32, 32}); + auto image_shape = op::Constant::create(element::i64, Shape{2}, {300, 300}); + auto pb = std::make_shared(layer_shape, image_shape, attrs); + ASSERT_EQ(pb->get_shape(), (Shape{2, 32768})); +} + +TEST(type_prop, prior_box3) +{ + op::PriorBoxAttrs attrs; + attrs.min_size = {256.0f}; + attrs.max_size = {315.0f}; + attrs.aspect_ratio = {2.0f}; + attrs.flip = true; + + auto layer_shape = op::Constant::create(element::i64, Shape{2}, {1, 1}); + auto image_shape = op::Constant::create(element::i64, Shape{2}, {300, 300}); + auto pb = std::make_shared(layer_shape, image_shape, attrs); + ASSERT_EQ(pb->get_shape(), (Shape{2, 16})); +} \ No newline at end of file diff --git a/ngraph/test/type_prop/sinh.cpp b/ngraph/test/type_prop/sinh.cpp new file mode 100644 index 00000000000000..252fc35cdc249f --- /dev/null +++ b/ngraph/test/type_prop/sinh.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" + +using Type = ::testing::Types; + +INSTANTIATE_TYPED_TEST_SUITE_P(type_prop_sinh, UnaryOperator, Type); diff --git a/ngraph/test/type_prop_layers.cpp b/ngraph/test/type_prop_layers.cpp index fec662e75e05a4..efb6a49ee14c70 100644 --- a/ngraph/test/type_prop_layers.cpp +++ b/ngraph/test/type_prop_layers.cpp @@ -7,7 +7,6 @@ #include "ngraph/ngraph.hpp" #include "ngraph/op/ctc_greedy_decoder.hpp" #include "ngraph/op/interpolate.hpp" -#include "ngraph/op/prior_box.hpp" #include "ngraph/op/prior_box_clustered.hpp" #include "ngraph/op/region_yolo.hpp" #include "ngraph/op/reorg_yolo.hpp" @@ -46,47 +45,6 @@ TEST(type_prop_layers, interpolate) .same_scheme(PartialShape{2, 2, Dimension::dynamic(), Dimension::dynamic()})); } -TEST(type_prop_layers, prior_box1) -{ - op::PriorBoxAttrs attrs; - attrs.min_size = {2.0f, 3.0f}; - attrs.aspect_ratio = {1.5f, 2.0f, 2.5f}; - attrs.scale_all_sizes = false; - - auto layer_shape = op::Constant::create(element::i64, Shape{2}, {32, 32}); - auto image_shape = op::Constant::create(element::i64, Shape{2}, {300, 300}); - auto pb = make_shared(layer_shape, image_shape, attrs); - ASSERT_EQ(pb->get_shape(), (Shape{2, 20480})); -} - -TEST(type_prop_layers, prior_box2) -{ - op::PriorBoxAttrs attrs; - attrs.min_size = {2.0f, 3.0f}; - attrs.aspect_ratio = {1.5f, 2.0f, 2.5f}; - attrs.flip = true; - attrs.scale_all_sizes = false; - - auto layer_shape = op::Constant::create(element::i64, Shape{2}, {32, 32}); - auto image_shape = op::Constant::create(element::i64, Shape{2}, {300, 300}); - auto pb = make_shared(layer_shape, image_shape, attrs); - ASSERT_EQ(pb->get_shape(), (Shape{2, 32768})); -} - -TEST(type_prop_layers, prior_box3) -{ - op::PriorBoxAttrs attrs; - attrs.min_size = {256.0f}; - attrs.max_size = {315.0f}; - attrs.aspect_ratio = {2.0f}; - attrs.flip = true; - - auto layer_shape = op::Constant::create(element::i64, Shape{2}, {1, 1}); - auto image_shape = op::Constant::create(element::i64, Shape{2}, {300, 300}); - auto pb = make_shared(layer_shape, image_shape, attrs); - ASSERT_EQ(pb->get_shape(), (Shape{2, 16})); -} - TEST(type_prop_layers, prior_box_clustered) { op::PriorBoxClusteredAttrs attrs; diff --git a/ngraph/test/util/engine/ie_engines.cpp b/ngraph/test/util/engine/ie_engines.cpp index 8e1a8f4e75eb9a..ce5e4247b8f977 100644 --- a/ngraph/test/util/engine/ie_engines.cpp +++ b/ngraph/test/util/engine/ie_engines.cpp @@ -6,7 +6,6 @@ #include "ngraph/opsets/opset.hpp" #include "ngraph/pass/manager.hpp" -#include "pass/opset1_upgrade.hpp" #include "shared_utils.hpp" using namespace ngraph; @@ -178,7 +177,6 @@ namespace test::IE_Engine::IE_Engine(const std::shared_ptr function, const char* device) : m_function{function} { - upgrade_and_validate_function(m_function); const auto cnn_network = InferenceEngine::CNNNetwork(m_function); m_network_inputs = cnn_network.getInputsInfo(); m_network_outputs = cnn_network.getOutputsInfo(); @@ -200,7 +198,7 @@ void test::IE_Engine::infer() if (m_network_inputs.size() != m_allocated_inputs) { IE_THROW() << "The tested graph has " << m_network_inputs.size() << " inputs, but " - << m_allocated_inputs << " were passed."; + << m_allocated_inputs << " were passed."; } else { @@ -294,26 +292,6 @@ testing::AssertionResult return comparison_result; } -std::shared_ptr - test::IE_Engine::upgrade_and_validate_function(const std::shared_ptr function) const -{ - pass::Manager passes; - passes.register_pass(); - passes.run_passes(function); - - static std::set ie_ops = get_ie_ops(); - for (const auto& node : function->get_ops()) - { - if (ie_ops.find(node->get_type_info()) == ie_ops.end()) - { - IE_THROW() << "Unsupported operator detected in the graph: " - << node->get_type_info().name; - } - } - - return function; -} - std::set test::IE_Engine::get_ie_ops() const { std::set ie_ops = get_opset1().get_type_info_set(); @@ -341,8 +319,8 @@ void test::IE_Engine::reset() namespace InferenceEngine { -// Without this section the linker is not able to find destructors for missing TBlob specializations -// which are instantiated in the unit tests that use TestCase and this engine + // Without this section the linker is not able to find destructors for missing TBlob + // specializations which are instantiated in the unit tests that use TestCase and this engine template TBlob::~TBlob() { diff --git a/ngraph/test/util/engine/ie_engines.hpp b/ngraph/test/util/engine/ie_engines.hpp index 4bcc5de195e3ae..5e219c6351a299 100644 --- a/ngraph/test/util/engine/ie_engines.hpp +++ b/ngraph/test/util/engine/ie_engines.hpp @@ -113,11 +113,6 @@ namespace ngraph unsigned int m_allocated_inputs = 0; unsigned int m_allocated_expected_outputs = 0; - /// Upgrades functions containing legacy opset0 to opset1 - /// and checks if the graph can be executed - std::shared_ptr - upgrade_and_validate_function(const std::shared_ptr function) const; - /// Retrieves a set of all ops IE can execute std::set get_ie_ops() const; @@ -160,5 +155,5 @@ namespace ngraph { static constexpr bool value = true; }; - } -} + } // namespace test +} // namespace ngraph diff --git a/ngraph/test/visitors/op/asinh.cpp b/ngraph/test/visitors/op/asinh.cpp new file mode 100644 index 00000000000000..6e18ede91c8b87 --- /dev/null +++ b/ngraph/test/visitors/op/asinh.cpp @@ -0,0 +1,11 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" +using Type = ::testing::Types>; + +INSTANTIATE_TYPED_TEST_SUITE_P(visitor_without_attribute, + UnaryOperatorVisitor, + Type, + UnaryOperatorTypeName); \ No newline at end of file diff --git a/ngraph/test/visitors/op/atan.cpp b/ngraph/test/visitors/op/atan.cpp new file mode 100644 index 00000000000000..72b5931c72bb88 --- /dev/null +++ b/ngraph/test/visitors/op/atan.cpp @@ -0,0 +1,12 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" + +using Types = ::testing::Types>; + +INSTANTIATE_TYPED_TEST_SUITE_P(visitor_without_attribute, + UnaryOperatorVisitor, + Types, + UnaryOperatorTypeName); \ No newline at end of file diff --git a/ngraph/test/visitors/op/batch_to_space.cpp b/ngraph/test/visitors/op/batch_to_space.cpp new file mode 100644 index 00000000000000..60f653283bff0c --- /dev/null +++ b/ngraph/test/visitors/op/batch_to_space.cpp @@ -0,0 +1,29 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" + +#include "ngraph/ngraph.hpp" +#include "ngraph/op/util/attr_types.hpp" + +#include "util/visitor.hpp" + +using namespace std; +using namespace ngraph; +using ngraph::test::NodeBuilder; + +TEST(attributes, batch_to_space_op) +{ + NodeBuilder::get_ops().register_factory(); + auto data = make_shared(element::f32, Shape{2, 128}); + auto block_shape = make_shared(element::i64, Shape{2}, vector{1, 2}); + auto crops_begin = make_shared(element::i64, Shape{2}, vector{0, 2}); + auto crops_end = make_shared(element::i64, Shape{2}, vector{0, 0}); + auto batch2space = make_shared(data, block_shape, crops_begin, crops_end); + + NodeBuilder builder(batch2space); + const auto expected_attr_count = 0; + + EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); +} diff --git a/ngraph/test/visitors/op/cosh.cpp b/ngraph/test/visitors/op/cosh.cpp new file mode 100644 index 00000000000000..d44b7701eb3bac --- /dev/null +++ b/ngraph/test/visitors/op/cosh.cpp @@ -0,0 +1,11 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" +using Type = ::testing::Types>; + +INSTANTIATE_TYPED_TEST_SUITE_P(visitor_without_attribute, + UnaryOperatorVisitor, + Type, + UnaryOperatorTypeName); diff --git a/ngraph/test/visitors/op/matrix_nms.cpp b/ngraph/test/visitors/op/matrix_nms.cpp new file mode 100644 index 00000000000000..7486e7791e23bf --- /dev/null +++ b/ngraph/test/visitors/op/matrix_nms.cpp @@ -0,0 +1,101 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" + +#include "ngraph/ngraph.hpp" +#include "ngraph/op/util/attr_types.hpp" +#include "ngraph/opsets/opset1.hpp" +#include "ngraph/opsets/opset3.hpp" +#include "ngraph/opsets/opset4.hpp" +#include "ngraph/opsets/opset5.hpp" +#include "ngraph/opsets/opset8.hpp" + +#include "util/visitor.hpp" + +using namespace std; +using namespace ngraph; +using ngraph::test::NodeBuilder; +using ngraph::test::ValueMap; + +TEST(attributes, matrix_nms_v8_op_custom_attributes) +{ + NodeBuilder::get_ops().register_factory(); + auto boxes = make_shared(element::f32, Shape{1, 1, 4}); + auto scores = make_shared(element::f32, Shape{1, 1, 1}); + + opset8::MatrixNms::Attributes attrs; + attrs.sort_result_type = opset8::MatrixNms::SortResultType::SCORE; + attrs.output_type = ngraph::element::i32; + attrs.nms_top_k = 100; + attrs.keep_top_k = 10; + attrs.sort_result_across_batch = true; + attrs.score_threshold = 0.1f; + attrs.background_class = 2; + attrs.decay_function = opset8::MatrixNms::DecayFunction::GAUSSIAN; + attrs.gaussian_sigma = 0.2f; + attrs.post_threshold = 0.3f; + attrs.normalized = false; + + auto nms = make_shared(boxes, scores, attrs); + NodeBuilder builder(nms); + auto g_nms = as_type_ptr(builder.create()); + const auto expected_attr_count = 11; + EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); + + auto& g_nms_attrs = g_nms->get_attrs(); + auto& nms_attrs = nms->get_attrs(); + + EXPECT_EQ(g_nms_attrs.sort_result_type, nms_attrs.sort_result_type); + EXPECT_EQ(g_nms_attrs.output_type, nms_attrs.output_type); + EXPECT_EQ(g_nms_attrs.nms_top_k, nms_attrs.nms_top_k); + EXPECT_EQ(g_nms_attrs.keep_top_k, nms_attrs.keep_top_k); + EXPECT_EQ(g_nms_attrs.sort_result_across_batch, nms_attrs.sort_result_across_batch); + EXPECT_EQ(g_nms_attrs.score_threshold, nms_attrs.score_threshold); + EXPECT_EQ(g_nms_attrs.background_class, nms_attrs.background_class); + EXPECT_EQ(g_nms_attrs.decay_function, nms_attrs.decay_function); + EXPECT_EQ(g_nms_attrs.gaussian_sigma, nms_attrs.gaussian_sigma); + EXPECT_EQ(g_nms_attrs.post_threshold, nms_attrs.post_threshold); + EXPECT_EQ(g_nms_attrs.normalized, nms_attrs.normalized); + + EXPECT_EQ(attrs.sort_result_type, nms_attrs.sort_result_type); + EXPECT_EQ(attrs.output_type, nms_attrs.output_type); + EXPECT_EQ(attrs.nms_top_k, nms_attrs.nms_top_k); + EXPECT_EQ(attrs.keep_top_k, nms_attrs.keep_top_k); + EXPECT_EQ(attrs.sort_result_across_batch, nms_attrs.sort_result_across_batch); + EXPECT_EQ(attrs.score_threshold, nms_attrs.score_threshold); + EXPECT_EQ(attrs.background_class, nms_attrs.background_class); + EXPECT_EQ(attrs.decay_function, nms_attrs.decay_function); + EXPECT_EQ(attrs.gaussian_sigma, nms_attrs.gaussian_sigma); + EXPECT_EQ(attrs.post_threshold, nms_attrs.post_threshold); + EXPECT_EQ(attrs.normalized, nms_attrs.normalized); +} + +TEST(attributes, matrix_nms_v8_op_default_attributes) +{ + NodeBuilder::get_ops().register_factory(); + auto boxes = make_shared(element::f32, Shape{1, 1, 4}); + auto scores = make_shared(element::f32, Shape{1, 1, 1}); + + auto nms = make_shared(boxes, scores, opset8::MatrixNms::Attributes()); + NodeBuilder builder(nms); + auto g_nms = as_type_ptr(builder.create()); + const auto expected_attr_count = 11; + EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); + + auto& g_nms_attrs = g_nms->get_attrs(); + auto& nms_attrs = nms->get_attrs(); + + EXPECT_EQ(g_nms_attrs.sort_result_type, nms_attrs.sort_result_type); + EXPECT_EQ(g_nms_attrs.output_type, nms_attrs.output_type); + EXPECT_EQ(g_nms_attrs.nms_top_k, nms_attrs.nms_top_k); + EXPECT_EQ(g_nms_attrs.keep_top_k, nms_attrs.keep_top_k); + EXPECT_EQ(g_nms_attrs.sort_result_across_batch, nms_attrs.sort_result_across_batch); + EXPECT_EQ(g_nms_attrs.score_threshold, nms_attrs.score_threshold); + EXPECT_EQ(g_nms_attrs.background_class, nms_attrs.background_class); + EXPECT_EQ(g_nms_attrs.decay_function, nms_attrs.decay_function); + EXPECT_EQ(g_nms_attrs.gaussian_sigma, nms_attrs.gaussian_sigma); + EXPECT_EQ(g_nms_attrs.post_threshold, nms_attrs.post_threshold); + EXPECT_EQ(g_nms_attrs.normalized, nms_attrs.normalized); +} diff --git a/ngraph/test/visitors/op/multiclass_nms.cpp b/ngraph/test/visitors/op/multiclass_nms.cpp new file mode 100644 index 00000000000000..50bb9ec5e234dc --- /dev/null +++ b/ngraph/test/visitors/op/multiclass_nms.cpp @@ -0,0 +1,97 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" + +#include "ngraph/ngraph.hpp" +#include "ngraph/op/util/attr_types.hpp" +#include "ngraph/opsets/opset1.hpp" +#include "ngraph/opsets/opset3.hpp" +#include "ngraph/opsets/opset4.hpp" +#include "ngraph/opsets/opset5.hpp" +#include "ngraph/opsets/opset8.hpp" + +#include "util/visitor.hpp" + +using namespace std; +using namespace ngraph; +using ngraph::test::NodeBuilder; +using ngraph::test::ValueMap; + +TEST(attributes, multiclass_nms_v8_op_custom_attributes) +{ + NodeBuilder::get_ops().register_factory(); + auto boxes = make_shared(element::f32, Shape{1, 1, 4}); + auto scores = make_shared(element::f32, Shape{1, 1, 1}); + + opset8::MulticlassNms::Attributes attrs; + attrs.sort_result_type = opset8::MulticlassNms::SortResultType::SCORE; + attrs.sort_result_across_batch = true; + attrs.output_type = ngraph::element::i32; + attrs.nms_top_k = 100; + attrs.keep_top_k = 10; + attrs.iou_threshold = 0.1f; + attrs.score_threshold = 0.2f; + attrs.background_class = 2; + attrs.nms_eta = 0.3f; + attrs.normalized = false; + + auto nms = make_shared(boxes, scores, attrs); + NodeBuilder builder(nms); + auto g_nms = as_type_ptr(builder.create()); + const auto expected_attr_count = 10; + EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); + + auto& g_nms_attrs = g_nms->get_attrs(); + auto& nms_attrs = nms->get_attrs(); + + EXPECT_EQ(g_nms_attrs.sort_result_type, nms_attrs.sort_result_type); + EXPECT_EQ(g_nms_attrs.sort_result_across_batch, nms_attrs.sort_result_across_batch); + EXPECT_EQ(g_nms_attrs.output_type, nms_attrs.output_type); + EXPECT_EQ(g_nms_attrs.nms_top_k, nms_attrs.nms_top_k); + EXPECT_EQ(g_nms_attrs.keep_top_k, nms_attrs.keep_top_k); + EXPECT_EQ(g_nms_attrs.iou_threshold, nms_attrs.iou_threshold); + EXPECT_EQ(g_nms_attrs.score_threshold, nms_attrs.score_threshold); + EXPECT_EQ(g_nms_attrs.background_class, nms_attrs.background_class); + EXPECT_EQ(g_nms_attrs.nms_eta, nms_attrs.nms_eta); + EXPECT_EQ(g_nms_attrs.normalized, nms_attrs.normalized); + + EXPECT_EQ(attrs.sort_result_type, nms_attrs.sort_result_type); + EXPECT_EQ(attrs.sort_result_across_batch, nms_attrs.sort_result_across_batch); + EXPECT_EQ(attrs.output_type, nms_attrs.output_type); + EXPECT_EQ(attrs.nms_top_k, nms_attrs.nms_top_k); + EXPECT_EQ(attrs.keep_top_k, nms_attrs.keep_top_k); + EXPECT_EQ(attrs.iou_threshold, nms_attrs.iou_threshold); + EXPECT_EQ(attrs.score_threshold, nms_attrs.score_threshold); + EXPECT_EQ(attrs.background_class, nms_attrs.background_class); + EXPECT_EQ(attrs.nms_eta, nms_attrs.nms_eta); + EXPECT_EQ(attrs.normalized, nms_attrs.normalized); +} + +TEST(attributes, multiclass_nms_v8_op_default_attributes) +{ + NodeBuilder::get_ops().register_factory(); + auto boxes = make_shared(element::f32, Shape{1, 1, 4}); + auto scores = make_shared(element::f32, Shape{1, 1, 1}); + + auto nms = make_shared(boxes, scores, opset8::MulticlassNms::Attributes()); + NodeBuilder builder(nms); + auto g_nms = as_type_ptr(builder.create()); + const auto expected_attr_count = 10; + EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); + + auto& g_nms_attrs = g_nms->get_attrs(); + auto& nms_attrs = nms->get_attrs(); + + EXPECT_EQ(g_nms_attrs.sort_result_type, nms_attrs.sort_result_type); + EXPECT_EQ(g_nms_attrs.sort_result_across_batch, nms_attrs.sort_result_across_batch); + EXPECT_EQ(g_nms_attrs.output_type, nms_attrs.output_type); + EXPECT_EQ(g_nms_attrs.nms_top_k, nms_attrs.nms_top_k); + EXPECT_EQ(g_nms_attrs.keep_top_k, nms_attrs.keep_top_k); + EXPECT_EQ(g_nms_attrs.iou_threshold, nms_attrs.iou_threshold); + EXPECT_EQ(g_nms_attrs.score_threshold, nms_attrs.score_threshold); + EXPECT_EQ(g_nms_attrs.background_class, nms_attrs.background_class); + EXPECT_EQ(g_nms_attrs.nms_eta, nms_attrs.nms_eta); + EXPECT_EQ(g_nms_attrs.normalized, nms_attrs.normalized); +} diff --git a/ngraph/test/visitors/op/prior_box.cpp b/ngraph/test/visitors/op/prior_box.cpp index 3e0c5c706d24d2..0c4ce74aa4b9e6 100644 --- a/ngraph/test/visitors/op/prior_box.cpp +++ b/ngraph/test/visitors/op/prior_box.cpp @@ -45,6 +45,8 @@ TEST(attributes, prior_box_op) const auto prior_box_attrs = prior_box->get_attrs(); const auto g_prior_box_attrs = g_prior_box->get_attrs(); + const auto expected_attr_count = 12; + EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); EXPECT_EQ(g_prior_box_attrs.min_size, prior_box_attrs.min_size); EXPECT_EQ(g_prior_box_attrs.max_size, prior_box_attrs.max_size); EXPECT_EQ(g_prior_box_attrs.aspect_ratio, prior_box_attrs.aspect_ratio); diff --git a/ngraph/test/visitors/op/sinh.cpp b/ngraph/test/visitors/op/sinh.cpp new file mode 100644 index 00000000000000..db35d185c4a741 --- /dev/null +++ b/ngraph/test/visitors/op/sinh.cpp @@ -0,0 +1,11 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" +using Type = ::testing::Types>; + +INSTANTIATE_TYPED_TEST_SUITE_P(visitor_without_attribute, + UnaryOperatorVisitor, + Type, + UnaryOperatorTypeName); diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 45395f910fc423..ac094ce648b46b 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -10,6 +10,7 @@ ie_shellcheck_process(DIRECTORY "${OpenVINO_SOURCE_DIR}" SKIP "${OpenVINO_SOURCE_DIR}/bin" "${OpenVINO_SOURCE_DIR}/build" "${OpenVINO_SOURCE_DIR}/thirdparty" + "${OpenVINO_SOURCE_DIR}/ngraph/python/pybind11" "${IE_MAIN_SOURCE_DIR}/thirdparty" "${TEMP}" # TODO fix and enable back: diff --git a/scripts/demo/car_1.bmp b/scripts/demo/car_1.bmp index 111cee4ff867d9..ffdb8bf2ec3060 100644 Binary files a/scripts/demo/car_1.bmp and b/scripts/demo/car_1.bmp differ diff --git a/scripts/demo/demo_benchmark_app.bat b/scripts/demo/demo_benchmark_app.bat index 3ca0d6c7bdc6e0..88928fddc672db 100644 --- a/scripts/demo/demo_benchmark_app.bat +++ b/scripts/demo/demo_benchmark_app.bat @@ -6,6 +6,7 @@ setlocal enabledelayedexpansion set TARGET=CPU set BUILD_FOLDER=%USERPROFILE%\Documents\Intel\OpenVINO +set VENV_DIR=%USERPROFILE%\Documents\Intel\OpenVINO\venv_openvino :: command line arguments parsing :input_arguments_loop @@ -21,10 +22,12 @@ if not "%1"=="" ( shift ) if "%1"=="-help" ( - echo %~n0%~x0 is benchmark demo using public SqueezeNet topology + echo Benchmark demo using public SqueezeNet topology echo. echo Options: - echo -d name Specify the target device to infer on; CPU, GPU, FPGA, HDDL or MYRIAD are acceptable. Sample will look for a suitable plugin for device specified + echo -help Print help message + echo -d DEVICE Specify the target device to infer on; CPU, GPU, HDDL or MYRIAD are acceptable. Sample will look for a suitable plugin for device specified + echo -sample-options OPTIONS Specify command line arguments for the sample exit /b ) shift @@ -88,7 +91,21 @@ if not "%python_ver%"=="okay" ( ) :: install yaml python modules required for downloader.py -pip3 install --user -r "%ROOT_DIR%..\open_model_zoo\tools\downloader\requirements.in" +if exist "%VENV_DIR%" ( + echo. + echo ###############^|^| Using the existing python virtual environment ^|^|############### + echo. +) else ( + echo. + echo ###############^|^| Creating the python virtual environment ^|^|############### + echo. + python -m venv "%VENV_DIR%" +) + +call "%VENV_DIR%\Scripts\activate.bat" +python -m pip install -U pip +python -m pip install -r "%ROOT_DIR%..\open_model_zoo\tools\downloader\requirements.in" + if ERRORLEVEL 1 GOTO errorHandling set downloader_dir=%INTEL_OPENVINO_DIR%\deployment_tools\open_model_zoo\tools\downloader @@ -121,8 +138,8 @@ echo. echo ###############^|^| Install Model Optimizer prerequisites ^|^|############### echo. CALL :delay 3 -cd /d "%INTEL_OPENVINO_DIR%\deployment_tools\model_optimizer\install_prerequisites" -call install_prerequisites_caffe.bat +cd /d "%INTEL_OPENVINO_DIR%\deployment_tools\model_optimizer" +python -m pip install -r requirements.txt if ERRORLEVEL 1 GOTO errorHandling CALL :delay 7 @@ -209,7 +226,7 @@ if "!MSBUILD_BIN!" == "" ( GOTO errorHandling ) -set "SOLUTION_DIR64=%BUILD_FOLDER%\inference_engine_samples_build" +set "SOLUTION_DIR64=%BUILD_FOLDER%\inference_engine_cpp_samples_build" echo Creating Visual Studio !MSBUILD_VERSION! %PLATFORM% files in %SOLUTION_DIR64%... && ^ if exist "%SOLUTION_DIR64%\CMakeCache.txt" del "%SOLUTION_DIR64%\CMakeCache.txt" diff --git a/scripts/demo/demo_benchmark_app.sh b/scripts/demo/demo_benchmark_app.sh index a287c406d2b2e7..0c2869037c4414 100755 --- a/scripts/demo/demo_benchmark_app.sh +++ b/scripts/demo/demo_benchmark_app.sh @@ -3,14 +3,21 @@ # Copyright (C) 2018-2021 Intel Corporation # SPDX-License-Identifier: Apache-2.0 +echo -ne "\e[0;33mWARNING: If you get an error when running the demo in the Docker container, you may need to install additional packages. To do this, run the container as root (-u 0) and run install_openvino_dependencies.sh script. If you get a package-independent error, try setting additional parameters using -sample-options.\e[0m\n" + ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]-$0}" )" && pwd )" +VENV_DIR="$HOME/venv_openvino" . "$ROOT_DIR/utils.sh" usage() { echo "Benchmark demo using public SqueezeNet topology" - echo "-d name specify the target device to infer on; CPU, GPU, FPGA, HDDL or MYRIAD are acceptable. Sample will look for a suitable plugin for device specified" - echo "-help print help message" + echo + echo "Options:" + echo " -help Print help message" + echo " -d DEVICE Specify the target device to infer on; CPU, GPU, HDDL or MYRIAD are acceptable. Sample will look for a suitable plugin for device specified" + echo " -sample-options OPTIONS Specify command line arguments for the sample" + echo exit 1 } @@ -50,7 +57,7 @@ fi target_precision="FP16" -printf "target_precision = %s\n" ${target_precision} +echo -ne "target_precision = ${target_precision}\n" models_path="$HOME/openvino_models/models" models_cache="$HOME/openvino_models/cache" @@ -61,13 +68,11 @@ model_name="squeezenet1.1" target_image_path="$ROOT_DIR/car.png" run_again="Then run the script again\n\n" -dashes="\n\n###################################################\n\n" - if [ -e "$ROOT_DIR/../../bin/setupvars.sh" ]; then setupvars_path="$ROOT_DIR/../../bin/setupvars.sh" else - printf "Error: setupvars.sh is not found\n" + echo -ne "Error: setupvars.sh is not found\n" fi if ! . "$setupvars_path" ; then @@ -75,14 +80,6 @@ if ! . "$setupvars_path" ; then exit 1 fi -# Step 1. Download the Caffe model and the prototxt of the model -echo -ne "${dashes}" -printf "\n\nDownloading the Caffe model and the prototxt" - -cur_path=$PWD - -printf "\nInstalling dependencies\n" - if [[ -f /etc/centos-release ]]; then DISTRO="centos" elif [[ -f /etc/lsb-release ]]; then @@ -90,55 +87,27 @@ elif [[ -f /etc/lsb-release ]]; then fi if [[ $DISTRO == "centos" ]]; then - sudo -E yum install -y centos-release-scl epel-release - sudo -E yum install -y gcc gcc-c++ make glibc-static glibc-devel libstdc++-static libstdc++-devel libstdc++ libgcc \ - glibc-static.i686 glibc-devel.i686 libstdc++-static.i686 libstdc++.i686 libgcc.i686 cmake - - sudo -E rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm || true - sudo -E yum install -y epel-release - sudo -E yum install -y cmake ffmpeg gstreamer1 gstreamer1-plugins-base libusbx-devel - # check installed Python version if command -v python3.5 >/dev/null 2>&1; then python_binary=python3.5 - pip_binary=pip3.5 fi if command -v python3.6 >/dev/null 2>&1; then python_binary=python3.6 - pip_binary=pip3.6 - fi - if [ -z "$python_binary" ]; then - sudo -E yum install -y rh-python36 || true - . scl_source enable rh-python36 - python_binary=python3.6 - pip_binary=pip3.6 fi elif [[ $DISTRO == "ubuntu" ]]; then - sudo -E apt update - print_and_run sudo -E apt -y install build-essential python3-pip virtualenv cmake libcairo2-dev libpango1.0-dev libglib2.0-dev libgtk2.0-dev libswscale-dev libavcodec-dev libavformat-dev libgstreamer1.0-0 gstreamer1.0-plugins-base python_binary=python3 - pip_binary=pip3 - - system_ver=$(grep -i "DISTRIB_RELEASE" -f /etc/lsb-release | cut -d "=" -f2) - if [ "$system_ver" = "16.04" ]; then - sudo -E apt-get install -y libpng12-dev - else - sudo -E apt-get install -y libpng-dev - fi elif [[ "$OSTYPE" == "darwin"* ]]; then # check installed Python version - if command -v python3.7 >/dev/null 2>&1; then + if command -v python3.8 >/dev/null 2>&1; then + python_binary=python3.8 + elif command -v python3.7 >/dev/null 2>&1; then python_binary=python3.7 - pip_binary=pip3.7 elif command -v python3.6 >/dev/null 2>&1; then python_binary=python3.6 - pip_binary=pip3.6 elif command -v python3.5 >/dev/null 2>&1; then python_binary=python3.5 - pip_binary=pip3.5 else python_binary=python3 - pip_binary=pip3 fi fi @@ -147,47 +116,52 @@ if ! command -v $python_binary &>/dev/null; then exit 1 fi -if [[ "$OSTYPE" == "darwin"* ]]; then - $pip_binary install -r "$ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in" +if [ -e "$VENV_DIR" ]; then + echo -ne "\n###############|| Using the existing python virtual environment ||###############\n\n" else - sudo -E "$pip_binary" install -r "$ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in" + echo -ne "\n###############|| Creating the python virtual environment ||###############\n\n" + "$python_binary" -m venv "$VENV_DIR" fi +. "$VENV_DIR/bin/activate" +python -m pip install -U pip +python -m pip install -r "$ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in" + +# Step 1. Download the Caffe model and the prototxt of the model +echo -ne "\n###############|| Downloading the Caffe model and the prototxt ||###############\n\n" + downloader_dir="${INTEL_OPENVINO_DIR}/deployment_tools/open_model_zoo/tools/downloader" -model_dir=$("$python_binary" "$downloader_dir/info_dumper.py" --name "$model_name" | - "$python_binary" -c 'import sys, json; print(json.load(sys.stdin)[0]["subdirectory"])') +model_dir=$(python "$downloader_dir/info_dumper.py" --name "$model_name" | + python -c 'import sys, json; print(json.load(sys.stdin)[0]["subdirectory"])') downloader_path="$downloader_dir/downloader.py" -print_and_run "$python_binary" "$downloader_path" --name "$model_name" --output_dir "${models_path}" --cache_dir "${models_cache}" +print_and_run python "$downloader_path" --name "$model_name" --output_dir "${models_path}" --cache_dir "${models_cache}" ir_dir="${irs_path}/${model_dir}/${target_precision}" if [ ! -e "$ir_dir" ]; then # Step 2. Configure Model Optimizer - echo -ne "${dashes}" - printf "Install Model Optimizer dependencies\n\n" - cd "${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/install_prerequisites" - . ./install_prerequisites.sh caffe - cd "$cur_path" + echo -ne "\n###############|| Install Model Optimizer dependencies ||###############\n\n" + cd "${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer" + python -m pip install -r requirements.txt + cd "$PWD" # Step 3. Convert a model with Model Optimizer - echo -ne "${dashes}" - printf "Convert a model with Model Optimizer\n\n" + echo -ne "\n###############|| Convert a model with Model Optimizer ||###############\n\n" mo_path="${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/mo.py" export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp - print_and_run "$python_binary" "$downloader_dir/converter.py" --mo "$mo_path" --name "$model_name" -d "$models_path" -o "$irs_path" --precisions "$target_precision" + print_and_run python "$downloader_dir/converter.py" --mo "$mo_path" --name "$model_name" -d "$models_path" -o "$irs_path" --precisions "$target_precision" else - printf "\n\nTarget folder %s already exists. Skipping IR generation with Model Optimizer." "${ir_dir}" + echo -ne "\n\nTarget folder ${ir_dir} already exists. Skipping IR generation with Model Optimizer." echo -ne "If you want to convert a model again, remove the entire ${ir_dir} folder. ${run_again}" fi # Step 4. Build samples -echo -ne "${dashes}" -printf "Build Inference Engine samples\n\n" +echo -ne "\n###############|| Build Inference Engine samples ||###############\n\n" OS_PATH=$(uname -m) NUM_THREADS="-j2" @@ -198,7 +172,7 @@ if [ "$OS_PATH" == "x86_64" ]; then fi samples_path="${INTEL_OPENVINO_DIR}/deployment_tools/inference_engine/samples/cpp" -build_dir="$HOME/inference_engine_samples_build" +build_dir="$HOME/inference_engine_cpp_samples_build" binaries_dir="${build_dir}/${OS_PATH}/Release" if [ -e "$build_dir/CMakeCache.txt" ]; then @@ -211,8 +185,7 @@ cmake -DCMAKE_BUILD_TYPE=Release "$samples_path" make $NUM_THREADS benchmark_app # Step 5. Run samples -echo -ne "${dashes}" -printf "Run Inference Engine benchmark app\n\n" +echo -ne "\n###############|| Run Inference Engine benchmark app ||###############\n\n" cd "$binaries_dir" @@ -220,6 +193,4 @@ cp -f "$ROOT_DIR/${model_name}.labels" "${ir_dir}/" print_and_run ./benchmark_app -d "$target" -i "$target_image_path" -m "${ir_dir}/${model_name}.xml" -pc "${sampleoptions[@]}" -echo -ne "${dashes}" - -printf "Inference Engine benchmark app completed successfully.\n\n" +echo -ne "\n###############|| Inference Engine benchmark app completed successfully ||###############\n\n" diff --git a/scripts/demo/demo_security_barrier_camera.bat b/scripts/demo/demo_security_barrier_camera.bat index 6e2e1b99bc6400..21db90e6d549b2 100644 --- a/scripts/demo/demo_security_barrier_camera.bat +++ b/scripts/demo/demo_security_barrier_camera.bat @@ -7,6 +7,7 @@ setlocal enabledelayedexpansion set TARGET=CPU set SAMPLE_OPTIONS= set BUILD_FOLDER=%USERPROFILE%\Documents\Intel\OpenVINO +set VENV_DIR=%USERPROFILE%\Documents\Intel\OpenVINO\venv_openvino :: command line arguments parsing :input_arguments_loop @@ -22,10 +23,12 @@ if not "%1"=="" ( shift ) if "%1"=="-help" ( - echo %~n0%~x0 is security barrier camera demo that showcases three models coming with the product + echo Security barrier camera demo that showcases three models coming with the product echo. echo Options: - echo -d name Specify the target device to infer on; CPU, GPU, FPGA, HDDL or MYRIAD are acceptable. Sample will look for a suitable plugin for device specified + echo -help Print help message + echo -d DEVICE Specify the target device to infer on; CPU, GPU, HDDL or MYRIAD are acceptable. Sample will look for a suitable plugin for device specified + echo -sample-options OPTIONS Specify command line arguments for the sample exit /b ) shift @@ -78,9 +81,22 @@ if not "%python_ver%"=="okay" ( ) :: install yaml python modules required for downloader.py -pip3 install --user -r "%ROOT_DIR%..\open_model_zoo\tools\downloader\requirements.in" -if ERRORLEVEL 1 GOTO errorHandling +if exist "%VENV_DIR%" ( + echo. + echo ###############^|^| Using the existing python virtual environment ^|^|############### + echo. +) else ( + echo. + echo ###############^|^| Creating the python virtual environment ^|^|############### + echo. + python -m venv "%VENV_DIR%" +) +call "%VENV_DIR%\Scripts\activate.bat" +python -m pip install -U pip +python -m pip install -r "%ROOT_DIR%..\open_model_zoo\tools\downloader\requirements.in" + +if ERRORLEVEL 1 GOTO errorHandling set models_path=%BUILD_FOLDER%\openvino_models\ir set models_cache=%BUILD_FOLDER%\openvino_models\cache diff --git a/scripts/demo/demo_security_barrier_camera.sh b/scripts/demo/demo_security_barrier_camera.sh index 36e09cab7ba9fe..982e7f57f3ce05 100755 --- a/scripts/demo/demo_security_barrier_camera.sh +++ b/scripts/demo/demo_security_barrier_camera.sh @@ -3,14 +3,21 @@ # Copyright (C) 2018-2021 Intel Corporation # SPDX-License-Identifier: Apache-2.0 +echo -ne "\e[0;33mWARNING: If you get an error when running the demo in the Docker container, you may need to install additional packages. To do this, run the container as root (-u 0) and run install_openvino_dependencies.sh script. If you get a package-independent error, try setting additional parameters using -sample-options.\e[0m\n" + ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]-$0}" )" && pwd )" +VENV_DIR="$HOME/venv_openvino" . "$ROOT_DIR/utils.sh" usage() { echo "Security barrier camera demo that showcases three models coming with the product" - echo "-d name specify the target device to infer on; CPU, GPU, FPGA, HDDL or MYRIAD are acceptable. Sample will look for a suitable plugin for device specified" - echo "-help print help message" + echo + echo "Options:" + echo " -help Print help message" + echo " -d DEVICE Specify the target device to infer on; CPU, GPU, HDDL or MYRIAD are acceptable. Sample will look for a suitable plugin for device specified" + echo " -sample-options OPTIONS Specify command line arguments for the sample" + echo exit 1 } @@ -44,11 +51,19 @@ esac shift done - target_image_path="$ROOT_DIR/car_1.bmp" run_again="Then run the script again\n\n" -dashes="\n\n###################################################\n\n" + +if [ -e "$ROOT_DIR/../../bin/setupvars.sh" ]; then + setupvars_path="$ROOT_DIR/../../bin/setupvars.sh" +else + echo -ne "Error: setupvars.sh is not found\n" +fi +if ! . "$setupvars_path" ; then + echo -ne "Unable to run ./setupvars.sh. Please check its presence. ${run_again}" + exit 1 +fi if [[ -f /etc/centos-release ]]; then DISTRO="centos" @@ -59,55 +74,27 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then fi if [[ $DISTRO == "centos" ]]; then - sudo -E yum install -y centos-release-scl epel-release - sudo -E yum install -y gcc gcc-c++ make glibc-static glibc-devel libstdc++-static libstdc++-devel libstdc++ libgcc \ - glibc-static.i686 glibc-devel.i686 libstdc++-static.i686 libstdc++.i686 libgcc.i686 cmake - - sudo -E rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm || true - sudo -E yum install -y epel-release - sudo -E yum install -y cmake ffmpeg gstreamer1 gstreamer1-plugins-base libusbx-devel - # check installed Python version if command -v python3.5 >/dev/null 2>&1; then python_binary=python3.5 - pip_binary=pip3.5 fi if command -v python3.6 >/dev/null 2>&1; then python_binary=python3.6 - pip_binary=pip3.6 - fi - if [ -z "$python_binary" ]; then - sudo -E yum install -y rh-python36 || true - . scl_source enable rh-python36 - python_binary=python3.6 - pip_binary=pip3.6 fi elif [[ $DISTRO == "ubuntu" ]]; then - sudo -E apt update - print_and_run sudo -E apt -y install build-essential python3-pip virtualenv cmake libcairo2-dev libpango1.0-dev libglib2.0-dev libgtk2.0-dev libswscale-dev libavcodec-dev libavformat-dev libgstreamer1.0-0 gstreamer1.0-plugins-base python_binary=python3 - pip_binary=pip3 - - system_ver=$(grep -i "DISTRIB_RELEASE" -f /etc/lsb-release | cut -d "=" -f2) - if [ "$system_ver" = "16.04" ]; then - sudo -E apt-get install -y libpng12-dev - else - sudo -E apt-get install -y libpng-dev - fi elif [[ "$OSTYPE" == "darwin"* ]]; then # check installed Python version - if command -v python3.7 >/dev/null 2>&1; then + if command -v python3.8 >/dev/null 2>&1; then + python_binary=python3.8 + elif command -v python3.7 >/dev/null 2>&1; then python_binary=python3.7 - pip_binary=pip3.7 elif command -v python3.6 >/dev/null 2>&1; then python_binary=python3.6 - pip_binary=pip3.6 elif command -v python3.5 >/dev/null 2>&1; then python_binary=python3.5 - pip_binary=pip3.5 else python_binary=python3 - pip_binary=pip3 fi fi @@ -116,30 +103,23 @@ if ! command -v $python_binary &>/dev/null; then exit 1 fi -if [[ $DISTRO == "macos" ]]; then - "$pip_binary" install -r "$ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in" +if [ -e "$VENV_DIR" ]; then + echo -ne "\n###############|| Using the existing python virtual environment ||###############\n\n" else - sudo -E "$pip_binary" install -r "$ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in" + echo -ne "\n###############|| Creating the python virtual environment ||###############\n\n" + "$python_binary" -m venv "$VENV_DIR" fi -if [ -e "$ROOT_DIR/../../bin/setupvars.sh" ]; then - setupvars_path="$ROOT_DIR/../../bin/setupvars.sh" -else - printf "Error: setupvars.sh is not found\n" -fi -if ! . "$setupvars_path" ; then - echo -ne "Unable to run ./setupvars.sh. Please check its presence. ${run_again}" - exit 1 -fi +. "$VENV_DIR/bin/activate" +python -m pip install -U pip +python -m pip install -r "$ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in" # Step 1. Downloading Intel models -echo -ne "${dashes}" -printf "Downloading Intel models\n\n" - +echo -ne "\n###############|| Downloading Intel models ||###############\n\n" target_precision="FP16" -printf "target_precision = %s\n" "${target_precision}" +echo -ne "target_precision = ${target_precision}\n" downloader_dir="${INTEL_OPENVINO_DIR}/deployment_tools/open_model_zoo/tools/downloader" @@ -150,19 +130,18 @@ models_cache="$HOME/openvino_models/cache" declare -a model_args while read -r model_opt model_name; do - model_subdir=$("$python_binary" "$downloader_dir/info_dumper.py" --name "$model_name" | - "$python_binary" -c 'import sys, json; print(json.load(sys.stdin)[0]["subdirectory"])') + model_subdir=$(python "$downloader_dir/info_dumper.py" --name "$model_name" | + python -c 'import sys, json; print(json.load(sys.stdin)[0]["subdirectory"])') model_path="$models_path/$model_subdir/$target_precision/$model_name" - print_and_run "$python_binary" "$downloader_path" --name "$model_name" --output_dir "$models_path" --cache_dir "$models_cache" + print_and_run python "$downloader_path" --name "$model_name" --output_dir "$models_path" --cache_dir "$models_cache" model_args+=("$model_opt" "${model_path}.xml") done < "$ROOT_DIR/demo_security_barrier_camera.conf" # Step 2. Build samples -echo -ne "${dashes}" -printf "Build Inference Engine demos\n\n" +echo -ne "\n###############|| Build Inference Engine demos ||###############\n\n" demos_path="${INTEL_OPENVINO_DIR}/deployment_tools/open_model_zoo/demos" @@ -189,13 +168,11 @@ cmake -DCMAKE_BUILD_TYPE=Release "$demos_path" make $NUM_THREADS security_barrier_camera_demo # Step 3. Run samples -echo -ne "${dashes}" -printf "Run Inference Engine security_barrier_camera demo\n\n" +echo -ne "\n###############|| Run Inference Engine security_barrier_camera demo ||###############\n\n" binaries_dir="${build_dir}/${OS_PATH}/Release" cd "$binaries_dir" print_and_run ./security_barrier_camera_demo -d "$target" -d_va "$target" -d_lpr "$target" -i "$target_image_path" "${model_args[@]}" "${sampleoptions[@]}" -echo -ne "${dashes}" -printf "Demo completed successfully.\n\n" +echo -ne "\n###############|| Demo completed successfully ||###############\n\n" diff --git a/scripts/demo/demo_squeezenet_download_convert_run.bat b/scripts/demo/demo_squeezenet_download_convert_run.bat index ad317ab4fd9f3e..c0bd34614dad0a 100644 --- a/scripts/demo/demo_squeezenet_download_convert_run.bat +++ b/scripts/demo/demo_squeezenet_download_convert_run.bat @@ -6,6 +6,7 @@ setlocal enabledelayedexpansion set TARGET=CPU set BUILD_FOLDER=%USERPROFILE%\Documents\Intel\OpenVINO +set VENV_DIR=%USERPROFILE%\Documents\Intel\OpenVINO\venv_openvino :: command line arguments parsing :input_arguments_loop @@ -21,10 +22,12 @@ if not "%1"=="" ( shift ) if "%1"=="-help" ( - echo %~n0%~x0 is classification demo using public SqueezeNet topology + echo Classification demo using public SqueezeNet topology echo. echo Options: - echo -d name Specify the target device to infer on; CPU, GPU, FPGA, HDDL or MYRIAD are acceptable. Sample will look for a suitable plugin for device specified + echo -help Print help message + echo -d DEVICE Specify the target device to infer on; CPU, GPU, HDDL or MYRIAD are acceptable. Sample will look for a suitable plugin for device specified + echo -sample-options OPTIONS Specify command line arguments for the sample exit /b ) shift @@ -84,7 +87,21 @@ if not "%python_ver%"=="okay" ( ) :: install yaml python modules required for downloader.py -pip3 install --user -r "%ROOT_DIR%..\open_model_zoo\tools\downloader\requirements.in" +if exist "%VENV_DIR%" ( + echo. + echo ###############^|^| Using the existing python virtual environment ^|^|############### + echo. +) else ( + echo. + echo ###############^|^| Creating the python virtual environment ^|^|############### + echo. + python -m venv "%VENV_DIR%" +) + +call "%VENV_DIR%\Scripts\activate.bat" +python -m pip install -U pip +python -m pip install -r "%ROOT_DIR%..\open_model_zoo\tools\downloader\requirements.in" + if ERRORLEVEL 1 GOTO errorHandling set downloader_dir=%INTEL_OPENVINO_DIR%\deployment_tools\open_model_zoo\tools\downloader @@ -117,8 +134,8 @@ echo. echo ###############^|^| Install Model Optimizer prerequisites ^|^|############### echo. CALL :delay 3 -cd /d "%INTEL_OPENVINO_DIR%\deployment_tools\model_optimizer\install_prerequisites" -call install_prerequisites_caffe.bat +cd /d "%INTEL_OPENVINO_DIR%\deployment_tools\model_optimizer" +python -m pip install -r requirements.txt if ERRORLEVEL 1 GOTO errorHandling CALL :delay 7 @@ -205,7 +222,7 @@ if "!MSBUILD_BIN!" == "" ( GOTO errorHandling ) -set "SOLUTION_DIR64=%BUILD_FOLDER%\inference_engine_samples_build" +set "SOLUTION_DIR64=%BUILD_FOLDER%\inference_engine_cpp_samples_build" echo Creating Visual Studio !MSBUILD_VERSION! %PLATFORM% files in %SOLUTION_DIR64%... && ^ if exist "%SOLUTION_DIR64%\CMakeCache.txt" del "%SOLUTION_DIR64%\CMakeCache.txt" diff --git a/scripts/demo/demo_squeezenet_download_convert_run.sh b/scripts/demo/demo_squeezenet_download_convert_run.sh index 24fc26c335c9bd..7f8427db8b9991 100755 --- a/scripts/demo/demo_squeezenet_download_convert_run.sh +++ b/scripts/demo/demo_squeezenet_download_convert_run.sh @@ -3,14 +3,21 @@ # Copyright (C) 2018-2021 Intel Corporation # SPDX-License-Identifier: Apache-2.0 +echo -ne "\e[0;33mWARNING: If you get an error when running the demo in the Docker container, you may need to install additional packages. To do this, run the container as root (-u 0) and run install_openvino_dependencies.sh script. If you get a package-independent error, try setting additional parameters using -sample-options.\e[0m\n" + ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]-$0}" )" && pwd )" +VENV_DIR="$HOME/venv_openvino" . "$ROOT_DIR/utils.sh" usage() { echo "Classification demo using public SqueezeNet topology" - echo "-d name specify the target device to infer on; CPU, GPU, FPGA, HDDL or MYRIAD are acceptable. Sample will look for a suitable plugin for device specified" - echo "-help print help message" + echo + echo "Options:" + echo " -help Print help message" + echo " -d DEVICE Specify the target device to infer on; CPU, GPU, HDDL or MYRIAD are acceptable. Sample will look for a suitable plugin for device specified" + echo " -sample-options OPTIONS Specify command line arguments for the sample" + echo exit 1 } @@ -46,7 +53,7 @@ done target_precision="FP16" -printf "target_precision = %s\n" "${target_precision}" +echo -ne "target_precision = ${target_precision}\n" models_path="$HOME/openvino_models/models" models_cache="$HOME/openvino_models/cache" @@ -57,13 +64,11 @@ model_name="squeezenet1.1" target_image_path="$ROOT_DIR/car.png" run_again="Then run the script again\n\n" -dashes="\n\n###################################################\n\n" - if [ -e "$ROOT_DIR/../../bin/setupvars.sh" ]; then setupvars_path="$ROOT_DIR/../../bin/setupvars.sh" else - printf "Error: setupvars.sh is not found\n" + echo -ne "Error: setupvars.sh is not found\n" fi if ! . "$setupvars_path" ; then @@ -71,14 +76,6 @@ if ! . "$setupvars_path" ; then exit 1 fi -# Step 1. Download the Caffe model and the prototxt of the model -echo -ne "${dashes}" -printf "\n\nDownloading the Caffe model and the prototxt" - -cur_path=$PWD - -printf "\nInstalling dependencies\n" - if [[ -f /etc/centos-release ]]; then DISTRO="centos" elif [[ -f /etc/lsb-release ]]; then @@ -86,55 +83,27 @@ elif [[ -f /etc/lsb-release ]]; then fi if [[ $DISTRO == "centos" ]]; then - sudo -E yum install -y centos-release-scl epel-release - sudo -E yum install -y gcc gcc-c++ make glibc-static glibc-devel libstdc++-static libstdc++-devel libstdc++ libgcc \ - glibc-static.i686 glibc-devel.i686 libstdc++-static.i686 libstdc++.i686 libgcc.i686 cmake - - sudo -E rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm || true - sudo -E yum install -y epel-release - sudo -E yum install -y cmake ffmpeg gstreamer1 gstreamer1-plugins-base libusbx-devel - # check installed Python version if command -v python3.5 >/dev/null 2>&1; then python_binary=python3.5 - pip_binary=pip3.5 fi if command -v python3.6 >/dev/null 2>&1; then python_binary=python3.6 - pip_binary=pip3.6 - fi - if [ -z "$python_binary" ]; then - sudo -E yum install -y rh-python36 || true - . scl_source enable rh-python36 - python_binary=python3.6 - pip_binary=pip3.6 fi elif [[ $DISTRO == "ubuntu" ]]; then - sudo -E apt update - print_and_run sudo -E apt -y install build-essential python3-pip virtualenv cmake libcairo2-dev libpango1.0-dev libglib2.0-dev libgtk2.0-dev libswscale-dev libavcodec-dev libavformat-dev libgstreamer1.0-0 gstreamer1.0-plugins-base python_binary=python3 - pip_binary=pip3 - - system_ver=$(grep -i "DISTRIB_RELEASE" -f /etc/lsb-release | cut -d "=" -f2) - if [ "$system_ver" = "16.04" ]; then - sudo -E apt-get install -y libpng12-dev - else - sudo -E apt-get install -y libpng-dev - fi elif [[ "$OSTYPE" == "darwin"* ]]; then # check installed Python version - if command -v python3.7 >/dev/null 2>&1; then + if command -v python3.8 >/dev/null 2>&1; then + python_binary=python3.8 + elif command -v python3.7 >/dev/null 2>&1; then python_binary=python3.7 - pip_binary=pip3.7 elif command -v python3.6 >/dev/null 2>&1; then python_binary=python3.6 - pip_binary=pip3.6 elif command -v python3.5 >/dev/null 2>&1; then python_binary=python3.5 - pip_binary=pip3.5 else python_binary=python3 - pip_binary=pip3 fi fi @@ -143,47 +112,52 @@ if ! command -v $python_binary &>/dev/null; then exit 1 fi -if [[ "$OSTYPE" == "darwin"* ]]; then - "$pip_binary" install -r "$ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in" +if [ -e "$VENV_DIR" ]; then + echo -ne "\n###############|| Using the existing python virtual environment ||###############\n\n" else - sudo -E "$pip_binary" install -r "$ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in" + echo -ne "\n###############|| Creating the python virtual environment ||###############\n\n" + "$python_binary" -m venv "$VENV_DIR" fi +. "$VENV_DIR/bin/activate" +python -m pip install -U pip +python -m pip install -r "$ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in" + +# Step 1. Download the Caffe model and the prototxt of the model +echo -ne "\n###############|| Downloading the Caffe model and the prototxt ||###############\n\n" + downloader_dir="${INTEL_OPENVINO_DIR}/deployment_tools/open_model_zoo/tools/downloader" -model_dir=$("$python_binary" "$downloader_dir/info_dumper.py" --name "$model_name" | - "$python_binary" -c 'import sys, json; print(json.load(sys.stdin)[0]["subdirectory"])') +model_dir=$(python "$downloader_dir/info_dumper.py" --name "$model_name" | + python -c 'import sys, json; print(json.load(sys.stdin)[0]["subdirectory"])') downloader_path="$downloader_dir/downloader.py" -print_and_run "$python_binary" "$downloader_path" --name "$model_name" --output_dir "${models_path}" --cache_dir "${models_cache}" +print_and_run python "$downloader_path" --name "$model_name" --output_dir "${models_path}" --cache_dir "${models_cache}" ir_dir="${irs_path}/${model_dir}/${target_precision}" if [ ! -e "$ir_dir" ]; then # Step 2. Configure Model Optimizer - echo -ne "${dashes}" - printf "Install Model Optimizer dependencies\n\n" - cd "${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/install_prerequisites" - . ./install_prerequisites.sh caffe - cd "$cur_path" + echo -ne "\n###############|| Install Model Optimizer dependencies ||###############\n\n" + cd "${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer" + python -m pip install -r requirements.txt + cd "$PWD" # Step 3. Convert a model with Model Optimizer - echo -ne "${dashes}" - printf "Convert a model with Model Optimizer\n\n" + echo -ne "\n###############|| Convert a model with Model Optimizer ||###############\n\n" mo_path="${INTEL_OPENVINO_DIR}/deployment_tools/model_optimizer/mo.py" export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp - print_and_run "$python_binary" "$downloader_dir/converter.py" --mo "$mo_path" --name "$model_name" -d "$models_path" -o "$irs_path" --precisions "$target_precision" + print_and_run python "$downloader_dir/converter.py" --mo "$mo_path" --name "$model_name" -d "$models_path" -o "$irs_path" --precisions "$target_precision" else - printf "\n\nTarget folder %s already exists. Skipping IR generation with Model Optimizer." "${ir_dir}" + echo -ne "\n\nTarget folder ${ir_dir} already exists. Skipping IR generation with Model Optimizer." echo -ne "If you want to convert a model again, remove the entire ${ir_dir} folder. ${run_again}" fi # Step 4. Build samples -echo -ne "${dashes}" -printf "Build Inference Engine samples\n\n" +echo -ne "\n###############|| Build Inference Engine samples ||###############\n\n" OS_PATH=$(uname -m) NUM_THREADS="-j2" @@ -194,7 +168,7 @@ if [ "$OS_PATH" == "x86_64" ]; then fi samples_path="${INTEL_OPENVINO_DIR}/deployment_tools/inference_engine/samples/cpp" -build_dir="$HOME/inference_engine_samples_build" +build_dir="$HOME/inference_engine_cpp_samples_build" binaries_dir="${build_dir}/${OS_PATH}/Release" if [ -e "$build_dir/CMakeCache.txt" ]; then @@ -207,8 +181,7 @@ cmake -DCMAKE_BUILD_TYPE=Release "$samples_path" make $NUM_THREADS classification_sample_async # Step 5. Run samples -echo -ne "${dashes}" -printf "Run Inference Engine classification sample\n\n" +echo -ne "\n###############|| Run Inference Engine classification sample ||###############\n\n" cd "$binaries_dir" @@ -216,5 +189,4 @@ cp -f "$ROOT_DIR/${model_name}.labels" "${ir_dir}/" print_and_run ./classification_sample_async -d "$target" -i "$target_image_path" -m "${ir_dir}/${model_name}.xml" "${sampleoptions[@]}" -echo -ne "${dashes}" -printf "Demo completed successfully.\n\n" +echo -ne "\n###############|| Demo completed successfully ||###############\n\n" diff --git a/tests/conditional_compilation/test_config.yml b/tests/conditional_compilation/test_config.yml index ac03e092fe1c14..a9f8a463d7a58d 100644 --- a/tests/conditional_compilation/test_config.yml +++ b/tests/conditional_compilation/test_config.yml @@ -7,8 +7,8 @@ path: ${TESTDATA}/models/mobilenet_v2_1.0_224/mobilenet_v2_1.0_224_i8.xml - model: path: ${TESTDATA}/models/inception_v3/inception_v3_i8.xml -- model: - path: ${TESTDATA}/models/resnet_v1_50/resnet_v1_50_i8.xml +#- model: +# path: ${TESTDATA}/models/resnet_v1_50/resnet_v1_50_i8.xml - model: path: ${TESTDATA}/models/test_model/test_model_fp16.xml - model: diff --git a/tests/stress_tests/scripts/run_memcheck.py b/tests/stress_tests/scripts/run_memcheck.py index b8f32b4c5890d0..561ff1b91273f1 100755 --- a/tests/stress_tests/scripts/run_memcheck.py +++ b/tests/stress_tests/scripts/run_memcheck.py @@ -9,24 +9,22 @@ """ import argparse -from glob import glob import json import logging import os import subprocess import sys -from pathlib import Path +from glob import glob +from compare_memcheck_2_runs import compare_memcheck_2_runs, \ + get_memcheck_records, get_db_memcheck_records +# Database arguments +from memcheck_upload import DATABASE, DB_COLLECTIONS from memcheck_upload import create_memcheck_records, \ upload_memcheck_records, \ create_memcheck_report, \ metadata_from_manifest, \ info_from_test_config -from compare_memcheck_2_runs import compare_memcheck_2_runs, \ - get_memcheck_records, get_db_memcheck_records - -# Database arguments -from memcheck_upload import DATABASE, DB_COLLECTIONS def run(args, log=None, verbose=True): @@ -142,12 +140,12 @@ def main(): else: if list(glob(os.path.join(args.output_dir, '**', '*.log'), recursive=True)): logging.error( - 'Output directory %s already has test logs.' \ + 'Output directory %s already has test logs.' 'Please specify an empty directory for output logs', args.output_dir) sys.exit(1) - returncode, _ = run([sys.executable, args.gtest_parallel] + + return_code, _ = run([sys.executable, args.gtest_parallel] + (['--output_dir', f'{args.output_dir}'] if args.output_dir else []) + (['--workers', f'{args.workers}'] if args.workers else []) + (['--timeout', f'{args.timeout}'] if args.timeout else []) + @@ -189,8 +187,11 @@ def main(): # create timeline report if args.timeline_report: - create_memcheck_report(records, args.db_url, args.db_collection, args.timeline_report) - logging.info('Created memcheck timeline report %s', args.timeline_report) + try: + create_memcheck_report(records, args.db_url, args.db_collection, args.timeline_report) + logging.info('Created memcheck timeline report %s', args.timeline_report) + except Exception as ex: + logging.warning(f'Failed to create timeline report: {ex}') # compare runs and prepare report if args.compare: @@ -203,9 +204,9 @@ def main(): db_name=DATABASE, db_url=args.db_url) compare_retcode = compare_memcheck_2_runs(cur_values=records, references=references, output_file=args.comparison_report) - returncode = returncode if returncode else compare_retcode + return_code = return_code if return_code else compare_retcode - sys.exit(returncode) + sys.exit(return_code) if __name__ == "__main__": diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 5476b1d9cae2af..bda132a4a5179e 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -80,7 +80,7 @@ function(add_gtest_libraries) endif() set(BUILD_SHARED_LIBS OFF) - set(INSTALL_GTEST OFF) + set(INSTALL_GTEST OFF CACHE BOOL "" FORCE) add_subdirectory(gtest EXCLUDE_FROM_ALL) get_target_property(gtest_include_dirs gtest INTERFACE_INCLUDE_DIRECTORIES) diff --git a/ngraph/frontend/cmake_static_protobuf/CMakeLists.txt b/thirdparty/cmake_static_protobuf/CMakeLists.txt similarity index 89% rename from ngraph/frontend/cmake_static_protobuf/CMakeLists.txt rename to thirdparty/cmake_static_protobuf/CMakeLists.txt index 4c37abac25ddfe..121b20659ce816 100644 --- a/ngraph/frontend/cmake_static_protobuf/CMakeLists.txt +++ b/thirdparty/cmake_static_protobuf/CMakeLists.txt @@ -16,7 +16,7 @@ set(BUILD_SHARED_LIBS OFF) set(BUILD_STANDALONE_STATIC ON) set(USE_STATIC_PROTOBUF ON) -include(../../cmake/external_protobuf.cmake) +add_subdirectory(../protobuf ${CMAKE_BINARY_DIR}/_deps/static-protobuf) set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_OLD}) set(BUILD_STANDALONE_STATIC ${BUILD_STANDALONE_STATIC_OLD}) diff --git a/thirdparty/ittapi/CMakeLists.txt b/thirdparty/ittapi/CMakeLists.txt index 9cec9b6126a80e..c50ff92fa272b3 100644 --- a/thirdparty/ittapi/CMakeLists.txt +++ b/thirdparty/ittapi/CMakeLists.txt @@ -11,18 +11,7 @@ if(ENABLE_PROFILING_ITT) message(WARNING "Profiling option enabled, but no ITT library was found under INTEL_VTUNE_DIR") endif() else() - include(FetchContent) - FetchContent_Declare( - ext_ittapi - GIT_REPOSITORY https://github.com/intel/ittapi.git - GIT_TAG v3.18.6 - ) - - FetchContent_GetProperties(ext_ittapi) - if(NOT ext_ittapi_POPULATED) - FetchContent_Populate(ext_ittapi) - add_subdirectory(${ext_ittapi_SOURCE_DIR} ${ext_ittapi_BINARY_DIR}) - endif() + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ittapi ${CMAKE_BINARY_DIR}/_deps/ittapi) target_compile_definitions(ittnotify INTERFACE ENABLE_PROFILING_ITT) if (UNIX) diff --git a/thirdparty/ittapi/ittapi b/thirdparty/ittapi/ittapi new file mode 160000 index 00000000000000..5416ee060ad51f --- /dev/null +++ b/thirdparty/ittapi/ittapi @@ -0,0 +1 @@ +Subproject commit 5416ee060ad51fd9eac3d6fcd4c7274c1d3370d8 diff --git a/ngraph/cmake/external_onnx.cmake b/thirdparty/onnx/CMakeLists.txt similarity index 51% rename from ngraph/cmake/external_onnx.cmake rename to thirdparty/onnx/CMakeLists.txt index a345e62c3e4a65..9c212d03a01d10 100644 --- a/ngraph/cmake/external_onnx.cmake +++ b/thirdparty/onnx/CMakeLists.txt @@ -2,31 +2,11 @@ # SPDX-License-Identifier: Apache-2.0 # -include(FetchContent) - -#------------------------------------------------------------------------------ -# ONNX.proto definition version -#------------------------------------------------------------------------------ - -set(ONNX_VERSION 1.8.1) - #------------------------------------------------------------------------------ -# Download and install libonnx ... +# Configure and install libonnx ... #------------------------------------------------------------------------------ -set(ONNX_GIT_REPO_URL https://github.com/onnx/onnx.git) -set(ONNX_GIT_BRANCH rel-${ONNX_VERSION}) set(NGRAPH_ONNX_NAMESPACE ngraph_onnx) -set(ONNX_PATCH_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/patches/onnx_patch.diff") - -FetchContent_Declare( - ext_onnx - GIT_REPOSITORY ${ONNX_GIT_REPO_URL} - GIT_TAG ${ONNX_GIT_BRANCH} - GIT_SHALLOW TRUE - # apply patch to fix problems with symbols visibility for MSVC - PATCH_COMMAND git reset --hard HEAD && git apply --ignore-space-change --ignore-whitespace --verbose ${ONNX_PATCH_FILE} -) macro(onnx_set_target_properties) target_include_directories(onnx SYSTEM PRIVATE "${Protobuf_INCLUDE_DIRS}") @@ -55,19 +35,13 @@ macro(onnx_set_target_properties) export(TARGETS onnx onnx_proto NAMESPACE ngraph:: APPEND FILE "${NGRAPH_TARGETS_FILE}") endmacro() -FetchContent_GetProperties(ext_onnx) -if(NOT ext_onnx_POPULATED) - FetchContent_Populate(ext_onnx) - set(ONNX_USE_PROTOBUF_SHARED_LIBS ${BUILD_SHARED_LIBS} CACHE BOOL "Use dynamic protobuf by ONNX library") - set(ONNX_NAMESPACE ${NGRAPH_ONNX_NAMESPACE}) - set(ONNX_USE_LITE_PROTO ${NGRAPH_USE_PROTOBUF_LITE} CACHE BOOL "Use protobuf lite for ONNX library") - set(ONNX_ML ON CACHE BOOL "Use ONNX ML") - if(CMAKE_CROSSCOMPILING) - set(ONNX_CUSTOM_PROTOC_EXECUTABLE ${SYSTEM_PROTOC}) - endif() - - add_subdirectory(${ext_onnx_SOURCE_DIR} ${ext_onnx_BINARY_DIR} EXCLUDE_FROM_ALL) - onnx_set_target_properties() -else() - onnx_set_target_properties() +set(ONNX_USE_PROTOBUF_SHARED_LIBS ${BUILD_SHARED_LIBS} CACHE BOOL "Use dynamic protobuf by ONNX library") +set(ONNX_NAMESPACE ${NGRAPH_ONNX_NAMESPACE}) +set(ONNX_USE_LITE_PROTO ${NGRAPH_USE_PROTOBUF_LITE} CACHE BOOL "Use protobuf lite for ONNX library") +set(ONNX_ML ON CACHE BOOL "Use ONNX ML") +if(CMAKE_CROSSCOMPILING) + set(ONNX_CUSTOM_PROTOC_EXECUTABLE ${SYSTEM_PROTOC}) endif() + +add_subdirectory(onnx EXCLUDE_FROM_ALL) +onnx_set_target_properties() diff --git a/thirdparty/onnx/onnx b/thirdparty/onnx/onnx new file mode 160000 index 00000000000000..0807930c7f46f3 --- /dev/null +++ b/thirdparty/onnx/onnx @@ -0,0 +1 @@ +Subproject commit 0807930c7f46f3bac1f520c4a2e78710aa5d0af7 diff --git a/thirdparty/protobuf/CMakeLists.txt b/thirdparty/protobuf/CMakeLists.txt new file mode 100644 index 00000000000000..611e26d200bed0 --- /dev/null +++ b/thirdparty/protobuf/CMakeLists.txt @@ -0,0 +1,125 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# + +#------------------------------------------------------------------------------ +# Configure and install Google Protobuf ... +#------------------------------------------------------------------------------ + +set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE OFF) + +if (MSVC) + set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "") +endif() + +if(CMAKE_CROSSCOMPILING) + find_program(SYSTEM_PROTOC protoc PATHS ENV PATH) + + if(SYSTEM_PROTOC) + execute_process( + COMMAND ${SYSTEM_PROTOC} --version + OUTPUT_VARIABLE PROTOC_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + string(REPLACE " " ";" PROTOC_VERSION ${PROTOC_VERSION}) + list(GET PROTOC_VERSION -1 PROTOC_VERSION) + + message("Detected system protoc version: ${PROTOC_VERSION}") + else() + message(FATAL_ERROR "System Protobuf is needed while cross-compiling") + endif() + + set(protobuf_BUILD_PROTOC_BINARIES OFF CACHE BOOL "Build libprotoc and protoc compiler" FORCE) +endif() + +if (CMAKE_GENERATOR STREQUAL "Ninja") + set(MAKE_UTIL make) +else() + set(MAKE_UTIL $(MAKE)) +endif() + +set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build tests") +set(protobuf_WITH_ZLIB OFF CACHE BOOL "Build with zlib support") + +if (NOT BUILD_STANDALONE_STATIC) + add_subdirectory(protobuf/cmake EXCLUDE_FROM_ALL) + get_directory_property(protobuf_VERSION DIRECTORY protobuf/cmake DEFINITION protobuf_VERSION) +endif() +if (USE_STATIC_PROTOBUF) + include(FetchContent) + FetchContent_Declare( + ext_protobuf_static + URL ${CMAKE_CURRENT_SOURCE_DIR}/protobuf + ) + FetchContent_GetProperties(ext_protobuf_static) + if((NOT ext_protobuf_static_POPULATED) AND BUILD_STANDALONE_STATIC) + FetchContent_Populate(ext_protobuf_static) + add_subdirectory(${ext_protobuf_static_SOURCE_DIR}/cmake ${ext_protobuf_static_BINARY_DIR} EXCLUDE_FROM_ALL) + get_directory_property(protobuf_VERSION DIRECTORY ${ext_protobuf_static_SOURCE_DIR}/cmake DEFINITION protobuf_VERSION) + endif() +endif() + +if (BUILD_STANDALONE_STATIC) + set(Protobuf_INCLUDE_DIRS ${ext_protobuf_static_SOURCE_DIR}/src) +else() + set(Protobuf_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/protobuf/src) +endif() + +if(NGRAPH_USE_PROTOBUF_LITE) + set(Protobuf_LIBRARIES libprotobuf-lite) +else() + set(Protobuf_LIBRARIES libprotobuf) +endif() + +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$") + set(_proto_libs ${Protobuf_LIBRARIES}) + if(TARGET libprotoc) + list(APPEND _proto_libs libprotoc) + target_compile_options(libprotoc PRIVATE -Wno-all -Wno-unused-variable) + endif() + set_target_properties(${_proto_libs} PROPERTIES + CXX_VISIBILITY_PRESET default + C_VISIBILITY_PRESET default + VISIBILITY_INLINES_HIDDEN OFF) + foreach(target libprotobuf libprotobuf-lite) + target_compile_options(${target} + PRIVATE -Wno-all -Wno-unused-variable -Wno-inconsistent-missing-override + PUBLIC -Wno-undef) + endforeach() +endif() + +if(NGRAPH_USE_PROTOBUF_LITE) + # if only libprotobuf-lite is used, both libprotobuf and libprotobuf-lite are built + # libprotoc target needs symbols from libprotobuf, even in libprotobuf-lite configuration + set_target_properties(libprotobuf PROPERTIES + CXX_VISIBILITY_PRESET default + C_VISIBILITY_PRESET default + VISIBILITY_INLINES_HIDDEN OFF) +endif() + +if(protobuf_VERSION VERSION_LESS "3.9" AND NGRAPH_USE_PROTOBUF_LITE) + message(FATAL_ERROR "Minimum supported version of protobuf-lite library is 3.9.0") +endif() + +if(ENABLE_LTO AND protobuf_VERSION VERSION_GREATER_EQUAL "3.8") + message(WARNING "Protobuf in version 3.8.0+ can throw runtime exceptions if LTO is enabled.") +endif() + +if(CMAKE_CROSSCOMPILING AND NOT PROTOC_VERSION VERSION_EQUAL protobuf_VERSION) + message(WARNING "system protobuf version does not match with the compiled one, please update system protobuf or submodule") +endif() + +if (NOT BUILD_STANDALONE_STATIC) + message("NGRAPH_INSTALL_LIB = ${NGRAPH_INSTALL_LIB}") + install(TARGETS ${Protobuf_LIBRARIES} + RUNTIME DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph + ARCHIVE DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph + LIBRARY DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph) + export(TARGETS ${Protobuf_LIBRARIES} NAMESPACE ngraph:: APPEND FILE "${NGRAPH_TARGETS_FILE}") +endif() + +# forward variables used in the other places +set(SYSTEM_PROTOC ${SYSTEM_PROTOC} PARENT_SCOPE) +set(Protobuf_LIBRARIES ${Protobuf_LIBRARIES} PARENT_SCOPE) +set(Protobuf_INCLUDE_DIRS ${Protobuf_INCLUDE_DIRS} PARENT_SCOPE) diff --git a/thirdparty/protobuf/protobuf b/thirdparty/protobuf/protobuf new file mode 160000 index 00000000000000..52b2447247f535 --- /dev/null +++ b/thirdparty/protobuf/protobuf @@ -0,0 +1 @@ +Subproject commit 52b2447247f535663ac1c292e088b4b27d2910ef