Merge branch 'master' into sy/ilyachur/draft_dynamic_plugin_rebased

This commit is contained in:
Steve Yoo 2021-09-13 09:59:44 +09:00
commit fe57d0faa6
301 changed files with 2353 additions and 2226 deletions

View File

@ -72,7 +72,7 @@ jobs:
workingDirectory: $(WORK_DIR) workingDirectory: $(WORK_DIR)
displayName: 'Install dependencies' displayName: 'Install dependencies'
- script: ngraph/python/tests/test_onnx/model_zoo_preprocess.sh -d $(MODELS_DIR)/models_data -o -s "$(ONNX_MODEL_ZOO_SHA)" - script: runtime/bindings/python/tests/test_onnx/model_zoo_preprocess.sh -d $(MODELS_DIR)/models_data -o -s "$(ONNX_MODEL_ZOO_SHA)"
displayName: 'Update models' displayName: 'Update models'
condition: ne(variables['BUILD_TYPE'], 'Debug') condition: ne(variables['BUILD_TYPE'], 'Debug')

View File

@ -74,8 +74,8 @@ RUN cmake .. \
RUN make -j $(nproc) install RUN make -j $(nproc) install
# Run tests via tox # Run tests via tox
WORKDIR /openvino/ngraph/python WORKDIR /openvino/runtime/bindings/python
ENV ngraph_DIR=/openvino/dist/deployment_tools/ngraph ENV OpenVINO_DIR=/openvino/dist/deployment_tools/inference_engine/share
ENV LD_LIBRARY_PATH=/openvino/dist/deployment_tools/ngraph/lib ENV LD_LIBRARY_PATH=/openvino/dist/deployment_tools/ngraph/lib
ENV PYTHONPATH=/openvino/bin/intel64/${BUILD_TYPE}/lib/python_api/python3.8:${PYTHONPATH} ENV PYTHONPATH=/openvino/bin/intel64/${BUILD_TYPE}/lib/python_api/python3.8:${PYTHONPATH}
CMD tox CMD tox

View File

@ -94,7 +94,7 @@ def prepare_repository(String workdir) {
def updateModels() { def updateModels() {
sh """ sh """
./ngraph/python/tests/test_onnx/model_zoo_preprocess.sh -d ${HOME}/ONNX_CI/models_data -o -s ${ONNX_MODEL_ZOO_SHA} ./runtime/bindings/python/tests/test_onnx/model_zoo_preprocess.sh -d ${HOME}/ONNX_CI/models_data -o -s ${ONNX_MODEL_ZOO_SHA}
""" """
} }

View File

@ -4,7 +4,7 @@ version: 2
updates: updates:
# Enable version updates for nGraph Python API # Enable version updates for nGraph Python API
- package-ecosystem: pip - package-ecosystem: pip
directory: "/ngraph/python" directory: "/runtime/bindings/python"
schedule: schedule:
interval: weekly interval: weekly
day: monday day: monday

4
.gitmodules vendored
View File

@ -44,8 +44,8 @@
[submodule "thirdparty/protobuf"] [submodule "thirdparty/protobuf"]
path = thirdparty/protobuf/protobuf path = thirdparty/protobuf/protobuf
url = https://github.com/protocolbuffers/protobuf.git url = https://github.com/protocolbuffers/protobuf.git
[submodule "ngraph/python/pybind11"] [submodule "runtime/bindings/python/thirdparty/pybind11"]
path = ngraph/python/pybind11 path = runtime/bindings/python/thirdparty/pybind11
url = https://github.com/pybind/pybind11.git url = https://github.com/pybind/pybind11.git
[submodule "thirdparty/ittapi/ittapi"] [submodule "thirdparty/ittapi/ittapi"]
path = thirdparty/ittapi/ittapi path = thirdparty/ittapi/ittapi

View File

@ -33,6 +33,7 @@ message (STATUS "CMAKE_BUILD_TYPE ...................... " ${CMAKE_BUILD_TYPE})
# remove file with exported developer targets to force its regeneration # remove file with exported developer targets to force its regeneration
file(REMOVE "${CMAKE_BINARY_DIR}/InferenceEngineTargets.cmake") file(REMOVE "${CMAKE_BINARY_DIR}/InferenceEngineTargets.cmake")
file(REMOVE "${CMAKE_BINARY_DIR}/OpenVINOTargets.cmake")
foreach(component IN LISTS openvino_export_components) foreach(component IN LISTS openvino_export_components)
file(REMOVE "${CMAKE_BINARY_DIR}/${component}_dev_targets.cmake") file(REMOVE "${CMAKE_BINARY_DIR}/${component}_dev_targets.cmake")
unset(${component} CACHE) unset(${component} CACHE)
@ -83,6 +84,8 @@ include(cmake/test_model_zoo.cmake)
add_subdirectory(thirdparty) add_subdirectory(thirdparty)
add_subdirectory(openvino) add_subdirectory(openvino)
add_subdirectory(ngraph) add_subdirectory(ngraph)
add_subdirectory(runtime)
add_subdirectory(inference-engine) add_subdirectory(inference-engine)
# for Template plugin # for Template plugin

View File

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

View File

@ -111,6 +111,25 @@ _ie_find_dependency(ngraph
if(NOT TARGET inference_engine) if(NOT TARGET inference_engine)
set(_ie_as_external_package ON) set(_ie_as_external_package ON)
include("${CMAKE_CURRENT_LIST_DIR}/InferenceEngineTargets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/InferenceEngineTargets.cmake")
# create targets with old names for compatibility
if(TARGET IE::runtime AND NOT TARGET IE::inference_engine)
add_library(IE::inference_engine INTERFACE IMPORTED)
set_target_properties(IE::inference_engine PROPERTIES
INTERFACE_LINK_LIBRARIES IE::runtime)
endif()
if(TARGET IE::core AND NOT TARGET ngraph::ngraph)
add_library(IE::ngraph INTERFACE IMPORTED)
set_target_properties(IE::ngraph PROPERTIES
INTERFACE_LINK_LIBRARIES IE::core)
endif()
if(TARGET IE::runtime::c AND NOT TARGET IE::inference_engine_c_api)
add_library(IE::inference_engine_c_api INTERFACE IMPORTED)
set_target_properties(IE::inference_engine_c_api PROPERTIES
INTERFACE_LINK_LIBRARIES IE::runtime::c)
endif()
endif() endif()
# mark components as available # mark components as available

View File

@ -44,10 +44,17 @@ find_dependency(InferenceEngine
NO_CMAKE_FIND_ROOT_PATH NO_CMAKE_FIND_ROOT_PATH
NO_DEFAULT_PATH) NO_DEFAULT_PATH)
find_dependency(OpenVINO
PATHS "${CMAKE_CURRENT_LIST_DIR}"
NO_CMAKE_FIND_ROOT_PATH
NO_DEFAULT_PATH)
# WA for cmake: it exports ngraph as IE::ngraph in the IE export list # WA for cmake: it exports ngraph as IE::ngraph in the IE export list
# while we already have ngraph export in its own export list as ngraph::ngraph # while we already have ngraph export in its own export list as ngraph::ngraph
set_property(TARGET ngraph::ngraph PROPERTY IMPORTED_GLOBAL TRUE) if(TARGET ngraph::ngraph AND NOT TARGET IE::ngraph)
add_library(IE::ngraph ALIAS ngraph::ngraph) add_library(IE::ngraph INTERFACE IMPORTED)
set_target_properties(IE::ngraph PROPERTIES INTERFACE_LINK_LIBRARIES ngraph::ngraph)
endif()
foreach(component @openvino_export_components@) foreach(component @openvino_export_components@)
include("${CMAKE_CURRENT_LIST_DIR}/${component}_dev_targets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/${component}_dev_targets.cmake")

View File

@ -0,0 +1,21 @@
# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
set(PACKAGE_VERSION_MAJOR @IE_VERSION_MAJOR@)
set(PACKAGE_VERSION_MINOR @IE_VERSION_MINOR@)
set(PACKAGE_VERSION_PATCH @IE_VERSION_PATCH@)
set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}")
set(PACKAGE_VERSION_EXACT False)
set(PACKAGE_VERSION_COMPATIBLE False)
if(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
set(PACKAGE_VERSION_EXACT True)
set(PACKAGE_VERSION_COMPATIBLE True)
endif()
if(PACKAGE_FIND_VERSION_MAJOR EQUAL PACKAGE_VERSION_MAJOR AND
PACKAGE_FIND_VERSION VERSION_LESS PACKAGE_VERSION)
set(PACKAGE_VERSION_COMPATIBLE True)
endif()

View File

@ -0,0 +1,203 @@
# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# FindOpenVINO
# ------
#
# Provides OpenVINO runtime for model creation and inference, frontend libraries
# to convert models from framework specific formats.
#
# The following components are supported:
#
# * `Runtime`: OpenVINO C++ and C Core & Inference Runtime, frontend manager
# * `ONNX`: OpenVINO ONNX frontend
# * `PaddlePaddle`: OpenVINO PaddlePaddle frontend
#
# If no components are specified, `Runtime` component is provided:
#
# find_package(OpenVINO REQUIRED) # only Runtime component
#
# If specific components are required:
#
# find_package(OpenVINO REQUIRED COMPONENTS Runtime ONNX)
#
# Imported Targets:
# ------
#
# Runtime targets:
#
# `openvino::runtime`
# The OpenVINO C++ Core & Inference Runtime
#
# `openvino::runtime::c`
# The OpenVINO C Inference Runtime
#
# `openvino::core`
# The OpenVINO C++ Core Runtime
#
# Frontend specific targets:
#
# `openvino::frontend::manager`
# OpenVINO frontend manager
#
# `openvino::frontend::onnx`
# ONNX FrontEnd target (optional)
#
# `openvino::frontend::paddlepaddle`
# PaddlePaddle FrontEnd target (optional)
#
# Result variables:
# ------
#
# The module sets the following variables in your project:
#
# `OpenVINO_FOUND`
# System has OpenVINO Runtime installed
#
# `OpenVINO_Runtime_FOUND`
# OpenVINO C++ Core & Inference Runtime is available
#
# `OpenVINO_Frontend_ONNX_FOUND`
# OpenVINO ONNX frontend is available
#
# `OpenVINO_Frontend_PaddlePaddle_FOUND`
# OpenVINO PaddlePaddle frontend is available
#
# OpenVINO version variables:
#
# `OpenVINO_VERSION_MAJOR`
# Major version component
#
# `OpenVINO_VERSION_MINOR`
# minor version component
#
# `OpenVINO_VERSION_PATCH`
# Patch version component
#
@PACKAGE_INIT@
#
# Common functions
#
if(NOT DEFINED CMAKE_FIND_PACKAGE_NAME)
set(CMAKE_FIND_PACKAGE_NAME OpenVINO)
set(_need_package_name_reset ON)
endif()
# we have to use our own version of find_dependency because of support cmake 3.7
macro(_ov_find_dependency dep)
set(cmake_fd_quiet_arg)
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
set(cmake_fd_quiet_arg QUIET)
endif()
set(cmake_fd_required_arg)
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
set(cmake_fd_required_arg REQUIRED)
endif()
get_property(cmake_fd_alreadyTransitive GLOBAL PROPERTY
_CMAKE_${dep}_TRANSITIVE_DEPENDENCY)
find_package(${dep} ${ARGN}
${cmake_fd_quiet_arg}
${cmake_fd_required_arg})
if(NOT DEFINED cmake_fd_alreadyTransitive OR cmake_fd_alreadyTransitive)
set_property(GLOBAL PROPERTY _CMAKE_${dep}_TRANSITIVE_DEPENDENCY TRUE)
endif()
if(NOT ${dep}_FOUND)
set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "${CMAKE_FIND_PACKAGE_NAME} could not be found because dependency ${dep} could not be found.")
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND False)
return()
endif()
set(cmake_fd_required_arg)
set(cmake_fd_quiet_arg)
endmacro()
function(_ov_target_no_deprecation_error)
if(NOT MSVC)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
set(flags "-diag-warning=1786")
else()
set(flags "-Wno-error=deprecated-declarations")
endif()
if(CMAKE_CROSSCOMPILING)
set_target_properties(${ARGV} PROPERTIES
INTERFACE_LINK_OPTIONS "-Wl,--allow-shlib-undefined")
endif()
set_target_properties(${ARGV} PROPERTIES INTERFACE_COMPILE_OPTIONS ${flags})
endif()
endfunction()
#
# OpenVINO config
#
# need to store current PACKAGE_PREFIX_DIR, because it's overwritten by sub-package one
set(_ov_package_prefix_dir "${PACKAGE_PREFIX_DIR}")
set(THREADING "@THREADING@")
if(THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO" AND NOT TBB_FOUND)
set_and_check(_tbb_dir "@PACKAGE_IE_TBB_DIR@")
_ov_find_dependency(TBB
COMPONENTS tbb tbbmalloc
CONFIG
PATHS ${TBBROOT}/cmake
${_tbb_dir}
NO_CMAKE_FIND_ROOT_PATH
NO_DEFAULT_PATH)
endif()
if(NOT TARGET inference_engine)
set(_ov_as_external_package ON)
include("${CMAKE_CURRENT_LIST_DIR}/OpenVINOTargets.cmake")
endif()
#
# Components
#
set(${CMAKE_FIND_PACKAGE_NAME}_Runtime_FOUND ON)
set(${CMAKE_FIND_PACKAGE_NAME}_ONNX_FOUND @NGRAPH_ONNX_FRONTEND_ENABLE@)
set(${CMAKE_FIND_PACKAGE_NAME}_PaddlePaddle_FOUND @NGRAPH_PDPD_FRONTEND_ENABLE@)
set(${CMAKE_FIND_PACKAGE_NAME}_Frontend_ONNX_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_ONNX_FOUND})
set(${CMAKE_FIND_PACKAGE_NAME}_Frontend_PaddlePaddle_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_PaddlePaddle_FOUND})
# if no components specified, only Runtime is provided
if(NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS)
set(${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS Runtime)
endif()
#
# Apply common functions
#
foreach(target openvino::runtime openvino::runtime::c openvino::core
openvino::frontend::manager openvino::frontend::onnx
openvino::frontend::paddlepaddle)
if(TARGET ${target} AND _ov_as_external_package)
_ov_target_no_deprecation_error(${target})
endif()
endforeach()
unset(_ov_as_external_package)
# restore PACKAGE_PREFIX_DIR
set(PACKAGE_PREFIX_DIR ${_ov_package_prefix_dir})
unset(_ov_package_prefix_dir)
check_required_components(${CMAKE_FIND_PACKAGE_NAME})
if(_need_package_name_reset)
unset(CMAKE_FIND_PACKAGE_NAME)
unset(_need_package_name_reset)
endif()
unset(${CMAKE_FIND_PACKAGE_NAME}_PaddlePaddle_FOUND)
unset(${CMAKE_FIND_PACKAGE_NAME}_ONNX_FOUND)

View File

@ -39,6 +39,31 @@
if(NOT TARGET ngraph) if(NOT TARGET ngraph)
include("${CMAKE_CURRENT_LIST_DIR}/ngraphTargets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/ngraphTargets.cmake")
# create targets with old names for compatibility
if(TARGET ngraph::core AND NOT TARGET ngraph::ngraph)
add_library(ngraph::ngraph INTERFACE IMPORTED)
set_target_properties(ngraph::ngraph PROPERTIES
INTERFACE_LINK_LIBRARIES ngraph::core)
endif()
if(TARGET ngraph::frontend::manager AND NOT TARGET ngraph::frontend_manager)
add_library(ngraph::frontend_manager INTERFACE IMPORTED)
set_target_properties(ngraph::frontend_manager PROPERTIES
INTERFACE_LINK_LIBRARIES ngraph::frontend::manager)
endif()
if(TARGET ngraph::frontend::onnx AND NOT TARGET ngraph::onnx_ngraph_frontend)
add_library(ngraph::onnx_ngraph_frontend INTERFACE IMPORTED)
set_target_properties(ngraph::onnx_ngraph_frontend PROPERTIES
INTERFACE_LINK_LIBRARIES ngraph::frontend::onnx)
endif()
if(TARGET ngraph::frontend::paddlepaddle AND NOT TARGET ngraph::paddlepaddle_ngraph_frontend)
add_library(ngraph::paddlepaddle_ngraph_frontend INTERFACE IMPORTED)
set_target_properties(ngraph::paddlepaddle_ngraph_frontend PROPERTIES
INTERFACE_LINK_LIBRARIES ngraph::frontend::paddlepaddle)
endif()
endif() endif()
set(ngraph_ngraph_FOUND ON) set(ngraph_ngraph_FOUND ON)
@ -46,19 +71,18 @@ set(NGRAPH_LIBRARIES ngraph::ngraph)
set(ngraph_onnx_ngraph_frontend_FOUND @NGRAPH_ONNX_FRONTEND_ENABLE@) set(ngraph_onnx_ngraph_frontend_FOUND @NGRAPH_ONNX_FRONTEND_ENABLE@)
# ngraph::onnx_importer target and variables are deprecated
set(ngraph_onnx_importer_FOUND @NGRAPH_ONNX_FRONTEND_ENABLE@) set(ngraph_onnx_importer_FOUND @NGRAPH_ONNX_FRONTEND_ENABLE@)
if(ngraph_onnx_importer_FOUND) if(ngraph_onnx_importer_FOUND)
set(ONNX_IMPORTER_LIBRARIES ngraph::onnx_ngraph_frontend) set(ONNX_IMPORTER_LIBRARIES ngraph::onnx_ngraph_frontend)
# ngraph::onnx_importer target and variables are deprecated
# but need to create a dummy target for BW compatibility
if(NOT TARGET ngraph::onnx_importer) if(NOT TARGET ngraph::onnx_importer)
add_library(ngraph::onnx_importer INTERFACE IMPORTED) add_library(ngraph::onnx_importer INTERFACE IMPORTED)
set_target_properties(ngraph::onnx_importer PROPERTIES set_target_properties(ngraph::onnx_importer PROPERTIES
INTERFACE_LINK_LIBRARIES ngraph::onnx_ngraph_frontend INTERFACE_LINK_LIBRARIES ngraph::onnx_ngraph_frontend)
)
endif() endif()
endif() endif()
set(ngraph_paddlepaddle_frontend_FOUND @NGRAPH_PDPD_FRONTEND_ENABLE@) set(ngraph_paddlepaddle_frontend_FOUND @NGRAPH_PDPD_FRONTEND_ENABLE@)
set(ir_frontend_FOUND @IR_FRONTEND_ENABLE@)
check_required_components(ngraph) check_required_components(ngraph)

View File

@ -9,20 +9,12 @@ if(NOT ENABLE_DOCKER)
add_subdirectory(snippets) add_subdirectory(snippets)
# Detect nGraph # Detect OpenVINO
find_package(ngraph QUIET find_package(OpenVINO QUIET
PATHS "${CMAKE_BINARY_DIR}/ngraph"
NO_DEFAULT_PATH)
if(NOT ngraph_FOUND)
set(ngraph_DIR ${CMAKE_BINARY_DIR}/ngraph)
endif()
# Detect InferenceEngine
find_package(InferenceEngine QUIET
PATHS "${CMAKE_BINARY_DIR}" PATHS "${CMAKE_BINARY_DIR}"
NO_DEFAULT_PATH) NO_DEFAULT_PATH)
if(NOT InferenceEngine_FOUND) if(NOT OpenVINO_FOUND)
set(InferenceEngine_DIR ${CMAKE_BINARY_DIR}) set(OpenVINO_DIR ${CMAKE_BINARY_DIR})
endif() endif()
if(NGRAPH_ONNX_FRONTEND_ENABLE) if(NGRAPH_ONNX_FRONTEND_ENABLE)
@ -72,7 +64,7 @@ function(build_docs)
set(C_API "${IE_SOURCE_DIR}/ie_bridges/c/include") set(C_API "${IE_SOURCE_DIR}/ie_bridges/c/include")
set(PLUGIN_API_DIR "${DOCS_BUILD_DIR}/IE_PLUGIN_DG") set(PLUGIN_API_DIR "${DOCS_BUILD_DIR}/IE_PLUGIN_DG")
set(NGRAPH_DIR "${OpenVINO_SOURCE_DIR}/ngraph") set(NGRAPH_DIR "${OpenVINO_SOURCE_DIR}/ngraph")
set(NGRAPH_PY_DIR "${NGRAPH_DIR}/python/src/ngraph/") set(NGRAPH_PY_DIR "${OpenVINO_SOURCE_DIR}/runtime/bindings/python/src/compatibility/ngraph/")
set(NGRAPH_CPP_DIR "${NGRAPH_DIR}/core/include/" "${NGRAPH_DIR}/frontend/onnx_import/include") set(NGRAPH_CPP_DIR "${NGRAPH_DIR}/core/include/" "${NGRAPH_DIR}/frontend/onnx_import/include")
# Preprocessing scripts # Preprocessing scripts

View File

@ -14,6 +14,6 @@ To build an extension library, run the commands below:
$ cd template_extension $ cd template_extension
$ mkdir build $ mkdir build
$ cd build $ cd build
$ cmake -DInferenceEngine_DIR=[IE_DIR] -Dngraph_DIR=[NGRAPH_DIR] ../ $ cmake -DOpenVINO_DIR=[OpenVINO_DIR] ../
$ cmake --build . $ cmake --build .
``` ```

View File

@ -50,8 +50,8 @@ The example below demonstrates how to unregister an operator from the destructor
## Requirements for Building with CMake ## Requirements for Building with CMake
A program that uses the `register_operator` functionality requires `ngraph::ngraph` and `ngraph::onnx_ngraph_frontend` libraries in addition to the Inference Engine. A program that uses the `register_operator` functionality requires `openvino::core` and `openvino::frontend::onnx` libraries in addition to the OpenVINO Inference Runtime.
The `onnx_ngraph_frontend` is a component of the `ngraph` package , so `find_package(ngraph REQUIRED COMPONENTS onnx_ngraph_frontend)` can find both. The `onnx_ngraph_frontend` is a component of the `OpenVINO` package , so `find_package(OpenVINO REQUIRED COMPONENTS ONNX)` can find both.
Those libraries need to be passed to the `target_link_libraries` command in the CMakeLists.txt file. Those libraries need to be passed to the `target_link_libraries` command in the CMakeLists.txt file.
See CMakeLists.txt below for reference: See CMakeLists.txt below for reference:

View File

@ -193,11 +193,10 @@ build/ - build directory
``` cmake ``` cmake
cmake_minimum_required(VERSION 3.0.0) cmake_minimum_required(VERSION 3.0.0)
project(project_name) project(project_name)
find_package(ngraph REQUIRED) find_package(OpenVINO REQUIRED)
find_package(InferenceEngine REQUIRED)
find_package(OpenCV REQUIRED) find_package(OpenCV REQUIRED)
add_executable(${PROJECT_NAME} src/main.cpp) add_executable(${PROJECT_NAME} src/main.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE ${InferenceEngine_LIBRARIES} ${OpenCV_LIBS} ${NGRAPH_LIBRARIES}) target_link_libraries(${PROJECT_NAME} PRIVATE openvino::runtime ${OpenCV_LIBS})
``` ```
3. **To build your project** using CMake with the default build tools currently available on your machine, execute the following commands: 3. **To build your project** using CMake with the default build tools currently available on your machine, execute the following commands:
> **NOTE**: Make sure you set environment variables first by running `<INSTALL_DIR>/bin/setupvars.sh` (or setupvars.bat for Windows)`. Otherwise the `InferenceEngine_DIR` and `OpenCV_DIR` variables won't be configured properly to pass `find_package` calls. > **NOTE**: Make sure you set environment variables first by running `<INSTALL_DIR>/bin/setupvars.sh` (or setupvars.bat for Windows)`. Otherwise the `InferenceEngine_DIR` and `OpenCV_DIR` variables won't be configured properly to pass `find_package` calls.

View File

@ -29,7 +29,8 @@ FILE_PATTERNS = *.cpp \
LAYOUT_FILE = "@NGRAPH_CPP_LAYOUT_BUILD@" LAYOUT_FILE = "@NGRAPH_CPP_LAYOUT_BUILD@"
INPUT = "@NGRAPH_DIR@/core/include/" \ INPUT = "@NGRAPH_DIR@/core/include/" \
"@NGRAPH_DIR@/frontend/onnx_import/include" "@NGRAPH_DIR@/frontend/onnx/frontend/include/" \
"@NGRAPH_DIR@/frontend/paddlepaddle/frontend/include/"
HTML_OUTPUT = "@NGRAPH_CPP_OUTPUT@" HTML_OUTPUT = "@NGRAPH_CPP_OUTPUT@"

View File

@ -67,10 +67,6 @@ limitations under the License.
<tab type="user" title="Intel® Movidius™ VPUs Setup Guide" url="@ref openvino_docs_install_guides_movidius_setup_guide"/> <tab type="user" title="Intel® Movidius™ VPUs Setup Guide" url="@ref openvino_docs_install_guides_movidius_setup_guide"/>
<tab type="user" title="Intel® Movidius™ VPUs Programming Guide" url="@ref openvino_docs_install_guides_movidius_programming_guide"/> <tab type="user" title="Intel® Movidius™ VPUs Programming Guide" url="@ref openvino_docs_install_guides_movidius_programming_guide"/>
</tab> </tab>
<tab type="usergroup" title="[DEPRECATED] FPGAs" url="@ref openvino_docs_install_guides_VisionAcceleratorFPGA_Configure">
<tab type="user" title="[DEPRECATED] Configuration Guide for Intel® Vision Accelerator Design with an Intel® Arria 10 FPGA SG2 (IEIs Mustang-F100-A10) on Linux" url="@ref openvino_docs_install_guides_VisionAcceleratorFPGA_Configure"/>
<tab type="user" title="[DEPRECATED] Configuration Guide for Intel® Programmable Acceleration Card with Intel® Arria® 10 FPGA GX on CentOS or Ubuntu*" url="@ref openvino_docs_install_guides_PAC_Configure"/>
</tab>
</tab> </tab>
<!-- Security --> <!-- Security -->
<tab type="usergroup" title="Security" url="@ref openvino_docs_security_guide_introduction"><!--automatically generated--> <tab type="usergroup" title="Security" url="@ref openvino_docs_security_guide_introduction"><!--automatically generated-->

View File

@ -1,21 +0,0 @@
# Configuration Guide for Intel® Distribution of OpenVINO™ toolkit 2020.4 and the Intel® Programmable Acceleration Card with Intel® Arria® 10 GX FPGA on CentOS or Ubuntu* {#openvino_docs_install_guides_PAC_Configure}
## Product Change Notice
Intel® Distribution of OpenVINO™ toolkit for Intel® Vision Accelerator Design with an Intel® Arria® 10 FPGA and the Intel® Programmable Acceleration Card with Intel® Arria® 10 GX FPGA
<table>
<tr>
<td><strong>Change Notice Begins</strong></td>
<td>July 2020</td>
</tr>
<tr>
<td><strong>Change Date</strong></td>
<td>October 2020</td>
</tr>
</table>
Intel will be transitioning to the next-generation programmable deep-learning solution based on FPGAs in order to increase the level of customization possible in FPGA deep-learning. As part of this transition, future standard releases (i.e., non-LTS releases) of Intel® Distribution of OpenVINO™ toolkit will no longer include the Intel® Vision Accelerator Design with an Intel® Arria® 10 FPGA and the Intel® Programmable Acceleration Card with Intel® Arria® 10 GX FPGA.
Intel® Distribution of OpenVINO™ toolkit 2020.3.X LTS release will continue to support Intel® Vision Accelerator Design with an Intel® Arria® 10 FPGA and the Intel® Programmable Acceleration Card with Intel® Arria® 10 GX FPGA. For questions about next-generation programmable deep-learning solutions based on FPGAs, please talk to your sales representative or contact us to get the latest FPGA updates.
For documentation for previous releases of Intel® Distribution of OpenVINO™ toolkit for Linux* with FPGA Support, see documentation for the [2020.4 version](https://docs.openvinotoolkit.org/2020.4/openvino_docs_install_guides_PAC_Configure.html) and lower.

View File

@ -1,247 +0,0 @@
# Configuration Guide for Intel® Distribution of OpenVINO™ toolkit 2018R5 and the Intel® Programmable Acceleration Card with Intel® Arria® 10 FPGA GX on CentOS* {#openvino_docs_install_guides_PAC_Configure_2018R5}
## Get Started
The following describes the set-up of the Intel® Distribution of OpenVINO™ toolkit on CentOS* 7.4. This is based upon a completely fresh install of CentOS 7.4 with developer tools included. This document was written for the Intel® Distribution of OpenVINO™ toolkit 2018 R5 release and may be largely applicable for later versions. Official Intel® documentation for the install process can be found in the following locations and it is highly recommended that these are read, especially for new users. This document serves as a guide, and in some cases, adds additional detail, specifically for an install with `sudo` privileges on CentOS 7.4.
[Intel® Acceleration Stack for FPGAs Quick Start Guide](https://www.intel.com/content/dam/altera-www/global/en_US/pdfs/literature/ug/ug-qs-ias-v1-1.pdf)
[OpenCL™ on Intel® PAC Quick Start Guide](https://www.intel.com/content/dam/altera-www/global/en_US/pdfs/literature/ug/ug-qs-ias-opencl-a10-v1-1.pdf)
[Installing the Intel® Distribution of OpenVINO™ toolkit for Linux*](https://docs.openvinotoolkit.org/latest/_docs_install_guides_installing_openvino_linux.html)
(Optional): Install NTFS support for transferring large installers if already downloaded on another machine.
```sh
sudo yum -y install epel-release
```
```sh
sudo yum -y install ntfs-3g
```
## Install Intel® PAC and the Intel® Programmable Acceleration Card Stack
1. Download version 1.1 of the Acceleration Stack for Runtime from the [Intel FPGA Acceleration Hub](https://www.altera.com/solutions/acceleration-hub/downloads.html).
This downloads as `a10_gx_pac_ias_1_1_pv_rte_installer.tar.gz`. Let it download to `~/Downloads`.
2. Create a new directory to install to:
```sh
mkdir -p ~/tools/intelrtestack
```
3. Untar and launch the installer:
```sh
cd ~/Downloads
```
```sh
tar xf a10_gx_pac_ias_1_1_pv_rte_installer.tar.gz
```
```sh
cd a10_gx_pac_ias_1_1_pv_rte_installer
```
```sh
sudo ./setup.sh
```
4. Select **Y** to install OPAE and accept license and when asked, specify `~/tools/intelrtestack` as the install path. During the installation there should be a message stating the directory already exists as it was created in the first command above. Select Y to install to this directory. If this message is not seen, it suggests that there was a typo when entering the install location.
5. Tools are installed to the following directories:
* `Intel® Quartus® software Programmer: ~/tools/inteltrestack/intelFPGA_pro/qprogrammer`
* `OpenCL™ Run Time Environment: ~/tools/intelrtestack/intelFPGA_pro/aclrte-linux64`
* `Intel® Acceleration Stack for FPGAs: ~/tools/intelrtestack/a10_gx_pac_ias_1_1_pv`
6. Install E10/E40 Software Patch
```sh
source ~/tools/intelrtestack/init_env.sh
```
```sh
cd $OPAE_PLATFORM_ROOT/hw
```
```sh
sudo wget https://www.intel.com/content/dam/altera-www/global/en_US/others/solutions/acceleration-hub/a10_gx_pac_ias_1_1_pv_eth.patch
```
```sh
sudo patch -s -p0 < a10_gx_pac_ias_1_1_pv_eth.patch
```
7. Check the version of the FPGA Interface Manager firmware on the PAC board.
```sh
sudo fpgainfo fme
```
8. If the reported `Pr Interface Id` is not `9926ab6d-6c92-5a68-aabc-a7d84c545738` then follow the instructions in section 4 of the [Intel® Acceleration Stack for FPGAs Quick Start Guide](https://www.intel.com/content/dam/altera-www/global/en_US/pdfs/literature/ug/ug-qs-ias-v1-1.pdf) to update the FME.
9. Run the built in self-test to verify operation of the Acceleration Stack and Intel® PAC in a non-virtualized environment.
```sh
sudo sh -c "echo 20 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages"
```
```sh
sudo fpgabist $OPAE_PLATFORM_ROOT/hw/samples/nlb_mode_3/bin/nlb_mode_3.gbs
```
## Extract and Verify the Intel® Acceleration Stack for FPGAs OpenCL™ BSP
1. Extract the BSP
```sh
cd $OPAE_PLATFORM_ROOT/opencl
```
```sh
sudo tar xf opencl_bsp.tar.gz
```
2. Create an initialization script `~/init_openvino.sh` with the following content that can be run upon opening a new terminal or rebooting. This will source the script ran above as well as setting up the OpenCL™ environment.
```sh
source \$HOME/tools/intelrtestack/init_env.sh
```
```sh
export CL_CONTEXT_COMPILER_MODE_ALTERA=3
```
```sh
export CL_CONTEXT_COMPILER_MODE_INTELFPGA=3
```
```sh
export INTELFPGAOCLSDKROOT="\$HOME/tools/intelrtestack/intelFPGA_pro/aclrte-linux64"
```
```sh
export ALTERAOCLSDKROOT="\$INTELFPGAOCLSDKROOT"
```
```sh
export AOCL_BOARD_PACKAGE_ROOT="\$OPAE_PLATFORM_ROOT/opencl/opencl_bsp"
```
```sh
\$AOCL_BOARD_PACKAGE_ROOT/linux64/libexec/setup_permissions.sh```
```sh
source $INTELFPGAOCLSDKROOT/init_opencl.sh
```
3. Source the script:
```sh
source ~/init_openvino.sh
```
4. Some of the settings made in the child scripts need a reboot to take effect. Reboot the machine and source the script again. Note that this script should be sourced each time a new terminal is opened for use with the Intel® Acceleration Stack for FPGAs and Intel® Distribution of OpenVINO™ toolkit.
```sh
source ~/init_openvino.sh
```
5. Install the OpenCL™ driver:
```sh
cd ~
```
```sh
sudo -E ./tools/intelrtestack/intelFPGA_pro/aclrte-linux64/bin/aocl install
```
Select **Y** when asked to install the BSP. Note that the following warning can be safely ignored.
```sh
WARNING: install not implemented. Please refer to DCP Quick Start User Guide.
```
6. Program the Intel® PAC board with a pre-compiled `.aocx` file (OpenCL™ based FPGA bitstream).
```sh
cd \$OPAE_PLATFORM_ROOT/opencl
```
```sh
aocl program acl0 hello_world.aocx
```
7. Build and run the Hello World application:
```sh
sudo tar xf exm_opencl_hello_world_x64_linux.tgz
```
```sh
sudo chmod -R a+w hello_world
```
```sh
cd hello_world
```
```sh
make
```
```sh
cp ../hello_world.aocx ./bin
```
```sh
./bin/host
```
## Add Intel® Distribution of OpenVINO™ toolkit with FPGA Support to Environment Variables
1. To run the Intel® Distribution of OpenVINO™ toolkit, add the last four commands to the `~/init_openvino.sh` script. The previous content is shown as well.
```sh
source \$HOME/tools/intelrtestack/init_env.sh
export CL_CONTEXT_COMPILER_MODE_ALTERA=3
export CL_CONTEXT_COMPILER_MODE_INTELFPGA=3
export INTELFPGAOCLSDKROOT="\$HOME/tools/intelrtestack/intelFPGA_pro/aclrte-linux64"
export ALTERAOCLSDKROOT="\$INTELFPGAOCLSDKROOT"
export AOCL_BOARD_PACKAGE_ROOT="\$OPAE_PLATFORM_ROOT/opencl/opencl_bsp"
\$AOCL_BOARD_PACKAGE_ROOT/linux64/libexec/setup_permissions.sh
source $INTELFPGAOCLSDKROOT/init_opencl.sh
export IE_INSTALL="/opt/intel/openvino/deployment_tools"
source \$IE_INSTALL/../bin/setupvars.sh
export PATH="\$PATH:\$HOME/inference_engine_samples/intel64/Release"
alias mo="python3.6 \$IE_INSTALL/model_optimizer/mo.py"
```
2. Source the script
```sh
source ~/init_openvino.sh
```
## Program a Bitstream
The bitstream you program should correspond to the topology you want to deploy. In this section, you program a SqueezeNet bitstream and deploy the classification sample with a SqueezeNet model.
> **IMPORTANT**: Only use bitstreams from the installed version of the Intel® Distribution of OpenVINO™ toolkit. Bitstreams from older versions of the Intel® Distribution of OpenVINO™ toolkit are incompatible with later versions. For example, you cannot use the `1-0-1_RC_FP16_Generic` bitstream, when the Intel® Distribution of OpenVINO™ toolkit supports the `2-0-1_RC_FP16_Generic bitstream`.
There are different folders for each FPGA card type which were downloaded in the Intel® Distribution of OpenVINO™ toolkit package.
For the Intel® Programmable Acceleration Card with Intel® Arria® 10 FPGA GX, the pre-trained bitstreams are in the `/opt/intel/openvino/bitstreams/a10_dcp_bitstreams` directory. This example uses a SqueezeNet bitstream with low precision for the classification sample.
Program the bitstream for Intel® Programmable Acceleration Card with Intel® Arria® 10 FPGA GX:
```sh
aocl program acl0 /opt/intel/openvino/bitstreams/a10_dcp_bitstreams/5-0_RC_FP11_SqueezeNet.aocx
```
## Use the Intel® Distribution of OpenVINO™ toolkit
1. Run inference with the Intel® Distribution of OpenVINO™ toolkit independent of the demo scripts using the SqueezeNet model that was download by the scripts. For convenience, copy the necessary files to a local directory. If the workstation has been rebooted or a new terminal is opened, source the script above first.
```sh
mkdir ~/openvino_test
```
```sh
cd ~/openvino_test
```
```sh
cp ~/openvino_models/classification/squeezenet/1.1/caffe/squeezenet1.1.* .
```
```sh
cp ~/openvino_models/ir/squeezenet1.1/squeezenet1.1.labels .
```
2. Note that the `squeezenet1.1.labels` file contains the classes used by ImageNet and is included here so that the inference results show text rather than classification numbers. Convert the model with the [Model Optimizer](https://docs.openvinotoolkit.org/latest/_docs_MO_DG_Deep_Learning_Model_Optimizer_DevGuide.html). Note that the command below uses the alias defined in the script above and is not referred to in other documentation.
```sh
mo --input_model squeezenet1.1.caffemodel
```
3. Now run Inference on the CPU using one of the built in Inference Engine samples:
```sh
classification_sample_async -m squeezenet1.1.xml -i $IE_INSTALL/demo/car.png
```
4. Add the `-d` option to run on FPGA:
```sh
classification_sample_async -m squeezenet1.1.xml -i $IE_INSTALL/demo/car.png -d HETERO:FPGA,CPU
```
5. Increase the number of iterations with the `-ni` option to reduce the impact of initialization:
```sh
classification_sample_async -m squeezenet1.1.xml -i $IE_INSTALL/demo/car.png -d HETERO:FPGA,CPU -ni 100
```
Congratulations, You are done with the Intel® Distribution of OpenVINO™ toolkit installation for FPGA.
## Additional Resources
Intel® Distribution of OpenVINO™ toolkit home page: [https://software.intel.com/en-us/openvino-toolkit](https://software.intel.com/en-us/openvino-toolkit)
Intel® Distribution of OpenVINO™ toolkit documentation: [https://docs.openvinotoolkit.org](https://docs.openvinotoolkit.org)
Inference Engine FPGA plugin documentation: [https://docs.openvinotoolkit.org/latest/_docs_IE_DG_supported_plugins_FPGA.html](https://docs.openvinotoolkit.org/latest/_docs_IE_DG_supported_plugins_FPGA.html)

View File

@ -1,247 +0,0 @@
# Configuration Guide for Intel® Distribution of OpenVINO™ toolkit 2019R1/2019R2/2019R3/2020.1 and the Intel® Programmable Acceleration Card with Intel® Arria® 10 FPGA GX on CentOS or Ubuntu* {#openvino_docs_install_guides_PAC_Configure_2019RX}
## Get Started
The following describes the set-up of the Intel® Distribution of OpenVINO™ toolkit on CentOS* 7.4 or Ubuntu* 16.04, kernel 4.15. This is based upon a completely fresh install of the OS with developer tools included. This document was written for the Intel® Distribution of OpenVINO™ toolkit 2019 release 1, 2, and 3 and may be largely applicable for later versions. Official Intel® documentation for the install process can be found in the following locations and it is highly recommended that these are read, especially for new users. This document serves as a guide, and in some cases, adds additional detail where necessary.
[Intel® Acceleration Stack for FPGAs Quick Start Guide](https://www.intel.com/content/dam/altera-www/global/en_US/pdfs/literature/ug/ug-qs-ias-v1-1.pdf)
[OpenCL™ on Intel® PAC Quick Start Guide](https://www.intel.com/content/dam/altera-www/global/en_US/pdfs/literature/ug/ug-qs-ias-opencl-a10-v1-1.pdf)
[Installing the Intel® Distribution of OpenVINO™ toolkit for Linux*](https://docs.openvinotoolkit.org/latest/_docs_install_guides_installing_openvino_linux.html)
(Optional): Install NTFS support for transferring large installers if already downloaded on another machine.
```sh
sudo yum -y install epel-release
```
```sh
sudo yum -y install ntfs-3g
```
## Install Intel® PAC and the Intel® Programmable Acceleration Card Stack
1. Download version 1.2 of the Acceleration Stack for Runtime from the [Intel FPGA Acceleration Hub](https://www.altera.com/solutions/acceleration-hub/downloads.html).
This downloads as `a10_gx_pac_ias_1_2_pv_rte_installer.tar.gz`. Let it download to `~/Downloads`.
2. Create a new directory to install to:
```sh
mkdir -p ~/tools/intelrtestack
```
3. Untar and launch the installer:
```sh
cd ~/Downloads
```
```sh
tar xf a10_gx_pac_ias_1_2_pv_rte_installer.tar.gz
```
```sh
cd a10_gx_pac_ias_1_2_pv_rte_installer
```
```sh
./setup.sh
```
4. Select **Y** to install OPAE and accept license and when asked, specify `/home/<user>/tools/intelrtestack` as the absolute install path. During the installation there should be a message stating the directory already exists as it was created in the first command above. Select **Y** to install to this directory. If this message is not seen, it suggests that there was a typo when entering the install location.
5. Tools are installed to the following directories:
* OpenCL™ Runtime Environment: `~/tools/intelrtestack/opencl_rte/aclrte-linux64`
* Intel® Acceleration Stack for FPGAs: `~/tools/intelrtestack/a10_gx_pac_ias_1_2_pv`
7. Check the version of the FPGA Interface Manager firmware on the PAC board.
```sh
sudo fpgainfo fme
```
8. If the reported `Pr Interface Id` is not `69528db6-eb31-577a-8c36-68f9faa081f6` then follow the instructions in section 4 of the [Intel® Acceleration Stack for FPGAs Quick Start Guide](https://www.intel.com/content/dam/altera-www/global/en_US/pdfs/literature/ug/ug-qs-ias-v1-2.pdf) to update the FME.
9. Run the built in self-test to verify operation of the Acceleration Stack and Intel® PAC in a non-virtualized environment.
```sh
sudo sh -c "echo 20 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages"
```
```sh
source ~/tools/intelrtestack/init_env.sh
```
```sh
sudo fpgabist $OPAE_PLATFORM_ROOT/hw/samples/nlb_mode_3/bin/nlb_mode_3.gbs
```
## Verify the Intel® Acceleration Stack for FPGAs OpenCL™ BSP
1. Remove any previous FCD files that may be from previous installations of hardware in the `/opt/Intel/OpenCL/Boards/` directory:
```sh
cd /opt/Intel/OpenCL/Boards
sudo rm -rf *.fcd
```
2. Install `lsb_release` on your system if you are using CentOS:
```sh
sudo yum install redhat-lsb-core
```
3. Create an initialization script `~/init_openvino.sh` with the following content that can be run upon opening a new terminal or rebooting. This will source the script ran above as well as setting up the OpenCL™ environment.
```sh
source $HOME/tools/intelrtestack/init_env.sh
```
```sh
export CL_CONTEXT_COMPILER_MODE_ALTERA=3
```
```sh
export CL_CONTEXT_COMPILER_MODE_INTELFPGA=3
```
```sh
export INTELFPGAOCLSDKROOT="/opt/altera/aocl-pro-rte/aclrte-linux64"
```
```sh
export ALTERAOCLSDKROOT="$INTELFPGAOCLSDKROOT"
```
```sh
export AOCL_BOARD_PACKAGE_ROOT="$OPAE_PLATFORM_ROOT/opencl/opencl_bsp"
```
```sh
$AOCL_BOARD_PACKAGE_ROOT/linux64/libexec/setup_permissions.sh
```
```sh
source $INTELFPGAOCLSDKROOT/init_opencl.sh
```
4. Source the script:
```sh
source ~/init_openvino.sh
```
5. Some of the settings made in the child scripts need a reboot to take effect. Reboot the machine and source the script again. Note that this script should be sourced each time a new terminal is opened for use with the Intel® Acceleration Stack for FPGAs and Intel® Distribution of OpenVINO™ toolkit.
```sh
source ~/init_openvino.sh
```
6. Install the OpenCL™ driver:
```sh
cd ~
```
```sh
sudo -E ./tools/intelrtestack/opencl_rte/aclrte-linux64/bin/aocl install
```
Select **Y** when asked to install the BSP. Note that the following warning can be safely ignored.
```sh
WARNING: install not implemented. Please refer to DCP Quick Start User Guide.
```
7. Program the Intel® PAC board with a pre-compiled `.aocx` file (OpenCL™ based FPGA bitstream).
```sh
cd $OPAE_PLATFORM_ROOT/opencl
```
```sh
aocl program acl0 hello_world.aocx
```
8. Build and run the Hello World application:
```sh
sudo tar xf exm_opencl_hello_world_x64_linux.tgz
```
```sh
sudo chmod -R a+w hello_world
```
```sh
cd hello_world
```
```sh
make
```
```sh
cp ../hello_world.aocx ./bin
```
```sh
./bin/host
```
## Add Intel® Distribution of OpenVINO™ toolkit with FPGA Support to Environment Variables
1. To run the Intel® Distribution of OpenVINO™ toolkit, add the last four commands to the `~/init_openvino.sh` script. The previous content is shown as well.
```sh
source $HOME/tools/intelrtestack/init_env.sh
export CL_CONTEXT_COMPILER_MODE_ALTERA=3
export CL_CONTEXT_COMPILER_MODE_INTELFPGA=3
export INTELFPGAOCLSDKROOT="/opt/altera/aocl-pro-rte/aclrte-linux64"
export ALTERAOCLSDKROOT="$INTELFPGAOCLSDKROOT"
export AOCL_BOARD_PACKAGE_ROOT="$OPAE_PLATFORM_ROOT/opencl/opencl_bsp"
$AOCL_BOARD_PACKAGE_ROOT/linux64/libexec/setup_permissions.sh
source $INTELFPGAOCLSDKROOT/init_opencl.sh
export IE_INSTALL="/opt/intel/openvino/deployment_tools"
source $IE_INSTALL/../bin/setupvars.sh
export PATH="$PATH:$HOME/inference_engine_samples_build/intel64/Release"
alias mo="python3.6 $IE_INSTALL/model_optimizer/mo.py"
```
For Ubuntu systems, it is recommended to use python3.5 above instead of python3.6.
2. Source the script
```sh
source ~/init_openvino.sh
```
## Program a Bitstream
The bitstream you program should correspond to the topology you want to deploy. In this section, you program a SqueezeNet bitstream and deploy the classification sample with a SqueezeNet model.
> **IMPORTANT**: Only use bitstreams from the installed version of the Intel® Distribution of OpenVINO™ toolkit. Bitstreams from older versions of the Intel® Distribution of OpenVINO™ toolkit are incompatible with later versions. For example, you cannot use the `1-0-1_RC_FP16_Generic` bitstream, when the Intel® Distribution of OpenVINO™ toolkit supports the `2-0-1_RC_FP16_Generic bitstream`.
There are different folders for each FPGA card type which were downloaded in the Intel® Distribution of OpenVINO™ toolkit package.
For the Intel® Programmable Acceleration Card with Intel® Arria® 10 FPGA GX, the pre-trained bitstreams are in the `/opt/intel/openvino/bitstreams/a10_dcp_bitstreams` directory. This example uses a SqueezeNet bitstream with low precision for the classification sample.
Program the bitstream for Intel® Programmable Acceleration Card with Intel® Arria® 10 FPGA GX.
For R1:
```sh
aocl program acl0 /opt/intel/openvino/bitstreams/a10_dcp_bitstreams/2019R1_RC_FP11_ResNet_SqueezeNet_VGG.aocx
```
Or for R2:
```sh
aocl program acl0 /opt/intel/openvino/bitstreams/a10_dcp_bitstreams/2019R2_RC_FP11_ResNet_SqueezeNet_VGG.aocx
```
Or for R3:
```sh
aocl program acl0 /opt/intel/openvino/bitstreams/a10_dcp_bitstreams/2019R3_PV_RC_FP11_InceptionV1_ResNet_SqueezeNet_TinyYolo_VGG.aocx
```
Or for 2020.1:
```sh
aocl program acl0 /opt/intel/openvino/bitstreams/a10_dcp_bitstreams/2019R4_RC_FP11_ResNet_SqueezeNet_TinyYolo.aocx
```
## Use the Intel® Distribution of OpenVINO™ toolkit
1. Run inference with the Intel® Distribution of OpenVINO™ toolkit independent of the demo scripts using the SqueezeNet model that was download by the scripts. For convenience, copy the necessary files to a local directory. If the workstation has been rebooted or a new terminal is opened, source the script above first.
```sh
mkdir ~/openvino_test
```
```sh
cd ~/openvino_test
```
```sh
cp ~/openvino_models/models/public/squeezenet1.1/squeezenet1.1.* .
```
```sh
cp ~/openvino_models/ir/public/squeezenet1.1/FP16/squeezenet1.1.labels .
```
2. Note that the `squeezenet1.1.labels` file contains the classes used by ImageNet and is included here so that the inference results show text rather than classification numbers. Convert the model with the [Model Optimizer](https://docs.openvinotoolkit.org/latest/_docs_MO_DG_Deep_Learning_Model_Optimizer_DevGuide.html). Note that the command below uses the alias defined in the script above and is not referred to in other documentation.
```sh
mo --input_model squeezenet1.1.caffemodel
```
3. Now run Inference on the CPU using one of the built in Inference Engine samples:
```sh
classification_sample_async -m squeezenet1.1.xml -i $IE_INSTALL/demo/car.png
```
4. Add the `-d` option to run on FPGA:
```sh
classification_sample_async -m squeezenet1.1.xml -i $IE_INSTALL/demo/car.png -d HETERO:FPGA,CPU
```
Congratulations, You are done with the Intel® Distribution of OpenVINO™ toolkit installation for FPGA.
## Additional Resources
Intel® Distribution of OpenVINO™ toolkit home page: [https://software.intel.com/en-us/openvino-toolkit](https://software.intel.com/en-us/openvino-toolkit)
Intel® Distribution of OpenVINO™ toolkit documentation: [https://docs.openvinotoolkit.org](https://docs.openvinotoolkit.org)
Inference Engine FPGA plugin documentation: [https://docs.openvinotoolkit.org/latest/_docs_IE_DG_supported_plugins_FPGA.html](https://docs.openvinotoolkit.org/latest/_docs_IE_DG_supported_plugins_FPGA.html)

View File

@ -1,21 +0,0 @@
# Configuration Guide for the Intel® Distribution of OpenVINO™ toolkit 2020.4 and the Intel® Vision Accelerator Design with an Intel® Arria® 10 FPGA SG2 (IEI's Mustang-F100-A10) on Linux* {#openvino_docs_install_guides_VisionAcceleratorFPGA_Configure}
## Product Change Notice
Intel® Distribution of OpenVINO™ toolkit for Intel® Vision Accelerator Design with an Intel® Arria® 10 FPGA and the Intel® Programmable Acceleration Card with Intel® Arria® 10 GX FPGA
<table>
<tr>
<td><strong>Change Notice Begins</strong></td>
<td>July 2020</td>
</tr>
<tr>
<td><strong>Change Date</strong></td>
<td>October 2020</td>
</tr>
</table>
Intel will be transitioning to the next-generation programmable deep-learning solution based on FPGAs in order to increase the level of customization possible in FPGA deep-learning. As part of this transition, future standard releases (i.e., non-LTS releases) of Intel® Distribution of OpenVINO™ toolkit will no longer include the Intel® Vision Accelerator Design with an Intel® Arria® 10 FPGA and the Intel® Programmable Acceleration Card with Intel® Arria® 10 GX FPGA.
Intel® Distribution of OpenVINO™ toolkit 2020.3.X LTS release will continue to support Intel® Vision Accelerator Design with an Intel® Arria® 10 FPGA and the Intel® Programmable Acceleration Card with Intel® Arria® 10 GX FPGA. For questions about next-generation programmable deep-learning solutions based on FPGAs, please talk to your sales representative or contact us to get the latest FPGA updates.
For documentation for previous releases of Intel® Distribution of OpenVINO™ toolkit for Linux* with FPGA Support, see documentation for the [2020.4 version](https://docs.openvinotoolkit.org/2020.4/openvino_docs_install_guides_VisionAcceleratorFPGA_Configure.html) and lower.

View File

@ -1,330 +0,0 @@
# Configuration Guide for the Intel® Distribution of OpenVINO™ toolkit 2018R5 and the Intel® Vision Accelerator Design with an Intel® Arria® 10 FPGA (IEI's Mustang-F100-A10) on Linux* {#openvino_docs_install_guides_VisionAcceleratorFPGA_Configure_2018R5}
> **NOTES:**
> * For a first-time installation, use all steps.
> * Use steps 1 and 2 only after receiving a new FPGA card.
> * Repeat steps 2-5 when installing a new version of the Intel® Distribution of OpenVINO™ toolkit.
> * Use steps 3-5 when a Neural Network topology used by an Intel® Distribution of OpenVINO™ toolkit application changes.
## 1. Configure and Install the Intel® Vision Accelerator Design with an Intel® Arria® 10 FPGA
1. Download `fpga_support_files.tgz` from the [Intel Registration Center](http://registrationcenter-download.intel.com/akdlm/irc_nas/12954/fpga_support_files.tgz). The files in this `.tgz` archive are required to ensure your FPGA card and the Intel® Distribution of OpenVINO™ toolkit work correctly.
2. Go to the directory where you downloaded the `fpga_support_files.tgz` archive.
3. Unpack the `.tgz` file:
```sh
tar -xvzf fpga_support_files.tgz
```
A directory named `fpga_support_files` is created.
4. Go to the `fpga_support_files` directory:
```sh
cd fpga_support_files
```
5. Source `setup_env.sh` to set your environment variables:
```sh
source /home/<user>/Downloads/fpga_support_files/setup_env.sh
```
6. Configure the FPGA Driver Blacklist:
```sh
sudo mv config/blacklist-altera-cvp.conf /etc/modprobe.d
```
7. Switch to superuser:
```sh
sudo su
```
8. Use the `setup_env.sh` script from `fpga_support_files.tgz` to set your environment variables:
```sh
source /home/<user>/Downloads/fpga_support_files/setup_env.sh
```
9. Change directory to `Downloads/fpga_support_files/`:
```sh
cd /home/<user>/Downloads/fpga_support_files/
```
10. Run the FPGA dependencies script, which allows OpenCL to support Ubuntu* and recent kernels:
```sh
./install_openvino_fpga_dependencies.sh
```
11. When asked, select the FPGA card, Intel® GPU, and Intel® Neural Compute Stick 2, then you can install the correct dependencies.
12. If you installed the 4.14 kernel as part of the installation script, you will need to reboot the machine and select the new kernel in the Ubuntu (grub) boot menu. You will also need to rerun `setup_env.sh` to set up your environmental variables again.
13. Install OpenCL™ devices. Enter **Y** when prompted to install:
```sh
aocl install
```
14. Reboot the machine:
```sh
reboot
```
15. Use the `setup_env.sh` script from `fpga_support_files.tgz` to set your environment variables:
```sh
source /home/<user>/Downloads/fpga_support_files/setup_env.sh
```
16. Run `aocl diagnose`:
```sh
aocl diagnose
```
Your screen displays `DIAGNOSTIC_PASSED`.
## 2. Set Up the Intel® Vision Accelerator Design with Intel® Arria® 10 FPGA for 2018R5
For the 2018R5 release, the Intel® Distribution of OpenVINO™ toolkit introduced a new board support package (BSP) `a10_1150_sg1` for the Intel® Vision Accelerator Design with an Intel® Arria® 10 FPGA, which is included into the `fpga_support_files.tgz` archive. To program the bitstreams for the Intel® Distribution of OpenVINO™ toolkit R5, you need to program the BSP into the board using the USB blaster.
> **NOTE**: These steps apply only if you update to the Intel® Distribution of OpenVINO™ toolkit R5. Otherwise, you can skip them.
1. Go to the `config` folder of the `fpga_support_files` directory where the `a10_1150_sg1` is located:
```sh
cd /home/<user>/Downloads/fpga_support_files/config/
```
2. Copy the `a10_1150_sg1` folder to the `board` directory:
```sh
sudo cp -rf a10_1150_sg1 /opt/altera/aocl-pro-rte/aclrte-linux64/board/
```
3. Convert the BSP files from DOS to UNIX:
```sh
sudo chmod +x a10_1150_sg1
find a10_1150_sg1 -type f -print0 | xargs -0 dos2unix
```
4. Set up the USB Blaster:
1. Connect the cable between the board and the host system. Use the letter codes in the diagram below for the connection points:
2. Connect the B end of the cable to point B on the board.
3. Connect the F end of the cable to point F on the FPGA download cable.
4. From point F end of the cable to point F on the FPGA download cable, the connection is as shown:
![](../img/VisionAcceleratorJTAG.png)
5. Source the `setup_env.sh` script from the `fpga_support_files` to set up the environment variables:
```sh
source /home/<user>/Downloads/fpga_support_files/setup_env.sh
```
6. Update the Intel® FPGA Download Cable rules to program the board without root permissions and to flash the initialization bitstreams so that the Intel® FPGA Download Cable can communicate with the board:
```sh
sudo cp config/51-usbblaster.rules /etc/udev/rules.d
```
7. Load the USB rules:
```sh
sudo udevadm control --reload-rules && udevadm trigger
```
8. Unplug and re-plug the Intel® FPGA Download Cable to enable JTAG connection.
9. Run `jtagconfig` to ensure that your Intel FPGA Download Cable driver is ready to use:
```sh
jtagconfig
```
Your output is similar to:
```sh
1) USB-Blaster [1-6]
02E660DD 10AX115H1(.|E2|ES)/10AX115H2/..
```
10. Download [Intel® Quartus® Prime Software Lite Edition 17.1](http://fpgasoftware.intel.com/17.1/?edition=lite). Install the Intel® Quartus® Prime Software Lite to the `/home/<user>/intelFPGA/17.1` directory.
> **NOTE**: You will need the complete the Intel® Quartus® Prime Software Lite version when you want to program the `boardtest_1ddr_top.aocx` into the flash for permanent availability.
11. Export the Intel® Quartus® Prime Software Lite environment variable:
```sh
export QUARTUS_ROOTDIR=/home/<user>/intelFPGA/17.1/quartus
```
12. Use `jtagconfig` to slow the clock:
```sh
jtagconfig --setparam 1 JtagClock 6M
```
13. (OPTIONAL) Confirm the clock is set to 6M:
```sh
jtagconfig --getparam 1 JtagClock
```
You should see the following:
```sh
6M
```
14. Go to `/opt/altera/aocl-pro-rte/aclrte-linux64/board/a10_1150_sg1/bringup`, where `boardtest_1ddr_top.aocx `is located:
```sh
cd /opt/altera/aocl-pro-rte/aclrte-linux64/board/a10_1150_sg1/bringup
```
15. Program the `boardtest_1ddr_top.aocx` file to the flash to be made permanently available even after power cycle:
```sh
aocl flash acl0 boardtest_1ddr_top.aocx
```
> **NOTE**: You will need the USB Blaster for this.
16. Reboot the host system.
17. Check if the host system recognizes the Intel® Vision Accelerator Design with Intel® Arria® 10 FPGA board. Confirm you can detect the PCIe card:
```sh
lspci | grep -i Altera
```
Your output is similar to:
```sh
01:00.0 Processing accelerators: Altera Corporation Device 2494 (rev 01)
```
18. Source the `setup_env.sh` script from the `fpga_support_files` directory to setup the environment variables:
```sh
source /home/<user>/Downloads/fpga_support_file/setup_env.sh
```
19. Uninstall the previous BSP before installing the OpenCL drivers for the R5 BSP:
```sh
aocl uninstall /opt/altera/aocl-pro-rte/aclrte-linux64/board/<BSP_package>/
```
20. Export and source the environment script:
```sh
export AOCL_BOARD_PACKAGE_ROOT=/opt/altera/aocl-pro-rte/aclrte-linux64/board/a10_1150_sg1
```
```sh
source /opt/altera/aocl-pro-rte/aclrte-linux64/init_opencl.sh
```
21. Install OpenCL™ devices:
```sh
aocl install
```
22. Run the `diagnose` command:
```sh
aocl diagnose
```
You should see `DIAGNOSTIC_PASSED` before proceeding to the next steps.
## 3. Program a Bitstream
The bitstream you program should correspond to the topology you want to deploy. In this section, you program a SqueezeNet bitstream and deploy the classification sample with a SqueezeNet model that you used the Model Optimizer to convert in the steps before.
> **IMPORTANT**: Only use bitstreams from the installed version of the Intel® Distribution of OpenVINO™ toolkit. Bitstreams from older versions of the Intel® Distribution of OpenVINO™ toolkit are incompatible with later versions of the Intel® Distribution of OpenVINO™ toolkit. For example, you cannot use the `1-0-1_A10DK_FP16_Generic` bitstream, when the Intel® Distribution of OpenVINO™ toolkit supports the `2-0-1_A10DK_FP16_Generic` bitstream.
Depending on how many bitstreams you selected, there are different folders for each FPGA card type which were downloaded in the Intel® Distribution of OpenVINO™ toolkit package:
1. For the Intel® Vision Accelerator Design with Intel® Arria® 10 FPGA the pre-trained bistreams are in `/opt/intel/openvino/bitstreams/a10_vision_design_bitstreams`. This example uses a SqueezeNet bitstream with low precision for the classification sample.
2. Rerun the environment setup script:
```sh
source /home/<user>/Downloads/fpga_support_files/setup_env.sh
```
3. Change to your home directory:
```sh
cd /home/<user>
```
4. Program the bitstream for the Intel® Vision Accelerator Design with Intel® Arria® 10 FPGA:
```sh
aocl program acl0 /opt/intel/openvino/bitstreams/a10_vision_design_bitstreams/5-0_PL1_FP11_SqueezeNet.aocx
```
### Optional Steps to Flash the FPGA Card
> **NOTE**:
> - To avoid having to reprogram the board after a power down, a bitstream will be programmed to permanent memory on the Intel® Vision Accelerator Design with Intel® Arria® 10 FPGA. This will take about 20 minutes.
> - The following steps 1-5 need to be done only once for a new Intel® Arria 10 FPGA card.
1. Plug in the micro USB cable to the card and your host system.
2. Run `jtagconfig` to ensure that the cable is properly inserted:
```sh
jtagconfig
```
3. Use `jtagconfig` to slow the clock:
```sh
jtagconfig --setparam 1 JtagClock 6M
```
4. Store the Intel® Vision Accelerator Design with Intel® Arria® 10 FPGA bitstream on the board:
```sh
aocl flash acl0 /opt/intel/openvino/bitstreams/a10_vision_design_bitstreams/5-0_PL1_FP11_SqueezeNet.aocx
```
Your output is similar to:
```sh
USB-BlasterII [1-14]
02E660DD 10AX115H1(.|E2|ES)/10AX115H2/..
020A40DD 5M(1270ZF324|2210Z)/EPM2210
```
## 4. Setup a Neural Network Model for FPGA
In this section, you will create an FP16 model suitable for hardware accelerators. For more information, see the [FPGA plugin](https://docs.openvinotoolkit.org/latest/_docs_IE_DG_supported_plugins_FPGA.html) section in the Inference Engine Developer Guide.
1. Create a directory for the FP16 SqueezeNet Model:
```sh
mkdir /home/<user>/squeezenet1.1_FP16
```
2. Go to `/home/<user>/squeezenet1.1_FP16`:
```sh
cd /home/<user>/squeezenet1.1_FP16
```
3. Use the Model Optimizer to convert an FP16 SqueezeNet Caffe* model into an optimized Intermediate Representation (IR):
```sh
python3 /opt/intel/openvino/deployment_tools/model_optimizer/mo.py --input_model /home/<user>/openvino_models/FP32/classification/squeezenet/1.1/caffe/squeezenet1.1.caffemodel --data_type FP16 --output_dir .
```
4. The `squeezenet1.1.labels` file contains the classes `ImageNet` uses. This file is included so that the inference results show text instead of classification numbers. Copy `squeezenet1.1.labels` to the your optimized model location:
```sh
cp /home/<user>/openvino_models/ir/squeezenet1.1/FP32/squeezenet1.1.labels .
```
5. Copy a sample image to the release directory. You will use this with your optimized model:
```sh
sudo cp /opt/intel/openvino/deployment_tools/demo/car.png ~/inference_engine_samples/intel64/Release
```
## 5. Run a Sample Application
1. Go to the samples directory
```sh
cd /home/<user>/inference_engine_samples/intel64/Release
```
2. Use an Inference Engine sample to run a sample application on the CPU:
```sh
./classification_sample_async -i car.png -m ~/openvino_models/ir/squeezenet1.1/FP32/squeezenet1.1.xml
```
Note the CPU throughput in Frames Per Second (FPS). This tells you how quickly the inference is done on the hardware. Now run the inference using the FPGA.
3. Add the `-d` option to target the FPGA:
```sh
./classification_sample_async -i car.png -m ~/squeezenet1.1_FP16/squeezenet1.1.xml -d HETERO:FPGA,CPU
```
The throughput on FPGA is listed and may show a lower FPS. This is due to the initialization time. To account for that, the next step increases the iterations to get a better sense of the speed the FPGA can run inference at.
4. Use `-ni` to increase the number of iterations, This option reduces the initialization impact:
```sh
./classification_sample_async -i car.png -m ~/squeezenet1.1_FP16/squeezenet1.1.xml -d HETERO:FPGA,CPU -ni 100
```
Congratulations, you are done with the Intel® Distribution of OpenVINO™ toolkit installation for FPGA.
## Additional Resources
Intel® Distribution of OpenVINO™ toolkit home page: [https://software.intel.com/en-us/openvino-toolkit](https://software.intel.com/en-us/openvino-toolkit)
Intel® Distribution of OpenVINO™ toolkit documentation: [https://docs.openvinotoolkit.org/](https://docs.openvinotoolkit.org/)
Inference Engine FPGA plugin documentation: [https://docs.openvinotoolkit.org/latest/_docs_IE_DG_supported_plugins_FPGA.html](https://docs.openvinotoolkit.org/latest/_docs_IE_DG_supported_plugins_FPGA.html)

View File

@ -1,281 +0,0 @@
# Configuration Guide for the Intel® Distribution of OpenVINO™ toolkit 2019R1 and the Intel® Vision Accelerator Design with an Intel® Arria® 10 FPGA (IEI's Mustang-F100-A10) on Linux* {#openvino_docs_install_guides_VisionAcceleratorFPGA_Configure_2019R1}
> **NOTES:**
> * For a first-time installation, use all steps.
> * Use step 1 only after receiving a new FPGA card.
> * Repeat steps 2-4 when installing a new version of the Intel® Distribution of OpenVINO™ toolkit.
> * Use steps 3-4 when a Neural Network topology used by an Intel® Distribution of OpenVINO™ toolkit application changes.
## 1. Configure and Set Up the Intel® Vision Accelerator Design with an Intel® Arria® 10 FPGA
For the 2019R1.x releases, the Intel® Distribution of OpenVINO™ toolkit introduced a new board support package (BSP) `a10_1150_sg1` for the Intel® Vision Accelerator Design with an Intel® Arria® 10 FPGA, which is included in the `fpga_support_files.tgz` archive below. To program the bitstreams for the Intel® Distribution of OpenVINO™ toolkit 2019R1.x, you need to program the BSP into the board using the USB blaster.
1. Download [Intel® Quartus® Prime Programmer and Tools Standard Edition 18.1](http://fpgasoftware.intel.com/18.1/?edition=standard&platform=linux&download_manager=direct#tabs-4). Install the Intel® Quartus® Prime Programmer and Tools Software to the `/home/<user>/intelFPGA/18.1` directory.
2. Download `fpga_support_files.tgz` from the [Intel Registration Center](http://registrationcenter-download.intel.com/akdlm/irc_nas/12954/fpga_support_files.tgz) to the `~/Downloads` directory. The files in this `.tgz` archive are required to ensure your FPGA card and the Intel® Distribution of OpenVINO™ toolkit work correctly.
3. Go to the directory where you downloaded the `fpga_support_files.tgz` archive.
4. Unpack the `.tgz` file:
```sh
tar -xvzf fpga_support_files.tgz
```
A directory named `fpga_support_files` is created.
5. Go to the `fpga_support_files` directory:
```sh
cd fpga_support_files
```
6. Switch to superuser:
```sh
sudo su
```
7. Use the `setup_env.sh` script from `fpga_support_files.tgz` to set your environment variables:
```sh
source /home/<user>/Downloads/fpga_support_files/setup_env.sh
```
8. Uninstall any previous BSP before installing the OpenCL BSP for the 2019R1.x BSP:
```sh
aocl uninstall /opt/altera/aocl-pro-rte/aclrte-linux64/board/<BSP_package>/
```
9. Change directory to `Downloads/fpga_support_files/`:
```sh
cd /home/<user>/Downloads/fpga_support_files/
```
10. Run the FPGA dependencies script, which allows OpenCL to support Ubuntu* and recent kernels:
```sh
./install_openvino_fpga_dependencies.sh
```
11. When asked, select the appropriate hardware accelerators you plan to use so it installs the correct dependencies.
12. If you installed the 4.14 kernel as part of the installation script, you will need to reboot the machine and select the new kernel in the Ubuntu (grub) boot menu. You will also need to rerun `setup_env.sh` to set up your environmental variables again.
13. Export the Intel® Quartus® Prime Programmer environment variable:
```sh
export QUARTUS_ROOTDIR=/home/<user>/intelFPGA/18.1/qprogrammer
```
14. Set up the USB Blaster:
1. Connect the cable between the board and the host system. Use the letter codes in the diagram below for the connection points:
2. Connect the B end of the cable to point B on the board.
3. Connect the F end of the cable to point F on the FPGA download cable.
4. From point F end of the cable to point F on the FPGA download cable, the connection is as shown:
![](../img/VisionAcceleratorJTAG.png)
15. Run `jtagconfig` to ensure that your Intel FPGA Download Cable driver is ready to use:
```sh
jtagconfig
```
Your output is similar to:
```sh
1) USB-Blaster [1-6]
02E660DD 10AX115H1(.|E2|ES)/10AX115H2/..
```
16. Use `jtagconfig` to slow the clock. The message "No parameter named JtagClock" can be safely ignored.
```sh
jtagconfig --setparam 1 JtagClock 6M
```
17. (OPTIONAL) Confirm the clock is set to 6M:
```sh
jtagconfig --getparam 1 JtagClock
```
You should see the following:
```sh
6M
```
18. Go to `/opt/altera/aocl-pro-rte/aclrte-linux64/board/a10_1150_sg1/bringup`, where `sg1_boardtest_2ddr_base.sof`is located:
```sh
cd /opt/altera/aocl-pro-rte/aclrte-linux64/board/a10_1150_sg1/bringup
```
19. Program the new sof file to the board:
```sh
quartus_pgm -c 1 -m JTAG -o "p;sg1_boardtest_2ddr_base.sof"
```
20. Soft reboot:
```sh
sudo reboot
```
21. Open up a new terminal and restore sudo access and the environment variables:
```sh
sudo su
source /home/<user>/Downloads/fpga_support_files/setup_env.sh
```
22. Install OpenCL™ devices. Enter **Y** when prompted to install:
```sh
aocl install
```
23. Reboot the machine:
```sh
reboot
```
24. Open up a new terminal and restore sudo access and the environment variables:
```sh
sudo su
source /home/<user>/Downloads/fpga_support_files/setup_env.sh
export QUARTUS_ROOTDIR=/home/<user>/intelFPGA/18.1/qprogrammer
```
25. Run `aocl diagnose`:
```sh
aocl diagnose
```
Your screen displays `DIAGNOSTIC_PASSED`.
26. Use `jtagconfig` to slow the clock. The message "No parameter named JtagClock" can be safely ignored.
```sh
jtagconfig --setparam 1 JtagClock 6M
```
27. Go to `/opt/intel/openvino/bitstreams/a10_vision_design_bitstreams/`, where `2019R1_PL1_FP11_ResNet_SqueezeNet_VGG.aocx `is located:
```sh
cd /opt/intel/openvino/bitstreams/a10_vision_design_bitstreams/
```
28. Program the `2019R1_PL1_FP11_ResNet_SqueezeNet_VGG.aocx` file to the flash to be made permanently available even after power cycle:
```sh
aocl flash acl0 2019R1_PL1_FP11_ResNet_SqueezeNet_VGG.aocx
```
> **NOTE**: You will need the USB Blaster for this.
29. Hard reboot the host system including powering off.
30. Now Soft reboot the host system to ensure the new PCIe device is seen properly
```sh
reboot
```
31. Open up a new terminal and restore sudo access and the environment variables:
```sh
sudo su
source /home/<user>/Downloads/fpga_support_files/setup_env.sh
```
32. Check if the host system recognizes the Intel® Vision Accelerator Design with Intel® Arria® 10 FPGA board. Confirm you can detect the PCIe card:
```sh
lspci | grep -i Altera
```
Your output is similar to:
```sh
01:00.0 Processing accelerators: Altera Corporation Device 2494 (rev 01)
```
33. Run `aocl diagnose`:
```sh
aocl diagnose
```
You should see `DIAGNOSTIC_PASSED` before proceeding to the next steps.
## 2. Program a Bitstream
The bitstream you program should correspond to the topology you want to deploy. In this section, you program a SqueezeNet bitstream and deploy the classification sample with a SqueezeNet model that you used the Model Optimizer to convert in the steps before.
> **IMPORTANT**: Only use bitstreams from the installed version of the Intel® Distribution of OpenVINO™ toolkit. Bitstreams from older versions of the Intel® Distribution of OpenVINO™ toolkit are incompatible with later versions of the Intel® Distribution of OpenVINO™ toolkit. For example, you cannot use the `1-0-1_A10DK_FP16_Generic` bitstream, when the Intel® Distribution of OpenVINO™ toolkit supports the `2-0-1_A10DK_FP16_Generic` bitstream.
Depending on how many bitstreams you selected, there are different folders for each FPGA card type which were downloaded in the Intel® Distribution of OpenVINO™ toolkit package:
1. For the Intel® Vision Accelerator Design with Intel® Arria® 10 FPGA the pre-trained bistreams are in `/opt/intel/openvino/bitstreams/a10_vision_design_bitstreams`. This example uses a SqueezeNet bitstream with low precision for the classification sample.
2. Rerun the environment setup script:
```sh
source /home/<user>/Downloads/fpga_support_files/setup_env.sh
```
3. Change to your home directory:
```sh
cd /home/<user>
```
4. Program the bitstream for the Intel® Vision Accelerator Design with Intel® Arria® 10 FPGA:
```sh
aocl program acl0 /opt/intel/openvino/bitstreams/a10_vision_design_bitstreams/2019R1_PL1_FP11_ResNet_SqueezeNet_VGG.aocx
```
### Steps to Flash the FPGA Card
> **NOTE**:
> - To avoid having to reprogram the board after a power down, a bitstream will be programmed to permanent memory on the Intel® Vision Accelerator Design with Intel® Arria® 10 FPGA. This will take about 20 minutes.
> - The steps can be followed in the [Configure and Setup the Intel® Vision Accelerator Design with an Intel® Arria® 10 FPGA](#1-configure-and-setup-the-intel-vision-accelerator-design-with-an-intel-arria-10-fpga) section of this guide from steps 14-18 and 28-36.
## 3. Setup a Neural Network Model for FPGA
In this section, you will create an FP16 model suitable for hardware accelerators. For more information, see the [FPGA plugin](https://docs.openvinotoolkit.org/latest/_docs_IE_DG_supported_plugins_FPGA.html) section in the Inference Engine Developer Guide.
1. Create a directory for the FP16 SqueezeNet Model:
```sh
mkdir /home/<user>/squeezenet1.1_FP16
```
2. Go to `/home/<user>/squeezenet1.1_FP16`:
```sh
cd /home/<user>/squeezenet1.1_FP16
```
3. Use the Model Optimizer to convert the FP32 SqueezeNet Caffe* model into an FP16 optimized Intermediate Representation (IR). The model files were downloaded when you ran the the Image Classification verification script while [installing the Intel® Distribution of OpenVINO™ toolkit for Linux* with FPGA Support](installing-openvino-linux-fpga.md). To convert, run the Model Optimizer script with the following arguments:
```sh
python3 /opt/intel/openvino/deployment_tools/model_optimizer/mo.py --input_model /home/<user>/openvino_models/models/FP32/classification/squeezenet/1.1/caffe/squeezenet1.1.caffemodel --data_type FP16 --output_dir .
```
4. The `squeezenet1.1.labels` file contains the classes `ImageNet` uses. This file is included so that the inference results show text instead of classification numbers. Copy `squeezenet1.1.labels` to the your optimized model location:
```sh
cp /home/<user>/openvino_models/ir/FP32/classification/squeezenet/1.1/caffe/squeezenet1.1.labels .
```
5. Copy a sample image to the release directory. You will use this with your optimized model:
```sh
sudo cp /opt/intel/openvino/deployment_tools/demo/car.png ~/inference_engine_samples_build/intel64/Release
```
## 4. Run a Sample Application
1. Go to the samples directory
```sh
cd /home/<user>/inference_engine_samples_build/intel64/Release
```
2. Use an Inference Engine sample to run a sample application on the CPU:
```sh
./classification_sample_async -i car.png -m ~/openvino_models/ir/FP32/classification/squeezenet/1.1/caffe/squeezenet1.1.xml
```
Note the CPU throughput in Frames Per Second (FPS). This tells you how quickly the inference is done on the hardware. Now run the inference using the FPGA.
3. Add the `-d` option to target the FPGA:
```sh
./classification_sample_async -i car.png -m ~/squeezenet1.1_FP16/squeezenet1.1.xml -d HETERO:FPGA,CPU
```
The throughput on FPGA is listed and may show a lower FPS. This is due to the initialization time. To account for that, the next step increases the iterations to get a better sense of the speed the FPGA can run inference at.
4. Use `-ni` to increase the number of iterations, This option reduces the initialization impact:
```sh
./classification_sample_async -i car.png -m ~/squeezenet1.1_FP16/squeezenet1.1.xml -d HETERO:FPGA,CPU -ni 100
```
Congratulations, you are done with the Intel® Distribution of OpenVINO™ toolkit installation for FPGA.
## Additional Resources
Intel® Distribution of OpenVINO™ toolkit home page: [https://software.intel.com/en-us/openvino-toolkit](https://software.intel.com/en-us/openvino-toolkit)
Intel® Distribution of OpenVINO™ toolkit documentation: [https://docs.openvinotoolkit.org/](https://docs.openvinotoolkit.org/)
Inference Engine FPGA plugin documentation: [https://docs.openvinotoolkit.org/latest/_docs_IE_DG_supported_plugins_FPGA.html](https://docs.openvinotoolkit.org/latest/_docs_IE_DG_supported_plugins_FPGA.html)

View File

@ -1,281 +0,0 @@
# Configuration Guide for the Intel® Distribution of OpenVINO™ toolkit 2019R3 and the Intel® Vision Accelerator Design with an Intel® Arria® 10 FPGA SG1 and SG2 (IEI's Mustang-F100-A10) on Linux* {#openvino_docs_install_guides_VisionAcceleratorFPGA_Configure_2019R3}
## 1. Configure and Set Up the Intel® Vision Accelerator Design with an Intel® Arria® 10 FPGA
1. Download [Intel® Quartus® Prime Programmer and Tools Standard Edition 18.1](http://fpgasoftware.intel.com/18.1/?edition=standard&platform=linux&download_manager=direct#tabs-4). Install the Intel® Quartus® Prime Programmer and Tools Software to the `/home/<user>/intelFPGA/18.1` directory.
2. Download `fpga_support_files.tgz` from the [Intel Registration Center](http://registrationcenter-download.intel.com/akdlm/irc_nas/12954/fpga_support_files.tgz) to the `~/Downloads` directory. The files in this `.tgz` archive are required to ensure your FPGA card and the Intel® Distribution of OpenVINO™ toolkit work correctly.
3. Go to the directory where you downloaded the `fpga_support_files.tgz` archive.
4. Unpack the `.tgz` file:
```sh
tar -xvzf fpga_support_files.tgz
```
A directory named `fpga_support_files` is created.
5. Switch to superuser:
```sh
sudo su
```
6. Change directory to `Downloads/fpga_support_files/`:
```sh
cd /home/<user>/Downloads/fpga_support_files/
```
7. Copy the USB Blaster Rules file:
```sh
cp config/51-usbblaster.rules /etc/udev/rules.d
udevadm control --reload-rules
udevadm trigger
```
8. Copy aocl fixes for latest kernels:
```sh
cp fixes/Command.pm /opt/altera/aocl-pro-rte/aclrte-linux64/share/lib/perl/acl/
cp config/blacklist-altera-cvp.conf /etc/modprobe.d/
```
9. Copy flash files so we don't need a full Quartus installation:
```sh
cp -r config/aocl_flash/linux64/* /home/<user>/intelFPGA/18.1/qprogrammer/linux64
```
10. Unpack the BSP for your appropriate Intel® Vision Accelerator Design with an Intel® Arria® 10 FPGA SG1 or SG2:
```sh
cd /opt/intel/openvino/bitstreams/a10_vision_design_sg<#>_bitstreams/BSP/
tar -xvzf a10_1150_sg<#>_r3.tgz
chmod -R 755 /opt/intel/openvino/bitstreams/a10_vision_design_sg<#>_bitstreams
```
> **NOTE**: If you do not know which version of the board you have, please refer to the product label on the fan cover side or by the product SKU: Mustang-F100-A10-R10 => SG1; Mustang-F100-A10E-R10 => SG2
11. Create an initialization script `/home/<user>/init_openvino.sh` with the following content that can be run upon opening a new terminal or rebooting. This will setup your proper environment variables.
```sh
export AOCL_BOARD_PACKAGE_ROOT=/opt/intel/openvino/bitstreams/a10_vision_design_sg<#>_bitstreams/BSP/a10_1150_sg<#>
export QUARTUS_ROOTDIR=/home/<user>/intelFPGA/18.1/qprogrammer
export PATH=$PATH:/opt/altera/aocl-pro-rte/aclrte-linux64/bin:/opt/altera/aocl-pro-rte/aclrte-linux64/host/linux64/bin:/home/<user>/intelFPGA/18.1/qprogrammer/bin
export INTELFPGAOCLSDKROOT=/opt/altera/aocl-pro-rte/aclrte-linux64
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$AOCL_BOARD_PACKAGE_ROOT/linux64/lib
export CL_CONTEXT_COMPILER_MODE_INTELFPGA=3
source /opt/altera/aocl-pro-rte/aclrte-linux64/init_opencl.sh
source /opt/intel/openvino/bin/setupvars.sh
```
12. Source the script.
```sh
source /home/<user>/init_openvino.sh
```
13. Uninstall any previous BSP before installing the OpenCL BSP for the 2019R3 BSP:
```sh
aocl uninstall /opt/altera/aocl-pro-rte/aclrte-linux64/board/<BSP_package>/
```
14. Set up the USB Blaster:
1. Connect the cable between the board and the host system. Use the letter codes in the diagram below for the connection points:
2. Connect the B end of the cable to point B on the board.
3. Connect the F end of the cable to point F on the FPGA download cable.
4. From point F end of the cable to point F on the FPGA download cable, the connection is as shown:
![](../img/VisionAcceleratorJTAG.png)
15. Run `jtagconfig` to ensure that your Intel FPGA Download Cable driver is ready to use:
```sh
jtagconfig
```
Your output is similar to:
```sh
1) USB-Blaster [1-6]
02E660DD 10AX115H1(.|E2|ES)/10AX115H2/..
```
16. Use `jtagconfig` to slow the clock. The message "No parameter named JtagClock" can be safely ignored.
```sh
jtagconfig --setparam 1 JtagClock 6M
```
17. (OPTIONAL) Confirm the clock is set to 6M:
```sh
jtagconfig --getparam 1 JtagClock
```
You should see the following:
```sh
6M
```
18. Go to `/opt/intel/openvino/bitstreams/a10_vision_design_sg<#>_bitstreams/BSP/a10_1150_sg<#>/bringup`, where `sg<#>_boardtest_2ddr_base.sof`is located:
```sh
cd /opt/intel/openvino/bitstreams/a10_vision_design_sg<#>_bitstreams/BSP/a10_1150_sg<#>/bringup
```
19. Program the new sof file to the board:
```sh
quartus_pgm -c 1 -m JTAG -o "p;sg<#>_boardtest_2ddr_base.sof"
```
20. Soft reboot:
```sh
reboot
```
21. Source the environment variable script you made.
```sh
sudo su
source /home/<user>/init_openvino.sh
```
22. Install OpenCL™ devices. Enter **Y** when prompted to install:
```sh
aocl install
```
23. Reboot the machine:
```sh
reboot
```
24. Source the environment variable script you made.
```sh
sudo su
source /home/<user>/init_openvino.sh
```
25. Run `aocl diagnose`:
```sh
aocl diagnose
```
Your screen displays `DIAGNOSTIC_PASSED`.
26. Use `jtagconfig` to slow the clock. The message "No parameter named JtagClock" can be safely ignored.
```sh
jtagconfig --setparam 1 JtagClock 6M
```
27. Go to `/opt/intel/openvino/bitstreams/a10_vision_design_sg<#>_bitstreams/`, where `2019R3_PV_PL<#>_FP11_InceptionV1_SqueezeNet.aocx `is located:
```sh
cd /opt/intel/openvino/bitstreams/a10_vision_design_sg<#>_bitstreams/
```
28. Program the `2019R3_PV_PL<#>_FP11_InceptionV1_SqueezeNet.aocx` file to the flash to be made permanently available even after power cycle:
```sh
aocl flash acl0 2019R3_PV_PL<#>_FP11_InceptionV1_SqueezeNet.aocx
```
> **NOTE**: You will need the USB Blaster for this.
29. Hard reboot the host system including powering off.
30. Source the environment variable script you made.
```sh
sudo su
source /home/<user>/init_openvino.sh
```
31. Check if the host system recognizes the Intel® Vision Accelerator Design with Intel® Arria® 10 FPGA board. Confirm you can detect the PCIe card:
```sh
lspci | grep -i Altera
```
Your output is similar to:
```sh
01:00.0 Processing accelerators: Altera Corporation Device 2494 (rev 01)
```
32. Run `aocl diagnose`:
```sh
aocl diagnose
```
You should see `DIAGNOSTIC_PASSED` before proceeding to the next steps.
## 2. Program a Bitstream
The bitstream you program should correspond to the topology you want to deploy. In this section, you program a SqueezeNet bitstream and deploy the classification sample with a SqueezeNet model that you used the Model Optimizer to convert in the steps before.
> **IMPORTANT**: Only use bitstreams from the installed version of the Intel® Distribution of OpenVINO™ toolkit. Bitstreams from older versions of the Intel® Distribution of OpenVINO™ toolkit are incompatible with later versions of the Intel® Distribution of OpenVINO™ toolkit. For example, you cannot use the `1-0-1_A10DK_FP16_Generic` bitstream, when the Intel® Distribution of OpenVINO™ toolkit supports the `2-0-1_A10DK_FP16_Generic` bitstream.
Depending on how many bitstreams you selected, there are different folders for each FPGA card type which were downloaded in the Intel® Distribution of OpenVINO™ toolkit package:
1. For the Intel® Vision Accelerator Design with Intel® Arria® 10 FPGA SG1 or SG2, the pre-trained bistreams are in `/opt/intel/openvino/bitstreams/a10_vision_design_sg<#>_bitstreams/`. This example uses a SqueezeNet bitstream with low precision for the classification sample.
2. Source the environment variable script you made.
```sh
source /home/<user>/init_openvino.sh
```
3. Change to your home directory:
```sh
cd /home/<user>
```
4. Program the bitstream for the Intel® Vision Accelerator Design with Intel® Arria® 10 FPGA SG1 or SG2:
```sh
aocl program acl0 /opt/intel/openvino/bitstreams/a10_vision_design_sg<#>_bitstreams/2019R3_PV_PL<#>_FP11_InceptionV1_SqueezeNet.aocx
```
### Steps to Flash the FPGA Card
> **NOTE**:
> - To avoid having to reprogram the board after a power down, a bitstream will be programmed to permanent memory on the Intel® Vision Accelerator Design with Intel® Arria® 10 FPGA. This will take about 20 minutes.
> - The steps can be followed above in this guide to do this.
## 3. Setup a Neural Network Model for FPGA
In this section, you will create an FP16 model suitable for hardware accelerators. For more information, see the [FPGA plugin](https://docs.openvinotoolkit.org/latest/_docs_IE_DG_supported_plugins_FPGA.html) section in the Inference Engine Developer Guide.
1. Create a directory for the FP16 SqueezeNet Model:
```sh
mkdir ~/squeezenet1.1_FP16
```
2. Go to `~/squeezenet1.1_FP16`:
```sh
cd ~/squeezenet1.1_FP16
```
3. Use the Model Optimizer to convert the FP32 SqueezeNet Caffe* model into an FP16 optimized Intermediate Representation (IR). The model files were downloaded when you ran the the Image Classification verification script while [installing the Intel® Distribution of OpenVINO™ toolkit for Linux* with FPGA Support](installing-openvino-linux-fpga.md). To convert, run the Model Optimizer script with the following arguments:
```sh
python3 /opt/intel/openvino/deployment_tools/model_optimizer/mo.py --input_model ~/openvino_models/models/FP16/public/squeezenet1.1/squeezenet1.1.caffemodel --data_type FP16 --output_dir .
```
4. The `squeezenet1.1.labels` file contains the classes `ImageNet` uses. This file is included so that the inference results show text instead of classification numbers. Copy `squeezenet1.1.labels` to the your optimized model location:
```sh
cp ~/openvino_models/ir/FP16/public/squeezenet1.1/squeezenet1.1.labels .
```
5. Copy a sample image to the release directory. You will use this with your optimized model:
```sh
cp /opt/intel/openvino/deployment_tools/demo/car.png ~/inference_engine_samples_build/intel64/Release
```
## 4. Run a Sample Application
1. Go to the samples directory
```sh
cd ~/inference_engine_samples_build/intel64/Release
```
2. Use an Inference Engine sample to run a sample application on the CPU:
```sh
./classification_sample_async -i car.png -m ~/openvino_models/ir/FP16/public/squeezenet1.1/squeezenet1.1.xml
```
Note the CPU throughput in Frames Per Second (FPS). This tells you how quickly the inference is done on the hardware. Now run the inference using the FPGA.
3. Add the `-d` option to target the FPGA:
```sh
./classification_sample_async -i car.png -m ~/openvino_models/ir/FP16/public/squeezenet1.1/squeezenet1.1.xml -d HETERO:FPGA,CPU
```
The throughput on FPGA is listed and may show a lower FPS. This may be due to the initialization time. To account for that, increase the number of iterations or batch size when deploying to get a better sense of the speed the FPGA can run inference at.
Congratulations, you are done with the Intel® Distribution of OpenVINO™ toolkit installation for FPGA.
## Additional Resources
Intel® Distribution of OpenVINO™ toolkit home page: [https://software.intel.com/en-us/openvino-toolkit](https://software.intel.com/en-us/openvino-toolkit)
Intel® Distribution of OpenVINO™ toolkit documentation: [https://docs.openvinotoolkit.org/](https://docs.openvinotoolkit.org/)
Inference Engine FPGA plugin documentation: [https://docs.openvinotoolkit.org/latest/_docs_IE_DG_supported_plugins_FPGA.html](https://docs.openvinotoolkit.org/latest/_docs_IE_DG_supported_plugins_FPGA.html)

View File

@ -1,21 +0,0 @@
# Configuration Guide for the Intel® Distribution of OpenVINO™ toolkit and the Intel® Vision Accelerator Design with an Intel® Arria® 10 FPGA SG2 (IEI's Mustang-F100-A10) on Windows* {#openvino_docs_install_guides_VisionAcceleratorFPGA_Configure_Windows}
## Product Change Notice
Intel® Distribution of OpenVINO™ toolkit for Intel® Vision Accelerator Design with an Intel® Arria® 10 FPGA and the Intel® Programmable Acceleration Card with Intel® Arria® 10 GX FPGA
<table>
<tr>
<td><strong>Change Notice Begins</strong></td>
<td>July 2020</td>
</tr>
<tr>
<td><strong>Change Date</strong></td>
<td>October 2020</td>
</tr>
</table>
Intel will be transitioning to the next-generation programmable deep-learning solution based on FPGAs in order to increase the level of customization possible in FPGA deep-learning. As part of this transition, future standard releases (i.e., non-LTS releases) of Intel® Distribution of OpenVINO™ toolkit will no longer include the Intel® Vision Accelerator Design with an Intel® Arria® 10 FPGA and the Intel® Programmable Acceleration Card with Intel® Arria® 10 GX FPGA.
Intel® Distribution of OpenVINO™ toolkit 2020.3.X LTS release will continue to support Intel® Vision Accelerator Design with an Intel® Arria® 10 FPGA and the Intel® Programmable Acceleration Card with Intel® Arria® 10 GX FPGA. For questions about next-generation programmable deep-learning solutions based on FPGAs, please talk to your sales representative or contact us to get the latest FPGA updates.
For documentation for previous releases of Intel® Distribution of OpenVINO™ toolkit for Windows* with FPGA Support, see documentation for the [2020.4 version](https://docs.openvinotoolkit.org/2020.4/openvino_docs_install_guides_VisionAcceleratorFPGA_Configure_Windows.html) and lower.

View File

@ -7,11 +7,11 @@ set(CMAKE_CXX_STANDARD 11)
set(TARGET_NAME "onnx_custom_op") set(TARGET_NAME "onnx_custom_op")
find_package(ngraph REQUIRED COMPONENTS onnx_ngraph_frontend) find_package(OpenVINO REQUIRED COMPONENTS ONNX)
add_library(${TARGET_NAME} STATIC onnx_custom_op.cpp onnx_custom_op.hpp) add_library(${TARGET_NAME} STATIC onnx_custom_op.cpp onnx_custom_op.hpp)
target_link_libraries(${TARGET_NAME} PUBLIC ngraph::ngraph ngraph::onnx_ngraph_frontend) target_link_libraries(${TARGET_NAME} PUBLIC openvino::core openvino::frontend::onnx)
# [cmake:onnx_custom_op] # [cmake:onnx_custom_op]
# Enable code style check # Enable code style check

View File

@ -2,63 +2,60 @@
**Versioned name**: *GatherTree-1* **Versioned name**: *GatherTree-1*
**Category**: Beam search post-processing **Category**: *Data movement*
**Short description**: Generates the complete beams from the ids per each step and the parent beam ids. **Short description**: Generates the complete beams from the ids per each step and the parent beam ids.
**Detailed description** **Detailed description**
The GatherTree operation implements the same algorithm as the [GatherTree operation in TensorFlow](https://www.tensorflow.org/addons/api_docs/python/tfa/seq2seq/gather_tree). *GatherTree* operation reorders token IDs of a given input tensor `step_id` representing IDs per each step of beam search, based on input tensor `parent_ids` representing the parent beam IDs. For a given beam, past the time step containing the first decoded `end_token` all values are filled in with end_token.
Pseudo code: The algorithm in pseudocode is as follows:
```python ```python
final_idx[ :, :, :] = end_token final_ids[ :, :, :] = end_token
for batch in range(BATCH_SIZE): for batch in range(BATCH_SIZE):
for beam in range(BEAM_WIDTH): for beam in range(BEAM_WIDTH):
max_sequence_in_beam = min(MAX_TIME, max_seq_len[batch]) max_sequence_in_beam = min(MAX_TIME, max_seq_len[batch])
parent = parent_idx[max_sequence_in_beam - 1, batch, beam] parent = parent_ids[max_sequence_in_beam - 1, batch, beam]
final_idx[max_sequence_in_beam - 1, batch, beam] = step_idx[max_sequence_in_beam - 1, batch, beam] final_ids[max_sequence_in_beam - 1, batch, beam] = step_ids[max_sequence_in_beam - 1, batch, beam]
for level in reversed(range(max_sequence_in_beam - 1)): for level in reversed(range(max_sequence_in_beam - 1)):
final_idx[level, batch, beam] = step_idx[level, batch, parent] final_ids[level, batch, beam] = step_ids[level, batch, parent]
parent = parent_idx[level, batch, parent] parent = parent_ids[level, batch, parent]
# For a given beam, past the time step containing the first decoded end_token # For a given beam, past the time step containing the first decoded end_token
# all values are filled in with end_token. # all values are filled in with end_token.
finished = False finished = False
for time in range(max_sequence_in_beam): for time in range(max_sequence_in_beam):
if(finished): if(finished):
final_idx[time, batch, beam] = end_token final_ids[time, batch, beam] = end_token
elif(final_idx[time, batch, beam] == end_token): elif(final_ids[time, batch, beam] == end_token):
finished = True finished = True
``` ```
Element data types for all input tensors should match each other. *GatherTree* operation is equivalent to [GatherTree operation in TensorFlow](https://www.tensorflow.org/addons/api_docs/python/tfa/seq2seq/gather_tree).
**Attributes**: *GatherTree* has no attributes **Attributes**: *GatherTree* operation has no attributes.
**Inputs** **Inputs**
* **1**: `step_ids` -- a tensor of shape `[MAX_TIME, BATCH_SIZE, BEAM_WIDTH]` of type *T* with indices from per each step. **Required.** * **1**: `step_ids` - Indices per each step. A tensor of type *T* and rank 3. Layout is `[MAX_TIME, BATCH_SIZE, BEAM_WIDTH]`. **Required.**
* **2**: `parent_ids` - Parent beam indices. A tensor of type *T* and rank 3. Layout is `[MAX_TIME, BATCH_SIZE, BEAM_WIDTH]`. **Required.**
* **2**: `parent_idx` -- a tensor of shape `[MAX_TIME, BATCH_SIZE, BEAM_WIDTH]` of type *T* with parent beam indices. **Required.** * **3**: `max_seq_len` - Maximum lengths for each sequence in the batch. A tensor of type *T* and rank 1. Layout is `[BATCH_SIZE]`. **Required.**
* **4**: `end_token` - Value of the end marker in a sequence. A scalar of type *T*. **Required.**
* **3**: `max_seq_len` -- a tensor of shape `[BATCH_SIZE]` of type *T* with maximum lengths for each sequence in the batch. **Required.** * **Note**: Inputs should have integer values only.
* **4**: `end_token` -- a scalar tensor of type *T* with value of the end marker in a sequence. **Required.**
**Outputs** **Outputs**
* **1**: `final_idx` -- a tensor of shape `[MAX_TIME, BATCH_SIZE, BEAM_WIDTH]` of type *T*. * **1**: `final_ids` - The reordered token IDs based on `parent_ids` input. A tensor of type *T* and rank 3. Layout is `[MAX_TIME, BATCH_SIZE, BEAM_WIDTH]`.
**Types** **Types**
* *T*: `float32` or `int32`; `float32` should have integer values only. * *T*: any supported numeric type.
**Example** **Example**

View File

@ -7,30 +7,28 @@ set(CMAKE_CXX_STANDARD 11)
set(TARGET_NAME "template_extension") set(TARGET_NAME "template_extension")
find_package(ngraph REQUIRED OPTIONAL_COMPONENTS onnx_ngraph_frontend) find_package(OpenVINO REQUIRED COMPONENTS Runtime OPTIONAL_COMPONENTS ONNX)
find_package(InferenceEngine REQUIRED)
find_package(OpenCV QUIET COMPONENTS core) find_package(OpenCV QUIET COMPONENTS core)
set(SRC cpu_kernel.cpp extension.cpp op.cpp) set(SRC cpu_kernel.cpp extension.cpp op.cpp)
if (OpenCV_FOUND) if(OpenCV_FOUND)
set(SRC ${SRC} fft_kernel.cpp fft_op.cpp) set(SRC ${SRC} fft_kernel.cpp fft_op.cpp)
endif() endif()
add_library(${TARGET_NAME} MODULE ${SRC}) add_library(${TARGET_NAME} MODULE ${SRC})
if (OpenCV_FOUND) if(OpenCV_FOUND)
target_compile_definitions(${TARGET_NAME} PRIVATE OPENCV_IMPORT_ENABLED) target_compile_definitions(${TARGET_NAME} PRIVATE OPENCV_IMPORT_ENABLED)
target_link_libraries(${TARGET_NAME} PRIVATE opencv_core) target_link_libraries(${TARGET_NAME} PRIVATE opencv_core)
endif() endif()
target_compile_definitions(${TARGET_NAME} PRIVATE IMPLEMENT_INFERENCE_EXTENSION_API) target_compile_definitions(${TARGET_NAME} PRIVATE IMPLEMENT_INFERENCE_EXTENSION_API)
target_link_libraries(${TARGET_NAME} PRIVATE IE::inference_engine target_link_libraries(${TARGET_NAME} PRIVATE openvino::core openvino::runtime)
${NGRAPH_LIBRARIES})
if (ngraph_onnx_ngraph_frontend_FOUND) if(OpenVINO_Frontend_ONNX_FOUND)
target_link_libraries(${TARGET_NAME} PRIVATE ngraph::onnx_ngraph_frontend) target_link_libraries(${TARGET_NAME} PRIVATE openvino::frontend::onnx)
target_compile_definitions(${TARGET_NAME} PRIVATE NGRAPH_ONNX_FRONTEND_ENABLED) target_compile_definitions(${TARGET_NAME} PRIVATE OPENVINO_ONNX_FRONTEND_ENABLED)
endif() endif()
# [cmake:extension] # [cmake:extension]

View File

@ -11,7 +11,7 @@
# include "fft_op.hpp" # include "fft_op.hpp"
#endif #endif
#include <ngraph/ngraph.hpp> #include <ngraph/ngraph.hpp>
#ifdef NGRAPH_ONNX_FRONTEND_ENABLED #ifdef OPENVINO_ONNX_FRONTEND_ENABLED
# include <onnx_import/onnx_utils.hpp> # include <onnx_import/onnx_utils.hpp>
#endif #endif
@ -24,7 +24,7 @@ using namespace TemplateExtension;
//! [extension:ctor] //! [extension:ctor]
Extension::Extension() { Extension::Extension() {
#ifdef NGRAPH_ONNX_FRONTEND_ENABLED #ifdef OPENVINO_ONNX_FRONTEND_ENABLED
ngraph::onnx_import::register_operator(Operation::type_info.name, ngraph::onnx_import::register_operator(Operation::type_info.name,
1, 1,
"custom_domain", "custom_domain",
@ -49,12 +49,12 @@ Extension::Extension() {
//! [extension:dtor] //! [extension:dtor]
Extension::~Extension() { Extension::~Extension() {
#ifdef NGRAPH_ONNX_FRONTEND_ENABLED #ifdef OPENVINO_ONNX_FRONTEND_ENABLED
ngraph::onnx_import::unregister_operator(Operation::type_info.name, 1, "custom_domain"); ngraph::onnx_import::unregister_operator(Operation::type_info.name, 1, "custom_domain");
# ifdef OPENCV_IMPORT_ENABLED # ifdef OPENCV_IMPORT_ENABLED
ngraph::onnx_import::unregister_operator(FFTOp::type_info.name, 1, "custom_domain"); ngraph::onnx_import::unregister_operator(FFTOp::type_info.name, 1, "custom_domain");
# endif // OPENCV_IMPORT_ENABLED # endif // OPENCV_IMPORT_ENABLED
#endif // NGRAPH_ONNX_FRONTEND_ENABLED #endif // OPENVINO_ONNX_FRONTEND_ENABLED
} }
//! [extension:dtor] //! [extension:dtor]

View File

@ -0,0 +1,100 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include <ie_core.hpp>
#include <ie_ngraph_utils.hpp>
#include <limits>
#include <algorithm>
#include <ngraph/ngraph.hpp>
#include <shared_test_classes/base/layer_test_utils.hpp>
#include "base_reference_test.hpp"
using namespace reference_tests;
using namespace ngraph;
using namespace InferenceEngine;
namespace {
struct GatherTreeParams {
template <class IN_ET>
GatherTreeParams(const ngraph::Shape inShape, std::vector<IN_ET> stepIds, const std::vector<IN_ET> parentIds,
const std::vector<IN_ET> maxSeqLen, const std::vector<IN_ET> endToken, std::vector<IN_ET> output) :
stepIdsTensor(inShape, element::from<IN_ET>(), stepIds), parentIdsTensor(inShape, element::from<IN_ET>(), parentIds),
maxSeqLenTensor(ngraph::Shape{inShape[1]}, element::from<IN_ET>(), maxSeqLen), endTokenTensor(ngraph::Shape{}, element::from<IN_ET>(), endToken),
expectedTensor(inShape, element::from<IN_ET>(), output) {}
Tensor stepIdsTensor;
Tensor parentIdsTensor;
Tensor maxSeqLenTensor;
Tensor endTokenTensor;
Tensor expectedTensor;
};
class ReferenceGatherTreeTest : public testing::TestWithParam<GatherTreeParams>, public CommonReferenceTest {
public:
void SetUp() override {
auto params = GetParam();
function = CreateFunction(params);
inputData = {params.stepIdsTensor.data, params.parentIdsTensor.data, params.maxSeqLenTensor.data, params.endTokenTensor.data};
refOutData = {params.expectedTensor.data};
}
static std::string getTestCaseName(const testing::TestParamInfo<GatherTreeParams>& obj) {
auto param = obj.param;
std::ostringstream result;
result << "iType=" << param.stepIdsTensor.type << "_";
result << "iShape=" << param.stepIdsTensor.shape;
return result.str();
}
private:
static std::shared_ptr<Function> CreateFunction(const GatherTreeParams& params) {
const auto stepIds = std::make_shared<op::Parameter>(params.stepIdsTensor.type, params.stepIdsTensor.shape);
const auto parentIds = std::make_shared<op::Parameter>(params.parentIdsTensor.type, params.parentIdsTensor.shape);
const auto maxSeqLen = std::make_shared<op::Parameter>(params.maxSeqLenTensor.type, params.maxSeqLenTensor.shape);
const auto endToken = std::make_shared<op::Parameter>(params.endTokenTensor.type, params.endTokenTensor.shape);
const auto gatherTree = std::make_shared<op::v1::GatherTree>(stepIds, parentIds, maxSeqLen, endToken);
return std::make_shared<Function>(NodeVector {gatherTree}, ParameterVector {stepIds, parentIds, maxSeqLen, endToken});
}
};
TEST_P(ReferenceGatherTreeTest, CompareWithRefs) {
Exec();
}
template <element::Type_t IN_ET>
std::vector<GatherTreeParams> generateGatherTreeParams() {
using T = typename element_type_traits<IN_ET>::value_type;
std::vector<GatherTreeParams> gatherTreeParams {
GatherTreeParams(Shape{4, 1, 3},
std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1},
std::vector<T>{0, 0, 0, 0, 1, 1, 2, 1, 2, -1, -1, -1},
std::vector<T>{3},
std::vector<T>{10},
std::vector<T>{2, 2, 2, 6, 5, 6, 7, 8, 9, 10, 10, 10}),
GatherTreeParams(Shape{2, 2, 2},
std::vector<T>{1, 2, 3, 4, 5, 6, 7, 8},
std::vector<T>{0, 0, 0, 0, 0, 0, 0, 0},
std::vector<T>{2, 4},
std::vector<T>{0},
std::vector<T>{1, 1, 3, 3, 5, 6, 7, 8})
};
return gatherTreeParams;
}
std::vector<GatherTreeParams> generateGatherTreeCombinedParams() {
const std::vector<std::vector<GatherTreeParams>> gatherTreeTypeParams {
generateGatherTreeParams<element::Type_t::f32>(),
generateGatherTreeParams<element::Type_t::i32>()};
std::vector<GatherTreeParams> combinedParams;
for (const auto& params : gatherTreeTypeParams) {
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
}
return combinedParams;
}
INSTANTIATE_TEST_SUITE_P(smoke_GatherTree_With_Hardcoded_Refs, ReferenceGatherTreeTest,
testing::ValuesIn(generateGatherTreeCombinedParams()), ReferenceGatherTreeTest::getTestCaseName);
} // namespace

View File

@ -10,11 +10,11 @@ file(GLOB HEADERS ${InferenceEngine_C_API_SOURCE_DIR}/include/*.h)
# create library # create library
add_library(${TARGET_NAME} SHARED ${HEADERS} ${SOURCES}) add_library(${TARGET_NAME} SHARED ${HEADERS} ${SOURCES})
add_library(openvino::runtime::c ALIAS ${TARGET_NAME})
target_link_libraries(${TARGET_NAME} PRIVATE inference_engine) target_link_libraries(${TARGET_NAME} PRIVATE inference_engine)
target_include_directories(${TARGET_NAME} PUBLIC target_include_directories(${TARGET_NAME} PUBLIC
$<INSTALL_INTERFACE:${IE_CPACK_IE_DIR}/include/ie>
$<BUILD_INTERFACE:${InferenceEngine_C_API_SOURCE_DIR}/include>) $<BUILD_INTERFACE:${InferenceEngine_C_API_SOURCE_DIR}/include>)
add_cpplint_target(${TARGET_NAME}_cpplint FOR_TARGETS ${TARGET_NAME}) add_cpplint_target(${TARGET_NAME}_cpplint FOR_TARGETS ${TARGET_NAME})
@ -29,6 +29,10 @@ ie_add_vs_version_file(NAME ${TARGET_NAME}
export(TARGETS ${TARGET_NAME} NAMESPACE IE:: export(TARGETS ${TARGET_NAME} NAMESPACE IE::
APPEND FILE "${CMAKE_BINARY_DIR}/InferenceEngineTargets.cmake") APPEND FILE "${CMAKE_BINARY_DIR}/InferenceEngineTargets.cmake")
set_target_properties(${TARGET_NAME} PROPERTIES EXPORT_NAME runtime::c)
export(TARGETS ${TARGET_NAME} NAMESPACE openvino::
APPEND FILE "${CMAKE_BINARY_DIR}/OpenVINOTargets.cmake")
# install # install
ie_cpack_add_component(core_c DEPENDS core) ie_cpack_add_component(core_c DEPENDS core)
@ -37,7 +41,14 @@ ie_cpack_add_component(core_c_dev DEPENDS core_c)
install(TARGETS ${TARGET_NAME} EXPORT InferenceEngineTargets install(TARGETS ${TARGET_NAME} EXPORT InferenceEngineTargets
RUNTIME DESTINATION ${IE_CPACK_RUNTIME_PATH} COMPONENT core_c RUNTIME DESTINATION ${IE_CPACK_RUNTIME_PATH} COMPONENT core_c
ARCHIVE DESTINATION ${IE_CPACK_ARCHIVE_PATH} COMPONENT core_c ARCHIVE DESTINATION ${IE_CPACK_ARCHIVE_PATH} COMPONENT core_c
LIBRARY DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT core_c) LIBRARY DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT core_c
INCLUDES DESTINATION ${IE_CPACK_IE_DIR}/include/ie)
install(TARGETS ${TARGET_NAME} EXPORT OpenVINOTargets
RUNTIME DESTINATION ${IE_CPACK_RUNTIME_PATH} COMPONENT core_c
ARCHIVE DESTINATION ${IE_CPACK_ARCHIVE_PATH} COMPONENT core_c
LIBRARY DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT core_c
INCLUDES DESTINATION ${IE_CPACK_IE_DIR}/include/ie)
install(DIRECTORY ${InferenceEngine_C_API_SOURCE_DIR}/include/ install(DIRECTORY ${InferenceEngine_C_API_SOURCE_DIR}/include/
DESTINATION ${IE_CPACK_IE_DIR}/include/ie DESTINATION ${IE_CPACK_IE_DIR}/include/ie

View File

@ -8,11 +8,8 @@ cmake_minimum_required (VERSION 3.13)
# Set the project name # Set the project name
project (ie_python_api) project (ie_python_api)
if(DEFINED OpenVINO_SOURCE_DIR) if(NOT DEFINED OpenVINO_SOURCE_DIR)
set(InferenceEngine_LIBRARIES inference_engine)
else()
find_package(InferenceEngineDeveloperPackage REQUIRED) find_package(InferenceEngineDeveloperPackage REQUIRED)
set(InferenceEngine_LIBRARIES IE::inference_engine)
endif() endif()
option(ENABLE_CONDA_FOLDER "Create output folder with conda python bindings" OFF) option(ENABLE_CONDA_FOLDER "Create output folder with conda python bindings" OFF)

View File

@ -11,6 +11,7 @@ from functools import reduce
import cv2 import cv2
import ngraph import ngraph
from ngraph.opset1 import max_pool
import numpy as np import numpy as np
from openvino.inference_engine import IECore, IENetwork from openvino.inference_engine import IECore, IENetwork
@ -85,7 +86,7 @@ def create_ngraph_function(args: argparse.Namespace) -> ngraph.impl.Function:
add_1_node = ngraph.add(conv_1_node, add_1_kernel) add_1_node = ngraph.add(conv_1_node, add_1_kernel)
# maxpool 1 # maxpool 1
maxpool_1_node = ngraph.max_pool(add_1_node, [2, 2], padding_begin, padding_end, [2, 2], 'ceil', None) maxpool_1_node = max_pool(add_1_node, [2, 2], padding_begin, padding_end, [2, 2], 'ceil')
# convolution 2 # convolution 2
conv_2_kernel_shape, conv_2_kernel_length = shape_and_length([50, 20, 5, 5]) conv_2_kernel_shape, conv_2_kernel_length = shape_and_length([50, 20, 5, 5])
@ -104,7 +105,7 @@ def create_ngraph_function(args: argparse.Namespace) -> ngraph.impl.Function:
add_2_node = ngraph.add(conv_2_node, add_2_kernel) add_2_node = ngraph.add(conv_2_node, add_2_kernel)
# maxpool 2 # maxpool 2
maxpool_2_node = ngraph.max_pool(add_2_node, [2, 2], padding_begin, padding_end, [2, 2], 'ceil', None) maxpool_2_node = max_pool(add_2_node, [2, 2], padding_begin, padding_end, [2, 2], 'ceil')
# reshape 1 # reshape 1
reshape_1_dims, reshape_1_length = shape_and_length([2]) reshape_1_dims, reshape_1_length = shape_and_length([2])

View File

@ -31,7 +31,7 @@ foreach(PYX_FILE IN LISTS PYX_SOURCES)
ov_python_disable_intel_warnings(${PYX_NAME}) ov_python_disable_intel_warnings(${PYX_NAME})
add_dependencies(${TARGET_NAME} ${PYX_NAME}) add_dependencies(${TARGET_NAME} ${PYX_NAME})
target_include_directories(${PYX_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") target_include_directories(${PYX_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
target_link_libraries(${PYX_NAME} PRIVATE ${InferenceEngine_LIBRARIES}) target_link_libraries(${PYX_NAME} PRIVATE openvino::runtime)
list(APPEND INSTALLED_TARGETS ${PYX_NAME}) list(APPEND INSTALLED_TARGETS ${PYX_NAME})
ie_python_minimal_api(${PYX_NAME}) ie_python_minimal_api(${PYX_NAME})
endforeach() endforeach()
@ -53,7 +53,7 @@ python_disable_deprecated_warnings()
ie_python_minimal_api(${TARGET_NAME}) ie_python_minimal_api(${TARGET_NAME})
target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
target_link_libraries(${TARGET_NAME} PRIVATE ${InferenceEngine_LIBRARIES}) target_link_libraries(${TARGET_NAME} PRIVATE openvino::runtime)
# Compatibility with python 2.7 which has deprecated "register" specifier # Compatibility with python 2.7 which has deprecated "register" specifier
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")

View File

@ -4,10 +4,8 @@
#include "ie_api_impl.hpp" #include "ie_api_impl.hpp"
#include <ngraph/partial_shape.hpp>
#include "ie_iinfer_request.hpp"
#include "ie_plugin_config.hpp" #include "ie_plugin_config.hpp"
#include "ngraph/partial_shape.hpp"
const std::string EXPORTED_NETWORK_NAME = "undefined"; const std::string EXPORTED_NETWORK_NAME = "undefined";
std::map<std::string, InferenceEngine::Precision> precision_map = {{"FP32", InferenceEngine::Precision::FP32}, std::map<std::string, InferenceEngine::Precision> precision_map = {{"FP32", InferenceEngine::Precision::FP32},

View File

@ -4,12 +4,9 @@
#pragma once #pragma once
#include <ie_extension.h>
#include <algorithm> #include <algorithm>
#include <chrono> #include <chrono>
#include <condition_variable> #include <condition_variable>
#include <ie_core.hpp>
#include <iostream> #include <iostream>
#include <iterator> #include <iterator>
#include <list> #include <list>
@ -23,6 +20,7 @@
#include <vector> #include <vector>
#include "Python.h" #include "Python.h"
#include "ie_core.hpp"
typedef std::chrono::high_resolution_clock Time; typedef std::chrono::high_resolution_clock Time;
typedef std::chrono::nanoseconds ns; typedef std::chrono::nanoseconds ns;

View File

@ -30,14 +30,14 @@ if(COMMAND ie_add_vs_version_file)
endif() endif()
if(TARGET offline_transformations) if(TARGET offline_transformations)
list(APPEND InferenceEngine_LIBRARIES offline_transformations) list(APPEND link_libraries offline_transformations)
else() else()
list(APPEND InferenceEngine_LIBRARIES IE::offline_transformations) list(APPEND link_libraries IE::offline_transformations)
endif() endif()
target_include_directories(${TARGET_NAME} SYSTEM PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../inference_engine") target_include_directories(${TARGET_NAME} SYSTEM PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../inference_engine")
target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
target_link_libraries(${TARGET_NAME} PRIVATE ${InferenceEngine_LIBRARIES}) target_link_libraries(${TARGET_NAME} PRIVATE openvino::runtime ${link_libraries})
# Compatibility with python 2.7 which has deprecated "register" specifier # Compatibility with python 2.7 which has deprecated "register" specifier
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")

View File

@ -30,14 +30,14 @@ if(COMMAND ie_add_vs_version_file)
endif() endif()
if(TARGET commonTestUtils) if(TARGET commonTestUtils)
list(APPEND InferenceEngine_LIBRARIES commonTestUtils) list(APPEND link_libraries commonTestUtils)
else() else()
list(APPEND InferenceEngine_LIBRARIES IE::commonTestUtils) list(APPEND link_libraries IE::commonTestUtils)
endif() endif()
target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
target_include_directories(${TARGET_NAME} SYSTEM PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../inference_engine") target_include_directories(${TARGET_NAME} SYSTEM PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../inference_engine")
target_link_libraries(${TARGET_NAME} PRIVATE ${InferenceEngine_LIBRARIES}) target_link_libraries(${TARGET_NAME} PRIVATE ${link_libraries})
# Compatibility with python 2.7 which has deprecated "register" specifier # Compatibility with python 2.7 which has deprecated "register" specifier
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")

View File

@ -33,11 +33,8 @@ endif()
if(OpenVINO_SOURCE_DIR) if(OpenVINO_SOURCE_DIR)
# in case if samples are built from IE repo # in case if samples are built from IE repo
set(IE_MAIN_SAMPLES_DIR ${OpenVINO_SOURCE_DIR}) set(IE_MAIN_SAMPLES_DIR "${OpenVINO_SOURCE_DIR}")
# hint for find_package(InferenceEngine in the samples folder) set(OpenVINO_DIR "${CMAKE_BINARY_DIR}")
set(InferenceEngine_DIR "${CMAKE_BINARY_DIR}")
# hint for find_package(ngraph in the samples folder)
set(ngraph_DIR ${CMAKE_BINARY_DIR}/ngraph)
else() else()
# in case if samples are built out of IE repo # in case if samples are built out of IE repo
set(IE_MAIN_SAMPLES_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(IE_MAIN_SAMPLES_DIR ${CMAKE_CURRENT_BINARY_DIR})
@ -128,8 +125,8 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/common/utils")
add_subdirectory(common/utils) add_subdirectory(common/utils)
endif() endif()
# format reader must be added after find_package(InferenceEngine) to get # format reader must be added after find_package(OpenVINO) to get
# exactly the same OpenCV_DIR path which was used for the InferenceEngine build # exactly the same OpenCV_DIR path which was used for the OpenVINO build
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/common/format_reader") if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/common/format_reader")
add_subdirectory(common/format_reader) add_subdirectory(common/format_reader)
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/common/opencv_c_wrapper") elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/common/opencv_c_wrapper")
@ -209,14 +206,13 @@ macro(ie_add_sample)
set(folder_name c_samples) set(folder_name c_samples)
endif() endif()
find_package(OpenVINO REQUIRED COMPONENTS Runtime)
if(c_sample) if(c_sample)
set(ie_component inference_engine_c_api) set(ov_link_libraries openvino::runtime::c)
else() else()
set(ie_component inference_engine) set(ov_link_libraries openvino::runtime)
endif() endif()
find_package(InferenceEngine REQUIRED COMPONENTS ${ie_component})
set_target_properties(${IE_SAMPLE_NAME} PROPERTIES FOLDER ${folder_name} set_target_properties(${IE_SAMPLE_NAME} PROPERTIES FOLDER ${folder_name}
COMPILE_PDB_NAME ${IE_SAMPLE_NAME}) COMPILE_PDB_NAME ${IE_SAMPLE_NAME})
@ -225,7 +221,7 @@ macro(ie_add_sample)
endif() endif()
target_include_directories(${IE_SAMPLE_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../common") target_include_directories(${IE_SAMPLE_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../common")
target_link_libraries(${IE_SAMPLE_NAME} PRIVATE ${OpenCV_LIBRARIES} ${InferenceEngine_LIBRARIES} target_link_libraries(${IE_SAMPLE_NAME} PRIVATE ${OpenCV_LIBRARIES} ${ov_link_libraries}
${IE_SAMPLE_DEPENDENCIES}) ${IE_SAMPLE_DEPENDENCIES})
if(NOT c_sample) if(NOT c_sample)
target_link_libraries(${IE_SAMPLE_NAME} PRIVATE gflags) target_link_libraries(${IE_SAMPLE_NAME} PRIVATE gflags)

View File

@ -12,9 +12,9 @@ set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "src")
target_include_directories(${TARGET_NAME} target_include_directories(${TARGET_NAME}
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
find_package(InferenceEngine REQUIRED COMPONENTS inference_engine) find_package(OpenVINO REQUIRED COMPONENTS Runtime)
target_link_libraries(${TARGET_NAME} PUBLIC ${InferenceEngine_LIBRARIES} gflags) target_link_libraries(${TARGET_NAME} PUBLIC openvino::runtime gflags)
if(COMMAND add_clang_format_target) if(COMMAND add_clang_format_target)
add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME}) add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME})

View File

@ -7,6 +7,3 @@ ie_add_sample(NAME hello_reshape_ssd
HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/reshape_ssd_extension.hpp" HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/reshape_ssd_extension.hpp"
DEPENDENCIES ie_samples_utils DEPENDENCIES ie_samples_utils
OPENCV_DEPENDENCIES core imgproc imgcodecs) OPENCV_DEPENDENCIES core imgproc imgcodecs)
find_package(ngraph REQUIRED)
target_link_libraries(hello_reshape_ssd PRIVATE ${NGRAPH_LIBRARIES})

View File

@ -8,6 +8,3 @@ ie_add_sample(NAME ngraph_function_creation_sample
SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp" SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp"
HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/ngraph_function_creation_sample.hpp" HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/ngraph_function_creation_sample.hpp"
DEPENDENCIES format_reader ie_samples_utils) DEPENDENCIES format_reader ie_samples_utils)
find_package(ngraph REQUIRED)
target_link_libraries(${TARGET_NAME} PRIVATE ${NGRAPH_LIBRARIES})

View File

@ -6,6 +6,3 @@ ie_add_sample(NAME object_detection_sample_ssd
SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp" SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp"
HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/object_detection_sample_ssd.h" HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/object_detection_sample_ssd.h"
DEPENDENCIES format_reader ie_samples_utils) DEPENDENCIES format_reader ie_samples_utils)
find_package(ngraph REQUIRED)
target_link_libraries(object_detection_sample_ssd PRIVATE ${NGRAPH_LIBRARIES})

View File

@ -120,12 +120,12 @@ ie_faster_build(${TARGET_NAME}_obj
) )
target_compile_definitions(${TARGET_NAME}_obj PRIVATE IMPLEMENT_INFERENCE_ENGINE_API target_compile_definitions(${TARGET_NAME}_obj PRIVATE IMPLEMENT_INFERENCE_ENGINE_API
$<TARGET_PROPERTY:ngraph::ngraph,INTERFACE_COMPILE_DEFINITIONS> $<TARGET_PROPERTY:ngraph,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:ngraph::frontend_manager::static,INTERFACE_COMPILE_DEFINITIONS>) $<TARGET_PROPERTY:frontend_manager::static,INTERFACE_COMPILE_DEFINITIONS>)
target_include_directories(${TARGET_NAME}_obj SYSTEM PRIVATE $<TARGET_PROPERTY:ngraph::ngraph,INTERFACE_INCLUDE_DIRECTORIES> target_include_directories(${TARGET_NAME}_obj SYSTEM PRIVATE $<TARGET_PROPERTY:ngraph,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:pugixml::static,INTERFACE_INCLUDE_DIRECTORIES> $<TARGET_PROPERTY:pugixml::static,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:ngraph::frontend_manager::static,INTERFACE_INCLUDE_DIRECTORIES> $<TARGET_PROPERTY:frontend_manager::static,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:xbyak,INTERFACE_INCLUDE_DIRECTORIES>) $<TARGET_PROPERTY:xbyak,INTERFACE_INCLUDE_DIRECTORIES>)
target_include_directories(${TARGET_NAME}_obj PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src" target_include_directories(${TARGET_NAME}_obj PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src"
@ -150,6 +150,8 @@ add_library(${TARGET_NAME} SHARED
${vs_version_file} ${vs_version_file}
$<TARGET_OBJECTS:${TARGET_NAME}_obj>) $<TARGET_OBJECTS:${TARGET_NAME}_obj>)
add_library(openvino::runtime ALIAS ${TARGET_NAME})
add_clang_format_target(${TARGET_NAME}_clang FOR_SOURCES ${IE_STATIC_DEPENDENT_FILES} ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${PUBLIC_HEADERS}) add_clang_format_target(${TARGET_NAME}_clang FOR_SOURCES ${IE_STATIC_DEPENDENT_FILES} ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${PUBLIC_HEADERS})
ov_ncc_naming_style(FOR_TARGET ${TARGET_NAME} ov_ncc_naming_style(FOR_TARGET ${TARGET_NAME}
@ -166,14 +168,12 @@ if (TBBBIND_2_4_FOUND)
endif() endif()
target_link_libraries(${TARGET_NAME} PRIVATE pugixml::static openvino::itt ${CMAKE_DL_LIBS} Threads::Threads target_link_libraries(${TARGET_NAME} PRIVATE pugixml::static openvino::itt ${CMAKE_DL_LIBS} Threads::Threads
ngraph::frontend_manager::static inference_engine_transformations frontend_manager::static inference_engine_transformations
PUBLIC ngraph) PUBLIC ngraph)
target_include_directories(${TARGET_NAME} INTERFACE target_include_directories(${TARGET_NAME} INTERFACE
$<BUILD_INTERFACE:${PUBLIC_HEADERS_DIR}> $<BUILD_INTERFACE:${PUBLIC_HEADERS_DIR}>
$<BUILD_INTERFACE:${PUBLIC_HEADERS_DIR}/ie> $<BUILD_INTERFACE:${PUBLIC_HEADERS_DIR}/ie>
$<INSTALL_INTERFACE:${IE_CPACK_IE_DIR}/include>
$<INSTALL_INTERFACE:${IE_CPACK_IE_DIR}/include/ie>
PRIVATE $<TARGET_PROPERTY:${TARGET_NAME}_plugin_api,INTERFACE_INCLUDE_DIRECTORIES> PRIVATE $<TARGET_PROPERTY:${TARGET_NAME}_plugin_api,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:${TARGET_NAME}_legacy,INTERFACE_INCLUDE_DIRECTORIES>) $<TARGET_PROPERTY:${TARGET_NAME}_legacy,INTERFACE_INCLUDE_DIRECTORIES>)
@ -209,7 +209,7 @@ if(WIN32)
set_target_properties(${TARGET_NAME}_s PROPERTIES COMPILE_PDB_NAME ${TARGET_NAME}_s) set_target_properties(${TARGET_NAME}_s PROPERTIES COMPILE_PDB_NAME ${TARGET_NAME}_s)
endif() endif()
target_link_libraries(${TARGET_NAME}_s PRIVATE openvino::itt ${CMAKE_DL_LIBS} ngraph ngraph::frontend_manager::static target_link_libraries(${TARGET_NAME}_s PRIVATE openvino::itt ${CMAKE_DL_LIBS} ngraph frontend_manager::static
inference_engine_transformations pugixml::static) inference_engine_transformations pugixml::static)
target_compile_definitions(${TARGET_NAME}_s PUBLIC USE_STATIC_IE) target_compile_definitions(${TARGET_NAME}_s PUBLIC USE_STATIC_IE)
@ -223,8 +223,11 @@ set_target_properties(${TARGET_NAME} ${TARGET_NAME}_obj ${TARGET_NAME}_s
# Export for build tree # Export for build tree
export(TARGETS ngraph ${TARGET_NAME} NAMESPACE IE:: export(TARGETS ${TARGET_NAME} NAMESPACE IE::
APPEND FILE "${CMAKE_BINARY_DIR}/InferenceEngineTargets.cmake") APPEND FILE "${CMAKE_BINARY_DIR}/InferenceEngineTargets.cmake")
export(TARGETS ${TARGET_NAME} NAMESPACE openvino::
APPEND FILE "${CMAKE_BINARY_DIR}/OpenVINOTargets.cmake")
# Export for developer package # Export for developer package
@ -281,7 +284,17 @@ install(DIRECTORY "${PUBLIC_HEADERS_DIR}" DESTINATION ${IE_CPACK_IE_DIR}
install(TARGETS ${TARGET_NAME} EXPORT InferenceEngineTargets install(TARGETS ${TARGET_NAME} EXPORT InferenceEngineTargets
RUNTIME DESTINATION ${IE_CPACK_RUNTIME_PATH} COMPONENT core RUNTIME DESTINATION ${IE_CPACK_RUNTIME_PATH} COMPONENT core
ARCHIVE DESTINATION ${IE_CPACK_ARCHIVE_PATH} COMPONENT core ARCHIVE DESTINATION ${IE_CPACK_ARCHIVE_PATH} COMPONENT core
LIBRARY DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT core) LIBRARY DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT core
INCLUDES DESTINATION ${IE_CPACK_IE_DIR}/include/ie)
set_target_properties(${TARGET_NAME} PROPERTIES EXPORT_NAME runtime)
install(TARGETS ${TARGET_NAME} EXPORT OpenVINOTargets
RUNTIME DESTINATION ${IE_CPACK_RUNTIME_PATH} COMPONENT core
ARCHIVE DESTINATION ${IE_CPACK_ARCHIVE_PATH} COMPONENT core
LIBRARY DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT core
INCLUDES DESTINATION ${IE_CPACK_IE_DIR}/include
# TODO: remove later once samples are updated
${IE_CPACK_IE_DIR}/include/ie)
install(FILES $<TARGET_FILE_DIR:${TARGET_NAME}>/plugins.xml install(FILES $<TARGET_FILE_DIR:${TARGET_NAME}>/plugins.xml
DESTINATION ${IE_CPACK_RUNTIME_PATH} DESTINATION ${IE_CPACK_RUNTIME_PATH}
@ -304,6 +317,12 @@ install(EXPORT InferenceEngineTargets
DESTINATION ${IE_CPACK_IE_DIR}/share DESTINATION ${IE_CPACK_IE_DIR}/share
COMPONENT core_dev) COMPONENT core_dev)
install(EXPORT OpenVINOTargets
FILE OpenVINOTargets.cmake
NAMESPACE openvino::
DESTINATION ${IE_CPACK_IE_DIR}/share
COMPONENT core_dev)
set(IE_NGRAPH_DIR "${CMAKE_BINARY_DIR}/ngraph") set(IE_NGRAPH_DIR "${CMAKE_BINARY_DIR}/ngraph")
set(IE_INCLUDE_DIR "${PUBLIC_HEADERS_DIR}/ie") set(IE_INCLUDE_DIR "${PUBLIC_HEADERS_DIR}/ie")
set(IE_PARALLEL_CMAKE "${InferenceEngine_SOURCE_DIR}/cmake/ie_parallel.cmake") set(IE_PARALLEL_CMAKE "${InferenceEngine_SOURCE_DIR}/cmake/ie_parallel.cmake")
@ -313,6 +332,11 @@ configure_package_config_file("${OpenVINO_SOURCE_DIR}/cmake/templates/InferenceE
INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}" INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}"
PATH_VARS ${PATH_VARS}) PATH_VARS ${PATH_VARS})
configure_package_config_file("${OpenVINO_SOURCE_DIR}/cmake/templates/OpenVINOConfig.cmake.in"
"${CMAKE_BINARY_DIR}/OpenVINOConfig.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}"
PATH_VARS ${PATH_VARS})
set(IE_INCLUDE_DIR "include/ie") set(IE_INCLUDE_DIR "include/ie")
set(IE_NGRAPH_DIR "../ngraph/cmake") set(IE_NGRAPH_DIR "../ngraph/cmake")
set(IE_TBB_DIR "${IE_TBB_DIR_INSTALL}") set(IE_TBB_DIR "${IE_TBB_DIR_INSTALL}")
@ -323,12 +347,23 @@ configure_package_config_file("${OpenVINO_SOURCE_DIR}/cmake/templates/InferenceE
INSTALL_DESTINATION share INSTALL_DESTINATION share
PATH_VARS ${PATH_VARS}) PATH_VARS ${PATH_VARS})
configure_package_config_file("${OpenVINO_SOURCE_DIR}/cmake/templates/OpenVINOConfig.cmake.in"
"${CMAKE_BINARY_DIR}/share/OpenVINOConfig.cmake"
INSTALL_DESTINATION share
PATH_VARS ${PATH_VARS})
configure_file("${OpenVINO_SOURCE_DIR}/cmake/templates/InferenceEngineConfig-version.cmake.in" configure_file("${OpenVINO_SOURCE_DIR}/cmake/templates/InferenceEngineConfig-version.cmake.in"
"${CMAKE_BINARY_DIR}/InferenceEngineConfig-version.cmake" "${CMAKE_BINARY_DIR}/InferenceEngineConfig-version.cmake" @ONLY)
@ONLY) configure_file("${OpenVINO_SOURCE_DIR}/cmake/templates/OpenVINOConfig-version.cmake.in"
"${CMAKE_BINARY_DIR}/OpenVINOConfig-version.cmake" @ONLY)
install(FILES "${CMAKE_BINARY_DIR}/share/InferenceEngineConfig.cmake" install(FILES "${CMAKE_BINARY_DIR}/share/InferenceEngineConfig.cmake"
"${CMAKE_BINARY_DIR}/InferenceEngineConfig-version.cmake" "${CMAKE_BINARY_DIR}/InferenceEngineConfig-version.cmake"
"${InferenceEngine_SOURCE_DIR}/cmake/ie_parallel.cmake" "${InferenceEngine_SOURCE_DIR}/cmake/ie_parallel.cmake"
DESTINATION ${IE_CPACK_IE_DIR}/share DESTINATION ${IE_CPACK_IE_DIR}/share
COMPONENT core_dev) COMPONENT core_dev)
install(FILES "${CMAKE_BINARY_DIR}/share/OpenVINOConfig.cmake"
"${CMAKE_BINARY_DIR}/OpenVINOConfig-version.cmake"
DESTINATION ${IE_CPACK_IE_DIR}/share
COMPONENT core_dev)

View File

@ -13,7 +13,8 @@
#include <map> #include <map>
#include <string> #include <string>
namespace InferenceEngine {}; namespace InferenceEngine {}
namespace ov { namespace ov {
namespace ie = InferenceEngine; namespace ie = InferenceEngine;
namespace runtime { namespace runtime {

View File

@ -0,0 +1,147 @@
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
/**
* @brief A header file that provides ExecutableNetwork class
*
* @file openvino/runtime/executable_network.hpp
*/
#pragma once
#include <map>
#include <memory>
#include <ostream>
#include <string>
#include <vector>
#include "ie_parameter.hpp"
#include "openvino/core/function.hpp"
#include "openvino/runtime/infer_request.hpp"
#include "openvino/runtime/remote_context.hpp"
namespace InferenceEngine {
class IExecutableNetworkInternal;
class RemoteContext;
} // namespace InferenceEngine
namespace ov {
namespace runtime {
class Core;
/**
* @brief This is an interface of an executable network
*/
class INFERENCE_ENGINE_API_CLASS(ExecutableNetwork) {
std::shared_ptr<SharedObject> _so;
std::shared_ptr<InferenceEngine::IExecutableNetworkInternal> _impl;
/**
* @brief Constructs ExecutableNetwork from the initialized std::shared_ptr
* @param so Plugin to use. This is required to ensure that ExecutableNetwork can work properly even if plugin
* object is destroyed.
* @param impl Initialized shared pointer
*/
ExecutableNetwork(const std::shared_ptr<SharedObject>& so,
const std::shared_ptr<ie::IExecutableNetworkInternal>& impl);
friend class ov::runtime::Core;
public:
/**
* @brief A default constructor.
*/
ExecutableNetwork() = default;
/**
* @brief Get executable graph information from a device
*
* @return Function containing Executable Graph Info
*/
std::shared_ptr<const Function> get_runtime_function() const;
/**
* @brief Get parameters of executeble graph function
*
* @return vector of paramter nodes
*/
ParameterVector get_parameters() const;
/**
* @brief Get results of executeble graph function
*
* @return vector of result nodes
*/
ResultVector get_results() const;
/**
* @brief Creates an inference request object used to infer the network.
*
* The created request has allocated input and output blobs (that can be changed later).
*
* @return InferRequest object
*/
InferRequest create_infer_request();
/**
* @brief Exports the current executable network.
*
* @see Core::ImportNetwork
*
* @param networkModel Network model output stream
*/
void export_model(std::ostream& networkModel);
/**
* @brief Sets configuration for current executable network
*
* @param config Map of pairs: (config parameter name, config parameter value)
*/
void set_config(const ie::ParamMap& config);
/** @brief Gets configuration for current executable network.
*
* The method is responsible to extract information
* which affects executable network execution. The list of supported configuration values can be extracted via
* ExecutableNetwork::get_metric with the SUPPORTED_CONFIG_KEYS key, but some of these keys cannot be changed
* dynamically, e.g. DEVICE_ID cannot changed if an executable network has already been compiled for particular
* device.
*
* @param name config key, can be found in ie_plugin_config.hpp
* @return Configuration parameter value
*/
ie::Parameter get_config(const std::string& name) const;
/**
* @brief Gets general runtime metric for an executable network.
*
* It can be network name, actual device ID on
* which executable network is running or all other properties which cannot be changed dynamically.
*
* @param name metric name to request
* @return Metric parameter value
*/
ie::Parameter get_metric(const std::string& name) const;
/**
* @brief Returns pointer to plugin-specific shared context
* on remote accelerator device that was used to create this ExecutableNetwork
* @return A context
*/
std::shared_ptr<ie::RemoteContext> get_context() const;
/**
* @brief Checks if current ExecutableNetwork object is not initialized
* @return true if current ExecutableNetwork object is not initialized, false - otherwise
*/
bool operator!() const noexcept;
/**
* @brief Checks if current ExecutableNetwork object is initialized
* @return true if current ExecutableNetwork object is initialized, false - otherwise
*/
explicit operator bool() const noexcept;
};
} // namespace runtime
} // namespace ov

View File

@ -24,6 +24,9 @@ class Blob;
namespace ov { namespace ov {
namespace runtime { namespace runtime {
class ExecutableNetwork;
/** /**
* @brief This is an interface of asynchronous infer request * @brief This is an interface of asynchronous infer request
* *
@ -40,7 +43,7 @@ class INFERENCE_ENGINE_API_CLASS(InferRequest) {
* @param impl Initialized shared pointer * @param impl Initialized shared pointer
*/ */
InferRequest(const std::shared_ptr<SharedObject>& so, const std::shared_ptr<ie::IInferRequestInternal>& impl); InferRequest(const std::shared_ptr<SharedObject>& so, const std::shared_ptr<ie::IInferRequestInternal>& impl);
friend class ExecutableNetwork; friend class ov::runtime::ExecutableNetwork;
public: public:
/** /**

View File

@ -9,6 +9,7 @@
#include "cpp_interfaces/interface/ie_iremote_context.hpp" #include "cpp_interfaces/interface/ie_iremote_context.hpp"
#include "ie_common.h" #include "ie_common.h"
#include "ie_executable_network_base.hpp" #include "ie_executable_network_base.hpp"
#include "openvino/runtime/executable_network.hpp"
namespace InferenceEngine { namespace InferenceEngine {
@ -18,7 +19,7 @@ namespace InferenceEngine {
try { \ try { \
__VA_ARGS__; \ __VA_ARGS__; \
} catch (...) { \ } catch (...) { \
details::Rethrow(); \ InferenceEngine::details::Rethrow(); \
} }
ExecutableNetwork::ExecutableNetwork(const details::SharedObjectLoader& so, const IExecutableNetworkInternal::Ptr& impl) ExecutableNetwork::ExecutableNetwork(const details::SharedObjectLoader& so, const IExecutableNetworkInternal::Ptr& impl)
@ -55,9 +56,10 @@ ExecutableNetwork::operator IExecutableNetwork::Ptr() {
std::vector<VariableState> ExecutableNetwork::QueryState() { std::vector<VariableState> ExecutableNetwork::QueryState() {
std::vector<VariableState> controller; std::vector<VariableState> controller;
EXEC_NET_CALL_STATEMENT(for (auto&& state EXEC_NET_CALL_STATEMENT({
: _impl->QueryState()) { for (auto&& state : _impl->QueryState()) {
controller.emplace_back(VariableState{_so, state}); controller.emplace_back(VariableState{_so, state});
}
}); });
return controller; return controller;
} }
@ -106,3 +108,58 @@ ExecutableNetwork::operator bool() const noexcept {
return !!_impl; return !!_impl;
} }
} // namespace InferenceEngine } // namespace InferenceEngine
namespace ov {
namespace runtime {
ExecutableNetwork::ExecutableNetwork(const std::shared_ptr<SharedObject>& so,
const std::shared_ptr<ie::IExecutableNetworkInternal>& impl)
: _so{so},
_impl{impl} {
IE_ASSERT(_impl != nullptr);
}
std::shared_ptr<const Function> ExecutableNetwork::get_runtime_function() const {
EXEC_NET_CALL_STATEMENT(return std::const_pointer_cast<const Function>(_impl->GetExecGraphInfo()));
}
ParameterVector ExecutableNetwork::get_parameters() const {
EXEC_NET_CALL_STATEMENT(return _impl->GetExecGraphInfo()->get_parameters());
}
ResultVector ExecutableNetwork::get_results() const {
EXEC_NET_CALL_STATEMENT(return _impl->GetExecGraphInfo()->get_results());
}
InferRequest ExecutableNetwork::create_infer_request() {
EXEC_NET_CALL_STATEMENT(return {_so, _impl->CreateInferRequest()});
}
void ExecutableNetwork::export_model(std::ostream& networkModel) {
EXEC_NET_CALL_STATEMENT(_impl->Export(networkModel));
}
void ExecutableNetwork::set_config(const ie::ParamMap& config) {
EXEC_NET_CALL_STATEMENT(_impl->SetConfig(config));
}
ie::Parameter ExecutableNetwork::get_config(const std::string& name) const {
EXEC_NET_CALL_STATEMENT(return _impl->GetConfig(name));
}
ie::Parameter ExecutableNetwork::get_metric(const std::string& name) const {
EXEC_NET_CALL_STATEMENT(return _impl->GetMetric(name));
}
std::shared_ptr<ie::RemoteContext> ExecutableNetwork::get_context() const {
EXEC_NET_CALL_STATEMENT(return _impl->GetContext());
}
bool ExecutableNetwork::operator!() const noexcept {
return !_impl;
}
ExecutableNetwork::operator bool() const noexcept {
return !!_impl;
}
} // namespace runtime
} // namespace ov

View File

@ -42,10 +42,10 @@ target_include_directories(${TARGET_NAME}_obj PRIVATE
${IE_MAIN_SOURCE_DIR}/src/inference_engine/src # For CNNNetworkNGraphImpl ${IE_MAIN_SOURCE_DIR}/src/inference_engine/src # For CNNNetworkNGraphImpl
$<TARGET_PROPERTY:inference_engine_transformations,INTERFACE_INCLUDE_DIRECTORIES> $<TARGET_PROPERTY:inference_engine_transformations,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:inference_engine_plugin_api,INTERFACE_INCLUDE_DIRECTORIES> $<TARGET_PROPERTY:inference_engine_plugin_api,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:ngraph::ngraph,INTERFACE_INCLUDE_DIRECTORIES> $<TARGET_PROPERTY:ngraph,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:pugixml::static,INTERFACE_INCLUDE_DIRECTORIES>) $<TARGET_PROPERTY:pugixml::static,INTERFACE_INCLUDE_DIRECTORIES>)
target_compile_definitions(${TARGET_NAME}_obj PRIVATE $<TARGET_PROPERTY:ngraph::ngraph,INTERFACE_COMPILE_DEFINITIONS>) target_compile_definitions(${TARGET_NAME}_obj PRIVATE $<TARGET_PROPERTY:ngraph,INTERFACE_COMPILE_DEFINITIONS>)
target_link_libraries(${TARGET_NAME}_obj PRIVATE openvino::itt) target_link_libraries(${TARGET_NAME}_obj PRIVATE openvino::itt)

View File

@ -182,18 +182,36 @@ bool ConcatTransformation::canBeTransformed(const TransformationContext& context
return false; return false;
} }
const auto axis = concat->get_axis(); const auto& axis = concat->get_axis();
const auto outPShape = concat->get_output_partial_shape(0); const auto& outPShape = concat->get_output_partial_shape(0);
const size_t normalizedAxis = ngraph::normalize_axis(concat->get_friendly_name(), axis, outPShape.rank()); const auto& outRank = outPShape.rank();
if (outRank.is_dynamic()) {
return false;
}
const size_t normalizedAxis = ngraph::normalize_axis(concat->get_friendly_name(), axis, outRank);
if (normalizedAxis != 1ul) { if (normalizedAxis != 1ul) {
return false; return false;
} }
if (outPShape.rank().is_dynamic() || outPShape[normalizedAxis].is_dynamic()) { if (outPShape[normalizedAxis].is_dynamic()) {
return false; return false;
} }
auto checkConstShape = [&normalizedAxis, &outRank](const std::shared_ptr<opset1::Constant>& constant) {
const size_t rankValue = outRank.get_length();
Shape constantShape = constant->get_shape();
while (constantShape.size() < rankValue) {
constantShape.insert(constantShape.begin(), 1ul);
}
const auto dqDimensionsCount = std::count_if(constantShape.begin(), constantShape.end(), [](size_t elem) { return elem > 1; });
const bool dqOnlyByConcatAxis = (dqDimensionsCount == 0) || (dqDimensionsCount == 1 && constantShape[normalizedAxis] != 1ul);
return dqOnlyByConcatAxis;
};
element::Type precision; element::Type precision;
for (size_t i = 0ul; i < concat->get_input_size(); i++) { for (size_t i = 0ul; i < concat->get_input_size(); i++) {
const FakeQuantizeDequantization dequantization = NetworkHelper::getDequantization(concat, i); const FakeQuantizeDequantization dequantization = NetworkHelper::getDequantization(concat, i);
@ -201,6 +219,11 @@ bool ConcatTransformation::canBeTransformed(const TransformationContext& context
return false; return false;
} }
if (((dequantization.subtract != nullptr) && (!checkConstShape(dequantization.subtractConstant))) ||
((dequantization.multiply != nullptr) && (!checkConstShape(dequantization.multiplyConstant)))) {
return false;
}
if (precision == element::undefined) { if (precision == element::undefined) {
precision = dequantization.data.get_element_type(); precision = dequantization.data.get_element_type();
} else if (precision != dequantization.data.get_element_type()) { } else if (precision != dequantization.data.get_element_type()) {

View File

@ -34,7 +34,7 @@ FakeQuantizeDequantization::FakeQuantizeDequantization(
} }
bool FakeQuantizeDequantization::empty() const { bool FakeQuantizeDequantization::empty() const {
return (convert == nullptr) && (subtract == nullptr) && (multiply == nullptr); return (subtract == nullptr) && (multiply == nullptr);
} }
bool FakeQuantizeDequantization::multiplyHasZeroOrDenormal() const { bool FakeQuantizeDequantization::multiplyHasZeroOrDenormal() const {

View File

@ -159,17 +159,17 @@ bool MultiplyTransformation::canBeTransformed(const TransformationContext& conte
FakeQuantizeDequantization dequantization1 = pass::low_precision::NetworkHelper::getDequantization(layer, 0ul); FakeQuantizeDequantization dequantization1 = pass::low_precision::NetworkHelper::getDequantization(layer, 0ul);
FakeQuantizeDequantization dequantization2 = pass::low_precision::NetworkHelper::getDequantization(layer, 1ul); FakeQuantizeDequantization dequantization2 = pass::low_precision::NetworkHelper::getDequantization(layer, 1ul);
if ((dequantization1.data.get_node() == nullptr) || if (dequantization1.data.get_node() == nullptr || dequantization2.data.get_node() == nullptr) {
(dequantization1.empty() && !ov::is_type<opset1::Constant>(dequantization1.data.get_node_shared_ptr()) &&
!ov::is_type<opset1::Constant>(dequantization2.data.get_node_shared_ptr()))) {
return false; return false;
} }
if ((dequantization2.data.get_node() == nullptr) || const bool nonConstantData = !ov::is_type<opset1::Constant>(dequantization1.data.get_node_shared_ptr()) &&
(dequantization2.empty() && !ov::is_type<opset1::Constant>(dequantization2.data.get_node_shared_ptr()) && !ov::is_type<opset1::Constant>(dequantization2.data.get_node_shared_ptr());
!ov::is_type<opset1::Constant>(dequantization1.data.get_node_shared_ptr()))) {
if (((dequantization1.empty() || dequantization2.empty()) && nonConstantData)) {
return false; return false;
} }
return EltwiseBaseTransformation::canBeTransformed(context, layer); return EltwiseBaseTransformation::canBeTransformed(context, layer);
} }

View File

@ -78,8 +78,6 @@ bool MVNTransformation::canBeTransformed(const TransformationContext& context, s
} }
} }
bool isScalarScales = NetworkHelper::isScalarLike(dequantization.multiplyConstant);
AxisSet reduction_axes; AxisSet reduction_axes;
if (ov::is_type<op::MVN>(mvn)) { if (ov::is_type<op::MVN>(mvn)) {
reduction_axes = ov::as_type_ptr<op::MVN>(mvn)->get_reduction_axes(); reduction_axes = ov::as_type_ptr<op::MVN>(mvn)->get_reduction_axes();
@ -104,6 +102,7 @@ bool MVNTransformation::canBeTransformed(const TransformationContext& context, s
} }
} }
bool isScalarScales = NetworkHelper::isScalarLike(dequantization.multiplyConstant);
return perTensor && isScalarScales; return perTensor && isScalarScales;
} }
@ -127,9 +126,9 @@ bool MVNTransformation::transform(TransformationContext &context, ngraph::patter
FakeQuantizeDequantization dequantization = NetworkHelper::getDequantization(mvn); FakeQuantizeDequantization dequantization = NetworkHelper::getDequantization(mvn);
const auto scalesConst = dequantization.multiplyConstant; const auto scalesConst = dequantization.multiplyConstant;
const auto type = scalesConst->get_element_type();
auto newScalesConst = dequantization.multiplyConstant; auto newScalesConst = scalesConst;
const auto type = scalesConst->get_output_element_type(0);
if (normalizeVariance) { if (normalizeVariance) {
switch (type) { switch (type) {
case ngraph::element::Type_t::f16: { case ngraph::element::Type_t::f16: {
@ -145,6 +144,7 @@ bool MVNTransformation::transform(TransformationContext &context, ngraph::patter
} }
} }
} }
std::shared_ptr<Node> newMVN; std::shared_ptr<Node> newMVN;
if (ov::is_type<op::MVN>(mvn)) { if (ov::is_type<op::MVN>(mvn)) {
newMVN = mvn->copy_with_new_inputs({dequantization.data}); newMVN = mvn->copy_with_new_inputs({dequantization.data});

View File

@ -83,7 +83,7 @@ void reshapeDequantizationConstant(const std::shared_ptr<opset1::Reshape>& resha
Shape newOperationConstantBroadcastedShape = constant->get_shape(); Shape newOperationConstantBroadcastedShape = constant->get_shape();
// add dimensions to broadcast values // add dimensions to broadcast values
if (newOperationConstantBroadcastedShape.size() == 2ul) { if (newOperationConstantBroadcastedShape.size() == 2ul) {
newOperationConstantBroadcastedShape.push_back(dimensionsToBroadcast); newOperationConstantBroadcastedShape[0] = dimensionsToBroadcast;
} else { } else {
newOperationConstantBroadcastedShape[2] = dimensionsToBroadcast; newOperationConstantBroadcastedShape[2] = dimensionsToBroadcast;
} }

View File

@ -910,7 +910,7 @@ void MKLDNNGraph::SortTopologically() {
for (int i = 0; i < node->parentEdges.size(); i++) { for (int i = 0; i < node->parentEdges.size(); i++) {
auto edge = node->getParentEdgeAt(i); auto edge = node->getParentEdgeAt(i);
int port = edge->getOutputNum(); int port = edge->getOutputNum();
if (!res[port]) if (port < port_num && !res[port])
res[port] = edge; res[port] = edge;
else else
res.push_back(edge); res.push_back(edge);
@ -924,7 +924,7 @@ void MKLDNNGraph::SortTopologically() {
for (int i = 0; i < node->childEdges.size(); i++) { for (int i = 0; i < node->childEdges.size(); i++) {
auto edge = node->getChildEdgeAt(i); auto edge = node->getChildEdgeAt(i);
int port = edge->getInputNum(); int port = edge->getInputNum();
if (!res[port]) if (port < port_num && !res[port])
res[port] = edge; res[port] = edge;
else else
res.push_back(edge); res.push_back(edge);

View File

@ -53,3 +53,15 @@ install(TARGETS ${TARGET_NAME} EXPORT InferenceEngineTargets
RUNTIME DESTINATION ${IE_CPACK_RUNTIME_PATH} COMPONENT core RUNTIME DESTINATION ${IE_CPACK_RUNTIME_PATH} COMPONENT core
ARCHIVE DESTINATION ${IE_CPACK_ARCHIVE_PATH} COMPONENT core ARCHIVE DESTINATION ${IE_CPACK_ARCHIVE_PATH} COMPONENT core
LIBRARY DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT core) LIBRARY DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT core)
install(TARGETS ${TARGET_NAME} EXPORT OpenVINOTargets
RUNTIME DESTINATION ${IE_CPACK_RUNTIME_PATH} COMPONENT core
ARCHIVE DESTINATION ${IE_CPACK_ARCHIVE_PATH} COMPONENT core
LIBRARY DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT core)
# because inference_engine_transformations is exported in multiple export list
# it needs to be exported in each list it's used
install(TARGETS ${TARGET_NAME} EXPORT ngraphTargets
RUNTIME DESTINATION ${IE_CPACK_RUNTIME_PATH} COMPONENT core
ARCHIVE DESTINATION ${IE_CPACK_ARCHIVE_PATH} COMPONENT core
LIBRARY DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT core)

View File

@ -11,6 +11,7 @@
#include <transformations_visibility.hpp> #include <transformations_visibility.hpp>
#include <ngraph/op/convert.hpp>
#include "ngraph/op/op.hpp" #include "ngraph/op/op.hpp"
namespace ngraph { namespace ngraph {
@ -84,6 +85,7 @@ protected:
// to infer output data types // to infer output data types
element::TypeVector m_input_data_types; element::TypeVector m_input_data_types;
element::TypeVector m_output_data_types; element::TypeVector m_output_data_types;
element::TypeVector m_original_output_data_types;
}; };
/// Set another type for a specified output for the period of time when an instance of the class exists. /// Set another type for a specified output for the period of time when an instance of the class exists.
@ -161,6 +163,7 @@ public:
} }
void validate_and_infer_types() override; void validate_and_infer_types() override;
bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override;
std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override; std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;
@ -170,6 +173,61 @@ private:
} }
}; };
template <typename BaseOp>
bool TypeRelaxed<BaseOp>::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const {
std::shared_ptr<ngraph::op::v0::Convert> convert;
HostTensorVector casted_inputs(BaseOp::get_input_size());
for (size_t i = 0; i < BaseOp::get_input_size(); ++i) {
const auto expected_input_type = get_origin_input_type(i);
if (inputs[i]->get_element_type() == expected_input_type || expected_input_type == element::undefined) {
casted_inputs[i] = inputs[i];
} else {
if (convert == nullptr) {
convert = std::make_shared<ngraph::op::v0::Convert>();
}
convert->set_destination_type(expected_input_type);
casted_inputs[i] = std::make_shared<HostTensor>(expected_input_type, inputs[i]->get_shape());
if (!convert->evaluate({ casted_inputs[i] }, { inputs[i] })) {
return false;
}
}
}
HostTensorVector original_outputs(BaseOp::get_output_size());
for (size_t i = 0; i < BaseOp::get_output_size(); ++i) {
const auto expected_output_type = get_overridden_output_type(i);
if (expected_output_type == element::undefined || expected_output_type == m_original_output_data_types[i]) {
original_outputs[i] = outputs[i];
} else {
original_outputs[i] = std::make_shared<HostTensor>(m_original_output_data_types[i], BaseOp::get_output_partial_shape(i));
}
}
if (!BaseOp::evaluate(original_outputs, casted_inputs)) {
return false;
}
for (size_t i = 0; i < BaseOp::get_output_size(); ++i) {
const auto expected_output_type = get_overridden_output_type(i);
if (expected_output_type != element::undefined && original_outputs[i]->get_element_type() != expected_output_type) {
if (convert == nullptr) {
convert = std::make_shared<ngraph::op::v0::Convert>();
}
convert->set_destination_type(expected_output_type);
const auto casted_output = std::make_shared<HostTensor>(expected_output_type, original_outputs[i]->get_shape());
if (!convert->evaluate({ outputs[i] }, { original_outputs[i] })) {
return false;
}
}
}
return true;
}
template <typename BaseOp> template <typename BaseOp>
void TypeRelaxed<BaseOp>::validate_and_infer_types() { void TypeRelaxed<BaseOp>::validate_and_infer_types() {
// Remember all input data types // Remember all input data types
@ -195,6 +253,14 @@ void TypeRelaxed<BaseOp>::validate_and_infer_types() {
BaseOp::get_input_tensor(i).set_tensor_type(old_input_types[i], BaseOp::get_input_partial_shape(i)); BaseOp::get_input_tensor(i).set_tensor_type(old_input_types[i], BaseOp::get_input_partial_shape(i));
} }
if (m_original_output_data_types.empty()) {
m_original_output_data_types = element::TypeVector(BaseOp::get_output_size());
}
// Save inferred output types
for (size_t i = 0; i < BaseOp::get_output_size(); ++i) {
m_original_output_data_types[i] = BaseOp::get_output_element_type(i);
}
// Override (some) output types // Override (some) output types
for (size_t i = 0; i < BaseOp::get_output_size(); ++i) { for (size_t i = 0; i < BaseOp::get_output_size(); ++i) {

View File

@ -127,7 +127,8 @@ std::map<std::string, std::string> extractMeta(const StageMetaInfo& stageMeta) {
if (stageMeta.execOrder < 0 || stageMeta.execTime == 0) { if (stageMeta.execOrder < 0 || stageMeta.execTime == 0) {
serializationInfo[ExecGraphInfoSerialization::PERF_COUNTER] = "not_executed"; serializationInfo[ExecGraphInfoSerialization::PERF_COUNTER] = "not_executed";
} else { } else {
serializationInfo[ExecGraphInfoSerialization::PERF_COUNTER] = std::to_string(stageMeta.execTime); int execTimeMcs = stageMeta.execTime * 1000; // ms to mcs
serializationInfo[ExecGraphInfoSerialization::PERF_COUNTER] = std::to_string(execTimeMcs);
} }
std::stringstream layoutStream; std::stringstream layoutStream;
int ind = 0; int ind = 0;

View File

@ -62,7 +62,6 @@ public:
operationType(std::move(operationType)) {} operationType(std::move(operationType)) {}
}; };
ngraph::element::Type precision;
bool broadcast; bool broadcast;
int constInput; int constInput;
TestTransformationParams params; TestTransformationParams params;
@ -169,7 +168,6 @@ const std::vector<std::pair<ngraph::PartialShape, ngraph::PartialShape>> inputSh
const std::vector<AddTransformationTestValues> testValuesWithoutConstantBranches = { const std::vector<AddTransformationTestValues> testValuesWithoutConstantBranches = {
// Multiply with zero on the first branch // Multiply with zero on the first branch
{ {
ngraph::element::f32,
false, false,
-1, -1,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -192,7 +190,6 @@ const std::vector<AddTransformationTestValues> testValuesWithoutConstantBranches
}, },
// Multiply with zero on the second branch // Multiply with zero on the second branch
{ {
ngraph::element::f32,
false, false,
-1, -1,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -245,7 +242,6 @@ const std::vector<AddTransformationTestValues> testValuesWithoutConstantBranches
// \ / // \ /
// Add // Add
{ {
ngraph::element::f32,
false, false,
-1, -1,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -298,7 +294,6 @@ const std::vector<AddTransformationTestValues> testValuesWithoutConstantBranches
// \ / // \ /
// Add // Add
{ {
ngraph::element::f32,
false, false,
-1, -1,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -328,7 +323,6 @@ const std::vector<AddTransformationTestValues> testValuesWithoutConstantBranches
"" ""
}, },
{ {
ngraph::element::f32,
false, false,
-1, -1,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -350,7 +344,6 @@ const std::vector<AddTransformationTestValues> testValuesWithoutConstantBranches
"" ""
}, },
{ {
ngraph::element::f32,
false, false,
-1, -1,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -372,7 +365,6 @@ const std::vector<AddTransformationTestValues> testValuesWithoutConstantBranches
"" ""
}, },
{ {
ngraph::element::f32,
false, false,
-1, -1,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -394,7 +386,6 @@ const std::vector<AddTransformationTestValues> testValuesWithoutConstantBranches
"" ""
}, },
{ {
ngraph::element::f32,
false, false,
-1, -1,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -419,7 +410,6 @@ const std::vector<AddTransformationTestValues> testValuesWithoutConstantBranches
// I8 + broadcast // I8 + broadcast
{ {
ngraph::element::f32,
true, true,
-1, -1,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -441,7 +431,6 @@ const std::vector<AddTransformationTestValues> testValuesWithoutConstantBranches
"" ""
}, },
{ {
ngraph::element::f32,
true, true,
-1, -1,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -463,7 +452,6 @@ const std::vector<AddTransformationTestValues> testValuesWithoutConstantBranches
"" ""
}, },
{ {
ngraph::element::f32,
true, true,
-1, -1,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -485,7 +473,6 @@ const std::vector<AddTransformationTestValues> testValuesWithoutConstantBranches
"" ""
}, },
{ {
ngraph::element::f32,
true, true,
-1, -1,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -507,7 +494,6 @@ const std::vector<AddTransformationTestValues> testValuesWithoutConstantBranches
"" ""
}, },
{ {
ngraph::element::f32,
true, true,
-1, -1,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -531,7 +517,6 @@ const std::vector<AddTransformationTestValues> testValuesWithoutConstantBranches
// convolution before FQ (choose that branch) // convolution before FQ (choose that branch)
{ {
ngraph::element::f32,
false, false,
-1, -1,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -554,7 +539,6 @@ const std::vector<AddTransformationTestValues> testValuesWithoutConstantBranches
}, },
// convolution with multiple consumers before FQ ( FP32 on other branch due to possible quantize fusing ) // convolution with multiple consumers before FQ ( FP32 on other branch due to possible quantize fusing )
{ {
ngraph::element::f32,
false, false,
-1, -1,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -577,7 +561,6 @@ const std::vector<AddTransformationTestValues> testValuesWithoutConstantBranches
}, },
// group convolution before FQ (choose that branch) // group convolution before FQ (choose that branch)
{ {
ngraph::element::f32,
false, false,
-1, -1,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -645,7 +628,6 @@ const std::vector<AddTransformationTestValues> testValuesWithFirstConstantBranch
// \ / // \ /
// Multiply // Multiply
{ {
ngraph::element::f32,
false, false,
0, 0,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -722,7 +704,6 @@ const std::vector<AddTransformationTestValues> testValuesWithSecondConstantBranc
// \ / // \ /
// Multiply // Multiply
{ {
ngraph::element::f32,
false, false,
1, 1,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -772,7 +753,6 @@ const std::vector<std::pair<ngraph::PartialShape, ngraph::PartialShape>> inputSh
const std::vector<AddTransformationTestValues> specialTestValues = { const std::vector<AddTransformationTestValues> specialTestValues = {
// constant input: Add -> Subtract // constant input: Add -> Subtract
{ {
ngraph::element::f32,
false, false,
1, 1,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -797,7 +777,6 @@ const std::vector<AddTransformationTestValues> specialTestValues = {
// constant input: Add -> Subtract // constant input: Add -> Subtract
{ {
ngraph::element::f32,
false, false,
0, 0,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -839,7 +818,6 @@ const std::vector<std::pair<ngraph::PartialShape, ngraph::PartialShape>> inputSh
const std::vector<AddTransformationTestValues> specialTestValues = { const std::vector<AddTransformationTestValues> specialTestValues = {
{ {
ngraph::element::f32,
false, false,
-1, -1,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -888,7 +866,6 @@ const std::vector<std::pair<ngraph::PartialShape, ngraph::PartialShape>> inputSh
const std::vector<AddTransformationTestValues> testValues = { const std::vector<AddTransformationTestValues> testValues = {
{ {
ngraph::element::f32,
false, false,
-1, -1,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -910,7 +887,6 @@ const std::vector<AddTransformationTestValues> testValues = {
"" ""
}, },
{ {
ngraph::element::f32,
false, false,
-1, -1,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -933,7 +909,6 @@ const std::vector<AddTransformationTestValues> testValues = {
}, },
// multiply with zero // multiply with zero
{ {
ngraph::element::f32,
false, false,
-1, -1,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -982,7 +957,6 @@ const std::vector<std::pair<ngraph::PartialShape, ngraph::PartialShape>> inputSh
const std::vector<AddTransformationTestValues> testValues = { const std::vector<AddTransformationTestValues> testValues = {
{ {
ngraph::element::f32,
false, false,
-1, -1,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -1004,7 +978,6 @@ const std::vector<AddTransformationTestValues> testValues = {
"" ""
}, },
{ {
ngraph::element::f32,
false, false,
-1, -1,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -1027,7 +1000,6 @@ const std::vector<AddTransformationTestValues> testValues = {
}, },
// multiply with zero // multiply with zero
{ {
ngraph::element::f32,
false, false,
-1, -1,
LayerTransformation::createParamsU8I8(), LayerTransformation::createParamsU8I8(),
@ -1077,7 +1049,6 @@ const std::vector<std::pair<ngraph::PartialShape, ngraph::PartialShape>> inputSh
const std::vector<AddTransformationTestValues> testValues = { const std::vector<AddTransformationTestValues> testValues = {
// FP32 model, quantized branch: 1 // FP32 model, quantized branch: 1
{ {
ngraph::element::f32,
false, false,
-1, -1,
LayerTransformation::createParamsU8I8().setUpdatePrecisions(false), LayerTransformation::createParamsU8I8().setUpdatePrecisions(false),
@ -1100,7 +1071,6 @@ const std::vector<AddTransformationTestValues> testValues = {
}, },
// FP32 model, quantized branch: 0 // FP32 model, quantized branch: 0
{ {
ngraph::element::f32,
false, false,
-1, -1,
LayerTransformation::createParamsU8I8().setUpdatePrecisions(false), LayerTransformation::createParamsU8I8().setUpdatePrecisions(false),
@ -1123,7 +1093,6 @@ const std::vector<AddTransformationTestValues> testValues = {
}, },
// INT8 model (FQ decomposition before LPT), quantized branch: 1 // INT8 model (FQ decomposition before LPT), quantized branch: 1
{ {
ngraph::element::f32,
false, false,
-1, -1,
LayerTransformation::createParamsU8I8().setUpdatePrecisions(false), LayerTransformation::createParamsU8I8().setUpdatePrecisions(false),
@ -1146,7 +1115,6 @@ const std::vector<AddTransformationTestValues> testValues = {
}, },
// INT8 model (FQ decomposition before LPT), quantized branch: 0 // INT8 model (FQ decomposition before LPT), quantized branch: 0
{ {
ngraph::element::f32,
false, false,
-1, -1,
LayerTransformation::createParamsU8I8().setUpdatePrecisions(false), LayerTransformation::createParamsU8I8().setUpdatePrecisions(false),

View File

@ -931,6 +931,30 @@ const std::vector<ReshapeTransformationTestValues> testValues = {
{{0.1f, 0.01f, 0.1f}, ngraph::element::f32, {1, 3}} {{0.1f, 0.01f, 0.1f}, ngraph::element::f32, {1, 3}}
} }
} }
},
// U8: without subtract 2D -> 2D
{
{ Dimension::dynamic(), 2 },
{ -1, 6 },
LayerTransformation::createParamsU8I8(),
{
ngraph::element::u8,
{
{ngraph::element::f32},
{},
{{0.1f, 0.02f}, ngraph::element::f32, {1, 2}}
}
},
{
ngraph::element::u8,
{{}, {}, {}},
ngraph::element::u8,
{
{ngraph::element::f32},
{},
{{0.1f, 0.02f, 0.1f, 0.02f, 0.1f, 0.02f}, ngraph::element::f32, {1, 6}}
}
}
} }
}; };

View File

@ -0,0 +1,49 @@
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include <openvino/runtime/executable_network.hpp>
using namespace ::testing;
using namespace std;
TEST(ExecutableNetworkOVTests, throwsOnUninitializedExportStream) {
ov::runtime::ExecutableNetwork exec;
ASSERT_THROW(exec.export_model(std::cout), InferenceEngine::NotAllocated);
}
TEST(ExecutableNetworkOVTests, throwsOnUninitializedGetFunction) {
ov::runtime::ExecutableNetwork exec;
ASSERT_THROW(exec.get_runtime_function(), InferenceEngine::NotAllocated);
}
TEST(ExecutableNetworkOVTests, throwsOnUninitializedGetParameters) {
ov::runtime::ExecutableNetwork exec;
ASSERT_THROW(exec.get_parameters(), InferenceEngine::NotAllocated);
}
TEST(ExecutableNetworkOVTests, throwsOnUninitializedGetResults) {
ov::runtime::ExecutableNetwork exec;
ASSERT_THROW(exec.get_results(), InferenceEngine::NotAllocated);
}
TEST(ExecutableNetworkOVTests, throwsOnUninitializedSetConfig) {
ov::runtime::ExecutableNetwork exec;
ASSERT_THROW(exec.set_config({{}}), InferenceEngine::NotAllocated);
}
TEST(ExecutableNetworkOVTests, throwsOnUninitializedGetConfig) {
ov::runtime::ExecutableNetwork exec;
ASSERT_THROW(exec.get_config({}), InferenceEngine::NotAllocated);
}
TEST(ExecutableNetworkOVTests, throwsOnUninitializedGetMetric) {
ov::runtime::ExecutableNetwork exec;
ASSERT_THROW(exec.get_metric({}), InferenceEngine::NotAllocated);
}
TEST(ExecutableNetworkOVTests, throwsOnUninitializedGetContext) {
ov::runtime::ExecutableNetwork exec;
ASSERT_THROW(exec.get_context(), InferenceEngine::NotAllocated);
}

View File

@ -0,0 +1,41 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <vector>
#include "shared_test_classes/single_layer/gather_tree.hpp"
#include "common_test_utils/test_constants.hpp"
using namespace LayerTestsDefinitions;
namespace {
TEST_P(GatherTreeLayerTest, Serialize) {
Serialize();
}
const std::vector<InferenceEngine::Precision> netPrecisions = {
InferenceEngine::Precision::FP32,
InferenceEngine::Precision::I32
};
const std::vector<std::vector<size_t>> inputShapes = { {5, 1, 10}, {1, 1, 10}, {20, 1, 10}, {20, 20, 10} };
const std::vector<ngraph::helpers::InputLayerType> secondaryInputTypes = {
ngraph::helpers::InputLayerType::CONSTANT,
ngraph::helpers::InputLayerType::PARAMETER
};
INSTANTIATE_TEST_SUITE_P(smoke_GatherTree_Serialization, GatherTreeLayerTest,
::testing::Combine(
::testing::ValuesIn(inputShapes),
::testing::ValuesIn(secondaryInputTypes),
::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(CommonTestUtils::DEVICE_CPU)),
GatherTreeLayerTest::getTestCaseName);
} // namespace

View File

@ -5,6 +5,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "common_test_utils/test_common.hpp" #include "common_test_utils/test_common.hpp"
#include <ngraph/opsets/opset1.hpp> #include <ngraph/opsets/opset1.hpp>
#include <ngraph/pass/constant_folding.hpp>
#include <ngraph_ops/type_relaxed.hpp> #include <ngraph_ops/type_relaxed.hpp>
@ -295,4 +296,75 @@ TEST_F(TypeRelaxedTests, OneOutputMultipleInputPorts) {
relaxed_op->validate_and_infer_types(); relaxed_op->validate_and_infer_types();
ASSERT_EQ(param1->output(0).get_element_type(), element::i64); ASSERT_EQ(param1->output(0).get_element_type(), element::i64);
} }
} }
TEST_F(TypeRelaxedTests, ConstantFoldingCheck) {
std::shared_ptr<ngraph::Function> f;
{
auto const1 = ngraph::opset1::Constant::create(element::i32, ngraph::Shape{}, { 2 });
auto const2 = ngraph::opset1::Constant::create(element::i32, ngraph::Shape{}, { 2 });
auto equal = ngraph::opset1::Equal(const1, const2);
auto relaxed_equal = make_shared<ngraph::op::TypeRelaxed<ngraph::opset1::Equal>>(equal, TypeVector{}, TypeVector{ element::u8 });
f = make_shared<ngraph::Function>(ngraph::OutputVector{ relaxed_equal }, ngraph::ParameterVector{});
ASSERT_NO_THROW(ngraph::pass::ConstantFolding().run_on_function(f));
auto layer_before_result = f->get_result()->get_input_node_shared_ptr(0);
ASSERT_TRUE(ngraph::is_type<ngraph::opset1::Constant>(layer_before_result));
}
}
TEST_F(TypeRelaxedTests, ConstantFoldingCheck1) {
std::shared_ptr<ngraph::Function> f;
{
auto const1 = ngraph::opset1::Constant::create(element::i32, ngraph::Shape{}, { 2 });
auto const2 = ngraph::opset1::Constant::create(element::i32, ngraph::Shape{}, { 2 });
auto equal = ngraph::opset1::Equal(const1, const2);
auto relaxed_equal = make_shared<ngraph::op::TypeRelaxed<ngraph::opset1::Equal>>(equal, TypeVector{}, TypeVector{ element::boolean });
f = make_shared<ngraph::Function>(ngraph::OutputVector{ relaxed_equal }, ngraph::ParameterVector{});
ASSERT_NO_THROW(ngraph::pass::ConstantFolding().run_on_function(f));
auto layer_before_result = f->get_result()->get_input_node_shared_ptr(0);
ASSERT_TRUE(ngraph::is_type<ngraph::opset1::Constant>(layer_before_result));
}
}
TEST_F(TypeRelaxedTests, ConstantFoldingCheck2) {
std::shared_ptr<ngraph::Function> f;
{
auto const1 = ngraph::opset1::Constant::create(element::u8, ngraph::Shape{}, { 2 });
auto const2 = ngraph::opset1::Constant::create(element::i8, ngraph::Shape{}, { 2 });
auto original_input_types = TypeVector{ element::i32, element::i32 };
auto relaxed_equal = std::make_shared<ngraph::op::TypeRelaxed<ngraph::opset1::Equal>>(
ngraph::element::TypeVector{ element::i32, element::i32 },
ngraph::element::TypeVector{ element::u8 },
ngraph::op::TemporaryReplaceOutputType(const1, element::i32).get(),
ngraph::op::TemporaryReplaceOutputType(const2, element::i32).get());
f = make_shared<ngraph::Function>(ngraph::OutputVector{ relaxed_equal }, ngraph::ParameterVector{});
ASSERT_NO_THROW(ngraph::pass::ConstantFolding().run_on_function(f));
auto layer_before_result = f->get_result()->get_input_node_shared_ptr(0);
ASSERT_TRUE(ngraph::is_type<ngraph::opset1::Constant>(layer_before_result));
}
}
TEST_F(TypeRelaxedTests, ConstantFoldingCheck3) {
std::shared_ptr<ngraph::Function> f;
{
auto const1 = ngraph::opset1::Constant::create(element::i32, ngraph::Shape{}, { 2 });
auto const2 = ngraph::opset1::Constant::create(element::i32, ngraph::Shape{}, { 2 });
auto equal = ngraph::opset1::Equal(const1, const2);
auto original_input_types = TypeVector{ element::f32, element::f32 };
auto relaxed_equal = make_shared<ngraph::op::TypeRelaxed<ngraph::opset1::Equal>>(equal, original_input_types, TypeVector{ element::u8 });
f = make_shared<ngraph::Function>(ngraph::OutputVector{ relaxed_equal }, ngraph::ParameterVector{});
ASSERT_NO_THROW(ngraph::pass::ConstantFolding().run_on_function(f));
auto layer_before_result = f->get_result()->get_input_node_shared_ptr(0);
ASSERT_TRUE(ngraph::is_type<ngraph::opset1::Constant>(layer_before_result));
}
}

View File

@ -23,7 +23,7 @@ const std::vector<ngraph::helpers::InputLayerType> secondaryInputTypes = {
ngraph::helpers::InputLayerType::PARAMETER ngraph::helpers::InputLayerType::PARAMETER
}; };
INSTANTIATE_TEST_SUITE_P(Basic_smoke, GatherTreeLayerTest, INSTANTIATE_TEST_SUITE_P(smoke_GatherTree, GatherTreeLayerTest,
::testing::Combine( ::testing::Combine(
::testing::ValuesIn(inputShapes), ::testing::ValuesIn(inputShapes),
::testing::ValuesIn(secondaryInputTypes), ::testing::ValuesIn(secondaryInputTypes),

View File

@ -440,6 +440,36 @@ TEST_P(OVClassNetworkTestP, LoadNetworkActualHeteroDevice2NoThrow) {
ASSERT_NO_THROW(ie.compile_model(actualNetwork, CommonTestUtils::DEVICE_HETERO, {{"TARGET_FALLBACK", deviceName}})); ASSERT_NO_THROW(ie.compile_model(actualNetwork, CommonTestUtils::DEVICE_HETERO, {{"TARGET_FALLBACK", deviceName}}));
} }
TEST_P(OVClassNetworkTestP, LoadNetworkCreateDefaultExecGraphResult) {
SKIP_IF_CURRENT_TEST_IS_DISABLED()
auto ie = createCoreWithTemplate();
auto net = ie.compile_model(actualNetwork, deviceName);
auto exec_function = net.GetExecGraphInfo().getFunction();
ASSERT_NE(nullptr, exec_function);
auto actual_parameters = exec_function->get_parameters();
auto actual_results = exec_function->get_results();
auto expected_parameters = actualNetwork->get_parameters();
auto expected_results = actualNetwork->get_results();
ASSERT_EQ(expected_parameters.size(), actual_parameters.size());
for (std::size_t i = 0; i < expected_parameters.size(); ++i) {
auto expected_element_type = expected_parameters[i]->get_output_element_type(0);
auto actual_element_type = actual_parameters[i]->get_output_element_type(0);
ASSERT_EQ(expected_element_type, actual_element_type) << "For index: " << i;
auto expected_shape = expected_parameters[i]->get_output_shape(0);
auto actual_shape = actual_parameters[i]->get_output_shape(0);
ASSERT_EQ(expected_shape, actual_shape) << "For index: " << i;
}
ASSERT_EQ(expected_results.size(), actual_results.size());
for (std::size_t i = 0; i < expected_results.size(); ++i) {
auto expected_element_type = expected_results[i]->get_input_element_type(0);
auto actual_element_type = actual_results[i]->get_input_element_type(0);
ASSERT_EQ(expected_element_type, actual_element_type) << "For index: " << i;
auto expected_shape = expected_results[i]->get_input_shape(0);
auto actual_shape = actual_results[i]->get_input_shape(0);
ASSERT_EQ(expected_shape, actual_shape) << "For index: " << i;
}
}
// //
// ImportExportNetwork // ImportExportNetwork
// //

View File

@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
#include <legacy/ngraph_ops/power.hpp> #include <ngraph/opsets/opset6.hpp>
#include "shared_test_classes/subgraph/softsign.hpp" #include "shared_test_classes/subgraph/softsign.hpp"
#include "ngraph_functions/builders.hpp" #include "ngraph_functions/builders.hpp"
@ -37,8 +37,13 @@ void SoftsignTest::SetUp() {
auto params = ngraph::builder::makeParams(ngPrc, { inputShape }); auto params = ngraph::builder::makeParams(ngPrc, { inputShape });
auto abs = std::make_shared<ngraph::op::Abs>(params[0]); auto abs = std::make_shared<ngraph::op::Abs>(params[0]);
auto add = std::make_shared<ngraph::op::PowerIE>(abs, 1, 1, 1);
auto power = std::make_shared<ngraph::op::PowerIE>(add, -1, 1, 0); auto const_1 = ngraph::opset1::Constant::create(ngPrc, ngraph::Shape{}, {1});
auto const_neg_1 = ngraph::opset1::Constant::create(ngPrc, ngraph::Shape{}, {-1});
auto add = std::make_shared<ngraph::opset6::Add>(abs, const_1);
auto power = std::make_shared<ngraph::opset6::Power>(add, const_neg_1);
auto mul = std::make_shared<ngraph::op::v1::Multiply>(power, params[0]); auto mul = std::make_shared<ngraph::op::v1::Multiply>(power, params[0]);
ngraph::ResultVector results{ std::make_shared<ngraph::op::Result>(mul) }; ngraph::ResultVector results{ std::make_shared<ngraph::op::Result>(mul) };
function = std::make_shared<ngraph::Function>(results, params, "SoftSignTest"); function = std::make_shared<ngraph::Function>(results, params, "SoftSignTest");

View File

@ -96,17 +96,20 @@ public:
/// Returns user context handle which was used to create the engine /// Returns user context handle which was used to create the engine
virtual void* get_user_context() const = 0; virtual void* get_user_context() const = 0;
/// Returns the maximum amount of GPU memory that engine allocated in current process /// Returns the total maximum amount of GPU memory allocated by engine in current process for all allocation types
uint64_t get_max_used_device_memory() const; uint64_t get_max_used_device_memory() const;
/// Returns the amount of GPU memory currently used by the engine /// Returns the maximum amount of GPU memory allocated by engine in current process for the specified allocation @p type
uint64_t get_used_device_memory() const; uint64_t get_max_used_device_memory(allocation_type type) const;
/// Adds @p bytes count to currently used memory size /// Returns the amount of GPU memory specified allocation @p type that currently used by the engine
void add_memory_used(uint64_t bytes); uint64_t get_used_device_memory(allocation_type type) const;
/// Subtracts @p bytes count from currently used memory size /// Adds @p bytes count to currently used memory size of the specified allocation @p type
void subtract_memory_used(uint64_t bytes); void add_memory_used(uint64_t bytes, allocation_type type);
/// Subtracts @p bytes count from currently used memory size of the specified allocation @p type
void subtract_memory_used(uint64_t bytes, allocation_type type);
/// Returns true if USM is enabled in engine config and device/driver supports required features /// Returns true if USM is enabled in engine config and device/driver supports required features
bool use_unified_shared_memory() const; bool use_unified_shared_memory() const;
@ -142,8 +145,8 @@ protected:
const device::ptr _device; const device::ptr _device;
engine_configuration _configuration; engine_configuration _configuration;
std::atomic<uint64_t> memory_usage = {0}; std::map<allocation_type, std::atomic<uint64_t>> memory_usage_map;
std::atomic<uint64_t> peak_memory_usage = {0}; std::map<allocation_type, std::atomic<uint64_t>> peak_memory_usage_map;
}; };
} // namespace cldnn } // namespace cldnn

View File

@ -120,22 +120,51 @@ memory_ptr engine::share_surface(const layout& layout, shared_surface surf, uint
#endif // _WIN32 #endif // _WIN32
uint64_t engine::get_max_used_device_memory() const { uint64_t engine::get_max_used_device_memory() const {
return peak_memory_usage.load(); uint64_t total_peak_memory_usage {0};
for (auto const& m : peak_memory_usage_map) {
total_peak_memory_usage += m.second.load();
}
return total_peak_memory_usage;
} }
uint64_t engine::get_used_device_memory() const { uint64_t engine::get_max_used_device_memory(allocation_type type) const {
return memory_usage.load(); uint64_t peak_memory_usage {0};
auto iter = peak_memory_usage_map.find(type);
if (iter != peak_memory_usage_map.end()) {
peak_memory_usage = iter->second.load();
}
return peak_memory_usage;
} }
void engine::add_memory_used(size_t bytes) { uint64_t engine::get_used_device_memory(allocation_type type) const {
memory_usage += bytes; uint64_t memory_usage {0};
if (memory_usage > peak_memory_usage) { auto iter = memory_usage_map.find(type);
peak_memory_usage = memory_usage.load(); if (iter != memory_usage_map.end()) {
memory_usage = iter->second.load();
}
return memory_usage;
}
void engine::add_memory_used(size_t bytes, allocation_type type) {
if (!memory_usage_map.count(type) && !peak_memory_usage_map.count(type)) {
static std::mutex m;
std::lock_guard<std::mutex> guard(m);
memory_usage_map[type] = 0;
peak_memory_usage_map[type] = 0;
}
memory_usage_map[type] += bytes;
if (memory_usage_map[type] > peak_memory_usage_map[type]) {
peak_memory_usage_map[type] = memory_usage_map[type].load();
} }
} }
void engine::subtract_memory_used(size_t bytes) { void engine::subtract_memory_used(size_t bytes, allocation_type type) {
memory_usage -= bytes; auto iter = memory_usage_map.find(type);
if (iter != memory_usage_map.end()) {
memory_usage_map[type] -= bytes;
} else {
throw std::runtime_error("Attempt to free unallocated memory");
}
} }
std::shared_ptr<cldnn::engine> engine::create(engine_types engine_type, std::shared_ptr<cldnn::engine> engine::create(engine_types engine_type,

View File

@ -20,27 +20,25 @@ namespace cldnn {
memory::memory(engine* engine, const layout& layout, allocation_type type, bool reused) memory::memory(engine* engine, const layout& layout, allocation_type type, bool reused)
: _engine(engine), _layout(layout), _bytes_count(_layout.bytes_count()), _type(type), _reused(reused) { : _engine(engine), _layout(layout), _bytes_count(_layout.bytes_count()), _type(type), _reused(reused) {
if (!_reused && _engine) { if (!_reused && _engine) {
_engine->add_memory_used(_bytes_count); _engine->add_memory_used(_bytes_count, type);
} GPU_DEBUG_GET_INSTANCE(debug_config);
GPU_DEBUG_IF(debug_config->verbose >= 1) {
GPU_DEBUG_GET_INSTANCE(debug_config); GPU_DEBUG_COUT << "Allocate " << _bytes_count << " bytes of " << type << " allocation type"
GPU_DEBUG_IF(debug_config->verbose >= 1) { << " (current=" << _engine->get_used_device_memory(type) << ";"
GPU_DEBUG_COUT << "Allocate " << _bytes_count << " bytes of " << type << " allocation type" << " max=" << _engine->get_max_used_device_memory(type) << ")" << std::endl;
<< " (current=" << _engine->get_used_device_memory() << ";" }
<< " max=" << _engine->get_max_used_device_memory() << ")" << std::endl;
} }
} }
memory::~memory() { memory::~memory() {
if (!_reused && _engine) { if (!_reused && _engine) {
_engine->subtract_memory_used(_bytes_count); _engine->subtract_memory_used(_bytes_count, _type);
} GPU_DEBUG_GET_INSTANCE(debug_config);
GPU_DEBUG_IF(debug_config->verbose >= 1) {
GPU_DEBUG_GET_INSTANCE(debug_config); GPU_DEBUG_COUT << "Free " << _bytes_count << " bytes of " << _type << " allocation type"
GPU_DEBUG_IF(debug_config->verbose >= 1) { << " (current=" << _engine->get_used_device_memory(_type) << ";"
GPU_DEBUG_COUT << "Free " << _bytes_count << " bytes" << " max=" << _engine->get_max_used_device_memory(_type) << ")" << std::endl;
<< " (current=" << _engine->get_used_device_memory() << ";" }
<< " max=" << _engine->get_max_used_device_memory() << ")" << std::endl;
} }
} }

View File

@ -403,7 +403,7 @@ TEST(memory_pool, shared_mem_pool_diff_batches) {
network network_second(*engine, topo, bo); network network_second(*engine, topo, bo);
network_second.set_input_data("input", input_1); network_second.set_input_data("input", input_1);
auto outputs_second = network_second.execute(); auto outputs_second = network_second.execute();
EXPECT_EQ(engine->get_max_used_device_memory(), (uint64_t)3928); EXPECT_EQ(engine->get_max_used_device_memory(), (uint64_t)4328);
} }
TEST(memory_pool, shared_dep_two_output) { TEST(memory_pool, shared_dep_two_output) {

View File

@ -52,11 +52,9 @@ extensions/back/ResultNormalizer.py
extensions/back/ResultRename.py extensions/back/ResultRename.py
extensions/back/ReverseInputChannels.py extensions/back/ReverseInputChannels.py
extensions/back/RNNSequenceTypeRename.py extensions/back/RNNSequenceTypeRename.py
extensions/back/ScalarConstNormalize.py
extensions/back/SelectBroadcast.py extensions/back/SelectBroadcast.py
extensions/back/ShapeOfConstFolding.py extensions/back/ShapeOfConstFolding.py
extensions/back/ShuffleChannelPatternOptimization.py extensions/back/ShuffleChannelPatternOptimization.py
extensions/back/ShufflenetReLUReorder.py
extensions/back/SpecialNodesFinalization.py extensions/back/SpecialNodesFinalization.py
extensions/back/StridedSliceMasksNormalizer.py extensions/back/StridedSliceMasksNormalizer.py
extensions/back/TopKNormalizer.py extensions/back/TopKNormalizer.py

View File

@ -16,62 +16,73 @@ class TensorFlowObjectDetectionAPIAnalysis(AnalyzeAction):
""" """
graph_condition = [lambda graph: graph.graph['fw'] == 'tf'] graph_condition = [lambda graph: graph.graph['fw'] == 'tf']
model_scopes = [('MaskRCNN', ['Preprocessor',
'FirstStageFeatureExtractor',
'SecondStageFeatureExtractor',
'SecondStageBoxPredictor',
'SecondStageBoxPredictor_1',
'SecondStageFeatureExtractor_1',
]),
('RFCN', ['Preprocessor',
'FirstStageFeatureExtractor',
'SecondStageFeatureExtractor',
'SecondStageBoxPredictor',
'SecondStageBoxPredictor/map',
'SecondStageBoxPredictor/map_1',
'SecondStagePostprocessor',
]),
('FasterRCNN', ['Preprocessor',
'FirstStageFeatureExtractor',
'SecondStageFeatureExtractor',
'SecondStageBoxPredictor',
'SecondStagePostprocessor',
]),
('SSD', ['Preprocessor',
'FeatureExtractor',
'Postprocessor',
]),
]
file_patterns = {'MaskRCNN': 'mask_rcnn_support.*\\.json', file_patterns = {'MaskRCNN': 'mask_rcnn_support.*\\.json',
'RFCN': 'rfcn_support.*\\.json', 'RFCN': 'rfcn_support.*\\.json',
'FasterRCNN': 'faster_rcnn_support.*\\.json', 'FasterRCNN': 'faster_rcnn_support.*\\.json',
'SSD': 'ssd.*_support.*\\.json', 'SSD': 'ssd.*_support.*\\.json',
} }
model_scopes = {'MaskRCNN': (['FirstStageFeatureExtractor',
'SecondStageFeatureExtractor',
'SecondStageBoxPredictor',
'SecondStageBoxPredictor_1',
'SecondStageFeatureExtractor_1',
],),
'RFCN': (['FirstStageFeatureExtractor',
'SecondStageFeatureExtractor',
'SecondStageBoxPredictor',
'SecondStageBoxPredictor/map',
'SecondStageBoxPredictor/map_1',
'SecondStagePostprocessor',
],),
'FasterRCNN': (['FirstStageFeatureExtractor',
'SecondStageFeatureExtractor',
'SecondStageBoxPredictor',
'SecondStagePostprocessor',
],
['FirstStageRPNFeatures',
'FirstStageBoxPredictor',
'SecondStagePostprocessor',
'mask_rcnn_keras_box_predictor',
],),
'SSD': ([('FeatureExtractor', 'ssd_mobile_net_v2keras_feature_extractor',
'ssd_mobile_net_v1fpn_keras_feature_extractor',
'ssd_mobile_net_v2fpn_keras_feature_extractor', 'ResNet50V1_FPN', 'ResNet101V1_FPN',
'ResNet152V1_FPN'
),
'Postprocessor']
),
}
def analyze(self, graph: Graph): def analyze(self, graph: Graph):
if any([name not in graph.nodes() for name in ['image_tensor', 'detection_classes', 'detection_boxes', tf_1_names = ['image_tensor', 'detection_classes', 'detection_boxes', 'detection_scores',
'detection_scores']]): ('Preprocessor', 'map')]
tf_1_cond = all([graph_contains_scope(graph, scope) for scope in tf_1_names])
tf_2_names = ['input_tensor', 'output_control_node', 'Identity_', ('Preprocessor', 'map')]
tf_2_cond = all([graph_contains_scope(graph, scope) for scope in tf_2_names])
if not tf_1_cond and not tf_2_cond:
log.debug('The model does not contain nodes that must exist in the TF OD API models') log.debug('The model does not contain nodes that must exist in the TF OD API models')
return None, None return None, None
for flavor, scopes in __class__.model_scopes: for flavor, scopes_tuple in self.model_scopes.items():
if all([graph_contains_scope(graph, scope) for scope in scopes]): for scopes in scopes_tuple:
result = dict() if all([graph_contains_scope(graph, scope) for scope in scopes]):
result['flavor'] = flavor result = dict()
result['mandatory_parameters'] = {'tensorflow_use_custom_operations_config': result['flavor'] = flavor
files_by_pattern(get_mo_root_dir() + '/extensions/front/tf', result['mandatory_parameters'] = {'tensorflow_use_custom_operations_config':
__class__.file_patterns[flavor], files_by_pattern(get_mo_root_dir() + '/extensions/front/tf',
add_prefix=True), __class__.file_patterns[flavor],
'tensorflow_object_detection_api_pipeline_config': None, add_prefix=True),
} 'tensorflow_object_detection_api_pipeline_config': None,
message = "Your model looks like TensorFlow Object Detection API Model.\n" \ }
"Check if all parameters are specified:\n" \ message = "Your model looks like TensorFlow Object Detection API Model.\n" \
"\t--tensorflow_use_custom_operations_config\n" \ "Check if all parameters are specified:\n" \
"\t--tensorflow_object_detection_api_pipeline_config\n" \ "\t--transformations_config\n" \
"\t--input_shape (optional)\n" \ "\t--tensorflow_object_detection_api_pipeline_config\n" \
"\t--reverse_input_channels (if you convert a model to use with the Inference Engine sample applications)\n" \ "\t--input_shape (optional)\n" \
"Detailed information about conversion of this model can be found at\n" \ "\t--reverse_input_channels (if you convert a model to use with the Inference Engine sample applications)\n" \
"https://docs.openvinotoolkit.org/latest/_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_Object_Detection_API_Models.html" "Detailed information about conversion of this model can be found at\n" \
return {'model_type': {'TF_OD_API': result}}, message "https://docs.openvinotoolkit.org/latest/_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_Object_Detection_API_Models.html"
return {'model_type': {'TF_OD_API': result}}, message
return None, None return None, None

View File

@ -5,7 +5,6 @@ import logging as log
import numpy as np import numpy as np
from extensions.back.ScalarConstNormalize import ScalarNormalize
from extensions.ops.ReduceOps import reduce_map from extensions.ops.ReduceOps import reduce_map
from mo.back.replacement import BackReplacementPattern from mo.back.replacement import BackReplacementPattern
from mo.front.common.partial_infer.utils import int64_array from mo.front.common.partial_infer.utils import int64_array
@ -23,9 +22,6 @@ class ReduceMerge(BackReplacementPattern):
enabled = True enabled = True
force_clean_up = True force_clean_up = True
def run_before(self):
return [ScalarNormalize]
@staticmethod @staticmethod
def fuse_reduces(first_reduce, second_reduce): def fuse_reduces(first_reduce, second_reduce):
first_reduce_name = first_reduce.soft_get('name', first_reduce.id) first_reduce_name = first_reduce.soft_get('name', first_reduce.id)

View File

@ -1,36 +0,0 @@
# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from extensions.back.ReshapeMutation import ReshapeMutation
from mo.back.replacement import BackReplacementPattern
from mo.front.common.partial_infer.utils import int64_array
from mo.front.tf.graph_utils import create_op_node_with_second_input
from mo.graph.graph import Graph
from mo.ops.reshape import Reshape
# Temporary nGraph workaround. TODO: REMOVE
class ScalarNormalize(BackReplacementPattern):
enabled = False
force_clean_up = True
def run_before(self):
return [ReshapeMutation]
@staticmethod
def pattern():
return dict(
nodes=[
('op', dict(kind='op', type='Const'))],
edges=[]
)
@staticmethod
def replace_pattern(graph: Graph, match: dict):
node = match['op']
if node.value.ndim == 0:
reshape = create_op_node_with_second_input(graph, Reshape, int64_array([1]),
{'name': node.id + '/Dims'})
node.out_port(0).get_connection().set_source(reshape.out_port(0))
node.out_port(0).connect(reshape.in_port(0))
reshape.infer(reshape)

View File

@ -1,62 +0,0 @@
# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
from mo.back.replacement import BackReplacementPattern
from mo.graph.graph import Graph
class ShufflenetReLUReorder(BackReplacementPattern):
"""
This pass is workaround for GPU plugin
"""
enabled = False
def pattern(self):
return dict(
nodes=[
('relu', dict(kind='op', type='ReLU')),
('relu_data', dict(kind='data')),
('reshape1', dict(kind='op', type='Reshape')),
('reshape1_data', dict(kind='data')),
('transpose', dict(kind='op', type='Transpose')),
('transpose_data', dict(kind='data')),
('reshape2', dict(kind='op', type='Reshape')),
('reshape2_data', dict(kind='data')),
('conv', dict(kind='op', type='Convolution'))
],
edges=[('relu', 'relu_data'),
('relu_data', 'reshape1'),
('reshape1', 'reshape1_data'),
('reshape1_data', 'transpose'),
('transpose', 'transpose_data'),
('transpose_data', 'reshape2'),
('reshape2', 'reshape2_data'),
('reshape2_data', 'conv'),
]
)
def replace_pattern(self, graph: Graph, match: dict):
relu = match['relu']
reshape1 = match['reshape1']
reshape2_data = match['reshape2_data']
conv = match['conv']
if np.max(conv.pad) == 0:
return
relu_input = relu.in_node()
# Disconnect InputData-x->ReLU->Data-x->Reshape1
edge_attrs = graph.get_edge_data(relu.out_node().id, reshape1.id)[0]
graph.remove_edge(relu_input.id, relu.id)
graph.remove_edge(relu.out_node().id, reshape1.id)
# Connect InputData-->Reshape1
graph.add_edges_from([(relu_input.id, reshape1.id, edge_attrs)])
# Insert ReLU: Reshape2Data->ReLU->Data->Convolution
edge_attrs = graph.get_edge_data(reshape2_data.id, conv.id)[0]
graph.remove_edge(reshape2_data.id, conv.id)
graph.add_edges_from([(reshape2_data.id, relu.id, {'in': 0}), (relu.out_node().id, conv.id, edge_attrs)])

View File

@ -2,7 +2,6 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
from extensions.back.Reshape0DToSqueeze import Reshape0DToSqueeze from extensions.back.Reshape0DToSqueeze import Reshape0DToSqueeze
from extensions.back.ScalarConstNormalize import ScalarNormalize
from mo.back.replacement import BackReplacementPattern from mo.back.replacement import BackReplacementPattern
from mo.front.common.partial_infer.utils import int64_array from mo.front.common.partial_infer.utils import int64_array
from mo.front.tf.graph_utils import create_op_node_with_second_input from mo.front.tf.graph_utils import create_op_node_with_second_input
@ -23,9 +22,6 @@ class TopKNormalizer(BackReplacementPattern):
""" """
enabled = True enabled = True
def run_after(self):
return [ScalarNormalize]
def run_before(self): def run_before(self):
return [Reshape0DToSqueeze] return [Reshape0DToSqueeze]

View File

@ -38,10 +38,11 @@ SUPPORTED_DATA_TYPES = {
'I32': (np.int32, 'I32', 'i32'), 'I32': (np.int32, 'I32', 'i32'),
'I64': (np.int64, 'I64', 'i64'), 'I64': (np.int64, 'I64', 'i64'),
'int8': (np.int8, 'I8', 'i8'), 'int8': (np.int8, 'I8', 'i8'),
'uint8': (np.uint8, 'U8', 'u8'),
'int32': (np.int32, 'I32', 'i32'), 'int32': (np.int32, 'I32', 'i32'),
'int64': (np.int64, 'I64', 'i64'), 'int64': (np.int64, 'I64', 'i64'),
'bool': (np.bool, 'BOOL', 'boolean'), 'bool': (np.bool, 'BOOL', 'boolean'),
'uint8': (np.uint8, 'U8', 'u8'),
'uint32': (np.uint32, 'U32', 'u32'),
'uint64': (np.uint64, 'U64', 'u64'), 'uint64': (np.uint64, 'U64', 'u64'),
# custom types # custom types

View File

@ -112,13 +112,14 @@ class AnalysisCollectorAnchor(AnalyzeAction):
pass pass
def graph_contains_scope(graph: Graph, scope: str): def graph_contains_scope(graph: Graph, scope: [str, tuple]):
""" """
Checks whether the graph contains node(s) which name starts with "scope" string. Checks whether the graph contains node(s) which name includes "scope" string.
:param graph: graph to check :param graph: graph to check
:param scope: string defining the scope :param scope: string or tuple with strings defining the scope
:return: the result of the check (True/False) :return: the result of the check (True/False)
""" """
if scope[-1] != '/': if type(scope) is str:
scope += '/' return any([node.soft_get('name').find(scope) != -1 for node in graph.get_op_nodes()])
return any([node.soft_get('name').startswith(scope) for node in graph.get_op_nodes()]) else:
return any([graph_contains_scope(graph, s) for s in scope])

View File

@ -1,136 +0,0 @@
# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import unittest
import numpy as np
from extensions.back.ShufflenetReLUReorder import ShufflenetReLUReorder
from mo.utils.ir_engine.compare_graphs import compare_graphs
from unit_tests.utils.graph import build_graph
# The dictionary with nodes attributes used to build various graphs. A key is the name of the node and the value is the
# dictionary with node attributes.
nodes_attributes = {
'placeholder_1': {'shape': None, 'type': 'Parameter', 'kind': 'op', 'op': 'Parameter'},
'placeholder_1_data': {'value': None, 'shape': None, 'kind': 'data', 'data_type': None},
# ReLU
'relu_1': {'type': 'ReLU', 'kind': 'op', 'op': 'ReLU'},
'relu_1_data': {'value': None, 'shape': None, 'kind': 'data'},
# Reshape layers
'reshape_1': {'type': 'Reshape', 'kind': 'op', 'op': 'Reshape'},
'reshape_1_data': {'value': None, 'shape': None, 'kind': 'data'},
'reshape_2': {'type': 'Reshape', 'kind': 'op', 'op': 'Reshape'},
'reshape_2_data': {'value': None, 'shape': None, 'kind': 'data'},
'reshape_3': {'type': 'Reshape', 'kind': 'op', 'op': 'Reshape'},
'reshape_3_data': {'value': None, 'shape': None, 'kind': 'data'},
# Transpose layer
'transpose_1': {'type': 'Transpose', 'kind': 'op', 'op': 'Transpose'},
'transpose_1_data': {'value': None, 'shape': None, 'kind': 'data'},
# Conv layer
'conv_1': {'type': 'Convolution', 'kind': 'op', 'op': 'Conv2d'},
'conv_1_data': {'value': None, 'shape': None, 'kind': 'data'},
}
class ShufflenetReLUReorderTests(unittest.TestCase):
def test_1(self):
graph = build_graph(nodes_attributes,
[('placeholder_1', 'placeholder_1_data'),
('placeholder_1_data', 'relu_1'),
('relu_1', 'relu_1_data'),
('relu_1_data', 'reshape_1'),
('reshape_1', 'reshape_1_data'),
('reshape_1_data', 'transpose_1'),
('transpose_1', 'transpose_1_data'),
('transpose_1_data', 'reshape_2'),
('reshape_2', 'reshape_2_data'),
('reshape_2_data', 'conv_1'),
('conv_1', 'conv_1_data')
],
{'placeholder_1_data': {'shape': np.array([1, 227, 227, 112])},
'relu_1_data': {'shape': np.array([1, 227, 227, 112])},
'reshape_1_data': {'shape': np.array([227, 227, 4, 28])},
'transpose_1': {'order': np.array([0, 1, 3, 2])},
'transpose_1_data': {'shape': np.array([227, 227, 28, 4])},
'reshape_2_data': {'shape': np.array([1, 227, 227, 112])},
'conv_1_data': {'shape': np.array([1, 227, 227, 112])},
'conv_1': {'pad': np.array([1, 1])}
})
graph.graph['layout'] = 'NHWC'
graph_ref = build_graph(nodes_attributes,
[('placeholder_1', 'placeholder_1_data'),
('placeholder_1_data', 'reshape_1'),
('reshape_1', 'reshape_1_data'),
('reshape_1_data', 'transpose_1'),
('transpose_1', 'transpose_1_data'),
('transpose_1_data', 'reshape_2'),
('reshape_2', 'reshape_2_data'),
('reshape_2_data', 'relu_1'),
('relu_1', 'relu_1_data'),
('relu_1_data', 'conv_1'),
('conv_1', 'conv_1_data')
],
{'placeholder_1_data': {'shape': np.array([1, 227, 227, 112])},
'relu_1_data': {'shape': np.array([1, 227, 227, 112])},
'reshape_1_data': {'shape': np.array([227, 227, 4, 28])},
'transpose_1': {'order': np.array([0, 1, 3, 2])},
'transpose_1_data': {'shape': np.array([227, 227, 28, 4])},
'reshape_2_data': {'shape': np.array([1, 227, 227, 112])},
'conv_1_data': {'shape': np.array([1, 227, 227, 112])},
})
pattern = ShufflenetReLUReorder()
pattern.find_and_replace_pattern(graph)
(flag, resp) = compare_graphs(graph, graph_ref, 'conv_1_data', check_op_attrs=True)
self.assertTrue(flag, resp)
def test_2_neg(self):
graph = build_graph(nodes_attributes,
[('placeholder_1', 'placeholder_1_data'),
('placeholder_1_data', 'reshape_1'),
('reshape_1', 'reshape_1_data'),
('reshape_1_data', 'transpose_1'),
('transpose_1', 'transpose_1_data'),
('transpose_1_data', 'reshape_2'),
('reshape_2', 'reshape_2_data'),
('reshape_2_data', 'conv_1'),
('conv_1', 'conv_1_data')
],
{'placeholder_1_data': {'shape': np.array([1, 227, 227, 112])},
'relu_1_data': {'shape': np.array([1, 227, 227, 112])},
'reshape_1_data': {'shape': np.array([227, 227, 4, 28])},
'transpose_1': {'order': np.array([0, 1, 3, 2])},
'transpose_1_data': {'shape': np.array([227, 227, 28, 4])},
'reshape_2_data': {'shape': np.array([1, 227, 227, 112])},
'conv_1_data': {'shape': np.array([1, 227, 227, 112])},
})
graph.graph['layout'] = 'NHWC'
graph_ref = build_graph(nodes_attributes,
[('placeholder_1', 'placeholder_1_data'),
('placeholder_1_data', 'reshape_1'),
('reshape_1', 'reshape_1_data'),
('reshape_1_data', 'transpose_1'),
('transpose_1', 'transpose_1_data'),
('transpose_1_data', 'reshape_2'),
('reshape_2', 'reshape_2_data'),
('reshape_2_data', 'conv_1'),
('conv_1', 'conv_1_data')
],
{'placeholder_1_data': {'shape': np.array([1, 227, 227, 112])},
'relu_1_data': {'shape': np.array([1, 227, 227, 112])},
'reshape_1_data': {'shape': np.array([227, 227, 4, 28])},
'transpose_1': {'order': np.array([0, 1, 3, 2])},
'transpose_1_data': {'shape': np.array([227, 227, 28, 4])},
'reshape_2_data': {'shape': np.array([1, 227, 227, 112])},
'conv_1_data': {'shape': np.array([1, 227, 227, 112])},
})
pattern = ShufflenetReLUReorder()
pattern.find_and_replace_pattern(graph)
(flag, resp) = compare_graphs(graph, graph_ref, 'conv_1_data', check_op_attrs=True)
self.assertTrue(flag, resp)

View File

@ -15,7 +15,7 @@ add_library(${TARGET_FE_NAME} SHARED ${LIBRARY_SRC} ${LIBRARY_HEADERS})
target_include_directories(${TARGET_FE_NAME} PRIVATE ".") target_include_directories(${TARGET_FE_NAME} PRIVATE ".")
target_link_libraries(${TARGET_FE_NAME} PRIVATE ngraph::frontend_manager::static) target_link_libraries(${TARGET_FE_NAME} PRIVATE frontend_manager::static)
target_link_libraries(${TARGET_FE_NAME} PUBLIC ngraph PRIVATE ngraph::builder) target_link_libraries(${TARGET_FE_NAME} PUBLIC ngraph PRIVATE ngraph::builder)
add_clang_format_target(${TARGET_FE_NAME}_clang FOR_TARGETS ${TARGET_FE_NAME}) add_clang_format_target(${TARGET_FE_NAME}_clang FOR_TARGETS ${TARGET_FE_NAME})

View File

@ -30,7 +30,7 @@ source_group("src" FILES ${PYBIND_FE_SRC})
pybind11_add_module(${PYBIND_FE_NAME} MODULE ${PYBIND_FE_SRC}) pybind11_add_module(${PYBIND_FE_NAME} MODULE ${PYBIND_FE_SRC})
target_link_libraries(${PYBIND_FE_NAME} PRIVATE ngraph::ngraph ngraph::frontend_manager::static) target_link_libraries(${PYBIND_FE_NAME} PRIVATE ngraph frontend_manager::static)
target_link_libraries(${PYBIND_FE_NAME} PRIVATE ${TARGET_FE_NAME}) target_link_libraries(${PYBIND_FE_NAME} PRIVATE ${TARGET_FE_NAME})
add_dependencies(${PYBIND_FE_NAME} ${TARGET_FE_NAME}) add_dependencies(${PYBIND_FE_NAME} ${TARGET_FE_NAME})

View File

@ -30,7 +30,3 @@ add_subdirectory(core)
add_subdirectory(frontend) add_subdirectory(frontend)
add_subdirectory(test) add_subdirectory(test)
if(ENABLE_PYTHON)
add_subdirectory(python)
endif()

View File

@ -71,25 +71,52 @@ set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/src/pass/convert_precis
# Defines macro in C++ to load backend plugin # Defines macro in C++ to load backend plugin
target_include_directories(ngraph PUBLIC $<BUILD_INTERFACE:${NGRAPH_INCLUDE_PATH}> target_include_directories(ngraph PUBLIC $<BUILD_INTERFACE:${NGRAPH_INCLUDE_PATH}>
$<INSTALL_INTERFACE:${NGRAPH_INSTALL_INCLUDE}>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}/include) ${CMAKE_CURRENT_BINARY_DIR}/include)
#Add an alias so that library can be used inside the build tree, e.g. when testing # Add an alias so that library can be used inside the build tree, e.g. when testing
add_library(ngraph::ngraph ALIAS ngraph) add_library(ngraph::ngraph ALIAS ngraph)
add_library(openvino::core ALIAS ngraph)
target_link_libraries(ngraph PRIVATE ${CMAKE_DL_LIBS}) target_link_libraries(ngraph PRIVATE ${CMAKE_DL_LIBS})
#-----------------------------------------------------------------------------------------------
# Export for build tree
#-----------------------------------------------------------------------------------------------
export(TARGETS ngraph NAMESPACE ngraph:: APPEND FILE "${NGRAPH_TARGETS_FILE}")
# WA for cmake
export(TARGETS ngraph NAMESPACE IE::
APPEND FILE "${CMAKE_BINARY_DIR}/InferenceEngineTargets.cmake")
set_target_properties(ngraph PROPERTIES EXPORT_NAME core)
export(TARGETS ngraph NAMESPACE openvino::
APPEND FILE "${CMAKE_BINARY_DIR}/OpenVINOTargets.cmake")
#----------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------
# Installation logic... # Installation logic...
#----------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------
export(TARGETS ngraph NAMESPACE ngraph:: APPEND FILE "${NGRAPH_TARGETS_FILE}")
install(TARGETS ngraph EXPORT ngraphTargets install(TARGETS ngraph EXPORT ngraphTargets
RUNTIME DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph RUNTIME DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph
ARCHIVE DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph ARCHIVE DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph
LIBRARY DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph) LIBRARY DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph
INCLUDES DESTINATION ${NGRAPH_INSTALL_INCLUDE})
# because ngraph is exported in multiple export list
# it needs to be exported in each list it's used
install(TARGETS ngraph EXPORT InferenceEngineTargets
RUNTIME DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph
ARCHIVE DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph
LIBRARY DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph
INCLUDES DESTINATION ${NGRAPH_INSTALL_INCLUDE})
install(TARGETS ngraph EXPORT OpenVINOTargets
RUNTIME DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph
ARCHIVE DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph
LIBRARY DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph
INCLUDES DESTINATION ${NGRAPH_INSTALL_INCLUDE})
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION ${NGRAPH_INSTALL_INCLUDE} DESTINATION ${NGRAPH_INSTALL_INCLUDE}

View File

@ -72,11 +72,12 @@ void runtime::reference::gather_tree(const char* step_ids,
throw ngraph_error("max_seq_len must have size of BATCH_SIZE"); throw ngraph_error("max_seq_len must have size of BATCH_SIZE");
} }
NGRAPH_SUPPRESS_DEPRECATED_START const auto in_strides = row_major_strides(step_ids_shape);
ngraph::CoordinateTransform cordinate_transform(step_ids_shape); ngraph::CoordinateTransformBasic cordinate_transform(step_ids_shape);
for (const auto& coord : cordinate_transform) { for (const auto& coord : cordinate_transform) {
memcpy(out + cordinate_transform.index(coord) * elem_size, end_token, elem_size); const auto out_idx = std::inner_product(coord.begin(), coord.end(), in_strides.begin(), 0);
memcpy(out + out_idx * elem_size, end_token, elem_size);
} }
for (size_t batch = 0; batch < batch_size; ++batch) { for (size_t batch = 0; batch < batch_size; ++batch) {
@ -87,31 +88,35 @@ void runtime::reference::gather_tree(const char* step_ids,
continue; continue;
} }
auto offset = cordinate_transform.index({max_seq_in_beam - 1, batch, beam}) * elem_size; const auto coord = Coordinate({max_seq_in_beam - 1, batch, beam});
const auto offset = std::inner_product(coord.begin(), coord.end(), in_strides.begin(), 0) * elem_size;
memcpy(out + offset, step_ids + offset, elem_size); memcpy(out + offset, step_ids + offset, elem_size);
size_t parent = _asIndex(parent_ids + offset, element_type); size_t parent = _asIndex(parent_ids + offset, element_type);
for (size_t level = max_seq_in_beam - 1; level-- > 0;) { for (size_t level = max_seq_in_beam - 1; level-- > 0;) {
memcpy(out + cordinate_transform.index({level, batch, beam}) * elem_size, const auto coord_beam = Coordinate({level, batch, beam});
step_ids + cordinate_transform.index({level, batch, parent}) * elem_size, const auto out_idx = std::inner_product(coord_beam.begin(), coord_beam.end(), in_strides.begin(), 0);
elem_size);
parent = const auto coord_parent = Coordinate({level, batch, parent});
_asIndex(parent_ids + cordinate_transform.index({level, batch, parent}) * elem_size, element_type); const auto step_ids_idx =
std::inner_product(coord_parent.begin(), coord_parent.end(), in_strides.begin(), 0);
memcpy(out + out_idx * elem_size, step_ids + step_ids_idx * elem_size, elem_size);
parent = _asIndex(parent_ids + step_ids_idx * elem_size, element_type);
} }
bool finished = false; bool finished = false;
for (size_t time = 0; time < max_seq_in_beam; ++time) { for (size_t time = 0; time < max_seq_in_beam; ++time) {
const auto out_coord = Coordinate({time, batch, beam});
const auto out_idx = std::inner_product(out_coord.begin(), out_coord.end(), in_strides.begin(), 0);
if (finished) { if (finished) {
memcpy(out + cordinate_transform.index({time, batch, beam}) * elem_size, end_token, elem_size); memcpy(out + out_idx * elem_size, end_token, elem_size);
} else if (_asIndex(out + cordinate_transform.index({time, batch, beam}) * elem_size, element_type) == } else if (_asIndex(out + out_idx * elem_size, element_type) == _asIndex(end_token, element_type)) {
_asIndex(end_token, element_type)) {
finished = true; finished = true;
} }
} }
} }
} }
NGRAPH_SUPPRESS_DEPRECATED_END
} }

View File

@ -21,7 +21,17 @@ Interval::value_type clip_times(Interval::value_type a, Interval::value_type b)
} }
} }
Interval::value_type clip_add(Interval::value_type a, Interval::value_type b) { Interval::value_type clip_add(Interval::value_type a, Interval::value_type b) {
return (a == Interval::s_max || b == Interval::s_max) ? Interval::s_max : a + b; if (a == Interval::s_max || b == Interval::s_max) {
return Interval::s_max;
}
// check overflow without undefined behavior: a + b <= max
const static auto max = std::numeric_limits<Interval::value_type>::max();
if (b > (max - a)) {
return Interval::s_max;
}
return a + b;
} }
Interval::value_type clip_minus(Interval::value_type a, Interval::value_type b) { Interval::value_type clip_minus(Interval::value_type a, Interval::value_type b) {
if (a <= b) { if (a <= b) {

View File

@ -33,35 +33,68 @@ bool ngraph::op::v1::GatherTree::visit_attributes(AttributeVisitor& visitor) {
void op::v1::GatherTree::validate_and_infer_types() { void op::v1::GatherTree::validate_and_infer_types() {
NGRAPH_OP_SCOPE(v1_GatherTree_validate_and_infer_types); NGRAPH_OP_SCOPE(v1_GatherTree_validate_and_infer_types);
const auto& step_ids_rank = get_input_partial_shape(0);
const auto& parent_idx_rank = get_input_partial_shape(1);
const auto& max_seq_len_rank = get_input_partial_shape(2);
const auto& end_token_rank = get_input_partial_shape(3);
NODE_VALIDATION_CHECK(this,
step_ids_rank.rank().is_dynamic() || step_ids_rank.rank().get_length() == 3,
"step_ids input rank must equal to 3 (step_ids rank: ",
step_ids_rank.rank().get_length(),
")");
NODE_VALIDATION_CHECK(this,
parent_idx_rank.rank().is_dynamic() || parent_idx_rank.rank().get_length() == 3,
"parent_idx input rank must equal to 3 (parent_idx rank: ",
parent_idx_rank.rank().get_length(),
")");
NODE_VALIDATION_CHECK(this,
max_seq_len_rank.rank().is_dynamic() || max_seq_len_rank.rank().get_length() == 1,
"max_seq_len input rank must equal to 1 (max_seq_len rank: ",
max_seq_len_rank.rank().get_length(),
")");
NODE_VALIDATION_CHECK(this,
end_token_rank.rank().is_dynamic() || end_token_rank.rank().get_length() == 0,
"end_token input rank must be scalar (end_token rank: ",
end_token_rank.rank().get_length(),
")");
const auto& step_ids_et = get_input_element_type(0); const auto& step_ids_et = get_input_element_type(0);
set_output_type(0, step_ids_et, step_ids_rank); const auto& parent_idx_et = get_input_element_type(1);
const auto& max_seq_len_et = get_input_element_type(2);
const auto& end_token_et = get_input_element_type(3);
element::Type result_et;
NODE_VALIDATION_CHECK(this,
element::Type::merge(result_et, step_ids_et, parent_idx_et) &&
element::Type::merge(result_et, result_et, max_seq_len_et) &&
element::Type::merge(result_et, result_et, end_token_et),
"Inputs must have the same element type. Got: step_ids (",
step_ids_et,
"), parent_idx_et (",
parent_idx_et,
"), max_seq_len (",
max_seq_len_et,
"), end_token (",
end_token_et,
")");
NODE_VALIDATION_CHECK(this,
result_et.is_real() || result_et.is_integral_number(),
"Element type of inputs must be numeric. Got: ",
result_et);
const auto& step_ids_pshape = get_input_partial_shape(0);
const auto& parent_idx_pshape = get_input_partial_shape(1);
const auto& max_seq_len_pshape = get_input_partial_shape(2);
const auto& end_token_pshape = get_input_partial_shape(3);
PartialShape result_pshape{PartialShape::dynamic()};
NODE_VALIDATION_CHECK(this,
PartialShape::merge_into(result_pshape, step_ids_pshape) &&
PartialShape::merge_into(result_pshape, parent_idx_pshape) &&
result_pshape.rank().compatible(3),
"step_ids and parent_idx inputs must have the same shape with rank 3. Got: ",
step_ids_pshape,
" and ",
parent_idx_pshape,
", respectively");
NODE_VALIDATION_CHECK(this,
max_seq_len_pshape.rank().compatible(1),
"max_seq_len input must have rank 1. Got: ",
max_seq_len_pshape);
if (result_pshape.rank().is_static() && max_seq_len_pshape.rank().is_static()) {
NODE_VALIDATION_CHECK(this,
Dimension::merge(result_pshape[1], result_pshape[1], max_seq_len_pshape[0]),
"Number of elements of max_seq_len input must match BATCH_SIZE dimension of "
"step_ids/parent_idx inputs. Got: ",
result_pshape[1],
" and ",
max_seq_len_pshape[0],
", respectively");
}
NODE_VALIDATION_CHECK(this,
end_token_pshape.rank().compatible(0),
"end_token input must be scalar. Got: ",
end_token_pshape);
set_output_type(0, result_et, result_pshape);
} }

View File

@ -73,7 +73,7 @@ bool op::v0::Tile::evaluate_tile(const HostTensorVector& outputs, const HostTens
const auto& data = inputs[0]; const auto& data = inputs[0];
const auto& axis = inputs[1]; const auto& axis = inputs[1];
auto& output = outputs[0]; auto& output = outputs[0];
auto repeats_val = read_vector<int64_t>(axis); auto repeats_val = read_index_vector(axis);
auto repeats_rank = repeats_val.size(); auto repeats_rank = repeats_val.size();
ov::StaticShape data_shape = data->get_shape(); ov::StaticShape data_shape = data->get_shape();
auto data_rank = data_shape.size(); auto data_rank = data_shape.size();

View File

@ -17,7 +17,7 @@ source_group("public include" FILES ${LIBRARY_PUBLIC_HEADERS})
# Static library # Static library
add_library(${TARGET_NAME}_static STATIC ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${LIBRARY_PUBLIC_HEADERS}) add_library(${TARGET_NAME}_static STATIC ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${LIBRARY_PUBLIC_HEADERS})
add_library(ngraph::${TARGET_NAME}::static ALIAS ${TARGET_NAME}_static) add_library(${TARGET_NAME}::static ALIAS ${TARGET_NAME}_static)
target_link_libraries(${TARGET_NAME}_static PRIVATE ${CMAKE_DL_LIBS} PUBLIC ngraph) target_link_libraries(${TARGET_NAME}_static PRIVATE ${CMAKE_DL_LIBS} PUBLIC ngraph)
target_include_directories(${TARGET_NAME}_static PUBLIC ${FRONTEND_INCLUDE_DIR}) target_include_directories(${TARGET_NAME}_static PUBLIC ${FRONTEND_INCLUDE_DIR})
target_include_directories(${TARGET_NAME}_static PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src) target_include_directories(${TARGET_NAME}_static PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
@ -28,8 +28,10 @@ target_compile_definitions(${TARGET_NAME}_static PUBLIC USE_STATIC_FRONTEND_MANA
add_library(${TARGET_NAME} SHARED ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${LIBRARY_PUBLIC_HEADERS}) add_library(${TARGET_NAME} SHARED ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${LIBRARY_PUBLIC_HEADERS})
add_library(ngraph::${TARGET_NAME} ALIAS ${TARGET_NAME}) add_library(ngraph::${TARGET_NAME} ALIAS ${TARGET_NAME})
add_library(openvino::frontend::manager ALIAS ${TARGET_NAME})
target_include_directories(${TARGET_NAME} PUBLIC $<BUILD_INTERFACE:${FRONTEND_INCLUDE_DIR}> target_include_directories(${TARGET_NAME} PUBLIC
$<BUILD_INTERFACE:${FRONTEND_INCLUDE_DIR}>
$<INSTALL_INTERFACE:${FRONTEND_INSTALL_INCLUDE}>) $<INSTALL_INTERFACE:${FRONTEND_INSTALL_INCLUDE}>)
target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src) target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
target_link_libraries(${TARGET_NAME} PRIVATE ${CMAKE_DL_LIBS} PUBLIC ngraph) target_link_libraries(${TARGET_NAME} PRIVATE ${CMAKE_DL_LIBS} PUBLIC ngraph)
@ -53,9 +55,17 @@ install(TARGETS ${TARGET_NAME} EXPORT ngraphTargets
ARCHIVE DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph ARCHIVE DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph
LIBRARY DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph) LIBRARY DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph)
set_target_properties(${TARGET_NAME} PROPERTIES EXPORT_NAME frontend::manager)
install(TARGETS ${TARGET_NAME} EXPORT OpenVINOTargets
RUNTIME DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph
ARCHIVE DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph
LIBRARY DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph)
install(DIRECTORY ${FRONTEND_INCLUDE_DIR}/frontend_manager install(DIRECTORY ${FRONTEND_INCLUDE_DIR}/frontend_manager
DESTINATION ${FRONTEND_INSTALL_INCLUDE} DESTINATION ${FRONTEND_INSTALL_INCLUDE}
COMPONENT ngraph_dev COMPONENT ngraph_dev
FILES_MATCHING PATTERN "*.hpp") FILES_MATCHING PATTERN "*.hpp")
export(TARGETS ${TARGET_NAME} NAMESPACE ngraph:: APPEND FILE "${NGRAPH_TARGETS_FILE}") export(TARGETS ${TARGET_NAME} NAMESPACE ngraph:: APPEND FILE "${NGRAPH_TARGETS_FILE}")
export(TARGETS ${TARGET_NAME} NAMESPACE openvino::
APPEND FILE "${CMAKE_BINARY_DIR}/OpenVINOTargets.cmake")

View File

@ -23,12 +23,11 @@ add_library(${TARGET_NAME} SHARED ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${LIBRARY_P
ov_ncc_naming_style(FOR_TARGET ${TARGET_NAME} ov_ncc_naming_style(FOR_TARGET ${TARGET_NAME}
INCLUDE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include" INCLUDE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include"
ADDITIONAL_INCLUDE_DIRECTORIES ADDITIONAL_INCLUDE_DIRECTORIES
$<TARGET_PROPERTY:ngraph::frontend_manager::static,INTERFACE_INCLUDE_DIRECTORIES>) $<TARGET_PROPERTY:frontend_manager::static,INTERFACE_INCLUDE_DIRECTORIES>)
target_include_directories(${TARGET_NAME} target_include_directories(${TARGET_NAME}
PUBLIC PUBLIC
$<BUILD_INTERFACE:${${TARGET_NAME}_INCLUDE_DIR}> $<BUILD_INTERFACE:${${TARGET_NAME}_INCLUDE_DIR}>
$<INSTALL_INTERFACE:${FRONTEND_INSTALL_INCLUDE}>
PRIVATE PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}) ${CMAKE_CURRENT_BINARY_DIR})
@ -40,22 +39,14 @@ if(COMMAND ie_add_vs_version_file)
FILEDESCRIPTION "FrontEnd to load and convert IR file format") FILEDESCRIPTION "FrontEnd to load and convert IR file format")
endif() endif()
target_link_libraries(${TARGET_NAME} PRIVATE ngraph::frontend_manager::static target_link_libraries(${TARGET_NAME} PRIVATE frontend_manager::static
PRIVATE ngraph::builder inference_engine_transformations ngraph::builder inference_engine_transformations
inference_engine pugixml::static inference_engine_plugin_api) inference_engine pugixml::static inference_engine_plugin_api)
add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME} add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME}
EXCLUDE_PATTERNS ${PROTO_SRCS} ${PROTO_HDRS}) EXCLUDE_PATTERNS ${PROTO_SRCS} ${PROTO_HDRS})
install(TARGETS ${TARGET_NAME} EXPORT ngraphTargets install(TARGETS ${TARGET_NAME}
RUNTIME DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph RUNTIME DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph
ARCHIVE DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph ARCHIVE DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph
LIBRARY DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph) LIBRARY DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph)
install(DIRECTORY ${${TARGET_NAME}_INCLUDE_DIR}/ir_frontend
DESTINATION ${FRONTEND_INSTALL_INCLUDE}
COMPONENT ngraph_dev
FILES_MATCHING PATTERN "*.hpp"
)
export(TARGETS ${TARGET_NAME} NAMESPACE ngraph:: APPEND FILE "${NGRAPH_TARGETS_FILE}")

View File

@ -2,6 +2,8 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# #
set(TARGET_NAME onnx_ngraph_frontend)
set(ONNX_OPSET_VERSION 13 CACHE INTERNAL "Supported version of ONNX operator set") set(ONNX_OPSET_VERSION 13 CACHE INTERNAL "Supported version of ONNX operator set")
set(ONNX_FRONTEND_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) set(ONNX_FRONTEND_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
@ -27,35 +29,41 @@ source_group("include" FILES ${LIBRARY_HEADERS})
source_group("public include" FILES ${LIBRARY_PUBLIC_HEADERS}) source_group("public include" FILES ${LIBRARY_PUBLIC_HEADERS})
# Create shared library # Create shared library
add_library(onnx_ngraph_frontend SHARED ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${LIBRARY_PUBLIC_HEADERS}) add_library(${TARGET_NAME} SHARED ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${LIBRARY_PUBLIC_HEADERS})
add_library(ngraph::onnx_ngraph_frontend ALIAS onnx_ngraph_frontend) add_library(openvino::frontend::onnx ALIAS ${TARGET_NAME})
add_clang_format_target(onnx_ngraph_frontend_clang FOR_TARGETS onnx_ngraph_frontend) add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME})
ov_ncc_naming_style(FOR_TARGET onnx_ngraph_frontend ov_ncc_naming_style(FOR_TARGET ${TARGET_NAME}
INCLUDE_DIRECTORY "${ONNX_FRONTEND_INCLUDE_DIR}" INCLUDE_DIRECTORY "${ONNX_FRONTEND_INCLUDE_DIR}"
DEFINITIONS DEFINITIONS
$<TARGET_PROPERTY:onnx,INTERFACE_COMPILE_DEFINITIONS> $<TARGET_PROPERTY:onnx,INTERFACE_COMPILE_DEFINITIONS>
ADDITIONAL_INCLUDE_DIRECTORIES ADDITIONAL_INCLUDE_DIRECTORIES
$<TARGET_PROPERTY:ngraph::frontend_manager::static,INTERFACE_INCLUDE_DIRECTORIES>) $<TARGET_PROPERTY:frontend_manager::static,INTERFACE_INCLUDE_DIRECTORIES>)
if(COMMAND ie_add_vs_version_file) if(COMMAND ie_add_vs_version_file)
ie_add_vs_version_file(NAME onnx_ngraph_frontend ie_add_vs_version_file(NAME ${TARGET_NAME}
FILEDESCRIPTION "nGraph ONNX frontend library") FILEDESCRIPTION "nGraph ONNX frontend library")
endif() endif()
target_link_libraries(onnx_ngraph_frontend PUBLIC ngraph PRIVATE frontend_manager ngraph::builder onnx_common inference_engine_transformations) target_link_libraries(${TARGET_NAME} PUBLIC ngraph PRIVATE frontend_manager ngraph::builder onnx_common inference_engine_transformations)
target_include_directories(onnx_ngraph_frontend PUBLIC $<BUILD_INTERFACE:${ONNX_FRONTEND_INCLUDE_DIR}> target_include_directories(${TARGET_NAME} PUBLIC $<BUILD_INTERFACE:${ONNX_FRONTEND_INCLUDE_DIR}>
$<INSTALL_INTERFACE:${FRONTEND_INSTALL_INCLUDE}>) $<INSTALL_INTERFACE:${FRONTEND_INSTALL_INCLUDE}>)
target_include_directories(onnx_ngraph_frontend PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src) target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
target_compile_definitions(onnx_ngraph_frontend PRIVATE ONNX_OPSET_VERSION=${ONNX_OPSET_VERSION}) target_compile_definitions(${TARGET_NAME} PRIVATE ONNX_OPSET_VERSION=${ONNX_OPSET_VERSION})
if(NGRAPH_USE_PROTOBUF_LITE) if(NGRAPH_USE_PROTOBUF_LITE)
target_compile_definitions(onnx_ngraph_frontend PRIVATE NGRAPH_USE_PROTOBUF_LITE) target_compile_definitions(${TARGET_NAME} PRIVATE NGRAPH_USE_PROTOBUF_LITE)
endif() endif()
install(TARGETS onnx_ngraph_frontend EXPORT ngraphTargets install(TARGETS ${TARGET_NAME} EXPORT ngraphTargets
RUNTIME DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph
ARCHIVE DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph
LIBRARY DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph)
set_target_properties(${TARGET_NAME} PROPERTIES EXPORT_NAME frontend::onnx)
install(TARGETS ${TARGET_NAME} EXPORT OpenVINOTargets
RUNTIME DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph RUNTIME DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph
ARCHIVE DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph ARCHIVE DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph
LIBRARY DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph) LIBRARY DESTINATION ${NGRAPH_INSTALL_LIB} COMPONENT ngraph)
@ -66,4 +74,6 @@ install(DIRECTORY ${ONNX_FRONTEND_INCLUDE_DIR}/onnx_frontend
COMPONENT ngraph_dev COMPONENT ngraph_dev
FILES_MATCHING PATTERN "*.hpp") FILES_MATCHING PATTERN "*.hpp")
export(TARGETS onnx_ngraph_frontend NAMESPACE ngraph:: APPEND FILE "${NGRAPH_TARGETS_FILE}") export(TARGETS ${TARGET_NAME} NAMESPACE ngraph:: APPEND FILE "${NGRAPH_TARGETS_FILE}")
export(TARGETS ${TARGET_NAME} NAMESPACE openvino::
APPEND FILE "${CMAKE_BINARY_DIR}/OpenVINOTargets.cmake")

View File

@ -217,6 +217,24 @@ bool onnx_editor::EdgeMapper::is_correct_tensor_name(const std::string& name) co
return false; return false;
} }
std::vector<std::string> onnx_editor::EdgeMapper::get_input_ports(const EditorNode& node) const {
NGRAPH_CHECK(is_correct_and_unambiguous_node(node),
"The node with name: " + (node.m_node_name.empty() ? "not_given" : node.m_node_name) +
", output_name: " + (node.m_output_name.empty() ? "not_given" : node.m_output_name) +
" is ambiguous");
const auto node_index = find_node_indexes(node.m_node_name, node.m_output_name)[0];
return m_node_inputs[node_index];
}
std::vector<std::string> onnx_editor::EdgeMapper::get_output_ports(const EditorNode& node) const {
NGRAPH_CHECK(is_correct_and_unambiguous_node(node),
"The node with name: " + (node.m_node_name.empty() ? "not_given" : node.m_node_name) +
", output_name: " + (node.m_output_name.empty() ? "not_given" : node.m_output_name) +
" is ambiguous");
const auto node_index = find_node_indexes(node.m_node_name, node.m_output_name)[0];
return m_node_outputs[node_index];
}
std::string onnx_editor::EdgeMapper::get_source_tensor_name(const InputEdge& edge) const { std::string onnx_editor::EdgeMapper::get_source_tensor_name(const InputEdge& edge) const {
if (edge.m_node_idx >= 0 && edge.m_node_idx < static_cast<int>(m_node_inputs.size()) && edge.m_port_idx >= 0 && if (edge.m_node_idx >= 0 && edge.m_node_idx < static_cast<int>(m_node_inputs.size()) && edge.m_port_idx >= 0 &&
edge.m_port_idx < static_cast<int>(m_node_inputs[edge.m_node_idx].size())) { edge.m_port_idx < static_cast<int>(m_node_inputs[edge.m_node_idx].size())) {

View File

@ -98,6 +98,20 @@ public:
/// ///
bool is_correct_tensor_name(const std::string& name) const; bool is_correct_tensor_name(const std::string& name) const;
/// \brief Get names of input ports of given node.
///
/// \param node An EditorNode helper structure created based on a node name
/// or a node output name.
///
std::vector<std::string> get_input_ports(const EditorNode& node) const;
/// \brief Get names of output ports of given node.
///
/// \param node An EditorNode helper structure created based on a node name
/// or a node output name.
///
std::vector<std::string> get_output_ports(const EditorNode& node) const;
/// \brief Get name of the tensor which is the source of the input edge. /// \brief Get name of the tensor which is the source of the input edge.
/// ///
/// \note Empty string is returned if the tensor name is not found. /// \note Empty string is returned if the tensor name is not found.

View File

@ -449,6 +449,16 @@ bool onnx_editor::ONNXModelEditor::is_correct_tensor_name(const std::string& nam
return m_pimpl->m_edge_mapper.is_correct_tensor_name(name); return m_pimpl->m_edge_mapper.is_correct_tensor_name(name);
} }
std::vector<std::string> onnx_editor::ONNXModelEditor::get_input_ports(const EditorNode& node) const {
update_mapper_if_needed();
return m_pimpl->m_edge_mapper.get_input_ports(node);
}
std::vector<std::string> onnx_editor::ONNXModelEditor::get_output_ports(const EditorNode& node) const {
update_mapper_if_needed();
return m_pimpl->m_edge_mapper.get_output_ports(node);
}
std::shared_ptr<Function> onnx_editor::ONNXModelEditor::decode() { std::shared_ptr<Function> onnx_editor::ONNXModelEditor::decode() {
return onnx_import::detail::decode_to_framework_nodes(m_pimpl->m_model_proto, m_model_path); return onnx_import::detail::decode_to_framework_nodes(m_pimpl->m_model_proto, m_model_path);
} }

View File

@ -204,6 +204,20 @@ public:
/// ///
bool is_correct_tensor_name(const std::string& name) const; bool is_correct_tensor_name(const std::string& name) const;
/// \brief Get names of input ports of given node.
///
/// \param node An EditorNode helper structure created based on a node name
/// or a node output name.
///
std::vector<std::string> get_input_ports(const EditorNode& node) const;
/// \brief Get names of output ports of given node.
///
/// \param node An EditorNode helper structure created based on a node name
/// or a node output name.
///
std::vector<std::string> get_output_ports(const EditorNode& node) const;
/// \brief Returns a nGraph function based on edited model /// \brief Returns a nGraph function based on edited model
/// decoded to framework nodes /// decoded to framework nodes
/// ///

View File

@ -52,9 +52,17 @@ std::vector<Place::Ptr> InputModelONNX::get_outputs() const {
} }
Place::Ptr InputModelONNX::get_place_by_tensor_name(const std::string& tensor_name) const { Place::Ptr InputModelONNX::get_place_by_tensor_name(const std::string& tensor_name) const {
NGRAPH_CHECK(m_editor->is_correct_tensor_name(tensor_name), if (m_editor->is_correct_tensor_name(tensor_name)) {
"The tensor with name: " + tensor_name + " does not exist in the graph"); return std::make_shared<PlaceTensorONNX>(tensor_name, m_editor);
return std::make_shared<PlaceTensorONNX>(tensor_name, m_editor); }
return nullptr;
}
Place::Ptr InputModelONNX::get_place_by_operation_name(const std::string& operation_name) const {
if (m_editor->is_correct_and_unambiguous_node(operation_name)) {
return std::make_shared<PlaceOpONNX>(onnx_editor::EditorNode{operation_name}, m_editor);
}
return nullptr;
} }
Place::Ptr InputModelONNX::get_place_by_operation_name_and_input_port(const std::string& operation_name, Place::Ptr InputModelONNX::get_place_by_operation_name_and_input_port(const std::string& operation_name,

View File

@ -25,6 +25,7 @@ public:
std::vector<Place::Ptr> get_inputs() const override; std::vector<Place::Ptr> get_inputs() const override;
std::vector<Place::Ptr> get_outputs() const override; std::vector<Place::Ptr> get_outputs() const override;
Place::Ptr get_place_by_tensor_name(const std::string& tensor_name) const override; Place::Ptr get_place_by_tensor_name(const std::string& tensor_name) const override;
Place::Ptr get_place_by_operation_name(const std::string& operation_name) const override;
Place::Ptr get_place_by_operation_name_and_input_port(const std::string& operation_name, Place::Ptr get_place_by_operation_name_and_input_port(const std::string& operation_name,
int input_port_index) override; int input_port_index) override;
void set_partial_shape(Place::Ptr place, const ngraph::PartialShape& shape) override; void set_partial_shape(Place::Ptr place, const ngraph::PartialShape& shape) override;

View File

@ -133,3 +133,59 @@ bool PlaceTensorONNX::is_equal_data(Place::Ptr another) const {
return is_equal(another) || (is_input() ? false : get_producing_port()->is_equal(another)) || return is_equal(another) || (is_input() ? false : get_producing_port()->is_equal(another)) ||
eq_to_consuming_port(another); eq_to_consuming_port(another);
} }
PlaceOpONNX::PlaceOpONNX(const onnx_editor::EditorNode& node, std::shared_ptr<onnx_editor::ONNXModelEditor> editor)
: m_node{node},
m_editor{editor} {}
std::vector<std::string> PlaceOpONNX::get_names() const {
return {m_node.m_node_name};
}
Place::Ptr PlaceOpONNX::get_output_port() const {
if (m_editor->get_output_ports(m_node).size() == 1) {
return get_output_port(0);
}
return nullptr;
}
Place::Ptr PlaceOpONNX::get_output_port(int output_port_index) const {
if (output_port_index < m_editor->get_output_ports(m_node).size()) {
const auto output_edge = m_editor->find_output_edge(m_node, onnx_editor::EditorOutput{output_port_index});
return std::make_shared<PlaceOutputEdgeONNX>(output_edge, m_editor);
}
return nullptr;
}
Place::Ptr PlaceOpONNX::get_output_port(const std::string& output_port_name) const {
const auto output_ports = m_editor->get_output_ports(m_node);
if (std::count(std::begin(output_ports), std::end(output_ports), output_port_name) == 1) {
const auto output_edge = m_editor->find_output_edge(m_node, onnx_editor::EditorOutput{output_port_name});
return std::make_shared<PlaceOutputEdgeONNX>(output_edge, m_editor);
}
return nullptr;
}
Place::Ptr PlaceOpONNX::get_input_port() const {
if (m_editor->get_input_ports(m_node).size() == 1) {
return get_input_port(0);
}
return nullptr;
}
Place::Ptr PlaceOpONNX::get_input_port(int input_port_index) const {
if (input_port_index < m_editor->get_input_ports(m_node).size()) {
const auto input_edge = m_editor->find_input_edge(m_node, onnx_editor::EditorInput{input_port_index});
return std::make_shared<PlaceInputEdgeONNX>(input_edge, m_editor);
}
return nullptr;
}
Place::Ptr PlaceOpONNX::get_input_port(const std::string& input_name) const {
const auto input_ports = m_editor->get_input_ports(m_node);
if (std::count(std::begin(input_ports), std::end(input_ports), input_name) == 1) {
const auto input_edge = m_editor->find_input_edge(m_node, onnx_editor::EditorInput{input_name});
return std::make_shared<PlaceInputEdgeONNX>(input_edge, m_editor);
}
return nullptr;
}

View File

@ -76,6 +76,24 @@ private:
std::string m_name; std::string m_name;
std::shared_ptr<onnx_editor::ONNXModelEditor> m_editor; std::shared_ptr<onnx_editor::ONNXModelEditor> m_editor;
}; };
class PlaceOpONNX : public Place {
public:
PlaceOpONNX(const onnx_editor::EditorNode& node, std::shared_ptr<onnx_editor::ONNXModelEditor> editor);
std::vector<std::string> get_names() const override;
Place::Ptr get_output_port() const override;
Place::Ptr get_output_port(int output_port_index) const override;
Place::Ptr get_output_port(const std::string& output_port_name) const override;
Place::Ptr get_input_port() const override;
Place::Ptr get_input_port(int input_port_index) const override;
Place::Ptr get_input_port(const std::string& input_name) const override;
private:
onnx_editor::EditorNode m_node;
std::shared_ptr<onnx_editor::ONNXModelEditor> m_editor;
};
} // namespace frontend } // namespace frontend
} // namespace ngraph } // namespace ngraph

View File

@ -16,7 +16,6 @@ source_group("include" FILES ${PUBLIC_HEADERS} ${PUBLIC_HEADERS})
# Create static library # Create static library
add_library(${TARGET_NAME} STATIC ${LIBRARY_SRC} ${PUBLIC_HEADERS}) add_library(${TARGET_NAME} STATIC ${LIBRARY_SRC} ${PUBLIC_HEADERS})
add_library(ngraph::onnx_common ALIAS ${TARGET_NAME})
# TODO Add handling ie_faster_build # TODO Add handling ie_faster_build

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