Skip to content

Build Android binaries with GPU delegate

Amish Garg edited this page May 18, 2021 · 1 revision

Author: @applikationsprogramvara

Building

I added the following lines at the end of this file

tflite_jni_binary(
    name = "libtensorflowlite_jni_normal_with_gpu.so", # <-- the new name here
    linkscript = ":tflite_version_script.lds",
    deps = [
        "//tensorflow/lite/c:c_api",
        "//tensorflow/lite/c:c_api_experimental",
        "//tensorflow/lite/delegates/nnapi/java/src/main/native",
        "//tensorflow/lite/delegates/xnnpack:xnnpack_delegate",
        "//tensorflow/lite/java/src/main/native",
        "//tensorflow/lite/delegates/gpu/java/src/main/native", # <-- this line was added
    ],
)

Then I started the command bazel build -c opt --config=android_arm64 //tensorflow/lite/java:libtensorflowlite_jni_normal_with_gpu.so

Check

I've checked the symbols using this command: nm -gDC libtensorflowlite_jni_normal_with_gpu.so

All the required symbols are present: the usual options TfLiteInterpreterOptionsCreate as well as the delegate one TfLiteGpuDelegateV2Create.