Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Openvino cmake config #7419

Merged
merged 39 commits into from
Sep 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
6ae131c
Added OpenVINOConfig.cmake
ilya-lavrenov Sep 6, 2021
00e269e
OpenVINOConfig.cmake part 2
ilya-lavrenov Sep 8, 2021
b84a30e
Trying to fix cmake generation
ilya-lavrenov Sep 8, 2021
68fab86
Fixes
ilya-lavrenov Sep 8, 2021
ef84fde
Export frontends as well
ilya-lavrenov Sep 8, 2021
1f2bb08
Merge remote-tracking branch 'upstream/master' into openvino-cmake-co…
ilya-lavrenov Sep 8, 2021
005658e
Fixed condition
ilya-lavrenov Sep 8, 2021
5126bed
Added OpenVINO cmake package usage: docs, C samples
ilya-lavrenov Sep 8, 2021
8974fc3
Use more OpenVINO config
ilya-lavrenov Sep 8, 2021
4361b48
Merge remote-tracking branch 'upstream/master' into openvino-cmake-co…
ilya-lavrenov Sep 8, 2021
8666873
Install OpenVINOConfig.cmake
ilya-lavrenov Sep 8, 2021
60d5fef
Trying to fix private plugins
ilya-lavrenov Sep 8, 2021
28cd2e3
Trying to fix .tox
ilya-lavrenov Sep 8, 2021
65103fb
Trying to fix ARM
ilya-lavrenov Sep 8, 2021
5e3019b
Fixed samples build
ilya-lavrenov Sep 8, 2021
356540f
Explicit ngraph duplicated targets
ilya-lavrenov Sep 8, 2021
42e746d
Fixed fuzzing tests build
ilya-lavrenov Sep 8, 2021
330f2e4
Merge remote-tracking branch 'upstream/master' into openvino-cmake-co…
ilya-lavrenov Sep 8, 2021
691fc64
Added IR frontend installation
ilya-lavrenov Sep 9, 2021
22e3757
Removed install directory for IE reader
ilya-lavrenov Sep 9, 2021
5a6c926
Merge remote-tracking branch 'upstream/master' into openvino-cmake-co…
ilya-lavrenov Sep 9, 2021
f75286e
Removed IR frontend from export list
ilya-lavrenov Sep 9, 2021
06a0dae
Merge remote-tracking branch 'upstream/master' into openvino-cmake-co…
ilya-lavrenov Sep 9, 2021
475d08c
Merge remote-tracking branch 'upstream/master' into openvino-cmake-co…
ilya-lavrenov Sep 9, 2021
61efd81
Reverted ngraph_DIR
ilya-lavrenov Sep 9, 2021
3e011a4
Try to fix .tox
ilya-lavrenov Sep 9, 2021
4a1d60b
Fixed ieFuncTests with ONNX extensions
ilya-lavrenov Sep 9, 2021
587a312
Attempt #2
ilya-lavrenov Sep 9, 2021
4e9e02c
Trying to fix ngraph setup.py
ilya-lavrenov Sep 9, 2021
b7ee2f8
Fix
ilya-lavrenov Sep 9, 2021
2e9eb18
Merge remote-tracking branch 'upstream/master' into openvino-cmake-co…
ilya-lavrenov Sep 9, 2021
44f523c
Trying to fix ONNX ngraph .tox CI
ilya-lavrenov Sep 9, 2021
97be889
Trying to remove spaces
ilya-lavrenov Sep 9, 2021
d0e7573
Fixed ngraph_DIR -> OpenVINO_DIR
ilya-lavrenov Sep 9, 2021
30e4105
Removed junk files
ilya-lavrenov Sep 10, 2021
e1940a7
Merge remote-tracking branch 'upstream/master' into openvino-cmake-co…
ilya-lavrenov Sep 10, 2021
c7f8f03
Try to fix ngraph wheel
ilya-lavrenov Sep 10, 2021
1d61994
Try to fix ie_wheel
ilya-lavrenov Sep 10, 2021
4b24008
Try to fix ngraph wheel
ilya-lavrenov Sep 10, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/openvino-onnx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ RUN make -j $(nproc) install

# Run tests via tox
WORKDIR /openvino/runtime/bindings/python
ENV ngraph_DIR=/openvino/dist/deployment_tools/ngraph
ENV OpenVINO_DIR=/openvino/dist/deployment_tools/inference_engine/share
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a temporary change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenVINO_DIR is permanent, path will be changed in future.

ENV LD_LIBRARY_PATH=/openvino/dist/deployment_tools/ngraph/lib
ENV PYTHONPATH=/openvino/bin/intel64/${BUILD_TYPE}/lib/python_api/python3.8:${PYTHONPATH}
CMD tox
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ message (STATUS "CMAKE_BUILD_TYPE ...................... " ${CMAKE_BUILD_TYPE})

# remove file with exported developer targets to force its regeneration
file(REMOVE "${CMAKE_BINARY_DIR}/InferenceEngineTargets.cmake")
file(REMOVE "${CMAKE_BINARY_DIR}/OpenVINOTargets.cmake")
foreach(component IN LISTS openvino_export_components)
file(REMOVE "${CMAKE_BINARY_DIR}/${component}_dev_targets.cmake")
unset(${component} CACHE)
Expand Down Expand Up @@ -83,13 +84,14 @@ include(cmake/test_model_zoo.cmake)
add_subdirectory(thirdparty)
add_subdirectory(openvino)
add_subdirectory(ngraph)

add_subdirectory(runtime)
add_subdirectory(inference-engine)

# for Template plugin
openvino_developer_export_targets(COMPONENT ngraph TARGETS ngraph_backend interpreter_backend)
include(cmake/extra_modules.cmake)

add_subdirectory(runtime)
add_subdirectory(model-optimizer)
add_subdirectory(docs)
add_subdirectory(tools)
Expand Down
19 changes: 19 additions & 0 deletions cmake/templates/InferenceEngineConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,25 @@ _ie_find_dependency(ngraph
if(NOT TARGET inference_engine)
set(_ie_as_external_package ON)
include("${CMAKE_CURRENT_LIST_DIR}/InferenceEngineTargets.cmake")

# create targets with old names for compatibility
if(TARGET IE::runtime AND NOT TARGET IE::inference_engine)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change prefix to OV? OV::runtime

add_library(IE::inference_engine INTERFACE IMPORTED)
set_target_properties(IE::inference_engine PROPERTIES
INTERFACE_LINK_LIBRARIES IE::runtime)
endif()

if(TARGET IE::core AND NOT TARGET ngraph::ngraph)
add_library(IE::ngraph INTERFACE IMPORTED)
set_target_properties(IE::ngraph PROPERTIES
INTERFACE_LINK_LIBRARIES IE::core)
endif()

if(TARGET IE::runtime::c AND NOT TARGET IE::inference_engine_c_api)
add_library(IE::inference_engine_c_api INTERFACE IMPORTED)
set_target_properties(IE::inference_engine_c_api PROPERTIES
INTERFACE_LINK_LIBRARIES IE::runtime::c)
endif()
endif()

# mark components as available
Expand Down
11 changes: 9 additions & 2 deletions cmake/templates/InferenceEngineDeveloperPackageConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,17 @@ find_dependency(InferenceEngine
NO_CMAKE_FIND_ROOT_PATH
NO_DEFAULT_PATH)

find_dependency(OpenVINO
PATHS "${CMAKE_CURRENT_LIST_DIR}"
NO_CMAKE_FIND_ROOT_PATH
NO_DEFAULT_PATH)

# WA for cmake: it exports ngraph as IE::ngraph in the IE export list
# while we already have ngraph export in its own export list as ngraph::ngraph
set_property(TARGET ngraph::ngraph PROPERTY IMPORTED_GLOBAL TRUE)
add_library(IE::ngraph ALIAS ngraph::ngraph)
if(TARGET ngraph::ngraph AND NOT TARGET IE::ngraph)
add_library(IE::ngraph INTERFACE IMPORTED)
set_target_properties(IE::ngraph PROPERTIES INTERFACE_LINK_LIBRARIES ngraph::ngraph)
endif()

foreach(component @openvino_export_components@)
include("${CMAKE_CURRENT_LIST_DIR}/${component}_dev_targets.cmake")
Expand Down
21 changes: 21 additions & 0 deletions cmake/templates/OpenVINOConfig-version.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#

set(PACKAGE_VERSION_MAJOR @IE_VERSION_MAJOR@)
set(PACKAGE_VERSION_MINOR @IE_VERSION_MINOR@)
set(PACKAGE_VERSION_PATCH @IE_VERSION_PATCH@)
set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}")

set(PACKAGE_VERSION_EXACT False)
set(PACKAGE_VERSION_COMPATIBLE False)

if(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
set(PACKAGE_VERSION_EXACT True)
set(PACKAGE_VERSION_COMPATIBLE True)
endif()

if(PACKAGE_FIND_VERSION_MAJOR EQUAL PACKAGE_VERSION_MAJOR AND
PACKAGE_FIND_VERSION VERSION_LESS PACKAGE_VERSION)
set(PACKAGE_VERSION_COMPATIBLE True)
endif()
203 changes: 203 additions & 0 deletions cmake/templates/OpenVINOConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# FindOpenVINO
# ------
#
# Provides OpenVINO runtime for model creation and inference, frontend libraries
# to convert models from framework specific formats.
#
# The following components are supported:
#
# * `Runtime`: OpenVINO C++ and C Core & Inference Runtime, frontend manager
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a Core as a separate component?

# * `ONNX`: OpenVINO ONNX frontend
# * `PaddlePaddle`: OpenVINO PaddlePaddle frontend
#
# If no components are specified, `Runtime` component is provided:
#
# find_package(OpenVINO REQUIRED) # only Runtime component
#
# If specific components are required:
#
# find_package(OpenVINO REQUIRED COMPONENTS Runtime ONNX)
#
# Imported Targets:
# ------
#
# Runtime targets:
#
# `openvino::runtime`
# The OpenVINO C++ Core & Inference Runtime
#
# `openvino::runtime::c`
# The OpenVINO C Inference Runtime
#
# `openvino::core`
# The OpenVINO C++ Core Runtime
#
# Frontend specific targets:
#
# `openvino::frontend::manager`
# OpenVINO frontend manager
#
# `openvino::frontend::onnx`
# ONNX FrontEnd target (optional)
#
# `openvino::frontend::paddlepaddle`
# PaddlePaddle FrontEnd target (optional)
#
# Result variables:
# ------
#
# The module sets the following variables in your project:
#
# `OpenVINO_FOUND`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if user wants to use nGraph without the runtime?

# System has OpenVINO Runtime installed
#
# `OpenVINO_Runtime_FOUND`
# OpenVINO C++ Core & Inference Runtime is available
#
# `OpenVINO_Frontend_ONNX_FOUND`
# OpenVINO ONNX frontend is available
#
# `OpenVINO_Frontend_PaddlePaddle_FOUND`
# OpenVINO PaddlePaddle frontend is available
#
# OpenVINO version variables:
#
# `OpenVINO_VERSION_MAJOR`
# Major version component
#
# `OpenVINO_VERSION_MINOR`
# minor version component
#
# `OpenVINO_VERSION_PATCH`
# Patch version component
#

@PACKAGE_INIT@

#
# Common functions
#

if(NOT DEFINED CMAKE_FIND_PACKAGE_NAME)
set(CMAKE_FIND_PACKAGE_NAME OpenVINO)
set(_need_package_name_reset ON)
endif()

# we have to use our own version of find_dependency because of support cmake 3.7
macro(_ov_find_dependency dep)
set(cmake_fd_quiet_arg)
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
set(cmake_fd_quiet_arg QUIET)
endif()
set(cmake_fd_required_arg)
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
set(cmake_fd_required_arg REQUIRED)
endif()

get_property(cmake_fd_alreadyTransitive GLOBAL PROPERTY
_CMAKE_${dep}_TRANSITIVE_DEPENDENCY)

find_package(${dep} ${ARGN}
${cmake_fd_quiet_arg}
${cmake_fd_required_arg})

if(NOT DEFINED cmake_fd_alreadyTransitive OR cmake_fd_alreadyTransitive)
set_property(GLOBAL PROPERTY _CMAKE_${dep}_TRANSITIVE_DEPENDENCY TRUE)
endif()

if(NOT ${dep}_FOUND)
set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "${CMAKE_FIND_PACKAGE_NAME} could not be found because dependency ${dep} could not be found.")
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND False)
return()
endif()

set(cmake_fd_required_arg)
set(cmake_fd_quiet_arg)
endmacro()

function(_ov_target_no_deprecation_error)
if(NOT MSVC)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
set(flags "-diag-warning=1786")
else()
set(flags "-Wno-error=deprecated-declarations")
endif()
if(CMAKE_CROSSCOMPILING)
set_target_properties(${ARGV} PROPERTIES
INTERFACE_LINK_OPTIONS "-Wl,--allow-shlib-undefined")
endif()

set_target_properties(${ARGV} PROPERTIES INTERFACE_COMPILE_OPTIONS ${flags})
endif()
endfunction()

#
# OpenVINO config
#

# need to store current PACKAGE_PREFIX_DIR, because it's overwritten by sub-package one
set(_ov_package_prefix_dir "${PACKAGE_PREFIX_DIR}")

set(THREADING "@THREADING@")
if(THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO" AND NOT TBB_FOUND)
set_and_check(_tbb_dir "@PACKAGE_IE_TBB_DIR@")
_ov_find_dependency(TBB
COMPONENTS tbb tbbmalloc
CONFIG
PATHS ${TBBROOT}/cmake
${_tbb_dir}
NO_CMAKE_FIND_ROOT_PATH
NO_DEFAULT_PATH)
endif()

if(NOT TARGET inference_engine)
set(_ov_as_external_package ON)
include("${CMAKE_CURRENT_LIST_DIR}/OpenVINOTargets.cmake")
endif()

#
# Components
#

set(${CMAKE_FIND_PACKAGE_NAME}_Runtime_FOUND ON)

set(${CMAKE_FIND_PACKAGE_NAME}_ONNX_FOUND @NGRAPH_ONNX_FRONTEND_ENABLE@)
set(${CMAKE_FIND_PACKAGE_NAME}_PaddlePaddle_FOUND @NGRAPH_PDPD_FRONTEND_ENABLE@)

set(${CMAKE_FIND_PACKAGE_NAME}_Frontend_ONNX_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_ONNX_FOUND})
set(${CMAKE_FIND_PACKAGE_NAME}_Frontend_PaddlePaddle_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_PaddlePaddle_FOUND})

# if no components specified, only Runtime is provided
if(NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS)
set(${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS Runtime)
endif()

#
# Apply common functions
#

foreach(target openvino::runtime openvino::runtime::c openvino::core
openvino::frontend::manager openvino::frontend::onnx
openvino::frontend::paddlepaddle)
if(TARGET ${target} AND _ov_as_external_package)
_ov_target_no_deprecation_error(${target})
endif()
endforeach()
unset(_ov_as_external_package)

# restore PACKAGE_PREFIX_DIR
set(PACKAGE_PREFIX_DIR ${_ov_package_prefix_dir})
unset(_ov_package_prefix_dir)

check_required_components(${CMAKE_FIND_PACKAGE_NAME})

if(_need_package_name_reset)
unset(CMAKE_FIND_PACKAGE_NAME)
unset(_need_package_name_reset)
endif()

unset(${CMAKE_FIND_PACKAGE_NAME}_PaddlePaddle_FOUND)
unset(${CMAKE_FIND_PACKAGE_NAME}_ONNX_FOUND)
32 changes: 28 additions & 4 deletions cmake/templates/ngraphConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,50 @@

if(NOT TARGET ngraph)
include("${CMAKE_CURRENT_LIST_DIR}/ngraphTargets.cmake")

# create targets with old names for compatibility
if(TARGET ngraph::core AND NOT TARGET ngraph::ngraph)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not openvino::core?

add_library(ngraph::ngraph INTERFACE IMPORTED)
set_target_properties(ngraph::ngraph PROPERTIES
INTERFACE_LINK_LIBRARIES ngraph::core)
endif()

if(TARGET ngraph::frontend::manager AND NOT TARGET ngraph::frontend_manager)
add_library(ngraph::frontend_manager INTERFACE IMPORTED)
set_target_properties(ngraph::frontend_manager PROPERTIES
INTERFACE_LINK_LIBRARIES ngraph::frontend::manager)
endif()

if(TARGET ngraph::frontend::onnx AND NOT TARGET ngraph::onnx_ngraph_frontend)
add_library(ngraph::onnx_ngraph_frontend INTERFACE IMPORTED)
set_target_properties(ngraph::onnx_ngraph_frontend PROPERTIES
INTERFACE_LINK_LIBRARIES ngraph::frontend::onnx)
endif()

if(TARGET ngraph::frontend::paddlepaddle AND NOT TARGET ngraph::paddlepaddle_ngraph_frontend)
add_library(ngraph::paddlepaddle_ngraph_frontend INTERFACE IMPORTED)
set_target_properties(ngraph::paddlepaddle_ngraph_frontend PROPERTIES
INTERFACE_LINK_LIBRARIES ngraph::frontend::paddlepaddle)
endif()
endif()

set(ngraph_ngraph_FOUND ON)
set(NGRAPH_LIBRARIES ngraph::ngraph)

set(ngraph_onnx_ngraph_frontend_FOUND @NGRAPH_ONNX_FRONTEND_ENABLE@)

# ngraph::onnx_importer target and variables are deprecated
set(ngraph_onnx_importer_FOUND @NGRAPH_ONNX_FRONTEND_ENABLE@)
if(ngraph_onnx_importer_FOUND)
set(ONNX_IMPORTER_LIBRARIES ngraph::onnx_ngraph_frontend)
# ngraph::onnx_importer target and variables are deprecated
# but need to create a dummy target for BW compatibility
if(NOT TARGET ngraph::onnx_importer)
add_library(ngraph::onnx_importer INTERFACE IMPORTED)
set_target_properties(ngraph::onnx_importer PROPERTIES
INTERFACE_LINK_LIBRARIES ngraph::onnx_ngraph_frontend
)
INTERFACE_LINK_LIBRARIES ngraph::onnx_ngraph_frontend)
endif()
endif()

set(ngraph_paddlepaddle_frontend_FOUND @NGRAPH_PDPD_FRONTEND_ENABLE@)
set(ir_frontend_FOUND @IR_FRONTEND_ENABLE@)

check_required_components(ngraph)
18 changes: 5 additions & 13 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,12 @@ if(NOT ENABLE_DOCKER)

add_subdirectory(snippets)

# Detect nGraph
find_package(ngraph QUIET
PATHS "${CMAKE_BINARY_DIR}/ngraph"
NO_DEFAULT_PATH)
if(NOT ngraph_FOUND)
set(ngraph_DIR ${CMAKE_BINARY_DIR}/ngraph)
endif()

# Detect InferenceEngine
find_package(InferenceEngine QUIET
# Detect OpenVINO
find_package(OpenVINO QUIET
PATHS "${CMAKE_BINARY_DIR}"
NO_DEFAULT_PATH)
if(NOT InferenceEngine_FOUND)
set(InferenceEngine_DIR ${CMAKE_BINARY_DIR})
if(NOT OpenVINO_FOUND)
set(OpenVINO_DIR ${CMAKE_BINARY_DIR})
endif()

if(NGRAPH_ONNX_FRONTEND_ENABLE)
Expand Down Expand Up @@ -72,7 +64,7 @@ function(build_docs)
set(C_API "${IE_SOURCE_DIR}/ie_bridges/c/include")
set(PLUGIN_API_DIR "${DOCS_BUILD_DIR}/IE_PLUGIN_DG")
set(NGRAPH_DIR "${OpenVINO_SOURCE_DIR}/ngraph")
set(NGRAPH_PY_DIR "${NGRAPH_DIR}/python/src/ngraph/")
set(NGRAPH_PY_DIR "${OpenVINO_SOURCE_DIR}/runtime/bindings/python/src/compatibility/ngraph/")
set(NGRAPH_CPP_DIR "${NGRAPH_DIR}/core/include/" "${NGRAPH_DIR}/frontend/onnx_import/include")

# Preprocessing scripts
Expand Down
Loading