Files
openvino/thirdparty/CMakeLists.txt

209 lines
6.8 KiB
CMake
Raw Normal View History

# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
2021-07-16 18:55:05 +03:00
if(SUGGEST_OVERRIDE_SUPPORTED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-suggest-override")
endif()
if(ENABLE_LTO)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON)
endif()
add_subdirectory(ittapi)
add_subdirectory(itt_collector EXCLUDE_FROM_ALL)
add_subdirectory(zlib EXCLUDE_FROM_ALL)
add_subdirectory(cnpy EXCLUDE_FROM_ALL)
2021-09-23 18:42:19 +03:00
if(ENABLE_CLDNN)
add_subdirectory(ocl)
2021-09-23 18:42:19 +03:00
endif()
add_subdirectory(xbyak EXCLUDE_FROM_ALL)
openvino_developer_export_targets(COMPONENT openvino_common TARGETS xbyak)
ov_install_static_lib(xbyak openvino_common)
#
# Pugixml
#
if(ENABLE_SYSTEM_PUGIXML)
find_package(PugiXML REQUIRED)
set_property(TARGET pugixml PROPERTY IMPORTED_GLOBAL TRUE)
add_library(pugixml::static ALIAS pugixml)
else()
function(ie_build_pugixml)
function(ie_build_pugixml_static)
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(pugixml EXCLUDE_FROM_ALL)
endfunction()
ie_build_pugixml_static()
set_property(TARGET pugixml-static PROPERTY EXPORT_NAME pugixml)
openvino_developer_export_targets(COMPONENT openvino_common TARGETS pugixml::static)
ov_install_static_lib(pugixml-static openvino_common)
endfunction()
ie_build_pugixml()
endif()
#
# Fluid, G-API, OpenCV HAL
#
add_library(ocv_hal INTERFACE)
target_include_directories(ocv_hal INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/ocv")
add_subdirectory(ade EXCLUDE_FROM_ALL)
add_subdirectory(fluid/modules/gapi EXCLUDE_FROM_ALL)
set_target_properties(ade fluid PROPERTIES FOLDER thirdparty)
openvino_developer_export_targets(COMPONENT openvino_common TARGETS ade fluid)
ov_install_static_lib(ade openvino_common)
ov_install_static_lib(fluid openvino_common)
#
# Gflags
#
add_subdirectory(gflags EXCLUDE_FROM_ALL)
openvino_developer_export_targets(COMPONENT openvino_common TARGETS gflags)
#
# Google Tests framework
#
if(NGRAPH_UNIT_TEST_ENABLE OR ENABLE_TESTS)
add_subdirectory(gtest EXCLUDE_FROM_ALL)
openvino_developer_export_targets(COMPONENT inference_engine_tests
TARGETS gmock gmock_main gtest gtest_main)
endif()
2021-07-16 18:55:05 +03:00
#
# Protobuf
#
Merge TensorFlow Frontend Implementation (#7855) * Migrate POC for TensorFlow frontend Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Refactor InputModelTensorFlow API Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Repack POC to official API Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Remove tensorflow API from public include Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Make TF frontend work from MO and clean-up code Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Apply codestyle * Fix win biuld * Fix Linux build Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Implement Place class Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Determine outputs from graph * Implement all Place classes Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Make small clean-up Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Apply code-style corrections Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Determine cut nodes * Apply codestyle * Rework to use places * Fix conversion issue * Fix build * Fix conversion * Small fixes * Add test for tf frontend * Add tests * Implement partial conversion * Use dynamic type in TFFrameworkNode * Fix build on Linux * Implement InputModelTF class Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Fix code by replacing InputModelTensorFlow to InputModelTF Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Fix to pass getPlaceByTensorName test Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Refactor and clean the code Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Finalize refactoring code Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Support freezing inputs Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Add support for pruning input ports as new model output Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Apply code-style fixes Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * move op convertors to separate files, refactoring * openvino codestyle * openvino codestyle * fix crash of layer tests * fix missprint * Implement TensorFlow NodeContext and DecoderTFProto classes Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Switch to new NodeContext Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Remove ngraph_builder class and node_context_impl class Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Move decoder/graph_iterator to separate files and remove old files Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Document Decoder, GraphIterator, and NodeContext classes Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Apply code style Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Remove empty file graph_iterator_proto.cpp and redundant comments Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Use base class for GraphIterator in model class and correct exception class Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Use ends_with from util library * Remain only InputModelTF constructor with GraphIterator and adopt other code Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Correct code after merge Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Apply code style Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Fix code based on feedback: delete extra namespace usage, etc. Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Make legacy TF frontend default in MO and avoid reading tf models from ReadNetwork Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Fix build issue with FrameworkNode after upstream merge Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Correct frontend name in test and clean the code Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * refactoring of tf FrontEnd: rename namespaces, delete default opset * codestyle * fix e2e tests * change namespaces of external classes * resolve review comment * codestyle * Clean useless comments and fix tests Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Add copyright for proto files Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Make op translators a part of FrontEndTF Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Align CMakeLists.txt file with other frontends Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Add job_pool into CMakeLists.txt for tensorflow tests Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Remove cout and WA in ie_network_reader.cpp Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Correct DecoderBase and FrontEndTF methods, clean the code from if 0, utility.hpp, ngraph_conversions.hpp Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Clean operation translator code and remove empty implementation Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Extend cmake template files with tensorflow frontend Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Apply code-style Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Fix build issues on MacOS and apply review feedback Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Remove ConstantFolding pass, add destructors for DecoderBase, GraphIterator, and fix Win build Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Fix Windows build issue Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Apply code-style fix Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Fix issues with code style: remove virtual keyword, OpMap removal Signed-off-by: Roman Kazantsev <roman.kazantsev@intel.com> * Resolve review remarks * Resolve review remarks * codestyle * resolve review remarks * fix copyright * resolve review comments Co-authored-by: Maxim Vafin <maxim.vafin@intel.com> Co-authored-by: Ivan Tikhonov <ivan.tikhonov@intel.com>
2021-10-14 10:36:10 +03:00
if(NGRAPH_PDPD_FRONTEND_ENABLE OR NGRAPH_ONNX_FRONTEND_ENABLE OR NGRAPH_TF_FRONTEND_ENABLE)
2021-07-16 18:55:05 +03:00
if(NGRAPH_USE_SYSTEM_PROTOBUF)
2021-07-20 18:13:22 +03:00
set(Protobuf_USE_STATIC_LIBS ON)
if(VERBOSE_BUILD)
set(Protobuf_DEBUG ON)
endif()
find_package(Protobuf 3.9.0 REQUIRED)
set(Protobuf_LITE_LIBRARIES protobuf::libprotobuf-lite)
2021-07-20 18:13:22 +03:00
set(SYSTEM_PROTOC protobuf::protoc)
set(PROTOC_EXECUTABLE ${SYSTEM_PROTOC})
foreach(target ${SYSTEM_PROTOC} ${Protobuf_LITE_LIBRARIES})
2021-07-20 18:13:22 +03:00
set_property(TARGET ${target} PROPERTY IMPORTED_GLOBAL TRUE)
endforeach()
2021-07-16 18:55:05 +03:00
else()
add_subdirectory(protobuf)
endif()
# forward variables used in the other places
set(SYSTEM_PROTOC ${SYSTEM_PROTOC} PARENT_SCOPE)
2021-07-20 18:13:22 +03:00
set(PROTOC_EXECUTABLE ${PROTOC_EXECUTABLE} PARENT_SCOPE)
set(Protobuf_LITE_LIBRARIES ${Protobuf_LITE_LIBRARIES} PARENT_SCOPE)
2021-07-16 18:55:05 +03:00
set(Protobuf_INCLUDE_DIRS ${Protobuf_INCLUDE_DIRS} PARENT_SCOPE)
2021-07-20 18:13:22 +03:00
# set public / interface compile options
foreach(target IN LISTS Protobuf_LITE_LIBRARIES)
2021-07-20 18:13:22 +03:00
set(link_type PUBLIC)
if(NGRAPH_USE_SYSTEM_PROTOBUF)
set(link_type INTERFACE)
endif()
2021-07-21 13:56:55 +03:00
if(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG)
2021-07-20 18:13:22 +03:00
target_compile_options(${target} ${link_type} -Wno-undef)
endif()
endforeach()
2021-07-16 18:55:05 +03:00
endif()
#
# ONNX
#
if(NGRAPH_ONNX_FRONTEND_ENABLE)
2021-07-16 18:55:05 +03:00
add_subdirectory(onnx)
endif()
2021-09-21 09:48:16 +03:00
#
# oneDNN for GPU plugin
#
if(ENABLE_ONEDNN_FOR_GPU)
function(build_onednn_gpu)
include(ExternalProject)
set(ONEDNN_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/onednn_gpu_build/")
set(ONEDNN_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/onednn_gpu_install/")
set(ONEDNN_PREFIX_DIR "${CMAKE_CURRENT_BINARY_DIR}/onednn_gpu_root")
if(CMAKE_COMPILER_IS_GNUCXX)
ie_add_compiler_flags(-Wno-undef)
endif()
ExternalProject_Add(onednn_gpu_build
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/onednn_gpu"
BINARY_DIR "${ONEDNN_BUILD_DIR}"
INSTALL_DIR "${ONEDNN_INSTALL_DIR}"
PREFIX "${ONEDNN_PREFIX_DIR}"
EXCLUDE_FROM_ALL ON
CMAKE_ARGS
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
"-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}"
"-DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}"
"-DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}"
"-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}"
"-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}"
"-DCMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE=${ENABLE_LTO}"
"-DCMAKE_POLICY_DEFAULT_CMP0069=NEW"
"-DCMAKE_MSVC_RUNTIME_LIBRARY=${CMAKE_MSVC_RUNTIME_LIBRARY}"
"-DDNNL_CPU_RUNTIME=NONE"
"-DDNNL_GPU_RUNTIME=OCL"
"-DDNNL_LIBRARY_NAME=onednn_gpu"
"-DCMAKE_INSTALL_PREFIX=${ONEDNN_INSTALL_DIR}"
"-DCMAKE_INSTALL_LIBDIR=lib/$<CONFIG>"
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
"-DDNNL_ENABLE_CONCURRENT_EXEC=ON"
"-DDNNL_ENABLE_PRIMITIVE_CACHE=ON"
"-DDNNL_ENABLE_JIT_PROFILING=${BUILD_SHARED_LIBS}"
"-DDNNL_ENABLE_ITT_TASKS=${BUILD_SHARED_LIBS}"
"-DDNNL_BUILD_TESTS=OFF"
"-DDNNL_BUILD_EXAMPLES=OFF"
"-DDNNL_BLAS_VENDOR=NONE"
"-DDNNL_LIBRARY_TYPE=STATIC"
"-DOpenCL_LIBRARY=${OpenCL_LIBRARY}"
"-DOpenCL_INCLUDE_DIR=${OpenCL_INCLUDE_DIR}"
"-DOPENCL_VERSION_2_2=${OPENCL_VERSION_2_2}"
)
add_library(onednn_gpu_tgt INTERFACE)
set_target_properties(onednn_gpu_tgt PROPERTIES
INTERFACE_LINK_DIRECTORIES "${ONEDNN_INSTALL_DIR}/lib/$<CONFIG>"
INTERFACE_LINK_LIBRARIES "onednn_gpu"
INTERFACE_INCLUDE_DIRECTORIES "${ONEDNN_INSTALL_DIR}/include"
INTERFACE_COMPILE_DEFINITIONS ENABLE_ONEDNN_FOR_GPU
)
add_dependencies(onednn_gpu_tgt onednn_gpu_build)
# TODO: install onednn_gpu in static builds
2021-09-21 09:48:16 +03:00
endfunction()
build_onednn_gpu()
endif()
#
# Install
#
ie_cpack_add_component(cpp_samples_deps)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/gflags
DESTINATION "samples/cpp/thirdparty"
COMPONENT cpp_samples_deps
USE_SOURCE_PERMISSIONS)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/zlib
DESTINATION "samples/cpp/thirdparty"
COMPONENT cpp_samples_deps
USE_SOURCE_PERMISSIONS)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cnpy
DESTINATION "samples/cpp/thirdparty"
COMPONENT cpp_samples_deps
USE_SOURCE_PERMISSIONS)