Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f26da46e3b | ||
|
|
cd95d8d3bb | ||
|
|
5c6a0cb922 | ||
|
|
2e634cafc9 | ||
|
|
28f258e18d | ||
|
|
2fe9b15230 | ||
|
|
9221f41b01 | ||
|
|
85de6ee857 | ||
|
|
acad2e01e5 | ||
|
|
94dd082199 | ||
|
|
95a57795dc | ||
|
|
a347375d01 | ||
|
|
b2140c083a | ||
|
|
949b74059f | ||
|
|
651161be1c | ||
|
|
f73852ea3d | ||
|
|
b0c5accaf8 | ||
|
|
733dae46cc | ||
|
|
fe3f978b98 | ||
|
|
6dfc778940 | ||
|
|
1798ac0d26 | ||
|
|
298900790c | ||
|
|
1c794d971c | ||
|
|
0923303e02 | ||
|
|
ba6e22b1b5 | ||
|
|
c585b530c1 | ||
|
|
693ab4e79a |
19
.clang-format
Normal file
19
.clang-format
Normal file
@@ -0,0 +1,19 @@
|
||||
BasedOnStyle: Google
|
||||
IndentWidth: 4
|
||||
UseTab: Never
|
||||
---
|
||||
Language: Cpp
|
||||
Standard: Cpp11
|
||||
|
||||
AccessModifierOffset: -4
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowShortFunctionsOnASingleLine: Empty
|
||||
AllowShortLambdasOnASingleLine: Empty
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
ColumnLimit: 120
|
||||
DerivePointerAlignment: false
|
||||
FixNamespaceComments: true
|
||||
IndentCaseLabels: false
|
||||
SpaceBeforeCpp11BracedList: true
|
||||
SpaceBeforeCtorInitializerColon: false
|
||||
---
|
||||
55
.github/workflows/mo.yml
vendored
Normal file
55
.github/workflows/mo.yml
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
name: MO
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'model-optimizer/**'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'model-optimizer/**'
|
||||
|
||||
jobs:
|
||||
Pylint-UT:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: 3.6
|
||||
|
||||
- name: Cache pip
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('model-optimizer/requirements*.txt') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-
|
||||
${{ runner.os }}-
|
||||
|
||||
# tensorflow 1.15 causes modules import
|
||||
# errors, most likely due to https://github.com/PyCQA/pylint/issues/2603
|
||||
# for tensorflow.core.framework and tensorflow.contrib
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip setuptools
|
||||
# For Pylint
|
||||
pip install tensorflow==1.14.0 tensorboard==1.14.0 tensorflow-estimator==1.14.0
|
||||
# For UT
|
||||
pip install unittest-xml-reporting==3.0.2
|
||||
# MO requirements
|
||||
pip install -r requirements.txt
|
||||
pip install -r requirements_dev.txt
|
||||
working-directory: model-optimizer
|
||||
|
||||
- name: Pylint
|
||||
run: pylint -d C,R,W mo/ mo.py extensions/
|
||||
working-directory: model-optimizer
|
||||
|
||||
- name: UT
|
||||
run: |
|
||||
export PYTHONPATH=$PYTHONPATH:`pwd`
|
||||
export MO_ROOT=`pwd`
|
||||
env
|
||||
mkdir ../mo-ut-logs
|
||||
python3 -m xmlrunner discover -p *_test.py --output=../mo-ut-logs
|
||||
working-directory: model-optimizer
|
||||
5
.gitmodules
vendored
5
.gitmodules
vendored
@@ -1,3 +1,8 @@
|
||||
[submodule "inference-engine/thirdparty/ade"]
|
||||
path = inference-engine/thirdparty/ade
|
||||
url = https://github.com/opencv/ade.git
|
||||
ignore = dirty
|
||||
[submodule "ngraph"]
|
||||
path = ngraph
|
||||
url = https://github.com/NervanaSystems/ngraph.git
|
||||
ignore = dirty
|
||||
|
||||
165
CMakeLists.txt
Normal file
165
CMakeLists.txt
Normal file
@@ -0,0 +1,165 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
cmake_policy(SET CMP0054 NEW)
|
||||
|
||||
# TODO: for make instal / package we need to use 3.13.3 version because
|
||||
# it allows to install targets created outside of current projects
|
||||
# See https://blog.kitware.com/cmake-3-13-0-available-for-download/
|
||||
|
||||
if (APPLE)
|
||||
# due to https://cmake.org/cmake/help/v3.12/policy/CMP0068.html
|
||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
||||
else()
|
||||
cmake_minimum_required(VERSION 3.7.2 FATAL_ERROR)
|
||||
endif()
|
||||
|
||||
|
||||
project(OpenVINO)
|
||||
|
||||
set(OpenVINO_MAIN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(IE_MAIN_SOURCE_DIR ${OpenVINO_MAIN_SOURCE_DIR}/inference-engine)
|
||||
set(CMAKE_MODULE_PATH "${OpenVINO_MAIN_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
||||
|
||||
include(CTest)
|
||||
include(features)
|
||||
|
||||
# include developer package
|
||||
include(developer_package NO_POLICY_SCOPE)
|
||||
|
||||
# These options are shared with 3rdparty plugins
|
||||
# by means of developer package
|
||||
include(check_features)
|
||||
include(dependencies)
|
||||
|
||||
# resolving dependencies for the project
|
||||
message (STATUS "PROJECT ............................... " ${PROJECT_NAME})
|
||||
message (STATUS "CMAKE_BINARY_DIR ...................... " ${CMAKE_BINARY_DIR})
|
||||
message (STATUS "OpenVINO_MAIN_SOURCE_DIR .............. " ${OpenVINO_MAIN_SOURCE_DIR})
|
||||
message (STATUS "IE_MAIN_SOURCE_DIR .............. " ${IE_MAIN_SOURCE_DIR})
|
||||
message (STATUS "CMAKE_GENERATOR ....................... " ${CMAKE_GENERATOR})
|
||||
message (STATUS "CMAKE_C_COMPILER_ID ................... " ${CMAKE_C_COMPILER_ID})
|
||||
message (STATUS "CMAKE_BUILD_TYPE ...................... " ${CMAKE_BUILD_TYPE})
|
||||
|
||||
# remove file with exported developer targets to force its regeneration
|
||||
file(REMOVE "${CMAKE_BINARY_DIR}/targets_developer.cmake")
|
||||
file(REMOVE "${CMAKE_BINARY_DIR}/targets.cmake")
|
||||
|
||||
function(build_ngraph)
|
||||
function(ngraph_set option value)
|
||||
if(NOT DEFINED ${option})
|
||||
set(${option} ${value} CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
set(NGRAPH_BUILD_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} CACHE STRING "" FORCE)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${OpenVINO_MAIN_SOURCE_DIR}/ngraph/cmake/Modules/")
|
||||
|
||||
if (ENABLE_SANITIZER)
|
||||
ngraph_set(NGRAPH_ADDRESS_SANITIZER TRUE)
|
||||
else ()
|
||||
ngraph_set(NGRAPH_ADDRESS_SANITIZER FALSE)
|
||||
endif ()
|
||||
ngraph_set(NGRAPH_TOOLS_ENABLE FALSE)
|
||||
ngraph_set(NGRAPH_CPU_ENABLE FALSE)
|
||||
ngraph_set(NGRAPH_INTERPRETER_ENABLE TRUE)
|
||||
ngraph_set(NGRAPH_NOP_ENABLE FALSE)
|
||||
ngraph_set(NGRAPH_GPUH_ENABLE FALSE)
|
||||
ngraph_set(NGRAPH_GENERIC_CPU_ENABLE FALSE)
|
||||
ngraph_set(NGRAPH_ENABLE_CPU_CONV_AUTO FALSE)
|
||||
ngraph_set(NGRAPH_PYTHON_BUILD_ENABLE FALSE)
|
||||
ngraph_set(NGRAPH_PLAIDML_ENABLE FALSE)
|
||||
ngraph_set(NGRAPH_FAST_MATH_ENABLE FALSE)
|
||||
ngraph_set(NGRAPH_JSON_ENABLE FALSE)
|
||||
ngraph_set(NGRAPH_DYNAMIC_COMPONENTS_ENABLE FALSE)
|
||||
ngraph_set(NGRAPH_NATIVE_ARCH_ENABLE FALSE)
|
||||
|
||||
if (NOT ANDROID)
|
||||
ngraph_set(NGRAPH_UNIT_TEST_ENABLE TRUE)
|
||||
ngraph_set(NGRAPH_UNIT_TEST_OPENVINO_ENABLE TRUE)
|
||||
ngraph_set(NGRAPH_ONNX_IMPORT_ENABLE TRUE)
|
||||
else()
|
||||
ngraph_set(NGRAPH_UNIT_TEST_ENABLE FALSE)
|
||||
ngraph_set(NGRAPH_TEST_UTIL_ENABLE FALSE)
|
||||
ngraph_set(NGRAPH_UNIT_TEST_OPENVINO_ENABLE FALSE)
|
||||
ngraph_set(NGRAPH_ONNX_IMPORT_ENABLE FALSE)
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
ie_add_compiler_flags(-Wno-error=uninitialized -Wno-error=literal-conversion)
|
||||
elseif(UNIX)
|
||||
ie_add_compiler_flags(-Wno-error=maybe-uninitialized -Wno-error=return-type -fPIC)
|
||||
endif()
|
||||
if(ANDROID)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=defaulted-function-deleted -Wno-error=unused-command-line-argument")
|
||||
endif()
|
||||
|
||||
# WA for GCC 7.0
|
||||
if (UNIX)
|
||||
ie_add_compiler_flags(-Wno-error=return-type -Wno-undef)
|
||||
elseif(WIN32)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4308 /wd4146 /wd4703 /wd4244")
|
||||
endif()
|
||||
|
||||
if(ENABLE_LTO)
|
||||
ie_enable_lto()
|
||||
endif()
|
||||
|
||||
ie_cpack_add_component(ngraph)
|
||||
|
||||
set(SDL_cmake_included ON)
|
||||
# set(NGRAPH_COMPONENT_PREFIX "deployment_tools/ngraph/")
|
||||
add_subdirectory(ngraph)
|
||||
endfunction()
|
||||
|
||||
build_ngraph()
|
||||
|
||||
add_subdirectory(inference-engine)
|
||||
|
||||
add_subdirectory(docs)
|
||||
|
||||
# cpack
|
||||
|
||||
# install setupvars
|
||||
|
||||
ie_cpack_add_component(setupvars REQUIRED)
|
||||
|
||||
if(UNIX)
|
||||
install(PROGRAMS scripts/setupvars/setupvars.sh
|
||||
DESTINATION bin
|
||||
COMPONENT setupvars)
|
||||
elseif(WIN32)
|
||||
install(PROGRAMS scripts/setupvars/setupvars.bat
|
||||
DESTINATION bin
|
||||
COMPONENT setupvars)
|
||||
endif()
|
||||
|
||||
# install install_dependencies
|
||||
|
||||
if(UNIX)
|
||||
ie_cpack_add_component(install_dependencies REQUIRED)
|
||||
install(DIRECTORY scripts/install_dependencies/
|
||||
DESTINATION install_dependencies
|
||||
COMPONENT install_dependencies)
|
||||
endif()
|
||||
|
||||
# install files for demo
|
||||
|
||||
ie_cpack_add_component(demo_scripts REQUIRED DEPENDS core)
|
||||
|
||||
if(UNIX)
|
||||
install(DIRECTORY scripts/demo/
|
||||
DESTINATION deployment_tools/demo
|
||||
COMPONENT demo_scripts
|
||||
USE_SOURCE_PERMISSIONS
|
||||
PATTERN *.bat EXCLUDE)
|
||||
elseif(WIN32)
|
||||
install(DIRECTORY scripts/demo/
|
||||
DESTINATION deployment_tools/demo
|
||||
COMPONENT demo_scripts
|
||||
USE_SOURCE_PERMISSIONS
|
||||
PATTERN *.sh EXCLUDE)
|
||||
endif()
|
||||
|
||||
ie_cpack(${IE_CPACK_COMPONENTS_ALL})
|
||||
66
CODEOWNERS
Normal file
66
CODEOWNERS
Normal file
@@ -0,0 +1,66 @@
|
||||
# See help here: https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners
|
||||
|
||||
* @openvinotoolkit/openvino-maintainers
|
||||
|
||||
CODEOWNERS @openvinotoolkit/openvino-admins @openvinotoolkit/openvino-maintainers
|
||||
|
||||
# CI:
|
||||
Jenkinsfile @openvinotoolkit/openvino-admins
|
||||
azure-pipelines.yml @openvinotoolkit/openvino-admins
|
||||
/.github/ @openvinotoolkit/openvino-admins
|
||||
|
||||
# QA Tests:
|
||||
/tests/ @openvinotoolkit/openvino-tests-maintainers
|
||||
|
||||
# IE Core:
|
||||
/inference-engine/ @openvinotoolkit/openvino-ie-maintainers
|
||||
/inference-engine/src/transformations/ @GlebKazantaev @ichuraev
|
||||
/inference-engine/src/legacy_api/ @openvinotoolkit/openvino-ngraph-maintainers
|
||||
/inference-engine/src/readers/ @openvinotoolkit/openvino-ngraph-maintainers
|
||||
|
||||
# IE CPU:
|
||||
/inference-engine/src/mkldnn_plugin/ @openvinotoolkit/openvino-ie-cpu-maintainers @openvinotoolkit/openvino-ie-cpu-developers
|
||||
/inference-engine/src/low_precision_transformations/ @openvinotoolkit/openvino-ie-cpu-maintainers @openvinotoolkit/openvino-ie-cpu-developers
|
||||
/inference-engine/thirdparty/mkl-dnn/ @openvinotoolkit/openvino-ie-cpu-maintainers @openvinotoolkit/openvino-ie-cpu-developers
|
||||
|
||||
# IE GPU:
|
||||
/inference-engine/src/cldnn_engine/ @openvinotoolkit/openvino-ie-gpu-maintainers @openvinotoolkit/openvino-ie-gpu-developers
|
||||
/inference-engine/include/gpu/ @openvinotoolkit/openvino-ie-gpu-maintainers @openvinotoolkit/openvino-ie-gpu-developers
|
||||
/inference-engine/include/cldnn/ @openvinotoolkit/openvino-ie-gpu-maintainers @openvinotoolkit/openvino-ie-gpu-developers
|
||||
/inference-engine/thirdparty/clDNN/ @openvinotoolkit/openvino-ie-gpu-maintainers @openvinotoolkit/openvino-ie-gpu-developers
|
||||
|
||||
# IE VPU:
|
||||
/inference-engine/src/vpu/ @openvinotoolkit/openvino-ie-vpu-maintainers
|
||||
/inference-engine/include/vpu/ @openvinotoolkit/openvino-ie-vpu-maintainers
|
||||
/inference-engine/thirdparty/movidius/ @openvinotoolkit/openvino-ie-vpu-maintainers
|
||||
/inference-engine/tests_deprecated/unit/engines/vpu/ @openvinotoolkit/openvino-ie-vpu-maintainers @openvinotoolkit/openvino-ie-tests-maintainers
|
||||
/inference-engine/tests_deprecated/functional/vpu/ @openvinotoolkit/openvino-ie-vpu-maintainers @openvinotoolkit/openvino-ie-tests-maintainers
|
||||
/inference-engine/tests_deprecated/behavior/vpu/ @openvinotoolkit/openvino-ie-vpu-maintainers @openvinotoolkit/openvino-ie-tests-maintainers
|
||||
/inference-engine/tests/functional/plugin/myriad/ @openvinotoolkit/openvino-ie-vpu-maintainers @openvinotoolkit/openvino-ie-tests-maintainers
|
||||
/inference-engine/tests/unit/vpu/ @openvinotoolkit/openvino-ie-vpu-maintainers @openvinotoolkit/openvino-ie-tests-maintainers
|
||||
/inference-engine/tests/unit/engines/vpu/ @openvinotoolkit/openvino-ie-vpu-maintainers @openvinotoolkit/openvino-ie-tests-maintainers
|
||||
/inference-engine/tools/vpu/ @openvinotoolkit/openvino-ie-vpu-maintainers
|
||||
/inference-engine/scripts/run_tests_myriad_multistick.sh @openvinotoolkit/openvino-ie-vpu-maintainers
|
||||
|
||||
# IE GNA:
|
||||
/inference-engine/src/gna_plugin/ @openvinotoolkit/openvino-ie-gna-maintainers
|
||||
/inference-engine/include/gna/ @openvinotoolkit/openvino-ie-gna-maintainers
|
||||
|
||||
# IE MULTI:
|
||||
/inference-engine/src/multi_device/ @openvinotoolkit/openvino-ie-multi-maintainers
|
||||
/inference-engine/include/multi-device/ @openvinotoolkit/openvino-ie-multi-maintainers
|
||||
|
||||
# IE Tests:
|
||||
/inference-engine/tests/ @openvinotoolkit/openvino-ie-tests-maintainers
|
||||
/inference-engine/tests_deprecated/ @openvinotoolkit/openvino-ie-tests-maintainers
|
||||
/inference-engine/tests/functional/inference_engine/ngraph_reader/ @openvinotoolkit/openvino-ie-tests-maintainers @openvinotoolkit/openvino-ngraph-maintainers
|
||||
/inference-engine/tests/functional/inference_engine/transformations/ @openvinotoolkit/openvino-ie-tests-maintainers @openvinotoolkit/openvino-ngraph-maintainers
|
||||
|
||||
# MO:
|
||||
/model-optimizer/ @openvinotoolkit/openvino-mo-maintainers
|
||||
|
||||
# nGraph:
|
||||
/ngraph/ @openvinotoolkit/openvino-ngraph-maintainers
|
||||
|
||||
# Tools
|
||||
/tools/ @openvinotoolkit/openvino-tools-maintainers
|
||||
18
CONTRIBUTING.md
Normal file
18
CONTRIBUTING.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# How to Contribute
|
||||
We welcome community contributions to the OpenVINO™ repository.
|
||||
If you have an idea how to improve the product, please share it
|
||||
with us doing the following steps:
|
||||
|
||||
* Make sure you can build the product and run all tests and samples with your patch
|
||||
* In case of a larger feature, provide relevant unit tests and one or more sample
|
||||
* Submit a pull request at https://github.com/openvinotoolkit/openvino/pulls
|
||||
|
||||
## OpenVINO™ Coding Style Guide
|
||||
We basically use the Google style (https://google.github.io/styleguide/cppguide.html) with some exceptions:
|
||||
* 4 spaces instead of 2 spaces for indentations
|
||||
* Limitation of 160 symbols for the line length
|
||||
* Exceptions are allowed
|
||||
* Using namespace are allowed in cpp and prohibited in headers
|
||||
* Underscore symbol before member in classes/structures
|
||||
* thisStyleForFunctions()
|
||||
* theSameStyleForVariables
|
||||
44
README.md
44
README.md
@@ -1,42 +1,48 @@
|
||||
# [OpenVINO™ Toolkit](https://01.org/openvinotoolkit) - Deep Learning Deployment Toolkit repository
|
||||
[](https://github.com/opencv/dldt/releases/tag/2019_R1)
|
||||
[](https://github.com/openvinotoolkit/openvino/releases/tag/2020.3.0)
|
||||
[](LICENSE)
|
||||
|
||||
This toolkit allows developers to deploy pre-trained deep learning models through a high-level C++ Inference Engine API integrated with application logic.
|
||||
This toolkit allows developers to deploy pre-trained deep learning models
|
||||
through a high-level C++ Inference Engine API integrated with application logic.
|
||||
|
||||
This open source version includes two components, namely Model Optimizer and Inference Engine, as well as CPU, GPU and heterogeneous plugins to accelerate deep learning inferencing on Intel(R) CPUs and Intel(R) Processor Graphics. It supports pre-trained models from the [Open Model Zoo](https://github.com/opencv/open_model_zoo/) along with 100+ open source and public models in popular formats such as Caffe*, Tensorflow*, MXNet* and ONNX*.
|
||||
This open source version includes two components: namely [Model Optimizer] and
|
||||
[Inference Engine], as well as CPU, GPU and heterogeneous plugins to accelerate
|
||||
deep learning inferencing on Intel® CPUs and Intel® Processor Graphics.
|
||||
It supports pre-trained models from the [Open Model Zoo], along with 100+ open
|
||||
source and public models in popular formats such as Caffe\*, TensorFlow\*,
|
||||
MXNet\* and ONNX\*.
|
||||
|
||||
## Repository components:
|
||||
* [Inference Engine](https://software.intel.com/en-us/articles/OpenVINO-InferEngine)
|
||||
* [Model Optimizer](https://software.intel.com/en-us/articles/OpenVINO-ModelOptimizer)
|
||||
* [Inference Engine]
|
||||
* [Model Optimizer]
|
||||
|
||||
## License
|
||||
Deep Learning Deployment Toolkit is licensed under [Apache License Version 2.0](LICENSE).
|
||||
By contributing to the project, you agree to the license and copyright terms therein
|
||||
and release your contribution under these terms.
|
||||
|
||||
## Documentation
|
||||
* [OpenVINO™ Release Notes](https://software.intel.com/en-us/articles/OpenVINO-RelNotes)
|
||||
* [Inference Engine build instructions](inference-engine/README.md)
|
||||
* [Get Started with Deep Learning Deployment Toolkit on Linux*](get-started-linux.md)
|
||||
* [OpenVINO™ Inference Engine Build Instructions](build-instruction.md)
|
||||
* [Get Started with Deep Learning Deployment Toolkit on Linux](get-started-linux.md)\*
|
||||
* [Introduction to Deep Learning Deployment Toolkit](https://docs.openvinotoolkit.org/latest/_docs_IE_DG_Introduction.html)
|
||||
* [Inference Engine Developer Guide](https://docs.openvinotoolkit.org/latest/_docs_IE_DG_Deep_Learning_Inference_Engine_DevGuide.html)
|
||||
* [Model Optimizer Developer Guide](https://docs.openvinotoolkit.org/latest/_docs_MO_DG_Deep_Learning_Model_Optimizer_DevGuide.html)
|
||||
|
||||
|
||||
## How to Contribute
|
||||
We welcome community contributions to the Deep Learning Deployment Toolkit repository. If you have an idea how to improve the product, please share it with us doing the following steps:
|
||||
* Make sure you can build the product and run all tests and samples with your patch
|
||||
* In case of a larger feature, provide a relevant unit tests and sample
|
||||
* Submit a pull request at https://github.com/opencv/dldt/pulls
|
||||
|
||||
We will review your contribution and, if any additional fixes or modifications are necessary, may give some feedback to guide you. When accepted, your pull request will be merged into GitHub* repositories.
|
||||
|
||||
Deep Learning Deployment Toolkit is licensed under Apache License, Version 2.0. By contributing to the project, you agree to the license and copyright terms therein and release your contribution under these terms.
|
||||
See [CONTRIBUTING](./CONTRIBUTING.md) for details. Thank you!
|
||||
|
||||
## Support
|
||||
Please report questions, issues and suggestions using:
|
||||
* [\#dldt](https://stackoverflow.com/search?q=%23dldt) tag on StackOverflow*
|
||||
* [GitHub* Issues](https://github.com/opencv/dldt/issues)
|
||||
|
||||
* The `openvino` [tag on StackOverflow]\*
|
||||
* [GitHub* Issues](https://github.com/openvinotoolkit/openvino/issues)
|
||||
* [Forum](https://software.intel.com/en-us/forums/computer-vision)
|
||||
|
||||
---
|
||||
\* Other names and brands may be claimed as the property of others.
|
||||
\* Other names and brands may be claimed as the property of others.
|
||||
|
||||
[Open Model Zoo]:https://github.com/opencv/open_model_zoo
|
||||
[Inference Engine]:https://software.intel.com/en-us/articles/OpenVINO-InferEngine
|
||||
[Model Optimizer]:https://software.intel.com/en-us/articles/OpenVINO-ModelOptimizer
|
||||
[tag on StackOverflow]:https://stackoverflow.com/search?q=%23openvino
|
||||
|
||||
345
azure-pipelines.yml
Normal file
345
azure-pipelines.yml
Normal file
@@ -0,0 +1,345 @@
|
||||
jobs:
|
||||
- job: Lin
|
||||
# About 150% of total time
|
||||
timeoutInMinutes: 75
|
||||
pool:
|
||||
#vmImage: 'ubuntu-18.04'
|
||||
name: LIN_VMSS_VENV_F8S_WU2
|
||||
variables:
|
||||
BUILD_TYPE: Release
|
||||
BIN_DIR: ../bin/intel64/$(BUILD_TYPE)
|
||||
steps:
|
||||
- script: |
|
||||
whoami
|
||||
uname -a
|
||||
which python3
|
||||
gcc --version
|
||||
lsb_release
|
||||
env
|
||||
cat /proc/cpuinfo
|
||||
cat /proc/meminfo
|
||||
vmstat -s
|
||||
df
|
||||
displayName: 'System properties'
|
||||
- script: |
|
||||
sudo apt --assume-yes install libusb-1.0-0-dev
|
||||
python3 -m pip install -r ./inference-engine/ie_bridges/python/requirements.txt
|
||||
# For running Python API tests
|
||||
python3 -m pip install -r ./inference-engine/ie_bridges/python/src/requirements-dev.txt
|
||||
displayName: 'Install dependencies'
|
||||
- script: |
|
||||
wget https://github.com/ninja-build/ninja/releases/download/v1.10.0/ninja-linux.zip
|
||||
unzip ninja-linux.zip
|
||||
sudo cp -v ninja /usr/local/bin/
|
||||
displayName: 'Install Ninja'
|
||||
- script: git submodule update --init --recursive --jobs 8
|
||||
displayName: 'Clone submodules'
|
||||
- script: |
|
||||
mkdir dldt-build
|
||||
cd dldt-build
|
||||
displayName: 'Create build directory'
|
||||
- task: CMake@1
|
||||
inputs:
|
||||
workingDirectory: dldt-build
|
||||
# CMake must get Python 3.x version by default
|
||||
cmakeArgs: .. -GNinja -DVERBOSE_BUILD=ON -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DENABLE_PYTHON=ON -DPYTHON_EXECUTABLE=/usr/bin/python3.6 -DENABLE_TESTS=ON
|
||||
- script: ninja
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'Build Lin'
|
||||
- script: ls -alR ../bin/
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'List files'
|
||||
- script: $(BIN_DIR)/unit-test --gtest_print_time=1 --gtest_filter=-backend_api.config_unsupported:*GPU*:*CPU*:constant.shared_data
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'nGraph UT'
|
||||
continueOnError: false
|
||||
- script: $(BIN_DIR)/InferenceEngineUnitTests
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'IE UT old'
|
||||
continueOnError: false
|
||||
- script: $(BIN_DIR)/ieUnitTests
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'IE UT'
|
||||
continueOnError: false
|
||||
- script: $(BIN_DIR)/cpuUnitTests
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'CPU UT'
|
||||
continueOnError: false
|
||||
- script: $(BIN_DIR)/gnaUnitTests
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'GNA UT'
|
||||
continueOnError: false
|
||||
- script: $(BIN_DIR)/vpuUnitTests
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'VPU UT'
|
||||
continueOnError: false
|
||||
- script: $(BIN_DIR)/ieFuncTests
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'IE FuncTests'
|
||||
continueOnError: false
|
||||
- script: $(BIN_DIR)/cpuFuncTests
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'CPU FuncTests'
|
||||
continueOnError: false
|
||||
- script: $(BIN_DIR)/MklDnnBehaviorTests
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'MklDnnBehaviorTests'
|
||||
continueOnError: false
|
||||
enabled: false
|
||||
- script: git clone https://github.com/openvinotoolkit/testdata.git
|
||||
displayName: 'Clone testdata'
|
||||
enabled: false
|
||||
- script: |
|
||||
export DATA_PATH=`pwd`/../testdata
|
||||
export MODELS_PATH=`pwd`/../testdata
|
||||
$(BIN_DIR)/MklDnnFunctionalTests --gtest_filter=*smoke*:-smoke_MobileNet/ModelTransformationsTest.LPT/mobilenet_v2_tf_depthwise_batch1_inPluginDisabled_inTestDisabled_asymmetric*
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'MklDnnFunctionalTests'
|
||||
continueOnError: false
|
||||
enabled: false
|
||||
- script: |
|
||||
export DATA_PATH=`pwd`/../testdata
|
||||
export MODELS_PATH=`pwd`/../testdata
|
||||
$(BIN_DIR)/InferenceEngineCAPITests
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'IE CAPITests'
|
||||
continueOnError: false
|
||||
enabled: false
|
||||
- script: |
|
||||
export DATA_PATH=`pwd`/../testdata
|
||||
export MODELS_PATH=`pwd`/../testdata
|
||||
export LD_LIBRARY_PATH=`pwd`/$(BIN_DIR)/lib
|
||||
export PYTHONPATH=`pwd`/$(BIN_DIR)/lib/python_api/python3.6
|
||||
env
|
||||
cd ../inference-engine/ie_bridges/python/tests
|
||||
pytest
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'Python API Tests'
|
||||
continueOnError: false
|
||||
enabled: false
|
||||
|
||||
- job: Mac
|
||||
# About 150% of total time
|
||||
timeoutInMinutes: 130
|
||||
pool:
|
||||
vmImage: 'macOS-10.15'
|
||||
variables:
|
||||
BUILD_TYPE: Release
|
||||
BIN_DIR: ../bin/intel64/$(BUILD_TYPE)
|
||||
steps:
|
||||
- task: UsePythonVersion@0
|
||||
inputs:
|
||||
versionSpec: '3.7'
|
||||
- script: |
|
||||
whoami
|
||||
uname -a
|
||||
which python3
|
||||
gcc --version
|
||||
xcrun --sdk macosx --show-sdk-version
|
||||
env
|
||||
sysctl -a
|
||||
displayName: 'System properties'
|
||||
- script: |
|
||||
brew install cython
|
||||
brew install automake
|
||||
displayName: 'Install dependencies'
|
||||
- script: brew install ninja
|
||||
displayName: 'Install Ninja'
|
||||
- script: git submodule update --init --recursive --jobs 8
|
||||
displayName: 'Clone submodules'
|
||||
- script: |
|
||||
mkdir dldt-build
|
||||
cd dldt-build
|
||||
displayName: 'Create build directory'
|
||||
- script: |
|
||||
export PATH="/usr/local/opt/cython/bin:$PATH"
|
||||
export CC=gcc
|
||||
export CXX=g++
|
||||
# Disable errors with Ninja
|
||||
#export CXXFLAGS="-Wno-error=unused-command-line-argument"
|
||||
#export CFLAGS="-Wno-error=unused-command-line-argument"
|
||||
cmake .. -DVERBOSE_BUILD=ON -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DENABLE_PYTHON=ON -DENABLE_TESTS=ON
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'CMake'
|
||||
- script: make -j3
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'Build Mac'
|
||||
- script: ls -alR ../bin/
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'List files'
|
||||
- script: $(BIN_DIR)/unit-test --gtest_print_time=1 --gtest_filter=-backend_api.config_unsupported:*GPU*:*CPU*:constant.shared_data
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'nGraph UT'
|
||||
continueOnError: false
|
||||
- script: $(BIN_DIR)/InferenceEngineUnitTests --gtest_filter=-*MKLDNNGraph*
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'IE UT old'
|
||||
continueOnError: false
|
||||
- script: $(BIN_DIR)/ieUnitTests
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'IE UT'
|
||||
continueOnError: false
|
||||
- script: $(BIN_DIR)/cpuUnitTests
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'CPU UT'
|
||||
continueOnError: false
|
||||
- script: $(BIN_DIR)/vpuUnitTests
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'VPU UT'
|
||||
continueOnError: false
|
||||
- script: $(BIN_DIR)/ieFuncTests
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'IE FuncTests'
|
||||
continueOnError: false
|
||||
- script: $(BIN_DIR)/cpuFuncTests
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'CPU FuncTests'
|
||||
continueOnError: false
|
||||
- script: $(BIN_DIR)/MklDnnBehaviorTests
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'MklDnnBehaviorTests'
|
||||
continueOnError: false
|
||||
enabled: false
|
||||
- script: git clone https://github.com/openvinotoolkit/testdata.git
|
||||
displayName: 'Clone testdata'
|
||||
enabled: false
|
||||
- script: |
|
||||
export DATA_PATH=`pwd`/../testdata
|
||||
export MODELS_PATH=`pwd`/../testdata
|
||||
$(BIN_DIR)/MklDnnFunctionalTests --gtest_filter=*smoke*:-smoke_MobileNet/ModelTransformationsTest.LPT/mobilenet_v2_tf_depthwise_batch1_inPluginDisabled_inTestDisabled_asymmetric*
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'MklDnnFunctionalTests'
|
||||
continueOnError: false
|
||||
enabled: false
|
||||
- script: |
|
||||
export DATA_PATH=`pwd`/../testdata
|
||||
export MODELS_PATH=`pwd`/../testdata
|
||||
$(BIN_DIR)/InferenceEngineCAPITests
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'IE CAPITests'
|
||||
continueOnError: false
|
||||
enabled: false
|
||||
|
||||
- job: Win
|
||||
# About 150% of total time
|
||||
timeoutInMinutes: 120
|
||||
pool:
|
||||
#vmImage: 'vs2017-win2016'
|
||||
name: WIN_VMSS_VENV_F8S_WU2
|
||||
variables:
|
||||
BUILD_TYPE: Release
|
||||
BUILD_DIR: D:\dldt-build
|
||||
BIN_DIR: ..\bin\intel64
|
||||
MSVS_VARS_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat
|
||||
MSVC_COMPILER_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.24.28314\bin\Hostx64\x64\cl.exe
|
||||
steps:
|
||||
- script: |
|
||||
where python3
|
||||
wmic computersystem get TotalPhysicalMemory
|
||||
wmic cpu list
|
||||
wmic logicaldisk get description,name
|
||||
wmic VOLUME list
|
||||
set
|
||||
displayName: 'System properties'
|
||||
- script: |
|
||||
certutil -urlcache -split -f https://github.com/ninja-build/ninja/releases/download/v1.10.0/ninja-win.zip ninja-win.zip
|
||||
powershell -command "Expand-Archive -Force ninja-win.zip"
|
||||
displayName: Install Ninja
|
||||
- script: git submodule update --init --recursive --jobs 8
|
||||
displayName: 'Clone submodules'
|
||||
- script: |
|
||||
rd /Q /S $(BUILD_DIR)
|
||||
mkdir $(BUILD_DIR)\bin
|
||||
rd /Q /S dldt-build
|
||||
mkdir dldt-build
|
||||
displayName: 'Create build directory'
|
||||
- script: |
|
||||
set PATH=$(Build.Repository.LocalPath)\ninja-win;%PATH%
|
||||
call "$(MSVS_VARS_PATH)" && cmake -GNinja -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DENABLE_TESTS=ON -DCMAKE_C_COMPILER:PATH="$(MSVC_COMPILER_PATH)" -DCMAKE_CXX_COMPILER:PATH="$(MSVC_COMPILER_PATH)" $(Build.Repository.LocalPath)
|
||||
workingDirectory: $(BUILD_DIR)
|
||||
displayName: 'CMake'
|
||||
- script: |
|
||||
set PATH=$(Build.Repository.LocalPath)\ninja-win;%PATH%
|
||||
call "$(MSVS_VARS_PATH)" && ninja
|
||||
workingDirectory: $(BUILD_DIR)
|
||||
displayName: 'Build Win'
|
||||
- script: dir ..\bin\ /s /b
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'List files'
|
||||
- script: |
|
||||
set PATH=$(Build.Repository.LocalPath)\inference-engine\temp\tbb\bin;%PATH%
|
||||
$(BIN_DIR)\unit-test --gtest_print_time=1 --gtest_filter=-backend_api.config_unsupported:*GPU*:*CPU*:constant.shared_data
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'nGraph UT'
|
||||
continueOnError: false
|
||||
- script: |
|
||||
set PATH=$(Build.Repository.LocalPath)\inference-engine\temp\tbb\bin;%PATH%
|
||||
$(BIN_DIR)\InferenceEngineUnitTests
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'IE UT old'
|
||||
continueOnError: false
|
||||
- script: |
|
||||
set PATH=$(Build.Repository.LocalPath)\inference-engine\temp\tbb\bin;%PATH%
|
||||
$(BIN_DIR)\ieUnitTests
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'IE UT'
|
||||
continueOnError: false
|
||||
- script: |
|
||||
set PATH=$(Build.Repository.LocalPath)\inference-engine\temp\tbb\bin;%PATH%
|
||||
$(BIN_DIR)\cpuUnitTests
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'CPU UT'
|
||||
continueOnError: false
|
||||
- script: |
|
||||
set PATH=$(Build.Repository.LocalPath)\inference-engine\temp\tbb\bin;%PATH%
|
||||
$(BIN_DIR)\gnaUnitTests
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'GNA UT'
|
||||
continueOnError: false
|
||||
- script: |
|
||||
set PATH=$(Build.Repository.LocalPath)\inference-engine\temp\tbb\bin;%PATH%
|
||||
$(BIN_DIR)\vpuUnitTests
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'VPU UT'
|
||||
continueOnError: false
|
||||
- script: |
|
||||
set PATH=$(Build.Repository.LocalPath)\inference-engine\temp\tbb\bin;%PATH%
|
||||
$(BIN_DIR)\ieFuncTests
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'IE FuncTests'
|
||||
continueOnError: false
|
||||
- script: |
|
||||
set PATH=$(Build.Repository.LocalPath)\inference-engine\temp\tbb\bin;%PATH%
|
||||
$(BIN_DIR)\cpuFuncTests
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'CPU FuncTests'
|
||||
continueOnError: false
|
||||
- script: |
|
||||
set PATH=$(Build.Repository.LocalPath)\inference-engine\temp\tbb\bin;%PATH%
|
||||
$(BIN_DIR)\MklDnnBehaviorTests
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'MklDnnBehaviorTests'
|
||||
continueOnError: false
|
||||
enabled: false
|
||||
- script: git clone https://github.com/openvinotoolkit/testdata.git
|
||||
workingDirectory: $(BUILD_DIR)
|
||||
displayName: 'Clone testdata'
|
||||
enabled: false
|
||||
- script: |
|
||||
set PATH=$(Build.Repository.LocalPath)\inference-engine\temp\tbb\bin;$(Build.Repository.LocalPath)\inference-engine\temp\opencv_4.3.0\opencv\bin;%PATH%
|
||||
set DATA_PATH=$(BUILD_DIR)\testdata
|
||||
set MODELS_PATH=$(BUILD_DIR)\testdata
|
||||
$(BIN_DIR)\MklDnnFunctionalTests --gtest_filter=*smoke*:-smoke_MobileNet/ModelTransformationsTest.LPT/mobilenet_v2_tf_depthwise_batch1_inPluginDisabled_inTestDisabled_asymmetric*
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'MklDnnFunctionalTests'
|
||||
continueOnError: false
|
||||
enabled: false
|
||||
- script: |
|
||||
set PATH=$(Build.Repository.LocalPath)\inference-engine\temp\tbb\bin;$(Build.Repository.LocalPath)\inference-engine\temp\opencv_4.3.0\opencv\bin;%PATH%
|
||||
set DATA_PATH=$(BUILD_DIR)\testdata
|
||||
set MODELS_PATH=$(BUILD_DIR)\testdata
|
||||
$(BIN_DIR)\InferenceEngineCAPITests
|
||||
workingDirectory: dldt-build
|
||||
displayName: 'IE CAPITests'
|
||||
continueOnError: false
|
||||
enabled: false
|
||||
704
build-instruction.md
Normal file
704
build-instruction.md
Normal file
@@ -0,0 +1,704 @@
|
||||
# Build OpenVINO™ Inference Engine
|
||||
|
||||
## Contents
|
||||
|
||||
- [Introduction](#introduction)
|
||||
- [Build on Linux\* Systems](#build-on-linux-systems)
|
||||
- [Software Requirements](#software-requirements)
|
||||
- [Build Steps](#build-steps)
|
||||
- [Additional Build Options](#additional-build-options)
|
||||
- [Build for Raspbian* Stretch OS](#build-for-raspbian-stretch-os)
|
||||
- [Hardware Requirements](#hardware-requirements)
|
||||
- [Native Compilation](#native-compilation)
|
||||
- [Cross Compilation Using Docker\*](#cross-compilation-using-docker)
|
||||
- [Additional Build Options](#additional-build-options-1)
|
||||
- [Build on Windows* Systems](#build-on-windows-systems)
|
||||
- [Software Requirements](#software-requirements-1)
|
||||
- [Build Steps](#build-steps-1)
|
||||
- [Additional Build Options](#additional-build-options-2)
|
||||
- [Building Inference Engine with Ninja* Build System](#building-inference-engine-with-ninja-build-system)
|
||||
- [Build on macOS\* Systems](#build-on-macos-systems)
|
||||
- [Software Requirements](#software-requirements-2)
|
||||
- [Build Steps](#build-steps-2)
|
||||
- [Additional Build Options](#additional-build-options-3)
|
||||
- [Build on Android\* Systems](#build-on-android-systems)
|
||||
- [Software Requirements](#software-requirements-3)
|
||||
- [Build Steps](#build-steps-3)
|
||||
- [Use Custom OpenCV Builds for Inference Engine](#use-custom-opencv-builds-for-inference-engine)
|
||||
- [Add Inference Engine to Your Project](#add-inference-engine-to-your-project)
|
||||
- [(Optional) Additional Installation Steps for the Intel® Movidius™ Neural Compute Stick and Neural Compute Stick 2](#optional-additional-installation-steps-for-the-intel-movidius-neural-compute-stick-and-neural-compute-stick-2)
|
||||
- [For Linux, Raspbian Stretch* OS](#for-linux-raspbian-stretch-os)
|
||||
- [Next Steps](#next-steps)
|
||||
- [Additional Resources](#additional-resources)
|
||||
|
||||
## Introduction
|
||||
|
||||
The Inference Engine can infer models in different formats with various input
|
||||
and output formats.
|
||||
|
||||
The open source version of Inference Engine includes the following plugins:
|
||||
|
||||
| PLUGIN | DEVICE TYPES |
|
||||
| ---------------------| -------------|
|
||||
| CPU plugin | Intel® Xeon® with Intel® AVX2 and AVX512, Intel® Core™ Processors with Intel® AVX2, Intel® Atom® Processors with Intel® SSE |
|
||||
| GPU plugin | Intel® Processor Graphics, including Intel® HD Graphics and Intel® Iris® Graphics |
|
||||
| GNA plugin | Intel® Speech Enabling Developer Kit, Amazon Alexa\* Premium Far-Field Developer Kit, Intel® Pentium® Silver processor J5005, Intel® Celeron® processor J4005, Intel® Core™ i3-8121U processor |
|
||||
| MYRIAD plugin | Intel® Movidius™ Neural Compute Stick powered by the Intel® Movidius™ Myriad™ 2, Intel® Neural Compute Stick 2 powered by the Intel® Movidius™ Myriad™ X |
|
||||
| Heterogeneous plugin | Heterogeneous plugin enables computing for inference on one network on several Intel® devices. |
|
||||
|
||||
Inference Engine plugin for Intel® FPGA is distributed only in a binary form,
|
||||
as a part of [Intel® Distribution of OpenVINO™].
|
||||
|
||||
## Build on Linux\* Systems
|
||||
|
||||
The software was validated on:
|
||||
- Ubuntu\* 16.04 (64-bit) with default GCC\* 5.4.0
|
||||
- CentOS\* 7.4 (64-bit) with default GCC\* 4.8.5
|
||||
|
||||
### Software Requirements
|
||||
- [CMake]\* 3.11 or higher
|
||||
- GCC\* 4.8 or higher to build the Inference Engine
|
||||
- Python 2.7 or higher for Inference Engine Python API wrapper
|
||||
- (Optional) [Install Intel® Graphics Compute Runtime for OpenCL™ Driver package 20.13.16352].
|
||||
|
||||
### Build Steps
|
||||
1. Clone submodules:
|
||||
```sh
|
||||
cd openvino
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
2. Install build dependencies using the `install_dependencies.sh` script in the
|
||||
project root folder.
|
||||
```sh
|
||||
chmod +x install_dependencies.sh
|
||||
```
|
||||
```sh
|
||||
./install_dependencies.sh
|
||||
```
|
||||
3. By default, the build enables the Inference Engine GPU plugin to infer models
|
||||
on your Intel® Processor Graphics. This requires you to
|
||||
[Install Intel® Graphics Compute Runtime for OpenCL™ Driver package 20.13.16352]
|
||||
before running the build. If you don't want to use the GPU plugin, use the
|
||||
`-DENABLE_CLDNN=OFF` CMake build option and skip the installation of the
|
||||
Intel® Graphics Compute Runtime for OpenCL™ Driver.
|
||||
4. Create a build folder:
|
||||
```sh
|
||||
mkdir build && cd build
|
||||
```
|
||||
5. Inference Engine uses a CMake-based build system. In the created `build`
|
||||
directory, run `cmake` to fetch project dependencies and create Unix
|
||||
makefiles, then run `make` to build the project:
|
||||
```sh
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||
make --jobs=$(nproc --all)
|
||||
```
|
||||
|
||||
### Additional Build Options
|
||||
|
||||
You can use the following additional build options:
|
||||
|
||||
- The default build uses an internal JIT GEMM implementation.
|
||||
|
||||
- To switch to an OpenBLAS\* implementation, use the `GEMM=OPENBLAS` option with
|
||||
`BLAS_INCLUDE_DIRS` and `BLAS_LIBRARIES` CMake options to specify a path to the
|
||||
OpenBLAS headers and library. For example, the following options on CentOS\*:
|
||||
`-DGEMM=OPENBLAS -DBLAS_INCLUDE_DIRS=/usr/include/openblas -DBLAS_LIBRARIES=/usr/lib64/libopenblas.so.0`.
|
||||
|
||||
- To switch to the optimized MKL-ML\* GEMM implementation, use `-DGEMM=MKL`
|
||||
and `-DMKLROOT=<path_to_MKL>` CMake options to specify a path to unpacked
|
||||
MKL-ML with the `include` and `lib` folders. MKL-ML\* package can be downloaded
|
||||
from the Intel® [MKL-DNN repository].
|
||||
|
||||
- Threading Building Blocks (TBB) is used by default. To build the Inference
|
||||
Engine with OpenMP\* threading, set the `-DTHREADING=OMP` option.
|
||||
|
||||
- Required versions of TBB and OpenCV packages are downloaded automatically by
|
||||
the CMake-based script. If you want to use the automatically downloaded
|
||||
packages but you already have installed TBB or OpenCV packages configured in
|
||||
your environment, you may need to clean the `TBBROOT` and `OpenCV_DIR`
|
||||
environment variables before running the `cmake` command, otherwise they
|
||||
will not be downloaded and the build may fail if incompatible versions were
|
||||
installed.
|
||||
|
||||
- If the CMake-based build script can not find and download the OpenCV package
|
||||
that is supported on your platform, or if you want to use a custom build of
|
||||
the OpenCV library, refer to the
|
||||
[Use Custom OpenCV Builds](#use-custom-opencv-builds-for-inference-engine)
|
||||
section for details.
|
||||
|
||||
- To build the Python API wrapper:
|
||||
1. Install all additional packages listed in the
|
||||
`/inference-engine/ie_bridges/python/requirements.txt` file:
|
||||
```sh
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
2. Use the `-DENABLE_PYTHON=ON` option. To specify an exact Python version, use the following
|
||||
options:
|
||||
```
|
||||
-DPYTHON_EXECUTABLE=`which python3.7` \
|
||||
-DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.7m.so \
|
||||
-DPYTHON_INCLUDE_DIR=/usr/include/python3.7
|
||||
```
|
||||
|
||||
- To switch the CPU and GPU plugins off/on, use the `cmake` options
|
||||
`-DENABLE_MKL_DNN=ON/OFF` and `-DENABLE_CLDNN=ON/OFF` respectively.
|
||||
|
||||
- nGraph-specific compilation options:
|
||||
`-DNGRAPH_ONNX_IMPORT_ENABLE=ON` enables the building of the nGraph ONNX importer.
|
||||
`-DNGRAPH_JSON_ENABLE=ON` enables nGraph JSON-based serialization.
|
||||
`-DNGRAPH_DEBUG_ENABLE=ON` enables additional debug prints.
|
||||
|
||||
## Build for Raspbian Stretch* OS
|
||||
|
||||
> **NOTE**: Only the MYRIAD plugin is supported.
|
||||
|
||||
### Hardware Requirements
|
||||
* Raspberry Pi\* 2 or 3 with Raspbian\* Stretch OS (32-bit). Check that it's CPU supports ARMv7 instruction set (`uname -m` command returns `armv7l`).
|
||||
|
||||
> **NOTE**: Despite the Raspberry Pi\* CPU is ARMv8, 32-bit OS detects ARMv7 CPU instruction set. The default `gcc` compiler applies ARMv6 architecture flag for compatibility with lower versions of boards. For more information, run the `gcc -Q --help=target` command and refer to the description of the `-march=` option.
|
||||
|
||||
You can compile the Inference Engine for Raspberry Pi\* in one of the two ways:
|
||||
* [Native Compilation](#native-compilation), which is the simplest way, but time-consuming
|
||||
* [Cross Compilation Using Docker*](#cross-compilation-using-docker), which is the recommended way
|
||||
|
||||
### Native Compilation
|
||||
Native compilation of the Inference Engine is the most straightforward solution. However, it might take at least one hour to complete on Raspberry Pi\* 3.
|
||||
|
||||
1. Install dependencies:
|
||||
|
||||
```bash
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y git cmake libusb-1.0-0-dev
|
||||
```
|
||||
|
||||
2. Go to the cloned `openvino` repository:
|
||||
|
||||
```bash
|
||||
cd openvino
|
||||
```
|
||||
|
||||
3. Initialize submodules:
|
||||
|
||||
```bash
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
4. Create a build folder:
|
||||
|
||||
```bash
|
||||
mkdir build && cd build
|
||||
```
|
||||
|
||||
5. Build the Inference Engine:
|
||||
|
||||
```bash
|
||||
cmake -DCMAKE_BUILD_TYPE=Release \
|
||||
-DENABLE_SSE42=OFF \
|
||||
-DTHREADING=SEQ \
|
||||
-DENABLE_GNA=OFF .. && make
|
||||
```
|
||||
|
||||
### Cross Compilation Using Docker*
|
||||
|
||||
This compilation was tested on the following configuration:
|
||||
|
||||
* Host: Ubuntu\* 16.04 (64-bit, Intel® Core™ i7-6700K CPU @ 4.00GHz × 8)
|
||||
* Target: Raspbian\* Stretch (32-bit, ARMv7, Raspberry Pi\* 3)
|
||||
|
||||
1. Install Docker\*:
|
||||
|
||||
```bash
|
||||
sudo apt-get install -y docker.io
|
||||
```
|
||||
|
||||
2. Add a current user to `docker` group:
|
||||
|
||||
```bash
|
||||
sudo usermod -a -G docker $USER
|
||||
```
|
||||
|
||||
Log out and log in for this to take effect.
|
||||
|
||||
3. Create a directory named `ie_cross_armhf` and add a text file named `Dockerfile`
|
||||
with the following content:
|
||||
|
||||
```docker
|
||||
FROM debian:stretch
|
||||
|
||||
USER root
|
||||
|
||||
RUN dpkg --add-architecture armhf && \
|
||||
apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
build-essential \
|
||||
crossbuild-essential-armhf \
|
||||
git \
|
||||
wget \
|
||||
libusb-1.0-0-dev:armhf \
|
||||
libgtk-3-dev:armhf \
|
||||
libavcodec-dev:armhf \
|
||||
libavformat-dev:armhf \
|
||||
libswscale-dev:armhf \
|
||||
libgstreamer1.0-dev:armhf \
|
||||
libgstreamer-plugins-base1.0-dev:armhf \
|
||||
libpython3-dev:armhf \
|
||||
python3-pip
|
||||
|
||||
RUN wget https://www.cmake.org/files/v3.14/cmake-3.14.3.tar.gz && \
|
||||
tar xf cmake-3.14.3.tar.gz && \
|
||||
(cd cmake-3.14.3 && ./bootstrap --parallel=$(nproc --all) && make --jobs=$(nproc --all) && make install) && \
|
||||
rm -rf cmake-3.14.3 cmake-3.14.3.tar.gz
|
||||
```
|
||||
|
||||
It uses the Debian\* Stretch (Debian 9) OS for compilation because it is a base of the Raspbian\* Stretch.
|
||||
|
||||
4. Build a Docker\* image:
|
||||
|
||||
```bash
|
||||
docker image build -t ie_cross_armhf ie_cross_armhf
|
||||
```
|
||||
|
||||
5. Run Docker\* container with mounted source code folder from host:
|
||||
|
||||
```bash
|
||||
docker run -it -v /absolute/path/to/openvino:/openvino ie_cross_armhf /bin/bash
|
||||
```
|
||||
|
||||
6. While in the container:
|
||||
|
||||
1. Go to the cloned `openvino` repository:
|
||||
|
||||
```bash
|
||||
cd openvino
|
||||
```
|
||||
|
||||
2. Create a build folder:
|
||||
|
||||
```bash
|
||||
mkdir build && cd build
|
||||
```
|
||||
|
||||
3. Build the Inference Engine:
|
||||
|
||||
```bash
|
||||
cmake -DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_TOOLCHAIN_FILE="../cmake/arm.toolchain.cmake" \
|
||||
-DTHREADS_PTHREAD_ARG="-pthread" \
|
||||
-DENABLE_SSE42=OFF \
|
||||
-DTHREADING=SEQ \
|
||||
-DENABLE_GNA=OFF .. && make --jobs=$(nproc --all)
|
||||
```
|
||||
|
||||
7. Press **Ctrl+D** to exit from Docker. You can find the resulting binaries
|
||||
in the `openvino/bin/armv7l/` directory and the OpenCV*
|
||||
installation in the `openvino/inference-engine/temp`.
|
||||
|
||||
>**NOTE**: Native applications that link to cross-compiled Inference Engine
|
||||
library require an extra compilation flag `-march=armv7-a`.
|
||||
|
||||
### Additional Build Options
|
||||
|
||||
You can use the following additional build options:
|
||||
|
||||
- Required versions of OpenCV packages are downloaded automatically by the
|
||||
CMake-based script. If you want to use the automatically downloaded packages
|
||||
but you already have installed OpenCV packages configured in your environment,
|
||||
you may need to clean the `OpenCV_DIR` environment variable before running
|
||||
the `cmake` command; otherwise they won't be downloaded and the build may
|
||||
fail if incompatible versions were installed.
|
||||
|
||||
- If the CMake-based build script cannot find and download the OpenCV package
|
||||
that is supported on your platform, or if you want to use a custom build of
|
||||
the OpenCV library, see: [Use Custom OpenCV Builds](#use-custom-opencv-builds-for-inference-engine)
|
||||
for details.
|
||||
|
||||
- To build Python API wrapper, install `libpython3-dev:armhf` and `python3-pip`
|
||||
packages using `apt-get`; then install `numpy` and `cython` python modules
|
||||
via `pip3`, adding the following options:
|
||||
```sh
|
||||
-DENABLE_PYTHON=ON \
|
||||
-DPYTHON_EXECUTABLE=/usr/bin/python3.5 \
|
||||
-DPYTHON_LIBRARY=/usr/lib/arm-linux-gnueabihf/libpython3.5m.so \
|
||||
-DPYTHON_INCLUDE_DIR=/usr/include/python3.5
|
||||
```
|
||||
|
||||
- nGraph-specific compilation options:
|
||||
`-DNGRAPH_ONNX_IMPORT_ENABLE=ON` enables the building of the nGraph ONNX importer.
|
||||
`-DNGRAPH_JSON_ENABLE=ON` enables nGraph JSON-based serialization.
|
||||
`-DNGRAPH_DEBUG_ENABLE=ON` enables additional debug prints.
|
||||
|
||||
## Build on Windows* Systems
|
||||
|
||||
The software was validated on:
|
||||
- Microsoft\* Windows\* 10 (64-bit) with Visual Studio 2017 and Intel® C++
|
||||
Compiler 2018 Update 3
|
||||
|
||||
### Software Requirements
|
||||
- [CMake]\*3.11 or higher
|
||||
- Microsoft\* Visual Studio 2017, 2019 or [Intel® C++ Compiler] 18.0
|
||||
- (Optional) Intel® Graphics Driver for Windows* (26.20) [driver package].
|
||||
- Python 3.4 or higher for Inference Engine Python API wrapper
|
||||
|
||||
### Build Steps
|
||||
|
||||
1. Clone submodules:
|
||||
```sh
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
2. By default, the build enables the Inference Engine GPU plugin to infer models
|
||||
on your Intel® Processor Graphics. This requires you to [download and install
|
||||
the Intel® Graphics Driver for Windows (26.20) [driver package] before
|
||||
running the build. If you don't want to use the GPU plugin, use the
|
||||
`-DENABLE_CLDNN=OFF` CMake build option and skip the installation of the
|
||||
Intel® Graphics Driver.
|
||||
3. Create build directory:
|
||||
```sh
|
||||
mkdir build
|
||||
```
|
||||
4. In the `build` directory, run `cmake` to fetch project dependencies and
|
||||
generate a Visual Studio solution.
|
||||
|
||||
For Microsoft\* Visual Studio 2017:
|
||||
```sh
|
||||
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release ..
|
||||
```
|
||||
|
||||
For Microsoft\* Visual Studio 2019:
|
||||
```sh
|
||||
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release ..
|
||||
```
|
||||
|
||||
For Intel® C++ Compiler 18:
|
||||
```sh
|
||||
cmake -G "Visual Studio 15 2017 Win64" -T "Intel C++ Compiler 18.0" ^
|
||||
-DCMAKE_BUILD_TYPE=Release ^
|
||||
-DICCLIB="C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018\windows\compiler\lib" ..
|
||||
```
|
||||
|
||||
5. Build generated solution in Visual Studio or run
|
||||
`cmake --build . --config Release` to build from the command line.
|
||||
|
||||
6. Before running the samples, add paths to the TBB and OpenCV binaries used for
|
||||
the build to the `%PATH%` environment variable. By default, TBB binaries are
|
||||
downloaded by the CMake-based script to the `<openvino_repo>/inference-engine/temp/tbb/bin`
|
||||
folder, OpenCV binaries to the `<openvino_repo>/inference-engine/temp/opencv_4.3.0/opencv/bin`
|
||||
folder.
|
||||
|
||||
### Additional Build Options
|
||||
|
||||
- Internal JIT GEMM implementation is used by default.
|
||||
|
||||
- To switch to OpenBLAS GEMM implementation, use the `-DGEMM=OPENBLAS` CMake
|
||||
option and specify path to OpenBLAS using the `-DBLAS_INCLUDE_DIRS=<OPENBLAS_DIR>\include`
|
||||
and `-DBLAS_LIBRARIES=<OPENBLAS_DIR>\lib\libopenblas.dll.a` options. Download
|
||||
a prebuilt OpenBLAS\* package via the [OpenBLAS] link. mingw64* runtime
|
||||
dependencies can be downloaded via the [mingw64\* runtime dependencies] link.
|
||||
|
||||
- To switch to the optimized MKL-ML\* GEMM implementation, use the
|
||||
`-DGEMM=MKL` and `-DMKLROOT=<path_to_MKL>` CMake options to specify a path to
|
||||
unpacked MKL-ML with the `include` and `lib` folders. MKL-ML\* package can be
|
||||
downloaded from the Intel® [MKL-DNN repository for Windows].
|
||||
|
||||
- Threading Building Blocks (TBB) is used by default. To build the Inference
|
||||
Engine with OpenMP* threading, set the `-DTHREADING=OMP` option.
|
||||
|
||||
- Required versions of TBB and OpenCV packages are downloaded automatically by
|
||||
the CMake-based script. If you want to use the automatically-downloaded
|
||||
packages but you already have installed TBB or OpenCV packages configured in
|
||||
your environment, you may need to clean the `TBBROOT` and `OpenCV_DIR`
|
||||
environment variables before running the `cmake` command; otherwise they won't
|
||||
be downloaded and the build may fail if incompatible versions were installed.
|
||||
|
||||
- If the CMake-based build script can not find and download the OpenCV package
|
||||
that is supported on your platform, or if you want to use a custom build of
|
||||
the OpenCV library, refer to the [Use Custom OpenCV Builds](#use-custom-opencv-builds-for-inference-engine)
|
||||
section for details.
|
||||
|
||||
- To switch off/on the CPU and GPU plugins, use the `cmake` options
|
||||
`-DENABLE_MKL_DNN=ON/OFF` and `-DENABLE_CLDNN=ON/OFF` respectively.
|
||||
|
||||
- To build the Python API wrapper, use the `-DENABLE_PYTHON=ON` option. To
|
||||
specify an exact Python version, use the following options:
|
||||
```sh
|
||||
-DPYTHON_EXECUTABLE="C:\Program Files\Python37\python.exe" ^
|
||||
-DPYTHON_LIBRARY="C:\Program Files\Python37\libs\python37.lib" ^
|
||||
-DPYTHON_INCLUDE_DIR="C:\Program Files\Python37\include"
|
||||
```
|
||||
|
||||
- nGraph-specific compilation options:
|
||||
`-DNGRAPH_ONNX_IMPORT_ENABLE=ON` enables the building of the nGraph ONNX importer.
|
||||
`-DNGRAPH_JSON_ENABLE=ON` enables nGraph JSON-based serialization.
|
||||
`-DNGRAPH_DEBUG_ENABLE=ON` enables additional debug prints.
|
||||
|
||||
### Building Inference Engine with Ninja* Build System
|
||||
|
||||
```sh
|
||||
call "C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018\windows\bin\ipsxe-comp-vars.bat" intel64 vs2017
|
||||
set CXX=icl
|
||||
set CC=icl
|
||||
:: clean TBBROOT value set by ipsxe-comp-vars.bat, required TBB package will be downloaded by openvino cmake script
|
||||
set TBBROOT=
|
||||
cmake -G Ninja -Wno-dev -DCMAKE_BUILD_TYPE=Release ..
|
||||
cmake --build . --config Release
|
||||
```
|
||||
|
||||
## Build on macOS* Systems
|
||||
|
||||
> **NOTE**: The current version of the OpenVINO™ toolkit for macOS* supports
|
||||
inference on Intel CPUs only.
|
||||
|
||||
The software was validated on:
|
||||
- macOS\* 10.14, 64-bit
|
||||
|
||||
### Software Requirements
|
||||
|
||||
- [CMake]\* 3.11 or higher
|
||||
- Clang\* compiler from Xcode\* 10.1 or higher
|
||||
- Python\* 3.4 or higher for the Inference Engine Python API wrapper
|
||||
|
||||
### Build Steps
|
||||
|
||||
1. Clone submodules:
|
||||
```sh
|
||||
cd openvino
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
2. Install build dependencies using the `install_dependencies.sh` script in the
|
||||
project root folder:
|
||||
```sh
|
||||
chmod +x install_dependencies.sh
|
||||
```
|
||||
```sh
|
||||
./install_dependencies.sh
|
||||
```
|
||||
3. Create a build folder:
|
||||
```sh
|
||||
mkdir build
|
||||
```
|
||||
4. Inference Engine uses a CMake-based build system. In the created `build`
|
||||
directory, run `cmake` to fetch project dependencies and create Unix makefiles,
|
||||
then run `make` to build the project:
|
||||
```sh
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||
make --jobs=$(nproc --all)
|
||||
```
|
||||
### Additional Build Options
|
||||
|
||||
You can use the following additional build options:
|
||||
|
||||
- Internal JIT GEMM implementation is used by default.
|
||||
|
||||
- To switch to the optimized MKL-ML\* GEMM implementation, use `-DGEMM=MKL` and
|
||||
`-DMKLROOT=<path_to_MKL>` cmake options to specify a path to unpacked MKL-ML
|
||||
with the `include` and `lib` folders. MKL-ML\* [package for Mac] can be downloaded
|
||||
[here](https://github.com/intel/mkl-dnn/releases/download/v0.19/mklml_mac_2019.0.5.20190502.tgz)
|
||||
|
||||
- Threading Building Blocks (TBB) is used by default. To build the Inference
|
||||
Engine with OpenMP* threading, set the `-DTHREADING=OMP` option.
|
||||
|
||||
- Required versions of TBB and OpenCV packages are downloaded automatically by
|
||||
the CMake-based script. If you want to use the automatically downloaded
|
||||
packages but you already have installed TBB or OpenCV packages configured in
|
||||
your environment, you may need to clean the `TBBROOT` and `OpenCV_DIR`
|
||||
environment variables before running the `cmake` command, otherwise they won't
|
||||
be downloaded and the build may fail if incompatible versions were installed.
|
||||
|
||||
- If the CMake-based build script can not find and download the OpenCV package
|
||||
that is supported on your platform, or if you want to use a custom build of
|
||||
the OpenCV library, refer to the
|
||||
[Use Custom OpenCV Builds](#use-custom-opencv-builds-for-inference-engine)
|
||||
section for details.
|
||||
|
||||
- To build the Python API wrapper, use the `-DENABLE_PYTHON=ON` option. To
|
||||
specify an exact Python version, use the following options:
|
||||
```sh
|
||||
-DPYTHON_EXECUTABLE=/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 \
|
||||
-DPYTHON_LIBRARY=/Library/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7m.dylib \
|
||||
-DPYTHON_INCLUDE_DIR=/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m
|
||||
```
|
||||
|
||||
- nGraph-specific compilation options:
|
||||
`-DNGRAPH_ONNX_IMPORT_ENABLE=ON` enables the building of the nGraph ONNX importer.
|
||||
`-DNGRAPH_JSON_ENABLE=ON` enables nGraph JSON-based serialization.
|
||||
`-DNGRAPH_DEBUG_ENABLE=ON` enables additional debug prints.
|
||||
|
||||
## Build on Android* Systems
|
||||
|
||||
This section describes how to build Inference Engine for Android x86 (64-bit) operating systems.
|
||||
|
||||
### Software Requirements
|
||||
|
||||
- [CMake]\* 3.11 or higher
|
||||
- Android NDK (this guide has been validated with r20 release)
|
||||
|
||||
### Build Steps
|
||||
|
||||
1. Download and unpack Android NDK: https://developer.android.com/ndk/downloads. Let's assume that `~/Downloads` is used as a working folder.
|
||||
```sh
|
||||
cd ~/Downloads
|
||||
wget https://dl.google.com/android/repository/android-ndk-r20-linux-x86_64.zip
|
||||
|
||||
unzip android-ndk-r20-linux-x86_64.zip
|
||||
mv android-ndk-r20 android-ndk
|
||||
```
|
||||
|
||||
2. Clone submodules
|
||||
```sh
|
||||
cd openvino
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
3. Create a build folder:
|
||||
```sh
|
||||
mkdir build
|
||||
```
|
||||
|
||||
4. Change working directory to `build` and run `cmake` to create makefiles. Then run `make`.
|
||||
```sh
|
||||
cd build
|
||||
|
||||
cmake .. \
|
||||
-DCMAKE_TOOLCHAIN_FILE=~/Downloads/android-ndk/build/cmake/android.toolchain.cmake \
|
||||
-DANDROID_ABI=x86_64 \
|
||||
-DANDROID_PLATFORM=21 \
|
||||
-DANDROID_STL=c++_shared \
|
||||
-DENABLE_OPENCV=OFF
|
||||
|
||||
make --jobs=$(nproc --all)
|
||||
```
|
||||
|
||||
* `ANDROID_ABI` specifies target architecture (`x86_64`)
|
||||
* `ANDROID_PLATFORM` - Android API version
|
||||
* `ANDROID_STL` specifies that shared C++ runtime is used. Copy `~/Downloads/android-ndk/sources/cxx-stl/llvm-libc++/libs/x86_64/libc++_shared.so` from Android NDK along with built binaries
|
||||
|
||||
|
||||
## Use Custom OpenCV Builds for Inference Engine
|
||||
|
||||
> **NOTE**: The recommended and tested version of OpenCV is 4.3. The minimum
|
||||
supported version is 3.4.0.
|
||||
|
||||
Required versions of OpenCV packages are downloaded automatically during the
|
||||
building Inference Engine library. If the build script can not find and download
|
||||
the OpenCV package that is supported on your platform, you can use one of the
|
||||
following options:
|
||||
|
||||
* Download the most suitable version from the list of available pre-build
|
||||
packages from [https://download.01.org/opencv/2020/openvinotoolkit] from the
|
||||
`<release_version>/inference_engine` directory.
|
||||
|
||||
* Use a system-provided OpenCV package (e.g with running the
|
||||
`apt install libopencv-dev` command). The following modules must be enabled:
|
||||
`imgcodecs`, `videoio`, `highgui`.
|
||||
|
||||
* Get the OpenCV package using a package manager: pip, conda, conan etc. The
|
||||
package must have the development components included (header files and CMake
|
||||
scripts).
|
||||
|
||||
* Build OpenCV from source using the [build instructions](https://docs.opencv.org/master/df/d65/tutorial_table_of_content_introduction.html) on the OpenCV site.
|
||||
|
||||
After you got the built OpenCV library, perform the following preparation steps
|
||||
before running the Inference Engine build:
|
||||
|
||||
1. Set the `OpenCV_DIR` environment variable to the directory where the
|
||||
`OpenCVConfig.cmake` file of you custom OpenCV build is located.
|
||||
2. Disable the package automatic downloading with using the `-DENABLE_OPENCV=OFF`
|
||||
option for CMake-based build script for Inference Engine.
|
||||
|
||||
## Add Inference Engine to Your Project
|
||||
|
||||
For CMake projects, set the `InferenceEngine_DIR` environment variable:
|
||||
|
||||
```sh
|
||||
export InferenceEngine_DIR=/path/to/openvino/build/
|
||||
```
|
||||
|
||||
Then you can find Inference Engine by `find_package`:
|
||||
|
||||
```cmake
|
||||
find_package(InferenceEngine)
|
||||
include_directories(${InferenceEngine_INCLUDE_DIRS})
|
||||
target_link_libraries(${PROJECT_NAME} ${InferenceEngine_LIBRARIES} dl)
|
||||
```
|
||||
|
||||
## (Optional) Additional Installation Steps for the Intel® Movidius™ Neural Compute Stick and Neural Compute Stick 2
|
||||
|
||||
> **NOTE**: These steps are only required if you want to perform inference on
|
||||
Intel® Movidius™ Neural Compute Stick or the Intel® Neural Compute Stick 2 using
|
||||
the Inference Engine MYRIAD Plugin. See also [Intel® Neural Compute Stick 2 Get Started].
|
||||
|
||||
### For Linux, Raspbian\* Stretch OS
|
||||
|
||||
1. Add the current Linux user to the `users` group; you will need to log out and
|
||||
log in for it to take effect:
|
||||
```sh
|
||||
sudo usermod -a -G users "$(whoami)"
|
||||
```
|
||||
|
||||
2. To perform inference on Intel® Movidius™ Neural Compute Stick and Intel®
|
||||
Neural Compute Stick 2, install the USB rules as follows:
|
||||
```sh
|
||||
cat <<EOF > 97-myriad-usbboot.rules
|
||||
SUBSYSTEM=="usb", ATTRS{idProduct}=="2150", ATTRS{idVendor}=="03e7", GROUP="users", MODE="0666", ENV{ID_MM_DEVICE_IGNORE}="1"
|
||||
SUBSYSTEM=="usb", ATTRS{idProduct}=="2485", ATTRS{idVendor}=="03e7", GROUP="users", MODE="0666", ENV{ID_MM_DEVICE_IGNORE}="1"
|
||||
SUBSYSTEM=="usb", ATTRS{idProduct}=="f63b", ATTRS{idVendor}=="03e7", GROUP="users", MODE="0666", ENV{ID_MM_DEVICE_IGNORE}="1"
|
||||
EOF
|
||||
```
|
||||
```sh
|
||||
sudo cp 97-myriad-usbboot.rules /etc/udev/rules.d/
|
||||
```
|
||||
```sh
|
||||
sudo udevadm control --reload-rules
|
||||
```
|
||||
```sh
|
||||
sudo udevadm trigger
|
||||
```
|
||||
```sh
|
||||
sudo ldconfig
|
||||
```
|
||||
```sh
|
||||
rm 97-myriad-usbboot.rules
|
||||
```
|
||||
|
||||
## Next Steps
|
||||
|
||||
Congratulations, you have built the Inference Engine. To get started with the
|
||||
OpenVINO™, proceed to the Get Started guides:
|
||||
|
||||
* [Get Started with Deep Learning Deployment Toolkit on Linux*](get-started-linux.md)
|
||||
|
||||
## Notice
|
||||
|
||||
To enable some additional nGraph features and use your custom nGraph library with the OpenVINO™ binary package,
|
||||
make sure the following:
|
||||
- nGraph library was built with the same version which is used in the Inference Engine.
|
||||
- nGraph library and the Inference Engine were built with the same compilers. Otherwise you might face application binary interface (ABI) problems.
|
||||
|
||||
To prepare your custom nGraph library for distribution, which includes collecting all headers, copy
|
||||
binaries, and so on, use the `install` CMake target.
|
||||
This target collects all dependencies, prepares the nGraph package and copies it to a separate directory.
|
||||
|
||||
## Additional Resources
|
||||
|
||||
* [OpenVINO™ Release Notes](https://software.intel.com/en-us/articles/OpenVINO-RelNotes)
|
||||
* [Introduction to Intel® Deep Learning Deployment Toolkit](https://docs.openvinotoolkit.org/latest/_docs_IE_DG_Introduction.html)
|
||||
* [Inference Engine Samples Overview](https://docs.openvinotoolkit.org/latest/_docs_IE_DG_Samples_Overview.html)
|
||||
* [Inference Engine Developer Guide](https://docs.openvinotoolkit.org/latest/_docs_IE_DG_Deep_Learning_Inference_Engine_DevGuide.html)
|
||||
* [Model Optimizer Developer Guide](https://docs.openvinotoolkit.org/latest/_docs_MO_DG_Deep_Learning_Model_Optimizer_DevGuide.html)
|
||||
|
||||
---
|
||||
\* Other names and brands may be claimed as the property of others.
|
||||
|
||||
|
||||
[Intel® Distribution of OpenVINO™]:https://software.intel.com/en-us/openvino-toolkit
|
||||
[CMake]:https://cmake.org/download/
|
||||
[Install Intel® Graphics Compute Runtime for OpenCL™ Driver package 20.13.16352]:https://github.com/intel/compute-runtime/releases/tag/20.13.16352
|
||||
[MKL-DNN repository]:https://github.com/intel/mkl-dnn/releases/download/v0.19/mklml_lnx_2019.0.5.20190502.tgz
|
||||
[MKL-DNN repository for Windows]:(https://github.com/intel/mkl-dnn/releases/download/v0.19/mklml_win_2019.0.5.20190502.zip)
|
||||
[OpenBLAS]:https://sourceforge.net/projects/openblas/files/v0.2.14/OpenBLAS-v0.2.14-Win64-int64.zip/download
|
||||
[mingw64\* runtime dependencies]:https://sourceforge.net/projects/openblas/files/v0.2.14/mingw64_dll.zip/download
|
||||
[https://download.01.org/opencv/2020/openvinotoolkit]:https://download.01.org/opencv/2020/openvinotoolkit
|
||||
[build instructions]:https://docs.opencv.org/master/df/d65/tutorial_table_of_content_introduction.html
|
||||
[driver package]:https://downloadcenter.intel.com/download/29335/Intel-Graphics-Windows-10-DCH-Drivers
|
||||
[Intel® Neural Compute Stick 2 Get Started]:https://software.intel.com/en-us/neural-compute-stick/get-started
|
||||
[Intel® C++ Compiler]:https://software.intel.com/en-us/intel-parallel-studio-xe
|
||||
[OpenBLAS]:https://sourceforge.net/projects/openblas/files/v0.2.14/OpenBLAS-v0.2.14-Win64-int64.zip/download
|
||||
73
cmake/arm.toolchain.cmake
Normal file
73
cmake/arm.toolchain.cmake
Normal file
@@ -0,0 +1,73 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR armv7l)
|
||||
|
||||
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
|
||||
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
|
||||
macro(__cmake_find_root_save_and_reset)
|
||||
foreach(v
|
||||
CMAKE_FIND_ROOT_PATH_MODE_LIBRARY
|
||||
CMAKE_FIND_ROOT_PATH_MODE_INCLUDE
|
||||
CMAKE_FIND_ROOT_PATH_MODE_PACKAGE
|
||||
CMAKE_FIND_ROOT_PATH_MODE_PROGRAM
|
||||
)
|
||||
set(__save_${v} ${${v}})
|
||||
set(${v} NEVER)
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
macro(__cmake_find_root_restore)
|
||||
foreach(v
|
||||
CMAKE_FIND_ROOT_PATH_MODE_LIBRARY
|
||||
CMAKE_FIND_ROOT_PATH_MODE_INCLUDE
|
||||
CMAKE_FIND_ROOT_PATH_MODE_PACKAGE
|
||||
CMAKE_FIND_ROOT_PATH_MODE_PROGRAM
|
||||
)
|
||||
set(${v} ${__save_${v}})
|
||||
unset(__save_${v})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
||||
# macro to find programs on the host OS
|
||||
macro(find_host_program)
|
||||
__cmake_find_root_save_and_reset()
|
||||
if(CMAKE_HOST_WIN32)
|
||||
SET(WIN32 1)
|
||||
SET(UNIX)
|
||||
elseif(CMAKE_HOST_APPLE)
|
||||
SET(APPLE 1)
|
||||
SET(UNIX)
|
||||
endif()
|
||||
find_program(${ARGN})
|
||||
SET(WIN32)
|
||||
SET(APPLE)
|
||||
SET(UNIX 1)
|
||||
__cmake_find_root_restore()
|
||||
endmacro()
|
||||
|
||||
# macro to find packages on the host OS
|
||||
macro(find_host_package)
|
||||
__cmake_find_root_save_and_reset()
|
||||
if(CMAKE_HOST_WIN32)
|
||||
SET(WIN32 1)
|
||||
SET(UNIX)
|
||||
elseif(CMAKE_HOST_APPLE)
|
||||
SET(APPLE 1)
|
||||
SET(UNIX)
|
||||
endif()
|
||||
find_package(${ARGN})
|
||||
SET(WIN32)
|
||||
SET(APPLE)
|
||||
SET(UNIX 1)
|
||||
__cmake_find_root_restore()
|
||||
endmacro()
|
||||
73
cmake/arm64.toolchain.cmake
Normal file
73
cmake/arm64.toolchain.cmake
Normal file
@@ -0,0 +1,73 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR aarch64)
|
||||
|
||||
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
|
||||
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
|
||||
macro(__cmake_find_root_save_and_reset)
|
||||
foreach(v
|
||||
CMAKE_FIND_ROOT_PATH_MODE_LIBRARY
|
||||
CMAKE_FIND_ROOT_PATH_MODE_INCLUDE
|
||||
CMAKE_FIND_ROOT_PATH_MODE_PACKAGE
|
||||
CMAKE_FIND_ROOT_PATH_MODE_PROGRAM
|
||||
)
|
||||
set(__save_${v} ${${v}})
|
||||
set(${v} NEVER)
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
macro(__cmake_find_root_restore)
|
||||
foreach(v
|
||||
CMAKE_FIND_ROOT_PATH_MODE_LIBRARY
|
||||
CMAKE_FIND_ROOT_PATH_MODE_INCLUDE
|
||||
CMAKE_FIND_ROOT_PATH_MODE_PACKAGE
|
||||
CMAKE_FIND_ROOT_PATH_MODE_PROGRAM
|
||||
)
|
||||
set(${v} ${__save_${v}})
|
||||
unset(__save_${v})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
||||
# macro to find programs on the host OS
|
||||
macro(find_host_program)
|
||||
__cmake_find_root_save_and_reset()
|
||||
if(CMAKE_HOST_WIN32)
|
||||
SET(WIN32 1)
|
||||
SET(UNIX)
|
||||
elseif(CMAKE_HOST_APPLE)
|
||||
SET(APPLE 1)
|
||||
SET(UNIX)
|
||||
endif()
|
||||
find_program(${ARGN})
|
||||
SET(WIN32)
|
||||
SET(APPLE)
|
||||
SET(UNIX 1)
|
||||
__cmake_find_root_restore()
|
||||
endmacro()
|
||||
|
||||
# macro to find packages on the host OS
|
||||
macro(find_host_package)
|
||||
__cmake_find_root_save_and_reset()
|
||||
if(CMAKE_HOST_WIN32)
|
||||
SET(WIN32 1)
|
||||
SET(UNIX)
|
||||
elseif(CMAKE_HOST_APPLE)
|
||||
SET(APPLE 1)
|
||||
SET(UNIX)
|
||||
endif()
|
||||
find_package(${ARGN})
|
||||
SET(WIN32)
|
||||
SET(APPLE)
|
||||
SET(UNIX 1)
|
||||
__cmake_find_root_restore()
|
||||
endmacro()
|
||||
35
cmake/check_features.cmake
Normal file
35
cmake/check_features.cmake
Normal file
@@ -0,0 +1,35 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
if (VERBOSE_BUILD)
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
|
||||
#64 bits platform
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
message(STATUS "Detected 64 bit architecture")
|
||||
SET(ARCH_64 ON)
|
||||
else()
|
||||
message(STATUS "Detected 32 bit architecture")
|
||||
SET(ARCH_64 OFF)
|
||||
endif()
|
||||
|
||||
if (NOT ENABLE_MKL_DNN)
|
||||
set(ENABLE_MKL OFF)
|
||||
endif()
|
||||
|
||||
if(ENABLE_AVX512F)
|
||||
if ((CMAKE_CXX_COMPILER_ID MATCHES MSVC) AND (MSVC_VERSION VERSION_LESS 1920))
|
||||
# 1920 version of MSVC 2019. In MSVC 2017 AVX512F not work
|
||||
set(ENABLE_AVX512F OFF CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES Clang)
|
||||
set(ENABLE_AVX512F OFF CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
if ((CMAKE_CXX_COMPILER_ID STREQUAL GNU) AND (NOT (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9)))
|
||||
set(ENABLE_AVX512F OFF CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
print_enabled_features()
|
||||
194
cmake/coverage/coverage.cmake
Normal file
194
cmake/coverage/coverage.cmake
Normal file
@@ -0,0 +1,194 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
if(NOT TARGET ie_coverage_clean)
|
||||
add_custom_target(ie_coverage_clean)
|
||||
endif()
|
||||
|
||||
if(NOT TARGET ie_coverage_init)
|
||||
add_custom_target(ie_coverage_init)
|
||||
endif()
|
||||
|
||||
if(NOT TARGET ie_coverage)
|
||||
add_custom_target(ie_coverage)
|
||||
endif()
|
||||
|
||||
set(IE_COVERAGE_REPORTS "${CMAKE_BINARY_DIR}/coverage")
|
||||
set(IE_COVERAGE_SCRIPT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/coverage")
|
||||
|
||||
include(CMakeParseArguments)
|
||||
|
||||
#
|
||||
# ie_coverage_clean(REPOSITORY <repo> DIRECTORY <dir>)
|
||||
#
|
||||
function(ie_coverage_clean)
|
||||
cmake_parse_arguments(IE_COVERAGE "" "REPOSITORY;DIRECTORY" "" ${ARGN})
|
||||
|
||||
add_custom_target(ie_coverage_zerocounters_${IE_COVERAGE_REPOSITORY}
|
||||
COMMAND lcov --zerocounters --quiet
|
||||
--directory "${IE_COVERAGE_DIRECTORY}"
|
||||
COMMENT "Add zero counters for coverage for ${IE_COVERAGE_REPOSITORY}"
|
||||
VERBATIM)
|
||||
|
||||
add_custom_target(ie_coverage_clean_${IE_COVERAGE_REPOSITORY}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-D "IE_COVERAGE_REPORTS=${IE_COVERAGE_REPORTS}"
|
||||
-D "IE_COVERAGE_DIRECTORY=${IE_COVERAGE_DIRECTORY}"
|
||||
-D "CMAKE_BINARY_DIRECTORY=${CMAKE_BINARY_DIR}"
|
||||
-D "CMAKE_SOURCE_DIRECTORY=${CMAKE_SOURCE_DIR}"
|
||||
-P "${IE_COVERAGE_SCRIPT_DIR}/coverage_clean.cmake"
|
||||
COMMENT "Clean previously created HTML report files for ${IE_COVERAGE_REPOSITORY}"
|
||||
DEPENDS "${IE_COVERAGE_SCRIPT_DIR}/coverage_clean.cmake"
|
||||
VERBATIM)
|
||||
|
||||
add_dependencies(ie_coverage_clean ie_coverage_zerocounters_${IE_COVERAGE_REPOSITORY}
|
||||
ie_coverage_clean_${IE_COVERAGE_REPOSITORY})
|
||||
endfunction()
|
||||
|
||||
#
|
||||
# ie_coverage_capture(INFO_FILE <info_file>
|
||||
# BASE_DIRECTORY <base dir>
|
||||
# DIRECTORY <gcda dir>)
|
||||
#
|
||||
function(ie_coverage_capture)
|
||||
cmake_parse_arguments(IE_COVERAGE "" "INFO_FILE;BASE_DIRECTORY;DIRECTORY" "" ${ARGN})
|
||||
|
||||
set(output_file "${IE_COVERAGE_REPORTS}/${IE_COVERAGE_INFO_FILE}.info")
|
||||
set(output_base_file "${IE_COVERAGE_REPORTS}/${IE_COVERAGE_INFO_FILE}_base.info")
|
||||
set(output_tests_file "${IE_COVERAGE_REPORTS}/${IE_COVERAGE_INFO_FILE}_tests.info")
|
||||
|
||||
add_custom_command(OUTPUT ${output_base_file}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${IE_COVERAGE_REPORTS}"
|
||||
COMMAND lcov --no-external --capture --initial --quiet
|
||||
--directory "${IE_COVERAGE_DIRECTORY}"
|
||||
--base-directory "${IE_COVERAGE_BASE_DIRECTORY}"
|
||||
--output-file ${output_base_file}
|
||||
COMMENT "Capture initial coverage data ${IE_COVERAGE_INFO_FILE}"
|
||||
VERBATIM)
|
||||
|
||||
add_custom_command(OUTPUT ${output_tests_file}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${IE_COVERAGE_REPORTS}"
|
||||
COMMAND lcov --no-external --capture --quiet
|
||||
--directory "${IE_COVERAGE_DIRECTORY}"
|
||||
--base-directory "${IE_COVERAGE_BASE_DIRECTORY}"
|
||||
--output-file ${output_tests_file}
|
||||
COMMENT "Capture test coverage data ${IE_COVERAGE_INFO_FILE}"
|
||||
VERBATIM)
|
||||
|
||||
add_custom_command(OUTPUT ${output_file}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-D "IE_COVERAGE_OUTPUT_FILE=${output_file}"
|
||||
-D "IE_COVERAGE_INPUT_FILES=${output_base_file};${output_tests_file}"
|
||||
-P "${IE_COVERAGE_SCRIPT_DIR}/coverage_merge.cmake"
|
||||
COMMENT "Generate total coverage data ${IE_COVERAGE_INFO_FILE}"
|
||||
DEPENDS ${output_base_file} ${output_tests_file}
|
||||
VERBATIM)
|
||||
|
||||
add_custom_target(ie_coverage_${IE_COVERAGE_INFO_FILE}_info
|
||||
DEPENDS ${output_file})
|
||||
endfunction()
|
||||
|
||||
#
|
||||
# ie_coverage_extract(INPUT <info_file> OUTPUT <output_file> PATTERNS <patterns ...>)
|
||||
#
|
||||
function(ie_coverage_extract)
|
||||
cmake_parse_arguments(IE_COVERAGE "" "INPUT;OUTPUT" "PATTERNS" ${ARGN})
|
||||
|
||||
set(input_file "${IE_COVERAGE_REPORTS}/${IE_COVERAGE_INPUT}.info")
|
||||
set(output_file "${IE_COVERAGE_REPORTS}/${IE_COVERAGE_OUTPUT}.info")
|
||||
|
||||
set(commands lcov --quiet)
|
||||
foreach(pattern IN LISTS IE_COVERAGE_PATTERNS)
|
||||
list(APPEND commands --extract ${input_file} ${pattern})
|
||||
endforeach()
|
||||
list(APPEND commands --output-file ${output_file})
|
||||
|
||||
add_custom_command(OUTPUT ${output_file}
|
||||
COMMAND ${commands}
|
||||
COMMENT "Generate coverage data ${IE_COVERAGE_OUTPUT}"
|
||||
DEPENDS ${input_file}
|
||||
VERBATIM)
|
||||
add_custom_target(ie_coverage_${IE_COVERAGE_OUTPUT}_info
|
||||
DEPENDS ${output_file})
|
||||
|
||||
add_dependencies(ie_coverage_${IE_COVERAGE_OUTPUT}_info ie_coverage_${IE_COVERAGE_INPUT}_info)
|
||||
endfunction()
|
||||
|
||||
#
|
||||
# ie_coverage_remove(INPUT <info_file> OUTPUT <output_file> PATTERNS <patterns ...>)
|
||||
#
|
||||
function(ie_coverage_remove)
|
||||
cmake_parse_arguments(IE_COVERAGE "" "INPUT;OUTPUT" "PATTERNS" ${ARGN})
|
||||
|
||||
set(input_file "${IE_COVERAGE_REPORTS}/${IE_COVERAGE_INPUT}.info")
|
||||
set(output_file "${IE_COVERAGE_REPORTS}/${IE_COVERAGE_OUTPUT}.info")
|
||||
|
||||
set(commands lcov --quiet)
|
||||
foreach(pattern IN LISTS IE_COVERAGE_PATTERNS)
|
||||
list(APPEND commands --remove ${input_file} ${pattern})
|
||||
endforeach()
|
||||
list(APPEND commands --output-file ${output_file})
|
||||
|
||||
add_custom_command(OUTPUT ${output_file}
|
||||
COMMAND ${commands}
|
||||
COMMENT "Generate coverage data ${IE_COVERAGE_OUTPUT}"
|
||||
DEPENDS ${input_file}
|
||||
VERBATIM)
|
||||
add_custom_target(ie_coverage_${IE_COVERAGE_OUTPUT}_info
|
||||
DEPENDS ${output_file})
|
||||
|
||||
add_dependencies(ie_coverage_${IE_COVERAGE_OUTPUT}_info ie_coverage_${IE_COVERAGE_INPUT}_info)
|
||||
endfunction()
|
||||
|
||||
#
|
||||
# ie_coverage_merge(OUTPUT <output file> INPUTS <input files ...>)
|
||||
#
|
||||
function(ie_coverage_merge)
|
||||
cmake_parse_arguments(IE_COVERAGE "" "OUTPUT" "INPUTS" ${ARGN})
|
||||
|
||||
set(output_file "${IE_COVERAGE_REPORTS}/${IE_COVERAGE_OUTPUT}.info")
|
||||
foreach(input_info_file IN LISTS IE_COVERAGE_INPUTS)
|
||||
set(input_file ${IE_COVERAGE_REPORTS}/${input_info_file}.info)
|
||||
list(APPEND dependencies ie_coverage_${input_info_file}_info)
|
||||
list(APPEND input_files ${input_file})
|
||||
endforeach()
|
||||
|
||||
add_custom_command(OUTPUT ${output_file}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-D "IE_COVERAGE_OUTPUT_FILE=${output_file}"
|
||||
-D "IE_COVERAGE_INPUT_FILES=${input_files}"
|
||||
-P "${IE_COVERAGE_SCRIPT_DIR}/coverage_merge.cmake"
|
||||
COMMENT "Generate coverage data ${IE_COVERAGE_OUTPUT}"
|
||||
DEPENDS ${input_files}
|
||||
VERBATIM)
|
||||
add_custom_target(ie_coverage_${IE_COVERAGE_OUTPUT}_info
|
||||
DEPENDS ${output_file})
|
||||
|
||||
add_dependencies(ie_coverage_${IE_COVERAGE_OUTPUT}_info ${dependencies})
|
||||
endfunction()
|
||||
|
||||
#
|
||||
# ie_coverage_genhtml(INFO_FILE <info_file> PREFIX <prefix>)
|
||||
#
|
||||
function(ie_coverage_genhtml)
|
||||
cmake_parse_arguments(IE_COVERAGE "" "INFO_FILE;PREFIX" "" ${ARGN})
|
||||
|
||||
set(input_file "${IE_COVERAGE_REPORTS}/${IE_COVERAGE_INFO_FILE}.info")
|
||||
set(output_directory "${IE_COVERAGE_REPORTS}/${IE_COVERAGE_INFO_FILE}")
|
||||
|
||||
add_custom_command(OUTPUT "${output_directory}/index.html"
|
||||
COMMAND genhtml ${input_file} --title "${IE_COVERAGE_INFO_FILE}" --legend
|
||||
--no-branch-coverage --demangle-cpp
|
||||
--output-directory "${output_directory}"
|
||||
--num-spaces 4 --quiet
|
||||
--prefix "${IE_COVERAGE_PREFIX}"
|
||||
DEPENDS ${input_file}
|
||||
COMMENT "Generate HTML report for ${IE_COVERAGE_INFO_FILE}"
|
||||
VERBATIM)
|
||||
add_custom_target(ie_coverage_${IE_COVERAGE_INFO_FILE}_genhtml
|
||||
DEPENDS "${output_directory}/index.html")
|
||||
|
||||
add_dependencies(ie_coverage_${IE_COVERAGE_INFO_FILE}_genhtml ie_coverage_${IE_COVERAGE_INFO_FILE}_info)
|
||||
add_dependencies(ie_coverage ie_coverage_${IE_COVERAGE_INFO_FILE}_genhtml)
|
||||
endfunction()
|
||||
30
cmake/coverage/coverage_clean.cmake
Normal file
30
cmake/coverage/coverage_clean.cmake
Normal file
@@ -0,0 +1,30 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
if(NOT DEFINED IE_COVERAGE_REPORTS)
|
||||
message(FATAL_ERROR "IE_COVERAGE_REPORTS variable is not defined")
|
||||
return()
|
||||
endif()
|
||||
|
||||
file(REMOVE_RECURSE "${IE_COVERAGE_REPORTS}")
|
||||
|
||||
if(NOT DEFINED IE_COVERAGE_DIRECTORY)
|
||||
message(FATAL_ERROR "IE_COVERAGE_DIRECTORY variable is not defined")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# remove .gcno files which are kept from the previous build
|
||||
|
||||
file(GLOB_RECURSE gcno_files "${IE_COVERAGE_DIRECTORY}/*.gcno")
|
||||
foreach(file IN LISTS gcno_files)
|
||||
string(REPLACE ".gcno" "" temp_file "${file}")
|
||||
string(REGEX REPLACE "CMakeFiles/.+dir/" "" temp_file "${temp_file}")
|
||||
string(REPLACE "${CMAKE_BINARY_DIRECTORY}" "${CMAKE_SOURCE_DIRECTORY}" source_file "${temp_file}")
|
||||
|
||||
if(NOT EXISTS "${source_file}")
|
||||
file(REMOVE "${file}")
|
||||
string(REPLACE "${CMAKE_BINARY_DIRECTORY}/" "" file "${file}")
|
||||
message("Removing ${file}")
|
||||
endif()
|
||||
endforeach()
|
||||
22
cmake/coverage/coverage_merge.cmake
Normal file
22
cmake/coverage/coverage_merge.cmake
Normal file
@@ -0,0 +1,22 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
if(NOT DEFINED IE_COVERAGE_OUTPUT_FILE)
|
||||
message(FATAL_ERROR "IE_COVERAGE_OUTPUT_FILE is not defined")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED IE_COVERAGE_INPUT_FILES)
|
||||
message(FATAL_ERROR "IE_COVERAGE_INPUT_FILES is not defined")
|
||||
endif()
|
||||
|
||||
set(command lcov --quiet)
|
||||
foreach(input_info_file IN LISTS IE_COVERAGE_INPUT_FILES)
|
||||
file(SIZE ${input_info_file} size)
|
||||
if(NOT size EQUAL 0)
|
||||
list(APPEND command --add-tracefile "${input_info_file}")
|
||||
endif()
|
||||
endforeach()
|
||||
list(APPEND command --output-file ${IE_COVERAGE_OUTPUT_FILE})
|
||||
|
||||
execute_process(COMMAND ${command})
|
||||
@@ -1,5 +1,4 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
@@ -9,7 +8,6 @@ function (debug_message)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
function(clean_message type)
|
||||
string (REPLACE ";" "" output_string "${ARGN}")
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E echo "${output_string}")
|
||||
@@ -28,11 +26,11 @@ function (log_rpath_remove_top component component_remove_top lib lib_remove_top
|
||||
|
||||
# debug_message(STATUS "LIB-IN=${lib} ")
|
||||
# debug_message(STATUS "TOPLIB-IN=${top_lib_dir} ")
|
||||
get_filename_component(top_lib_dir ${${component}} DIRECTORY)
|
||||
get_filename_component(top_lib_dir "${${component}}" DIRECTORY)
|
||||
|
||||
if (${component_remove_top} AND ${component})
|
||||
else()
|
||||
get_filename_component(add_name ${${component}} NAME)
|
||||
get_filename_component(add_name "${${component}}" NAME)
|
||||
set(top_lib_dir "${top_lib_dir}/${add_name}")
|
||||
endif()
|
||||
if (${lib_remove_top} AND lib)
|
||||
@@ -47,7 +45,12 @@ function (log_rpath_remove_top component component_remove_top lib lib_remove_top
|
||||
|
||||
# debug_message(STATUS "LIB-OUT=${lib_dir}")
|
||||
# debug_message(STATUS "TOPLIB-OUT=${top_lib_dir}")
|
||||
|
||||
|
||||
if (WIN32)
|
||||
string (TOLOWER "${top_lib_dir}" top_lib_dir)
|
||||
string (TOLOWER "${lib_dir}" lib_dir)
|
||||
endif()
|
||||
|
||||
string (REPLACE "${top_lib_dir}" "" component_dir "${lib_dir}")
|
||||
|
||||
set(RPATH_INFO "${component}=${component_dir}")
|
||||
@@ -56,9 +59,7 @@ function (log_rpath_remove_top component component_remove_top lib lib_remove_top
|
||||
endfunction()
|
||||
|
||||
function (log_rpath_from_dir component lib_dir)
|
||||
if(NOT APPLE)
|
||||
log_rpath_remove_top("${component}" TRUE "${lib_dir}" FALSE)
|
||||
endif()
|
||||
log_rpath_remove_top("${component}" TRUE "${lib_dir}" FALSE)
|
||||
endfunction()
|
||||
|
||||
function (log_rpath component lib_path)
|
||||
@@ -69,4 +70,4 @@ endfunction()
|
||||
# This macro is redefined (with additional checks) within the InferenceEngineConfig.cmake file.
|
||||
macro(ext_message TRACE_LEVEL)
|
||||
message(${TRACE_LEVEL} "${ARGN}")
|
||||
endmacro()
|
||||
endmacro()
|
||||
37
cmake/dependencies.cmake
Normal file
37
cmake/dependencies.cmake
Normal file
@@ -0,0 +1,37 @@
|
||||
# Copyright (C) 2018 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
set_temp_directory(TEMP "${IE_MAIN_SOURCE_DIR}")
|
||||
|
||||
include(dependency_solver)
|
||||
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*")
|
||||
set(HOST_X86_64 ON)
|
||||
endif()
|
||||
|
||||
set(protoc_version "3.7.1")
|
||||
if(CMAKE_HOST_SYSTEM_NAME MATCHES Linux)
|
||||
RESOLVE_DEPENDENCY(SYSTEM_PROTOC_ROOT
|
||||
ARCHIVE_LIN "protoc-${protoc_version}-linux-x86_64.tar.gz"
|
||||
TARGET_PATH "${TEMP}/protoc-${protoc_version}-linux-x86_64")
|
||||
debug_message(STATUS "host protoc-${protoc_version} root path = " ${SYSTEM_PROTOC_ROOT})
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported host system (${CMAKE_HOST_SYSTEM_NAME}) and arch (${CMAKE_HOST_SYSTEM_PROCESSOR}) for cross-compilation")
|
||||
endif()
|
||||
|
||||
reset_deps_cache(SYSTEM_PROTOC)
|
||||
|
||||
message("${SYSTEM_PROTOC_ROOT}/bin")
|
||||
find_program(
|
||||
SYSTEM_PROTOC
|
||||
NAMES protoc
|
||||
PATHS "${SYSTEM_PROTOC_ROOT}/bin"
|
||||
NO_DEFAULT_PATH)
|
||||
if(NOT SYSTEM_PROTOC)
|
||||
message(FATAL_ERROR "[ONNX IMPORTER] Missing host protoc binary")
|
||||
endif()
|
||||
|
||||
update_deps_cache(SYSTEM_PROTOC "${SYSTEM_PROTOC}" "Path to host protoc for ONNX Importer")
|
||||
endif()
|
||||
218
cmake/developer_package.cmake
Normal file
218
cmake/developer_package.cmake
Normal file
@@ -0,0 +1,218 @@
|
||||
# Copyright (C) 2018 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
set(CMAKE_MODULE_PATH "${OpenVINO_MAIN_SOURCE_DIR}/cmake/download" ${CMAKE_MODULE_PATH})
|
||||
|
||||
include(CPackComponent)
|
||||
unset(IE_CPACK_COMPONENTS_ALL CACHE)
|
||||
|
||||
set(IE_CPACK_IE_DIR deployment_tools/inference_engine)
|
||||
|
||||
# Search packages for the host system instead of packages for the target system
|
||||
# in case of cross compilation these macros should be defined by the toolchain file
|
||||
if(NOT COMMAND find_host_package)
|
||||
macro(find_host_package)
|
||||
find_package(${ARGN})
|
||||
endmacro()
|
||||
endif()
|
||||
if(NOT COMMAND find_host_program)
|
||||
macro(find_host_program)
|
||||
find_program(${ARGN})
|
||||
endmacro()
|
||||
endif()
|
||||
|
||||
#
|
||||
# ie_cpack_set_library_dir()
|
||||
#
|
||||
# Set library directory for cpack
|
||||
#
|
||||
function(ie_cpack_set_library_dir)
|
||||
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} ARCH)
|
||||
if(ARCH STREQUAL "x86_64" OR ARCH STREQUAL "amd64") # Windows detects Intel's 64-bit CPU as AMD64
|
||||
set(ARCH intel64)
|
||||
elseif(ARCH STREQUAL "i386")
|
||||
set(ARCH ia32)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set(IE_CPACK_LIBRARY_PATH ${IE_CPACK_IE_DIR}/lib/${ARCH}/${CMAKE_BUILD_TYPE} PARENT_SCOPE)
|
||||
set(IE_CPACK_RUNTIME_PATH ${IE_CPACK_IE_DIR}/bin/${ARCH}/${CMAKE_BUILD_TYPE} PARENT_SCOPE)
|
||||
set(IE_CPACK_ARCHIVE_PATH ${IE_CPACK_IE_DIR}/lib/${ARCH}/${CMAKE_BUILD_TYPE} PARENT_SCOPE)
|
||||
else()
|
||||
set(IE_CPACK_LIBRARY_PATH ${IE_CPACK_IE_DIR}/lib/${ARCH} PARENT_SCOPE)
|
||||
set(IE_CPACK_RUNTIME_PATH ${IE_CPACK_IE_DIR}/lib/${ARCH} PARENT_SCOPE)
|
||||
set(IE_CPACK_ARCHIVE_PATH ${IE_CPACK_IE_DIR}/lib/${ARCH} PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
ie_cpack_set_library_dir()
|
||||
|
||||
#
|
||||
# ie_cpack_add_component(NAME ...)
|
||||
#
|
||||
# Wraps original `cpack_add_component` and adds component to internal IE list
|
||||
#
|
||||
macro(ie_cpack_add_component NAME)
|
||||
list(APPEND IE_CPACK_COMPONENTS_ALL ${NAME})
|
||||
set(IE_CPACK_COMPONENTS_ALL "${IE_CPACK_COMPONENTS_ALL}" CACHE STRING "" FORCE)
|
||||
cpack_add_component(${NAME} ${ARGN})
|
||||
endmacro()
|
||||
|
||||
macro(ie_cpack)
|
||||
set(CPACK_GENERATOR "TGZ")
|
||||
if(WIN32)
|
||||
set(CPACK_PACKAGE_NAME inference-engine_${CMAKE_BUILD_TYPE})
|
||||
string(REPLACE "\\" "_" CPACK_PACKAGE_VERSION "${CI_BUILD_NUMBER}")
|
||||
else()
|
||||
set(CPACK_PACKAGE_NAME inference-engine)
|
||||
string(REPLACE "/" "_" CPACK_PACKAGE_VERSION "${CI_BUILD_NUMBER}")
|
||||
endif()
|
||||
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
|
||||
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
|
||||
set(CPACK_PACKAGE_VENDOR "Intel")
|
||||
set(CPACK_COMPONENTS_ALL ${ARGN})
|
||||
set(CPACK_STRIP_FILES ON)
|
||||
|
||||
if(OS_FOLDER)
|
||||
set(CPACK_SYSTEM_NAME "${OS_FOLDER}")
|
||||
endif()
|
||||
|
||||
include(CPack)
|
||||
endmacro()
|
||||
|
||||
# prepare temporary folder
|
||||
function(set_temp_directory temp_variable source_tree_dir)
|
||||
if (DEFINED ENV{DL_SDK_TEMP} AND NOT $ENV{DL_SDK_TEMP} STREQUAL "")
|
||||
message(STATUS "DL_SDK_TEMP environment is set : $ENV{DL_SDK_TEMP}")
|
||||
|
||||
if (WIN32)
|
||||
string(REPLACE "\\" "\\\\" temp $ENV{DL_SDK_TEMP})
|
||||
else()
|
||||
set(temp $ENV{DL_SDK_TEMP})
|
||||
endif()
|
||||
|
||||
if (ENABLE_ALTERNATIVE_TEMP)
|
||||
set(ALTERNATIVE_PATH ${source_tree_dir}/temp)
|
||||
endif()
|
||||
else ()
|
||||
set(temp ${source_tree_dir}/temp)
|
||||
endif()
|
||||
|
||||
set("${temp_variable}" "${temp}" CACHE PATH "Path to temp directory")
|
||||
if(ALTERNATIVE_PATH)
|
||||
set(ALTERNATIVE_PATH "${ALTERNATIVE_PATH}" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
include(coverage/coverage)
|
||||
|
||||
# External dependencies
|
||||
find_package(Threads)
|
||||
|
||||
# Detect target
|
||||
include(target_flags)
|
||||
|
||||
# printing debug messages
|
||||
include(debug)
|
||||
|
||||
# linking libraries without discarding symbols
|
||||
include(whole_archive)
|
||||
|
||||
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} ARCH_FOLDER)
|
||||
if(ARCH_FOLDER STREQUAL "x86_64" OR ARCH_FOLDER STREQUAL "amd64") # Windows detects Intel's 64-bit CPU as AMD64
|
||||
set(ARCH_FOLDER intel64)
|
||||
elseif(ARCH_FOLDER STREQUAL "i386")
|
||||
set(ARCH_FOLDER ia32)
|
||||
endif()
|
||||
|
||||
if(OS_FOLDER)
|
||||
message ("**** OS FOLDER IS: [${OS_FOLDER}]")
|
||||
if("${OS_FOLDER}" STREQUAL "ON")
|
||||
message ("**** USING OS FOLDER: [${CMAKE_SYSTEM_NAME}]")
|
||||
set(BIN_FOLDER "bin/${CMAKE_SYSTEM_NAME}/${ARCH_FOLDER}")
|
||||
else()
|
||||
set(BIN_FOLDER "bin/${OS_FOLDER}/${ARCH_FOLDER}")
|
||||
endif()
|
||||
else()
|
||||
set(BIN_FOLDER "bin/${ARCH_FOLDER}")
|
||||
endif()
|
||||
|
||||
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
||||
debug_message(STATUS "CMAKE_BUILD_TYPE not defined, 'Release' will be used")
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
endif()
|
||||
|
||||
set(OUTPUT_ROOT ${OpenVINO_MAIN_SOURCE_DIR})
|
||||
|
||||
# Enable postfixes for Debug/Release builds
|
||||
set(IE_DEBUG_POSTFIX_WIN "d")
|
||||
set(IE_RELEASE_POSTFIX_WIN "")
|
||||
set(IE_DEBUG_POSTFIX_LIN "")
|
||||
set(IE_RELEASE_POSTFIX_LIN "")
|
||||
set(IE_DEBUG_POSTFIX_MAC "d")
|
||||
set(IE_RELEASE_POSTFIX_MAC "")
|
||||
|
||||
if(WIN32)
|
||||
set(IE_DEBUG_POSTFIX ${IE_DEBUG_POSTFIX_WIN})
|
||||
set(IE_RELEASE_POSTFIX ${IE_RELEASE_POSTFIX_WIN})
|
||||
elseif(APPLE)
|
||||
set(IE_DEBUG_POSTFIX ${IE_DEBUG_POSTFIX_MAC})
|
||||
set(IE_RELEASE_POSTFIX ${IE_RELEASE_POSTFIX_MAC})
|
||||
else()
|
||||
set(IE_DEBUG_POSTFIX ${IE_DEBUG_POSTFIX_LIN})
|
||||
set(IE_RELEASE_POSTFIX ${IE_RELEASE_POSTFIX_LIN})
|
||||
endif()
|
||||
|
||||
set(CMAKE_DEBUG_POSTFIX ${IE_DEBUG_POSTFIX})
|
||||
set(CMAKE_RELEASE_POSTFIX ${IE_RELEASE_POSTFIX})
|
||||
|
||||
if (WIN32)
|
||||
# Support CMake multiconfiguration for Visual Studio build
|
||||
set(IE_BUILD_POSTFIX $<$<CONFIG:Debug>:${IE_DEBUG_POSTFIX}>$<$<CONFIG:Release>:${IE_RELEASE_POSTFIX}>)
|
||||
else ()
|
||||
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug" )
|
||||
set(IE_BUILD_POSTFIX ${IE_DEBUG_POSTFIX})
|
||||
else()
|
||||
set(IE_BUILD_POSTFIX ${IE_RELEASE_POSTFIX})
|
||||
endif()
|
||||
endif()
|
||||
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
|
||||
|
||||
add_definitions(-DIE_BUILD_POSTFIX=\"${IE_BUILD_POSTFIX}\")
|
||||
|
||||
if(NOT UNIX)
|
||||
if (WIN32)
|
||||
# set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
|
||||
# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
|
||||
endif()
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
||||
set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
||||
set(CMAKE_PDB_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
||||
else()
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE}/lib)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE}/lib)
|
||||
set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE})
|
||||
set(CMAKE_PDB_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE})
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
set(CMAKE_MACOSX_RPATH ON)
|
||||
endif(APPLE)
|
||||
|
||||
# Use solution folders
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
include(sdl)
|
||||
include(os_flags NO_POLICY_SCOPE)
|
||||
include(sanitizer)
|
||||
|
||||
function(set_ci_build_number)
|
||||
set(OpenVINO_MAIN_SOURCE_DIR "${CMAKE_SOURCE_DIR}")
|
||||
include(version)
|
||||
set(CI_BUILD_NUMBER "${CI_BUILD_NUMBER}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
set_ci_build_number()
|
||||
195
cmake/download/dependency_solver.cmake
Normal file
195
cmake/download/dependency_solver.cmake
Normal file
@@ -0,0 +1,195 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
include ("download")
|
||||
|
||||
function (resolve_archive_dependency VAR COMPONENT ARCHIVE ARCHIVE_UNIFIED ARCHIVE_WIN ARCHIVE_LIN ARCHIVE_MAC ARCHIVE_ANDROID TARGET_PATH FOLDER ENVIRONMENT)
|
||||
|
||||
if (ENVIRONMENT AND (DEFINED ${ENVIRONMENT} OR DEFINED ENV{${ENVIRONMENT}}))
|
||||
set(HAS_ENV "TRUE")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED HAS_ENV)
|
||||
if (ARCHIVE)
|
||||
#TODO: check whether this is platform specific binary with same name per or it is in common folder
|
||||
DownloadAndExtract(${COMPONENT} ${ARCHIVE} ${TARGET_PATH} result_path ${FOLDER})
|
||||
else()
|
||||
DownloadAndExtractPlatformSpecific(${COMPONENT} ${ARCHIVE_UNIFIED} ${ARCHIVE_WIN} ${ARCHIVE_LIN} ${ARCHIVE_MAC} ${ARCHIVE_ANDROID} ${TARGET_PATH} result_path ${FOLDER})
|
||||
endif()
|
||||
|
||||
set (${VAR} ${result_path} PARENT_SCOPE)
|
||||
else()
|
||||
if (DEFINED ${ENVIRONMENT})
|
||||
set (${VAR} ${${ENVIRONMENT}} PARENT_SCOPE)
|
||||
else ()
|
||||
set (${VAR} $ENV{${ENVIRONMENT}} PARENT_SCOPE)
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
endfunction(resolve_archive_dependency)
|
||||
|
||||
function(resolve_pull_request GITHUB_PULL_REQUEST TARGET_PATH)
|
||||
get_filename_component(FILE_NAME ${GITHUB_PULL_REQUEST} NAME)
|
||||
set (PATCH_URL "")
|
||||
DownloadAndApply("${PATCH_URL}/${GITHUB_PULL_REQUEST}" "${IE_MAIN_SOURCE_DIR}/${TARGET_PATH}/${FILE_NAME}")
|
||||
endfunction(resolve_pull_request)
|
||||
|
||||
function(extract_version_from_filename filename regex version)
|
||||
string(REGEX MATCH ${regex} match ${filename})
|
||||
|
||||
if (CMAKE_MATCH_1)
|
||||
set(${version} ${CMAKE_MATCH_1} PARENT_SCOPE)
|
||||
else()
|
||||
set(${version} ${filename} PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction(extract_version_from_filename)
|
||||
|
||||
function(read_version archive regex version_var)
|
||||
extract_version_from_filename(${archive} ${regex} version)
|
||||
set(${version_var} "${version}" CACHE INTERNAL "" FORCE)
|
||||
debug_message(STATUS "${version_var} = " ${version})
|
||||
endfunction(read_version)
|
||||
|
||||
function (RESOLVE_DEPENDENCY NAME_OF_CMAKE_VAR)
|
||||
|
||||
list(REMOVE_AT ARGV 0)
|
||||
set(SUPPORTED_ARGS FOLDER ARCHIVE ARCHIVE_UNIFIED ARCHIVE_WIN ARCHIVE_LIN ARCHIVE_MAC ARCHIVE_ANDROID TARGET_PATH ENVIRONMENT GITHUB_PULL_REQUEST VERSION_REGEX)
|
||||
|
||||
|
||||
#unnecessary vars
|
||||
foreach(arg ${ARGV})
|
||||
#message("one_arg=" ${one_arg})
|
||||
#message("arg=" ${arg})
|
||||
#parse no arg vars
|
||||
if (";${SUPPORTED_ARGS};" MATCHES ";${arg};")
|
||||
if(DEFINED one_arg)
|
||||
set(${one_arg} TRUE)
|
||||
endif()
|
||||
set (one_arg ${arg})
|
||||
elseif(DEFINED one_arg)
|
||||
set(${one_arg} ${arg})
|
||||
unset(one_arg)
|
||||
else()
|
||||
message(FATAL_ERROR "invalid argument passed to resolve dependency: " ${arg})
|
||||
endif()
|
||||
endforeach(arg)
|
||||
|
||||
#if last token was bool
|
||||
if(DEFINED one_arg)
|
||||
set(${one_arg} TRUE)
|
||||
endif()
|
||||
|
||||
|
||||
if (NOT DEFINED ARCHIVE)
|
||||
SET(ARCHIVE "OFF")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED ARCHIVE_UNIFIED)
|
||||
SET(ARCHIVE_UNIFIED "OFF")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED ARCHIVE_WIN)
|
||||
SET(ARCHIVE_WIN "OFF")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED ARCHIVE_LIN)
|
||||
SET(ARCHIVE_LIN "OFF")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED ARCHIVE_MAC)
|
||||
SET(ARCHIVE_MAC "OFF")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED ARCHIVE_ANDROID)
|
||||
SET(ARCHIVE_ANDROID "OFF")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED ENVIRONMENT)
|
||||
set (ENVIRONMENT "OFF")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED FOLDER)
|
||||
set (FOLDER FALSE)
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
#for each dependency type have to do separate things
|
||||
if (ARCHIVE_WIN OR ARCHIVE_LIN OR ARCHIVE_MAC OR ARCHIVE_ANDROID OR ARCHIVE OR ARCHIVE_UNIFIED)
|
||||
if (NOT DEFINED TARGET_PATH)
|
||||
message(FATAL_ERROR "TARGET_PATH should be defined for every dependency")
|
||||
endif()
|
||||
|
||||
resolve_archive_dependency(RESULT ${NAME_OF_CMAKE_VAR} ${ARCHIVE} ${ARCHIVE_UNIFIED} ${ARCHIVE_WIN} ${ARCHIVE_LIN} ${ARCHIVE_MAC} ${ARCHIVE_ANDROID} ${TARGET_PATH} ${FOLDER} ${ENVIRONMENT})
|
||||
set(${NAME_OF_CMAKE_VAR} ${RESULT} PARENT_SCOPE)
|
||||
if (VERSION_REGEX)
|
||||
GetNameAndUrlToDownload(archive RELATIVE_URL ${ARCHIVE_UNIFIED} ${ARCHIVE_WIN} ${ARCHIVE_LIN} ${ARCHIVE_MAC} ${ARCHIVE_ANDROID})
|
||||
if (archive)
|
||||
read_version(${archive} ${VERSION_REGEX} "${NAME_OF_CMAKE_VAR}_VERSION")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
elseif (DEFINED GITHUB_PULL_REQUEST)
|
||||
resolve_pull_request(${GITHUB_PULL_REQUEST} ${TARGET_PATH})
|
||||
else()
|
||||
message(FATAL_ERROR "Dependency of unknowntype, SHOULD set one of ARCHIVE_WIN, ARCHIVE, ARCHIVE_LIN, ARCHIVE_MAC, ARCHIVE_ANDROID, GITHUB_PULL_REQUEST")
|
||||
endif()
|
||||
|
||||
endfunction(RESOLVE_DEPENDENCY)
|
||||
|
||||
function (resolve_model_dependency network archive network_model_path)
|
||||
RESOLVE_DEPENDENCY(${network_model_path}
|
||||
ARCHIVE "models_archives/${archive}"
|
||||
TARGET_PATH "${MODELS_PATH}/${network}")
|
||||
string (REPLACE ${MODELS_PATH} "" relative_path ${${network_model_path}})
|
||||
set(${network_model_path} ".${relative_path}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(reset_deps_cache)
|
||||
#
|
||||
# Reset the dependencies cache if it was set by dependency solver
|
||||
#
|
||||
set(need_reset FALSE)
|
||||
|
||||
foreach(var_name IN LISTS ARGN)
|
||||
if(DEFINED ${var_name})
|
||||
if(${var_name} MATCHES ${TEMP})
|
||||
set(need_reset TRUE)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
foreach(var_name IN LISTS ARGN)
|
||||
if(DEFINED ENV{${var_name}})
|
||||
if($ENV{${var_name}} MATCHES ${TEMP})
|
||||
set(need_reset TRUE)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(need_reset)
|
||||
foreach(var_name IN LISTS ARGN)
|
||||
unset(${var_name} CACHE)
|
||||
endforeach()
|
||||
foreach(var_name IN LISTS ARGN)
|
||||
unset(ENV{${var_name}})
|
||||
endforeach()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(update_deps_cache VAR_NAME INTERNAL_VALUE DOC_MSG)
|
||||
#
|
||||
# Update the variable value if it wasn't provided by the user
|
||||
#
|
||||
|
||||
if(NOT DEFINED ${VAR_NAME} AND NOT DEFINED ENV{${VAR_NAME}})
|
||||
# User didn't provide its own value, use INTERNAL_VALUE
|
||||
set(${VAR_NAME} ${INTERNAL_VALUE} CACHE PATH ${DOC_MSG})
|
||||
else()
|
||||
# The variable was provided by the user, don't use INTERNAL_VALUE
|
||||
if(NOT DEFINED ${VAR_NAME} AND DEFINED ENV{${VAR_NAME}})
|
||||
# User provided the variable via environment, convert it to the CACHE variable
|
||||
set(${VAR_NAME} $ENV{${VAR_NAME}} CACHE PATH ${DOC_MSG})
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
@@ -1,5 +1,4 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
@@ -1,35 +1,29 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
include ("extract")
|
||||
include ("download_and_check")
|
||||
|
||||
function (GetNameAndUrlToDownload name url archive_name_unified archive_name_win archive_name_lin archive_name_mac)
|
||||
function (GetNameAndUrlToDownload name url archive_name_unified archive_name_win archive_name_lin archive_name_mac archive_name_android)
|
||||
if (archive_name_unified)
|
||||
set (${url} "${archive_name_unified}" PARENT_SCOPE)
|
||||
set (${name} ${archive_name_unified} PARENT_SCOPE)
|
||||
else()
|
||||
if (LINUX OR (APPLE AND NOT archive_name_mac))
|
||||
if (NOT archive_name_lin)
|
||||
return()
|
||||
endif()
|
||||
if(archive_name_lin)
|
||||
set (PLATFORM_FOLDER linux)
|
||||
set (archive_name ${archive_name_lin})
|
||||
elseif(APPLE)
|
||||
if (NOT archive_name_mac)
|
||||
return()
|
||||
endif()
|
||||
elseif(archive_name_mac)
|
||||
set (PLATFORM_FOLDER mac)
|
||||
set (archive_name ${archive_name_mac})
|
||||
else()
|
||||
#if no dependency for target platfrom skip it
|
||||
if (NOT archive_name_win)
|
||||
return()
|
||||
endif()
|
||||
elseif(archive_name_android)
|
||||
set (PLATFORM_FOLDER android)
|
||||
set (archive_name ${archive_name_android})
|
||||
elseif(archive_name_win)
|
||||
set (PLATFORM_FOLDER windows)
|
||||
set (archive_name ${archive_name_win})
|
||||
else()
|
||||
return()
|
||||
endif()
|
||||
|
||||
set (${name} ${archive_name} PARENT_SCOPE)
|
||||
@@ -38,17 +32,18 @@ function (GetNameAndUrlToDownload name url archive_name_unified archive_name_win
|
||||
endfunction(GetNameAndUrlToDownload)
|
||||
|
||||
#download from paltform specific folder from share server
|
||||
function (DownloadAndExtractPlatformSpecific
|
||||
component
|
||||
archive_name_unified
|
||||
archive_name_win
|
||||
archive_name_lin
|
||||
archive_name_mac
|
||||
unpacked_path
|
||||
function (DownloadAndExtractPlatformSpecific
|
||||
component
|
||||
archive_name_unified
|
||||
archive_name_win
|
||||
archive_name_lin
|
||||
archive_name_mac
|
||||
archive_name_android
|
||||
unpacked_path
|
||||
result_path
|
||||
folder)
|
||||
|
||||
GetNameAndUrlToDownload(archive_name RELATIVE_URL ${archive_name_unified} ${archive_name_win} ${archive_name_lin} ${archive_name_mac} )
|
||||
GetNameAndUrlToDownload(archive_name RELATIVE_URL ${archive_name_unified} ${archive_name_win} ${archive_name_lin} ${archive_name_mac} ${archive_name_android} )
|
||||
if (NOT archive_name OR NOT RELATIVE_URL)
|
||||
return()
|
||||
endif()
|
||||
@@ -62,35 +57,35 @@ function (DownloadAndExtract component archive_name unpacked_path result_path fo
|
||||
set (RELATIVE_URL "${archive_name}")
|
||||
set(fattal TRUE)
|
||||
CheckOrDownloadAndExtract(${component} ${RELATIVE_URL} ${archive_name} ${unpacked_path} result_path2 ${folder} ${fattal} result TRUE)
|
||||
|
||||
|
||||
if (NOT ${result})
|
||||
DownloadAndExtractPlatformSpecific(${component} ${archive_name} ${archive_name} ${archive_name} ${unpacked_path} ${result_path2} ${folder})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set (${result_path} ${result_path2} PARENT_SCOPE)
|
||||
|
||||
endfunction(DownloadAndExtract)
|
||||
|
||||
|
||||
function (DownloadAndExtractInternal URL archive_path unpacked_path folder fattal result123)
|
||||
function (DownloadAndExtractInternal URL archive_path unpacked_path folder fattal resultExt)
|
||||
set (status "ON")
|
||||
DownloadAndCheck(${URL} ${archive_path} ${fattal} result1)
|
||||
if ("${result1}" STREQUAL "ARCHIVE_DOWNLOAD_FAIL")
|
||||
#check alternative url as well
|
||||
set (status "OFF")
|
||||
file(REMOVE_RECURSE "${archive_path}")
|
||||
file(REMOVE_RECURSE "${archive_path}")
|
||||
endif()
|
||||
|
||||
if ("${result1}" STREQUAL "CHECKSUM_DOWNLOAD_FAIL" OR "${result1}" STREQUAL "HASH_MISMATCH")
|
||||
set(status FALSE)
|
||||
file(REMOVE_RECURSE "${archive_path}")
|
||||
file(REMOVE_RECURSE "${archive_path}")
|
||||
endif()
|
||||
|
||||
if("${status}" STREQUAL "ON")
|
||||
ExtractWithVersion(${URL} ${archive_path} ${unpacked_path} ${folder} result)
|
||||
endif()
|
||||
|
||||
set (result123 ${status} PARENT_SCOPE)
|
||||
|
||||
set (${resultExt} ${status} PARENT_SCOPE)
|
||||
|
||||
endfunction(DownloadAndExtractInternal)
|
||||
|
||||
@@ -99,36 +94,49 @@ function (ExtractWithVersion URL archive_path unpacked_path folder result)
|
||||
debug_message("ExtractWithVersion : ${archive_path} : ${unpacked_path}")
|
||||
extract(${archive_path} ${unpacked_path} ${folder} status)
|
||||
#dont need archive actually after unpacking
|
||||
file(REMOVE_RECURSE "${archive_path}")
|
||||
file(REMOVE_RECURSE "${archive_path}")
|
||||
if (${status})
|
||||
set (version_file ${unpacked_path}/ie_dependency.info)
|
||||
file(WRITE ${version_file} ${URL})
|
||||
else()
|
||||
file(REMOVE_RECURSE "${unpacked_path}")
|
||||
message(FATAL_ERROR "Failed to extract the archive from ${URL}, archive ${archive_path} to folder ${unpacked_path}")
|
||||
endif()
|
||||
set (${result} ${status} PARENT_SCOPE)
|
||||
set (${result} ${status} PARENT_SCOPE)
|
||||
endfunction (ExtractWithVersion)
|
||||
|
||||
function (DownloadOrExtractInternal URL archive_path unpacked_path folder fattal result123)
|
||||
function (DownloadOrExtractInternal URL archive_path unpacked_path folder fattal resultExt)
|
||||
debug_message("checking wether archive downloaded : ${archive_path}")
|
||||
|
||||
set (downloadStatus "NOTOK")
|
||||
if (NOT EXISTS ${archive_path})
|
||||
DownloadAndExtractInternal(${URL} ${archive_path} ${unpacked_path} ${folder} ${fattal} result)
|
||||
if (${result})
|
||||
set (downloadStatus "OK")
|
||||
endif()
|
||||
else()
|
||||
|
||||
if (ENABLE_UNSAFE_LOCATIONS)
|
||||
ExtractWithVersion(${URL} ${archive_path} ${unpacked_path} ${folder} result)
|
||||
if(NOT ${result})
|
||||
DownloadAndExtractInternal(${URL} ${archive_path} ${unpacked_path} ${folder} ${fattal} result)
|
||||
if (${result})
|
||||
set (downloadStatus "OK")
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
debug_message("archive found on FS : ${archive_path}, however we cannot check it's checksum and think that it is invalid")
|
||||
file(REMOVE_RECURSE "${archive_path}")
|
||||
DownloadAndExtractInternal(${URL} ${archive_path} ${unpacked_path} ${folder} ${fattal} result)
|
||||
endif()
|
||||
if (${result})
|
||||
set (downloadStatus "OK")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT ${downloadStatus} STREQUAL "OK")
|
||||
message(FATAL_ERROR "Failed to download and extract the archive from ${URL}, archive ${archive_path} to folder ${unpacked_path}")
|
||||
endif()
|
||||
|
||||
if (NOT ${result})
|
||||
message(FATAL_ERROR "error: extract of '${archive_path}' failed")
|
||||
@@ -138,7 +146,7 @@ endfunction(DownloadOrExtractInternal)
|
||||
|
||||
file(REMOVE ${CMAKE_BINARY_DIR}/dependencies_64.txt)
|
||||
|
||||
function (CheckOrDownloadAndExtract component RELATIVE_URL archive_name unpacked_path result_path folder fattal result123 use_alternatives)
|
||||
function (CheckOrDownloadAndExtract component RELATIVE_URL archive_name unpacked_path result_path folder fattal resultExt use_alternatives)
|
||||
set (archive_path ${TEMP}/download/${archive_name})
|
||||
set (status "ON")
|
||||
set (on_master FALSE)
|
||||
@@ -146,7 +154,7 @@ function (CheckOrDownloadAndExtract component RELATIVE_URL archive_name unpacked
|
||||
if(DEFINED ENV{IE_PATH_TO_DEPS})
|
||||
set(URL "$ENV{IE_PATH_TO_DEPS}/${RELATIVE_URL}")
|
||||
else()
|
||||
set(URL "https://download.01.org/opencv/2019/openvinotoolkit/R1/inference_engine/${RELATIVE_URL}")
|
||||
set(URL "https://download.01.org/opencv/2020/openvinotoolkit/2020.3/inference_engine/${RELATIVE_URL}")
|
||||
endif()
|
||||
|
||||
#no message on recursive calls
|
||||
@@ -160,7 +168,7 @@ function (CheckOrDownloadAndExtract component RELATIVE_URL archive_name unpacked
|
||||
|
||||
if (NOT EXISTS ${unpacked_path})
|
||||
DownloadOrExtractInternal(${URL} ${archive_path} ${unpacked_path} ${folder} ${fattal} status)
|
||||
else(NOT EXISTS ${unpacked_path})
|
||||
else(NOT EXISTS ${unpacked_path})
|
||||
#path exists, so we would like to check what was unpacked version
|
||||
set (version_file ${unpacked_path}/ie_dependency.info)
|
||||
|
||||
@@ -177,7 +185,7 @@ function (CheckOrDownloadAndExtract component RELATIVE_URL archive_name unpacked
|
||||
"\trm -rf ${unpacked_path}\n"
|
||||
"and rerun cmake.\n"
|
||||
"If your dependency is fine, then execute:\n\techo ${URL} > ${unpacked_path}/ie_dependency.info\n")
|
||||
# file(REMOVE_RECURSE "${unpacked_path}")
|
||||
# file(REMOVE_RECURSE "${unpacked_path}")
|
||||
# DownloadOrExtractInternal(${URL} ${archive_path} ${unpacked_path} ${fattal} status)
|
||||
else()
|
||||
if (EXISTS ${version_file})
|
||||
@@ -197,11 +205,11 @@ function (CheckOrDownloadAndExtract component RELATIVE_URL archive_name unpacked
|
||||
string(REPLACE ${TEMP} ${ALTERNATIVE_PATH} archive_path ${archive_path})
|
||||
|
||||
debug_message("dependency different: use local path for fetching updated version: ${alternative_path}")
|
||||
CheckOrDownloadAndExtract(${component} ${RELATIVE_URL} ${archive_name} ${unpacked_path} ${result_path} ${folder} ${fattal} ${result123} FALSE)
|
||||
CheckOrDownloadAndExtract(${component} ${RELATIVE_URL} ${archive_name} ${unpacked_path} ${result_path} ${folder} ${fattal} ${resultExt} FALSE)
|
||||
|
||||
else()
|
||||
debug_message("dependency updated: download it again")
|
||||
file(REMOVE_RECURSE "${unpacked_path}")
|
||||
file(REMOVE_RECURSE "${unpacked_path}")
|
||||
DownloadOrExtractInternal(${URL} ${archive_path} ${unpacked_path} ${folder} ${fattal} status)
|
||||
endif()
|
||||
endif ()
|
||||
@@ -209,11 +217,10 @@ function (CheckOrDownloadAndExtract component RELATIVE_URL archive_name unpacked
|
||||
endif()
|
||||
|
||||
if (${use_alternatives} OR ${on_master})
|
||||
set (${result123} "${status}" PARENT_SCOPE)
|
||||
set (${resultExt} "${status}" PARENT_SCOPE)
|
||||
set (${result_path} ${unpacked_path} PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
endfunction(CheckOrDownloadAndExtract)
|
||||
|
||||
|
||||
endfunction(CheckOrDownloadAndExtract)
|
||||
@@ -1,11 +1,9 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
function (extract archive_path unpacked_path folder result)
|
||||
# Slurped from a generated extract-TARGET.cmake file.
|
||||
if (NOT EXISTS ${unpacked_path})
|
||||
get_filename_component(unpacked_dir ${unpacked_path} DIRECTORY)
|
||||
|
||||
file(MAKE_DIRECTORY ${unpacked_path})
|
||||
@@ -41,6 +39,5 @@ function (extract archive_path unpacked_path folder result)
|
||||
else()
|
||||
set(${result} 1 PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
endfunction (extract)
|
||||
40
cmake/features.cmake
Normal file
40
cmake/features.cmake
Normal file
@@ -0,0 +1,40 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
include (target_flags)
|
||||
include (options)
|
||||
|
||||
# these options are aimed to optimize build time on development system
|
||||
|
||||
if(X86_64)
|
||||
set(ENABLE_MKL_DNN_DEFAULT ON)
|
||||
else()
|
||||
set(ENABLE_MKL_DNN_DEFAULT OFF)
|
||||
endif()
|
||||
ie_option (ENABLE_MKL_DNN "MKL-DNN plugin for inference engine" ${ENABLE_MKL_DNN_DEFAULT})
|
||||
|
||||
ie_dependent_option (ENABLE_CLDNN "clDnn based plugin for inference engine" ON "WIN32 OR X86_64;NOT APPLE;NOT MINGW" OFF)
|
||||
|
||||
# FIXME: there are compiler failures with LTO and Cross-Compile toolchains. Disabling for now, but
|
||||
# this must be addressed in a proper way
|
||||
ie_dependent_option (ENABLE_LTO "Enable Link Time Optimization" OFF "LINUX OR WIN32;NOT CMAKE_CROSSCOMPILING" OFF)
|
||||
|
||||
ie_option (OS_FOLDER "create OS dedicated folder in output" OFF)
|
||||
|
||||
# FIXME: ARM cross-compiler generates several "false positive" warnings regarding __builtin_memcpy buffer overflow
|
||||
ie_dependent_option (TREAT_WARNING_AS_ERROR "Treat build warnings as errors" ON "X86 OR X86_64" OFF)
|
||||
|
||||
ie_option (ENABLE_SANITIZER "enable checking memory errors via AddressSanitizer" OFF)
|
||||
|
||||
ie_option (ENABLE_THREAD_SANITIZER "enable checking data races via ThreadSanitizer" OFF)
|
||||
|
||||
ie_dependent_option (COVERAGE "enable code coverage" OFF "CMAKE_CXX_COMPILER_ID STREQUAL GNU" OFF)
|
||||
|
||||
# Define CPU capabilities
|
||||
|
||||
ie_dependent_option (ENABLE_SSE42 "Enable SSE4.2 optimizations" ON "X86_64 OR X86" OFF)
|
||||
|
||||
ie_dependent_option (ENABLE_AVX2 "Enable AVX2 optimizations" ON "X86_64 OR X86" OFF)
|
||||
|
||||
ie_dependent_option (ENABLE_AVX512F "Enable AVX512 optimizations" ON "X86_64 OR X86" OFF)
|
||||
27
cmake/options.cmake
Normal file
27
cmake/options.cmake
Normal file
@@ -0,0 +1,27 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Usage: ie_option(<option_variable> "description" <initial value or boolean expression> [IF <condition>])
|
||||
|
||||
include (CMakeDependentOption)
|
||||
include (version)
|
||||
|
||||
macro (ie_option variable description value)
|
||||
option(${variable} "${description}" ${value})
|
||||
list(APPEND IE_OPTIONS ${variable})
|
||||
endmacro()
|
||||
|
||||
macro (ie_dependent_option variable description def_value condition fallback_value)
|
||||
cmake_dependent_option(${variable} "${description}" ${def_value} "${condition}" ${fallback_value})
|
||||
list(APPEND IE_OPTIONS ${variable})
|
||||
endmacro()
|
||||
|
||||
function (print_enabled_features)
|
||||
message(STATUS "Inference Engine enabled features: ")
|
||||
message(STATUS "")
|
||||
message(STATUS " CI_BUILD_NUMBER: ${CI_BUILD_NUMBER}")
|
||||
foreach(_var ${IE_OPTIONS})
|
||||
message(STATUS " ${_var} = ${${_var}}")
|
||||
endforeach()
|
||||
message(STATUS "")
|
||||
endfunction()
|
||||
291
cmake/os_flags.cmake
Normal file
291
cmake/os_flags.cmake
Normal file
@@ -0,0 +1,291 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
#
|
||||
# Disables deprecated warnings generation
|
||||
# Defines ie_c_cxx_deprecated varaible which contains C / C++ compiler flags
|
||||
#
|
||||
macro(disable_deprecated_warnings)
|
||||
if(WIN32)
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES Intel)
|
||||
set(ie_c_cxx_deprecated "/Qdiag-disable:1478,1786")
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
|
||||
set(ie_c_cxx_deprecated "/wd4996")
|
||||
endif()
|
||||
else()
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL Intel)
|
||||
set(ie_c_cxx_deprecated "-diag-disable=1478,1786")
|
||||
else()
|
||||
set(ie_c_cxx_deprecated "-Wno-deprecated-declarations")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT ie_c_cxx_deprecated)
|
||||
message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ie_c_cxx_deprecated}")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ie_c_cxx_deprecated}")
|
||||
endmacro()
|
||||
|
||||
#
|
||||
# Don't threat deprecated warnings as errors
|
||||
# Defines ie_c_cxx_deprecated_no_errors varaible which contains C / C++ compiler flags
|
||||
#
|
||||
macro(ie_deprecated_no_errors)
|
||||
if(WIN32)
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES Intel)
|
||||
set(ie_c_cxx_deprecated "/Qdiag-warning:1478,1786")
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
|
||||
set(ie_c_cxx_deprecated "/wd4996")
|
||||
endif()
|
||||
else()
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES Intel)
|
||||
set(ie_c_cxx_deprecated_no_errors "-diag-warning=1478,1786")
|
||||
else()
|
||||
set(ie_c_cxx_deprecated_no_errors "-Wno-error=deprecated-declarations")
|
||||
endif()
|
||||
|
||||
if(NOT ie_c_cxx_deprecated_no_errors)
|
||||
message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ie_c_cxx_deprecated_no_errors}")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ie_c_cxx_deprecated_no_errors}")
|
||||
endmacro()
|
||||
|
||||
#
|
||||
# Provides SSE4.2 compilation flags depending on an OS and a compiler
|
||||
#
|
||||
function(ie_sse42_optimization_flags flags)
|
||||
if(WIN32)
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
|
||||
# No such option for MSVC 2019
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL Intel)
|
||||
set(${flags} "/arch:SSE4.2 /QxSSE4.2" PARENT_SCOPE)
|
||||
else()
|
||||
message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}")
|
||||
endif()
|
||||
else()
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL Intel)
|
||||
set(${flags} "-msse4.2 -xSSE4.2" PARENT_SCOPE)
|
||||
else()
|
||||
set(${flags} "-msse4.2" PARENT_SCOPE)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#
|
||||
# Provides AVX2 compilation flags depending on an OS and a compiler
|
||||
#
|
||||
function(ie_avx2_optimization_flags flags)
|
||||
if(WIN32)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL Intel)
|
||||
set(${flags} "/QxCORE-AVX2" PARENT_SCOPE)
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
|
||||
set(${flags} "/arch:AVX2" PARENT_SCOPE)
|
||||
else()
|
||||
message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}")
|
||||
endif()
|
||||
else()
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL Intel)
|
||||
set(${flags} "-march=core-avx2 -xCORE-AVX2 -mtune=core-avx2" PARENT_SCOPE)
|
||||
else()
|
||||
set(${flags} "-mavx2 -mfma" PARENT_SCOPE)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#
|
||||
# Provides common AVX512 compilation flags for AVX512F instruction set support
|
||||
# depending on an OS and a compiler
|
||||
#
|
||||
function(ie_avx512_optimization_flags flags)
|
||||
if(WIN32)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL Intel)
|
||||
set(${flags} "/QxCOMMON-AVX512" PARENT_SCOPE)
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
|
||||
set(${flags} "/arch:AVX512" PARENT_SCOPE)
|
||||
else()
|
||||
message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}")
|
||||
endif()
|
||||
else()
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL Intel)
|
||||
set(${flags} "-xCOMMON-AVX512" PARENT_SCOPE)
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
|
||||
set(${flags} "-mavx512f -mfma" PARENT_SCOPE)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#
|
||||
# Enables Link Time Optimization compilation
|
||||
#
|
||||
macro(ie_enable_lto)
|
||||
if(UNIX)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto")
|
||||
# LTO causes issues with gcc 4.8.5 during cmake pthread check
|
||||
if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9)
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -flto")
|
||||
endif()
|
||||
|
||||
# modify linker and ar
|
||||
if(LINUX)
|
||||
set(CMAKE_AR "gcc-ar")
|
||||
set(CMAKE_RANLIB "gcc-ranlib")
|
||||
endif()
|
||||
elseif(WIN32)
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Release)
|
||||
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GL")
|
||||
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /GL")
|
||||
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LTCG:STATUS")
|
||||
# set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LTCG:STATUS")
|
||||
# set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /LTCG:STATUS")
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
#
|
||||
# Adds compiler flags to C / C++ sources
|
||||
#
|
||||
macro(ie_add_compiler_flags)
|
||||
foreach(flag ${ARGN})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
#
|
||||
# Compilation and linker flags
|
||||
#
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
|
||||
# to allows to override CMAKE_CXX_STANDARD from command line
|
||||
if(NOT DEFINED CMAKE_CXX_STANDARD)
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
else()
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
endif()
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
endif()
|
||||
|
||||
if(COVERAGE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
|
||||
endif()
|
||||
|
||||
if(NOT MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsigned-char")
|
||||
endif()
|
||||
|
||||
set(CMAKE_POLICY_DEFAULT_CMP0063 NEW)
|
||||
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
||||
set(CMAKE_C_VISIBILITY_PRESET hidden)
|
||||
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
|
||||
|
||||
if(WIN32)
|
||||
ie_add_compiler_flags(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS)
|
||||
ie_add_compiler_flags(/EHsc) # no asynchronous structured exception handling
|
||||
ie_add_compiler_flags(/Gy) # remove unreferenced functions: function level linking
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
|
||||
|
||||
if (TREAT_WARNING_AS_ERROR)
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES Intel)
|
||||
ie_add_compiler_flags(/WX)
|
||||
ie_add_compiler_flags(/Qdiag-warning:47,1740,1786)
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
|
||||
# ie_add_compiler_flags(/WX) # Too many warnings
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Compiler specific flags
|
||||
|
||||
ie_add_compiler_flags(/bigobj)
|
||||
|
||||
# Disable noisy warnings
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
|
||||
# C4251 needs to have dll-interface to be used by clients of class
|
||||
ie_add_compiler_flags(/wd4251)
|
||||
# C4275 non dll-interface class used as base for dll-interface class
|
||||
ie_add_compiler_flags(/wd4275)
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES Intel)
|
||||
# 161 unrecognized pragma
|
||||
# 177 variable was declared but never referenced
|
||||
# 556 not matched type of assigned function pointer
|
||||
# 1744: field of class type without a DLL interface used in a class with a DLL interface
|
||||
# 2586 decorated name length exceeded, name was truncated
|
||||
# 2651: attribute does not apply to any entity
|
||||
# 3180 unrecognized OpenMP pragma
|
||||
# 11075: To get full report use -Qopt-report:4 -Qopt-report-phase ipo
|
||||
# 15335 was not vectorized: vectorization possible but seems inefficient. Use vector always directive or /Qvec-threshold0 to override
|
||||
ie_add_compiler_flags(/Qdiag-disable:161,177,556,1744,2586,2651,3180,11075,15335)
|
||||
endif()
|
||||
|
||||
# Debug information flags
|
||||
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Z7")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Z7")
|
||||
|
||||
if(ENABLE_DEBUG_SYMBOLS)
|
||||
ie_add_compiler_flags(/Z7)
|
||||
|
||||
set(DEBUG_SYMBOLS_LINKER_FLAGS "/DEBUG")
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
# Keep default /OPT values. See /DEBUG reference for details.
|
||||
set(DEBUG_SYMBOLS_LINKER_FLAGS "${DEBUG_SYMBOLS_LINKER_FLAGS} /OPT:REF /OPT:ICF")
|
||||
endif()
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${DEBUG_SYMBOLS_LINKER_FLAGS}")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${DEBUG_SYMBOLS_LINKER_FLAGS}")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${DEBUG_SYMBOLS_LINKER_FLAGS}")
|
||||
endif()
|
||||
else()
|
||||
# TODO: enable for C sources as well
|
||||
# ie_add_compiler_flags(-Werror)
|
||||
if(TREAT_WARNING_AS_ERROR)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
||||
endif()
|
||||
|
||||
ie_add_compiler_flags(-ffunction-sections -fdata-sections)
|
||||
ie_add_compiler_flags(-fdiagnostics-show-option)
|
||||
ie_add_compiler_flags(-Wundef)
|
||||
|
||||
# Disable noisy warnings
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
||||
ie_add_compiler_flags(-Wswitch)
|
||||
elseif(UNIX)
|
||||
ie_add_compiler_flags(-Wuninitialized -Winit-self)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
ie_add_compiler_flags(-Wno-error=switch)
|
||||
else()
|
||||
ie_add_compiler_flags(-Wmaybe-uninitialized)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||
ie_add_compiler_flags(-diag-disable=remark)
|
||||
endif()
|
||||
|
||||
# Linker flags
|
||||
|
||||
if(APPLE)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-dead_strip")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-dead_strip")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-dead_strip")
|
||||
elseif(LINUX)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections -Wl,--exclude-libs,ALL")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--gc-sections -Wl,--exclude-libs,ALL")
|
||||
endif()
|
||||
endif()
|
||||
36
cmake/sanitizer.cmake
Normal file
36
cmake/sanitizer.cmake
Normal file
@@ -0,0 +1,36 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
if (ENABLE_SANITIZER)
|
||||
set(SANITIZER_COMPILER_FLAGS "-g -fsanitize=address -fno-omit-frame-pointer")
|
||||
CHECK_CXX_COMPILER_FLAG("-fsanitize-recover=address" SANITIZE_RECOVER_SUPPORTED)
|
||||
if (SANITIZE_RECOVER_SUPPORTED)
|
||||
set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize-recover=address")
|
||||
endif()
|
||||
|
||||
set(SANITIZER_LINKER_FLAGS "-fsanitize=address")
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fuse-ld=gold")
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZER_COMPILER_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZER_COMPILER_FLAGS}")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SANITIZER_LINKER_FLAGS}")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${SANITIZER_LINKER_FLAGS}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SANITIZER_LINKER_FLAGS}")
|
||||
endif()
|
||||
|
||||
if (ENABLE_THREAD_SANITIZER)
|
||||
set(SANITIZER_COMPILER_FLAGS "-g -fsanitize=thread")
|
||||
|
||||
set(SANITIZER_LINKER_FLAGS "-fsanitize=thread")
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZER_COMPILER_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZER_COMPILER_FLAGS}")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SANITIZER_LINKER_FLAGS}")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${SANITIZER_LINKER_FLAGS}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SANITIZER_LINKER_FLAGS}")
|
||||
endif()
|
||||
45
cmake/sdl.cmake
Normal file
45
cmake/sdl.cmake
Normal file
@@ -0,0 +1,45 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
if(UNIX)
|
||||
set(IE_C_CXX_FLAGS "${IE_C_CXX_FLAGS} -Wformat -Wformat-security")
|
||||
if (NOT ENABLE_SANITIZER)
|
||||
# ASan does not support fortification https://github.com/google/sanitizers/issues/247
|
||||
set(IE_C_CXX_FLAGS "${IE_C_CXX_FLAGS} -D_FORTIFY_SOURCE=2")
|
||||
endif()
|
||||
if(NOT APPLE)
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -pie")
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -z noexecstack -z relro -z now")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} -z noexecstack -z relro -z now")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -z noexecstack -z relro -z now")
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
|
||||
set(IE_C_CXX_FLAGS "${IE_C_CXX_FLAGS} -fstack-protector-all")
|
||||
else()
|
||||
set(IE_C_CXX_FLAGS "${IE_C_CXX_FLAGS} -fstack-protector-strong")
|
||||
endif()
|
||||
if (NOT ENABLE_SANITIZER)
|
||||
set(IE_C_CXX_FLAGS "${IE_C_CXX_FLAGS} -s")
|
||||
endif()
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set(IE_C_CXX_FLAGS "${IE_C_CXX_FLAGS} -fstack-protector-all")
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||
if (NOT ENABLE_SANITIZER)
|
||||
set(IE_C_CXX_FLAGS "${IE_C_CXX_FLAGS} -Wl,--strip-all")
|
||||
endif()
|
||||
set(IE_C_CXX_FLAGS "${IE_C_CXX_FLAGS} -fstack-protector-strong")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -z noexecstack -z relro -z now")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} -z noexecstack -z relro -z now")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -z noexecstack -z relro -z now")
|
||||
endif()
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
|
||||
set(IE_C_CXX_FLAGS "${IE_C_CXX_FLAGS} /sdl")
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${IE_C_CXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${IE_C_CXX_FLAGS}")
|
||||
endif()
|
||||
35
cmake/target_flags.cmake
Normal file
35
cmake/target_flags.cmake
Normal file
@@ -0,0 +1,35 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Target system specific flags
|
||||
|
||||
if(CMAKE_CL_64)
|
||||
set(MSVC64 ON)
|
||||
endif()
|
||||
|
||||
if(WIN32 AND CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine
|
||||
OUTPUT_VARIABLE OPENVINO_GCC_TARGET_MACHINE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(OPENVINO_GCC_TARGET_MACHINE MATCHES "amd64|x86_64|AMD64")
|
||||
set(MINGW64 ON)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(MSVC64 OR MINGW64)
|
||||
set(X86_64 ON)
|
||||
elseif(MINGW OR (MSVC AND NOT CMAKE_CROSSCOMPILING))
|
||||
set(X86 ON)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*")
|
||||
set(X86_64 ON)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686.*|i386.*|x86.*|amd64.*|AMD64.*")
|
||||
set(X86 ON)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm.*|ARM.*)")
|
||||
set(ARM ON)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)")
|
||||
set(AARCH64 ON)
|
||||
endif()
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
set(LINUX ON)
|
||||
endif()
|
||||
@@ -1,12 +1,11 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
function (branchName VAR)
|
||||
execute_process(
|
||||
COMMAND git rev-parse --abbrev-ref HEAD
|
||||
WORKING_DIRECTORY ${IE_MAIN_SOURCE_DIR}
|
||||
WORKING_DIRECTORY ${OpenVINO_MAIN_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_BRANCH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
set (${VAR} ${GIT_BRANCH} PARENT_SCOPE)
|
||||
@@ -15,7 +14,7 @@ endfunction()
|
||||
function (commitHash VAR)
|
||||
execute_process(
|
||||
COMMAND git rev-parse HEAD
|
||||
WORKING_DIRECTORY ${IE_MAIN_SOURCE_DIR}
|
||||
WORKING_DIRECTORY ${OpenVINO_MAIN_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_COMMIT_HASH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
set (${VAR} ${GIT_COMMIT_HASH} PARENT_SCOPE)
|
||||
53
cmake/whole_archive.cmake
Normal file
53
cmake/whole_archive.cmake
Normal file
@@ -0,0 +1,53 @@
|
||||
# Copyright (C) 2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
#[[
|
||||
function links static library without removing any symbol from it.
|
||||
|
||||
ieTargetLinkWholeArchive(<target name> <lib1> [<lib2> ...])
|
||||
Example:
|
||||
ieTargetLinkWholeArchive("MyriadFunctionalTests" "CommonLib" "AnotherLib")
|
||||
|
||||
#]]
|
||||
|
||||
function(ieTargetLinkWholeArchive targetName)
|
||||
set(libs)
|
||||
foreach(staticLib ${ARGN})
|
||||
if (MSVC)
|
||||
# CMake does not support generator expression in LINK_FLAGS, so we workaround it a little bit:
|
||||
# passing same static library as normal link (to get build deps working, and includes too), than using WHOLEARCHIVE option
|
||||
# it's important here to not use slash '/' for option !
|
||||
if (CMAKE_GENERATOR MATCHES "Visual Studio")
|
||||
# MSBuild is unhappy when parsing double quotes in combination with WHOLEARCHIVE flag.
|
||||
# remove quotes from path - so build path with spaces not supported, but it's better than nothing.
|
||||
list(APPEND libs ${staticLib}
|
||||
"-WHOLEARCHIVE:$<TARGET_FILE:${staticLib}>"
|
||||
)
|
||||
if (CMAKE_CURRENT_BINARY_DIR MATCHES " ")
|
||||
message(WARNING "Visual Studio CMake generator may cause problems if your build directory contains spaces. "
|
||||
"Remove spaces from path or select different generator.")
|
||||
endif()
|
||||
else()
|
||||
list(APPEND libs ${staticLib}
|
||||
"-WHOLEARCHIVE:\"$<TARGET_FILE:${staticLib}>\""
|
||||
)
|
||||
endif()
|
||||
elseif(APPLE)
|
||||
list(APPEND libs
|
||||
"-Wl,-all_load"
|
||||
${staticLib}
|
||||
"-Wl,-noall_load"
|
||||
)
|
||||
else()
|
||||
list(APPEND libs
|
||||
"-Wl,--whole-archive"
|
||||
${staticLib}
|
||||
"-Wl,--no-whole-archive"
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
if (libs)
|
||||
target_link_libraries(${targetName} PRIVATE ${libs})
|
||||
endif()
|
||||
endfunction()
|
||||
47
docs/CMakeLists.txt
Normal file
47
docs/CMakeLists.txt
Normal file
@@ -0,0 +1,47 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
if(NOT ENABLE_DOCKER)
|
||||
add_subdirectory(examples)
|
||||
# Detect nGraph
|
||||
find_package(ngraph QUIET)
|
||||
if(NOT ngraph_FOUND)
|
||||
set(ngraph_DIR ${CMAKE_BINARY_DIR}/ngraph)
|
||||
endif()
|
||||
# Detect InferenceEngine
|
||||
find_package(InferenceEngine QUIET)
|
||||
if(NOT InferenceEngine_FOUND)
|
||||
set(InferenceEngine_DIR ${CMAKE_BINARY_DIR})
|
||||
endif()
|
||||
add_subdirectory(template_extension)
|
||||
endif()
|
||||
|
||||
# OpenVINO docs
|
||||
|
||||
set(OPENVINO_DOCS_PATH "" CACHE PATH "Path to openvino-documentation local repository")
|
||||
set(args "")
|
||||
|
||||
if(OPENVINO_DOCS_PATH)
|
||||
set(args "${args} ovinodoc_path:${OPENVINO_DOCS_PATH}")
|
||||
endif()
|
||||
|
||||
file(GLOB_RECURSE docs_files "${OpenVINO_MAIN_SOURCE_DIR}/docs")
|
||||
file(GLOB_RECURSE include_files "${OpenVINO_MAIN_SOURCE_DIR}/inference-engine/include")
|
||||
file(GLOB_RECURSE ovino_files "${OPENVINO_DOCS_PATH}")
|
||||
|
||||
add_custom_target(ie_docs
|
||||
COMMAND ./build_docs.sh ${args}
|
||||
WORKING_DIRECTORY "${OpenVINO_MAIN_SOURCE_DIR}/docs/build_documentation"
|
||||
COMMENT "Generating OpenVINO documentation"
|
||||
SOURCES ${docs_files} ${include_files} ${ovino_files}
|
||||
VERBATIM)
|
||||
|
||||
find_program(browser NAMES xdg-open)
|
||||
if(browser)
|
||||
add_custom_target(ie_docs_open
|
||||
COMMAND ${browser} "${OpenVINO_MAIN_SOURCE_DIR}/doc/html/index.html"
|
||||
DEPENDS ie_docs
|
||||
COMMENT "Open OpenVINO documentation"
|
||||
VERBATIM)
|
||||
endif()
|
||||
14
docs/examples/CMakeLists.txt
Normal file
14
docs/examples/CMakeLists.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
set(TARGET_NAME ie_docs_examples)
|
||||
|
||||
file(GLOB SOURCES *.cpp)
|
||||
|
||||
add_library(ie_docs_examples STATIC ${SOURCES})
|
||||
|
||||
target_link_libraries(${TARGET_NAME} PRIVATE inference_engine_plugin_api)
|
||||
|
||||
#add_cpplint_target(${TARGET_NAME}_cpplint FOR_TARGETS ${TARGET_NAME})
|
||||
#add_clang_format_target(clang_format_${TARGET_NAME} FOR_TARGETS ${TARGET_NAME})
|
||||
68
docs/examples/example_async_infer_request.cpp
Normal file
68
docs/examples/example_async_infer_request.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
// Copyright (C) 2018-2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <threading/ie_itask_executor.hpp>
|
||||
#include <cpp_interfaces/impl/ie_infer_async_request_thread_safe_default.hpp>
|
||||
#include <memory>
|
||||
|
||||
using namespace InferenceEngine;
|
||||
|
||||
class AcceleratorSyncRequest : public InferRequestInternal {
|
||||
public:
|
||||
using Ptr = std::shared_ptr<AcceleratorSyncRequest>;
|
||||
|
||||
void Preprocess();
|
||||
void WriteToDevice();
|
||||
void RunOnDevice();
|
||||
void ReadFromDevice();
|
||||
void PostProcess();
|
||||
};
|
||||
|
||||
// ! [async_infer_request:define_pipeline]
|
||||
// Inherits from AsyncInferRequestThreadSafeDefault
|
||||
class AcceleratorAsyncInferRequest : public AsyncInferRequestThreadSafeDefault {
|
||||
// Store the pointer to the synchronous request and five executors
|
||||
AcceleratorAsyncInferRequest(const AcceleratorSyncRequest::Ptr& syncRequest,
|
||||
const ITaskExecutor::Ptr& preprocessExecutor,
|
||||
const ITaskExecutor::Ptr& writeToDeviceExecutor,
|
||||
const ITaskExecutor::Ptr& runOnDeviceExecutor,
|
||||
const ITaskExecutor::Ptr& readFromDeviceExecutor,
|
||||
const ITaskExecutor::Ptr& postProcessExecutor) :
|
||||
AsyncInferRequestThreadSafeDefault(syncRequest, nullptr, nullptr),
|
||||
_accSyncRequest{syncRequest},
|
||||
_preprocessExecutor{preprocessExecutor},
|
||||
_writeToDeviceExecutor{writeToDeviceExecutor},
|
||||
_runOnDeviceExecutor{runOnDeviceExecutor},
|
||||
_readFromDeviceExecutor{readFromDeviceExecutor},
|
||||
_postProcessExecutor{postProcessExecutor}
|
||||
{
|
||||
// Five pipeline stages of synchronous infer request are run by different executors
|
||||
_pipeline = {
|
||||
{ _preprocessExecutor , [this] {
|
||||
_accSyncRequest->Preprocess();
|
||||
}},
|
||||
{ _writeToDeviceExecutor , [this] {
|
||||
_accSyncRequest->WriteToDevice();
|
||||
}},
|
||||
{ _runOnDeviceExecutor , [this] {
|
||||
_accSyncRequest->RunOnDevice();
|
||||
}},
|
||||
{ _readFromDeviceExecutor , [this] {
|
||||
_accSyncRequest->ReadFromDevice();
|
||||
}},
|
||||
{ _postProcessExecutor , [this] {
|
||||
_accSyncRequest->PostProcess();
|
||||
}},
|
||||
};
|
||||
}
|
||||
|
||||
// As all stages use _accSyncRequest member we should wait for all stages tasks before the destructor destroy this member.
|
||||
~AcceleratorAsyncInferRequest() {
|
||||
StopAndWait();
|
||||
}
|
||||
|
||||
AcceleratorSyncRequest::Ptr _accSyncRequest;
|
||||
ITaskExecutor::Ptr _preprocessExecutor, _writeToDeviceExecutor, _runOnDeviceExecutor, _readFromDeviceExecutor, _postProcessExecutor;
|
||||
};
|
||||
// ! [async_infer_request:define_pipeline]
|
||||
53
docs/examples/example_itask_executor.cpp
Normal file
53
docs/examples/example_itask_executor.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
// Copyright (C) 2018-2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <threading/ie_cpu_streams_executor.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <future>
|
||||
#include <iostream>
|
||||
|
||||
void example1() {
|
||||
// ! [itask_executor:define_pipeline]
|
||||
// std::promise is move only object so to satisfy copy callable constraint we use std::shared_ptr
|
||||
auto promise = std::make_shared<std::promise<void>>();
|
||||
// When the promise is created we can get std::future to wait the result
|
||||
auto future = promise->get_future();
|
||||
// Rather simple task
|
||||
InferenceEngine::Task task = [] {std::cout << "Some Output" << std::endl; };
|
||||
// Create an executor
|
||||
InferenceEngine::ITaskExecutor::Ptr taskExecutor = std::make_shared<InferenceEngine::CPUStreamsExecutor>();
|
||||
if (taskExecutor == nullptr) {
|
||||
// ProcessError(e);
|
||||
return;
|
||||
}
|
||||
// We capture the task and the promise. When the task is executed in the task executor context
|
||||
// we munually call std::promise::set_value() method
|
||||
taskExecutor->run([task, promise] {
|
||||
std::exception_ptr currentException;
|
||||
try {
|
||||
task();
|
||||
} catch(...) {
|
||||
// If there is some exceptions store the pointer to current exception
|
||||
currentException = std::current_exception();
|
||||
}
|
||||
|
||||
if (nullptr == currentException) {
|
||||
promise->set_value(); // <-- If there is no problems just call std::promise::set_value()
|
||||
} else {
|
||||
promise->set_exception(currentException); // <-- If there is an exception forward it to std::future object
|
||||
}
|
||||
});
|
||||
// To wait the task completion we call std::future::wait method
|
||||
future.wait(); // The current thread will be blocked here and wait when std::promise::set_value()
|
||||
// or std::promise::set_exception() method will be called.
|
||||
|
||||
// If the future store the exception it will be rethrown in std::future::get method
|
||||
try {
|
||||
future.get();
|
||||
} catch(std::exception& /*e*/) {
|
||||
// ProcessError(e);
|
||||
}
|
||||
// ! [itask_executor:define_pipeline]
|
||||
}
|
||||
18
docs/template_extension/CMakeLists.txt
Normal file
18
docs/template_extension/CMakeLists.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
# Copyright (C) 2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
# [cmake:extension]
|
||||
set(TARGET_NAME "template_extension")
|
||||
|
||||
find_package(ngraph REQUIRED)
|
||||
find_package(InferenceEngine REQUIRED)
|
||||
|
||||
file(GLOB_RECURSE SRC *.cpp)
|
||||
|
||||
add_library(${TARGET_NAME} SHARED ${SRC})
|
||||
|
||||
target_compile_definitions(${TARGET_NAME} PRIVATE IMPLEMENT_INFERENCE_EXTENSION_API)
|
||||
target_link_libraries(${TARGET_NAME} PRIVATE ${InferenceEngine_LIBRARIES}
|
||||
${NGRAPH_LIBRARIES})
|
||||
# [cmake:extension]
|
||||
124
docs/template_extension/cpu_kernel.cpp
Normal file
124
docs/template_extension/cpu_kernel.cpp
Normal file
@@ -0,0 +1,124 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
#include "cpu_kernel.hpp"
|
||||
#include "op.hpp"
|
||||
#include <details/ie_exception.hpp>
|
||||
#include <ie_layouts.h>
|
||||
|
||||
using namespace TemplateExtension;
|
||||
|
||||
//! [cpu_implementation:ctor]
|
||||
OpImplementation::OpImplementation(const std::shared_ptr<ngraph::Node> &node) {
|
||||
try {
|
||||
auto castedNode = std::dynamic_pointer_cast<Operation>(node);
|
||||
if (!castedNode)
|
||||
THROW_IE_EXCEPTION << "Cannot create implementation for unknown operation!";
|
||||
if (castedNode->inputs().size() != 1 || castedNode->outputs().size() != 1)
|
||||
THROW_IE_EXCEPTION << "Cannot create implementation for operation with incorrect number of inputs or outputs!";
|
||||
if (castedNode->get_input_partial_shape(0).is_dynamic() || castedNode->get_output_partial_shape(0).is_dynamic())
|
||||
THROW_IE_EXCEPTION << "Cannot create implementation for op with dynamic shapes!";
|
||||
if (castedNode->get_input_shape(0).size() != 4 || castedNode->get_output_shape(0).size() != 4)
|
||||
THROW_IE_EXCEPTION << "Operation supports only 4d tensors for input and output.";
|
||||
if (castedNode->get_input_element_type(0) != ngraph::element::f32 || castedNode->get_output_element_type(0) != ngraph::element::f32)
|
||||
THROW_IE_EXCEPTION << "Operation supports only FP32 tensors.";
|
||||
add = castedNode->getAddAttr();
|
||||
} catch (InferenceEngine::details::InferenceEngineException& ex) {
|
||||
error = ex.what();
|
||||
}
|
||||
}
|
||||
//! [cpu_implementation:ctor]
|
||||
|
||||
//! [cpu_implementation:getSupportedConfigurations]
|
||||
InferenceEngine::StatusCode OpImplementation::getSupportedConfigurations(std::vector<InferenceEngine::LayerConfig> &conf,
|
||||
InferenceEngine::ResponseDesc *resp) noexcept {
|
||||
auto createConfig = [](const InferenceEngine::SizeVector inShape, const InferenceEngine::SizeVector& outShape, bool planar) {
|
||||
InferenceEngine::LayerConfig config;
|
||||
config.dynBatchSupport = false;
|
||||
InferenceEngine::DataConfig inData;
|
||||
InferenceEngine::DataConfig outData;
|
||||
InferenceEngine::SizeVector order = {0, 1, 2, 3};
|
||||
// Allow any offset before data
|
||||
size_t offset((std::numeric_limits<size_t>::max)());
|
||||
if (planar) {
|
||||
inData.desc = InferenceEngine::TensorDesc(InferenceEngine::Precision::FP32, inShape, {inShape, order, offset});
|
||||
config.inConfs.push_back(inData);
|
||||
outData.desc = InferenceEngine::TensorDesc(InferenceEngine::Precision::FP32, outShape, {outShape, order, offset});
|
||||
config.outConfs.push_back(outData);
|
||||
} else {
|
||||
// Add blocked (nChw8c) format
|
||||
auto div_up = [](const int a, const int b) -> int {
|
||||
if (!b)
|
||||
return 0;
|
||||
return (a + b - 1) / b;
|
||||
};
|
||||
|
||||
order.push_back(1);
|
||||
InferenceEngine::SizeVector inBlkDims = inShape;
|
||||
inBlkDims[1] = div_up(inBlkDims[1], 8);
|
||||
inBlkDims.push_back(8);
|
||||
InferenceEngine::SizeVector outBlkDims = outShape;
|
||||
outBlkDims[1] = div_up(outBlkDims[1], 8);
|
||||
outBlkDims.push_back(8);
|
||||
inData.desc = InferenceEngine::TensorDesc(InferenceEngine::Precision::FP32, inShape, {inBlkDims, order, offset});
|
||||
config.inConfs.push_back(inData);
|
||||
outData.desc = InferenceEngine::TensorDesc(InferenceEngine::Precision::FP32, outShape, {outBlkDims, order, offset});
|
||||
config.outConfs.push_back(outData);
|
||||
}
|
||||
return config;
|
||||
};
|
||||
if (!error.empty()) {
|
||||
if (resp) {
|
||||
strncpy(resp->msg, error.c_str(), sizeof(resp->msg) - 1);
|
||||
resp->msg[sizeof(resp->msg)-1] = 0;
|
||||
}
|
||||
return InferenceEngine::GENERAL_ERROR;
|
||||
}
|
||||
// Add planar format
|
||||
conf.emplace_back(createConfig(inShape, outShape, true));
|
||||
// Add blocked format nChw8c
|
||||
conf.emplace_back(createConfig(inShape, outShape, false));
|
||||
return InferenceEngine::OK;
|
||||
}
|
||||
//! [cpu_implementation:getSupportedConfigurations]
|
||||
|
||||
//! [cpu_implementation:init]
|
||||
InferenceEngine::StatusCode OpImplementation::init(InferenceEngine::LayerConfig &config, InferenceEngine::ResponseDesc *resp) noexcept {
|
||||
try {
|
||||
if (config.inConfs.size() != 1 || config.outConfs.size() != 1) {
|
||||
THROW_IE_EXCEPTION << "Operation cannot be initialized with incorrect number of inputs/outputs!";
|
||||
}
|
||||
|
||||
if (config.inConfs[0].desc.getDims().size() != 4 || config.outConfs[0].desc.getDims().size() != 4) {
|
||||
THROW_IE_EXCEPTION << "Operation can be initialized only with 4d input/output tensors!";
|
||||
}
|
||||
|
||||
if (config.outConfs[0].desc.getPrecision() != InferenceEngine::Precision::FP32 ||
|
||||
config.inConfs[0].desc.getPrecision() != InferenceEngine::Precision::FP32) {
|
||||
THROW_IE_EXCEPTION << "Operation supports only FP32 precisions!";
|
||||
}
|
||||
} catch (InferenceEngine::details::InferenceEngineException& ex) {
|
||||
if (resp) {
|
||||
strncpy(resp->msg, error.c_str(), sizeof(resp->msg) - 1);
|
||||
resp->msg[sizeof(resp->msg)-1] = 0;
|
||||
}
|
||||
return InferenceEngine::GENERAL_ERROR;
|
||||
}
|
||||
|
||||
return InferenceEngine::OK;
|
||||
}
|
||||
//! [cpu_implementation:init]
|
||||
|
||||
//! [cpu_implementation:execute]
|
||||
InferenceEngine::StatusCode OpImplementation::execute(std::vector<InferenceEngine::Blob::Ptr> &inputs,
|
||||
std::vector<InferenceEngine::Blob::Ptr> &outputs,
|
||||
InferenceEngine::ResponseDesc *resp) noexcept {
|
||||
const float* src_data = inputs[0]->cbuffer().as<const float *>() + inputs[0]->getTensorDesc().getBlockingDesc().getOffsetPadding();
|
||||
float *dst_data = outputs[0]->buffer().as<float *>() + outputs[0]->getTensorDesc().getBlockingDesc().getOffsetPadding();
|
||||
|
||||
for (size_t i = 0; i < inputs[0]->size(); i++) {
|
||||
dst_data[i] = src_data[i] + add;
|
||||
}
|
||||
return InferenceEngine::OK;
|
||||
}
|
||||
//! [cpu_implementation:execute]
|
||||
31
docs/template_extension/cpu_kernel.hpp
Normal file
31
docs/template_extension/cpu_kernel.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ie_iextension.h>
|
||||
#include <ngraph/ngraph.hpp>
|
||||
|
||||
namespace TemplateExtension {
|
||||
|
||||
//! [cpu_implementation:header]
|
||||
class OpImplementation : public InferenceEngine::ILayerExecImpl {
|
||||
public:
|
||||
explicit OpImplementation(const std::shared_ptr<ngraph::Node>& node);
|
||||
InferenceEngine::StatusCode getSupportedConfigurations(std::vector<InferenceEngine::LayerConfig> &conf,
|
||||
InferenceEngine::ResponseDesc *resp) noexcept override;
|
||||
InferenceEngine::StatusCode init(InferenceEngine::LayerConfig &config,
|
||||
InferenceEngine::ResponseDesc *resp) noexcept override;
|
||||
InferenceEngine::StatusCode execute(std::vector<InferenceEngine::Blob::Ptr> &inputs,
|
||||
std::vector<InferenceEngine::Blob::Ptr> &outputs,
|
||||
InferenceEngine::ResponseDesc *resp) noexcept override;
|
||||
private:
|
||||
int64_t add;
|
||||
ngraph::Shape inShape;
|
||||
ngraph::Shape outShape;
|
||||
std::string error;
|
||||
};
|
||||
//! [cpu_implementation:header]
|
||||
|
||||
} // namespace TemplateExtension
|
||||
73
docs/template_extension/extension.cpp
Normal file
73
docs/template_extension/extension.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
#include "extension.hpp"
|
||||
#include "cpu_kernel.hpp"
|
||||
#include "op.hpp"
|
||||
#include <ngraph/factory.hpp>
|
||||
#include <ngraph/opsets/opset.hpp>
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
using namespace TemplateExtension;
|
||||
|
||||
//! [extension:GetVersion]
|
||||
void Extension::GetVersion(const InferenceEngine::Version *&versionInfo) const noexcept {
|
||||
static InferenceEngine::Version ExtensionDescription = {
|
||||
{1, 0}, // extension API version
|
||||
"1.0",
|
||||
"template_ext" // extension description message
|
||||
};
|
||||
|
||||
versionInfo = &ExtensionDescription;
|
||||
}
|
||||
//! [extension:GetVersion]
|
||||
|
||||
//! [extension:getOpSets]
|
||||
std::map<std::string, ngraph::OpSet> Extension::getOpSets() {
|
||||
std::map<std::string, ngraph::OpSet> opsets;
|
||||
ngraph::OpSet opset;
|
||||
opset.insert<Operation>();
|
||||
opsets["custom_opset"] = opset;
|
||||
return opsets;
|
||||
}
|
||||
//! [extension:getOpSets]
|
||||
|
||||
//! [extension:getImplTypes]
|
||||
std::vector<std::string> Extension::getImplTypes(const std::shared_ptr<ngraph::Node> &node) {
|
||||
if (std::dynamic_pointer_cast<Operation>(node)) {
|
||||
return {"CPU"};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
//! [extension:getImplTypes]
|
||||
|
||||
//! [extension:getImplementation]
|
||||
InferenceEngine::ILayerImpl::Ptr Extension::getImplementation(const std::shared_ptr<ngraph::Node> &node, const std::string &implType) {
|
||||
if (std::dynamic_pointer_cast<Operation>(node) && implType == "CPU") {
|
||||
return std::make_shared<OpImplementation>(node);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
//! [extension:getImplementation]
|
||||
|
||||
//! [extension:CreateExtension]
|
||||
// Exported function
|
||||
INFERENCE_EXTENSION_API(InferenceEngine::StatusCode) InferenceEngine::CreateExtension(InferenceEngine::IExtension *&ext,
|
||||
InferenceEngine::ResponseDesc *resp) noexcept {
|
||||
try {
|
||||
ext = new Extension();
|
||||
return OK;
|
||||
} catch (std::exception &ex) {
|
||||
if (resp) {
|
||||
std::string err = ((std::string) "Couldn't create extension: ") + ex.what();
|
||||
err.copy(resp->msg, 255);
|
||||
}
|
||||
return InferenceEngine::GENERAL_ERROR;
|
||||
}
|
||||
}
|
||||
//! [extension:CreateExtension]
|
||||
31
docs/template_extension/extension.hpp
Normal file
31
docs/template_extension/extension.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ie_iextension.h>
|
||||
#include <ie_api.h>
|
||||
#include <ngraph/ngraph.hpp>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
//! [extension:header]
|
||||
namespace TemplateExtension {
|
||||
|
||||
class Extension : public InferenceEngine::IExtension {
|
||||
public:
|
||||
Extension() = default;
|
||||
void GetVersion(const InferenceEngine::Version*& versionInfo) const noexcept override;
|
||||
void Unload() noexcept override {}
|
||||
void Release() noexcept override { delete this; }
|
||||
|
||||
std::map<std::string, ngraph::OpSet> getOpSets() override;
|
||||
std::vector<std::string> getImplTypes(const std::shared_ptr<ngraph::Node>& node) override;
|
||||
InferenceEngine::ILayerImpl::Ptr getImplementation(const std::shared_ptr<ngraph::Node>& node, const std::string& implType) override;
|
||||
};
|
||||
|
||||
} // namespace TemplateExtension
|
||||
//! [extension:header]
|
||||
38
docs/template_extension/op.cpp
Normal file
38
docs/template_extension/op.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
#include "op.hpp"
|
||||
|
||||
using namespace TemplateExtension;
|
||||
|
||||
constexpr ngraph::NodeTypeInfo Operation::type_info;
|
||||
|
||||
//! [op:ctor]
|
||||
Operation::Operation(const ngraph::Output<ngraph::Node> &arg, int64_t add) : Op({arg}), add(add) {
|
||||
constructor_validate_and_infer_types();
|
||||
}
|
||||
//! [op:ctor]
|
||||
|
||||
//! [op:validate]
|
||||
void Operation::validate_and_infer_types() {
|
||||
// Operation doesn't change shapes end element type
|
||||
set_output_type(0, get_input_element_type(0), get_input_partial_shape(0));
|
||||
}
|
||||
//! [op:validate]
|
||||
|
||||
//! [op:copy]
|
||||
std::shared_ptr<ngraph::Node> Operation::copy_with_new_args(const ngraph::NodeVector &new_args) const {
|
||||
if (new_args.size() != 1) {
|
||||
throw ngraph::ngraph_error("Incorrect number of new arguments");
|
||||
}
|
||||
|
||||
return std::make_shared<Operation>(new_args.at(0), add);
|
||||
}
|
||||
//! [op:copy]
|
||||
|
||||
//! [op:visit_attributes]
|
||||
bool Operation::visit_attributes(ngraph::AttributeVisitor &visitor) {
|
||||
visitor.on_attribute("add", add);
|
||||
return true;
|
||||
}
|
||||
//! [op:visit_attributes]
|
||||
29
docs/template_extension/op.hpp
Normal file
29
docs/template_extension/op.hpp
Normal file
@@ -0,0 +1,29 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ngraph/ngraph.hpp>
|
||||
|
||||
//! [op:header]
|
||||
namespace TemplateExtension {
|
||||
|
||||
class Operation : public ngraph::op::Op {
|
||||
public:
|
||||
static constexpr ngraph::NodeTypeInfo type_info{"Template", 0};
|
||||
const ngraph::NodeTypeInfo& get_type_info() const override { return type_info; }
|
||||
|
||||
Operation() = default;
|
||||
Operation(const ngraph::Output<ngraph::Node>& arg, int64_t add);
|
||||
void validate_and_infer_types() override;
|
||||
std::shared_ptr<ngraph::Node> copy_with_new_args(const ngraph::NodeVector& new_args) const override;
|
||||
bool visit_attributes(ngraph::AttributeVisitor& visitor) override;
|
||||
int64_t getAddAttr() { return add; }
|
||||
|
||||
private:
|
||||
int64_t add;
|
||||
};
|
||||
//! [op:header]
|
||||
|
||||
} // namespace TemplateExtension
|
||||
31
docs/template_plugin/CMakeLists.txt
Normal file
31
docs/template_plugin/CMakeLists.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
# Copyright (C) 2018 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
# [cmake:main]
|
||||
if (APPLE)
|
||||
# due to https://cmake.org/cmake/help/v3.12/policy/CMP0068.html
|
||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
||||
else()
|
||||
cmake_minimum_required(VERSION 3.7.2 FATAL_ERROR)
|
||||
endif()
|
||||
|
||||
project(InferenceEngineTemplatePlugin)
|
||||
|
||||
set(IE_MAIN_TEMPLATE_PLUGIN_SOURCE_DIR ${InferenceEngineTemplatePlugin_SOURCE_DIR})
|
||||
|
||||
find_package(InferenceEngineDeveloperPackage REQUIRED)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
if(ENABLE_TESTS)
|
||||
include(CTest)
|
||||
enable_testing()
|
||||
|
||||
endif()
|
||||
# [cmake:main]
|
||||
|
||||
# install
|
||||
|
||||
# ATTENTION: uncomment to install component
|
||||
# ie_cpack(template)
|
||||
18
docs/template_plugin/README.md
Normal file
18
docs/template_plugin/README.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# template-plugin
|
||||
|
||||
Template Plugin for Inference Engine which demonstrates basics of how Inference Engine plugin can be built and implemented on top of Inference Engine Developer Package and Plugin API.
|
||||
|
||||
## How to build
|
||||
|
||||
```bash
|
||||
$ cd $DLDT_HOME
|
||||
$ mkdir $DLDT_HOME/build
|
||||
$ cd $DLDT_HOME/build
|
||||
$ cmake -DENABLE_TESTS=ON -DENABLE_BEH_TESTS=ON -DENABLE_FUNCTIONAL_TESTS=ON ..
|
||||
$ make -j8
|
||||
$ cd $TEMPLATE_PLUGIN_HOME
|
||||
$ mkdir $TEMPLATE_PLUGIN_HOME/build
|
||||
$ cd $TEMPLATE_PLUGIN_HOME/build
|
||||
$ cmake -DInferenceEngineDeveloperPackage_DIR=$DLDT_HOME/build ..
|
||||
$ make -j8
|
||||
```
|
||||
59
docs/template_plugin/include/template/template_config.hpp
Normal file
59
docs/template_plugin/include/template/template_config.hpp
Normal file
@@ -0,0 +1,59 @@
|
||||
// Copyright (C) 2018-2019 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
/**
|
||||
* @brief A header that defines advanced related properties for DLIA plugins.
|
||||
* These properties should be used in SetConfig() and LoadNetwork() methods of plugins
|
||||
*
|
||||
* @file dlia_config.hpp
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "ie_plugin_config.hpp"
|
||||
|
||||
namespace InferenceEngine {
|
||||
|
||||
namespace TemplateMetrics {
|
||||
|
||||
/**
|
||||
* @def TEMPLATE_METRIC_VALUE(name)
|
||||
* @brief Shortcut for defining Template metric values
|
||||
*/
|
||||
#define TEMPLATE_METRIC_VALUE(name) InferenceEngine::TemplateMetrics::name
|
||||
#define DECLARE_TEMPLATE_METRIC_VALUE(name) static constexpr auto name = #name
|
||||
|
||||
// ! [public_header:metrics]
|
||||
/**
|
||||
* @brief Defines whether current Template device instance supports hardware blocks for fast convolution computations.
|
||||
*/
|
||||
DECLARE_TEMPLATE_METRIC_VALUE(HARDWARE_CONVOLUTION);
|
||||
// ! [public_header:metrics]
|
||||
|
||||
} // namespace TemplateMetrics
|
||||
|
||||
namespace TemplateConfigParams {
|
||||
|
||||
/**
|
||||
* @def TEMPLATE_CONFIG_KEY(name)
|
||||
* @brief Shortcut for defining Template device configuration keys
|
||||
*/
|
||||
#define TEMPLATE_CONFIG_KEY(name) InferenceEngine::TemplateConfigParams::_CONFIG_KEY(TEMPLATE_##name)
|
||||
|
||||
#define DECLARE_TEMPLATE_CONFIG_KEY(name) DECLARE_CONFIG_KEY(TEMPLATE_##name)
|
||||
#define DECLARE_TEMPLATE_CONFIG_VALUE(name) DECLARE_CONFIG_VALUE(TEMPLATE_##name)
|
||||
|
||||
/**
|
||||
* @brief The key to define the type of transformations for TEMPLATE inputs and outputs.
|
||||
* TEMPLATE use custom data layout for input and output blobs. IE TEMPLATE Plugin provides custom
|
||||
* optimized version of transformation functions that do not use OpenMP and much more faster
|
||||
* than native TEMPLATE functions. Values: "NO" - optimized plugin transformations
|
||||
* are used, "YES" - native TEMPLATE transformations are used.
|
||||
*/
|
||||
DECLARE_TEMPLATE_CONFIG_KEY(ANY_CONFIG_KEY);
|
||||
|
||||
|
||||
} // namespace TemplateConfigParams
|
||||
} // namespace InferenceEngine
|
||||
43
docs/template_plugin/src/CMakeLists.txt
Normal file
43
docs/template_plugin/src/CMakeLists.txt
Normal file
@@ -0,0 +1,43 @@
|
||||
# Copyright (C) 2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
# [cmake:plugin]
|
||||
set(TARGET_NAME "templatePlugin")
|
||||
|
||||
if(ENABLE_LTO)
|
||||
ie_enable_lto()
|
||||
endif()
|
||||
|
||||
file(GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
||||
file(GLOB_RECURSE HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp)
|
||||
|
||||
# adds a shared library with plugin
|
||||
ie_add_plugin(NAME ${TARGET_NAME}
|
||||
DEVICE_NAME "TEMPLATE"
|
||||
SOURCES ${SOURCES} ${HEADERS}
|
||||
SKIP_INSTALL # ATTENTION: uncomment to install component
|
||||
VERSION_DEFINES_FOR template_plugin.cpp)
|
||||
|
||||
target_include_directories(${TARGET_NAME} PRIVATE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
"${IE_MAIN_TEMPLATE_PLUGIN_SOURCE_DIR}/include")
|
||||
|
||||
target_link_libraries(${TARGET_NAME} PRIVATE IE::inference_engine IE::inference_engine_transformations ${NGRAPH_LIBRARIES} ${INTEL_ITT_LIBS})
|
||||
|
||||
# ATTENTION: uncomment to register a plugin in the plugins.xml file
|
||||
# ie_register_plugins(MAIN_TARGET ${TARGET_NAME}
|
||||
# POSSIBLE_PLUGINS ${TARGET_NAME})
|
||||
# [cmake:plugin]
|
||||
|
||||
# ATTENTION: uncomment to install component
|
||||
# install
|
||||
|
||||
# set(component_name template)
|
||||
# ie_cpack_add_component(${component_name} REQUIRED)
|
||||
|
||||
# install(TARGETS ${TARGET_NAME}
|
||||
# RUNTIME DESTINATION ${IE_CPACK_RUNTIME_PATH}
|
||||
# ARCHIVE DESTINATION ${IE_CPACK_ARCHIVE_PATH}
|
||||
# LIBRARY DESTINATION ${IE_CPACK_LIBRARY_PATH}
|
||||
# COMPONENT ${component_name})
|
||||
44
docs/template_plugin/src/template_async_infer_request.cpp
Normal file
44
docs/template_plugin/src/template_async_infer_request.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <ie_profiling.hpp>
|
||||
|
||||
#include "template_async_infer_request.hpp"
|
||||
#include "template_executable_network.hpp"
|
||||
|
||||
using namespace TemplatePlugin;
|
||||
|
||||
// ! [async_infer_request:ctor]
|
||||
TemplateAsyncInferRequest::TemplateAsyncInferRequest(
|
||||
const TemplateInferRequest::Ptr& inferRequest,
|
||||
const InferenceEngine::ITaskExecutor::Ptr& cpuTaskExecutor,
|
||||
const InferenceEngine::ITaskExecutor::Ptr& waitExecutor,
|
||||
const InferenceEngine::ITaskExecutor::Ptr& callbackExecutor) :
|
||||
AsyncInferRequestThreadSafeDefault(inferRequest, cpuTaskExecutor, callbackExecutor),
|
||||
_inferRequest(inferRequest), _waitExecutor(waitExecutor) {
|
||||
_pipeline = {
|
||||
{cpuTaskExecutor, [this] {
|
||||
IE_PROFILING_AUTO_SCOPE(PreprocessingAndStartPipeline)
|
||||
_inferRequest->inferPreprocess();
|
||||
_inferRequest->startPipeline();
|
||||
}},
|
||||
{_waitExecutor, [this] {
|
||||
IE_PROFILING_AUTO_SCOPE(WaitPipeline)
|
||||
_inferRequest->waitPipeline();
|
||||
}},
|
||||
{cpuTaskExecutor, [this] {
|
||||
IE_PROFILING_AUTO_SCOPE(Postprocessing)
|
||||
_inferRequest->inferPostprocess();
|
||||
}}
|
||||
};
|
||||
}
|
||||
// ! [async_infer_request:ctor]
|
||||
|
||||
// ! [async_infer_request:dtor]
|
||||
TemplateAsyncInferRequest::~TemplateAsyncInferRequest() {
|
||||
InferenceEngine::AsyncInferRequestThreadSafeDefault::StopAndWait();
|
||||
}
|
||||
// ! [async_infer_request:dtor]
|
||||
30
docs/template_plugin/src/template_async_infer_request.hpp
Normal file
30
docs/template_plugin/src/template_async_infer_request.hpp
Normal file
@@ -0,0 +1,30 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cpp_interfaces/impl/ie_infer_async_request_thread_safe_default.hpp>
|
||||
|
||||
#include "template_infer_request.hpp"
|
||||
|
||||
namespace TemplatePlugin {
|
||||
|
||||
// ! [async_infer_request:header]
|
||||
class TemplateAsyncInferRequest : public InferenceEngine::AsyncInferRequestThreadSafeDefault {
|
||||
public:
|
||||
TemplateAsyncInferRequest(const TemplateInferRequest::Ptr& inferRequest,
|
||||
const InferenceEngine::ITaskExecutor::Ptr& taskExecutor,
|
||||
const InferenceEngine::ITaskExecutor::Ptr& waitExecutor,
|
||||
const InferenceEngine::ITaskExecutor::Ptr& callbackExecutor);
|
||||
|
||||
~TemplateAsyncInferRequest() override;
|
||||
|
||||
private:
|
||||
TemplateInferRequest::Ptr _inferRequest;
|
||||
InferenceEngine::ITaskExecutor::Ptr _waitExecutor;
|
||||
};
|
||||
// ! [async_infer_request:header]
|
||||
|
||||
} // namespace TemplatePlugin
|
||||
45
docs/template_plugin/src/template_config.cpp
Normal file
45
docs/template_plugin/src/template_config.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include <ie_util_internal.hpp>
|
||||
#include <ie_plugin_config.hpp>
|
||||
#include <file_utils.h>
|
||||
#include <cpp_interfaces/exception2status.hpp>
|
||||
|
||||
#include "template_config.hpp"
|
||||
|
||||
using namespace TemplatePlugin;
|
||||
|
||||
Configuration::Configuration() { }
|
||||
|
||||
Configuration::Configuration(const ConfigMap& config, const Configuration & defaultCfg, bool throwOnUnsupported) {
|
||||
*this = defaultCfg;
|
||||
for (auto&& c : config) {
|
||||
const auto& key = c.first;
|
||||
const auto& value = c.second;
|
||||
|
||||
if (CONFIG_KEY(DEVICE_ID) == key) {
|
||||
deviceId = std::stoi(value);
|
||||
} else if (CONFIG_KEY(PERF_COUNT) == key) {
|
||||
perfCount = (CONFIG_VALUE(YES) == value);
|
||||
} else if (throwOnUnsupported) {
|
||||
THROW_IE_EXCEPTION << NOT_FOUND_str << ": " << key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
InferenceEngine::Parameter Configuration::Get(const std::string& name) const {
|
||||
if (name == CONFIG_KEY(DEVICE_ID)) {
|
||||
return {std::to_string(deviceId)};
|
||||
} else if (name == CONFIG_KEY(PERF_COUNT)) {
|
||||
return {perfCount};
|
||||
} else {
|
||||
THROW_IE_EXCEPTION << NOT_FOUND_str << ": " << name;
|
||||
}
|
||||
}
|
||||
40
docs/template_plugin/src/template_config.hpp
Normal file
40
docs/template_plugin/src/template_config.hpp
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <ie_parameter.hpp>
|
||||
|
||||
namespace TemplatePlugin {
|
||||
|
||||
template<typename T>
|
||||
using IOMap = std::unordered_map<std::string, T>;
|
||||
|
||||
// ! [configuration:header]
|
||||
using ConfigMap = std::map<std::string, std::string>;
|
||||
|
||||
struct Configuration {
|
||||
Configuration();
|
||||
Configuration(const Configuration&) = default;
|
||||
Configuration(Configuration&&) = default;
|
||||
Configuration& operator=(const Configuration&) = default;
|
||||
Configuration& operator=(Configuration&&) = default;
|
||||
|
||||
explicit Configuration(const ConfigMap& config, const Configuration & defaultCfg = {}, const bool throwOnUnsupported = true);
|
||||
|
||||
InferenceEngine::Parameter Get(const std::string& name) const;
|
||||
|
||||
// Plugin configuration parameters
|
||||
|
||||
int deviceId = 0;
|
||||
bool perfCount = true;
|
||||
};
|
||||
// ! [configuration:header]
|
||||
|
||||
} // namespace TemplatePlugin
|
||||
167
docs/template_plugin/src/template_executable_network.cpp
Normal file
167
docs/template_plugin/src/template_executable_network.cpp
Normal file
@@ -0,0 +1,167 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <atomic>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <ie_metric_helpers.hpp>
|
||||
#include <ie_util_internal.hpp>
|
||||
#include <ie_plugin_config.hpp>
|
||||
#include <network_serializer.h>
|
||||
#include <threading/ie_executor_manager.hpp>
|
||||
#include <details/ie_cnn_network_tools.h>
|
||||
|
||||
#include <ngraph/specialize_function.hpp>
|
||||
#include <ngraph/pass/manager.hpp>
|
||||
#include <ngraph/pass/constant_folding.hpp>
|
||||
|
||||
#include <transformations/convert_divide.hpp>
|
||||
|
||||
#include "template_plugin.hpp"
|
||||
#include "template_executable_network.hpp"
|
||||
|
||||
using namespace TemplatePlugin;
|
||||
|
||||
// ! [executable_network:ctor_cnnnetwork]
|
||||
TemplatePlugin::ExecutableNetwork::ExecutableNetwork(InferenceEngine::ICNNNetwork& network,
|
||||
const Configuration& cfg):
|
||||
_name(network.getName()),
|
||||
_cfg(cfg),
|
||||
_waitExecutor(InferenceEngine::ExecutorManager::getInstance()->getExecutor("Template")) {
|
||||
// TODO: if your plugin supports device ID (more that single instance of device can be on host machine)
|
||||
// you should select proper device based on KEY_DEVICE_ID or automatic behavior
|
||||
// In this case, _waitExecutor should also be created per device.
|
||||
|
||||
try {
|
||||
if (std::shared_ptr<const ngraph::Function> ngraphFunction = network.getFunction()) {
|
||||
CompileGraph(ngraphFunction);
|
||||
} else {
|
||||
THROW_IE_EXCEPTION << "TEMPLATE plugin can compile only IR v10 networks";
|
||||
}
|
||||
}
|
||||
catch (const InferenceEngineException & e) {
|
||||
throw e;
|
||||
}
|
||||
catch (const std::exception & e) {
|
||||
THROW_IE_EXCEPTION << "Standard exception from compilation library: " << e.what();
|
||||
}
|
||||
catch (...) {
|
||||
THROW_IE_EXCEPTION << "Generic exception is thrown";
|
||||
}
|
||||
}
|
||||
// ! [executable_network:ctor_cnnnetwork]
|
||||
|
||||
// ! [executable_network:ctor_import_stream]
|
||||
TemplatePlugin::ExecutableNetwork::ExecutableNetwork(std::istream & model,
|
||||
const Configuration& cfg) :
|
||||
_cfg(cfg) {
|
||||
// TODO: since Import network is not a mandatory functionality, this ctor can just be removed
|
||||
}
|
||||
// ! [executable_network:ctor_import_stream]
|
||||
|
||||
// ! [executable_network:compile_graph]
|
||||
void TemplatePlugin::ExecutableNetwork::CompileGraph(const std::shared_ptr<const ngraph::Function> & ngraphFunction) {
|
||||
// TODO: perform actual graph compilation taking `_cfg` into account
|
||||
|
||||
// 1.Copy ngraph::Function first to apply some transformations later in
|
||||
// ExecutableNetwork::CompileGraph, which modify original ngraph::Function
|
||||
const bool shareConsts = false, constFolding = false;
|
||||
std::vector<::ngraph::element::Type> new_types;
|
||||
std::vector<::ngraph::PartialShape> new_shapes;
|
||||
|
||||
for (const auto ¶meter : ngraphFunction->get_parameters()) {
|
||||
new_shapes.emplace_back(parameter->get_partial_shape());
|
||||
new_types.emplace_back(parameter->get_element_type());
|
||||
}
|
||||
|
||||
auto copyFunction = ngraph::specialize_function(std::const_pointer_cast<ngraph::Function>(ngraphFunction),
|
||||
new_types, new_shapes, std::vector<void *>(new_types.size(), nullptr), constFolding, shareConsts);
|
||||
|
||||
// 2. Perform common and device-specific transformations
|
||||
ngraph::pass::Manager passManager;
|
||||
// Example: register standard ngraph transformation from ngraph::ngraph
|
||||
passManager.register_pass<ngraph::pass::ConstantFolding>();
|
||||
// Example: register inference engine optimization transformation for IE::inference_engine_transformations
|
||||
passManager.register_pass<ngraph::pass::ConvertDivide>();
|
||||
// Register any other transformations
|
||||
// ..
|
||||
|
||||
// After `run_passes`, we have the transformed function, where operations match device operations,
|
||||
// and we can create device hardware-dependent graph
|
||||
passManager.run_passes(copyFunction);
|
||||
|
||||
// 3. Iterate over operations and create hardware-specific ngraph
|
||||
for (const auto& op : copyFunction->get_ordered_ops()) {
|
||||
// TODO: map ngraph `op` to device operation
|
||||
}
|
||||
|
||||
// 4. Perform any other steps like allocation and filling device buffers, and so on
|
||||
}
|
||||
// ! [executable_network:compile_graph]
|
||||
|
||||
// ! [executable_network:create_infer_request_impl]
|
||||
InferenceEngine::InferRequestInternal::Ptr TemplatePlugin::ExecutableNetwork::CreateInferRequestImpl(InferenceEngine::InputsDataMap networkInputs,
|
||||
InferenceEngine::OutputsDataMap networkOutputs) {
|
||||
return std::make_shared<TemplateInferRequest>(networkInputs, networkOutputs, std::static_pointer_cast<ExecutableNetwork>(shared_from_this()));
|
||||
}
|
||||
// ! [executable_network:create_infer_request_impl]
|
||||
|
||||
// ! [executable_network:create_infer_request]
|
||||
void TemplatePlugin::ExecutableNetwork::CreateInferRequest(IInferRequest::Ptr& asyncRequest) {
|
||||
auto internalRequest = CreateInferRequestImpl(_networkInputs, _networkOutputs);
|
||||
auto asyncThreadSafeImpl = std::make_shared<TemplateAsyncInferRequest>(std::static_pointer_cast<TemplateInferRequest>(internalRequest),
|
||||
_taskExecutor, _waitExecutor, _callbackExecutor);
|
||||
asyncRequest.reset(new InferenceEngine::InferRequestBase<TemplateAsyncInferRequest>(asyncThreadSafeImpl),
|
||||
[](InferenceEngine::IInferRequest *p) { p->Release(); });
|
||||
asyncThreadSafeImpl->SetPointerToPublicInterface(asyncRequest);
|
||||
}
|
||||
// ! [executable_network:create_infer_request]
|
||||
|
||||
// ! [executable_network:get_config]
|
||||
void TemplatePlugin::ExecutableNetwork::GetConfig(const std::string &name, Parameter &result, ResponseDesc *resp) const {
|
||||
// TODO: return more supported values for config keys
|
||||
if (name == CONFIG_KEY(DEVICE_ID) ||
|
||||
name == CONFIG_KEY(PERF_COUNT)) {
|
||||
result = _cfg.Get(name);
|
||||
} else {
|
||||
THROW_IE_EXCEPTION << "Unsupported ExecutableNetwork config key: " << name;
|
||||
}
|
||||
}
|
||||
// ! [executable_network:get_config]
|
||||
|
||||
// ! [executable_network:get_metric]
|
||||
void TemplatePlugin::ExecutableNetwork::GetMetric(const std::string &name, InferenceEngine::Parameter &result, InferenceEngine::ResponseDesc *) const {
|
||||
// TODO: return more supported values for metrics
|
||||
if (METRIC_KEY(SUPPORTED_METRICS) == name) {
|
||||
result = IE_SET_METRIC(SUPPORTED_METRICS, std::vector<std::string>{
|
||||
METRIC_KEY(NETWORK_NAME),
|
||||
METRIC_KEY(SUPPORTED_METRICS),
|
||||
METRIC_KEY(SUPPORTED_CONFIG_KEYS),
|
||||
METRIC_KEY(OPTIMAL_NUMBER_OF_INFER_REQUESTS)});
|
||||
} else if (METRIC_KEY(SUPPORTED_CONFIG_KEYS) == name) {
|
||||
result = IE_SET_METRIC(SUPPORTED_CONFIG_KEYS, std::vector<std::string>{
|
||||
CONFIG_KEY(DEVICE_ID),
|
||||
CONFIG_KEY(PERF_COUNT)});
|
||||
} else if (METRIC_KEY(NETWORK_NAME) == name) {
|
||||
result = IE_SET_METRIC(NETWORK_NAME, _name);
|
||||
} else if (METRIC_KEY(OPTIMAL_NUMBER_OF_INFER_REQUESTS) == name) {
|
||||
// TODO: fill with actual number
|
||||
unsigned int value = 1;
|
||||
result = IE_SET_METRIC(OPTIMAL_NUMBER_OF_INFER_REQUESTS, value);
|
||||
} else {
|
||||
THROW_IE_EXCEPTION << "Unsupported ExecutableNetwork metric: " << name;
|
||||
}
|
||||
}
|
||||
// ! [executable_network:get_metric]
|
||||
|
||||
// ! [executable_network:export_impl]
|
||||
void TemplatePlugin::ExecutableNetwork::ExportImpl(std::ostream& dlaModel) {
|
||||
// TODO: Code which exports graph from std::ostream
|
||||
}
|
||||
// ! [executable_network:export_impl]
|
||||
68
docs/template_plugin/src/template_executable_network.hpp
Normal file
68
docs/template_plugin/src/template_executable_network.hpp
Normal file
@@ -0,0 +1,68 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
#include <tuple>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <list>
|
||||
|
||||
#include <ie_common.h>
|
||||
#include <cpp_interfaces/impl/ie_executable_network_thread_safe_default.hpp>
|
||||
#include <cnn_network_impl.hpp>
|
||||
#include <threading/ie_itask_executor.hpp>
|
||||
|
||||
#include <ngraph/function.hpp>
|
||||
|
||||
#include "template_config.hpp"
|
||||
#include "template_infer_request.hpp"
|
||||
#include "template_async_infer_request.hpp"
|
||||
|
||||
namespace TemplatePlugin {
|
||||
|
||||
class Engine;
|
||||
|
||||
/**
|
||||
* @class ExecutableNetwork
|
||||
* @brief Interface of executable network
|
||||
*/
|
||||
// ! [executable_network:header]
|
||||
class ExecutableNetwork : public InferenceEngine::ExecutableNetworkThreadSafeDefault {
|
||||
public:
|
||||
ExecutableNetwork(InferenceEngine::ICNNNetwork& network,
|
||||
const Configuration& cfg);
|
||||
|
||||
ExecutableNetwork(std::istream & model,
|
||||
const Configuration& cfg);
|
||||
|
||||
~ExecutableNetwork() override = default;
|
||||
|
||||
// Methods from a base class ExecutableNetworkThreadSafeDefault
|
||||
|
||||
void ExportImpl(std::ostream& model) override;
|
||||
InferenceEngine::InferRequestInternal::Ptr CreateInferRequestImpl(InferenceEngine::InputsDataMap networkInputs,
|
||||
InferenceEngine::OutputsDataMap networkOutputs) override;
|
||||
void CreateInferRequest(InferenceEngine::IInferRequest::Ptr &asyncRequest) override;
|
||||
void GetMetric(const std::string &name, InferenceEngine::Parameter &result, InferenceEngine::ResponseDesc *resp) const override;
|
||||
void GetConfig(const std::string &name, InferenceEngine::Parameter &result, InferenceEngine::ResponseDesc *resp) const override;
|
||||
|
||||
std::atomic<std::size_t> _requestId = {0};
|
||||
std::string _name;
|
||||
Configuration _cfg;
|
||||
|
||||
private:
|
||||
void CompileGraph(const std::shared_ptr<const ngraph::Function> & ngraphFunction);
|
||||
|
||||
std::shared_ptr<Engine> _plugin;
|
||||
InferenceEngine::ITaskExecutor::Ptr _waitExecutor;
|
||||
};
|
||||
// ! [executable_network:header]
|
||||
|
||||
} // namespace TemplatePlugin
|
||||
224
docs/template_plugin/src/template_infer_request.cpp
Normal file
224
docs/template_plugin/src/template_infer_request.cpp
Normal file
@@ -0,0 +1,224 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
||||
#include <utility>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#include <ie_blob.h>
|
||||
#include <ie_plugin.hpp>
|
||||
#include <description_buffer.hpp>
|
||||
#include <debug.h>
|
||||
#include <ie_layouts.h>
|
||||
#include <threading/ie_executor_manager.hpp>
|
||||
#include <blob_transform.hpp>
|
||||
#include <ie_parallel.hpp>
|
||||
#include <ie_memcpy.h>
|
||||
#include <precision_utils.h>
|
||||
#include <template/template_config.hpp>
|
||||
|
||||
#include "template_infer_request.hpp"
|
||||
#include "template_executable_network.hpp"
|
||||
#include "template_plugin.hpp"
|
||||
|
||||
using namespace TemplatePlugin;
|
||||
|
||||
using Time = std::chrono::high_resolution_clock;
|
||||
using ns = std::chrono::nanoseconds;
|
||||
using fsec = std::chrono::duration<float>;
|
||||
|
||||
// ! [infer_request:ctor]
|
||||
TemplateInferRequest::TemplateInferRequest(const InferenceEngine::InputsDataMap& networkInputs,
|
||||
const InferenceEngine::OutputsDataMap& networkOutputs,
|
||||
const std::shared_ptr<TemplatePlugin::ExecutableNetwork>& executableNetwork) :
|
||||
InferRequestInternal(networkInputs, networkOutputs),
|
||||
_executableNetwork(executableNetwork) {
|
||||
// TODO: allocate infer request device and host buffers if needed, fill actual list of profiling tasks
|
||||
|
||||
auto requestID = std::to_string(_executableNetwork->_requestId);
|
||||
_executableNetwork->_requestId++;
|
||||
|
||||
std::string name = _executableNetwork->_name + "_Req" + requestID;
|
||||
_profilingTask = { {
|
||||
{ ProfilingTask("Template" + std::to_string(_executableNetwork->_cfg.deviceId) + "_" + name + "_Preprocess") },
|
||||
{ ProfilingTask("Template" + std::to_string(_executableNetwork->_cfg.deviceId) + "_" + name + "_Postprocess") },
|
||||
{ ProfilingTask("Template" + std::to_string(_executableNetwork->_cfg.deviceId) + "_" + name + "_StartPipline") },
|
||||
{ ProfilingTask("Template" + std::to_string(_executableNetwork->_cfg.deviceId) + "_" + name + "_WaitPipline") },
|
||||
} };
|
||||
|
||||
allocateDeviceBuffers();
|
||||
allocateInputBlobs();
|
||||
allocateOutputBlobs();
|
||||
}
|
||||
// ! [infer_request:ctor]
|
||||
|
||||
// ! [infer_request:dtor]
|
||||
TemplateInferRequest::~TemplateInferRequest() {
|
||||
_executableNetwork->_requestId--;
|
||||
}
|
||||
// ! [infer_request:dtor]
|
||||
|
||||
void TemplateInferRequest::allocateDeviceBuffers() {
|
||||
// TODO: allocate device buffers if Template device is a remote one
|
||||
}
|
||||
|
||||
void TemplateInferRequest::allocateInputBlobs() {
|
||||
for (auto &networkInput : _networkInputs) {
|
||||
SizeVector dims = networkInput.second->getTensorDesc().getDims();
|
||||
Precision precision = networkInput.second->getTensorDesc().getPrecision();
|
||||
Layout input_layout = networkInput.second->getInputData()->getLayout();
|
||||
Blob::Ptr inputBlob;
|
||||
Blob::Ptr inputBlobNCHW;
|
||||
switch (precision) {
|
||||
case Precision::FP32 :
|
||||
inputBlobNCHW = inputBlob = InferenceEngine::make_shared_blob<float>({ precision, dims, input_layout });
|
||||
if (input_layout == Layout::NHWC) {
|
||||
inputBlobNCHW = InferenceEngine::make_shared_blob<float>({ precision, dims, Layout::NCHW });
|
||||
}
|
||||
break;
|
||||
case Precision::FP16 :
|
||||
case Precision::I16 :
|
||||
inputBlobNCHW = inputBlob = InferenceEngine::make_shared_blob<int16_t>({ precision, dims, input_layout });
|
||||
if (input_layout == Layout::NHWC) {
|
||||
inputBlobNCHW = InferenceEngine::make_shared_blob<int16_t>({ precision, dims, Layout::NCHW });
|
||||
}
|
||||
break;
|
||||
case Precision::U8 :
|
||||
inputBlobNCHW = inputBlob = InferenceEngine::make_shared_blob<uint8_t>({ precision, dims, input_layout });
|
||||
if (input_layout == Layout::NHWC) {
|
||||
inputBlobNCHW = InferenceEngine::make_shared_blob<uint8_t>({ precision, dims, Layout::NCHW });
|
||||
}
|
||||
break;
|
||||
default:
|
||||
THROW_IE_EXCEPTION << "Unsupported network precision: " << precision
|
||||
<< precision << "! Supported precisions are: FP32, FP16, I16, U8";
|
||||
}
|
||||
// allocate the input blob
|
||||
inputBlob->allocate();
|
||||
_inputs[networkInput.first] = inputBlob;
|
||||
if (inputBlobNCHW != inputBlob) {
|
||||
inputBlobNCHW->allocate();
|
||||
}
|
||||
_inputsNCHW[networkInput.first] = inputBlobNCHW;
|
||||
}
|
||||
}
|
||||
|
||||
void TemplateInferRequest::allocateOutputBlobs() {
|
||||
for (auto &networkOutput : _networkOutputs) {
|
||||
SizeVector dims = networkOutput.second->getTensorDesc().getDims();
|
||||
Precision precision = networkOutput.second->getPrecision();
|
||||
Blob::Ptr outputBlob;
|
||||
|
||||
// allocate the output blob
|
||||
Blob::Ptr outputBlobNCHW;
|
||||
switch (precision) {
|
||||
case Precision::FP32 :
|
||||
outputBlobNCHW = outputBlob = InferenceEngine::make_shared_blob<float>({ precision, dims, networkOutput.second->getLayout() });
|
||||
if (networkOutput.second->getLayout() == Layout::NHWC) {
|
||||
outputBlobNCHW = InferenceEngine::make_shared_blob<float>({ precision, dims, Layout::NCHW });
|
||||
}
|
||||
break;
|
||||
case Precision::FP16 :
|
||||
outputBlobNCHW = outputBlob = InferenceEngine::make_shared_blob<int16_t>({ precision, dims, networkOutput.second->getLayout() });
|
||||
if (networkOutput.second->getLayout() == Layout::NHWC) {
|
||||
outputBlobNCHW = InferenceEngine::make_shared_blob<int16_t>({ precision, dims, Layout::NCHW });
|
||||
}
|
||||
break;
|
||||
default:
|
||||
THROW_IE_EXCEPTION << PARAMETER_MISMATCH_str << "Unsupported output precision: "
|
||||
<< precision << "! Supported precisions are: FP32, FP16";
|
||||
}
|
||||
// allocate the output blob
|
||||
outputBlob->allocate();
|
||||
_outputs[networkOutput.first] = outputBlob;
|
||||
if (outputBlobNCHW != outputBlob) {
|
||||
outputBlobNCHW->allocate();
|
||||
}
|
||||
_outputsNCHW[networkOutput.first] = outputBlobNCHW;
|
||||
}
|
||||
|
||||
if (_networkOutputs.empty() || _networkInputs.empty()) {
|
||||
THROW_IE_EXCEPTION << "Internal error: no information about network's output/input";
|
||||
}
|
||||
}
|
||||
|
||||
// ! [infer_request:infer_impl]
|
||||
void TemplateInferRequest::InferImpl() {
|
||||
// TODO: fill with actual list of pipeline stages, which are executed syncronously for sync infer requests
|
||||
inferPreprocess();
|
||||
startPipeline();
|
||||
waitPipeline();
|
||||
inferPostprocess();
|
||||
}
|
||||
// ! [infer_request:infer_impl]
|
||||
|
||||
// ! [infer_request:infer_preprocess]
|
||||
void TemplateInferRequest::inferPreprocess() {
|
||||
auto prev = Time::now();
|
||||
|
||||
// execute input pre-processing.
|
||||
InferRequestInternal::execDataPreprocessing(_inputs);
|
||||
|
||||
for (auto &input : InferRequestInternal::_inputs) {
|
||||
auto& src = input.second;
|
||||
auto& dst = _inputsNCHW[input.first];
|
||||
if (src != dst) {
|
||||
if (src->getTensorDesc().getPrecision() == dst->getTensorDesc().getPrecision()
|
||||
&& src->getTensorDesc().getDims() == dst->getTensorDesc().getDims()
|
||||
&& src->getTensorDesc().getLayout() == dst->getTensorDesc().getLayout()) {
|
||||
_inputsNCHW[input.first] = input.second;
|
||||
} else { // Convert Layout to NCHW
|
||||
InferenceEngine::blob_copy(src, dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Preprocessing on inputs if needed: work _inputsNCHW
|
||||
|
||||
_inputPreprocessTime = static_cast<double>(std::chrono::duration_cast<ns>(Time::now() - prev).count());
|
||||
}
|
||||
// ! [infer_request:infer_preprocess]
|
||||
|
||||
void TemplateInferRequest::startPipeline() {
|
||||
IE_PROFILING_AUTO_SCOPE_TASK(_profilingTask[StartPipeline])
|
||||
// TODO: Start pipeline and fill _inputTransferTime, _executeTime, _outputTransferTime
|
||||
}
|
||||
|
||||
void TemplateInferRequest::waitPipeline() {
|
||||
IE_PROFILING_AUTO_SCOPE_TASK(_profilingTask[WaitPipeline])
|
||||
auto prev = Time::now();
|
||||
// TODO: Wait pipeline using driver API or other synronizations methods
|
||||
_inputPreprocessTime = static_cast<double>(std::chrono::duration_cast<ns>(Time::now() - prev).count());
|
||||
}
|
||||
|
||||
void TemplateInferRequest::inferPostprocess() {
|
||||
IE_PROFILING_AUTO_SCOPE_TASK(_profilingTask[Postprocess])
|
||||
auto prev = Time::now();
|
||||
// TODO: perform post-processing and convert to NHWC layout
|
||||
_outputPostProcessTime = static_cast<double>(std::chrono::duration_cast<ns>(Time::now() - prev).count());
|
||||
}
|
||||
|
||||
// ! [infer_request:get_performance_counts]
|
||||
void TemplateInferRequest::GetPerformanceCounts(std::map<std::string, InferenceEngineProfileInfo> &perfMap) const {
|
||||
InferenceEngineProfileInfo info;
|
||||
info.execution_index = 0;
|
||||
info.status = InferenceEngineProfileInfo::EXECUTED;
|
||||
info.cpu_uSec = info.realTime_uSec = _inputPreprocessTime / 1000;
|
||||
perfMap["1. input preprocessing"] = info;
|
||||
info.cpu_uSec = 0;
|
||||
info.realTime_uSec = _inputTransferTime / 1000;
|
||||
perfMap["2. input transfer to a device"] = info;
|
||||
info.cpu_uSec = 0;
|
||||
info.realTime_uSec = _executeTime / 1000;
|
||||
perfMap["3. execution time"] = info;
|
||||
info.cpu_uSec = 0;
|
||||
info.realTime_uSec = _outputTransferTime / 1000;
|
||||
perfMap["4. output transfer from a device"] = info;
|
||||
info.cpu_uSec = info.realTime_uSec = _outputPostProcessTime / 1000;
|
||||
perfMap["5. output postprocessing"] = info;
|
||||
}
|
||||
// ! [infer_request:get_performance_counts]
|
||||
74
docs/template_plugin/src/template_infer_request.hpp
Normal file
74
docs/template_plugin/src/template_infer_request.hpp
Normal file
@@ -0,0 +1,74 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <ie_common.h>
|
||||
#include <ie_profiling.hpp>
|
||||
#include <cpp_interfaces/impl/ie_infer_request_internal.hpp>
|
||||
#include <cpp_interfaces/impl/ie_executable_network_internal.hpp>
|
||||
#include <threading/ie_itask_executor.hpp>
|
||||
|
||||
#include "template_config.hpp"
|
||||
|
||||
namespace TemplatePlugin {
|
||||
|
||||
class ExecutableNetwork;
|
||||
|
||||
// ! [infer_request:header]
|
||||
class TemplateInferRequest : public InferenceEngine::InferRequestInternal {
|
||||
public:
|
||||
typedef std::shared_ptr<TemplateInferRequest> Ptr;
|
||||
|
||||
TemplateInferRequest(const InferenceEngine::InputsDataMap& networkInputs,
|
||||
const InferenceEngine::OutputsDataMap& networkOutputs,
|
||||
const std::shared_ptr<ExecutableNetwork>& executableNetwork);
|
||||
~TemplateInferRequest() override;
|
||||
|
||||
void InferImpl() override;
|
||||
void GetPerformanceCounts(std::map<std::string, InferenceEngine::InferenceEngineProfileInfo>& perfMap) const override;
|
||||
|
||||
// pipeline methods-stages which are used in async infer request implementation and assigned to particular executor
|
||||
void inferPreprocess();
|
||||
void startPipeline();
|
||||
void waitPipeline();
|
||||
void inferPostprocess();
|
||||
|
||||
std::shared_ptr<ExecutableNetwork> _executableNetwork;
|
||||
|
||||
private:
|
||||
void allocateDeviceBuffers();
|
||||
void allocateInputBlobs();
|
||||
void allocateOutputBlobs();
|
||||
|
||||
enum {
|
||||
Preprocess,
|
||||
Postprocess,
|
||||
StartPipeline,
|
||||
WaitPipeline,
|
||||
numOfStages
|
||||
};
|
||||
|
||||
std::array<InferenceEngine::ProfilingTask, numOfStages> _profilingTask;
|
||||
|
||||
InferenceEngine::BlobMap _inputsNCHW;
|
||||
InferenceEngine::BlobMap _outputsNCHW;
|
||||
|
||||
// for performance counts
|
||||
double _inputPreprocessTime = 0.0;
|
||||
double _inputTransferTime = 0.0;
|
||||
double _executeTime = 0.0;
|
||||
double _outputTransferTime = 0.0;
|
||||
double _outputPostProcessTime = 0.0;
|
||||
};
|
||||
// ! [infer_request:header]
|
||||
|
||||
} // namespace TemplatePlugin
|
||||
194
docs/template_plugin/src/template_plugin.cpp
Normal file
194
docs/template_plugin/src/template_plugin.cpp
Normal file
@@ -0,0 +1,194 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
||||
#include <utility>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <regex>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#include <ie_metric_helpers.hpp>
|
||||
#include <details/ie_cnn_network_tools.h>
|
||||
#include <ie_plugin_config.hpp>
|
||||
#include <ie_util_internal.hpp>
|
||||
#include <inference_engine.hpp>
|
||||
#include <file_utils.h>
|
||||
#include <cpp_interfaces/base/ie_plugin_base.hpp>
|
||||
#include <cpp_interfaces/interface/ie_internal_plugin_config.hpp>
|
||||
#include <threading/ie_executor_manager.hpp>
|
||||
#include <graph_tools.hpp>
|
||||
#include <ie_input_info.hpp>
|
||||
#include <ie_layouts.h>
|
||||
#include <hetero/hetero_plugin_config.hpp>
|
||||
#include <template/template_config.hpp>
|
||||
|
||||
#include "template_plugin.hpp"
|
||||
#include "template_executable_network.hpp"
|
||||
#include "template_infer_request.hpp"
|
||||
|
||||
using namespace TemplatePlugin;
|
||||
|
||||
// ! [plugin:ctor]
|
||||
Plugin::Plugin() {
|
||||
// TODO: fill with actual device name
|
||||
_pluginName = "TEMPLATE";
|
||||
}
|
||||
// ! [plugin:ctor]
|
||||
|
||||
// ! [plugin:load_exe_network_impl]
|
||||
InferenceEngine::ExecutableNetworkInternal::Ptr Plugin::LoadExeNetworkImpl(const InferenceEngine::ICore * core,
|
||||
const InferenceEngine::ICNNNetwork & network,
|
||||
const ConfigMap &config) {
|
||||
auto cfg = Configuration{ config, _cfg };
|
||||
InferenceEngine::InputsDataMap networkInputs;
|
||||
InferenceEngine::OutputsDataMap networkOutputs;
|
||||
|
||||
network.getInputsInfo(networkInputs);
|
||||
network.getOutputsInfo(networkOutputs);
|
||||
|
||||
// TODO: check with precisions supported by Template device
|
||||
|
||||
for (auto networkOutput : networkOutputs) {
|
||||
auto output_precision = networkOutput.second->getPrecision();
|
||||
|
||||
if (output_precision != Precision::FP32 &&
|
||||
output_precision != Precision::FP16) {
|
||||
THROW_IE_EXCEPTION << "Template device supports only FP16 and FP32 output precision.";
|
||||
}
|
||||
}
|
||||
|
||||
for (auto networkInput : networkInputs) {
|
||||
auto input_precision = networkInput.second->getTensorDesc().getPrecision();
|
||||
|
||||
if (input_precision != InferenceEngine::Precision::FP32 &&
|
||||
input_precision != InferenceEngine::Precision::FP16 &&
|
||||
input_precision != InferenceEngine::Precision::I16 &&
|
||||
input_precision != InferenceEngine::Precision::U8) {
|
||||
THROW_IE_EXCEPTION << "Input image format " << input_precision << " is not supported yet.\n"
|
||||
<< "Supported formats are: FP32, FP16, I16 and U8.";
|
||||
}
|
||||
}
|
||||
|
||||
auto clonedNetwork = cloneNet(network);
|
||||
ConstTransformer transformator(clonedNetwork.get());
|
||||
transformator.fullTrim();
|
||||
|
||||
return std::make_shared<ExecutableNetwork>(*clonedNetwork, cfg);
|
||||
}
|
||||
// ! [plugin:load_exe_network_impl]
|
||||
|
||||
// ! [plugin:import_network_impl]
|
||||
InferenceEngine::ExecutableNetwork Plugin::ImportNetworkImpl(std::istream& model, const std::map<std::string, std::string>& config) {
|
||||
// TODO: Import network from stream is not mandatory functionality;
|
||||
// Can just throw an exception and remove the code below
|
||||
Configuration exportedCfg;
|
||||
|
||||
// some code below which reads exportedCfg from `model` stream
|
||||
// ..
|
||||
|
||||
auto cfg = Configuration(config, exportedCfg);
|
||||
|
||||
IExecutableNetwork::Ptr executableNetwork;
|
||||
auto exec_network_impl = std::make_shared<ExecutableNetwork>(model, cfg);
|
||||
executableNetwork.reset(new ExecutableNetworkBase<ExecutableNetworkInternal>(exec_network_impl),
|
||||
[](InferenceEngine::details::IRelease *p) {p->Release(); });
|
||||
|
||||
return InferenceEngine::ExecutableNetwork{ executableNetwork };
|
||||
}
|
||||
// ! [plugin:import_network_impl]
|
||||
|
||||
// ! [plugin:query_network]
|
||||
void Plugin::QueryNetwork(const ICNNNetwork &network, const ConfigMap& config, QueryNetworkResult &res) const {
|
||||
Configuration cfg{config, _cfg, false};
|
||||
res.rc = StatusCode::OK;
|
||||
|
||||
if (std::shared_ptr<const ngraph::Function> ngraphFunction = network.getFunction()) {
|
||||
auto ops = ngraphFunction->get_ordered_ops();
|
||||
for (auto&& op : ops) {
|
||||
// TODO: investigate if an op is actually supported by Template device
|
||||
bool supported = true;
|
||||
if (supported) {
|
||||
res.supportedLayersMap.insert({ op->get_friendly_name(), GetName() });
|
||||
}
|
||||
}
|
||||
} else {
|
||||
THROW_IE_EXCEPTION << "TEMPLATE plugin can query only IR v10 networks";
|
||||
}
|
||||
}
|
||||
// ! [plugin:query_network]
|
||||
|
||||
// ! [plugin:add_extension]
|
||||
void Plugin::AddExtension(InferenceEngine::IExtensionPtr /*extension*/) {
|
||||
// TODO: add extensions if plugin supports extensions
|
||||
}
|
||||
// ! [plugin:add_extension]
|
||||
|
||||
// ! [plugin:set_config]
|
||||
void Plugin::SetConfig(const ConfigMap &config) {
|
||||
_cfg = Configuration{config, _cfg};
|
||||
}
|
||||
// ! [plugin:set_config]
|
||||
|
||||
// ! [plugin:get_config]
|
||||
InferenceEngine::Parameter Plugin::GetConfig(const std::string& name, const std::map<std::string, InferenceEngine::Parameter> & /*options*/) const {
|
||||
return _cfg.Get(name);
|
||||
}
|
||||
// ! [plugin:get_config]
|
||||
|
||||
// ! [plugin:get_metric]
|
||||
InferenceEngine::Parameter Plugin::GetMetric(const std::string& name, const std::map<std::string, InferenceEngine::Parameter> & options) const {
|
||||
if (METRIC_KEY(SUPPORTED_METRICS) == name) {
|
||||
std::vector<std::string> supportedMetrics = {
|
||||
METRIC_KEY(AVAILABLE_DEVICES),
|
||||
METRIC_KEY(SUPPORTED_METRICS),
|
||||
METRIC_KEY(SUPPORTED_CONFIG_KEYS),
|
||||
METRIC_KEY(FULL_DEVICE_NAME),
|
||||
METRIC_KEY(OPTIMIZATION_CAPABILITIES),
|
||||
METRIC_KEY(RANGE_FOR_ASYNC_INFER_REQUESTS) };
|
||||
IE_SET_METRIC_RETURN(SUPPORTED_METRICS, supportedMetrics);
|
||||
} else if (METRIC_KEY(SUPPORTED_CONFIG_KEYS) == name) {
|
||||
std::vector<std::string> confiKeys = {
|
||||
CONFIG_KEY(DEVICE_ID),
|
||||
CONFIG_KEY(PERF_COUNT) };
|
||||
IE_SET_METRIC_RETURN(SUPPORTED_CONFIG_KEYS, confiKeys);
|
||||
} else if (METRIC_KEY(AVAILABLE_DEVICES) == name) {
|
||||
// TODO: fill list of available devices
|
||||
std::vector<std::string> availableDevices = { "" };
|
||||
IE_SET_METRIC_RETURN(AVAILABLE_DEVICES, availableDevices);
|
||||
} else if (METRIC_KEY(FULL_DEVICE_NAME) == name) {
|
||||
std::string name = "Template Device Full Name";
|
||||
IE_SET_METRIC_RETURN(FULL_DEVICE_NAME, name);
|
||||
} else if (METRIC_KEY(OPTIMIZATION_CAPABILITIES) == name) {
|
||||
// TODO: fill actual list of supported capabilities: e.g. Template device supports only FP32
|
||||
std::vector<std::string> capabilities = { METRIC_VALUE(FP32), TEMPLATE_METRIC_VALUE(HARDWARE_CONVOLUTION) };
|
||||
IE_SET_METRIC_RETURN(OPTIMIZATION_CAPABILITIES, capabilities);
|
||||
} else if (METRIC_KEY(RANGE_FOR_ASYNC_INFER_REQUESTS) == name) {
|
||||
// TODO: fill with actual values
|
||||
using uint = unsigned int;
|
||||
IE_SET_METRIC_RETURN(RANGE_FOR_ASYNC_INFER_REQUESTS, std::make_tuple(uint{1}, uint{1}, uint{1}));
|
||||
} else {
|
||||
THROW_IE_EXCEPTION << "Unsupported device metric: " << name;
|
||||
}
|
||||
}
|
||||
// ! [plugin:get_metric]
|
||||
|
||||
IE_SUPPRESS_DEPRECATED_START
|
||||
|
||||
// ! [plugin:create_plugin_engine]
|
||||
INFERENCE_PLUGIN_API(StatusCode) CreatePluginEngine(IInferencePlugin *&plugin, ResponseDesc *resp) noexcept {
|
||||
try {
|
||||
plugin = make_ie_compatible_plugin({2, 1, CI_BUILD_NUMBER, "templatePlugin"},
|
||||
std::make_shared<Plugin>());
|
||||
return OK;
|
||||
}
|
||||
catch (std::exception &ex) {
|
||||
return DescriptionBuffer(GENERAL_ERROR, resp) << ex.what();
|
||||
}
|
||||
}
|
||||
// ! [plugin:create_plugin_engine]
|
||||
|
||||
IE_SUPPRESS_DEPRECATED_END
|
||||
48
docs/template_plugin/src/template_plugin.hpp
Normal file
48
docs/template_plugin/src/template_plugin.hpp
Normal file
@@ -0,0 +1,48 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <inference_engine.hpp>
|
||||
#include <description_buffer.hpp>
|
||||
#include <cpp_interfaces/impl/ie_plugin_internal.hpp>
|
||||
#include <ie_error.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "template_executable_network.hpp"
|
||||
#include "template_config.hpp"
|
||||
|
||||
//! [plugin:header]
|
||||
namespace TemplatePlugin {
|
||||
|
||||
class Plugin : public InferenceEngine::InferencePluginInternal {
|
||||
public:
|
||||
using Ptr = std::shared_ptr<Plugin>;
|
||||
|
||||
Plugin();
|
||||
~Plugin() override = default;
|
||||
|
||||
void SetConfig(const std::map<std::string, std::string> &config) override;
|
||||
void QueryNetwork(const InferenceEngine::ICNNNetwork &network,
|
||||
const std::map<std::string, std::string>& config,
|
||||
InferenceEngine::QueryNetworkResult &res) const override;
|
||||
InferenceEngine::ExecutableNetworkInternal::Ptr
|
||||
LoadExeNetworkImpl(const InferenceEngine::ICore * core, const InferenceEngine::ICNNNetwork &network,
|
||||
const std::map<std::string, std::string> &config) override;
|
||||
void AddExtension(InferenceEngine::IExtensionPtr extension) override;
|
||||
InferenceEngine::Parameter GetConfig(const std::string& name, const std::map<std::string, InferenceEngine::Parameter> & options) const override;
|
||||
InferenceEngine::Parameter GetMetric(const std::string& name, const std::map<std::string, InferenceEngine::Parameter> & options) const override;
|
||||
InferenceEngine::ExecutableNetwork ImportNetworkImpl(std::istream& model, const std::map<std::string, std::string>& config) override;
|
||||
|
||||
private:
|
||||
Configuration _cfg;
|
||||
};
|
||||
|
||||
} // namespace TemplatePlugin
|
||||
//! [plugin:header]
|
||||
@@ -1,43 +1,59 @@
|
||||
# Get Started with OpenVINO™ Deep Learning Deployment Toolkit (DLDT) on Linux*
|
||||
|
||||
This guide provides you with the information that will help you to start using the DLDT on Linux*. With this guide you will learn how to:
|
||||
This guide provides you with the information that will help you to start using
|
||||
the OpenVINO on Linux\*. With this guide, you will learn how to:
|
||||
|
||||
1. [Configure the Model Optimizer](#configure-the-model-optimizer)
|
||||
2. [Prepare a model for sample inference:](#prepare-a-model-for-sample-inference)
|
||||
2. [Prepare a model for sample inference](#prepare-a-model-for-sample-inference)
|
||||
1. [Download a pre-trained model](#download-a-trained-model)
|
||||
2. [Convert the model to an Intermediate Representation (IR) with the Model Optimizer](#convert-the-model-to-an-intermediate-representation-with-the-model-optimizer)
|
||||
3. [Run the Image Classification Sample Application with the model](#run-the-image-classification-sample-application)
|
||||
|
||||
## Prerequisites
|
||||
1. This guide assumes that you have already cloned the `dldt` repo and successfully built the Inference Engine and Samples using the [build instructions](inference-engine/README.md).
|
||||
2. The original structure of the repository directories is kept unchanged.
|
||||
1. This guide assumes that you have already cloned the `openvino` repo and
|
||||
successfully built the Inference Engine and Samples using the
|
||||
[build instructions](inference-engine/README.md).
|
||||
2. The original structure of the repository directories remains unchanged.
|
||||
|
||||
> **NOTE**: Below, the directory to which the `dldt` repository is cloned is referred to as `<DLDT_DIR>`.
|
||||
> **NOTE**: Below, the directory to which the `openvino` repository is cloned is
|
||||
referred to as `<OPENVINO_DIR>`.
|
||||
|
||||
## Configure the Model Optimizer
|
||||
|
||||
The Model Optimizer is a Python\*-based command line tool for importing trained models from popular deep learning frameworks such as Caffe\*, TensorFlow\*, Apache MXNet\*, ONNX\* and Kaldi\*.
|
||||
The Model Optimizer is a Python\*-based command line tool for importing trained
|
||||
models from popular deep learning frameworks such as Caffe\*, TensorFlow\*,
|
||||
Apache MXNet\*, ONNX\* and Kaldi\*.
|
||||
|
||||
You cannot perform inference on your trained model without running the model through the Model Optimizer. When you run a pre-trained model through the Model Optimizer, your output is an Intermediate Representation (IR) of the network. The Intermediate Representation is a pair of files that describe the whole model:
|
||||
You cannot perform inference on your trained model without having first run the
|
||||
model through the Model Optimizer. When you run a pre-trained model through the
|
||||
Model Optimizer, it outputs an *Intermediate Representation*, or *(IR)* of
|
||||
the network, a pair of files that describes the whole model:
|
||||
|
||||
- `.xml`: Describes the network topology
|
||||
- `.bin`: Contains the weights and biases binary data
|
||||
|
||||
For more information about the Model Optimizer, refer to the [Model Optimizer Developer Guide](https://docs.openvinotoolkit.org/latest/_docs_MO_DG_Deep_Learning_Model_Optimizer_DevGuide.html).
|
||||
For more information about the Model Optimizer, refer to the
|
||||
[Model Optimizer Developer Guide].
|
||||
|
||||
### Model Optimizer Configuration Steps
|
||||
|
||||
You can choose to either configure all supported frameworks at once **OR** configure one framework at a time. Choose the option that best suits your needs. If you see error messages, make sure you installed all dependencies.
|
||||
You can choose to either configure all supported frameworks at once **OR**
|
||||
configure one framework at a time. Choose the option that best suits your needs.
|
||||
If you see error messages, check for any missing dependencies.
|
||||
|
||||
> **NOTE**: Since the TensorFlow framework is not officially supported on CentOS*, the Model Optimizer for TensorFlow can't be configured and ran on those systems.
|
||||
> **NOTE**: The TensorFlow\* framework is not officially supported on CentOS\*,
|
||||
so the Model Optimizer for TensorFlow cannot be configured on, or run with
|
||||
CentOS.
|
||||
|
||||
> **IMPORTANT**: The Internet access is required to execute the following steps successfully. If you have access to the Internet through the proxy server only, please make sure that it is configured in your OS environment.
|
||||
> **IMPORTANT**: Internet access is required to execute the following steps
|
||||
successfully. If you access the Internet via proxy server only, please make
|
||||
sure that it is configured in your OS environment as well.
|
||||
|
||||
**Option 1: Configure all supported frameworks at the same time**
|
||||
|
||||
1. Go to the Model Optimizer prerequisites directory:
|
||||
```sh
|
||||
cd <DLDT_DIR>/model_optimizer/install_prerequisites
|
||||
cd <OPENVINO_DIR>/model_optimizer/install_prerequisites
|
||||
```
|
||||
2. Run the script to configure the Model Optimizer for Caffe,
|
||||
TensorFlow, MXNet, Kaldi\*, and ONNX:
|
||||
@@ -47,11 +63,12 @@ sudo ./install_prerequisites.sh
|
||||
|
||||
**Option 2: Configure each framework separately**
|
||||
|
||||
Configure individual frameworks separately **ONLY** if you did not select **Option 1** above.
|
||||
Configure individual frameworks separately **ONLY** if you did not select
|
||||
**Option 1** above.
|
||||
|
||||
1. Go to the Model Optimizer prerequisites directory:
|
||||
```sh
|
||||
cd <DLDT_DIR>/model_optimizer/install_prerequisites
|
||||
cd <OPENVINO_DIR>/model_optimizer/install_prerequisites
|
||||
```
|
||||
2. Run the script for your model framework. You can run more than one script:
|
||||
|
||||
@@ -79,25 +96,45 @@ cd <DLDT_DIR>/model_optimizer/install_prerequisites
|
||||
```sh
|
||||
sudo ./install_prerequisites_kaldi.sh
|
||||
```
|
||||
The Model Optimizer is configured for one or more frameworks. Continue to the next session to download and prepare a model for running a sample inference.
|
||||
The Model Optimizer is configured for one or more frameworks. Continue to the
|
||||
next session to download and prepare a model for running a sample inference.
|
||||
|
||||
## Prepare a Model for Sample Inference
|
||||
|
||||
This paragraph contains the steps to get the pre-trained model for sample inference and to prepare the model's optimized Intermediate Representation that Inference Engine uses.
|
||||
This section describes how to get a pre-trained model for sample inference
|
||||
and how to prepare the optimized Intermediate Representation (IR) that
|
||||
Inference Inference Engine uses.
|
||||
|
||||
|
||||
### Download a Trained Model
|
||||
|
||||
To run the Image Classification Sample you'll need a pre-trained model to run the inference on. This guide will use the public SqueezeNet 1.1 Caffe* model. You can find and download this model manually or use the OpenVINO™ [Model Downloader](https://github.com/opencv/open_model_zoo/tree/master/model_downloader).
|
||||
To run the Image Classification Sample, you need a pre-trained model to run
|
||||
the inference on. This guide uses the public SqueezeNet 1.1 Caffe\* model.
|
||||
You can find and download this model manually or use the OpenVINO™
|
||||
[Model Downloader].
|
||||
|
||||
With the Model Downloader, you can download other popular public deep learning topologies and the [OpenVINO™ pre-trained models](https://github.com/opencv/open_model_zoo/tree/master/intel_models) prepared for running inference for a wide list of inference scenarios: object detection, object recognition, object re-identification, human pose estimation, action recognition and others.
|
||||
With the Model Downloader, you can download other popular public deep learning
|
||||
topologies and [OpenVINO™ pre-trained models], which are already prepared for
|
||||
running inference upon a wide list of inference scenarios:
|
||||
|
||||
To download the SqueezeNet 1.1 Caffe* model to a models folder with the Model Downloader:
|
||||
1. Install the [prerequisites](https://github.com/opencv/open_model_zoo/tree/master/model_downloader#prerequisites).
|
||||
2. Run the `downloader.py` with specifying the topology name and a `<models_dir>` path. For example to download the model to the `~/public_models` directory:
|
||||
* object detection,
|
||||
* object recognition,
|
||||
* object re-identification,
|
||||
* human pose estimation,
|
||||
* action recognition, and others.
|
||||
|
||||
To download the SqueezeNet 1.1 Caffe* model to a `models` folder (referred to
|
||||
as `<models_dir>` below) with the Model Downloader:
|
||||
|
||||
1. Install the [prerequisites].
|
||||
2. Run the `downloader.py` script, specifying the topology name and the path
|
||||
to your `<models_dir>`. For example, to download the model to a directory
|
||||
named `~/public_models`, run:
|
||||
```sh
|
||||
./downloader.py --name squeezenet1.1 --output_dir ~/public_models
|
||||
```
|
||||
When the model files are successfully downloaded the output similar to the following is printed:
|
||||
When the model files are successfully downloaded, output similar to the
|
||||
following is printed:
|
||||
```sh
|
||||
###############|| Downloading topologies ||###############
|
||||
|
||||
@@ -117,59 +154,74 @@ To download the SqueezeNet 1.1 Caffe* model to a models folder with the Model Do
|
||||
|
||||
1. Create a `<ir_dir>` directory that will contains the Intermediate Representation (IR) of the model.
|
||||
|
||||
2. Inference Engine can perform inference on a [list of supported devices](https://docs.openvinotoolkit.org/latest/_docs_IE_DG_supported_plugins_Supported_Devices.html) using specific device plugins. Different plugins support models of [different precision formats](https://docs.openvinotoolkit.org/latest/_docs_IE_DG_supported_plugins_Supported_Devices.html#supported_model_formats), such as FP32, FP16, INT8. To prepare an IR to run inference on a particular hardware, run the Model Optimizer with the appropriate `--data_type` options:
|
||||
2. Inference Engine can perform inference on a [list of supported devices]
|
||||
using specific device plugins. Different plugins support models of
|
||||
[different precision formats], such as `FP32`, `FP16`, `INT8`. To prepare an
|
||||
IR to run inference on particular hardware, run the Model Optimizer with the
|
||||
appropriate `--data_type` options:
|
||||
|
||||
**For CPU (FP32):**
|
||||
```sh
|
||||
python3 <DLDT_DIR>/model_optimizer/mo.py --input_model <models_dir>/classification/squeezenet/1.1/caffe/squeezenet1.1.caffemodel --data_type FP32 --output_dir <ir_dir>
|
||||
python3 <OPENVINO_DIR>/model_optimizer/mo.py --input_model <models_dir>/classification/squeezenet/1.1/caffe/squeezenet1.1.caffemodel --data_type FP32 --output_dir <ir_dir>
|
||||
```
|
||||
|
||||
**For GPU and MYRIAD (FP16):**
|
||||
```sh
|
||||
python3 <DLDT_DIR>/model_optimizer/mo.py --input_model <models_dir>/classification/squeezenet/1.1/caffe/squeezenet1.1.caffemodel --data_type FP16 --output_dir <ir_dir>
|
||||
python3 <OPENVINO_DIR>/model_optimizer/mo.py --input_model <models_dir>/classification/squeezenet/1.1/caffe/squeezenet1.1.caffemodel --data_type FP16 --output_dir <ir_dir>
|
||||
```
|
||||
After the Model Optimizer script is completed, the produced IR files (`squeezenet1.1.xml`, `squeezenet1.1.bin`) are in the specified `<ir_dir>` directory.
|
||||
|
||||
3. Copy the `squeezenet1.1.labels` file from the `<DLDT_DIR>/inference-engine/samples/sample_data/` to the model IR directory. This file contains the classes that ImageNet uses so that the inference results show text instead of classification numbers:
|
||||
```sh
|
||||
cp <DLDT_DIR>/inference-engine/samples/sample_data/squeezenet1.1.labels <ir_dir>
|
||||
3. Copy the `squeezenet1.1.labels` file from the `<OPENVINO_DIR>/scripts/demo/`
|
||||
folder to the model IR directory. This file contains the classes that ImageNet
|
||||
uses so that the inference results show text instead of classification numbers:
|
||||
```sh
|
||||
cp <OPENVINO_DIR>/scripts/demo/squeezenet1.1.labels <ir_dir>
|
||||
```
|
||||
|
||||
Now you are ready to run the Image Classification Sample Application.
|
||||
|
||||
## Run the Image Classification Sample Application
|
||||
|
||||
The Inference Engine sample applications are automatically compiled when you built the Inference Engine using the [build instructions](inference-engine/README.md). The binary files are located in the `<DLDT_DIR>/inference-engine/bin/intel64/Release` directory.
|
||||
The Inference Engine sample applications are automatically compiled when you
|
||||
built the Inference Engine using the [build instructions](inference-engine/README.md).
|
||||
The binary files are located in the `<OPENVINO_DIR>/inference-engine/bin/intel64/Release`
|
||||
directory.
|
||||
|
||||
Follow the steps below to run the Image Classification sample application on the prepared IR and with an input image:
|
||||
To run the Image Classification sample application with an input image on the prepared IR:
|
||||
|
||||
1. Go to the samples build directory:
|
||||
```sh
|
||||
cd <DLDT_DIR>/inference-engine/bin/intel64/Release
|
||||
```
|
||||
2. Run the sample executable with specifying the `car.png` file from the `<DLDT_DIR>/inference-engine/samples/sample_data/` directory as an input image, the IR of your model and a plugin for a hardware device to perform inference on:
|
||||
cd <OPENVINO_DIR>/inference-engine/bin/intel64/Release
|
||||
|
||||
2. Run the sample executable with specifying the `car.png` file from the
|
||||
`<OPENVINO_DIR>/scripts/demo/` directory as an input
|
||||
image, the IR of your model and a plugin for a hardware device to perform
|
||||
inference on:
|
||||
|
||||
**For CPU:**
|
||||
```sh
|
||||
./classification_sample -i <DLDT_DIR>/inference-engine/samples/sample_data/car.png -m <ir_dir>/squeezenet1.1.xml -d CPU
|
||||
./classification_sample -i <OPENVINO_DIR>/scripts/demo/car.png -m <ir_dir>/squeezenet1.1.xml -d CPU
|
||||
```
|
||||
|
||||
**For GPU:**
|
||||
```sh
|
||||
./classification_sample -i <DLDT_DIR>/inference-engine/samples/sample_data/car.png -m <ir_dir>/squeezenet1.1.xml -d GPU
|
||||
./classification_sample -i <OPENVINO_DIR>/scripts/demo/car.png -m <ir_dir>/squeezenet1.1.xml -d GPU
|
||||
```
|
||||
|
||||
**For MYRIAD:**
|
||||
>**NOTE**: Running inference on VPU devices (Intel® Movidius™ Neural Compute Stick or Intel® Neural Compute Stick 2) with the MYRIAD plugin requires performing [additional hardware configuration steps](inference-engine/README.md#optional-additional-installation-steps-for-the-intel-movidius-neural-compute-stick-and-neural-compute-stick-2).
|
||||
```sh
|
||||
./classification_sample -i <DLDT_DIR>/inference-engine/samples/sample_data/car.png -m <ir_dir>/squeezenet1.1.xml -d MYRIAD
|
||||
|
||||
>**NOTE**: Running inference on VPU devices (Intel® Movidius™ Neural Compute
|
||||
Stick or Intel® Neural Compute Stick 2) with the MYRIAD plugin requires
|
||||
performing [additional hardware configuration steps](inference-engine/README.md#optional-additional-installation-steps-for-the-intel-movidius-neural-compute-stick-and-neural-compute-stick-2).
|
||||
```sh
|
||||
./classification_sample -i <OPENVINO_DIR>/scripts/demo/car.png -m <ir_dir>/squeezenet1.1.xml -d MYRIAD
|
||||
```
|
||||
|
||||
When the Sample Application completes, you will have the label and confidence for the top-10 categories printed on the screen. Below is a sample output with inference results on CPU:
|
||||
```sh
|
||||
Top 10 results:
|
||||
|
||||
Image /home/user/dldt/inference-engine/samples/sample_data/car.png
|
||||
Image /home/user/openvino/scripts/demo/car.png
|
||||
|
||||
classid probability label
|
||||
------- ----------- -----
|
||||
@@ -199,5 +251,12 @@ Throughput: 375.3339402 FPS
|
||||
* [Inference Engine build instructions](inference-engine/README.md)
|
||||
* [Introduction to Intel® Deep Learning Deployment Toolkit](https://docs.openvinotoolkit.org/latest/_docs_IE_DG_Introduction.html)
|
||||
* [Inference Engine Developer Guide](https://docs.openvinotoolkit.org/latest/_docs_IE_DG_Deep_Learning_Inference_Engine_DevGuide.html)
|
||||
* [Model Optimizer Developer Guide](https://docs.openvinotoolkit.org/latest/_docs_MO_DG_Deep_Learning_Model_Optimizer_DevGuide.html)
|
||||
* [Model Optimizer Developer Guide]
|
||||
* [Inference Engine Samples Overview](https://docs.openvinotoolkit.org/latest/_docs_IE_DG_Samples_Overview.html).
|
||||
|
||||
[Model Optimizer Developer Guide]:https://docs.openvinotoolkit.org/latest/_docs_MO_DG_Deep_Learning_Model_Optimizer_DevGuide.html
|
||||
[Model Downloader]:https://github.com/opencv/open_model_zoo/tree/master/tools/downloader
|
||||
[OpenVINO™ pre-trained models]:https://github.com/opencv/open_model_zoo/tree/master/models/intel
|
||||
[prerequisites]:https://github.com/opencv/open_model_zoo/tree/master/tools/downloader#prerequisites
|
||||
[list of supported devices]:https://docs.openvinotoolkit.org/latest/_docs_IE_DG_supported_plugins_Supported_Devices.html
|
||||
[different precision formats]:https://docs.openvinotoolkit.org/latest/_docs_IE_DG_supported_plugins_Supported_Devices.html#supported_model_formats
|
||||
@@ -1,150 +1,78 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
|
||||
|
||||
project(InferenceEngine)
|
||||
|
||||
set(DEV_BUILD TRUE)
|
||||
set(CMAKE_MODULE_PATH "${IE_MAIN_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
||||
|
||||
include(CTest)
|
||||
include(features_ie)
|
||||
|
||||
## WA for problem with gtest submodule. It cannot detect uint32 type.
|
||||
## remove Gtest submodule and this two lines together
|
||||
include (CheckTypeSize)
|
||||
check_type_size (uint32_t uint32_t LANGUAGE CXX)
|
||||
# include developer package
|
||||
include(developer_package_ie)
|
||||
|
||||
if (UNIX AND NOT APPLE)
|
||||
set(LINUX TRUE)
|
||||
# These options are shared with 3rdparty plugins
|
||||
# by means of developer package
|
||||
include(check_features_ie)
|
||||
|
||||
# resolving dependencies for the project
|
||||
include(dependencies)
|
||||
|
||||
|
||||
# Fuzz tests also building without ENABLE_FUZZING
|
||||
include(fuzzing)
|
||||
|
||||
if (ENABLE_FUZZING)
|
||||
enable_fuzzing()
|
||||
endif()
|
||||
|
||||
option (OS_FOLDER "create OS dedicated folder in output" OFF)
|
||||
|
||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l")
|
||||
set (ARCH_FOLDER armv7l)
|
||||
elseif("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
|
||||
set (ARCH_FOLDER intel64)
|
||||
else()
|
||||
set (ARCH_FOLDER ia32)
|
||||
find_package(ngraph QUIET)
|
||||
if(NOT ngraph_FOUND)
|
||||
set(ngraph_DIR ${CMAKE_BINARY_DIR}/ngraph)
|
||||
endif()
|
||||
find_package(ngraph REQUIRED)
|
||||
|
||||
if (OS_FOLDER)
|
||||
message ("**** OS FOLDER IS: [${OS_FOLDER}]")
|
||||
if ("${OS_FOLDER}" STREQUAL "ON")
|
||||
message ("**** USING OS FOLDER: [${CMAKE_SYSTEM_NAME}]")
|
||||
set (BIN_FOLDER bin/${CMAKE_SYSTEM_NAME}/${ARCH_FOLDER})
|
||||
else()
|
||||
set (BIN_FOLDER bin/${OS_FOLDER}/${ARCH_FOLDER})
|
||||
endif()
|
||||
else()
|
||||
set (BIN_FOLDER bin/${ARCH_FOLDER})
|
||||
endif()
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
set (IE_MAIN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set (CMAKE_MODULE_PATH "${IE_MAIN_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
||||
unset(IEDeveloperPackageTargets CACHE)
|
||||
function(ie_developer_export_targets)
|
||||
set(IEDeveloperPackageTargets "${IEDeveloperPackageTargets};${ARGV}")
|
||||
|
||||
#printing debug messages
|
||||
include (debug)
|
||||
# to allow exporting of aliased targets with the original names
|
||||
foreach(target_name ${IEDeveloperPackageTargets})
|
||||
if(TARGET "${target_name}")
|
||||
get_target_property(original_name ${target_name} ALIASED_TARGET)
|
||||
if(TARGET "${original_name}")
|
||||
message(STATUS "The name ${target_name} is an ALIAS for ${original_name}. "
|
||||
"It will be exported to the InferenceEngineDeveloperPackage with the original name.")
|
||||
list(REMOVE_ITEM IEDeveloperPackageTargets ${target_name})
|
||||
list(APPEND IEDeveloperPackageTargets ${original_name})
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
||||
debug_message(STATUS "CMAKE_BUILD_TYPE not defined, 'Release' will be used")
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
endif()
|
||||
message(STATUS "BUILD_CONFIGURATION: ${CMAKE_BUILD_TYPE}")
|
||||
list(REMOVE_DUPLICATES IEDeveloperPackageTargets)
|
||||
set(IEDeveloperPackageTargets "${IEDeveloperPackageTargets}" CACHE INTERNAL
|
||||
"Paths to extra Inference Engine plugins" FORCE)
|
||||
endfunction()
|
||||
|
||||
if(COVERAGE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage -O0")
|
||||
endif()
|
||||
function(ie_developer_export)
|
||||
export(TARGETS ${IEDeveloperPackageTargets} NAMESPACE IE::
|
||||
APPEND FILE "${CMAKE_BINARY_DIR}/targets_developer.cmake")
|
||||
|
||||
if (UNIX)
|
||||
SET(LIB_DL ${CMAKE_DL_LIBS})
|
||||
endif()
|
||||
# Custom target to build only Inference Engine Developer Package targets
|
||||
add_custom_target(ie_dev_targets ALL DEPENDS ${IEDeveloperPackageTargets})
|
||||
endfunction()
|
||||
|
||||
set (OUTPUT_ROOT ${IE_MAIN_SOURCE_DIR})
|
||||
|
||||
include(os_flags)
|
||||
|
||||
#resolving dependencies for the project
|
||||
include (dependencies)
|
||||
|
||||
set(CMAKE_DEBUG_POSTFIX ${IE_DEBUG_POSTFIX})
|
||||
set(CMAKE_RELEASE_POSTFIX ${IE_RELEASE_POSTFIX})
|
||||
|
||||
if (WIN32)
|
||||
# Support CMake multiconfiguration for Visual Studio build
|
||||
set(IE_BUILD_POSTFIX $<$<CONFIG:Debug>:${IE_DEBUG_POSTFIX}>$<$<CONFIG:Release>:${IE_RELEASE_POSTFIX}>)
|
||||
set(IE_BUILD_CONFIGURATION $<CONFIG>)
|
||||
else ()
|
||||
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug" )
|
||||
set(IE_BUILD_POSTFIX ${IE_DEBUG_POSTFIX})
|
||||
else()
|
||||
set(IE_BUILD_POSTFIX ${IE_RELEASE_POSTFIX})
|
||||
endif()
|
||||
set(IE_BUILD_CONFIGURATION ${CMAKE_BUILD_TYPE})
|
||||
endif()
|
||||
|
||||
add_definitions(-DIE_BUILD_POSTFIX=\"${IE_BUILD_POSTFIX}\")
|
||||
|
||||
if(NOT(UNIX))
|
||||
if (WIN32)
|
||||
#set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
|
||||
#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
|
||||
endif()
|
||||
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
||||
set (CMAKE_LIBRARY_PATH ${OUTPUT_ROOT}/${BIN_FOLDER})
|
||||
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
||||
set (CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
||||
set (CMAKE_PDB_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
||||
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
||||
set (LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
||||
set (LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_DIRECTORY}) # compatibility issue: linux uses LIBRARY_OUTPUT_PATH, windows uses LIBRARY_OUTPUT_DIRECTORY
|
||||
else ()
|
||||
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER}/${IE_BUILD_CONFIGURATION}/lib)
|
||||
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER}/${IE_BUILD_CONFIGURATION}/lib)
|
||||
set (CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER}/${IE_BUILD_CONFIGURATION})
|
||||
set (CMAKE_PDB_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER}/${IE_BUILD_CONFIGURATION})
|
||||
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER}/${IE_BUILD_CONFIGURATION})
|
||||
set (LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER}/${IE_BUILD_CONFIGURATION}/lib)
|
||||
set (LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_DIRECTORY}/lib)
|
||||
endif()
|
||||
|
||||
if (APPLE)
|
||||
set(CMAKE_MACOSX_RPATH 1)
|
||||
endif(APPLE)
|
||||
|
||||
#rpath fully disabled
|
||||
if (NOT ENABLE_PLUGIN_RPATH)
|
||||
SET (CMAKE_SKIP_RPATH TRUE)
|
||||
endif()
|
||||
|
||||
#Use solution folders.
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
#message("=====================> ${CMAKE_BUILD_TYPE} <=====================")
|
||||
|
||||
message (STATUS "PROJECT ............................... " ${PROJECT_NAME})
|
||||
message (STATUS "CMAKE_BINARY_DIR ...................... " ${CMAKE_BINARY_DIR})
|
||||
message (STATUS "IE_MAIN_SOURCE_DIR .................... " ${IE_MAIN_SOURCE_DIR})
|
||||
message (STATUS "CMAKE_GENERATOR ....................... " ${CMAKE_GENERATOR})
|
||||
message (STATUS "CMAKE_C_COMPILER_ID ................... " ${CMAKE_C_COMPILER_ID})
|
||||
|
||||
include(sdl)
|
||||
|
||||
set (CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
include (sanitizer)
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
include(cpplint)
|
||||
add_subdirectory(thirdparty)
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(tests)
|
||||
add_subdirectory(thirdparty)
|
||||
set(InferenceEngine_DIR "${CMAKE_BINARY_DIR}")
|
||||
|
||||
#to be able to link
|
||||
set (LIB_FOLDER ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER}/${IE_BUILD_CONFIGURATION}/lib)
|
||||
if(ENABLE_TESTS)
|
||||
add_subdirectory(tests_deprecated)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
add_subdirectory(tools)
|
||||
|
||||
# gflags and format_reader targets are kept inside of samples directory and
|
||||
# they must be built even if samples build is disabled (required for tests and tools).
|
||||
@@ -159,4 +87,123 @@ if (ENABLE_PYTHON)
|
||||
add_subdirectory(ie_bridges/python)
|
||||
endif()
|
||||
|
||||
if (ENABLE_C)
|
||||
add_subdirectory(ie_bridges/c)
|
||||
endif()
|
||||
|
||||
add_cpplint_report_target()
|
||||
|
||||
#
|
||||
# Install
|
||||
#
|
||||
|
||||
# install C++ samples
|
||||
|
||||
ie_cpack_add_component(cpp_samples REQUIRED DEPENDS core)
|
||||
|
||||
if(UNIX)
|
||||
install(DIRECTORY samples/
|
||||
DESTINATION ${IE_CPACK_IE_DIR}/samples/cpp
|
||||
COMPONENT cpp_samples
|
||||
USE_SOURCE_PERMISSIONS
|
||||
PATTERN *.bat EXCLUDE
|
||||
PATTERN speech_libs_and_demos EXCLUDE)
|
||||
elseif(WIN32)
|
||||
install(DIRECTORY samples/
|
||||
DESTINATION ${IE_CPACK_IE_DIR}/samples/cpp
|
||||
COMPONENT cpp_samples
|
||||
USE_SOURCE_PERMISSIONS
|
||||
PATTERN *.sh EXCLUDE
|
||||
PATTERN speech_libs_and_demos EXCLUDE)
|
||||
endif()
|
||||
|
||||
# install C samples
|
||||
|
||||
ie_cpack_add_component(c_samples REQUIRED DEPENDS core)
|
||||
|
||||
if(UNIX)
|
||||
install(PROGRAMS samples/build_samples.sh
|
||||
DESTINATION ${IE_CPACK_IE_DIR}/samples/c
|
||||
COMPONENT c_samples)
|
||||
elseif(WIN32)
|
||||
install(PROGRAMS samples/build_samples_msvc.bat
|
||||
DESTINATION ${IE_CPACK_IE_DIR}/samples/c
|
||||
COMPONENT c_samples)
|
||||
endif()
|
||||
|
||||
install(DIRECTORY ie_bridges/c/samples/
|
||||
DESTINATION ${IE_CPACK_IE_DIR}/samples/c
|
||||
COMPONENT c_samples
|
||||
PATTERN ie_bridges/c/samples/CMakeLists.txt EXCLUDE)
|
||||
|
||||
install(FILES samples/CMakeLists.txt
|
||||
DESTINATION ${IE_CPACK_IE_DIR}/samples/c
|
||||
COMPONENT c_samples)
|
||||
|
||||
# install Python samples
|
||||
|
||||
if(ENABLE_PYTHON)
|
||||
ie_cpack_add_component(python_samples REQUIRED DEPENDS core)
|
||||
|
||||
install(DIRECTORY ${ie_python_api_SOURCE_DIR}/sample/
|
||||
DESTINATION ${IE_CPACK_IE_DIR}/samples/python
|
||||
COMPONENT python_samples)
|
||||
endif()
|
||||
|
||||
#
|
||||
# Developer package
|
||||
#
|
||||
|
||||
ie_developer_export_targets(format_reader)
|
||||
ie_developer_export_targets(${NGRAPH_LIBRARIES})
|
||||
|
||||
ie_developer_export()
|
||||
|
||||
configure_file(
|
||||
"${IE_MAIN_SOURCE_DIR}/cmake/developer_package_config.cmake.in"
|
||||
"${CMAKE_BINARY_DIR}/InferenceEngineDeveloperPackageConfig.cmake"
|
||||
@ONLY)
|
||||
|
||||
configure_file(
|
||||
"${IE_MAIN_SOURCE_DIR}/cmake/share/InferenceEngineConfig-version.cmake.in"
|
||||
"${CMAKE_BINARY_DIR}/InferenceEngineDeveloperPackageConfig-version.cmake"
|
||||
COPYONLY)
|
||||
|
||||
#
|
||||
# Coverage
|
||||
#
|
||||
|
||||
if(COVERAGE)
|
||||
include(coverage_ie)
|
||||
endif()
|
||||
|
||||
#
|
||||
# Add plugins
|
||||
#
|
||||
|
||||
function(register_extra_plugins)
|
||||
set(InferenceEngineDeveloperPackage_DIR "${CMAKE_CURRENT_BINARY_DIR}/build-plugins")
|
||||
set(iedevconfig_file "${InferenceEngineDeveloperPackage_DIR}/InferenceEngineDeveloperPackageConfig.cmake")
|
||||
file(REMOVE "${iedevconfig_file}")
|
||||
|
||||
file(WRITE "${iedevconfig_file}" "\# !! AUTOGENERATED: DON'T EDIT !!\n\n")
|
||||
file(APPEND "${iedevconfig_file}" "ie_deprecated_no_errors()\n")
|
||||
|
||||
foreach(target IN LISTS IEDeveloperPackageTargets)
|
||||
if(target)
|
||||
file(APPEND "${iedevconfig_file}" "add_library(IE::${target} ALIAS ${target})\n")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# automatically import plugins from the 'plugins' folder
|
||||
file(GLOB local_extra_plugins "plugins/*")
|
||||
list(APPEND local_extra_plugins "${OpenVINO_MAIN_SOURCE_DIR}/docs/template_plugin")
|
||||
|
||||
foreach(plugin_path IN LISTS IE_EXTRA_PLUGINS local_extra_plugins)
|
||||
get_filename_component(plugin_dir "${plugin_path}" NAME)
|
||||
message(STATUS "Register ${plugin_dir} to be built in build-plugins/${plugin_dir}")
|
||||
add_subdirectory("${plugin_path}" "build-plugins/${plugin_dir}")
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
register_extra_plugins()
|
||||
|
||||
@@ -1,481 +0,0 @@
|
||||
# Build Inference Engine
|
||||
|
||||
## Contents
|
||||
|
||||
- [Introduction](#introduction)
|
||||
- [Build on Linux* Systems](#build-on-linux-systems)
|
||||
- [Software Requirements](#software-requirements)
|
||||
- [Build Steps](#build-steps)
|
||||
- [Additional Build Options](#additional-build-options)
|
||||
- [Build for Raspbian* Stretch OS](#build-for-raspbian-stretch-os)
|
||||
- [Hardware Requirements](#hardware-requirements)
|
||||
- [Native Compilation](#native-compilation)
|
||||
- [Cross Compilation Using Docker*](#cross-compilation-using-docker)
|
||||
- [Additional Build Options](#additional-build-options-1)
|
||||
- [Build on Windows* Systems](#build-on-windows-systems)
|
||||
- [Software Requirements](#software-requirements-1)
|
||||
- [Build Steps](#build-steps-1)
|
||||
- [Additional Build Options](#additional-build-options-2)
|
||||
- [Building Inference Engine with Ninja* Build System](#building-inference-engine-with-ninja-build-system)
|
||||
- [Build on macOS* Systems](#build-on-macos-systems)
|
||||
- [Software Requirements](#software-requirements-2)
|
||||
- [Build Steps](#build-steps-2)
|
||||
- [Additional Build Options](#additional-build-options-3)
|
||||
- [Use Custom OpenCV Builds for Inference Engine](#use-custom-opencv-builds-for-inference-engine)
|
||||
- [(Optional) Additional Installation Steps for the Intel® Movidius™ Neural Compute Stick and Neural Compute Stick 2](#optional-additional-installation-steps-for-the-intel-movidius-neural-compute-stick-and-neural-compute-stick-2)
|
||||
- [For Linux, Raspbian Stretch* OS](#for-linux-raspbian-stretch-os)
|
||||
- [For Windows](#for-windows-1)
|
||||
- [Next Steps](#next-steps)
|
||||
- [Additional Resources](#additional-resources)
|
||||
|
||||
## Introduction
|
||||
The Inference Engine can infer models in different formats with various input and output formats.
|
||||
|
||||
The open source version of Inference Engine includes the following plugins:
|
||||
|
||||
| PLUGIN | DEVICE TYPES |
|
||||
| ---------------------| -------------|
|
||||
| CPU plugin | Intel® Xeon® with Intel® AVX2 and AVX512, Intel® Core™ Processors with Intel® AVX2, Intel® Atom® Processors with Intel® SSE |
|
||||
| GPU plugin | Intel® Processor Graphics, including Intel® HD Graphics and Intel® Iris® Graphics |
|
||||
| GNA plugin | Intel® Speech Enabling Developer Kit, Amazon Alexa* Premium Far-Field Developer Kit, Intel® Pentium® Silver processor J5005, Intel® Celeron® processor J4005, Intel® Core™ i3-8121U processor |
|
||||
| MYRIAD plugin | Intel® Movidius™ Neural Compute Stick powered by the Intel® Movidius™ Myriad™ 2, Intel® Neural Compute Stick 2 powered by the Intel® Movidius™ Myriad™ X |
|
||||
| Heterogeneous plugin | Heterogeneous plugin enables computing for inference on one network on several Intel® devices. |
|
||||
|
||||
Inference Engine plugin for Intel® FPGA is distributed only in a binary form as a part of [Intel® Distribution of OpenVINO™](https://software.intel.com/en-us/openvino-toolkit).
|
||||
|
||||
## Build on Linux* Systems
|
||||
|
||||
The software was validated on:
|
||||
- Ubuntu\* 16.04 (64-bit) with default GCC\* 5.4.0
|
||||
- CentOS\* 7.4 (64-bit) with default GCC\* 4.8.5
|
||||
|
||||
### Software Requirements
|
||||
- [CMake\*](https://cmake.org/download/) 3.5 or higher
|
||||
- GCC\* 4.8 or higher to build the Inference Engine
|
||||
- Python 2.7 or higher for Inference Engine Python API wrapper
|
||||
- (Optional) [Install Intel® Graphics Compute Runtime for OpenCL™ Driver package 19.04.12237](https://github.com/intel/compute-runtime/releases/tag/19.04.12237).
|
||||
|
||||
### Build Steps
|
||||
1. Clone submodules:
|
||||
```sh
|
||||
cd dldt/inference-engine
|
||||
git submodule init
|
||||
git submodule update --recursive
|
||||
```
|
||||
2. Install build dependencies using the `install_dependencies.sh` script in the project root folder.
|
||||
3. By default, the build enables the Inference Engine GPU plugin to infer models on your Intel® Processor Graphics. This requires you to [Install Intel® Graphics Compute Runtime for OpenCL™ Driver package 19.04.12237](https://github.com/intel/compute-runtime/releases/tag/19.04.12237) before running the build. If you don't want to use the GPU plugin, use the `-DENABLE_CLDNN=ON` CMake build option and skip the installation of the Intel® Graphics Compute Runtime for OpenCL™ Driver.
|
||||
4. Create a build folder:
|
||||
```sh
|
||||
mkdir build && cd build
|
||||
```
|
||||
5. Inference Engine uses a CMake-based build system. In the created `build` directory, run `cmake` to fetch project dependencies and create Unix makefiles, then run `make` to build the project:
|
||||
```sh
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||
make --jobs=$(nproc --all)
|
||||
```
|
||||
|
||||
### Additional Build Options
|
||||
|
||||
You can use the following additional build options:
|
||||
|
||||
- Internal JIT GEMM implementation is used by default.
|
||||
|
||||
- To switch to OpenBLAS\* implementation, use the `GEMM=OPENBLAS` option and `BLAS_INCLUDE_DIRS` and `BLAS_LIBRARIES` CMake options to specify path to the OpenBLAS headers and library. For example use the following options on CentOS\*: `-DGEMM=OPENBLAS -DBLAS_INCLUDE_DIRS=/usr/include/openblas -DBLAS_LIBRARIES=/usr/lib64/libopenblas.so.0`.
|
||||
|
||||
- To switch to the optimized MKL-ML\* GEMM implementation, use `-DGEMM=MKL` and `-DMKLROOT=<path_to_MKL>` CMake options to specify a path to unpacked MKL-ML with the `include` and `lib` folders. MKL-ML\* package can be downloaded from the [MKL-DNN repository](https://github.com/intel/mkl-dnn/releases/download/v0.17/mklml_lnx_2019.0.1.20180928.tgz).
|
||||
|
||||
- Threading Building Blocks (TBB) is used by default. To build the Inference Engine with OpenMP* threading, set the `-DTHREADING=OMP` option.
|
||||
|
||||
- Required versions of TBB and OpenCV packages are downloaded automatically by the CMake-based script. If you want to use the automatically downloaded packages but you already have installed TBB or OpenCV packages configured in your environment, you may need to clean the `TBBROOT` and `OpenCV_DIR` environment variables before running the `cmake` command, otherwise they won't be downloaded and the build may fail if incompatible versions were installed.
|
||||
|
||||
- If the CMake-based build script can not find and download the OpenCV package that is supported on your platform, or if you want to use a custom build of the OpenCV library, refer to the [Use Custom OpenCV Builds](#use-custom-opencv-builds-for-inference-engine) section for details.
|
||||
|
||||
- To build the Python API wrapper, use the `-DENABLE_PYTHON=ON` option. To specify an exact Python version, use the following options:
|
||||
```sh
|
||||
-DPYTHON_EXECUTABLE=`which python3.7` \
|
||||
-DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.7m.so \
|
||||
-DPYTHON_INCLUDE_DIR=/usr/include/python3.7
|
||||
```
|
||||
|
||||
- To switch off/on the CPU and GPU plugins, use the `cmake` options `-DENABLE_MKL_DNN=ON/OFF` and `-DENABLE_CLDNN=ON/OFF` respectively.
|
||||
|
||||
5. Adding to your project
|
||||
|
||||
For CMake projects, set an environment variable `InferenceEngine_DIR`:
|
||||
|
||||
```sh
|
||||
export InferenceEngine_DIR=/path/to/dldt/inference-engine/build/
|
||||
```
|
||||
|
||||
Then you can find Inference Engine by `find_package`:
|
||||
|
||||
```cmake
|
||||
find_package(InferenceEngine)
|
||||
|
||||
include_directories(${InferenceEngine_INCLUDE_DIRS})
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} ${InferenceEngine_LIBRARIES} dl)
|
||||
```
|
||||
|
||||
## Build for Raspbian Stretch* OS
|
||||
|
||||
> **NOTE**: Only the MYRIAD plugin is supported.
|
||||
|
||||
### Hardware Requirements
|
||||
* Raspberry Pi\* 2 or 3 with Raspbian\* Stretch OS (32-bit). Check that it's CPU supports ARMv7 instruction set (`uname -m` command returns `armv7l`).
|
||||
|
||||
> **NOTE**: Despite the Raspberry Pi\* CPU is ARMv8, 32-bit OS detects ARMv7 CPU instruction set. The default `gcc` compiler applies ARMv6 architecture flag for compatibility with lower versions of boards. For more information, run the `gcc -Q --help=target` command and refer to the description of the `-march=` option.
|
||||
|
||||
You can compile the Inference Engine for Raspberry Pi\* in one of the two ways:
|
||||
* [Native Compilation](#native-compilation), which is the simplest way, but time-consuming
|
||||
* [Cross Compilation Using Docker*](#cross-compilation-using-docker), which is the recommended way
|
||||
|
||||
### Native Compilation
|
||||
Native compilation of the Inference Engine is the most straightforward solution. However, it might take at least one hour to complete on Raspberry Pi\* 3.
|
||||
|
||||
1. Install dependencies:
|
||||
|
||||
```bash
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y git cmake libusb-1.0-0-dev
|
||||
```
|
||||
|
||||
2. Go to the `inference-engine` directory of the cloned `dldt` repository:
|
||||
|
||||
```bash
|
||||
cd dldt/inference-engine
|
||||
```
|
||||
|
||||
3. Initialize submodules:
|
||||
|
||||
```bash
|
||||
git submodule init
|
||||
git submodule update --recursive
|
||||
```
|
||||
|
||||
4. Create a build folder:
|
||||
|
||||
```bash
|
||||
mkdir build && cd build
|
||||
```
|
||||
|
||||
5. Build the Inference Engine:
|
||||
|
||||
```bash
|
||||
cmake -DCMAKE_BUILD_TYPE=Release \
|
||||
-DENABLE_SSE42=OFF \
|
||||
-DTHREADING=SEQ \
|
||||
-DENABLE_GNA=OFF .. && make -j2
|
||||
```
|
||||
|
||||
### Cross Compilation Using Docker*
|
||||
|
||||
This compilation was tested on the following configuration:
|
||||
|
||||
* Host: Ubuntu\* 16.04 (64-bit, Intel® Core™ i7-6700K CPU @ 4.00GHz × 8)
|
||||
* Target: Raspbian\* Stretch (32-bit, ARMv7, Raspberry Pi\* 3)
|
||||
|
||||
1. Install Docker\*:
|
||||
|
||||
```bash
|
||||
sudo apt-get install -y docker.io
|
||||
```
|
||||
|
||||
2. Add a current user to `docker` group:
|
||||
|
||||
```bash
|
||||
sudo usermod -a -G docker $USER
|
||||
```
|
||||
|
||||
Log out and log in for this to take effect.
|
||||
|
||||
3. Create a directory named `ie_cross_armhf` and add a text file named `Dockerfile`
|
||||
with the following content:
|
||||
|
||||
```docker
|
||||
FROM debian:stretch
|
||||
|
||||
USER root
|
||||
|
||||
RUN dpkg --add-architecture armhf && \
|
||||
apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
build-essential \
|
||||
crossbuild-essential-armhf \
|
||||
git \
|
||||
wget \
|
||||
libusb-1.0-0-dev:armhf \
|
||||
libgtk-3-dev:armhf \
|
||||
libavcodec-dev:armhf \
|
||||
libavformat-dev:armhf \
|
||||
libswscale-dev:armhf \
|
||||
libgstreamer1.0-dev:armhf \
|
||||
libgstreamer-plugins-base1.0-dev:armhf \
|
||||
libpython3-dev:armhf \
|
||||
python3-pip
|
||||
|
||||
RUN wget https://www.cmake.org/files/v3.14/cmake-3.14.3.tar.gz && \
|
||||
tar xf cmake-3.14.3.tar.gz && \
|
||||
(cd cmake-3.14.3 && ./bootstrap --parallel=$(nproc --all) && make --jobs=$(nproc --all) && make install) && \
|
||||
rm -rf cmake-3.14.3 cmake-3.14.3.tar.gz
|
||||
|
||||
```
|
||||
|
||||
It uses the Debian\* Stretch (Debian 9) OS for compilation because it is a base of the Raspbian\* Stretch.
|
||||
|
||||
4. Build a Docker\* image:
|
||||
|
||||
```bash
|
||||
docker image build -t ie_cross_armhf ie_cross_armhf
|
||||
```
|
||||
|
||||
5. Run Docker\* container with mounted source code folder from host:
|
||||
|
||||
```bash
|
||||
docker run -it -v /absolute/path/to/dldt:/dldt ie_cross_armhf /bin/bash
|
||||
```
|
||||
|
||||
6. While in the container:
|
||||
|
||||
1. Go to the `inference-engine` directory of the cloned `dldt` repository:
|
||||
|
||||
```bash
|
||||
cd dldt/inference-engine
|
||||
```
|
||||
|
||||
2. Create a build folder:
|
||||
|
||||
```bash
|
||||
mkdir build && cd build
|
||||
```
|
||||
|
||||
3. Build the Inference Engine:
|
||||
|
||||
```bash
|
||||
cmake -DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_TOOLCHAIN_FILE="../cmake/arm.toolchain.cmake" \
|
||||
-DTHREADS_PTHREAD_ARG="-pthread" \
|
||||
-DENABLE_SSE42=OFF \
|
||||
-DTHREADING=SEQ \
|
||||
-DENABLE_GNA=OFF .. && make --jobs=$(nproc --all)
|
||||
```
|
||||
|
||||
7. Press "Ctrl"+"D" to exit from Docker\*. You can find the resulting binaries in the `dldt/inference-engine/bin/armv7l/` directory and the OpenCV* installation in the `dldt/inference-engine/temp`.
|
||||
|
||||
>**NOTE**: Native applications that link to cross-compiled Inference Engine library require an extra compilation flag `-march=armv7-a`.
|
||||
|
||||
### Additional Build Options
|
||||
|
||||
You can use the following additional build options:
|
||||
|
||||
- Required versions of OpenCV packages are downloaded automatically by the CMake-based script. If you want to use the automatically downloaded packages but you already have installed OpenCV packages configured in your environment, you may need to clean the `OpenCV_DIR` environment variable before running the `cmake` command, otherwise they won't be downloaded and the build may fail if incompatible versions were installed.
|
||||
|
||||
- If the CMake-based build script can not find and download the OpenCV package that is supported on your platform, or if you want to use a custom build of the OpenCV library, refer to the [Use Custom OpenCV Builds](#use-custom-opencv-builds-for-inference-engine) section for details.
|
||||
|
||||
- To build Python API wrapper, install `libpython3-dev:armhf` and `python3-pip` packages using `apt-get`, then install `numpy` and `cython` python modules using `pip3` command and add the following cmake options:
|
||||
```sh
|
||||
-DENABLE_PYTHON=ON \
|
||||
-DPYTHON_EXECUTABLE=/usr/bin/python3.5 \
|
||||
-DPYTHON_LIBRARY=/usr/lib/arm-linux-gnueabihf/libpython3.5m.so \
|
||||
-DPYTHON_INCLUDE_DIR=/usr/include/python3.5
|
||||
```
|
||||
|
||||
## Build on Windows* Systems
|
||||
|
||||
The software was validated on:
|
||||
- Microsoft\* Windows\* 10 (64-bit) with Visual Studio 2017 and Intel® C++ Compiler 2018 Update 3
|
||||
|
||||
### Software Requirements
|
||||
- [CMake\*](https://cmake.org/download/) 3.5 or higher
|
||||
- [OpenBLAS\*](https://sourceforge.net/projects/openblas/files/v0.2.14/OpenBLAS-v0.2.14-Win64-int64.zip/download) and [mingw64\* runtime dependencies](https://sourceforge.net/projects/openblas/files/v0.2.14/mingw64_dll.zip/download).
|
||||
- [Intel® C++ Compiler](https://software.intel.com/en-us/intel-parallel-studio-xe) 18.0 to build the Inference Engine on Windows.
|
||||
- (Optional) [Intel® Graphics Driver for Windows* [25.20] driver package](https://downloadcenter.intel.com/download/28646/Intel-Graphics-Windows-10-DCH-Drivers?product=80939).
|
||||
- Python 3.4 or higher for Inference Engine Python API wrapper
|
||||
|
||||
### Build Steps
|
||||
1. Clone submodules:
|
||||
```sh
|
||||
git submodule init
|
||||
git submodule update --recursive
|
||||
```
|
||||
2. Download and install [Intel® C++ Compiler](https://software.intel.com/en-us/intel-parallel-studio-xe) 18.0
|
||||
3. Install OpenBLAS:
|
||||
1. Download [OpenBLAS\*](https://sourceforge.net/projects/openblas/files/v0.2.14/OpenBLAS-v0.2.14-Win64-int64.zip/download)
|
||||
2. Unzip the downloaded package to a directory on your machine. In this document, this directory is referred to as `<OPENBLAS_DIR>`.
|
||||
4. By default, the build enables the Inference Engine GPU plugin to infer models on your Intel® Processor Graphics. This requires you to [download and install the Intel® Graphics Driver for Windows* [25.20] driver package](https://downloadcenter.intel.com/download/28646/Intel-Graphics-Windows-10-DCH-Drivers?product=80939) before running the build. If you don't want to use the GPU plugin, use the `-DENABLE_CLDNN=ON` CMake build option and skip the installation of the Intel® Graphics Driver.
|
||||
5. Create build directory:
|
||||
```sh
|
||||
mkdir build
|
||||
```
|
||||
6. In the `build` directory, run `cmake` to fetch project dependencies and generate a Visual Studio solution:
|
||||
```sh
|
||||
cd build
|
||||
cmake -G "Visual Studio 15 2017 Win64" -T "Intel C++ Compiler 18.0" ^
|
||||
-DCMAKE_BUILD_TYPE=Release ^
|
||||
-DICCLIB="C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018\windows\compiler\lib" ..
|
||||
```
|
||||
|
||||
7. Build generated solution in Visual Studio 2017 or run `cmake --build . --config Release` to build from the command line.
|
||||
|
||||
8. Before running the samples, add paths to TBB and OpenCV binaries used for the build to the `%PATH%` environment variable. By default, TBB binaries are downloaded by the CMake-based script to the `<dldt_repo>/inference-engine/temp/tbb/lib` folder, OpenCV binaries - to the `<dldt_repo>/inference-engine/temp/opencv_4.1.0/bin` folder.
|
||||
|
||||
### Additional Build Options
|
||||
|
||||
- Internal JIT GEMM implementation is used by default.
|
||||
- To switch to OpenBLAS GEMM implementation, use the `-DGEMM=OPENBLAS` CMake option and specify path to OpenBLAS using the `-DBLAS_INCLUDE_DIRS=<OPENBLAS_DIR>\include` and `-DBLAS_LIBRARIES=<OPENBLAS_DIR>\lib\libopenblas.dll.a` options. Prebuilt OpenBLAS\* package can be downloaded [here](https://sourceforge.net/projects/openblas/files/v0.2.14/OpenBLAS-v0.2.14-Win64-int64.zip/download). mingw64* runtime dependencies can be downloaded [here](https://sourceforge.net/projects/openblas/files/v0.2.14/mingw64_dll.zip/download).
|
||||
- To switch to the optimized MKL-ML\* GEMM implementation, use the `-DGEMM=MKL` and `-DMKLROOT=<path_to_MKL>` CMake options to specify a path to unpacked MKL-ML with the `include` and `lib` folders. MKL-ML\* package can be downloaded from the [MKL-DNN repository](https://github.com/intel/mkl-dnn/releases/download/v0.17/mklml_win_2019.0.1.20180928.zip).
|
||||
|
||||
- Threading Building Blocks (TBB) is used by default. To build the Inference Engine with OpenMP* threading, set the `-DTHREADING=OMP` option.
|
||||
|
||||
- Required versions of TBB and OpenCV packages are downloaded automatically by the CMake-based script. If you want to use the automatically downloaded packages but you already have installed TBB or OpenCV packages configured in your environment, you may need to clean the `TBBROOT` and `OpenCV_DIR` environment variables before running the `cmake` command, otherwise they won't be downloaded and the build may fail if incompatible versions were installed.
|
||||
|
||||
- If the CMake-based build script can not find and download the OpenCV package that is supported on your platform, or if you want to use a custom build of the OpenCV library, refer to the [Use Custom OpenCV Builds](#use-custom-opencv-builds-for-inference-engine) section for details.
|
||||
|
||||
- To switch off/on the CPU and GPU plugins, use the `cmake` options `-DENABLE_MKL_DNN=ON/OFF` and `-DENABLE_CLDNN=ON/OFF` respectively.
|
||||
|
||||
- To build the Python API wrapper, use the `-DENABLE_PYTHON=ON` option. To specify an exact Python version, use the following options:
|
||||
```sh
|
||||
-DPYTHON_EXECUTABLE="C:\Program Files\Python37\python.exe" ^
|
||||
-DPYTHON_LIBRARY="C:\Program Files\Python37\libs\python37.lib" ^
|
||||
-DPYTHON_INCLUDE_DIR="C:\Program Files\Python37\include"
|
||||
```
|
||||
|
||||
### Building Inference Engine with Ninja* Build System
|
||||
|
||||
```sh
|
||||
call "C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018\windows\bin\ipsxe-comp-vars.bat" intel64 vs2017
|
||||
set CXX=icl
|
||||
set CC=icl
|
||||
:: clean TBBROOT value set by ipsxe-comp-vars.bat, required TBB package will be downloaded by dldt cmake script
|
||||
set TBBROOT=
|
||||
cmake -G Ninja -Wno-dev -DCMAKE_BUILD_TYPE=Release ..
|
||||
cmake --build . --config Release
|
||||
```
|
||||
|
||||
## Build on macOS* Systems
|
||||
|
||||
> **NOTE**: The current version of the OpenVINO™ toolkit for macOS* supports inference on Intel CPUs only.
|
||||
|
||||
The software was validated on:
|
||||
- macOS\* 10.14, 64-bit
|
||||
|
||||
### Software Requirements
|
||||
- [CMake\*](https://cmake.org/download/) 3.5 or higher
|
||||
- Clang\* compiler from Xcode\* 10.1
|
||||
- Python\* 3.4 or higher for the Inference Engine Python API wrapper
|
||||
|
||||
### Build Steps
|
||||
1. Clone submodules:
|
||||
```sh
|
||||
cd dldt/inference-engine
|
||||
git submodule init
|
||||
git submodule update --recursive
|
||||
```
|
||||
2. Install build dependencies using the `install_dependencies.sh` script in the project root folder.
|
||||
3. Create a build folder:
|
||||
```sh
|
||||
mkdir build
|
||||
```
|
||||
4. Inference Engine uses a CMake-based build system. In the created `build` directory, run `cmake` to fetch project dependencies and create Unix makefiles, then run `make` to build the project:
|
||||
```sh
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||
make --jobs=$(nproc --all)
|
||||
```
|
||||
### Additional Build Options
|
||||
|
||||
You can use the following additional build options:
|
||||
- Internal JIT GEMM implementation is used by default.
|
||||
- To switch to the optimized MKL-ML\* GEMM implementation, use `-DGEMM=MKL` and `-DMKLROOT=<path_to_MKL>` cmake options to specify a path to unpacked MKL-ML with the `include` and `lib` folders. MKL-ML\* package can be downloaded [here](https://github.com/intel/mkl-dnn/releases/download/v0.17.1/mklml_mac_2019.0.1.20180928.tgz)
|
||||
|
||||
- Threading Building Blocks (TBB) is used by default. To build the Inference Engine with OpenMP* threading, set the `-DTHREADING=OMP` option.
|
||||
|
||||
- Required versions of TBB and OpenCV packages are downloaded automatically by the CMake-based script. If you want to use the automatically downloaded packages but you already have installed TBB or OpenCV packages configured in your environment, you may need to clean the `TBBROOT` and `OpenCV_DIR` environment variables before running the `cmake` command, otherwise they won't be downloaded and the build may fail if incompatible versions were installed.
|
||||
|
||||
- If the CMake-based build script can not find and download the OpenCV package that is supported on your platform, or if you want to use a custom build of the OpenCV library, refer to the [Use Custom OpenCV Builds](#use-custom-opencv-builds-for-inference-engine) section for details.
|
||||
|
||||
- To build the Python API wrapper, use the `-DENABLE_PYTHON=ON` option. To specify an exact Python version, use the following options:
|
||||
```sh
|
||||
-DPYTHON_EXECUTABLE=/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 \
|
||||
-DPYTHON_LIBRARY=/Library/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7m.dylib \
|
||||
-DPYTHON_INCLUDE_DIR=/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m
|
||||
```
|
||||
|
||||
## Use Custom OpenCV Builds for Inference Engine
|
||||
|
||||
> **NOTE**: The recommended and tested version of OpenCV is 4.1. The minimum supported version is 3.4.0.
|
||||
|
||||
Required versions of OpenCV packages are downloaded automatically during the building Inference Engine library. If the build script can not find and download the OpenCV package that is supported on your platform, you can use one of the following options:
|
||||
|
||||
* Download the most suitable version from the list of available pre-build packages from [https://download.01.org/opencv/2019/openvinotoolkit](https://download.01.org/opencv/2019/openvinotoolkit) from the `<release_version>/inference_engine` directory.
|
||||
|
||||
* Use a system provided OpenCV package (e.g with running the `apt install libopencv-dev` command). The following modules must be enabled: `imgcodecs`, `videoio`, `highgui`.
|
||||
|
||||
* Get the OpenCV package using a package manager: pip, conda, conan etc. The package must have the development components included (header files and CMake scripts).
|
||||
|
||||
* Build OpenCV from source using the [build instructions](https://docs.opencv.org/master/df/d65/tutorial_table_of_content_introduction.html) on the OpenCV site.
|
||||
|
||||
After you got the built OpenCV library, perform the following preparation steps before running the Inference Engine build:
|
||||
|
||||
1. Set the `OpenCV_DIR` environment variable to the directory where the `OpenCVConfig.cmake` file of you custom OpenCV build is located.
|
||||
2. Disable the package automatic downloading with using the `-DENABLE_OPENCV=OFF` option for CMake-based build script for Inference Engine.
|
||||
|
||||
## (Optional) Additional Installation Steps for the Intel® Movidius™ Neural Compute Stick and Neural Compute Stick 2
|
||||
|
||||
> **NOTE**: These steps are only required if you want to perform inference on Intel® Movidius™ Neural Compute Stick or the Intel® Neural Compute Stick 2 using the Inference Engine MYRIAD Plugin. See also [Intel® Neural Compute Stick 2 Get Started](https://software.intel.com/en-us/neural-compute-stick/get-started)
|
||||
|
||||
### For Linux, Raspbian\* Stretch OS
|
||||
|
||||
1. Add the current Linux user to the `users` group:
|
||||
```sh
|
||||
sudo usermod -a -G users "$(whoami)"
|
||||
```
|
||||
Log out and log in for it to take effect.
|
||||
|
||||
2. To perform inference on Intel® Movidius™ Neural Compute Stick and Intel® Neural Compute Stick 2, install the USB rules as follows:
|
||||
```sh
|
||||
cat <<EOF > 97-myriad-usbboot.rules
|
||||
SUBSYSTEM=="usb", ATTRS{idProduct}=="2150", ATTRS{idVendor}=="03e7", GROUP="users", MODE="0666", ENV{ID_MM_DEVICE_IGNORE}="1"
|
||||
SUBSYSTEM=="usb", ATTRS{idProduct}=="2485", ATTRS{idVendor}=="03e7", GROUP="users", MODE="0666", ENV{ID_MM_DEVICE_IGNORE}="1"
|
||||
SUBSYSTEM=="usb", ATTRS{idProduct}=="f63b", ATTRS{idVendor}=="03e7", GROUP="users", MODE="0666", ENV{ID_MM_DEVICE_IGNORE}="1"
|
||||
EOF
|
||||
```
|
||||
```sh
|
||||
sudo cp 97-myriad-usbboot.rules /etc/udev/rules.d/
|
||||
```
|
||||
```sh
|
||||
sudo udevadm control --reload-rules
|
||||
```
|
||||
```sh
|
||||
sudo udevadm trigger
|
||||
```
|
||||
```sh
|
||||
sudo ldconfig
|
||||
```
|
||||
```sh
|
||||
rm 97-myriad-usbboot.rules
|
||||
```
|
||||
|
||||
### For Windows
|
||||
|
||||
For Intel® Movidius™ Neural Compute Stick and Intel® Neural Compute Stick 2, install the Movidius™ VSC driver:
|
||||
1. Go to the `<DLDT_ROOT_DIR>/inference-engine/thirdparty/movidius/MovidiusDriver` directory, where the `DLDT_ROOT_DIR` is the directory to which the DLDT repository was cloned.
|
||||
2. Right click on the `Movidius_VSC_Device.inf` file and choose **Install** from the pop up menu.
|
||||
|
||||
You have installed the driver for your Intel® Movidius™ Neural Compute Stick or Intel® Neural Compute Stick 2.
|
||||
|
||||
## Next Steps
|
||||
|
||||
Congratulations, you have built the Inference Engine. To get started with the OpenVINO™ DLDT, proceed to the Get Started guides:
|
||||
|
||||
* [Get Started with Deep Learning Deployment Toolkit on Linux*](../get-started-linux.md)
|
||||
|
||||
## Additional Resources
|
||||
|
||||
* [OpenVINO™ Release Notes](https://software.intel.com/en-us/articles/OpenVINO-RelNotes)
|
||||
* [Introduction to Intel® Deep Learning Deployment Toolkit](https://docs.openvinotoolkit.org/latest/_docs_IE_DG_Introduction.html)
|
||||
* [Inference Engine Samples Overview](https://docs.openvinotoolkit.org/latest/_docs_IE_DG_Samples_Overview.html)
|
||||
* [Inference Engine Developer Guide](https://docs.openvinotoolkit.org/latest/_docs_IE_DG_Deep_Learning_Inference_Engine_DevGuide.html)
|
||||
* [Model Optimizer Developer Guide](https://docs.openvinotoolkit.org/latest/_docs_MO_DG_Deep_Learning_Model_Optimizer_DevGuide.html)
|
||||
|
||||
---
|
||||
\* Other names and brands may be claimed as the property of others.
|
||||
57
inference-engine/cmake/FindITT.cmake
Normal file
57
inference-engine/cmake/FindITT.cmake
Normal file
@@ -0,0 +1,57 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
unset(ITT_INCLUDE_DIR CACHE)
|
||||
unset(ITT_LIB CACHE)
|
||||
|
||||
if(NOT DEFINED INTEL_VTUNE_DIR AND DEFINED ENV{INTEL_VTUNE_DIR})
|
||||
set(INTEL_VTUNE_DIR "$ENV{INTEL_VTUNE_DIR}")
|
||||
endif()
|
||||
if(NOT DEFINED INTEL_VTUNE_DIR)
|
||||
if(EXISTS "/opt/intel/vtune_amplifier_xe/include")
|
||||
set(INTEL_VTUNE_DIR "/opt/intel/vtune_amplifier_xe")
|
||||
elseif(EXISTS "/opt/intel/vtune_amplifier/include")
|
||||
set(INTEL_VTUNE_DIR "/opt/intel/vtune_amplifier")
|
||||
elseif (EXISTS "C:/Program Files (x86)/IntelSWTools/VTune Amplifier XE")
|
||||
set(INTEL_VTUNE_DIR "C:/Program Files (x86)/IntelSWTools/VTune Amplifier XE")
|
||||
elseif (EXISTS "C:/Program Files (x86)/IntelSWTools/VTune Amplifier")
|
||||
set(INTEL_VTUNE_DIR "C:/Program Files (x86)/IntelSWTools/VTune Amplifier")
|
||||
elseif (EXISTS "$ENV{HOME}/intel/vtune_amplifier_2019")
|
||||
set(INTEL_VTUNE_DIR "$ENV{HOME}/intel/vtune_amplifier_2019")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(DEFINED INTEL_VTUNE_DIR)
|
||||
message(STATUS "INTEL_VTUNE_DIR = ${INTEL_VTUNE_DIR}")
|
||||
|
||||
find_path(ITT_INCLUDE_DIR
|
||||
FILES
|
||||
ittnotify.h
|
||||
PATHS "${INTEL_VTUNE_DIR}/include/")
|
||||
|
||||
find_library(ITT_LIB
|
||||
"libittnotify${CMAKE_STATIC_LIBRARY_SUFFIX}"
|
||||
PATHS ${INTEL_VTUNE_DIR}/lib64)
|
||||
|
||||
set(Located_ITT_LIBS ${ITT_LIB})
|
||||
set(Located_ITT_INCLUDE_DIRS ${ITT_INCLUDE_DIR})
|
||||
else()
|
||||
message(STATUS "INTEL_VTUNE_DIR is not defined")
|
||||
endif()
|
||||
|
||||
# Handle find_package() arguments, and set INTEL_ITT_FOUND
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(INTEL_ITT
|
||||
REQUIRED_VARS
|
||||
Located_ITT_INCLUDE_DIRS
|
||||
Located_ITT_LIBS)
|
||||
|
||||
if(INTEL_ITT_FOUND)
|
||||
add_library(ittnotify STATIC IMPORTED GLOBAL)
|
||||
set_target_properties(ittnotify PROPERTIES IMPORTED_LOCATION "${Located_ITT_LIBS}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${Located_ITT_INCLUDE_DIRS}
|
||||
INTERFACE_COMPILE_DEFINITIONS ENABLE_PROFILING_ITT)
|
||||
|
||||
set(INTEL_ITT_LIBS ittnotify ${CMAKE_DL_LIBS})
|
||||
endif()
|
||||
32
inference-engine/cmake/FindTBB.cmake
Normal file
32
inference-engine/cmake/FindTBB.cmake
Normal file
@@ -0,0 +1,32 @@
|
||||
# Copyright (C) 2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
########################################################################
|
||||
#
|
||||
# Perform search of TBB package corresponding with specified search order.
|
||||
#
|
||||
# TBBROOT var is set into external package path or has a default value
|
||||
# with IE own version of TBB. Search order is next:
|
||||
# 1) ${TBBROOT}/cmake
|
||||
# 2) ${TBBROOT} with IE own version of TBBConfig.cmake (actual for TBB < 2017.7)
|
||||
#
|
||||
|
||||
## Path to IE own version of TBBConfig.cmake old TBB version without cmake config.
|
||||
if(APPLE)
|
||||
set(IE_OWN_TBB_CONFIG tbb/mac)
|
||||
elseif(UNIX)
|
||||
set(IE_OWN_TBB_CONFIG tbb/lnx)
|
||||
elseif(WIN)
|
||||
set(IE_OWN_TBB_CONFIG tbb/win)
|
||||
else()
|
||||
unset(IE_OWN_TBB_CONFIG)
|
||||
endif()
|
||||
|
||||
find_package(TBB
|
||||
CONFIG
|
||||
NO_DEFAULT_PATH
|
||||
PATHS ${TBBROOT}/cmake
|
||||
${CMAKE_CURRENT_LIST_DIR}/${IE_OWN_TBB_CONFIG}
|
||||
)
|
||||
find_package_handle_standard_args(TBB CONFIG_MODE)
|
||||
@@ -1,37 +1,80 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
#module to locate GNA libraries
|
||||
# module to locate GNA libraries
|
||||
|
||||
if (WIN32)
|
||||
set(GNA_PLATFORM_DIR win64)
|
||||
set(GNA_LIB_DIR x64)
|
||||
set(GNA_LIB gna)
|
||||
set(GNA_PLATFORM_DIR win64 CACHE STRING "" FORCE)
|
||||
elseif (UNIX)
|
||||
set(GNA_PLATFORM_DIR linux)
|
||||
set(GNA_LIB_DIR lib)
|
||||
set(GNA_LIB gna_api)
|
||||
set(GNA_KERNEL_LIB gna_kernel)
|
||||
set(GNA_PLATFORM_DIR linux CACHE STRING "" FORCE)
|
||||
else ()
|
||||
message(FATAL_ERROR "GNA not supported on this platform, only linux, and windows")
|
||||
endif ()
|
||||
|
||||
find_library(GNA_API_LIBRARY
|
||||
${GNA_LIB}
|
||||
set(libGNA_FOUND TRUE)
|
||||
|
||||
set(GNA_KERNEL_LIB_NAME gna CACHE STRING "" FORCE)
|
||||
set(GNA_LIBS_LIST
|
||||
"libGNA::API"
|
||||
"libGNA::KERNEL")
|
||||
|
||||
if (GNA_LIBRARY_VERSION STREQUAL "GNA1")
|
||||
# use old version of GNA Library from gna_20181120
|
||||
if (WIN32)
|
||||
set(GNA_LIB_DIR x64 CACHE STRING "" FORCE)
|
||||
else ()
|
||||
list(APPEND GNA_LIBS_LIST
|
||||
"libGNA::OLD_API_LIB")
|
||||
set(GNA_LIB_DIR lib CACHE STRING "" FORCE)
|
||||
set(GNA_KERNEL_LIB_NAME gna_kernel CACHE STRING "" FORCE)
|
||||
endif()
|
||||
set(libGNA_INCLUDE_DIRS "${GNA}/${GNA_PLATFORM_DIR}/include" CACHE STRING "" FORCE)
|
||||
else()
|
||||
# use current version of GNA library
|
||||
set(GNA_LIB_DIR x64 CACHE STRING "" FORCE)
|
||||
set(libGNA_INCLUDE_DIRS "${GNA}/include" CACHE STRING "" FORCE)
|
||||
endif()
|
||||
set(libGNA_LIBRARIES_BASE_PATH ${GNA}/${GNA_PLATFORM_DIR}/${GNA_LIB_DIR} CACHE STRING "" FORCE)
|
||||
|
||||
add_library(libGNA::KERNEL SHARED IMPORTED)
|
||||
find_library(GNA_KERNEL_LIBRARY
|
||||
${GNA_KERNEL_LIB_NAME}
|
||||
HINTS
|
||||
${GNA}/${GNA_PLATFORM_DIR}/${GNA_LIB_DIR})
|
||||
${libGNA_LIBRARIES_BASE_PATH})
|
||||
set_target_properties(libGNA::KERNEL PROPERTIES IMPORTED_LOCATION ${GNA_KERNEL_LIBRARY})
|
||||
|
||||
set(libGNA_INCLUDE_DIRS ${GNA}/${GNA_PLATFORM_DIR}/include)
|
||||
set(libGNA_LIBRARY ${GNA_API_LIBRARY})
|
||||
|
||||
if (UNIX)
|
||||
#message("Searching for libgna_kernel.so in: ${GNA}/${GNA_PLATFORM_DIR}/${GNA_KERNEL_LIB}")
|
||||
find_library(GNA_KERNEL_LIBRARY
|
||||
${GNA_KERNEL_LIB}
|
||||
if ((GNA_LIBRARY_VERSION STREQUAL "GNA1") AND (NOT WIN32))
|
||||
add_library(libGNA::OLD_API_LIB SHARED IMPORTED)
|
||||
find_library(GNA_API_LIBRARY
|
||||
gna_api
|
||||
HINTS
|
||||
${GNA}/${GNA_PLATFORM_DIR}/${GNA_LIB_DIR})
|
||||
endif ()
|
||||
${libGNA_LIBRARIES_BASE_PATH})
|
||||
set_target_properties(libGNA::OLD_API_LIB PROPERTIES IMPORTED_LOCATION ${GNA_API_LIBRARY})
|
||||
target_link_libraries(libGNA::OLD_API_LIB INTERFACE libGNA::KERNEL)
|
||||
set_target_properties(libGNA::OLD_API_LIB PROPERTIES IMPORTED_NO_SONAME TRUE)
|
||||
set_target_properties(libGNA::KERNEL PROPERTIES IMPORTED_NO_SONAME TRUE)
|
||||
endif()
|
||||
|
||||
set(libGNA_LIBRARIES ${libGNA_LIBRARY} ${GNA_KERNEL_LIBRARY})
|
||||
add_library(libGNA::API INTERFACE IMPORTED)
|
||||
set_property(TARGET libGNA::API PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${libGNA_INCLUDE_DIRS})
|
||||
|
||||
add_library(libGNA INTERFACE IMPORTED)
|
||||
foreach(_lib_name ${GNA_LIBS_LIST})
|
||||
set_property(TARGET libGNA APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${_lib_name})
|
||||
|
||||
get_target_property(_target_type ${_lib_name} TYPE)
|
||||
if (${_target_type} STREQUAL "INTERFACE_LIBRARY")
|
||||
get_target_property(_target_location ${_lib_name} INTERFACE_INCLUDE_DIRECTORIES)
|
||||
else()
|
||||
get_target_property(_target_location ${_lib_name} IMPORTED_LOCATION)
|
||||
endif ()
|
||||
message(STATUS "${_lib_name} ${_target_type} : ${_target_location}")
|
||||
endforeach(_lib_name)
|
||||
|
||||
if (WIN32)
|
||||
set_target_properties(libGNA::KERNEL PROPERTIES
|
||||
IMPORTED_IMPLIB ${GNA_KERNEL_LIBRARY})
|
||||
elseif(NOT GNA_LIBRARY_VERSION STREQUAL "GNA1")
|
||||
set_target_properties(libGNA PROPERTIES INTERFACE_LINK_OPTIONS "-Wl,-rpath-link,${libGNA_LIBRARIES_BASE_PATH}")
|
||||
endif ()
|
||||
|
||||
156
inference-engine/cmake/add_ie_target.cmake
Normal file
156
inference-engine/cmake/add_ie_target.cmake
Normal file
@@ -0,0 +1,156 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
#[[
|
||||
function to create CMake target and setup its options in a declarative style.
|
||||
Example:
|
||||
addIeTarget(
|
||||
NAME core_lib
|
||||
ADD_CPPLINT
|
||||
DEVELOPER_PACKAGE
|
||||
TYPE SHARED
|
||||
ROOT ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
ADDITIONAL_SOURCE_DIRS
|
||||
/some/additional/sources
|
||||
EXCLUDED_SOURCE_DIRS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/unnecessary_sources/
|
||||
INCLUDES
|
||||
${SDL_INCLUDES}
|
||||
/some/specific/path
|
||||
LINK_LIBRARIES
|
||||
ie::important_plugin
|
||||
EXPORT_DEPENDENCIES
|
||||
dependency_lib_to_export
|
||||
DEPENDENCIES
|
||||
dependencies
|
||||
OBJECT_FILES
|
||||
object libraries
|
||||
)
|
||||
#]]
|
||||
function(addIeTarget)
|
||||
set(options
|
||||
ADD_CPPLINT # Enables code style checks for the target
|
||||
DEVELOPER_PACKAGE # Enables exporting of the target through the developer package
|
||||
)
|
||||
set(oneValueRequiredArgs
|
||||
TYPE # type of target, SHARED|STATIC|EXECUTABLE. SHARED and STATIC correspond to add_library, EXECUTABLE to add_executable
|
||||
NAME # name of target
|
||||
ROOT # root directory to be used for recursive search of source files
|
||||
)
|
||||
set(oneValueOptionalArgs
|
||||
)
|
||||
set(multiValueArgs
|
||||
INCLUDES # Extra include directories
|
||||
LINK_LIBRARIES # Link libraries (in form of target name or file name)
|
||||
DEPENDENCIES # compile order dependencies (no link implied)
|
||||
DEFINES # extra preprocessor definitions
|
||||
ADDITIONAL_SOURCE_DIRS # list of directories which will be used to recursive search of source files in addition to ROOT
|
||||
OBJECT_FILES # list of object files to be additionally built into the target
|
||||
EXCLUDED_SOURCE_DIRS # list of directories excluded from the global recursive search of source files
|
||||
LINK_LIBRARIES_WHOLE_ARCHIVE # list of static libraries to link, each object file should be used and not discarded
|
||||
LINK_FLAGS # list of extra commands to linker
|
||||
EXPORT_DEPENDENCIES # list of the dependencies to be exported with the target through the developer package
|
||||
)
|
||||
cmake_parse_arguments(ARG "${options}" "${oneValueRequiredArgs};${oneValueOptionalArgs}" "${multiValueArgs}" ${ARGN} )
|
||||
|
||||
# sanity checks
|
||||
foreach(argName ${oneValueRequiredArgs})
|
||||
if (NOT ARG_${argName})
|
||||
message(SEND_ERROR "Argument '${argName}' is required.")
|
||||
endif()
|
||||
endforeach()
|
||||
if (ARG_UNPARSED_ARGUMENTS)
|
||||
message(SEND_ERROR "Unexpected parameters have passed to function: ${ARG_UNPARSED_ARGUMENTS}")
|
||||
endif()
|
||||
|
||||
# adding files to target
|
||||
set(includeSearch)
|
||||
set(sourceSearch)
|
||||
foreach(directory ${ARG_ROOT} ${ARG_ADDITIONAL_SOURCE_DIRS})
|
||||
list(APPEND includeSearch ${directory}/*.h ${directory}/*.hpp)
|
||||
list(APPEND sourceSearch ${directory}/*.cpp)
|
||||
endforeach()
|
||||
|
||||
file(GLOB_RECURSE includes ${includeSearch})
|
||||
file(GLOB_RECURSE sources ${sourceSearch})
|
||||
|
||||
# remove unnecessary directories
|
||||
if (ARG_EXCLUDED_SOURCE_DIRS)
|
||||
list(FILTER includes EXCLUDE REGEX "${ARG_EXCLUDED_SOURCE_DIRS}/*")
|
||||
list(FILTER sources EXCLUDE REGEX "${ARG_EXCLUDED_SOURCE_DIRS}/*")
|
||||
endif()
|
||||
|
||||
source_group("include" FILES ${includes})
|
||||
source_group("src" FILES ${sources})
|
||||
|
||||
set(all_sources)
|
||||
list(APPEND all_sources ${sources} ${includes} ${ARG_OBJECT_FILES})
|
||||
|
||||
# defining a target
|
||||
if (ARG_TYPE STREQUAL EXECUTABLE)
|
||||
add_executable(${ARG_NAME} ${all_sources})
|
||||
elseif(ARG_TYPE STREQUAL STATIC OR ARG_TYPE STREQUAL SHARED)
|
||||
add_library(${ARG_NAME} ${type} ${all_sources})
|
||||
else()
|
||||
message(SEND_ERROR "Invalid target type ${ARG_TYPE} specified for target name ${ARG_NAME}")
|
||||
endif()
|
||||
|
||||
ieTargetLinkWholeArchive(${ARG_NAME} ${ARG_LINK_LIBRARIES_WHOLE_ARCHIVE})
|
||||
|
||||
if (ARG_DEFINES)
|
||||
target_compile_definitions(${ARG_NAME} PRIVATE ${ARG_DEFINES})
|
||||
endif()
|
||||
if (ARG_INCLUDES)
|
||||
target_include_directories(${ARG_NAME} PRIVATE ${ARG_INCLUDES})
|
||||
endif()
|
||||
if (ARG_LINK_LIBRARIES)
|
||||
target_link_libraries(${ARG_NAME} PRIVATE ${ARG_LINK_LIBRARIES})
|
||||
endif()
|
||||
if (ARG_DEPENDENCIES)
|
||||
add_dependencies(${ARG_NAME} ${ARG_DEPENDENCIES})
|
||||
endif()
|
||||
if (ARG_LINK_FLAGS)
|
||||
get_target_property(oldLinkFlags ${ARG_NAME} LINK_FLAGS)
|
||||
string(REPLACE ";" " " ARG_LINK_FLAGS "${ARG_LINK_FLAGS}")
|
||||
set_target_properties(${ARG_NAME} PROPERTIES LINK_FLAGS "${oldLinkFlags} ${ARG_LINK_FLAGS}")
|
||||
endif()
|
||||
if (ARG_ADD_CPPLINT)
|
||||
# code style
|
||||
add_cpplint_target(${ARG_NAME}_cpplint FOR_TARGETS ${ARG_NAME})
|
||||
add_clang_format_target(${ARG_NAME}_clang_format FOR_TARGETS ${ARG_NAME})
|
||||
endif()
|
||||
if (ARG_DEVELOPER_PACKAGE)
|
||||
# developer package
|
||||
ie_developer_export_targets(${ARG_NAME})
|
||||
if (ARG_EXPORT_DEPENDENCIES)
|
||||
ie_developer_export_targets(${ARG_NAME} ${ARG_EXPORT_DEPENDENCIES})
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#[[
|
||||
Wrapper function over addIeTarget, that also adds a test with the same name.
|
||||
You could use
|
||||
addIeTargetTest( ... LABELS labelOne labelTwo )
|
||||
also to provide labels for that test.
|
||||
Important: you MUST pass LABELS as last argument, otherwise it will consume any parameters that come after.
|
||||
#]]
|
||||
function(addIeTargetTest)
|
||||
set(options
|
||||
)
|
||||
set(oneValueRequiredArgs
|
||||
NAME
|
||||
)
|
||||
set(oneValueOptionalArgs
|
||||
)
|
||||
set(multiValueArgs
|
||||
LABELS
|
||||
)
|
||||
cmake_parse_arguments(ARG "${options}" "${oneValueRequiredArgs};${oneValueOptionalArgs}" "${multiValueArgs}" ${ARGN} )
|
||||
|
||||
addIeTarget(TYPE EXECUTABLE NAME ${ARG_NAME} ${ARG_UNPARSED_ARGUMENTS})
|
||||
|
||||
add_test(NAME ${ARG_NAME} COMMAND ${ARG_NAME})
|
||||
set_property(TEST ${ARG_NAME} PROPERTY LABELS ${ARG_LABELS})
|
||||
endfunction()
|
||||
@@ -1,10 +0,0 @@
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR armv7l)
|
||||
|
||||
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
|
||||
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
@@ -1,128 +0,0 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
include("features")
|
||||
include("mode")
|
||||
include("itt")
|
||||
|
||||
#64 bits platform
|
||||
if ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
|
||||
message(STATUS "Detected 64 bit architecture")
|
||||
SET(ARCH_64 ON)
|
||||
SET(ARCH_32 OFF)
|
||||
else()
|
||||
message(STATUS "Detected 32 bit architecture")
|
||||
SET(ARCH_64 OFF)
|
||||
SET(ARCH_32 ON)
|
||||
endif()
|
||||
|
||||
if (ARCH_64)
|
||||
else()
|
||||
if (UNIX OR APPLE)
|
||||
SET(ENABLE_CLDNN OFF)
|
||||
endif()
|
||||
SET(ENABLE_MKL_DNN OFF)
|
||||
endif()
|
||||
|
||||
#apple specific
|
||||
if (APPLE)
|
||||
set(ENABLE_GNA OFF)
|
||||
set(ENABLE_CLDNN OFF)
|
||||
SET(ENABLE_MYRIAD OFF)
|
||||
endif()
|
||||
|
||||
|
||||
#minGW specific - under wine no support for downloading file and applying them using git
|
||||
if (WIN32)
|
||||
if (MINGW)
|
||||
SET(ENABLE_CLDNN OFF) # dont have mingw dll for linking
|
||||
set(ENABLE_SAMPLES OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Linux specific - not all OS'es are supported
|
||||
if (LINUX)
|
||||
include("linux_name")
|
||||
get_linux_name(LINUX_OS_NAME)
|
||||
if (LINUX_OS_NAME)
|
||||
if (NOT(
|
||||
${LINUX_OS_NAME} STREQUAL "Ubuntu 14.04" OR
|
||||
${LINUX_OS_NAME} STREQUAL "Ubuntu 16.04" OR
|
||||
${LINUX_OS_NAME} STREQUAL "CentOS 7"))
|
||||
endif()
|
||||
else ()
|
||||
message(WARNING "Cannot detect Linux OS via reading /etc/*-release:\n ${release_data}")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (NOT ENABLE_MKL_DNN)
|
||||
set(ENABLE_MKL OFF)
|
||||
endif()
|
||||
|
||||
if (NOT ENABLE_VPU)
|
||||
set(ENABLE_MYRIAD OFF)
|
||||
endif()
|
||||
|
||||
if (NOT ENABLE_MYRIAD)
|
||||
set(ENABLE_VPU OFF)
|
||||
endif()
|
||||
|
||||
#next section set defines to be accesible in c++/c code for certain feature
|
||||
if (ENABLE_PROFILING_RAW)
|
||||
add_definitions(-DENABLE_PROFILING_RAW=1)
|
||||
endif()
|
||||
|
||||
if (ENABLE_CLDNN)
|
||||
add_definitions(-DENABLE_CLDNN=1)
|
||||
endif()
|
||||
|
||||
if (ENABLE_MYRIAD)
|
||||
add_definitions(-DENABLE_MYRIAD=1)
|
||||
endif()
|
||||
|
||||
if (ENABLE_MYX_PCIE AND ENABLE_MYRIAD)
|
||||
add_definitions(-DENABLE_MYX_PCIE=1)
|
||||
endif()
|
||||
|
||||
if (ENABLE_MYRIAD_NO_BOOT AND ENABLE_MYRIAD )
|
||||
add_definitions(-DENABLE_MYRIAD_NO_BOOT=1)
|
||||
endif()
|
||||
|
||||
if (ENABLE_MYX_PCIE AND ENABLE_MYRIAD_NO_BOOT)
|
||||
message(FATAL_ERROR "ENABLE_MYX_PCIE and ENABLE_MYRIAD_NO_BOOT can't be enabled at the same time")
|
||||
endif()
|
||||
|
||||
if (ENABLE_MKL_DNN)
|
||||
add_definitions(-DENABLE_MKL_DNN=1)
|
||||
endif()
|
||||
|
||||
if (ENABLE_GNA)
|
||||
add_definitions(-DENABLE_GNA)
|
||||
endif()
|
||||
|
||||
if (ENABLE_SAMPLES)
|
||||
set (ENABLE_SAMPLES_CORE ON)
|
||||
endif()
|
||||
|
||||
if (DEVELOPMENT_PLUGIN_MODE)
|
||||
message (STATUS "Enabled development plugin mode")
|
||||
|
||||
set (ENABLE_MKL_DNN OFF)
|
||||
set (ENABLE_TESTS OFF)
|
||||
|
||||
message (STATUS "Initialising submodules")
|
||||
execute_process (COMMAND git submodule update --init ${IE_MAIN_SOURCE_DIR}/thirdparty/pugixml
|
||||
RESULT_VARIABLE git_res)
|
||||
|
||||
if (NOT ${git_res})
|
||||
message (STATUS "Initialising submodules - done")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (VERBOSE_BUILD)
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
endif()
|
||||
|
||||
print_enabled_features()
|
||||
39
inference-engine/cmake/check_features_ie.cmake
Normal file
39
inference-engine/cmake/check_features_ie.cmake
Normal file
@@ -0,0 +1,39 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
#next section set defines to be accesible in c++/c code for certain feature
|
||||
if (ENABLE_PROFILING_RAW)
|
||||
add_definitions(-DENABLE_PROFILING_RAW=1)
|
||||
endif()
|
||||
|
||||
if (ENABLE_MYRIAD)
|
||||
add_definitions(-DENABLE_MYRIAD=1)
|
||||
endif()
|
||||
|
||||
if (ENABLE_MYRIAD_NO_BOOT AND ENABLE_MYRIAD )
|
||||
add_definitions(-DENABLE_MYRIAD_NO_BOOT=1)
|
||||
endif()
|
||||
|
||||
if (ENABLE_CLDNN)
|
||||
add_definitions(-DENABLE_CLDNN=1)
|
||||
endif()
|
||||
|
||||
if (ENABLE_MKL_DNN)
|
||||
add_definitions(-DENABLE_MKL_DNN=1)
|
||||
endif()
|
||||
|
||||
if (ENABLE_GNA)
|
||||
add_definitions(-DENABLE_GNA)
|
||||
|
||||
if (UNIX AND NOT APPLE AND CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.4)
|
||||
message(WARNING "${GNA_LIBRARY_VERSION} is not supported on GCC version ${CMAKE_CXX_COMPILER_VERSION}. Fallback to GNA1")
|
||||
set(GNA_LIBRARY_VERSION GNA1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (ENABLE_SPEECH_DEMO)
|
||||
add_definitions(-DENABLE_SPEECH_DEMO)
|
||||
endif()
|
||||
|
||||
print_enabled_features()
|
||||
124
inference-engine/cmake/clang_format.cmake
Normal file
124
inference-engine/cmake/clang_format.cmake
Normal file
@@ -0,0 +1,124 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
if (ENABLE_CLANG_FORMAT)
|
||||
set(CLANG_FORMAT_FILENAME clang-format-9 clang-format)
|
||||
find_program(CLANG_FORMAT NAMES ${CLANG_FORMAT_FILENAME} PATHS ENV PATH)
|
||||
if (CLANG_FORMAT)
|
||||
execute_process(COMMAND ${CLANG_FORMAT} ${CMAKE_CURRENT_SOURCE_DIR} ARGS --version OUTPUT_VARIABLE CLANG_VERSION)
|
||||
if (NOT CLANG_VERSION OR CLANG_VERSION STREQUAL "")
|
||||
message(WARNING "Supported clang-format version is 9!")
|
||||
set(ENABLE_CLANG_FORMAT OFF)
|
||||
else()
|
||||
string(REGEX REPLACE "[^0-9]+([0-9]+)\\..*" "\\1" CLANG_FORMAT_MAJOR_VERSION ${CLANG_VERSION})
|
||||
if (NOT ${CLANG_FORMAT_MAJOR_VERSION} EQUAL "9")
|
||||
message(WARNING "Supported clang-format version is 9!")
|
||||
set(ENABLE_CLANG_FORMAT OFF)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ENABLE_CLANG_FORMAT)
|
||||
add_custom_target(clang_format_check_all)
|
||||
add_custom_target(clang_format_fix_all)
|
||||
set(CLANG_FORMAT_ALL_OUTPUT_FILES "" CACHE INTERNAL "All clang-format output files")
|
||||
endif()
|
||||
|
||||
function(add_clang_format_target TARGET_NAME)
|
||||
if(NOT ENABLE_CLANG_FORMAT)
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(options ALL)
|
||||
set(oneValueArgs "")
|
||||
set(multiValueArgs "FOR_TARGETS" "FOR_SOURCES" "EXCLUDE_PATTERNS")
|
||||
cmake_parse_arguments(CLANG_FORMAT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if(CLANG_FORMAT_ALL)
|
||||
set(all ALL)
|
||||
endif()
|
||||
|
||||
foreach(target IN LISTS CLANG_FORMAT_FOR_TARGETS)
|
||||
get_target_property(target_sources "${target}" SOURCES)
|
||||
list(APPEND CLANG_FORMAT_FOR_SOURCES ${target_sources})
|
||||
endforeach()
|
||||
list(REMOVE_DUPLICATES CLANG_FORMAT_FOR_SOURCES)
|
||||
|
||||
set(all_output_files "")
|
||||
foreach(source_file IN LISTS CLANG_FORMAT_FOR_SOURCES)
|
||||
set(exclude FALSE)
|
||||
foreach(pattern IN LISTS CLANG_FORMAT_EXCLUDE_PATTERNS)
|
||||
if(source_file MATCHES "${pattern}")
|
||||
set(exclude ON)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(exclude)
|
||||
continue()
|
||||
endif()
|
||||
|
||||
# ignore object libraries
|
||||
if(NOT EXISTS "${source_file}")
|
||||
continue()
|
||||
endif()
|
||||
|
||||
file(RELATIVE_PATH source_file_relative "${CMAKE_CURRENT_SOURCE_DIR}" "${source_file}")
|
||||
set(output_file "${CMAKE_CURRENT_BINARY_DIR}/clang_format/${source_file_relative}.clang")
|
||||
string(REPLACE ".." "__" output_file "${output_file}")
|
||||
get_filename_component(output_dir "${output_file}" DIRECTORY)
|
||||
file(MAKE_DIRECTORY "${output_dir}")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT
|
||||
"${output_file}"
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}"
|
||||
-D "CLANG_FORMAT=${CLANG_FORMAT}"
|
||||
-D "INPUT_FILE=${source_file}"
|
||||
-D "OUTPUT_FILE=${output_file}"
|
||||
-P "${IE_MAIN_SOURCE_DIR}/cmake/clang_format_check.cmake"
|
||||
DEPENDS
|
||||
"${source_file}"
|
||||
"${IE_MAIN_SOURCE_DIR}/cmake/clang_format_check.cmake"
|
||||
COMMENT
|
||||
"[clang-format] ${source_file}"
|
||||
VERBATIM)
|
||||
|
||||
list(APPEND all_output_files "${output_file}")
|
||||
endforeach()
|
||||
|
||||
set(CLANG_FORMAT_ALL_OUTPUT_FILES
|
||||
${CLANG_FORMAT_ALL_OUTPUT_FILES} ${all_output_files}
|
||||
CACHE INTERNAL
|
||||
"All clang-format output files")
|
||||
|
||||
add_custom_target(${TARGET_NAME}
|
||||
${all}
|
||||
DEPENDS ${all_output_files}
|
||||
COMMENT "[clang-format] ${TARGET_NAME}")
|
||||
|
||||
add_custom_target(${TARGET_NAME}_fix
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}"
|
||||
-D "CLANG_FORMAT=${CLANG_FORMAT}"
|
||||
-D "INPUT_FILES=${CLANG_FORMAT_FOR_SOURCES}"
|
||||
-D "EXCLUDE_PATTERNS=${CLANG_FORMAT_EXCLUDE_PATTERNS}"
|
||||
-P "${IE_MAIN_SOURCE_DIR}/cmake/clang_format_fix.cmake"
|
||||
DEPENDS
|
||||
"${CLANG_FORMAT_FOR_SOURCES}"
|
||||
"${IE_MAIN_SOURCE_DIR}/cmake/clang_format_fix.cmake"
|
||||
COMMENT
|
||||
"[clang-format] ${TARGET_NAME}_fix"
|
||||
VERBATIM)
|
||||
|
||||
# if(CLANG_FORMAT_FOR_TARGETS)
|
||||
# foreach(target IN LISTS CLANG_FORMAT_FOR_TARGETS)
|
||||
# add_dependencies(${target} ${TARGET_NAME})
|
||||
# endforeach()
|
||||
# endif()
|
||||
|
||||
add_dependencies(clang_format_check_all ${TARGET_NAME})
|
||||
add_dependencies(clang_format_fix_all ${TARGET_NAME}_fix)
|
||||
endfunction()
|
||||
18
inference-engine/cmake/clang_format_check.cmake
Normal file
18
inference-engine/cmake/clang_format_check.cmake
Normal file
@@ -0,0 +1,18 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
file(REMOVE "${OUTPUT_FILE}")
|
||||
|
||||
execute_process(COMMAND ${CLANG_FORMAT} -style=file -output-replacements-xml ${INPUT_FILE}
|
||||
OUTPUT_VARIABLE STYLE_CHECK_RESULT
|
||||
)
|
||||
# Display the cpplint output to console (to parse it form IDE)
|
||||
message("${output}")
|
||||
file(WRITE "${OUTPUT_FILE}" "${STYLE_CHECK_RESULT}")
|
||||
|
||||
if(NOT SKIP_RETURN_CODE)
|
||||
if("${STYLE_CHECK_RESULT}" MATCHES ".*<replacement .*")
|
||||
message(FATAL_ERROR "[clang-format] Code style check failed for : ${INPUT_FILE}")
|
||||
endif()
|
||||
endif()
|
||||
24
inference-engine/cmake/clang_format_fix.cmake
Normal file
24
inference-engine/cmake/clang_format_fix.cmake
Normal file
@@ -0,0 +1,24 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
function(style_apply_file INPUT_FILE)
|
||||
execute_process(COMMAND ${CLANG_FORMAT} -style=file -i ${INPUT_FILE}
|
||||
OUTPUT_VARIABLE STYLE_CHECK_RESULT)
|
||||
endfunction()
|
||||
|
||||
foreach(source_file IN LISTS INPUT_FILES)
|
||||
set(exclude FALSE)
|
||||
foreach(pattern IN LISTS EXCLUDE_PATTERNS)
|
||||
if(source_file MATCHES "${pattern}")
|
||||
set(exclude ON)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(exclude)
|
||||
continue()
|
||||
endif()
|
||||
|
||||
style_apply_file(${source_file})
|
||||
endforeach()
|
||||
@@ -1,13 +1,34 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
if(DEFINED IE_MAIN_SOURCE_DIR AND TARGET inference_engine)
|
||||
set(InferenceEngine_INCLUDE_DIRS ${IE_MAIN_SOURCE_DIR}/include)
|
||||
set(InferenceEngine_LIBRARIES inference_engine)
|
||||
set(InferenceEngine_LIBRARIES inference_engine_legacy inference_engine
|
||||
inference_engine_c_api inference_engine_nn_builder)
|
||||
else()
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/targets.cmake")
|
||||
if(NOT WIN32)
|
||||
set_target_properties(IE::inference_engine PROPERTIES INTERFACE_COMPILE_OPTIONS "-Wno-error=deprecated-declarations")
|
||||
endif()
|
||||
|
||||
file(TO_CMAKE_PATH "${CMAKE_CURRENT_LIST_DIR}" cache_path)
|
||||
set (ie_options THREADING)
|
||||
load_cache("${cache_path}" READ_WITH_PREFIX "" ${ie_options})
|
||||
message(STATUS "The following CMake options are exported from the Inference Engine build")
|
||||
message("")
|
||||
foreach(option IN LISTS ie_options)
|
||||
message(" ${option}: ${${option}}")
|
||||
endforeach()
|
||||
message("")
|
||||
|
||||
# inherit TBB from main IE project if enabled
|
||||
if (THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO")
|
||||
load_cache("${cache_path}" READ_WITH_PREFIX "" TBB_DIR;ENABLE_TBB_RELEASE_ONLY)
|
||||
set(TBB_FIND_RELEASE_ONLY ${ENABLE_TBB_RELEASE_ONLY})
|
||||
find_package(TBB)
|
||||
endif()
|
||||
|
||||
get_target_property(InferenceEngine_INCLUDE_DIRS IE::inference_engine INTERFACE_INCLUDE_DIRECTORIES)
|
||||
set(InferenceEngine_LIBRARIES IE::inference_engine)
|
||||
set(InferenceEngine_LIBRARIES IE::inference_engine_legacy IE::inference_engine
|
||||
IE::inference_engine_c_api IE::inference_engine_nn_builder)
|
||||
endif()
|
||||
|
||||
73
inference-engine/cmake/coverage_ie.cmake
Normal file
73
inference-engine/cmake/coverage_ie.cmake
Normal file
@@ -0,0 +1,73 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
set(DLDT_COVERAGE_GCDA_DATA_DIRECTORY "${CMAKE_BINARY_DIR}/inference-engine/src")
|
||||
set(DLDT_COVERAGE_BASE_DIRECTORY "${IE_MAIN_SOURCE_DIR}/src")
|
||||
|
||||
ie_coverage_clean(REPOSITORY "dldt"
|
||||
DIRECTORY "${DLDT_COVERAGE_GCDA_DATA_DIRECTORY}")
|
||||
ie_coverage_capture(INFO_FILE "dldt"
|
||||
BASE_DIRECTORY "${DLDT_COVERAGE_BASE_DIRECTORY}"
|
||||
DIRECTORY "${DLDT_COVERAGE_GCDA_DATA_DIRECTORY}")
|
||||
|
||||
# Generate reports
|
||||
|
||||
ie_coverage_extract(INPUT "dldt" OUTPUT "inference_engine_with_builders"
|
||||
PATTERNS "${DLDT_COVERAGE_BASE_DIRECTORY}/inference_engine/*"
|
||||
"${DLDT_COVERAGE_BASE_DIRECTORY}/plugin_api/*")
|
||||
ie_coverage_remove(INPUT "inference_engine_with_builders" OUTPUT "inference_engine"
|
||||
PATTERNS "${DLDT_COVERAGE_BASE_DIRECTORY}/inference_engine/builders/*")
|
||||
ie_coverage_genhtml(INFO_FILE "inference_engine"
|
||||
PREFIX "${DLDT_COVERAGE_BASE_DIRECTORY}")
|
||||
|
||||
ie_coverage_extract(INPUT "dldt" OUTPUT "inference_engine_legacy"
|
||||
PATTERNS "${DLDT_COVERAGE_BASE_DIRECTORY}/legacy_api/*")
|
||||
ie_coverage_genhtml(INFO_FILE "inference_engine_legacy"
|
||||
PREFIX "${DLDT_COVERAGE_BASE_DIRECTORY}")
|
||||
|
||||
ie_coverage_extract(INPUT "dldt" OUTPUT "hetero_plugin"
|
||||
PATTERNS "${DLDT_COVERAGE_BASE_DIRECTORY}/hetero_plugin/*")
|
||||
ie_coverage_genhtml(INFO_FILE "hetero_plugin"
|
||||
PREFIX "${DLDT_COVERAGE_BASE_DIRECTORY}")
|
||||
|
||||
ie_coverage_extract(INPUT "dldt" OUTPUT "multi_device"
|
||||
PATTERNS "${DLDT_COVERAGE_BASE_DIRECTORY}/multi_device/*")
|
||||
ie_coverage_genhtml(INFO_FILE "multi_device"
|
||||
PREFIX "${DLDT_COVERAGE_BASE_DIRECTORY}")
|
||||
|
||||
ie_coverage_extract(INPUT "dldt" OUTPUT "preprocessing"
|
||||
PATTERNS "${DLDT_COVERAGE_BASE_DIRECTORY}/preprocessing/*")
|
||||
ie_coverage_genhtml(INFO_FILE "preprocessing"
|
||||
PREFIX "${DLDT_COVERAGE_BASE_DIRECTORY}")
|
||||
|
||||
ie_coverage_extract(INPUT "dldt" OUTPUT "inference_engine_transformations"
|
||||
PATTERNS "${DLDT_COVERAGE_BASE_DIRECTORY}/inference_engine_transformations/*")
|
||||
ie_coverage_genhtml(INFO_FILE "inference_engine_transformations"
|
||||
PREFIX "${DLDT_COVERAGE_BASE_DIRECTORY}")
|
||||
|
||||
ie_coverage_extract(INPUT "dldt" OUTPUT "low_precision_transformations"
|
||||
PATTERNS "${DLDT_COVERAGE_BASE_DIRECTORY}/low_precision_transformations/*")
|
||||
ie_coverage_genhtml(INFO_FILE "low_precision_transformations"
|
||||
PREFIX "${DLDT_COVERAGE_BASE_DIRECTORY}")
|
||||
|
||||
if(ENABLE_MKL_DNN)
|
||||
ie_coverage_extract(INPUT "dldt" OUTPUT "mkldnn_plugin"
|
||||
PATTERNS "${DLDT_COVERAGE_BASE_DIRECTORY}/mkldnn_plugin/*")
|
||||
ie_coverage_genhtml(INFO_FILE "mkldnn_plugin"
|
||||
PREFIX "${DLDT_COVERAGE_BASE_DIRECTORY}")
|
||||
endif()
|
||||
|
||||
if(ENABLE_CLDNN)
|
||||
ie_coverage_extract(INPUT "dldt" OUTPUT "cldnn_engine"
|
||||
PATTERNS "${DLDT_COVERAGE_BASE_DIRECTORY}/cldnn_engine/*")
|
||||
ie_coverage_genhtml(INFO_FILE "cldnn_engine"
|
||||
PREFIX "${DLDT_COVERAGE_BASE_DIRECTORY}")
|
||||
endif()
|
||||
|
||||
if(ENABLE_GNA)
|
||||
ie_coverage_extract(INPUT "dldt" OUTPUT "gna_plugin"
|
||||
PATTERNS "${DLDT_COVERAGE_BASE_DIRECTORY}/gna_plugin/*")
|
||||
ie_coverage_genhtml(INFO_FILE "gna_plugin"
|
||||
PREFIX "${DLDT_COVERAGE_BASE_DIRECTORY}")
|
||||
endif()
|
||||
@@ -1,13 +1,12 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
if(ENABLE_CPPLINT)
|
||||
find_package(PythonInterp 2.7 EXACT)
|
||||
find_host_package(PythonInterp)
|
||||
|
||||
if(NOT PYTHONINTERP_FOUND)
|
||||
message(WARNING "Python was not found (required for cpplint check)")
|
||||
message(WARNING "Python interpreter was not found (required for cpplint check)")
|
||||
set(ENABLE_CPPLINT OFF)
|
||||
endif()
|
||||
endif()
|
||||
@@ -24,7 +23,7 @@ function(add_cpplint_target TARGET_NAME)
|
||||
|
||||
set(options "")
|
||||
set(oneValueArgs "")
|
||||
set(multiValueArgs "FOR_TARGETS" "FOR_SOURCES" "EXCLUDE_PATTERNS")
|
||||
set(multiValueArgs FOR_TARGETS FOR_SOURCES EXCLUDE_PATTERNS CUSTOM_FILTERS)
|
||||
cmake_parse_arguments(CPPLINT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
foreach(target IN LISTS CPPLINT_FOR_TARGETS)
|
||||
@@ -33,12 +32,17 @@ function(add_cpplint_target TARGET_NAME)
|
||||
endforeach()
|
||||
list(REMOVE_DUPLICATES CPPLINT_FOR_SOURCES)
|
||||
|
||||
set(custom_filter "")
|
||||
foreach(filter IN LISTS CPPLINT_CUSTOM_FILTERS)
|
||||
string(CONCAT custom_filter "${custom_filter}" "," "${filter}")
|
||||
endforeach()
|
||||
|
||||
set(all_output_files "")
|
||||
foreach(source_file IN LISTS CPPLINT_FOR_SOURCES)
|
||||
set(exclude FALSE)
|
||||
foreach(pattern IN LISTS CPPLINT_EXCLUDE_PATTERNS)
|
||||
if(source_file MATCHES "${pattern}")
|
||||
set(exclude TRUE)
|
||||
set(exclude ON)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
@@ -47,6 +51,11 @@ function(add_cpplint_target TARGET_NAME)
|
||||
continue()
|
||||
endif()
|
||||
|
||||
# ignore object libraries
|
||||
if(NOT EXISTS "${source_file}")
|
||||
continue()
|
||||
endif()
|
||||
|
||||
file(RELATIVE_PATH source_file_relative "${CMAKE_CURRENT_SOURCE_DIR}" "${source_file}")
|
||||
set(output_file "${CMAKE_CURRENT_BINARY_DIR}/cpplint/${source_file_relative}.cpplint")
|
||||
string(REPLACE ".." "__" output_file "${output_file}")
|
||||
@@ -58,12 +67,12 @@ function(add_cpplint_target TARGET_NAME)
|
||||
"${output_file}"
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}"
|
||||
-D "PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}"
|
||||
-D "CPPLINT_SCRIPT=${IE_MAIN_SOURCE_DIR}/scripts/cpplint.py"
|
||||
-D "INPUT_FILE=${source_file}"
|
||||
-D "OUTPUT_FILE=${output_file}"
|
||||
-D "WORKING_DIRECTORY=${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
-D "SKIP_RETURN_CODE=${ENABLE_CPPLINT_REPORT}"
|
||||
-D "CUSTOM_FILTER=${custom_filter}"
|
||||
-P "${IE_MAIN_SOURCE_DIR}/cmake/cpplint_run.cmake"
|
||||
DEPENDS
|
||||
"${source_file}"
|
||||
@@ -127,7 +136,7 @@ function(add_cpplint_report_target)
|
||||
-D "OUTPUT_FILE=${cppcheck_output_file}"
|
||||
-P "${IE_MAIN_SOURCE_DIR}/cmake/cpplint_to_cppcheck_xml.cmake"
|
||||
DEPENDS
|
||||
${cpplint_output_file}
|
||||
"${cpplint_output_file}"
|
||||
"${IE_MAIN_SOURCE_DIR}/scripts/cpplint_to_cppcheckxml.py"
|
||||
"${IE_MAIN_SOURCE_DIR}/cmake/cpplint_to_cppcheck_xml.cmake"
|
||||
COMMENT
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
@@ -22,9 +21,9 @@ execute_process(
|
||||
|
||||
file(READ "${REPORT_DIR}/index.html" cur_file_content)
|
||||
|
||||
string(REPLACE "Cppcheck" "cpplint" cur_file_content ${cur_file_content})
|
||||
string(REPLACE "a tool for static C/C++ code analysis" "an open source lint-like tool from Google" cur_file_content ${cur_file_content})
|
||||
string(REPLACE "http://cppcheck.sourceforge.net" "http://google-styleguide.googlecode.com/svn/trunk/cpplint/cpplint.py" cur_file_content ${cur_file_content})
|
||||
string(REPLACE "IRC: <a href=\"irc://irc.freenode.net/cppcheck\">irc://irc.freenode.net/cppcheck</a>" " " cur_file_content ${cur_file_content})
|
||||
string(REPLACE "Cppcheck" "cpplint" cur_file_content "${cur_file_content}")
|
||||
string(REPLACE "a tool for static C/C++ code analysis" "an open source lint-like tool from Google" cur_file_content "${cur_file_content}")
|
||||
string(REPLACE "http://cppcheck.sourceforge.net" "http://google-styleguide.googlecode.com/svn/trunk/cpplint/cpplint.py" cur_file_content "${cur_file_content}")
|
||||
string(REPLACE "IRC: <a href=\"irc://irc.freenode.net/cppcheck\">irc://irc.freenode.net/cppcheck</a>" " " cur_file_content "${cur_file_content}")
|
||||
|
||||
file(WRITE "${REPORT_DIR}/index.html" "${cur_file_content}")
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
|
||||
@@ -1,37 +1,55 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
file(REMOVE "${OUTPUT_FILE}")
|
||||
|
||||
set(DEFAULT_FILTER "
|
||||
-build/header_guard,\
|
||||
-build/include,\
|
||||
-build/include_order,\
|
||||
-build/include_subdir,\
|
||||
-build/include_what_you_use,\
|
||||
-build/namespaces,\
|
||||
-build/c++11,\
|
||||
-whitespace/indent,\
|
||||
-whitespace/comments,\
|
||||
-whitespace/ending_newline,\
|
||||
-runtime/references,\
|
||||
-runtime/int,\
|
||||
-runtime/explicit,\
|
||||
-readability/todo,\
|
||||
-readability/fn_size,\
|
||||
")
|
||||
set(FILTER "${DEFAULT_FILTER}${CUSTOM_FILTER}")
|
||||
|
||||
execute_process(
|
||||
COMMAND
|
||||
"${PYTHON_EXECUTABLE}"
|
||||
python3
|
||||
"${CPPLINT_SCRIPT}"
|
||||
"--linelength=160"
|
||||
"--counting=detailed"
|
||||
"--filter=-readability/fn_size"
|
||||
"--quiet"
|
||||
"--filter=${FILTER}"
|
||||
"${INPUT_FILE}"
|
||||
WORKING_DIRECTORY "${WORKING_DIRECTORY}"
|
||||
RESULT_VARIABLE result
|
||||
OUTPUT_VARIABLE output
|
||||
ERROR_VARIABLE output)
|
||||
|
||||
# Display the cpplint output to console (to parse it form IDE)
|
||||
message("${output}")
|
||||
|
||||
# Store cpplint output to file (replace problematic symbols)
|
||||
string(REPLACE "\"" ""\;" output ${output})
|
||||
string(REPLACE "<" "<\;" output ${output})
|
||||
string(REPLACE ">" ">\;" output ${output})
|
||||
string(REPLACE "'" "&apos\;" output ${output})
|
||||
string(REPLACE "&" "&\;" output ${output})
|
||||
file(WRITE "${OUTPUT_FILE}" ${output})
|
||||
string(REPLACE "\"" ""\;" formatted_output "${output}")
|
||||
string(REPLACE "<" "<\;" formatted_output "${formatted_output}")
|
||||
string(REPLACE ">" ">\;" formatted_output "${formatted_output}")
|
||||
string(REPLACE "'" "&apos\;" formatted_output "${formatted_output}")
|
||||
string(REPLACE "&" "&\;" formatted_output "${formatted_output}")
|
||||
file(WRITE "${OUTPUT_FILE}" "${formatted_output}")
|
||||
|
||||
if(NOT SKIP_RETURN_CODE)
|
||||
# Pass through the cpplint return code
|
||||
if(NOT result EQUAL 0)
|
||||
# Display the cpplint output to console (to parse it form IDE)
|
||||
message("${output}")
|
||||
message(FATAL_ERROR "[cpplint] Code style check failed for : ${INPUT_FILE}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
|
||||
@@ -1,71 +1,40 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
cmake_policy(SET CMP0054 NEW)
|
||||
|
||||
#features trigger supported by build system
|
||||
include(check_features)
|
||||
include(debug)
|
||||
|
||||
#we have number of dependencies stored on ftp
|
||||
include(dependency_solver)
|
||||
|
||||
#prepare temporary folder
|
||||
if (DEFINED ENV{${DL_SDK_TEMP}} AND NOT $ENV{${DL_SDK_TEMP}} STREQUAL "")
|
||||
if (WIN32)
|
||||
string(REPLACE "\\" "\\\\" TEMP $ENV{${DL_SDK_TEMP}})
|
||||
else(WIN32)
|
||||
set(TEMP $ENV{${DL_SDK_TEMP}})
|
||||
endif(WIN32)
|
||||
|
||||
if (ENABLE_ALTERNATIVE_TEMP)
|
||||
set(ALTERNATIVE_PATH ${IE_MAIN_SOURCE_DIR}/temp)
|
||||
endif()
|
||||
else ()
|
||||
message(STATUS "DL_SDK_TEMP envionment not set")
|
||||
set(TEMP ${IE_MAIN_SOURCE_DIR}/temp)
|
||||
endif ()
|
||||
|
||||
if (CMAKE_CROSSCOMPILING)
|
||||
set(CMAKE_STAGING_PREFIX "${TEMP}")
|
||||
endif()
|
||||
|
||||
include(ExternalProject)
|
||||
|
||||
if (ENABLE_SAME_BRANCH_FOR_MODELS)
|
||||
branchName(MODELS_BRANCH)
|
||||
else()
|
||||
set(MODELS_BRANCH "master")
|
||||
include(linux_name)
|
||||
if(COMMAND get_linux_name)
|
||||
get_linux_name(LINUX_OS_NAME)
|
||||
endif()
|
||||
|
||||
if (ENABLE_MYRIAD)
|
||||
RESOLVE_DEPENDENCY(VPU_FIRMWARE_MA2450
|
||||
ARCHIVE_UNIFIED firmware_ma2450_491.zip
|
||||
TARGET_PATH "${TEMP}/vpu/firmware/ma2450"
|
||||
ENVIRONMENT "VPU_FIRMWARE_MA2450"
|
||||
FOLDER)
|
||||
debug_message(STATUS "ma2450=" ${VPU_FIRMWARE_MA2450})
|
||||
endif ()
|
||||
include(CMakeParseArguments)
|
||||
|
||||
if (ENABLE_MYRIAD)
|
||||
RESOLVE_DEPENDENCY(VPU_FIRMWARE_MA2480
|
||||
ARCHIVE_UNIFIED firmware_ma2480_mdk_R7_9.zip
|
||||
TARGET_PATH "${TEMP}/vpu/firmware/ma2480"
|
||||
ENVIRONMENT "VPU_FIRMWARE_MA2480"
|
||||
FOLDER)
|
||||
debug_message(STATUS "ma2480=" ${VPU_FIRMWARE_MA2480})
|
||||
endif ()
|
||||
include(vpu_dependencies)
|
||||
endif()
|
||||
|
||||
## enable cblas_gemm from OpenBLAS package
|
||||
if (GEMM STREQUAL "OPENBLAS")
|
||||
if(NOT BLAS_LIBRARIES OR NOT BLAS_INCLUDE_DIRS)
|
||||
find_package(BLAS REQUIRED)
|
||||
if(BLAS_FOUND)
|
||||
find_path(BLAS_INCLUDE_DIRS cblas.h)
|
||||
else()
|
||||
message(ERROR "OpenBLAS not found: install OpenBLAS or set -DBLAS_INCLUDE_DIRS=<path to dir with cblas.h> and -DBLAS_LIBRARIES=<path to libopenblas.so or openblas.lib>")
|
||||
if(NOT BLAS_LIBRARIES OR NOT BLAS_INCLUDE_DIRS)
|
||||
find_package(BLAS REQUIRED)
|
||||
if(BLAS_FOUND)
|
||||
find_path(BLAS_INCLUDE_DIRS cblas.h)
|
||||
else()
|
||||
message(ERROR "OpenBLAS not found: install OpenBLAS or set -DBLAS_INCLUDE_DIRS=<path to dir with cblas.h> and -DBLAS_LIBRARIES=<path to libopenblas.so or openblas.lib>")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
debug_message(STATUS "openblas=" ${BLAS_LIBRARIES})
|
||||
debug_message(STATUS "openblas=" ${BLAS_LIBRARIES})
|
||||
endif ()
|
||||
|
||||
#MKL-ml package
|
||||
@@ -79,128 +48,175 @@ endif ()
|
||||
|
||||
## Intel OMP package
|
||||
if (THREADING STREQUAL "OMP")
|
||||
if (WIN32)
|
||||
RESOLVE_DEPENDENCY(OMP
|
||||
ARCHIVE_WIN "iomp.zip"
|
||||
TARGET_PATH "${TEMP}/omp"
|
||||
ENVIRONMENT "OMP"
|
||||
VERSION_REGEX ".*_([a-z]*_([a-z0-9]+\\.)*[0-9]+).*")
|
||||
elseif(LINUX)
|
||||
RESOLVE_DEPENDENCY(OMP
|
||||
ARCHIVE_LIN "iomp.tgz"
|
||||
TARGET_PATH "${TEMP}/omp"
|
||||
ENVIRONMENT "OMP"
|
||||
VERSION_REGEX ".*_([a-z]*_([a-z0-9]+\\.)*[0-9]+).*")
|
||||
else(APPLE)
|
||||
RESOLVE_DEPENDENCY(OMP
|
||||
ARCHIVE_MAC "iomp_20190130_mac.tgz"
|
||||
TARGET_PATH "${TEMP}/omp"
|
||||
ENVIRONMENT "OMP"
|
||||
VERSION_REGEX ".*_([a-z]*_([a-z0-9]+\\.)*[0-9]+).*")
|
||||
endif()
|
||||
log_rpath_from_dir(OMP "${OMP}/lib")
|
||||
debug_message(STATUS "intel_omp=" ${OMP})
|
||||
reset_deps_cache(OMP)
|
||||
if (WIN32 AND X86_64)
|
||||
RESOLVE_DEPENDENCY(OMP
|
||||
ARCHIVE_WIN "iomp.zip"
|
||||
TARGET_PATH "${TEMP}/omp"
|
||||
ENVIRONMENT "OMP"
|
||||
VERSION_REGEX ".*_([a-z]*_([a-z0-9]+\\.)*[0-9]+).*")
|
||||
elseif(LINUX AND X86_64)
|
||||
RESOLVE_DEPENDENCY(OMP
|
||||
ARCHIVE_LIN "iomp.tgz"
|
||||
TARGET_PATH "${TEMP}/omp"
|
||||
ENVIRONMENT "OMP"
|
||||
VERSION_REGEX ".*_([a-z]*_([a-z0-9]+\\.)*[0-9]+).*")
|
||||
elseif(APPLE AND X86_64)
|
||||
RESOLVE_DEPENDENCY(OMP
|
||||
ARCHIVE_MAC "iomp_20190130_mac.tgz"
|
||||
TARGET_PATH "${TEMP}/omp"
|
||||
ENVIRONMENT "OMP"
|
||||
VERSION_REGEX ".*_([a-z]*_([a-z0-9]+\\.)*[0-9]+).*")
|
||||
else()
|
||||
message(FATAL_ERROR "Intel OMP is not available on current platform")
|
||||
endif()
|
||||
update_deps_cache(OMP "${OMP}" "Path to OMP root folder")
|
||||
log_rpath_from_dir(OMP "${OMP}/lib")
|
||||
debug_message(STATUS "intel_omp=" ${OMP})
|
||||
endif ()
|
||||
|
||||
## TBB package
|
||||
if (THREADING STREQUAL "TBB")
|
||||
if (WIN32)
|
||||
#TODO: add target_path to be platform specific as well, to avoid following if
|
||||
RESOLVE_DEPENDENCY(TBB
|
||||
ARCHIVE_WIN "tbb2019_20181010_win.zip" #TODO: windows zip archive created incorrectly using old name for folder
|
||||
TARGET_PATH "${TEMP}/tbb"
|
||||
ENVIRONMENT "TBBROOT"
|
||||
VERSION_REGEX ".*_([a-z]*_([a-z0-9]+\\.)*[0-9]+).*")
|
||||
elseif(LINUX)
|
||||
RESOLVE_DEPENDENCY(TBB
|
||||
ARCHIVE_LIN "tbb2019_20181010_lin.tgz"
|
||||
TARGET_PATH "${TEMP}/tbb"
|
||||
ENVIRONMENT "TBBROOT")
|
||||
else(APPLE)
|
||||
RESOLVE_DEPENDENCY(TBB
|
||||
ARCHIVE_MAC "tbb2019_20190414_mac.tgz"
|
||||
TARGET_PATH "${TEMP}/tbb"
|
||||
ENVIRONMENT "TBBROOT"
|
||||
VERSION_REGEX ".*_([a-z]*_([a-z0-9]+\\.)*[0-9]+).*")
|
||||
endif()
|
||||
log_rpath_from_dir(TBB "${TBB}/lib")
|
||||
debug_message(STATUS "tbb=" ${TBB})
|
||||
if (THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO")
|
||||
reset_deps_cache(TBBROOT)
|
||||
|
||||
if(NOT DEFINED TBB_DIR AND NOT DEFINED ENV{TBB_DIR})
|
||||
if (WIN32 AND X86_64)
|
||||
#TODO: add target_path to be platform specific as well, to avoid following if
|
||||
RESOLVE_DEPENDENCY(TBB
|
||||
ARCHIVE_WIN "tbb2020_20200415_win.zip"
|
||||
TARGET_PATH "${TEMP}/tbb"
|
||||
ENVIRONMENT "TBBROOT")
|
||||
elseif(ANDROID) # Should be before LINUX due LINUX is detected as well
|
||||
RESOLVE_DEPENDENCY(TBB
|
||||
ARCHIVE_ANDROID "tbb2020_20200404_android.tgz"
|
||||
TARGET_PATH "${TEMP}/tbb"
|
||||
ENVIRONMENT "TBBROOT")
|
||||
elseif(LINUX AND X86_64)
|
||||
RESOLVE_DEPENDENCY(TBB
|
||||
ARCHIVE_LIN "tbb2020_20200415_lin_strip.tgz"
|
||||
TARGET_PATH "${TEMP}/tbb")
|
||||
elseif(APPLE AND X86_64)
|
||||
RESOLVE_DEPENDENCY(TBB
|
||||
ARCHIVE_MAC "tbb2020_20200404_mac.tgz"
|
||||
TARGET_PATH "${TEMP}/tbb"
|
||||
ENVIRONMENT "TBBROOT")
|
||||
else()
|
||||
message(FATAL_ERROR "TBB is not available on current platform")
|
||||
endif()
|
||||
else()
|
||||
if(DEFINED TBB_DIR)
|
||||
get_filename_component(TBB ${TBB_DIR} DIRECTORY)
|
||||
else()
|
||||
get_filename_component(TBB $ENV{TBB_DIR} DIRECTORY)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
update_deps_cache(TBBROOT "${TBB}" "Path to TBB root folder")
|
||||
|
||||
if (WIN32)
|
||||
log_rpath_from_dir(TBB "${TBB}/bin")
|
||||
else ()
|
||||
log_rpath_from_dir(TBB "${TBB}/lib")
|
||||
endif ()
|
||||
debug_message(STATUS "tbb=" ${TBB})
|
||||
endif ()
|
||||
|
||||
if (ENABLE_OPENCV)
|
||||
if (WIN32)
|
||||
RESOLVE_DEPENDENCY(OPENCV
|
||||
ARCHIVE_WIN "opencv_4.1.0-0437.zip"
|
||||
TARGET_PATH "${TEMP}/opencv_4.1.0"
|
||||
ENVIRONMENT "OpenCV_DIR"
|
||||
VERSION_REGEX ".*_([0-9]+.[0-9]+.[0-9]+).*")
|
||||
log_rpath_from_dir(OPENCV "\\opencv_4.1.0\\bin")
|
||||
set( ENV{OpenCV_DIR} ${OPENCV}/cmake )
|
||||
elseif(APPLE)
|
||||
RESOLVE_DEPENDENCY(OPENCV
|
||||
ARCHIVE_MAC "opencv_4.1.0-0437_osx.tar.xz"
|
||||
TARGET_PATH "${TEMP}/opencv_4.1.0_osx"
|
||||
ENVIRONMENT "OpenCV_DIR"
|
||||
VERSION_REGEX ".*_([0-9]+.[0-9]+.[0-9]+).*")
|
||||
log_rpath_from_dir(OPENCV "opencv_4.1.0_osx/lib")
|
||||
set( ENV{OpenCV_DIR} ${OPENCV}/cmake )
|
||||
elseif(LINUX)
|
||||
if (${LINUX_OS_NAME} STREQUAL "Ubuntu 16.04")
|
||||
RESOLVE_DEPENDENCY(OPENCV
|
||||
ARCHIVE_LIN "opencv_4.1.0-0437_ubuntu16.tar.xz"
|
||||
TARGET_PATH "${TEMP}/opencv_4.1.0_ubuntu16"
|
||||
ENVIRONMENT "OpenCV_DIR"
|
||||
VERSION_REGEX ".*_([0-9]+.[0-9]+.[0-9]+).*")
|
||||
log_rpath_from_dir(OPENCV "opencv_4.1.0_ubuntu16/lib")
|
||||
elseif (${LINUX_OS_NAME} STREQUAL "Ubuntu 18.04")
|
||||
RESOLVE_DEPENDENCY(OPENCV
|
||||
ARCHIVE_LIN "opencv_4.1.0-0437_ubuntu18.tar.xz"
|
||||
TARGET_PATH "${TEMP}/opencv_4.1.0_ubuntu18"
|
||||
ENVIRONMENT "OpenCV_DIR"
|
||||
VERSION_REGEX ".*_([0-9]+.[0-9]+.[0-9]+).*")
|
||||
log_rpath_from_dir(OPENCV "opencv_4.1.0_ubuntu18/lib")
|
||||
elseif (${LINUX_OS_NAME} STREQUAL "CentOS 7")
|
||||
RESOLVE_DEPENDENCY(OPENCV
|
||||
ARCHIVE_LIN "opencv_4.1.0-0437_centos7.tar.xz"
|
||||
TARGET_PATH "${TEMP}/opencv_4.1.0_centos"
|
||||
ENVIRONMENT "OpenCV_DIR"
|
||||
VERSION_REGEX ".*_([0-9]+.[0-9]+.[0-9]+).*")
|
||||
log_rpath_from_dir(OPENCV "opencv_4.1.0_centos/lib")
|
||||
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l" AND
|
||||
(${LINUX_OS_NAME} STREQUAL "Debian 9" OR
|
||||
${LINUX_OS_NAME} STREQUAL "Raspbian 9"))
|
||||
RESOLVE_DEPENDENCY(OPENCV
|
||||
ARCHIVE_LIN "opencv_4.1.0-0437_debian9arm.tar.xz"
|
||||
TARGET_PATH "${TEMP}/opencv_4.1.0_debian9arm"
|
||||
ENVIRONMENT "OpenCV_DIR"
|
||||
VERSION_REGEX ".*_([0-9]+.[0-9]+.[0-9]+).*")
|
||||
log_rpath_from_dir(OPENCV "opencv_4.1.0_debian9arm/lib")
|
||||
endif()
|
||||
set( ENV{OpenCV_DIR} ${OPENCV}/cmake )
|
||||
endif()
|
||||
debug_message(STATUS "opencv=" ${OPENCV})
|
||||
endif()
|
||||
reset_deps_cache(OpenCV_DIR)
|
||||
|
||||
set(OPENCV_VERSION "4.3.0")
|
||||
set(OPENCV_BUILD "060")
|
||||
if (WIN32 AND X86_64)
|
||||
RESOLVE_DEPENDENCY(OPENCV
|
||||
ARCHIVE_WIN "opencv_${OPENCV_VERSION}-${OPENCV_BUILD}.txz"
|
||||
TARGET_PATH "${TEMP}/opencv_${OPENCV_VERSION}/opencv"
|
||||
ENVIRONMENT "OpenCV_DIR"
|
||||
VERSION_REGEX ".*_([0-9]+.[0-9]+.[0-9]+).*")
|
||||
elseif(APPLE AND X86_64)
|
||||
RESOLVE_DEPENDENCY(OPENCV
|
||||
ARCHIVE_MAC "opencv_${OPENCV_VERSION}-${OPENCV_BUILD}_osx.txz"
|
||||
TARGET_PATH "${TEMP}/opencv_${OPENCV_VERSION}_osx/opencv"
|
||||
ENVIRONMENT "OpenCV_DIR"
|
||||
VERSION_REGEX ".*_([0-9]+.[0-9]+.[0-9]+).*")
|
||||
elseif(LINUX)
|
||||
if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l")
|
||||
set(OPENCV_SUFFIX "debian9arm")
|
||||
elseif (${LINUX_OS_NAME} STREQUAL "CentOS 7" OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9")
|
||||
set(OPENCV_SUFFIX "centos7")
|
||||
elseif (${LINUX_OS_NAME} STREQUAL "Ubuntu 16.04")
|
||||
set(OPENCV_SUFFIX "ubuntu16")
|
||||
elseif (${LINUX_OS_NAME} STREQUAL "Ubuntu 18.04")
|
||||
set(OPENCV_SUFFIX "ubuntu18")
|
||||
else()
|
||||
message(FATAL_ERROR "OpenCV is not available on current platform")
|
||||
endif()
|
||||
RESOLVE_DEPENDENCY(OPENCV
|
||||
ARCHIVE_LIN "opencv_${OPENCV_VERSION}-${OPENCV_BUILD}_${OPENCV_SUFFIX}.txz"
|
||||
TARGET_PATH "${TEMP}/opencv_${OPENCV_VERSION}_${OPENCV_SUFFIX}/opencv"
|
||||
ENVIRONMENT "OpenCV_DIR"
|
||||
VERSION_REGEX ".*_([0-9]+.[0-9]+.[0-9]+).*")
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
set(ocv_cmake_path "${OPENCV}/sdk/native/jni/")
|
||||
else()
|
||||
set(ocv_cmake_path "${OPENCV}/cmake")
|
||||
endif()
|
||||
|
||||
update_deps_cache(OpenCV_DIR "${ocv_cmake_path}" "Path to OpenCV package folder")
|
||||
|
||||
if(WIN32)
|
||||
log_rpath_from_dir(OPENCV "${OpenCV_DIR}/../bin")
|
||||
elseif(ANDROID)
|
||||
log_rpath_from_dir(OPENCV "${OpenCV_DIR}/../../../lib")
|
||||
else()
|
||||
log_rpath_from_dir(OPENCV "${OpenCV_DIR}/../lib")
|
||||
endif()
|
||||
debug_message(STATUS "opencv=" ${OPENCV})
|
||||
endif()
|
||||
|
||||
include(ie_parallel)
|
||||
|
||||
if (ENABLE_GNA)
|
||||
RESOLVE_DEPENDENCY(GNA
|
||||
ARCHIVE_UNIFIED "gna_20181120.zip"
|
||||
TARGET_PATH "${TEMP}/gna")
|
||||
reset_deps_cache(
|
||||
GNA
|
||||
GNA_PLATFORM_DIR
|
||||
GNA_KERNEL_LIB_NAME
|
||||
GNA_LIBS_LIST
|
||||
GNA_LIB_DIR
|
||||
libGNA_INCLUDE_DIRS
|
||||
libGNA_LIBRARIES_BASE_PATH)
|
||||
if (GNA_LIBRARY_VERSION STREQUAL "GNA1")
|
||||
RESOLVE_DEPENDENCY(GNA
|
||||
ARCHIVE_UNIFIED "gna_20181120.zip"
|
||||
TARGET_PATH "${TEMP}/gna")
|
||||
else()
|
||||
if(GNA_LIBRARY_VERSION STREQUAL "GNA1_1401")
|
||||
set(GNA_VERSION "01.00.00.1401")
|
||||
endif()
|
||||
if(GNA_LIBRARY_VERSION STREQUAL "GNA2")
|
||||
set(GNA_VERSION "02.00.00.0654")
|
||||
endif()
|
||||
RESOLVE_DEPENDENCY(GNA
|
||||
ARCHIVE_UNIFIED "GNA_${GNA_VERSION}.zip"
|
||||
TARGET_PATH "${TEMP}/gna_${GNA_VERSION}"
|
||||
VERSION_REGEX ".*_([0-9]+.[0-9]+.[0-9]+.[0-9]+).*")
|
||||
endif()
|
||||
update_deps_cache(GNA "${GNA}" "Path to GNA root folder")
|
||||
debug_message(STATUS "gna=" ${GNA})
|
||||
endif()
|
||||
|
||||
configure_file(
|
||||
"${CMAKE_SOURCE_DIR}/cmake/share/InferenceEngineConfig.cmake.in"
|
||||
"${IE_MAIN_SOURCE_DIR}/cmake/share/InferenceEngineConfig.cmake.in"
|
||||
"${CMAKE_BINARY_DIR}/share/InferenceEngineConfig.cmake"
|
||||
@ONLY)
|
||||
|
||||
configure_file(
|
||||
"${CMAKE_SOURCE_DIR}/cmake/share/InferenceEngineConfig-version.cmake.in"
|
||||
"${IE_MAIN_SOURCE_DIR}/cmake/share/InferenceEngineConfig-version.cmake.in"
|
||||
"${CMAKE_BINARY_DIR}/share/InferenceEngineConfig-version.cmake"
|
||||
COPYONLY)
|
||||
|
||||
configure_file(
|
||||
"${CMAKE_SOURCE_DIR}/cmake/ie_parallel.cmake"
|
||||
"${IE_MAIN_SOURCE_DIR}/cmake/ie_parallel.cmake"
|
||||
"${CMAKE_BINARY_DIR}/share/ie_parallel.cmake"
|
||||
COPYONLY)
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
include ("download")
|
||||
|
||||
function (resolve_archive_dependency VAR COMPONENT ARCHIVE ARCHIVE_UNIFIED ARCHIVE_WIN ARCHIVE_LIN ARCHIVE_MAC TARGET_PATH FOLDER ENVIRONMENT)
|
||||
|
||||
if (ENVIRONMENT AND (DEFINED ENV{${ENVIRONMENT}}))
|
||||
set(HAS_ENV "TRUE")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED HAS_ENV)
|
||||
if (ARCHIVE)
|
||||
#TODO: check whether this is platform specific binary with same name per or it is in common folder
|
||||
DownloadAndExtract(${COMPONENT} ${ARCHIVE} ${TARGET_PATH} result_path ${FOLDER})
|
||||
else()
|
||||
DownloadAndExtractPlatformSpecific(${COMPONENT} ${ARCHIVE_UNIFIED} ${ARCHIVE_WIN} ${ARCHIVE_LIN} ${ARCHIVE_MAC} ${TARGET_PATH} result_path ${FOLDER})
|
||||
endif()
|
||||
|
||||
set (${VAR} ${result_path} PARENT_SCOPE)
|
||||
else()
|
||||
set (${VAR} $ENV{${ENVIRONMENT}} PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
endfunction(resolve_archive_dependency)
|
||||
|
||||
function(resolve_pull_request GITHUB_PULL_REQUEST TARGET_PATH)
|
||||
get_filename_component(FILE_NAME ${GITHUB_PULL_REQUEST} NAME)
|
||||
set (PATCH_URL "")
|
||||
DownloadAndApply("${PATCH_URL}/${GITHUB_PULL_REQUEST}" "${IE_MAIN_SOURCE_DIR}/${TARGET_PATH}/${FILE_NAME}")
|
||||
endfunction(resolve_pull_request)
|
||||
|
||||
function(extract_version_from_filename filename regex version)
|
||||
string(REGEX MATCH ${regex} match ${filename})
|
||||
|
||||
if (CMAKE_MATCH_1)
|
||||
set(${version} ${CMAKE_MATCH_1} PARENT_SCOPE)
|
||||
else()
|
||||
set(${version} ${filename} PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction(extract_version_from_filename)
|
||||
|
||||
function(read_version archive regex version_var)
|
||||
extract_version_from_filename(${archive} ${regex} version)
|
||||
set(${version_var} "${version}" CACHE INTERNAL "" FORCE)
|
||||
debug_message(STATUS "${version_var} = " ${version})
|
||||
endfunction(read_version)
|
||||
|
||||
function (RESOLVE_DEPENDENCY NAME_OF_CMAKE_VAR)
|
||||
|
||||
list(REMOVE_AT ARGV 0)
|
||||
set(SUPPORTED_ARGS FOLDER ARCHIVE ARCHIVE_UNIFIED ARCHIVE_WIN ARCHIVE_LIN ARCHIVE_MAC TARGET_PATH ENVIRONMENT GITHUB_PULL_REQUEST VERSION_REGEX)
|
||||
|
||||
|
||||
#unnecessary vars
|
||||
foreach(arg ${ARGV})
|
||||
#message("one_arg=" ${one_arg})
|
||||
#message("arg=" ${arg})
|
||||
#parse no arg vars
|
||||
if (";${SUPPORTED_ARGS};" MATCHES ";${arg};")
|
||||
if(DEFINED one_arg)
|
||||
set(${one_arg} TRUE)
|
||||
endif()
|
||||
set (one_arg ${arg})
|
||||
elseif(DEFINED one_arg)
|
||||
set(${one_arg} ${arg})
|
||||
unset(one_arg)
|
||||
else()
|
||||
message(FATAL_ERROR "invalid argument passed to resolve dependency: " ${arg})
|
||||
endif()
|
||||
endforeach(arg)
|
||||
|
||||
#if last token was bool
|
||||
if(DEFINED one_arg)
|
||||
set(${one_arg} TRUE)
|
||||
endif()
|
||||
|
||||
|
||||
if (NOT DEFINED ARCHIVE)
|
||||
SET(ARCHIVE "OFF")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED ARCHIVE_UNIFIED)
|
||||
SET(ARCHIVE_UNIFIED "OFF")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED ARCHIVE_WIN)
|
||||
SET(ARCHIVE_WIN "OFF")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED ARCHIVE_LIN)
|
||||
SET(ARCHIVE_LIN "OFF")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED ARCHIVE_MAC)
|
||||
SET(ARCHIVE_MAC "OFF")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED ENVIRONMENT)
|
||||
set (ENVIRONMENT "OFF")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED FOLDER)
|
||||
set (FOLDER FALSE)
|
||||
endif()
|
||||
|
||||
#for each dependency type have to do separate things
|
||||
if (ARCHIVE_WIN OR ARCHIVE_LIN OR ARCHIVE_MAC OR ARCHIVE OR ARCHIVE_UNIFIED)
|
||||
if (NOT DEFINED TARGET_PATH)
|
||||
message(FATAL_ERROR "TARGET_PATH should be defined for every dependency")
|
||||
endif()
|
||||
|
||||
resolve_archive_dependency(RESULT ${NAME_OF_CMAKE_VAR} ${ARCHIVE} ${ARCHIVE_UNIFIED} ${ARCHIVE_WIN} ${ARCHIVE_LIN} ${ARCHIVE_MAC} ${TARGET_PATH} ${FOLDER} ${ENVIRONMENT})
|
||||
set(${NAME_OF_CMAKE_VAR} ${RESULT} PARENT_SCOPE)
|
||||
if (VERSION_REGEX)
|
||||
GetNameAndUrlToDownload(archive RELATIVE_URL ${ARCHIVE_UNIFIED} ${ARCHIVE_WIN} ${ARCHIVE_LIN} ${ARCHIVE_MAC})
|
||||
if (archive)
|
||||
read_version(${archive} ${VERSION_REGEX} "${NAME_OF_CMAKE_VAR}_VERSION")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
elseif (DEFINED GITHUB_PULL_REQUEST)
|
||||
resolve_pull_request(${GITHUB_PULL_REQUEST} ${TARGET_PATH})
|
||||
else()
|
||||
message(FATAL_ERROR "Dependency of unknowntype, SHOULD set one of ARCHIVE_WIN, ARCHIVE, ARCHIVE_LIN, ARCHIVE_MAC, GITHUB_PULL_REQUEST")
|
||||
endif()
|
||||
|
||||
endfunction(RESOLVE_DEPENDENCY)
|
||||
60
inference-engine/cmake/developer_package_config.cmake.in
Normal file
60
inference-engine/cmake/developer_package_config.cmake.in
Normal file
@@ -0,0 +1,60 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
set(OpenVINO_MAIN_SOURCE_DIR "@OpenVINO_SOURCE_DIR@")
|
||||
set(IE_MAIN_SOURCE_DIR "@InferenceEngine_SOURCE_DIR@")
|
||||
|
||||
file(TO_CMAKE_PATH "${CMAKE_CURRENT_LIST_DIR}" cache_path)
|
||||
|
||||
# Variables to export in plugin's projects
|
||||
|
||||
set(ie_options "@IE_OPTIONS@;CMAKE_BUILD_TYPE;CMAKE_SKIP_RPATH")
|
||||
|
||||
load_cache("${cache_path}" READ_WITH_PREFIX "" ${ie_options})
|
||||
|
||||
message(STATUS "The following CMake options are exported from Inference Engine Developer package")
|
||||
message("")
|
||||
foreach(option IN LISTS ie_options)
|
||||
message(" ${option}: ${${option}}")
|
||||
endforeach()
|
||||
message("")
|
||||
|
||||
set(gflags_DIR "@gflags_BINARY_DIR@")
|
||||
|
||||
# Targets
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/targets_developer.cmake")
|
||||
# to allow too create ALIAS for IE::inference_engine in 3rd-party projects
|
||||
set_property(TARGET IE::inference_engine PROPERTY IMPORTED_GLOBAL TRUE)
|
||||
|
||||
get_target_property(InferenceEngine_INCLUDE_DIRS IE::inference_engine INTERFACE_INCLUDE_DIRECTORIES)
|
||||
set(InferenceEngine_LIBRARIES IE::inference_engine_legacy IE::inference_engine IE::inference_engine_nn_builder)
|
||||
|
||||
#
|
||||
# Common cmake includes
|
||||
#
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${OpenVINO_MAIN_SOURCE_DIR}/cmake")
|
||||
list(APPEND CMAKE_MODULE_PATH "${IE_MAIN_SOURCE_DIR}/cmake")
|
||||
|
||||
# generic stuff from developer package
|
||||
include(developer_package NO_POLICY_SCOPE)
|
||||
include(developer_package_ie)
|
||||
|
||||
# Don't threat deprecated API warnings as errors in 3rd party apps
|
||||
ie_deprecated_no_errors()
|
||||
|
||||
# inherit OpenCV from main IE project if enabled
|
||||
if (ENABLE_OPENCV)
|
||||
load_cache("${cache_path}" READ_WITH_PREFIX "" OpenCV_DIR)
|
||||
find_package(OpenCV)
|
||||
endif()
|
||||
|
||||
# inherit TBB from main IE project if enabled
|
||||
if (THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO")
|
||||
load_cache("${cache_path}" READ_WITH_PREFIX "" TBB_DIR)
|
||||
find_package(TBB)
|
||||
endif()
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
15
inference-engine/cmake/developer_package_ie.cmake
Normal file
15
inference-engine/cmake/developer_package_ie.cmake
Normal file
@@ -0,0 +1,15 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
include(cpplint)
|
||||
include(clang_format)
|
||||
|
||||
if(ENABLE_PROFILING_ITT)
|
||||
find_package(ITT REQUIRED)
|
||||
endif()
|
||||
|
||||
set(TBB_FIND_RELEASE_ONLY ${ENABLE_TBB_RELEASE_ONLY})
|
||||
|
||||
include(plugins/plugins)
|
||||
include(add_ie_target)
|
||||
@@ -1,119 +0,0 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
include (options)
|
||||
|
||||
#this options are aimed to optimize build time on development system
|
||||
|
||||
#backed targets
|
||||
|
||||
ie_option (ENABLE_GNA "GNA support for inference engine" ON)
|
||||
|
||||
ie_option (ENABLE_MKL_DNN "MKL-DNN plugin for inference engine" ON)
|
||||
|
||||
ie_option (ENABLE_CLDNN "clDnn based plugin for inference engine" ON)
|
||||
|
||||
ie_option (ENABLE_PROFILING_ITT "ITT tracing of IE and plugins internals" ON)
|
||||
|
||||
ie_option (ENABLE_PROFILING_RAW "Raw counters profiling (just values, no start/stop time or timeline)" OFF)
|
||||
|
||||
# "MKL-DNN library might use MKL-ML or OpenBLAS for gemm tasks: MKL|OPENBLAS|JIT"
|
||||
if (NOT GEMM STREQUAL "MKL"
|
||||
AND NOT GEMM STREQUAL "OPENBLAS"
|
||||
AND NOT GEMM STREQUAL "JIT")
|
||||
set (GEMM "JIT")
|
||||
message(STATUS "GEMM should be set to MKL, OPENBLAS or JIT. Default option is " ${GEMM})
|
||||
endif()
|
||||
set(GEMM "${GEMM}" CACHE STRING "Gemm implementation" FORCE)
|
||||
list (APPEND IE_OPTIONS GEMM)
|
||||
|
||||
# "MKL-DNN library based on OMP or TBB or Sequential implementation: TBB|OMP|SEQ"
|
||||
if (NOT THREADING STREQUAL "TBB"
|
||||
AND NOT THREADING STREQUAL "OMP"
|
||||
AND NOT THREADING STREQUAL "SEQ")
|
||||
set (THREADING "TBB")
|
||||
message(STATUS "THREADING should be set to TBB, OMP or SEQ. Default option is " ${THREADING})
|
||||
endif()
|
||||
set(THREADING "${THREADING}" CACHE STRING "Threading" FORCE)
|
||||
list (APPEND IE_OPTIONS THREADING)
|
||||
|
||||
# Enable postfixes for Debug/Release builds
|
||||
set (IE_DEBUG_POSTFIX_WIN "d")
|
||||
set (IE_RELEASE_POSTFIX_WIN "")
|
||||
set (IE_DEBUG_POSTFIX_LIN "")
|
||||
set (IE_RELEASE_POSTFIX_LIN "")
|
||||
set (IE_DEBUG_POSTFIX_MAC "d")
|
||||
set (IE_RELEASE_POSTFIX_MAC "")
|
||||
|
||||
if (WIN32)
|
||||
set (IE_DEBUG_POSTFIX ${IE_DEBUG_POSTFIX_WIN})
|
||||
set (IE_RELEASE_POSTFIX ${IE_RELEASE_POSTFIX_WIN})
|
||||
elseif(APPLE)
|
||||
set (IE_DEBUG_POSTFIX ${IE_DEBUG_POSTFIX_MAC})
|
||||
set (IE_RELEASE_POSTFIX ${IE_RELEASE_POSTFIX_MAC})
|
||||
else()
|
||||
set (IE_DEBUG_POSTFIX ${IE_DEBUG_POSTFIX_LIN})
|
||||
set (IE_RELEASE_POSTFIX ${IE_RELEASE_POSTFIX_LIN})
|
||||
endif()
|
||||
set(IE_DEBUG_POSTFIX "${IE_DEBUG_POSTFIX}" CACHE STRING "Debug postfix" FORCE)
|
||||
list (APPEND IE_OPTIONS IE_DEBUG_POSTFIX)
|
||||
set(IE_RELEASE_POSTFIX "${IE_RELEASE_POSTFIX}" CACHE STRING "Release postfix" FORCE)
|
||||
list (APPEND IE_OPTIONS IE_RELEASE_POSTFIX)
|
||||
|
||||
ie_option (ENABLE_VPU "vpu targeted plugins for inference engine" ON)
|
||||
|
||||
ie_option (ENABLE_MYRIAD "myriad targeted plugin for inference engine" ON)
|
||||
|
||||
ie_option (ENABLE_MYX_PCIE "myriad plugin with support PCIE device" OFF)
|
||||
|
||||
ie_option (ENABLE_MYRIAD_NO_BOOT "myriad plugin will skip device boot" OFF)
|
||||
|
||||
ie_option (ENABLE_TESTS "unit and functional tests" OFF)
|
||||
|
||||
ie_option (ENABLE_GAPI_TESTS "unit tests for GAPI kernels" OFF)
|
||||
|
||||
ie_option (GAPI_TEST_PERF "if GAPI unit tests should examine performance" OFF)
|
||||
|
||||
ie_option (ENABLE_SAMPLES "console samples are part of inference engine package" ON)
|
||||
|
||||
ie_option (ENABLE_SAMPLES_CORE "console samples core library" ON)
|
||||
|
||||
ie_option (ENABLE_SANITIZER "enable checking memory errors via AddressSanitizer" OFF)
|
||||
|
||||
ie_option (COVERAGE "enable code coverage" OFF)
|
||||
|
||||
ie_option (ENABLE_STRESS_UNIT_TESTS "stress unit tests" OFF)
|
||||
|
||||
ie_option (VERBOSE_BUILD "shows extra information about build" OFF)
|
||||
|
||||
ie_option (ENABLE_UNSAFE_LOCATIONS "skip check for MD5 for dependency" OFF)
|
||||
|
||||
ie_option (ENABLE_ALTERNATIVE_TEMP "in case of dependency conflict, to avoid modification in master, use local copy of dependency" ON)
|
||||
|
||||
ie_option (ENABLE_SEGMENTATION_TESTS "segmentation tests" ON)
|
||||
|
||||
ie_option (ENABLE_OBJECT_DETECTION_TESTS "object detection tests" ON)
|
||||
|
||||
ie_option (ENABLE_OPENCV "enables OpenCV" ON)
|
||||
|
||||
ie_option (OS_FOLDER "create OS dedicated folder in output" OFF)
|
||||
|
||||
ie_option (ENABLE_PLUGIN_RPATH "enables rpath information to be present in plugins binary, and in corresponding test_applications" ON)
|
||||
|
||||
ie_option (ENABLE_AFFINITY_GENERATOR "enables affinity generator build" OFF)
|
||||
|
||||
ie_option (ENABLE_DEBUG_SYMBOLS "generates symbols for debugging" OFF)
|
||||
|
||||
ie_option (ENABLE_PYTHON "enables ie python bridge build" OFF)
|
||||
|
||||
ie_option (TREAT_WARNING_AS_ERROR "Treat build warnings as errors" ON)
|
||||
|
||||
ie_option(ENABLE_CPPLINT "Enable cpplint checks during the build" OFF)
|
||||
ie_option(ENABLE_CPPLINT_REPORT "Build cpplint report instead of failing the build" OFF)
|
||||
|
||||
#environment variables used
|
||||
|
||||
#name of environment variable stored path to temp directory"
|
||||
set (DL_SDK_TEMP "DL_SDK_TEMP")
|
||||
114
inference-engine/cmake/features_ie.cmake
Normal file
114
inference-engine/cmake/features_ie.cmake
Normal file
@@ -0,0 +1,114 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
include (target_flags)
|
||||
include (options)
|
||||
|
||||
#these options are aimed to optimize build time on development system
|
||||
|
||||
ie_dependent_option (ENABLE_GNA "GNA support for inference engine" ON "NOT APPLE;NOT ANDROID;X86 OR X86_64" OFF)
|
||||
|
||||
ie_dependent_option (ENABLE_CLDNN_TESTS "Enable clDNN unit tests" OFF "ENABLE_CLDNN" OFF)
|
||||
|
||||
ie_dependent_option (ENABLE_PROFILING_ITT "ITT tracing of IE and plugins internals" ON "NOT CMAKE_CROSSCOMPILING" OFF)
|
||||
|
||||
# "MKL-DNN library might use MKL-ML or OpenBLAS for gemm tasks: MKL|OPENBLAS|JIT"
|
||||
if (ENABLE_MKL_DNN)
|
||||
if(AARCH64)
|
||||
set(GEMM_DEFAULT "OPENBLAS")
|
||||
else()
|
||||
set(GEMM_DEFAULT "JIT")
|
||||
endif()
|
||||
set(GEMM "${GEMM_DEFAULT}" CACHE STRING "GEMM implementation")
|
||||
set_property(CACHE GEMM PROPERTY STRINGS "MKL" "OPENBLAS" "JIT")
|
||||
list (APPEND IE_OPTIONS GEMM)
|
||||
if (NOT GEMM STREQUAL "MKL" AND
|
||||
NOT GEMM STREQUAL "OPENBLAS" AND
|
||||
NOT GEMM STREQUAL "JIT")
|
||||
message(FATAL_ERROR "GEMM should be set to MKL, OPENBLAS or JIT. Default option is ${GEMM_DEFAULT}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# "MKL-DNN library based on OMP or TBB or Sequential implementation: TBB|OMP|SEQ"
|
||||
if(ARM)
|
||||
set(THREADING_DEFAULT "SEQ")
|
||||
else()
|
||||
set(THREADING_DEFAULT "TBB")
|
||||
endif()
|
||||
set(THREADING "${THREADING_DEFAULT}" CACHE STRING "Threading")
|
||||
set_property(CACHE THREADING PROPERTY STRINGS "TBB" "TBB_AUTO" "OMP" "SEQ")
|
||||
list (APPEND IE_OPTIONS THREADING)
|
||||
if (NOT THREADING STREQUAL "TBB" AND
|
||||
NOT THREADING STREQUAL "TBB_AUTO" AND
|
||||
NOT THREADING STREQUAL "OMP" AND
|
||||
NOT THREADING STREQUAL "SEQ")
|
||||
message(FATAL_ERROR "THREADING should be set to TBB, TBB_AUTO, OMP or SEQ. Default option is ${THREADING_DEFAULT}")
|
||||
endif()
|
||||
|
||||
if (ENABLE_GNA)
|
||||
if (UNIX AND NOT APPLE AND CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.4)
|
||||
set (DEFAULT_GNA_LIB GNA1)
|
||||
else()
|
||||
set (DEFAULT_GNA_LIB GNA1_1401)
|
||||
endif()
|
||||
set(GNA_LIBRARY_VERSION "${DEFAULT_GNA_LIB}" CACHE STRING "GNAVersion")
|
||||
set_property(CACHE GNA_LIBRARY_VERSION PROPERTY STRINGS "GNA1" "GNA1_1401" "GNA2")
|
||||
list (APPEND IE_OPTIONS GNA_LIBRARY_VERSION)
|
||||
if (NOT GNA_LIBRARY_VERSION STREQUAL "GNA1" AND
|
||||
NOT GNA_LIBRARY_VERSION STREQUAL "GNA1_1401" AND
|
||||
NOT GNA_LIBRARY_VERSION STREQUAL "GNA2")
|
||||
message(FATAL_ERROR "GNA_LIBRARY_VERSION should be set to GNA1, GNA1_1401 or GNA2. Default option is ${DEFAULT_GNA_LIB}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
ie_option (ENABLE_IR_READER "Compile with IR readers / parsers" ON)
|
||||
|
||||
ie_option (ENABLE_VPU "vpu targeted plugins for inference engine" ON)
|
||||
|
||||
ie_dependent_option (ENABLE_MYRIAD "myriad targeted plugin for inference engine" ON "ENABLE_VPU" OFF)
|
||||
|
||||
ie_dependent_option (ENABLE_MYRIAD_NO_BOOT "myriad plugin will skip device boot" OFF "ENABLE_MYRIAD" OFF)
|
||||
|
||||
ie_option (ENABLE_TESTS "unit, behavior and functional tests" OFF)
|
||||
|
||||
ie_dependent_option (ENABLE_GAPI_TESTS "tests for GAPI kernels" OFF "ENABLE_TESTS" OFF)
|
||||
|
||||
ie_dependent_option (GAPI_TEST_PERF "if GAPI unit tests should examine performance" OFF "ENABLE_GAPI_TESTS" OFF)
|
||||
|
||||
ie_dependent_option (ENABLE_MYRIAD_MVNC_TESTS "functional and behavior tests for mvnc api" OFF "ENABLE_TESTS;ENABLE_MYRIAD" OFF)
|
||||
|
||||
ie_dependent_option (ENABLE_SAMPLES "console samples are part of inference engine package" ON "NOT MINGW" OFF)
|
||||
|
||||
ie_dependent_option (ENABLE_BEH_TESTS "tests oriented to check inference engine API corecteness" ON "ENABLE_TESTS" OFF)
|
||||
|
||||
ie_dependent_option (ENABLE_FUNCTIONAL_TESTS "functional tests" ON "ENABLE_TESTS;ENABLE_IR_READER" OFF)
|
||||
|
||||
ie_dependent_option (ENABLE_SAMPLES "console samples are part of inference engine package" ON "NOT MINGW" OFF)
|
||||
|
||||
ie_option (ENABLE_FUZZING "instrument build for fuzzing" OFF)
|
||||
|
||||
ie_option (VERBOSE_BUILD "shows extra information about build" OFF)
|
||||
|
||||
ie_option (ENABLE_UNSAFE_LOCATIONS "skip check for MD5 for dependency" OFF)
|
||||
|
||||
ie_option (ENABLE_ALTERNATIVE_TEMP "in case of dependency conflict, to avoid modification in master, use local copy of dependency" ON)
|
||||
|
||||
ie_option (ENABLE_OPENCV "enables OpenCV" ON)
|
||||
|
||||
ie_option (ENABLE_DEBUG_SYMBOLS "generates symbols for debugging" OFF)
|
||||
|
||||
ie_option (ENABLE_PYTHON "enables ie python bridge build" OFF)
|
||||
|
||||
ie_option (ENABLE_CPP_CCT "enables C++ version of Cross Check Tool" OFF)
|
||||
|
||||
ie_option (ENABLE_C "enables ie c bridge build" ON)
|
||||
|
||||
ie_dependent_option(ENABLE_CPPLINT "Enable cpplint checks during the build" OFF "OFF;UNIX;NOT APPLE;NOT ANDROID" OFF)
|
||||
ie_dependent_option(ENABLE_CPPLINT_REPORT "Build cpplint report instead of failing the build" OFF "ENABLE_CPPLINT" OFF)
|
||||
|
||||
ie_option(ENABLE_CLANG_FORMAT "Enable clang-format checks during the build" OFF)
|
||||
|
||||
set(IE_EXTRA_PLUGINS "" CACHE STRING "Extra paths for plugins to include into DLDT build tree")
|
||||
|
||||
ie_dependent_option(ENABLE_TBB_RELEASE_ONLY "Only Release TBB libraries are linked to the Inference Engine binaries" ON "THREADING MATCHES TBB;LINUX" OFF)
|
||||
30
inference-engine/cmake/fuzzing.cmake
Normal file
30
inference-engine/cmake/fuzzing.cmake
Normal file
@@ -0,0 +1,30 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
function(enable_fuzzing)
|
||||
# Enable (libFuzzer)[https://llvm.org/docs/LibFuzzer.html] if supported.
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT WIN32)
|
||||
# Communicate libfuzzer is enabled
|
||||
set(WITH_LIBFUZZER ON PARENT_SCOPE)
|
||||
add_compile_definitions(WITH_LIBFUZZER)
|
||||
|
||||
# Enable libfuzzer and code coverage
|
||||
set(FUZZING_COMPILER_FLAGS "-fsanitize=fuzzer-no-link -fprofile-instr-generate -fcoverage-mapping")
|
||||
set(FUZZING_LINKER_FLAGS "-fsanitize-coverage=trace-pc-guard -fprofile-instr-generate")
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FUZZING_COMPILER_FLAGS}" PARENT_SCOPE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FUZZING_COMPILER_FLAGS}" PARENT_SCOPE)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${FUZZING_LINKER_FLAGS}" PARENT_SCOPE)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FUZZING_LINKER_FLAGS}")
|
||||
endif()
|
||||
endfunction(enable_fuzzing)
|
||||
|
||||
|
||||
function(add_fuzzer FUZZER_EXE_NAME FUZZER_SOURCES)
|
||||
add_executable(${FUZZER_EXE_NAME} ${FUZZER_SOURCES})
|
||||
if(WITH_LIBFUZZER)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=fuzzer" PARENT_SCOPE)
|
||||
endif()
|
||||
target_link_libraries(${FUZZER_EXE_NAME} PRIVATE fuzz-testhelper)
|
||||
endfunction(add_fuzzer)
|
||||
@@ -1,51 +1,73 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
if (THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO")
|
||||
find_package(TBB COMPONENTS tbb tbbmalloc)
|
||||
if (TBB_FOUND)
|
||||
if (${TBB_VERSION} VERSION_LESS 2020)
|
||||
ext_message(WARNING "TBB version is less than OpenVINO recommends to use.\
|
||||
Some TBB related features like NUMA-aware tbb::task_arena\
|
||||
execution will be disabled.")
|
||||
endif()
|
||||
else ()
|
||||
ext_message(WARNING "TBB was not found by the configured TBB_DIR/TBBROOT path. \
|
||||
SEQ method will be used.")
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
function(set_ie_threading_interface_for TARGET_NAME)
|
||||
get_target_property(target_type ${TARGET_NAME} TYPE)
|
||||
if(target_type STREQUAL "INTERFACE_LIBRARY")
|
||||
set(LINK_TYPE "INTERFACE")
|
||||
else()
|
||||
set(LINK_TYPE "PUBLIC")
|
||||
endif()
|
||||
|
||||
function(ie_target_link_libraries TARGET_NAME LINK_TYPE)
|
||||
if(CMAKE_VERSION VERSION_LESS "3.12.0")
|
||||
if(NOT target_type STREQUAL "OBJECT_LIBRARY")
|
||||
target_link_libraries(${TARGET_NAME} ${LINK_TYPE} ${ARGN})
|
||||
else()
|
||||
# Object library may not link to anything.
|
||||
# To add interface include directories and compile options explicitly.
|
||||
foreach(ITEM IN LISTS ARGN)
|
||||
if(TARGET ${ITEM})
|
||||
get_target_property(compile_options ${ITEM} INTERFACE_COMPILE_OPTIONS)
|
||||
if (compile_options)
|
||||
target_compile_options(${TARGET_NAME} ${LINK_TYPE} ${compile_options})
|
||||
endif()
|
||||
get_target_property(compile_definitions ${ITEM} INTERFACE_COMPILE_DEFINITIONS)
|
||||
if (compile_options)
|
||||
target_compile_definitions(${TARGET_NAME} ${LINK_TYPE} ${compile_definitions})
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
else()
|
||||
target_link_libraries(${TARGET_NAME} ${LINK_TYPE} ${ARGN})
|
||||
endif()
|
||||
|
||||
# include directories as SYSTEM
|
||||
foreach(library IN LISTS ARGN)
|
||||
if(TARGET ${library})
|
||||
get_target_property(include_directories ${library} INTERFACE_INCLUDE_DIRECTORIES)
|
||||
if(include_directories)
|
||||
target_include_directories(${TARGET_NAME} SYSTEM BEFORE ${LINK_TYPE} ${include_directories})
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
set(IE_THREAD_DEFINE "IE_THREAD_SEQ")
|
||||
|
||||
if (THREADING STREQUAL "TBB")
|
||||
if (NOT (IE_MAIN_SOURCE_DIR))
|
||||
set(incl_path ${IE_EXTERNAL_DIR}/tbb/include)
|
||||
if (WIN32)
|
||||
set(lib_rel_path ${IE_LIB_REL_DIR})
|
||||
set(lib_dbg_path ${IE_LIB_DBG_DIR})
|
||||
else ()
|
||||
set(lib_rel_path ${IE_EXTERNAL_DIR}/tbb/lib)
|
||||
set(lib_dbg_path ${lib_rel_path})
|
||||
endif ()
|
||||
else ()
|
||||
set(incl_path ${TBB}/include)
|
||||
set(lib_rel_path ${TBB}/lib)
|
||||
set(lib_dbg_path ${lib_rel_path})
|
||||
endif ()
|
||||
|
||||
if (NOT TBB_INCLUDE_DIRS OR NOT TBB_LIBRARIES_RELEASE OR NOT TBB_LIBRARIES_DEBUG)
|
||||
find_path(TBB_INCLUDE_DIRS tbb/tbb.h ${incl_path} NO_DEFAULT_PATH)
|
||||
find_library(TBB_LIBRARIES_RELEASE tbb ${lib_rel_path} NO_DEFAULT_PATH)
|
||||
find_library(TBB_LIBRARIES_DEBUG tbb_debug ${lib_dbg_path} NO_DEFAULT_PATH)
|
||||
ext_message(STATUS "TBB include: ${TBB_INCLUDE_DIRS}")
|
||||
ext_message(STATUS "TBB Release lib: ${TBB_LIBRARIES_RELEASE}")
|
||||
ext_message(STATUS "TBB Debug lib: ${TBB_LIBRARIES_DEBUG}")
|
||||
endif ()
|
||||
|
||||
if (NOT TBB_INCLUDE_DIRS OR NOT TBB_LIBRARIES_RELEASE OR NOT TBB_LIBRARIES_DEBUG)
|
||||
ext_message(WARNING "TBB not found. TBB support will be disabled. ${IE_THREAD_DEFINE} is defined")
|
||||
else ()
|
||||
if (THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO")
|
||||
if (TBB_FOUND)
|
||||
set(IE_THREAD_DEFINE "IE_THREAD_TBB")
|
||||
target_include_directories(${TARGET_NAME} PUBLIC ${TBB_INCLUDE_DIRS})
|
||||
if (WIN32)
|
||||
target_link_libraries(${TARGET_NAME} PUBLIC "-nodefaultlib:vcomp")
|
||||
target_link_libraries(${TARGET_NAME} PUBLIC "$<$<CONFIG:DEBUG>:${TBB_LIBRARIES_DEBUG}>;$<$<NOT:$<CONFIG:DEBUG>>:${TBB_LIBRARIES_RELEASE}>")
|
||||
else()
|
||||
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||
target_link_libraries(${TARGET_NAME} PUBLIC ${TBB_LIBRARIES_DEBUG})
|
||||
else()
|
||||
target_link_libraries(${TARGET_NAME} PUBLIC ${TBB_LIBRARIES_RELEASE})
|
||||
endif ()
|
||||
endif ()
|
||||
ie_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} ${TBB_IMPORTED_TARGETS})
|
||||
else ()
|
||||
ext_message(WARNING "TBB was not found by the configured TBB_DIR path. \
|
||||
SEQ method will be used for ${TARGET_NAME}")
|
||||
endif ()
|
||||
elseif (THREADING STREQUAL "OMP")
|
||||
if (WIN32)
|
||||
@@ -67,40 +89,55 @@ function(set_ie_threading_interface_for TARGET_NAME)
|
||||
set(lib_dbg_path ${lib_rel_path})
|
||||
endif ()
|
||||
|
||||
if (NOT OMP_LIBRARIES_RELEASE OR NOT OMP_LIBRARIES_DEBUG)
|
||||
if (NOT OMP_LIBRARIES_RELEASE)
|
||||
find_library(OMP_LIBRARIES_RELEASE ${omp_lib_name} ${lib_rel_path} NO_DEFAULT_PATH)
|
||||
find_library(OMP_LIBRARIES_DEBUG ${omp_lib_name} ${lib_dbg_path} NO_DEFAULT_PATH)
|
||||
ext_message(STATUS "OMP Release lib: ${OMP_LIBRARIES_RELEASE}")
|
||||
ext_message(STATUS "OMP Debug lib: ${OMP_LIBRARIES_DEBUG}")
|
||||
if (NOT LINUX)
|
||||
find_library(OMP_LIBRARIES_DEBUG ${omp_lib_name} ${lib_dbg_path} NO_DEFAULT_PATH)
|
||||
if (OMP_LIBRARIES_DEBUG)
|
||||
ext_message(STATUS "OMP Debug lib: ${OMP_LIBRARIES_DEBUG}")
|
||||
else ()
|
||||
ext_message(WARNING "OMP Debug binaries are missed.")
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (NOT OMP_LIBRARIES_RELEASE OR NOT OMP_LIBRARIES_DEBUG)
|
||||
if (NOT OMP_LIBRARIES_RELEASE)
|
||||
ext_message(WARNING "Intel OpenMP not found. Intel OpenMP support will be disabled. ${IE_THREAD_DEFINE} is defined")
|
||||
else ()
|
||||
set(IE_THREAD_DEFINE "IE_THREAD_OMP")
|
||||
|
||||
if (WIN32)
|
||||
target_compile_options(${TARGET_NAME} PUBLIC ${OpenMP_CXX_FLAGS} /openmp)
|
||||
target_compile_options(${TARGET_NAME} PUBLIC ${OpenMP_CXX_FLAGS} /Qopenmp)
|
||||
|
||||
target_link_libraries(${TARGET_NAME} PUBLIC "-nodefaultlib:vcomp")
|
||||
target_link_libraries(${TARGET_NAME} PUBLIC "$<$<CONFIG:DEBUG>:${OMP_LIBRARIES_DEBUG}>;$<$<NOT:$<CONFIG:DEBUG>>:${OMP_LIBRARIES_RELEASE}>")
|
||||
if (WIN32)
|
||||
target_compile_options(${TARGET_NAME} ${LINK_TYPE} ${OpenMP_CXX_FLAGS} /openmp)
|
||||
target_compile_options(${TARGET_NAME} ${LINK_TYPE} ${OpenMP_CXX_FLAGS} /Qopenmp)
|
||||
ie_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} "-nodefaultlib:vcomp")
|
||||
else()
|
||||
target_compile_options(${TARGET_NAME} PUBLIC ${OpenMP_CXX_FLAGS} -fopenmp)
|
||||
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||
target_link_libraries(${TARGET_NAME} PUBLIC ${OMP_LIBRARIES_DEBUG})
|
||||
target_compile_options(${TARGET_NAME} ${LINK_TYPE} ${OpenMP_CXX_FLAGS} -fopenmp)
|
||||
endif ()
|
||||
|
||||
# Debug binaries are optional.
|
||||
if (OMP_LIBRARIES_DEBUG AND NOT LINUX)
|
||||
if (WIN32)
|
||||
ie_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} "$<$<CONFIG:DEBUG>:${OMP_LIBRARIES_DEBUG}>;$<$<NOT:$<CONFIG:DEBUG>>:${OMP_LIBRARIES_RELEASE}>")
|
||||
else()
|
||||
target_link_libraries(${TARGET_NAME} PUBLIC ${OMP_LIBRARIES_RELEASE})
|
||||
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||
ie_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} ${OMP_LIBRARIES_DEBUG})
|
||||
else()
|
||||
ie_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} ${OMP_LIBRARIES_RELEASE})
|
||||
endif ()
|
||||
endif ()
|
||||
else ()
|
||||
# Link Release library to all configurations.
|
||||
ie_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} ${OMP_LIBRARIES_RELEASE})
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
endif ()
|
||||
|
||||
target_compile_definitions(${TARGET_NAME} PUBLIC -DIE_THREAD=${IE_THREAD_DEFINE})
|
||||
target_compile_definitions(${TARGET_NAME} ${LINK_TYPE} -DIE_THREAD=${IE_THREAD_DEFINE})
|
||||
|
||||
if (NOT THREADING STREQUAL "SEQ")
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(${TARGET_NAME} PUBLIC ${CMAKE_THREAD_LIBS_INIT})
|
||||
ie_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif()
|
||||
endfunction(set_ie_threading_interface_for)
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
unset(ITT_INCLUDE_DIR CACHE)
|
||||
unset(ITT_LIB CACHE)
|
||||
|
||||
if(NOT DEFINED INTEL_VTUNE_DIR AND DEFINED ENV{INTEL_VTUNE_DIR})
|
||||
set(INTEL_VTUNE_DIR "$ENV{INTEL_VTUNE_DIR}")
|
||||
endif()
|
||||
if(NOT DEFINED INTEL_VTUNE_DIR)
|
||||
if(EXISTS "/opt/intel/vtune_amplifier_xe/include")
|
||||
set(INTEL_VTUNE_DIR "/opt/intel/vtune_amplifier_xe")
|
||||
elseif(EXISTS "/opt/intel/vtune_amplifier/include")
|
||||
set(INTEL_VTUNE_DIR "/opt/intel/vtune_amplifier")
|
||||
elseif (EXISTS "C:/Program Files (x86)/IntelSWTools/VTune Amplifier XE")
|
||||
set(INTEL_VTUNE_DIR "C:/Program Files (x86)/IntelSWTools/VTune Amplifier XE")
|
||||
elseif (EXISTS "C:/Program Files (x86)/IntelSWTools/VTune Amplifier")
|
||||
set(INTEL_VTUNE_DIR "C:/Program Files (x86)/IntelSWTools/VTune Amplifier")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(DEFINED INTEL_VTUNE_DIR)
|
||||
message(STATUS "INTEL_VTUNE_DIR = ${INTEL_VTUNE_DIR}")
|
||||
|
||||
find_path(ITT_INCLUDE_DIR
|
||||
FILES
|
||||
ittnotify.h
|
||||
PATHS "${INTEL_VTUNE_DIR}/include/")
|
||||
|
||||
find_library(ITT_LIB
|
||||
"libittnotify${CMAKE_STATIC_LIBRARY_SUFFIX}"
|
||||
PATHS ${INTEL_VTUNE_DIR}/lib64)
|
||||
|
||||
set(Located_ITT_LIBS ${ITT_LIB} ${CMAKE_DL_LIBS})
|
||||
set(Located_ITT_INCLUDE_DIRS ${ITT_INCLUDE_DIR})
|
||||
else()
|
||||
message(STATUS "INTEL_VTUNE_DIR is not defined")
|
||||
endif()
|
||||
|
||||
# Handle find_package() arguments, and set INTEL_ITT_FOUND
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(INTEL_ITT
|
||||
REQUIRED_VARS
|
||||
Located_ITT_INCLUDE_DIRS
|
||||
Located_ITT_LIBS)
|
||||
|
||||
if(ENABLE_PROFILING_ITT AND INTEL_ITT_FOUND)
|
||||
add_definitions(-DENABLE_PROFILING_ITT=1)
|
||||
|
||||
set(INTEL_ITT_LIBS ${Located_ITT_LIBS})
|
||||
set(INTEL_ITT_INCLUDE_DIRS ${Located_ITT_INCLUDE_DIRS})
|
||||
|
||||
message(STATUS "INTEL_ITT_INCLUDE_DIRS: ${INTEL_ITT_INCLUDE_DIRS}")
|
||||
include_directories(${INTEL_ITT_INCLUDE_DIRS})
|
||||
message(STATUS "INTEL_ITT_LIBS: ${INTEL_ITT_LIBS}")
|
||||
else()
|
||||
add_definitions(-DENABLE_PROFILING_ITT=0)
|
||||
message(STATUS "INTEL_ITT is disabled")
|
||||
endif()
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
if (UNIX)
|
||||
if (LINUX)
|
||||
function(get_linux_name res_var)
|
||||
if (NOT EXISTS "/etc/lsb-release")
|
||||
execute_process(COMMAND find -L /etc/ -maxdepth 1 -type f -name *-release -exec cat {} \;
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
option(DEVELOPMENT_PLUGIN_MODE "Disabled build of all plugins" OFF)
|
||||
@@ -1,21 +0,0 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Usage: ie_option(<option_variable> "description" <initial value or boolean expression> [IF <condition>])
|
||||
|
||||
function (ie_option variable description value)
|
||||
option(${variable} "${description}" ${value})
|
||||
list (APPEND IE_OPTIONS "${variable}")
|
||||
|
||||
set (IE_OPTIONS "${IE_OPTIONS}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
include(version)
|
||||
|
||||
function (print_enabled_features)
|
||||
message(STATUS "CI_BUILD_NUMBER: ${CI_BUILD_NUMBER}")
|
||||
foreach(_var ${IE_OPTIONS})
|
||||
message(STATUS "${_var} = ${${_var}}")
|
||||
endforeach()
|
||||
endfunction()
|
||||
@@ -1,42 +0,0 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
if (WIN32)
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS _CRT_SECURE_NO_WARNINGS)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SCL_SECURE_NO_WARNINGS")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") #no asynchronous structured exception handling
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
|
||||
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Z7")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Z7")
|
||||
|
||||
if(ENABLE_DEBUG_SYMBOLS)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Z7")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Z7")
|
||||
|
||||
set(DEBUG_SYMBOLS_LINKER_FLAGS "/DEBUG")
|
||||
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
|
||||
# Keep default /OPT values. See /DEBUG reference for details.
|
||||
set(DEBUG_SYMBOLS_LINKER_FLAGS "${DEBUG_SYMBOLS_LINKER_FLAGS} /OPT:REF /OPT:ICF")
|
||||
endif()
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${DEBUG_SYMBOLS_LINKER_FLAGS}")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${DEBUG_SYMBOLS_LINKER_FLAGS}")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${DEBUG_SYMBOLS_LINKER_FLAGS}")
|
||||
endif()
|
||||
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Werror=return-type ")
|
||||
if (APPLE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unused-command-line-argument")
|
||||
elseif(UNIX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wuninitialized -Winit-self")
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wmaybe-uninitialized")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
27
inference-engine/cmake/plugins/create_plugin_file.cmake
Normal file
27
inference-engine/cmake/plugins/create_plugin_file.cmake
Normal file
@@ -0,0 +1,27 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
set(newContent " <plugin name=\"${IE_DEVICE_NAME}\" location=\"${IE_PLUGIN_LIBRARY_NAME}\">")
|
||||
|
||||
if(IE_PLUGIN_PROPERTIES)
|
||||
set(newContent "${newContent}
|
||||
<properties>")
|
||||
|
||||
foreach(props IN LISTS IE_PLUGIN_PROPERTIES)
|
||||
string(REPLACE "," ";" props "${props}")
|
||||
|
||||
list(GET props 0 key)
|
||||
list(GET props 1 value)
|
||||
set(newContent "${newContent}
|
||||
<property key=\"${key}\" value=\"${value}\"/>")
|
||||
endforeach()
|
||||
|
||||
set(newContent "${newContent}
|
||||
</properties>")
|
||||
endif()
|
||||
|
||||
set(newContent "${newContent}
|
||||
</plugin>")
|
||||
|
||||
file(WRITE "${IE_CONFIG_OUTPUT_FILE}" "${newContent}")
|
||||
166
inference-engine/cmake/plugins/plugins.cmake
Normal file
166
inference-engine/cmake/plugins/plugins.cmake
Normal file
@@ -0,0 +1,166 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
include(CMakeParseArguments)
|
||||
|
||||
set(PLUGIN_FILES "" CACHE INTERNAL "")
|
||||
|
||||
function(get_shared_library_name target_name library_name)
|
||||
set(LIB_PREFIX "${CMAKE_SHARED_LIBRARY_PREFIX}")
|
||||
set(LIB_SUFFIX "${IE_BUILD_POSTFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||
|
||||
set("${library_name}" "${LIB_PREFIX}${target_name}${LIB_SUFFIX}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
if(NOT TARGET ie_plugins)
|
||||
add_custom_target(ie_plugins)
|
||||
endif()
|
||||
|
||||
#
|
||||
# ie_add_plugin(NAME <targetName>
|
||||
# DEVICE_NAME <deviceName>
|
||||
# SOURCES <sources>
|
||||
# OBJECT_LIBRARIES <object_libs>
|
||||
# VERSION_DEFINES_FOR <source>
|
||||
# SKIP_INSTALL
|
||||
# )
|
||||
#
|
||||
function(ie_add_plugin)
|
||||
set(options SKIP_INSTALL)
|
||||
set(oneValueArgs NAME DEVICE_NAME VERSION_DEFINES_FOR)
|
||||
set(multiValueArgs SOURCES OBJECT_LIBRARIES CPPLINT_FILTERS)
|
||||
cmake_parse_arguments(IE_PLUGIN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if(NOT IE_PLUGIN_NAME)
|
||||
message(FATAL_ERROR "Please, specify plugin target name")
|
||||
endif()
|
||||
|
||||
if(NOT IE_PLUGIN_DEVICE_NAME)
|
||||
message(FATAL_ERROR "Please, specify device name for ${IE_PLUGIN_NAME}")
|
||||
endif()
|
||||
|
||||
# create and configure target
|
||||
|
||||
if(IE_PLUGIN_VERSION_DEFINES_FOR)
|
||||
addVersionDefines(${IE_PLUGIN_VERSION_DEFINES_FOR} CI_BUILD_NUMBER)
|
||||
endif()
|
||||
|
||||
set(input_files ${IE_PLUGIN_SOURCES})
|
||||
foreach(obj_lib IN LISTS IE_PLUGIN_OBJECT_LIBRARIES)
|
||||
list(APPEND input_files $<TARGET_OBJECTS:${obj_lib}>)
|
||||
add_cpplint_target(${obj_lib}_cpplint FOR_TARGETS ${obj_lib})
|
||||
endforeach()
|
||||
|
||||
add_library(${IE_PLUGIN_NAME} SHARED ${input_files})
|
||||
target_compile_definitions(${IE_PLUGIN_NAME} PRIVATE IMPLEMENT_INFERENCE_ENGINE_PLUGIN)
|
||||
|
||||
if(TARGET IE::inference_engine_plugin_api)
|
||||
target_link_libraries(${IE_PLUGIN_NAME} PRIVATE IE::inference_engine_plugin_api)
|
||||
else()
|
||||
target_link_libraries(${IE_PLUGIN_NAME} PRIVATE inference_engine_plugin_api)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set_target_properties(${IE_PLUGIN_NAME} PROPERTIES COMPILE_PDB_NAME ${TARGET_NAME})
|
||||
endif()
|
||||
|
||||
set(custom_filter "")
|
||||
foreach(filter IN LISTS IE_PLUGIN_CPPLINT_FILTERS)
|
||||
string(CONCAT custom_filter "${custom_filter}" "," "${filter}")
|
||||
endforeach()
|
||||
|
||||
add_cpplint_target(${IE_PLUGIN_NAME}_cpplint FOR_TARGETS ${IE_PLUGIN_NAME} CUSTOM_FILTERS ${custom_filter})
|
||||
|
||||
# append plugin to the list to register
|
||||
|
||||
list(APPEND PLUGIN_FILES "${IE_PLUGIN_DEVICE_NAME}:${IE_PLUGIN_NAME}")
|
||||
list(REMOVE_DUPLICATES PLUGIN_FILES)
|
||||
set(PLUGIN_FILES "${PLUGIN_FILES}" CACHE INTERNAL "" FORCE)
|
||||
|
||||
add_dependencies(ie_plugins ${IE_PLUGIN_NAME})
|
||||
if(TARGET inference_engine_preproc)
|
||||
add_dependencies(${IE_PLUGIN_NAME} inference_engine_preproc)
|
||||
endif()
|
||||
|
||||
# install rules
|
||||
|
||||
if(NOT IE_PLUGIN_SKIP_INSTALL)
|
||||
string(TOLOWER "${IE_PLUGIN_DEVICE_NAME}" install_component)
|
||||
ie_cpack_add_component(${install_component} REQUIRED DEPENDS core)
|
||||
|
||||
install(TARGETS ${IE_PLUGIN_NAME}
|
||||
RUNTIME DESTINATION ${IE_CPACK_RUNTIME_PATH} COMPONENT ${install_component}
|
||||
ARCHIVE DESTINATION ${IE_CPACK_ARCHIVE_PATH} COMPONENT ${install_component}
|
||||
LIBRARY DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT ${install_component})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#
|
||||
# ie_register_plugins(MAIN_TARGET <main target name>
|
||||
# POSSIBLE_PLUGINS <list of plugins which can be build by this repo>)
|
||||
#
|
||||
macro(ie_register_plugins)
|
||||
set(options)
|
||||
set(oneValueArgs MAIN_TARGET)
|
||||
set(multiValueArgs POSSIBLE_PLUGINS)
|
||||
cmake_parse_arguments(IE_REGISTER "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if(NOT IE_REGISTER_MAIN_TARGET)
|
||||
message(FATAL_ERROR "Please, define MAIN_TARGET")
|
||||
endif()
|
||||
|
||||
set(plugins_to_remove ${IE_REGISTER_POSSIBLE_PLUGINS})
|
||||
set(plugin_files_local)
|
||||
set(config_output_file "$<TARGET_FILE_DIR:${IE_REGISTER_MAIN_TARGET}>/plugins.xml")
|
||||
|
||||
foreach(plugin IN LISTS plugins_to_remove)
|
||||
add_custom_command(TARGET ${IE_REGISTER_MAIN_TARGET} POST_BUILD
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}"
|
||||
-D "IE_CONFIG_OUTPUT_FILE=${config_output_file}"
|
||||
-D "IE_PLUGIN_NAME=${plugin}"
|
||||
-D "IE_CONFIGS_DIR=${CMAKE_BINARY_DIR}/plugins"
|
||||
-P "${IE_MAIN_SOURCE_DIR}/cmake/plugins/unregister_plugin_cmake.cmake"
|
||||
COMMENT
|
||||
"Remove ${plugin} from the plugins.xml file"
|
||||
VERBATIM)
|
||||
endforeach()
|
||||
|
||||
foreach(name IN LISTS PLUGIN_FILES)
|
||||
string(REPLACE ":" ";" name "${name}")
|
||||
list(LENGTH name length)
|
||||
if(NOT ${length} EQUAL 2)
|
||||
message(FATAL_ERROR "Unexpected error, please, contact developer of this script")
|
||||
endif()
|
||||
list(GET name 0 device_name)
|
||||
list(GET name 1 name)
|
||||
|
||||
# create plugin file
|
||||
set(config_file_name "${CMAKE_BINARY_DIR}/plugins/${name}.xml")
|
||||
get_shared_library_name(${name} library_name)
|
||||
|
||||
add_custom_command(TARGET ${IE_REGISTER_MAIN_TARGET} POST_BUILD
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}"
|
||||
-D "IE_CONFIG_OUTPUT_FILE=${config_file_name}"
|
||||
-D "IE_DEVICE_NAME=${device_name}"
|
||||
-D "IE_PLUGIN_LIBRARY_NAME=${library_name}"
|
||||
-P "${IE_MAIN_SOURCE_DIR}/cmake/plugins/create_plugin_file.cmake"
|
||||
COMMENT "Register ${name} plugin"
|
||||
VERBATIM)
|
||||
|
||||
list(APPEND plugin_files_local "${config_file_name}")
|
||||
endforeach()
|
||||
|
||||
add_custom_command(TARGET ${IE_REGISTER_MAIN_TARGET} POST_BUILD
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}"
|
||||
-D "CMAKE_SHARED_LIBRARY_PREFIX=${CMAKE_SHARED_LIBRARY_PREFIX}"
|
||||
-D "IE_CONFIG_OUTPUT_FILE=${config_output_file}"
|
||||
-D "IE_CONFIGS_DIR=${CMAKE_BINARY_DIR}/plugins"
|
||||
-P "${IE_MAIN_SOURCE_DIR}/cmake/plugins/register_plugin_cmake.cmake"
|
||||
COMMENT
|
||||
"Registering plugins to plugins.xml config file"
|
||||
VERBATIM)
|
||||
endmacro()
|
||||
65
inference-engine/cmake/plugins/register_plugin_cmake.cmake
Normal file
65
inference-engine/cmake/plugins/register_plugin_cmake.cmake
Normal file
@@ -0,0 +1,65 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
set(file_content
|
||||
"<ie>
|
||||
<plugins>
|
||||
</plugins>
|
||||
</ie>")
|
||||
|
||||
if(NOT EXISTS "${IE_CONFIG_OUTPUT_FILE}")
|
||||
file(WRITE "${IE_CONFIG_OUTPUT_FILE}" "${file_content}")
|
||||
endif()
|
||||
|
||||
# get list of plugin files
|
||||
file(GLOB plugin_files "${IE_CONFIGS_DIR}/*.xml")
|
||||
|
||||
function(check_plugin_exists plugin_name outvar)
|
||||
set(${outvar} OFF PARENT_SCOPE)
|
||||
|
||||
# check if config file already has this plugin
|
||||
file(STRINGS "${IE_CONFIG_OUTPUT_FILE}" content REGEX "plugin .*=\"")
|
||||
|
||||
foreach(line IN LISTS content)
|
||||
string(REGEX MATCH "location=\"([^\"]*)\"" location "${line}")
|
||||
get_filename_component(location "${CMAKE_MATCH_1}" NAME_WE)
|
||||
|
||||
if("${CMAKE_SHARED_LIBRARY_PREFIX}${plugin_name}" MATCHES "${location}")
|
||||
# plugin has already registered
|
||||
set(${outvar} ON PARENT_SCOPE)
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
set(plugin_files_to_add)
|
||||
foreach(plugin_file IN LISTS plugin_files)
|
||||
get_filename_component(plugin_name "${plugin_file}" NAME_WE)
|
||||
check_plugin_exists("${plugin_name}" exists)
|
||||
|
||||
if(NOT exists)
|
||||
list(APPEND plugin_files_to_add "${plugin_file}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# add plugin
|
||||
set(newContent "")
|
||||
file(STRINGS "${IE_CONFIG_OUTPUT_FILE}" content)
|
||||
|
||||
foreach(line IN LISTS content)
|
||||
if("${line}" MATCHES "</plugins>")
|
||||
foreach(plugin_file IN LISTS plugin_files_to_add)
|
||||
file(READ "${plugin_file}" content)
|
||||
set(newContent "${newContent}
|
||||
${content}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(newContent)
|
||||
set(newContent "${newContent}\n${line}")
|
||||
else()
|
||||
set(newContent "${line}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
file(WRITE "${IE_CONFIG_OUTPUT_FILE}" "${newContent}")
|
||||
35
inference-engine/cmake/plugins/unregister_plugin_cmake.cmake
Normal file
35
inference-engine/cmake/plugins/unregister_plugin_cmake.cmake
Normal file
@@ -0,0 +1,35 @@
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
if(NOT EXISTS "${IE_CONFIG_OUTPUT_FILE}")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# remove plugin file
|
||||
file(REMOVE "${IE_CONFIGS_DIR}/${IE_PLUGIN_NAME}.xml")
|
||||
|
||||
# remove plugin
|
||||
set(newContent "")
|
||||
file(STRINGS "${IE_CONFIG_OUTPUT_FILE}" content)
|
||||
|
||||
set(skip_plugin OFF)
|
||||
foreach(line IN LISTS content)
|
||||
if("${line}" MATCHES "${IE_PLUGIN_NAME}")
|
||||
set(skip_plugin ON)
|
||||
endif()
|
||||
|
||||
if(NOT skip_plugin)
|
||||
if(newContent)
|
||||
set(newContent "${newContent}\n${line}")
|
||||
else()
|
||||
set(newContent "${line}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if("${line}" MATCHES "</plugin>")
|
||||
set(skip_plugin OFF)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
file(WRITE "${IE_CONFIG_OUTPUT_FILE}" "${newContent}")
|
||||
@@ -1,24 +0,0 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
if (ENABLE_SANITIZER)
|
||||
set(SANITIZER_COMPILER_FLAGS "-fsanitize=address")
|
||||
CHECK_CXX_COMPILER_FLAG("-fsanitize-recover=address" SANITIZE_RECOVER_SUPPORTED)
|
||||
if (SANITIZE_RECOVER_SUPPORTED)
|
||||
set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize-recover=address")
|
||||
endif()
|
||||
|
||||
set(SANITIZER_LINKER_FLAGS "-fsanitize=address")
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fuse-ld=gold")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CC_FLAGS "${CMAKE_CC_FLAGS} ${SANITIZER_COMPILER_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZER_COMPILER_FLAGS}")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SANITIZER_LINKER_FLAGS}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SANITIZER_LINKER_FLAGS}")
|
||||
endif()
|
||||
@@ -1,39 +0,0 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
if (UNIX OR APPLE AND ${CMAKE_BUILD_TYPE} STREQUAL "Release")
|
||||
set(CMAKE_CCXX_FLAGS "${CMAKE_CCXX_FLAGS} -fPIE -fPIC -Wformat -Wformat-security")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_FORTIFY_SOURCE=2")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -D_FORTIFY_SOURCE=2")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack -z relro -z now")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack -z relro -z now")
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
|
||||
set(CMAKE_CCXX_FLAGS "${CMAKE_CCXX_FLAGS} -fstack-protector-all")
|
||||
else()
|
||||
set(CMAKE_CCXX_FLAGS "${CMAKE_CCXX_FLAGS} -fstack-protector-strong")
|
||||
endif()
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s -fvisibility=hidden")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s -fvisibility=hidden")
|
||||
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
set(CMAKE_CCXX_FLAGS "${CMAKE_CCXX_FLAGS} -fstack-protector-all")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fvisibility=hidden")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fvisibility=hidden")
|
||||
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack -z relro -z now")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack -z relro -z now")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wl,--strip-all -fvisibility=hidden")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wl,--strip-all -fvisibility=hidden")
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CCXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CCXX_FLAGS}")
|
||||
elseif (WIN32)
|
||||
if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MP /sdl")
|
||||
endif()
|
||||
endif()
|
||||
@@ -1,9 +1,8 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
set(InferenceEngine_VERSION 1.6.0)
|
||||
set(InferenceEngine_VERSION 2.1.0)
|
||||
set(PACKAGE_VERSION ${InferenceEngine_VERSION})
|
||||
|
||||
set(PACKAGE_VERSION_EXACT False)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
#
|
||||
@@ -16,7 +15,10 @@
|
||||
#
|
||||
# and the following imported targets:
|
||||
#
|
||||
# IE::inference_engine - The Inference Engine library
|
||||
# IE::inference_engine - The Inference Engine library
|
||||
# IE::inference_engine_legacy - The Inference Engine library with legacy API for IR v7 and older.
|
||||
# IE::inference_engine_c_api - The Inference Engine C API library
|
||||
# IE::inference_engine_nn_builder - The Inference Engine NN Builder library
|
||||
#
|
||||
|
||||
macro(ext_message TRACE_LEVEL)
|
||||
@@ -37,16 +39,16 @@ set(InferenceEngine_FOUND FALSE)
|
||||
if(TARGET IE::inference_engine)
|
||||
set(InferenceEngine_FOUND TRUE)
|
||||
get_target_property(InferenceEngine_INCLUDE_DIRS IE::inference_engine INTERFACE_INCLUDE_DIRECTORIES)
|
||||
set(InferenceEngine_LIBRARIES IE::inference_engine)
|
||||
set(InferenceEngine_LIBRARIES IE::inference_engine_legacy IE::inference_engine
|
||||
IE::inference_engine_c_api IE::inference_engine_nn_builder)
|
||||
else()
|
||||
if (WIN32)
|
||||
set(_ARCH intel64)
|
||||
else()
|
||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l")
|
||||
set(_ARCH armv7l)
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
|
||||
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} _ARCH)
|
||||
if(_ARCH STREQUAL "x86_64" OR _ARCH STREQUAL "amd64") # Windows detects Intel's 64-bit CPU as AMD64
|
||||
set(_ARCH intel64)
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i386")
|
||||
elseif(_ARCH STREQUAL "i386")
|
||||
set(_ARCH ia32)
|
||||
endif()
|
||||
endif()
|
||||
@@ -70,95 +72,104 @@ else()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT IE_ROOT_DIR)
|
||||
ext_message(FATAL_ERROR "inference_engine directory is not found")
|
||||
if(NOT IE_ROOT_DIR)
|
||||
ext_message(FATAL_ERROR "inference_engine root directory is not found")
|
||||
endif()
|
||||
|
||||
find_path(IE_INCLUDE_DIR inference_engine.hpp "${IE_ROOT_DIR}/include" NO_DEFAULT_PATH)
|
||||
|
||||
if(IE_INCLUDE_DIR AND NOT "${IE_ROOT_DIR}/include" EQUAL "${IE_INCLUDE_DIR}")
|
||||
unset(IE_INCLUDE_DIR CACHE)
|
||||
endif()
|
||||
|
||||
if(IE_SRC_DIR AND NOT "${IE_ROOT_DIR}/src" EQUAL "${IE_SRC_DIR}")
|
||||
unset(IE_SRC_DIR CACHE)
|
||||
endif()
|
||||
|
||||
if(IE_LIBRARY AND NOT "${IE_ROOT_DIR}/lib/${_ARCH}" EQUAL "${IE_LIBRARY}")
|
||||
unset(IE_LIBRARY CACHE)
|
||||
endif()
|
||||
|
||||
set(_IE_ROOT_INCLUDE_DIR "${IE_ROOT_DIR}/include")
|
||||
set(_IE_ROOT_SRC_DIR "${IE_ROOT_DIR}/src")
|
||||
set(_IE_ROOT_LIBRARY "${IE_ROOT_DIR}/lib/${_ARCH}")
|
||||
|
||||
find_path(IE_INCLUDE_DIR inference_engine.hpp "${_IE_ROOT_INCLUDE_DIR}")
|
||||
find_path(IE_SRC_DIR extension "${_IE_ROOT_SRC_DIR}")
|
||||
|
||||
set(IE_LIB_DIR "${_IE_ROOT_LIBRARY}")
|
||||
set(IE_LIB_DIR "${IE_ROOT_DIR}/lib/${_ARCH}")
|
||||
set(IE_LIB_REL_DIR "${IE_LIB_DIR}/Release")
|
||||
set(IE_LIB_DBG_DIR "${IE_LIB_DIR}/Debug")
|
||||
set(IE_EXTERNAL_DIR "${IE_ROOT_DIR}/external")
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
if (WIN32)
|
||||
find_library(IE_RELEASE_LIBRARY inference_engine@IE_RELEASE_POSTFIX_WIN@ "${IE_LIB_REL_DIR}")
|
||||
find_library(IE_DEBUG_LIBRARY inference_engine@IE_DEBUG_POSTFIX_WIN@ "${IE_LIB_DBG_DIR}")
|
||||
find_package_handle_standard_args( InferenceEngine
|
||||
FOUND_VAR INFERENCEENGINE_FOUND
|
||||
REQUIRED_VARS IE_RELEASE_LIBRARY IE_DEBUG_LIBRARY IE_INCLUDE_DIR
|
||||
FAIL_MESSAGE "Inference Engine cannot be found at ${_IE_ROOT_LIBRARY}. Please consult InferenceEgnineConfig.cmake module's help page.")
|
||||
elseif (APPLE)
|
||||
find_library(IE_RELEASE_LIBRARY inference_engine@IE_RELEASE_POSTFIX_MAC@ "${IE_LIB_DIR}")
|
||||
find_library(IE_DEBUG_LIBRARY inference_engine@IE_DEBUG_POSTFIX_MAC@ "${IE_LIB_DIR}")
|
||||
find_package_handle_standard_args( InferenceEngine
|
||||
FOUND_VAR INFERENCEENGINE_FOUND
|
||||
REQUIRED_VARS IE_RELEASE_LIBRARY IE_DEBUG_LIBRARY IE_INCLUDE_DIR
|
||||
FAIL_MESSAGE "Inference Engine cannot be found at ${_IE_ROOT_LIBRARY}. Please consult InferenceEgnineConfig.cmake module's help page.")
|
||||
|
||||
if(WIN32)
|
||||
find_library(IE_RELEASE_LIBRARY inference_engine@IE_RELEASE_POSTFIX_WIN@ "${IE_LIB_REL_DIR}" NO_DEFAULT_PATH)
|
||||
find_library(IE_LEGACY_RELEASE_LIBRARY inference_engine_legacy@IE_RELEASE_POSTFIX_WIN@ "${IE_LIB_REL_DIR}" NO_DEFAULT_PATH)
|
||||
find_library(IE_C_API_RELEASE_LIBRARY inference_engine_c_api@IE_RELEASE_POSTFIX_WIN@ "${IE_LIB_REL_DIR}" NO_DEFAULT_PATH)
|
||||
find_library(IE_NN_BUILDER_RELEASE_LIBRARY inference_engine_nn_builder@IE_RELEASE_POSTFIX_WIN@ "${IE_LIB_REL_DIR}" NO_DEFAULT_PATH)
|
||||
elseif(APPLE)
|
||||
find_library(IE_RELEASE_LIBRARY inference_engine@IE_RELEASE_POSTFIX_MAC@ "${IE_LIB_DIR}" NO_DEFAULT_PATH)
|
||||
find_library(IE_LEGACY_RELEASE_LIBRARY inference_engine_legacy@IE_RELEASE_POSTFIX_MAC@ "${IE_LIB_DIR}" NO_DEFAULT_PATH)
|
||||
find_library(IE_C_API_RELEASE_LIBRARY inference_engine_c_api@IE_RELEASE_POSTFIX_MAC@ "${IE_LIB_DIR}" NO_DEFAULT_PATH)
|
||||
find_library(IE_NN_BUILDER_RELEASE_LIBRARY inference_engine_nn_builder@IE_RELEASE_POSTFIX_MAC@ "${IE_LIB_DIR}" NO_DEFAULT_PATH)
|
||||
else()
|
||||
find_library(IE_LIBRARY inference_engine@IE_RELEASE_POSTFIX_LIN@ "${IE_LIB_DIR}")
|
||||
find_package_handle_standard_args( InferenceEngine
|
||||
FOUND_VAR INFERENCEENGINE_FOUND
|
||||
REQUIRED_VARS IE_LIBRARY IE_INCLUDE_DIR
|
||||
FAIL_MESSAGE "Inference Engine cannot be found at ${_IE_ROOT_LIBRARY}. Please consult InferenceEgnineConfig.cmake module's help page.")
|
||||
find_library(IE_RELEASE_LIBRARY inference_engine@IE_RELEASE_POSTFIX_LIN@ "${IE_LIB_DIR}" NO_DEFAULT_PATH)
|
||||
find_library(IE_LEGACY_RELEASE_LIBRARY inference_engine_legacy@IE_RELEASE_POSTFIX_LIN@ "${IE_LIB_DIR}" NO_DEFAULT_PATH)
|
||||
find_library(IE_C_API_RELEASE_LIBRARY inference_engine_c_api@IE_RELEASE_POSTFIX_LIN@ "${IE_LIB_DIR}" NO_DEFAULT_PATH)
|
||||
find_library(IE_NN_BUILDER_RELEASE_LIBRARY inference_engine_nn_builder@IE_RELEASE_POSTFIX_LIN@ "${IE_LIB_DIR}" NO_DEFAULT_PATH)
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args( InferenceEngine
|
||||
FOUND_VAR INFERENCEENGINE_FOUND
|
||||
REQUIRED_VARS IE_RELEASE_LIBRARY IE_LEGACY_RELEASE_LIBRARY IE_C_API_RELEASE_LIBRARY IE_NN_BUILDER_RELEASE_LIBRARY IE_INCLUDE_DIR
|
||||
FAIL_MESSAGE "Some of mandatory Inference Engine components are not found. Please consult InferenceEgnineConfig.cmake module's help page.")
|
||||
|
||||
if(INFERENCEENGINE_FOUND)
|
||||
# to keep this line for successful execution in CMake 2.8
|
||||
set(InferenceEngine_FOUND TRUE)
|
||||
|
||||
add_library(IE::inference_engine SHARED IMPORTED GLOBAL)
|
||||
foreach(ie_library_suffix "" "_legacy" "_c_api" "_nn_builder")
|
||||
string(TOUPPER "${ie_library_suffix}" ie_library_usuffix)
|
||||
add_library(IE::inference_engine${ie_library_suffix} SHARED IMPORTED GLOBAL)
|
||||
|
||||
if (WIN32)
|
||||
set_property(TARGET IE::inference_engine APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
|
||||
set_property(TARGET IE::inference_engine APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
||||
if (WIN32)
|
||||
set_target_properties(IE::inference_engine${ie_library_suffix} PROPERTIES
|
||||
IMPORTED_CONFIGURATIONS RELEASE
|
||||
IMPORTED_IMPLIB_RELEASE "${IE${ie_library_usuffix}_RELEASE_LIBRARY}"
|
||||
MAP_IMPORTED_CONFIG_RELEASE Release
|
||||
MAP_IMPORTED_CONFIG_RELWITHDEBINFO Release
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${IE_INCLUDE_DIR}")
|
||||
|
||||
set_target_properties(IE::inference_engine PROPERTIES
|
||||
IMPORTED_IMPLIB_RELEASE "${IE_RELEASE_LIBRARY}"
|
||||
IMPORTED_IMPLIB_DEBUG "${IE_DEBUG_LIBRARY}"
|
||||
MAP_IMPORTED_CONFIG_DEBUG Debug
|
||||
MAP_IMPORTED_CONFIG_RELEASE Release
|
||||
MAP_IMPORTED_CONFIG_RELWITHDEBINFO Release
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${IE_INCLUDE_DIR}")
|
||||
elseif (APPLE)
|
||||
set_target_properties(IE::inference_engine PROPERTIES
|
||||
IMPORTED_LOCATION_RELEASE "${IE_RELEASE_LIBRARY}"
|
||||
IMPORTED_LOCATION_DEBUG "${IE_DEBUG_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${IE_INCLUDE_DIR}")
|
||||
target_link_libraries(IE::inference_engine INTERFACE ${CMAKE_DL_LIBS})
|
||||
else()
|
||||
set_target_properties(IE::inference_engine PROPERTIES
|
||||
IMPORTED_LOCATION "${IE_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${IE_INCLUDE_DIR}")
|
||||
target_link_libraries(IE::inference_engine INTERFACE ${CMAKE_DL_LIBS})
|
||||
endif()
|
||||
# Debug binaries are optional
|
||||
find_library(IE${ie_library_usuffix}_DEBUG_LIBRARY inference_engine${ie_library_suffix}@IE_DEBUG_POSTFIX_WIN@
|
||||
"${IE_LIB_DBG_DIR}" NO_DEFAULT_PATH)
|
||||
if (IE${ie_library_usuffix}_DEBUG_LIBRARY)
|
||||
set_property(TARGET IE::inference_engine${ie_library_suffix} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
|
||||
set_target_properties(IE::inference_engine${ie_library_suffix} PROPERTIES
|
||||
IMPORTED_IMPLIB_DEBUG "${IE${ie_library_usuffix}_DEBUG_LIBRARY}"
|
||||
MAP_IMPORTED_CONFIG_DEBUG Debug)
|
||||
else()
|
||||
ext_message(WARNING "Inference Engine DEBUG binaries are missed.")
|
||||
endif()
|
||||
elseif (APPLE)
|
||||
set_target_properties(IE::inference_engine${ie_library_suffix} PROPERTIES
|
||||
IMPORTED_LOCATION_RELEASE "${IE${ie_library_usuffix}_RELEASE_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${IE_INCLUDE_DIR}"
|
||||
INTERFACE_COMPILE_OPTIONS "-Wno-error=deprecated-declarations")
|
||||
|
||||
# Debug binaries are optional
|
||||
find_library(IE${ie_library_usuffix}_DEBUG_LIBRARY inference_engine${ie_library_suffix}@IE_DEBUG_POSTFIX_MAC@ "${IE_LIB_DIR}" NO_DEFAULT_PATH)
|
||||
if (IE${ie_library_usuffix}_DEBUG_LIBRARY)
|
||||
set_target_properties(IE::inference_engine${ie_library_suffix} PROPERTIES
|
||||
IMPORTED_LOCATION_DEBUG "${IE${ie_library_usuffix}_DEBUG_LIBRARY}")
|
||||
else()
|
||||
ext_message(WARNING "Inference Engine DEBUG binaries are missed")
|
||||
endif()
|
||||
|
||||
target_link_libraries(IE::inference_engine${ie_library_suffix} INTERFACE ${CMAKE_DL_LIBS})
|
||||
else()
|
||||
# Only Release binaries are distributed for Linux systems
|
||||
set_target_properties(IE::inference_engine${ie_library_suffix} PROPERTIES
|
||||
IMPORTED_LOCATION "${IE${ie_library_usuffix}_RELEASE_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${IE_INCLUDE_DIR}")
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES Intel)
|
||||
set_target_properties(IE::inference_engine${ie_library_suffix} PROPERTIES
|
||||
INTERFACE_COMPILE_OPTIONS "-diag-warning=1786")
|
||||
else()
|
||||
set_target_properties(IE::inference_engine${ie_library_suffix} PROPERTIES
|
||||
INTERFACE_COMPILE_OPTIONS "-Wno-error=deprecated-declarations")
|
||||
endif()
|
||||
target_link_libraries(IE::inference_engine${ie_library_suffix} INTERFACE ${CMAKE_DL_LIBS})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(InferenceEngine_INCLUDE_DIRS ${IE_INCLUDE_DIR})
|
||||
set(InferenceEngine_LIBRARIES IE::inference_engine)
|
||||
set(InferenceEngine_LIBRARIES IE::inference_engine_legacy IE::inference_engine
|
||||
IE::inference_engine_c_api IE::inference_engine_nn_builder)
|
||||
|
||||
set(IE_EXTERNAL_DIR "${IE_ROOT_DIR}/external")
|
||||
include("${IE_ROOT_DIR}/share/ie_parallel.cmake")
|
||||
|
||||
add_subdirectory(${IE_SRC_DIR}/extension EXCLUDE_FROM_ALL ie_cpu_extension)
|
||||
add_library(IE::ie_cpu_extension ALIAS ie_cpu_extension)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
196
inference-engine/cmake/tbb/lnx/TBBConfig.cmake
Normal file
196
inference-engine/cmake/tbb/lnx/TBBConfig.cmake
Normal file
@@ -0,0 +1,196 @@
|
||||
#===============================================================================
|
||||
# Copyright 2017-2020 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#===============================================================================
|
||||
|
||||
# TBB_FOUND should not be set explicitly. It is defined automatically by CMake.
|
||||
# Handling of TBB_VERSION is in TBBConfigVersion.cmake.
|
||||
|
||||
if (NOT TBB_FIND_COMPONENTS)
|
||||
set(TBB_FIND_COMPONENTS "tbb;tbbmalloc;tbbmalloc_proxy")
|
||||
foreach (_tbb_component ${TBB_FIND_COMPONENTS})
|
||||
set(TBB_FIND_REQUIRED_${_tbb_component} 1)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Add components with internal dependencies: tbbmalloc_proxy -> tbbmalloc
|
||||
list(FIND TBB_FIND_COMPONENTS tbbmalloc_proxy _tbbmalloc_proxy_ix)
|
||||
if (NOT _tbbmalloc_proxy_ix EQUAL -1)
|
||||
list(FIND TBB_FIND_COMPONENTS tbbmalloc _tbbmalloc_ix)
|
||||
if (_tbbmalloc_ix EQUAL -1)
|
||||
list(APPEND TBB_FIND_COMPONENTS tbbmalloc)
|
||||
set(TBB_FIND_REQUIRED_tbbmalloc ${TBB_FIND_REQUIRED_tbbmalloc_proxy})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT TBBROOT)
|
||||
if(DEFINED ENV{TBBROOT})
|
||||
set (TBBROOT $ENV{TBBROOT})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(_tbb_root ${TBBROOT})
|
||||
|
||||
set(_tbb_x32_subdir ia32)
|
||||
set(_tbb_x64_subdir intel64)
|
||||
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(_tbb_arch_subdir ${_tbb_x64_subdir})
|
||||
else()
|
||||
set(_tbb_arch_subdir ${_tbb_x32_subdir})
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_LOADED)
|
||||
set(_tbb_compiler_id ${CMAKE_CXX_COMPILER_ID})
|
||||
set(_tbb_compiler_ver ${CMAKE_CXX_COMPILER_VERSION})
|
||||
elseif (CMAKE_C_COMPILER_LOADED)
|
||||
set(_tbb_compiler_id ${CMAKE_C_COMPILER_ID})
|
||||
set(_tbb_compiler_ver ${CMAKE_C_COMPILER_VERSION})
|
||||
endif()
|
||||
|
||||
# For non-GCC compilers try to find version of system GCC to choose right compiler subdirectory.
|
||||
if (NOT _tbb_compiler_id STREQUAL "GNU")
|
||||
execute_process(COMMAND gcc --version OUTPUT_VARIABLE _tbb_gcc_ver_output ERROR_QUIET)
|
||||
string(REGEX REPLACE ".*gcc.*([0-9]+\\.[0-9]+)\\.[0-9]+.*" "\\1" _tbb_compiler_ver "${_tbb_gcc_ver_output}")
|
||||
if (NOT _tbb_compiler_ver)
|
||||
message(FATAL_ERROR "This Intel TBB package is intended to be used only environment with available 'gcc'")
|
||||
endif()
|
||||
unset(_tbb_gcc_ver_output)
|
||||
endif()
|
||||
|
||||
if (EXISTS "${_tbb_root}/lib/${_tbb_arch_subdir}")
|
||||
set(_tbb_lib ${_tbb_root}/lib/${_tbb_arch_subdir})
|
||||
set(_tbb_inc ${_tbb_root}/include)
|
||||
|
||||
file(GLOB _tbb_gcc_versions_available RELATIVE ${_tbb_lib} ${_tbb_lib}/*)
|
||||
# shall we check _tbb_gcc_versions_available is not empty?
|
||||
foreach (_tbb_gcc_version ${_tbb_gcc_versions_available})
|
||||
string(SUBSTRING ${_tbb_gcc_version} 3 -1 _tbb_gcc_version_number)
|
||||
if (NOT _tbb_compiler_ver VERSION_LESS _tbb_gcc_version_number)
|
||||
set(_tbb_compiler_subdir ${_tbb_gcc_version})
|
||||
endif()
|
||||
endforeach()
|
||||
else()
|
||||
if (TBBROOT)
|
||||
set(__tbb_hint_path "${TBBROOT}")
|
||||
else()
|
||||
set(__tbb_hint_path "/non/existing/path")
|
||||
endif()
|
||||
|
||||
# try to find TBB in the system
|
||||
find_library(_tbb_lib NAMES tbb
|
||||
HINTS "${__tbb_hint_path}"
|
||||
PATH_SUFFIXES lib lib64)
|
||||
find_path(_tbb_inc NAMES tbb.h
|
||||
HINTS "${__tbb_hint_path}"
|
||||
PATH_SUFFIXES include tbb include/tbb)
|
||||
unset(__tbb_hint_path)
|
||||
|
||||
if (NOT _tbb_lib OR NOT _tbb_inc)
|
||||
message("FATAL_ERROR" "Cannot find TBB")
|
||||
endif()
|
||||
|
||||
get_filename_component(_tbb_lib "${_tbb_lib}" PATH)
|
||||
get_filename_component(_tbb_inc "${_tbb_inc}" PATH)
|
||||
|
||||
set(_tbb_arch_subdir "")
|
||||
set(_tbb_compiler_subdir "")
|
||||
endif()
|
||||
|
||||
unset(_tbb_gcc_version_number)
|
||||
unset(_tbb_compiler_id)
|
||||
unset(_tbb_compiler_ver)
|
||||
|
||||
# Now we check that all the needed component are present
|
||||
get_filename_component(_tbb_lib_path "${_tbb_lib}/${_tbb_compiler_subdir}" ABSOLUTE)
|
||||
|
||||
if (TBB_FOUND)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# detect version
|
||||
find_file(_tbb_def_header tbb_stddef.h HINTS "${_tbb_root}/include/tbb")
|
||||
|
||||
if (_tbb_def_header)
|
||||
file(READ "${_tbb_def_header}" _tbb_def_content)
|
||||
string(REGEX MATCH "TBB_VERSION_MAJOR[ ]*[0-9]*" _tbb_version_major ${_tbb_def_content})
|
||||
string(REGEX MATCH "[0-9][0-9]*" _tbb_version_major ${_tbb_version_major})
|
||||
|
||||
string(REGEX MATCH "TBB_VERSION_MINOR[ ]*[0-9]" _tbb_version_minor ${_tbb_def_content})
|
||||
string(REGEX MATCH "[0-9][0-9]*" _tbb_version_minor ${_tbb_version_minor})
|
||||
|
||||
set(TBB_VERSION "${_tbb_version_major}.${_tbb_version_minor}")
|
||||
else()
|
||||
set(TBB_VERSION "")
|
||||
endif()
|
||||
|
||||
foreach (_tbb_soversion 2 12)
|
||||
foreach (_tbb_component ${TBB_FIND_COMPONENTS})
|
||||
set(_tbb_release_lib
|
||||
"${_tbb_lib_path}/lib${_tbb_component}.so.${_tbb_soversion}")
|
||||
set(_tbb_debug_lib
|
||||
"${_tbb_lib_path}/lib${_tbb_component}_debug.so.${_tbb_soversion}")
|
||||
|
||||
# oneDNN change: check library existence (BUILD_MODE related only, not both)
|
||||
string(TOUPPER "${CMAKE_BUILD_TYPE}" UPPERCASE_CMAKE_BUILD_TYPE)
|
||||
if (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
|
||||
if (EXISTS "${_tbb_debug_lib}")
|
||||
set(_lib_exists TRUE)
|
||||
elseif (EXISTS "${_tbb_release_lib}")
|
||||
message(FATAL_ERROR
|
||||
"Intel TBB release library is found here: ${_tbb_release_lib}. "
|
||||
"But the debug library
|
||||
(lib${_tbb_component}_debug.so.${_tbb_soversion}) is missing.")
|
||||
endif()
|
||||
else()
|
||||
if (EXISTS "${_tbb_release_lib}")
|
||||
set(_lib_exists TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (_lib_exists)
|
||||
if (NOT TARGET TBB::${_tbb_component})
|
||||
add_library(TBB::${_tbb_component} SHARED IMPORTED)
|
||||
set_target_properties(TBB::${_tbb_component} PROPERTIES
|
||||
IMPORTED_CONFIGURATIONS "RELEASE;DEBUG"
|
||||
IMPORTED_LOCATION_RELEASE "${_tbb_release_lib}"
|
||||
IMPORTED_LOCATION_DEBUG "${_tbb_debug_lib}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${_tbb_inc}")
|
||||
|
||||
# Add internal dependencies for imported targets: TBB::tbbmalloc_proxy -> TBB::tbbmalloc
|
||||
if (_tbb_component STREQUAL tbbmalloc_proxy)
|
||||
set_target_properties(TBB::tbbmalloc_proxy PROPERTIES INTERFACE_LINK_LIBRARIES TBB::tbbmalloc)
|
||||
endif()
|
||||
|
||||
list(APPEND TBB_IMPORTED_TARGETS TBB::${_tbb_component})
|
||||
set(TBB_${_tbb_component}_FOUND 1)
|
||||
endif()
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
if (NOT _lib_exists AND TBB_FIND_REQUIRED AND TBB_FIND_REQUIRED_${_tbb_component})
|
||||
message(FATAL_ERROR "Missed required Intel TBB component: ${_tbb_component}")
|
||||
endif()
|
||||
|
||||
unset(_tbb_x32_subdir)
|
||||
unset(_tbb_x64_subdir)
|
||||
unset(_tbb_arch_subdir)
|
||||
unset(_tbb_compiler_subdir)
|
||||
unset(_tbbmalloc_proxy_ix)
|
||||
unset(_tbbmalloc_ix)
|
||||
unset(_tbb_lib_path)
|
||||
unset(_tbb_release_lib)
|
||||
unset(_tbb_debug_lib)
|
||||
114
inference-engine/cmake/tbb/mac/TBBConfig.cmake
Normal file
114
inference-engine/cmake/tbb/mac/TBBConfig.cmake
Normal file
@@ -0,0 +1,114 @@
|
||||
#===============================================================================
|
||||
# Copyright 2017-2020 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#===============================================================================
|
||||
|
||||
# TBB_FOUND should not be set explicitly. It is defined automatically by CMake.
|
||||
# Handling of TBB_VERSION is in TBBConfigVersion.cmake.
|
||||
|
||||
if (NOT TBB_FIND_COMPONENTS)
|
||||
set(TBB_FIND_COMPONENTS "tbb;tbbmalloc;tbbmalloc_proxy")
|
||||
foreach (_tbb_component ${TBB_FIND_COMPONENTS})
|
||||
set(TBB_FIND_REQUIRED_${_tbb_component} 1)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Add components with internal dependencies: tbbmalloc_proxy -> tbbmalloc
|
||||
list(FIND TBB_FIND_COMPONENTS tbbmalloc_proxy _tbbmalloc_proxy_ix)
|
||||
if (NOT _tbbmalloc_proxy_ix EQUAL -1)
|
||||
list(FIND TBB_FIND_COMPONENTS tbbmalloc _tbbmalloc_ix)
|
||||
if (_tbbmalloc_ix EQUAL -1)
|
||||
list(APPEND TBB_FIND_COMPONENTS tbbmalloc)
|
||||
set(TBB_FIND_REQUIRED_tbbmalloc ${TBB_FIND_REQUIRED_tbbmalloc_proxy})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT TBBROOT)
|
||||
if(DEFINED ENV{TBBROOT})
|
||||
set (TBBROOT $ENV{TBBROOT})
|
||||
else()
|
||||
message("FATAL_ERROR" "TBBROOT is unset")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(_tbb_root ${TBBROOT})
|
||||
|
||||
set(_tbb_x32_subdir .)
|
||||
set(_tbb_x64_subdir .)
|
||||
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(_tbb_arch_subdir ${_tbb_x64_subdir})
|
||||
else()
|
||||
set(_tbb_arch_subdir ${_tbb_x32_subdir})
|
||||
endif()
|
||||
|
||||
set(_tbb_compiler_subdir .)
|
||||
|
||||
get_filename_component(_tbb_lib_path "${_tbb_root}/lib/${_tbb_arch_subdir}/${_tbb_compiler_subdir}" ABSOLUTE)
|
||||
|
||||
if (TBB_FOUND)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# detect version
|
||||
find_file(_tbb_def_header tbb_stddef.h HINTS "${_tbb_root}/include/tbb")
|
||||
|
||||
if (_tbb_def_header)
|
||||
file(READ "${_tbb_def_header}" _tbb_def_content)
|
||||
string(REGEX MATCH "TBB_VERSION_MAJOR[ ]*[0-9]*" _tbb_version_major ${_tbb_def_content})
|
||||
string(REGEX MATCH "[0-9][0-9]*" _tbb_version_major ${_tbb_version_major})
|
||||
|
||||
string(REGEX MATCH "TBB_VERSION_MINOR[ ]*[0-9]" _tbb_version_minor ${_tbb_def_content})
|
||||
string(REGEX MATCH "[0-9][0-9]*" _tbb_version_minor ${_tbb_version_minor})
|
||||
|
||||
set(TBB_VERSION "${_tbb_version_major}.${_tbb_version_minor}")
|
||||
else()
|
||||
set(TBB_VERSION "")
|
||||
endif()
|
||||
|
||||
foreach (_tbb_component ${TBB_FIND_COMPONENTS})
|
||||
set(_tbb_release_lib "${_tbb_lib_path}/lib${_tbb_component}.dylib")
|
||||
set(_tbb_debug_lib "${_tbb_lib_path}/lib${_tbb_component}_debug.dylib")
|
||||
|
||||
if (EXISTS "${_tbb_release_lib}" AND EXISTS "${_tbb_debug_lib}")
|
||||
if (NOT TARGET TBB::${_tbb_component})
|
||||
add_library(TBB::${_tbb_component} SHARED IMPORTED)
|
||||
set_target_properties(TBB::${_tbb_component} PROPERTIES
|
||||
IMPORTED_CONFIGURATIONS "RELEASE;DEBUG"
|
||||
IMPORTED_LOCATION_RELEASE "${_tbb_release_lib}"
|
||||
IMPORTED_LOCATION_DEBUG "${_tbb_debug_lib}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${_tbb_root}/include")
|
||||
|
||||
# Add internal dependencies for imported targets: TBB::tbbmalloc_proxy -> TBB::tbbmalloc
|
||||
if (_tbb_component STREQUAL tbbmalloc_proxy)
|
||||
set_target_properties(TBB::tbbmalloc_proxy PROPERTIES INTERFACE_LINK_LIBRARIES TBB::tbbmalloc)
|
||||
endif()
|
||||
|
||||
list(APPEND TBB_IMPORTED_TARGETS TBB::${_tbb_component})
|
||||
set(TBB_${_tbb_component}_FOUND 1)
|
||||
endif()
|
||||
elseif (TBB_FIND_REQUIRED AND TBB_FIND_REQUIRED_${_tbb_component})
|
||||
message(FATAL_ERROR "Missed required Intel TBB component: ${_tbb_component}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
unset(_tbb_x32_subdir)
|
||||
unset(_tbb_x64_subdir)
|
||||
unset(_tbb_arch_subdir)
|
||||
unset(_tbb_compiler_subdir)
|
||||
unset(_tbbmalloc_proxy_ix)
|
||||
unset(_tbbmalloc_ix)
|
||||
unset(_tbb_lib_path)
|
||||
unset(_tbb_release_lib)
|
||||
unset(_tbb_debug_lib)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user