From: 박종현/동작제어Lab(SR)/Senior Engineer/삼성전자 Date: Thu, 3 May 2018 05:34:03 +0000 (+0900) Subject: Add 'TensorFlowLite' as an external module (#188) X-Git-Tag: nncc_backup~2715 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d300152256ea9f906b23201c01a3b12f148bb518;p=platform%2Fcore%2Fml%2Fnnfw.git 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 --- 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()