From a5d155d825ca1bd2d9f6052b09435ca7c820248c Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/On-Device=20Lab=28SR=29/Staff?= =?utf8?q?=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Fri, 11 Jan 2019 17:05:41 +0900 Subject: [PATCH] Introduce TensorFlow Lite 1.12 package (#2820) This commit introduces TensorFlow Lite 1.12 package. Signed-off-by: Jonghyun Park --- .../TensorFlowLite-1.12/Lite/CMakeLists.txt | 40 +++++++++++++++ .../TensorFlowLite-1.12/TensorFlowLiteConfig.cmake | 59 ++++++++++++++++++++++ .../TensorFlowLiteConfigVersion.cmake | 9 ++++ 3 files changed, 108 insertions(+) create mode 100644 cmake/packages/TensorFlowLite-1.12/Lite/CMakeLists.txt create mode 100644 cmake/packages/TensorFlowLite-1.12/TensorFlowLiteConfig.cmake create mode 100644 cmake/packages/TensorFlowLite-1.12/TensorFlowLiteConfigVersion.cmake diff --git a/cmake/packages/TensorFlowLite-1.12/Lite/CMakeLists.txt b/cmake/packages/TensorFlowLite-1.12/Lite/CMakeLists.txt new file mode 100644 index 0000000..a3edba9 --- /dev/null +++ b/cmake/packages/TensorFlowLite-1.12/Lite/CMakeLists.txt @@ -0,0 +1,40 @@ +# NOTE The followings SHOULD be defined before using this CMakeLists.txt +# +# 'TensorFlowSource_DIR' variable +# 'eigen' target +# 'gemmlowp' target +# 'neon2sse' target +# 'farmhash' target +# 'flatbuffers' target +# 'abseil' target +# +message(STATUS "Build TensorFlow Lite from ${TensorFlowSource_DIR}") + +set(TensorFlowLiteSource_DIR ${TensorFlowSource_DIR}/tensorflow/contrib/lite) + +file(GLOB CORE_SRCS "${TensorFlowLiteSource_DIR}/*.c" "${TensorFlowLiteSource_DIR}/*.cc" "${TensorFlowLiteSource_DIR}/c/*.c" "${TensorFlowLiteSource_DIR}/core/api/*.cc") +file(GLOB_RECURSE CORE_TESTS "${TensorFlowLiteSource_DIR}/*test*.cc") +list(REMOVE_ITEM CORE_SRCS ${CORE_TESTS}) + +file(GLOB_RECURSE KERNEL_SRCS "${TensorFlowLiteSource_DIR}/kernels/*.cc") +file(GLOB_RECURSE KERNEL_TESTS "${TensorFlowLiteSource_DIR}/kernels/*test*.cc") +list(REMOVE_ITEM KERNEL_SRCS ${KERNEL_TESTS}) +# Exclude buggy kernel(s) from the build +#list(REMOVE_ITEM KERNEL_SRCS "${TensorFlowLiteSource_DIR}/kernels/internal/spectrogram.cc") + +list(APPEND SRCS ${CORE_SRCS}) +list(APPEND SRCS ${KERNEL_SRCS}) + +include(CheckCXXCompilerFlag) + +CHECK_CXX_COMPILER_FLAG(-Wno-extern-c-compat COMPILER_SUPPORT_EXTERN_C_COMPAT_WARNING) + +add_library(tensorflowlite-1.12 ${SRCS}) +set_target_properties(tensorflowlite-1.12 PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_include_directories(tensorflowlite-1.12 PUBLIC ${TensorFlowSource_DIR}) +target_compile_options(tensorflowlite-1.12 PUBLIC -Wno-ignored-attributes) +if(COMPILER_SUPPORT_EXTERN_C_COMPAT_WARNING) + target_compile_options(tensorflowlite-1.12 PUBLIC -Wno-extern-c-compat) +endif(COMPILER_SUPPORT_EXTERN_C_COMPAT_WARNING) +target_compile_definitions(tensorflowlite-1.12 PUBLIC "GEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK") +target_link_libraries(tensorflowlite-1.12 eigen gemmlowp neon2sse farmhash flatbuffers abseil dl) diff --git a/cmake/packages/TensorFlowLite-1.12/TensorFlowLiteConfig.cmake b/cmake/packages/TensorFlowLite-1.12/TensorFlowLiteConfig.cmake new file mode 100644 index 0000000..6febbf0 --- /dev/null +++ b/cmake/packages/TensorFlowLite-1.12/TensorFlowLiteConfig.cmake @@ -0,0 +1,59 @@ +function(_TensorFlowLite_import) + nncc_find_package(TensorFlowSource EXACT 1.12 QUIET) + + if(NOT TensorFlowSource_FOUND) + set(TensorFlowLite_FOUND FALSE PARENT_SCOPE) + return() + endif(NOT TensorFlowSource_FOUND) + + nncc_find_package(FlatBuffers QUIET) + + if(NOT FlatBuffers_FOUND) + set(TensorFlowLite_FOUND FALSE PARENT_SCOPE) + return() + endif(NOT FlatBuffers_FOUND) + + nncc_find_package(Farmhash QUIET) + + if(NOT Farmhash_FOUND) + set(TensorFlowLite_FOUND FALSE PARENT_SCOPE) + return() + endif(NOT Farmhash_FOUND) + + nncc_find_package(Eigen QUIET) + + if(NOT Eigen_FOUND) + set(TensorFlowLite_FOUND FALSE PARENT_SCOPE) + return() + endif(NOT Eigen_FOUND) + + nncc_find_package(GEMMLowp QUIET) + + if(NOT GEMMLowp_FOUND) + set(TensorFlowLite_FOUND FALSE PARENT_SCOPE) + return() + endif(NOT GEMMLowp_FOUND) + + nncc_find_package(NEON2SSE QUIET) + + if(NOT NEON2SSE_FOUND) + set(TensorFlowLite_FOUND FALSE PARENT_SCOPE) + return() + endif(NOT NEON2SSE_FOUND) + + nncc_find_package(Abseil QUIET) + + if(NOT Abseil_FOUND) + set(TensorFlowLite_FOUND FALSE PARENT_SCOPE) + return() + endif(NOT Abseil_FOUND) + + if(NOT TARGET tensorflowlite-1.12) + nncc_include(ExternalProjectTools) + add_extdirectory("${CMAKE_CURRENT_LIST_DIR}/Lite" tflite-1.12) + endif(NOT TARGET tensorflowlite-1.12) + + set(TensorFlowLite_FOUND TRUE PARENT_SCOPE) +endfunction(_TensorFlowLite_import) + +_TensorFlowLite_import() diff --git a/cmake/packages/TensorFlowLite-1.12/TensorFlowLiteConfigVersion.cmake b/cmake/packages/TensorFlowLite-1.12/TensorFlowLiteConfigVersion.cmake new file mode 100644 index 0000000..4a57b65 --- /dev/null +++ b/cmake/packages/TensorFlowLite-1.12/TensorFlowLiteConfigVersion.cmake @@ -0,0 +1,9 @@ +set(PACKAGE_VERSION "1.12") +set(PACKAGE_VERSION_EXACT FALSE) +set(PACKAGE_VERSION_COMPATIBLE FALSE) +set(PACKAGE_VERSION_UNSUITABLE TRUE) + +if(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT TRUE) + set(PACKAGE_VERSION_UNSUITABLE FALSE) +endif(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION) -- 2.7.4