Skip to content

Commit

Permalink
fix: Link libtensorflowlite_jni.so
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed Aug 22, 2023
1 parent 8fe5387 commit e5c66e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ set (CMAKE_CXX_STANDARD 17)
find_package(ReactAndroid REQUIRED CONFIG)
find_package(fbjni REQUIRED CONFIG)

find_library(
TFLITE
tensorflowlite_jni
PATHS "./src/main/cpp/lib/tensorflow/jni/${ANDROID_ABI}"
NO_DEFAULT_PATH
NO_CMAKE_FIND_ROOT_PATH)

string(APPEND CMAKE_CXX_FLAGS " -DANDROID")

add_library(
Expand All @@ -27,6 +34,7 @@ target_include_directories(
"../cpp"
"src/main/cpp"
"src/main/cpp/lib/tensorflow/headers/"
"../tensorflow/"
"${NODE_MODULES_DIR}/react-native/ReactCommon"
"${NODE_MODULES_DIR}/react-native/ReactCommon/callinvoker"
"${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/jni/react/turbomodule" # <-- CallInvokerHolder JNI wrapper
Expand All @@ -40,4 +48,5 @@ target_link_libraries(
ReactAndroid::jsi # <-- jsi.h
ReactAndroid::reactnativejni # <-- CallInvokerImpl
fbjni::fbjni # <-- fbjni.h
${TFLITE}
)
2 changes: 1 addition & 1 deletion cpp/TensorflowPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ TensorflowPlugin::TensorflowPlugin(TfLiteInterpreter* interpreter,
Buffer model,
Delegate delegate,
std::shared_ptr<react::CallInvoker> callInvoker):
_interpreter(interpreter), _model(model), _delegate(delegate), _callInvoker(callInvoker) {
_interpreter(interpreter), _delegate(delegate), _model(model), _callInvoker(callInvoker) {
// Allocate memory for the model's input/output `TFLTensor`s.
TfLiteStatus status = TfLiteInterpreterAllocateTensors(_interpreter);
if (status != kTfLiteOk) {
Expand Down

0 comments on commit e5c66e5

Please sign in to comment.