Getting different tensorflow lite 2.8.0 shared libraries for Android when cross-compile it with bazel and cmake

Hi All!
I’m trying to build TensorFlow Lite 2.8.0 shared library for android with cmake.

Using environment:
Ubuntu 20.04.4;
Android SDK 32;
Android NDK 20b (20.1.5948944);
TensorFlow Lite 2.8.0;

Firstly, to check my model, I built TensorFlow Lite 2.8.0 with bazel.
I just made next build.sh in folder with TFLite sources:

bazel \
	--host_jvm_args=-Djavax.net.ssl.trustStore=/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/cacerts \
        --host_jvm_args=-Djavax.net.ssl.trustStorePassword=changeit \
        build --config=android_arm64 -c opt //tensorflow/lite/c:libtensorflowlite_c.so

Also I added next .tf_configure.bazelrc file in folder with TFLite sources:

build --action_env ANDROID_NDK_HOME="/home/Android/Sdk/ndk/20.1.5948944/"
build --action_env ANDROID_NDK_API_LEVEL="20"
build --action_env ANDROID_SDK_HOME="/home/Android/Sdk"

And result lib works fine! I mean, my model with result libtensorflowlite_c.so works as expected.

After it, I tried to build libtensorflowlite_c.so using cmake.
I made next build.sh script and placed it in the build folder near folder with TFLite sources:

NDK_ROOT=${HOME}/Android/Sdk/ndk/20.1.5948944/build/cmake/android.toolchain.cmake
ARMCC_FLAGS="-s"
cmake -DCMAKE_TOOLCHAIN_FILE=${NDK_ROOT} \
  -DCMAKE_CXX_FLAGS="${ARMCC_FLAGS}" \
  -DANDROID_ABI=arm64-v8a \
  -DANDROID_NDK_API_LEVEL=20 \
  ../v2.8.0/tensorflow/lite/c
cmake --build . -j

I got target libtensorflowlite_c.so file.
But my model doesn’t work correct with this lib.

I thought that difference in assembly may be in dependencies versions. But after checking .cmake files in TFLite sources folder
/tensorflow/lite/tools/cmake/modules I noticed that all modules are synchronized with tensorflow/third_party workspace.bzl.
So I haven’t got idea what the difference in building process with bazel and cmake.
If someone know what I should to do to get libtensorflowlite_c.so with cmake the same as with bazel, please tell me.
I will very glad if somebody can help me.
Thanks!

1 Like

Solved.
I had different dependencies of XNN pack for different build systems.
For bazel it was XNNPACK with TAG 69fa3b3707acd05e533db87b627e36def4886846.
And for cmake it was XNNPACK with TAG 113092317754c7dea47bfb3cb49c4f59c3c1fa10.
It was my bad.
Sorry and thanks!