* Infrastructure for tflite * Removed submodule flatbuffers * Added flatbuffers submodule. Fixed version to v22.12.06 aka acf39ff * Move headers back * Flatbuffers integration * Small fixes * Started parsing the Model * flatbuffer changes * decoder_flatbuffer changes * Lite Input Model -- not needed as of now but looks cool * Rolled back inherritance from ov::frontend::tensorflow::InputModel * Results are not treated as outputs, but its ok * Fix missplaced input vs output * Refactor * Load model op-by-op. Frontend API finalized * Debugging still, there are prints here and there. Decoder is not sane * Convolution with all attributes is translated and quantization is applied for inputs and constatants. TODO: quantize intermediate tensors, separate decoder specific logic? * Float ssd and posenet models are showing good accuracy * Need to refactor but work flawlessly * Telemetry and lightweight model cutting * Code style and test changes. Extensions supported * Quantization and style * Style refinements * Move onednn back * New portion of operations enabled * TFLite FE doesn't inherrit TF FE * Moved files to another directory * Rename header op_table.hpp to common_op_table.hpp for all files in src/frontends/tensorflow_common/src/op/ * Removed visability macroses * CMake changes * Unit-test execution in .ci * Update labeler.yml * Codeowners * Style check and fix * Static Build arrangement * Addressing the comments * install common headers to previous place * New approach with public decoder and graph_iterator * New approach with public decoder and graph_iterator * Move GraphIterator back * Comments addressed * Comments adressed * Preliminary TF FE README.md changes * Added target_compile_definitions OPENVINO_STATIC_LIBRARY for static build * Fixed conflicts and added TF to common places * Frontends use only openvino::core::dev API * Merged common tensorflow changes and made code build and work on selective number of models * Style * Rollback unnecessary changes from Tensorflow FE * Rollback unnecessary changes from Tensorflow Common * Minor refactor * cmake minor refactoring * Mixed commit * Style and merge fix * Low hanging fruit operations * Fix windows build * Refactor quantization parameters representation * license compliance. approved by OS PDT * copyrights in generic file * dependabot * labeler * Unit Test to be triggered in CI * cmake variables naming. corrected copyright years in copyrights/generic file * library renamed in .ci/ calls * Copyright year update * Set openvino-tf-frontend-maintainers as owner of /src/frontends/tensorflow_lite/ * Fixed flatc corss-compilation * Cleaned flatbuffers header usage * Nitpicks solved * Update cmake/templates/OpenVINOConfig.cmake.in * Compile with flatbuffers headers * Fixed "which is prefixed in the source directory" * Fixed typo in flatbuffers cmake * Removed flatbuffers submodule * Added fork submodule * Fixed static build * Fixed cross-compilatio * Fixed -Wshadow warning * Fixed warning on Windows * Use only headers from flatbuffers library * Added LTO and fixed compilation errors on Windows * Fixed warnings in tensorflow_common * Move ctors implementation to cpp file * Added information about new frontends to common FEm part * Temporaryily disable warnings * Fixed code style using clang-format * Fixed Windows * reverted changes in onnx * Revert changes in onnx_common * Removed pragma once frm cpp Co-authored-by: missjane <estepyreva@gmail.com> Co-authored-by: Ilya Lavrenov <ilya.lavrenov@intel.com>
352 lines
12 KiB
CMake
352 lines
12 KiB
CMake
# Copyright (C) 2018-2023 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 common
|
|
# * `ONNX`: OpenVINO ONNX frontend
|
|
# * `Paddle`: OpenVINO Paddle frontend
|
|
# * `PyTorch`: OpenVINO PyTorch frontend
|
|
# * `TensorFlow`: OpenVINO TensorFlow frontend
|
|
# * `TensorFlowLite`: OpenVINO TensorFlow Lite 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
|
|
#
|
|
# Frontend specific targets:
|
|
#
|
|
# `openvino::frontend::onnx`
|
|
# ONNX FrontEnd target (optional)
|
|
#
|
|
# `openvino::frontend::paddle`
|
|
# Paddle FrontEnd target (optional)
|
|
#
|
|
# `openvino::frontend::pytorch`
|
|
# PyTorch FrontEnd target (optional)
|
|
#
|
|
# `openvino::frontend::tensorflow`
|
|
# TensorFlow FrontEnd target (optional)
|
|
#
|
|
# `openvino::frontend::tensorflow_lite`
|
|
# TensorFlow Lite FrontEnd target (optional)
|
|
#
|
|
# Result variables:
|
|
# ------
|
|
#
|
|
# The module sets the following variables in your project:
|
|
#
|
|
# `OpenVINO_FOUND`
|
|
# System has OpenVINO Runtime installed
|
|
#
|
|
# `OpenVINO_Runtime_FOUND`
|
|
# OpenVINO C++ Core & Inference Runtime is available
|
|
#
|
|
# `OpenVINO_Frontend_ONNX_FOUND`
|
|
# OpenVINO ONNX frontend is available
|
|
#
|
|
# `OpenVINO_Frontend_Paddle_FOUND`
|
|
# OpenVINO Paddle frontend is available
|
|
#
|
|
# `OpenVINO_Frontend_PyTorch_FOUND`
|
|
# OpenVINO PyTorch frontend is available
|
|
#
|
|
# `OpenVINO_Frontend_TensorFlow_FOUND`
|
|
# OpenVINO TensorFlow frontend is available
|
|
#
|
|
# `OpenVINO_Frontend_TensorFlowLite_FOUND`
|
|
# OpenVINO TensorFlow Lite frontend is available
|
|
#
|
|
# `OpenVINO_Frontend_IR_FOUND`
|
|
# OpenVINO IR 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()
|
|
|
|
unset(cmake_fd_required_arg)
|
|
unset(cmake_fd_quiet_arg)
|
|
endmacro()
|
|
|
|
macro(_ov_find_tbb)
|
|
set(THREADING "@THREADING@")
|
|
if((THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO") AND NOT TBB_FOUND)
|
|
set(enable_pkgconfig_tbb "@tbb_FOUND@")
|
|
|
|
# try tbb.pc
|
|
if(enable_pkgconfig_tbb AND NOT ANDROID)
|
|
_ov_find_dependency(PkgConfig)
|
|
if(PkgConfig_FOUND)
|
|
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
|
|
set(pkg_config_quiet_arg QUIET)
|
|
endif()
|
|
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
|
|
set(pkg_config_required_arg REQUIRED)
|
|
endif()
|
|
|
|
pkg_search_module(tbb
|
|
${pkg_config_quiet_arg}
|
|
${pkg_config_required_arg}
|
|
IMPORTED_TARGET
|
|
tbb)
|
|
unset(pkg_config_quiet_arg)
|
|
unset(pkg_config_required_arg)
|
|
|
|
if(tbb_FOUND)
|
|
if(TARGET PkgConfig::tbb)
|
|
set(TBB_VERSION ${tbb_VERSION})
|
|
set(TBB_FOUND ${tbb_FOUND})
|
|
unset(tbb_FOUND)
|
|
unset(tbb_VERSION)
|
|
elseif(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
|
|
message(FATAL_ERROR "cmake v${CMAKE_VERSION} contains bug in function 'pkg_search_module', need to update to at least v3.16.0 version")
|
|
endif()
|
|
endif()
|
|
endif()
|
|
else()
|
|
# try cmake TBB interface
|
|
|
|
set(enable_system_tbb "@ENABLE_SYSTEM_TBB@")
|
|
if(NOT enable_system_tbb)
|
|
set_and_check(_tbb_dir "@PACKAGE_IE_TBB_DIR@")
|
|
|
|
# see https://stackoverflow.com/questions/28070810/cmake-generate-error-on-windows-as-it-uses-as-escape-seq
|
|
if(DEFINED ENV{TBBROOT})
|
|
file(TO_CMAKE_PATH $ENV{TBBROOT} ENV_TBBROOT)
|
|
endif()
|
|
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
|
|
set(_no_cmake_install_prefix NO_CMAKE_INSTALL_PREFIX)
|
|
endif()
|
|
|
|
set(find_package_tbb_extra_args
|
|
CONFIG
|
|
PATHS
|
|
# oneTBB case exposed via export TBBROOT=<custom TBB root>
|
|
"${ENV_TBBROOT}/lib64/cmake/TBB"
|
|
"${ENV_TBBROOT}/lib/cmake/TBB"
|
|
"${ENV_TBBROOT}/lib/cmake/tbb"
|
|
# for custom TBB exposed via cmake -DTBBROOT=<custom TBB root>
|
|
"${TBBROOT}/cmake"
|
|
# _tbb_dir points to TBB_DIR (custom | temp | system) used to build OpenVINO
|
|
${_tbb_dir}
|
|
CMAKE_FIND_ROOT_PATH_BOTH
|
|
NO_PACKAGE_ROOT_PATH
|
|
NO_SYSTEM_ENVIRONMENT_PATH
|
|
NO_CMAKE_PACKAGE_REGISTRY
|
|
NO_CMAKE_SYSTEM_PATH
|
|
${_no_cmake_install_prefix}
|
|
NO_CMAKE_SYSTEM_PACKAGE_REGISTRY)
|
|
unset(_tbb_dir)
|
|
unset(_no_cmake_install_prefix)
|
|
endif()
|
|
unset(enable_system_tbb)
|
|
|
|
_ov_find_dependency(TBB
|
|
COMPONENTS tbb tbbmalloc
|
|
${find_package_tbb_extra_args})
|
|
unset(find_package_tbb_extra_args)
|
|
endif()
|
|
unset(enable_pkgconfig_tbb)
|
|
|
|
set(install_tbbbind "@install_tbbbind@")
|
|
if(install_tbbbind)
|
|
set_and_check(_tbb_bind_dir "@PACKAGE_IE_TBBBIND_DIR@")
|
|
_ov_find_dependency(TBBBIND_2_5
|
|
PATHS ${_tbb_bind_dir}
|
|
NO_CMAKE_FIND_ROOT_PATH
|
|
NO_DEFAULT_PATH)
|
|
set_target_properties(${TBBBIND_2_5_IMPORTED_TARGETS} PROPERTIES IMPORTED_GLOBAL ON)
|
|
unset(_tbb_bind_dir)
|
|
endif()
|
|
unset(install_tbbbind)
|
|
endif()
|
|
endmacro()
|
|
|
|
macro(_ov_find_intel_gna_dependencies)
|
|
set(_OV_ENABLE_INTEL_GNA "@ENABLE_INTEL_GNA@")
|
|
if(_OV_ENABLE_INTEL_GNA AND NOT libGNA_FOUND)
|
|
set_and_check(GNA_PATH "@PACKAGE_GNA_PATH@")
|
|
_ov_find_dependency(libGNA
|
|
COMPONENTS KERNEL
|
|
CONFIG
|
|
PATHS "${CMAKE_CURRENT_LIST_DIR}"
|
|
NO_CMAKE_FIND_ROOT_PATH
|
|
NO_DEFAULT_PATH)
|
|
unset(GNA_PATH)
|
|
endif()
|
|
unset(_OV_ENABLE_INTEL_GNA)
|
|
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(_OV_ENABLE_OPENVINO_BUILD_SHARED "@BUILD_SHARED_LIBS@")
|
|
|
|
if(NOT _OV_ENABLE_OPENVINO_BUILD_SHARED)
|
|
_ov_find_tbb()
|
|
_ov_find_intel_gna_dependencies()
|
|
endif()
|
|
|
|
_ov_find_dependency(Threads)
|
|
|
|
unset(_OV_ENABLE_OPENVINO_BUILD_SHARED)
|
|
|
|
if(NOT TARGET openvino)
|
|
set(_ov_as_external_package ON)
|
|
include("${CMAKE_CURRENT_LIST_DIR}/OpenVINOTargets.cmake")
|
|
|
|
# WA for cmake version < 3.16 which does not export
|
|
# IMPORTED_LINK_DEPENDENT_LIBRARIES_** properties if no PUBLIC dependencies for the library
|
|
if((THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO") AND TBB_FOUND)
|
|
foreach(type RELEASE DEBUG RELWITHDEBINFO MINSIZEREL)
|
|
foreach(tbb_target TBB::tbb TBB::tbbmalloc PkgConfig::tbb)
|
|
if(TARGET ${tbb_target})
|
|
set_property(TARGET openvino::runtime APPEND PROPERTY IMPORTED_LINK_DEPENDENT_LIBRARIES_${type} "${tbb_target}")
|
|
endif()
|
|
endforeach()
|
|
endforeach()
|
|
endif()
|
|
unset(THREADING)
|
|
endif()
|
|
|
|
#
|
|
# Components
|
|
#
|
|
|
|
set(${CMAKE_FIND_PACKAGE_NAME}_Runtime_FOUND ON)
|
|
|
|
set(${CMAKE_FIND_PACKAGE_NAME}_ONNX_FOUND @ENABLE_OV_ONNX_FRONTEND@)
|
|
set(${CMAKE_FIND_PACKAGE_NAME}_Paddle_FOUND @ENABLE_OV_PADDLE_FRONTEND@)
|
|
set(${CMAKE_FIND_PACKAGE_NAME}_TensorFlow_FOUND @ENABLE_OV_TF_FRONTEND@)
|
|
set(${CMAKE_FIND_PACKAGE_NAME}_TensorFlowLite_FOUND @ENABLE_OV_TF_LITE_FRONTEND@)
|
|
set(${CMAKE_FIND_PACKAGE_NAME}_IR_FOUND @ENABLE_OV_IR_FRONTEND@)
|
|
set(${CMAKE_FIND_PACKAGE_NAME}_PyTorch_FOUND @ENABLE_OV_PYTORCH_FRONTEND@)
|
|
|
|
set(${CMAKE_FIND_PACKAGE_NAME}_Frontend_ONNX_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_ONNX_FOUND})
|
|
set(${CMAKE_FIND_PACKAGE_NAME}_Frontend_Paddle_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_Paddle_FOUND})
|
|
set(${CMAKE_FIND_PACKAGE_NAME}_Frontend_TensorFlow_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_TensorFlow_FOUND})
|
|
set(${CMAKE_FIND_PACKAGE_NAME}_Frontend_TensorFlowLite_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_TensorFlowLite_FOUND})
|
|
set(${CMAKE_FIND_PACKAGE_NAME}_Frontend_IR_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_IR_FOUND})
|
|
set(${CMAKE_FIND_PACKAGE_NAME}_Frontend_PyTorch_FOUND ${${CMAKE_FIND_PACKAGE_NAME}_PyTorch_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::frontend::onnx openvino::frontend::paddle openvino::frontend::tensorflow)
|
|
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}_IR_FOUND)
|
|
unset(${CMAKE_FIND_PACKAGE_NAME}_Paddle_FOUND)
|
|
unset(${CMAKE_FIND_PACKAGE_NAME}_ONNX_FOUND)
|
|
unset(${CMAKE_FIND_PACKAGE_NAME}_TensorFlow_FOUND)
|