lhelontra / tensorflow-on-arm

TensorFlow for Arm
MIT License
1.05k stars 274 forks source link

Trouble using this to compile tensorflow lite #72

Closed snowzach closed 4 years ago

snowzach commented 4 years ago

This repo works awesome to compile tensorflow but I am also trying to use it to compile tensorflow lite.

Essentially I just edit the config file and replace //tensorflow/tools/pip_package:build_pip_package with //tensorflow/lite:libtensorflowlite.so

It actually seems like it compiles fine but it doesn't link properly and errors with a bunch of undefined reference totflite::tensor_utils::NeonYaddaYadda` errors.

I found another post related to this https://github.com/tensorflow/tensorflow/issues/25120

I wasn't sure what to edit or if there was another flag I could pass to make it link properly.

Just curious if you or anyone else might have some ideas? I really don't get bazel totally.

snowzach commented 4 years ago

I figured out what the issue is, I think that it uses cpu=armeabi but in the tensorflow lite build stuff there is armeabi-v7a and armv7a but not targer for armeabi that includes the neon libraries. I think the easy fix is to change the cross compile stuff to use cpu-armeabi but I'm not sure what else that breaks.

lhelontra commented 4 years ago

In next branch have patch for fixes neon issues.

cd tensorflow-on-arm/build_tensorflow/
docker build -t tf-arm-buster -f Dockerfile .
docker run --name tf-arm-buster -it -v /tmp/tensorflow_pkg/:/tmp/tensorflow_pkg/ tf-arm-buster /bin/bash
git checkout next

edit your config file and replace //tensorflow/tools/pip_package:build_pip_package with //tensorflow/lite:libtensorflowlite.so and build.

I'm testing edit the rpi.conf file, after build, libtensorflowlite.so can be found in bazel-bin/tensorflow/lite/libtensorflowlite.so

snowzach commented 4 years ago

Yep, that worked! Thanks!

snowzach commented 4 years ago

Any other suggestions on how I can use this to build tensorflow lite without having to edit the config files?

lhelontra commented 4 years ago

You can try build from source or creates a new config for build tflite only.