Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shrink libtensorflow_inference.so library using selective registration
This reduces libtensorflow_inference.so from 9.7MB to 2.5MB. SUMMARY - tensorflow-android.jar - created by extracting classes.jar from the "org.tensorflow:tensorflow-android:1.2.0" AAR dependency. - libtensorflow_inference.so - built for armeabi-v7a using print_selective_registration_header and then building //tensorflow/contrib/android:libtensorflow_inference.so with selective registration. Detailed build steps are listed below. BUILD STEPS Here are the commands I ran (in my Docker container): bazel build --local_resources 4096,4.0,1.0 -j 1 tensorflow/python/tools:print_selective_registration_header bazel-bin/tensorflow/python/tools/print_selective_registration_header --graphs=/TF/mnist_model_graph.pb > /tensorflow/core/framework/ops_to_register.h bazel build --local_resources 4096,4.0,1.0 -j 1 -c opt --copt="-DSELECTIVE_REGISTRATION" --copt="-DSUPPORT_SELECTIVE_REGISTRATION" //tensorflow/contrib/android:libtensorflow_inference.so --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --crosstool_top=//external:android/crosstool --cpu=armeabi-v7a --verbose_failures LIMITATIONS The previous "org.tensorflow:tensorflow-android:1.2.0" dependency used supported the four main architectures: arm64-v8a, armeabi-v7a, x86, x86_64 This change only includes a native library for the armeabi-v7a architecture. The app will crash on all other architectures, and Android Studio fails to install the app with a INSTALL_FAILED_NO_MATCHING_ABIS error.
- Loading branch information