Introduce TensorFlow Lite 1.12 package (#2820)
author박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Fri, 11 Jan 2019 08:05:41 +0000 (17:05 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Fri, 11 Jan 2019 08:05:41 +0000 (17:05 +0900)
This commit introduces TensorFlow Lite 1.12 package.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
cmake/packages/TensorFlowLite-1.12/Lite/CMakeLists.txt [new file with mode: 0644]
cmake/packages/TensorFlowLite-1.12/TensorFlowLiteConfig.cmake [new file with mode: 0644]
cmake/packages/TensorFlowLite-1.12/TensorFlowLiteConfigVersion.cmake [new file with mode: 0644]

diff --git a/cmake/packages/TensorFlowLite-1.12/Lite/CMakeLists.txt b/cmake/packages/TensorFlowLite-1.12/Lite/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a3edba9
--- /dev/null
@@ -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 (file)
index 0000000..6febbf0
--- /dev/null
@@ -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 (file)
index 0000000..4a57b65
--- /dev/null
@@ -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)