Skip to content

Commit

Permalink
add README
Browse files Browse the repository at this point in the history
  • Loading branch information
cuongvng committed Mar 21, 2021
1 parent d075db7 commit bf2d358
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,32 @@
# TF-Lite-C--API-shared-libraries-for-Android
Generate shared libraries (`.so`) for using TF Lite C++ API in Android applications
# Generate shared libraries (`.so`) for using TF Lite C++ API in Android applications

When following [TF Lite documentation](https://www.tensorflow.org/lite/guide/android#use_tflite_c_api) for building the C++ shared libraries to use their APIs on Android apps , I experienced many Bazel build errors.
After searching on the internet for a while, [this solution](https://github.com/tensorflow/tensorflow/issues/34520#issuecomment-557533555) worked for me (on both my local Mac and Linux Google Colab).
This repo shows the instructions to build the libraries, specifically every commands that can be executed sequentially to get the job done!

If you don't care about the process, just go ahead and get the generated libraries (for *32bit armeabi-v7a* and *64bit arm64-v8a*) in the folder [generated-libs](./generated-libs).

### On Mac OS
- [Install Bazel](https://docs.bazel.build/versions/4.0.0/install-os-x.html#step-2-install-bazel-via-homebrew) via Homebrew:
```
brew install bazel
```

- Clone the [TensorFlow repo](https://github.com/tensorflow/tensorflow)
```
git clone https://github.com/tensorflow/tensorflow
```

- Build the libraries
```
# For ARM 64 bit
bazel build -c opt //tensorflow/lite:libtensorflowlite.so --fat_apk_cpu=arm64-v8a
# For ARM 32 bit
bazel build -c opt //tensorflow/lite:libtensorflowlite.so --fat_apk_cpu=arm-v7a
```

### On Linux
Run the commands listed on the notebook [run_me.ipynb](./run_me.ipynb).

---
*If you find this repo useful, please give it a star!*

0 comments on commit bf2d358

Please sign in to comment.