From d300152256ea9f906b23201c01a3b12f148bb518 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Senior=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Thu, 3 May 2018 14:34:03 +0900 Subject: [PATCH] Add 'TensorFlowLite' as an external module (#188) This commit adds 'TensorFlowLite' external module which builds a 'libtensorflowlite.a' from TensorFlow Lite source. Signed-off-by: Jonghyun Park --- cmake/packages/TensorFlowLiteConfig.cmake | 70 +++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 cmake/packages/TensorFlowLiteConfig.cmake diff --git a/cmake/packages/TensorFlowLiteConfig.cmake b/cmake/packages/TensorFlowLiteConfig.cmake new file mode 100644 index 0000000..36395ce --- /dev/null +++ b/cmake/packages/TensorFlowLiteConfig.cmake @@ -0,0 +1,70 @@ +function(_TensorFlowLite_import) + nncc_find_package(TensorFlowSource 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) + + set(TensorFlowLiteSource_DIR ${TensorFlowSource_DIR}/tensorflow/contrib/lite) + + file(GLOB CORE_SRCS "${TensorFlowLiteSource_DIR}/*.c" "${TensorFlowLiteSource_DIR}/*.cc") + file(GLOB 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}) + + if(NOT TARGET tensorflowlite) + add_library(tensorflowlite ${SRCS}) + target_include_directories(tensorflowlite PUBLIC ${TensorFlowSource_DIR}) + target_compile_options(tensorflowlite PUBLIC -Wno-ignored-attributes) + target_compile_definitions(tensorflowlite PUBLIC "GEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK") + target_link_libraries(tensorflowlite eigen gemmlowp neon2sse farmhash flatbuffers dl) + endif(NOT TARGET tensorflowlite) + + set(TensorFlowLite_FOUND TRUE PARENT_SCOPE) +endfunction(_TensorFlowLite_import) + +_TensorFlowLite_import() -- 2.7.4