From ba86c611cb7ef76e1ad41e9c507300be7b4e2a5c Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=84=B8=ED=9D=AC/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Principal=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Thu, 31 May 2018 10:24:49 +0900 Subject: [PATCH] Build Android TFLite JNI shared library (#1442) * Build Android TFLite JNI shared library This will change cmake to drop Android JNI including Tensorflow Lite - current drop will work same as vanilla TFLite library Signed-off-by: SaeHie Park * apply comments --- externals/CMakeLists.txt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index 5d038bf..004df65 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -50,3 +50,27 @@ add_library(tensorflow-lite ${TFLITE_SRCS}) target_include_directories(tensorflow-lite PUBLIC ${TFLITE_INCLUDES}) target_compile_definitions(tensorflow-lite PUBLIC "GEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK") target_link_libraries(tensorflow-lite eigen3 ${LIB_PTHREAD} dl) + +if("${TARGET_OS}" STREQUAL "android") + # + # Tensorflow Lite JNI library + # + set(TFLITE_JNI_BASE ${TENSORFLOW_LITE_BASE}/java/src/main/native) + set(TFLITE_JNI_SRCS ${TFLITE_JNI_BASE}/duration_utils_jni.cc + ${TFLITE_JNI_BASE}/exception_jni.cc + ${TFLITE_JNI_BASE}/nativeinterpreterwrapper_jni.cc + ${TFLITE_JNI_BASE}/tensor_jni.cc + ${TFLITE_JNI_BASE}/tensorflow_lite_jni.cc + ${TFLITE_JNI_BASE}/builtin_ops_jni.cc + ) + set(TFLITE_JNI_INCLUDES ${TENSORFLOW_LITE_BASE}/java/src/native) + + # We need this for running vanilla tflite + # TODO remove this when nnfw is used + set(TFLITE_SRCS_V ${TENSORFLOW_LITE_BASE}/kernels/register.cc) + + # TODO use tensorflow-lite static library instead of compiling all the sources again + add_library(tensorflowlite_jni SHARED ${TFLITE_JNI_SRCS} ${TFLITE_SRCS} ${TFLITE_SRCS_V}) + target_include_directories(tensorflowlite_jni PUBLIC ${TFLITE_JNI_INCLUDES} ${TFLITE_INCLUDES}) + target_link_libraries(tensorflowlite_jni eigen3 ${LIB_PTHREAD} dl) +endif() -- 2.7.4