[Android] change tflite option in JNI and build scripts accepted/tizen/unified/20240425.114346 accepted/tizen/unified/toolchain/20240427.045640 accepted/tizen/unified/x/20240426.050456
authorYelin Jeong <yelini.jeong@samsung.com>
Wed, 17 Apr 2024 06:54:47 +0000 (15:54 +0900)
committerjaeyun-jung <39614140+jaeyun-jung@users.noreply.github.com>
Thu, 25 Apr 2024 03:24:08 +0000 (12:24 +0900)
This patch changes tflite path usage in build.gradle and android build scripts.
This change is for nnstreamer/nnstreamer-android

Signed-off-by: Yelin Jeong <yelini.jeong@samsung.com>
java/android/nnstreamer/build.gradle
java/android/nnstreamer/src/main/jni/Android-tensorflow-lite.mk
java/android/nnstreamer/src/main/jni/Android.mk
java/build-nnstreamer-android.sh

index 351c73b..131e11c 100644 (file)
@@ -63,6 +63,16 @@ android {
                 targets "nnstreamer-native"
 
                 abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
+
+                def tfliteRoot
+
+                if (project.hasProperty('tfliteRoot'))
+                    tfliteRoot = project.tfliteRoot
+                else
+                    tfliteRoot = System.env.TFLITE_ROOT_ANDROID
+
+                if (tfliteRoot != null)
+                    arguments "TFLITE_ROOT_ANDROID=$tfliteRoot"
             }
         }
     }
index f1e37b0..d66f085 100644 (file)
@@ -76,7 +76,7 @@ ifeq ($(TFLITE_ENABLE_XNNPACK_DELEGATE),true)
 TFLITE_FLAGS += -DTFLITE_XNNPACK_DELEGATE_SUPPORTED=1
 endif
 
-TF_LITE_DIR := $(LOCAL_PATH)/tensorflow-lite
+TF_LITE_DIR := $(TFLITE_ROOT)
 TF_LITE_INCLUDES := $(TF_LITE_DIR)/include
 
 ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
index 1052752..f54eb46 100644 (file)
@@ -41,7 +41,17 @@ NNSTREAMER_API_OPTION := all
 ENABLE_TENSOR_QUERY := true
 
 # tensorflow-lite (nnstreamer tf-lite subplugin)
+ifdef TFLITE_ROOT_ANDROID
+ifneq ($(filter $(TARGET_ARCH_ABI), armeabi-v7a arm64-v8a),)
+TFLITE_ROOT        := $(TFLITE_ROOT_ANDROID)
+endif
+endif
+
+ifdef TFLITE_ROOT
+ENABLE_TF_LITE := true
+else
 ENABLE_TF_LITE := false
+endif
 
 # SNAP (Samsung Neural Acceleration Platform)
 ENABLE_SNAP := false
index 760e03e..f8233f7 100755 (executable)
@@ -578,10 +578,9 @@ fi
 
 # Update tf-lite option
 if [[ $enable_tflite == "yes" ]]; then
-    sed -i "s|ENABLE_TF_LITE := false|ENABLE_TF_LITE := true|" nnstreamer/src/main/jni/Android-nnstreamer-prebuilt.mk
-    sed -i "s|ENABLE_TF_LITE := false|ENABLE_TF_LITE := true|" nnstreamer/src/main/jni/Android.mk
     sed -i "s|TFLITE_VERSION := 2.8.1|TFLITE_VERSION := $tf_lite_ver|" nnstreamer/src/main/jni/Android-tensorflow-lite.mk
     tar -xJf ./external/tensorflow-lite-$tf_lite_ver.tar.xz -C ./nnstreamer/src/main/jni
+    export TFLITE_ROOT_ANDROID=$ml_api_dir/$build_dir/nnstreamer/src/main/jni/tensorflow-lite
 fi
 
 if [[ $enable_flatbuf == "yes" ]]; then