I\'m trying to figure out the workflow for training and deploying a Tensorflow model on Android. I\'m aware of the other questions similar to this one on StackOverflow, but non
After setting up an Android NDK in your WORKSPACE file, Bazel can cross-compile a .so for Android, like this:
cc_binary(
name = "libfoo.so",
srcs = ["foo.cc"],
deps = [":bar"],
linkstatic = 1,
linkshared = 1,
)
$ bazel build foo:libfoo.so \
--crosstool_top=//external:android/crosstool --cpu=armeabi-v7a \
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain
$ file bazel-bin/foo/libfoo.so
bazel-bin/foo/libfoo.so: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), not stripped
Bazel wants all of the java app code to be inside the 'WORKSPACE' top-level directory (in the Tensorflow repo)
When 0.1.4 is released (pushing it right now) and we have pushed some fixes to TensorFlow and Protobuf, you can start using the TensorFlow repo as a remote repository. After setting it up in your WORKSPACE file, you can then refer to TensorFlow rules using @tensorflow//foo/bar
labels.