diff options
Diffstat (limited to 'runtimes/contrib/android_tflite/CMakeLists.txt')
-rw-r--r-- | runtimes/contrib/android_tflite/CMakeLists.txt | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/runtimes/contrib/android_tflite/CMakeLists.txt b/runtimes/contrib/android_tflite/CMakeLists.txt new file mode 100644 index 000000000..7e8d211cf --- /dev/null +++ b/runtimes/contrib/android_tflite/CMakeLists.txt @@ -0,0 +1,45 @@ +if(NOT BUILD_ANDROID_TFLITE) + return() +endif(NOT BUILD_ANDROID_TFLITE) + +nnfw_find_package(TensorFlowLite REQUIRED) + +# TODO Set this as system-level global configuration on android build +if(NOT DEFINED NDK_DIR) + file(GLOB NDK_DIRS "${CMAKE_SOURCE_DIR}/tools/cross/ndk/*") + list(LENGTH NDK_DIRS NDK_DIRS_COUNT) + if (NDK_DIRS_COUNT EQUAL 1) + set(NDK_DIR "${NDK_DIRS}") + endif(NDK_DIRS_COUNT EQUAL 1) +endif(NOT DEFINED NDK_DIR) + +if(NOT DEFINED NDK_DIR) + message(FATAL_ERROR "NDK_DIR should be specified via environment variable") +endif() +message(STATUS "Found NDK: ${NDK_DIR}") +target_include_directories(tensorflow-lite SYSTEM PUBLIC "${NDK_DIR}") +target_link_libraries(tensorflow-lite log) + +# +# 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 eigen ${LIB_PTHREAD} dl) +target_link_libraries(tensorflowlite_jni log) +install(TARGETS tensorflowlite_jni DESTINATION lib) |