New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature] Support Cross Compiling with tfcompile #9661
Comments
I don't think anyone is currently working on this, but maybe @tatatodd can correct me. I'm gonna mark as contributions welcome for now. |
Can you get what you want by changing the --target_triple option handed to tfcompile? I don't have either target to see if the result works here...but from Linux, I can do: |
I can confirm that doing what @petecoup suggests does work. I'm able to cross-compile from linux amd64 targetting rpi3 hardware (though, I still lack proper tooling to set the |
@petecoup @lissyx In which file do we need to make changes, tfcompile.bzl or tfcompile_main.cc I see the line I want to compile for both android and ios For ios I tried first tried, just replacing in tfcompile_main.cc with Next, in addition to changes in tfcompile_main.cc, when I also made the change in tfcompile.bzl by replacing the line with ERROR: /tensorflow/test_graph_build/BUILD:4:1: Linking of rule '//test_graph_build:test_graph_tfmatmul' failed: link_dynamic_library.sh failed: error executing command external/bazel_tools/tools/cpp/link_dynamic_library.sh no ignored ignored ignored /usr/bin/gcc -shared -o bazel-out/local-opt/bin/test_graph_build/libtest_graph_tfmatmul.so '-fuse-ld=gold' ... (remaining 7 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1. |
@ruppeshnalwaya1993 This is what I have in our code, inside the
So basically your
|
@lissyx Thanks for your reply! I want to build for iOS and not raspberry pie. Nevertheless, to make sure I understand the process correctly, I tried to build using the changes that you suggested. One thing I am not sure of is given
how do specify in the bazel build command in terminal to build for //tensorflow:rpi3 and not //conditions:default or anything else? Since I was unsure how to specify the target in the terminal command, I specified the default one to be also raspberry pie like this:
I tried building the test graph mentioned at tensorflow aot page by adding tfcompile_flags as written above in the BUILD file and running the command
But after a lot of time compiling, this does throws an error as follows:
What would be the right way to build this ? |
I'm not sure about your error. What does According to My best bet is that you should not be using ld.gold but your arch's ld. In our case, we disable the test and benchmark binaries with |
@lissyx I resolved the error by building tfcompile separately using command
The above command generated
I had already built the simple ios example project once before, hence I am assuming all the header search paths and linker paths and libs are properly set in build settings of the project. But after additional adding the .h and .o generated from AOT, with accompanying code to test it, the project it not building. What am I missing? Is there something additional I have to link? |
@ruppeshnalwaya1993 Ah, I hit the same kind of stuff, I just chose for now to build the related libs, link my binary against and share them. I am not convinced it is the proper way, I would have preferred they get statically linked by Bazel, but for now it's good enough for me. Targets are: |
@lissyx What will the bazel build command to build say |
I don't know, I'm just documenting how I got things to work in my case. |
@lissyx Ok, np. Thanks for your help. :) |
@lissyx @cancan101 I got some success. I ran the following command to build
And got success in running the test program with the test graph. Now I try running the frozen and optimised graph of pix2pix(https://github.com/affinelayer/pix2pix-tensorflow) and I get the output to be buffer with all values zero. I double checked that the passed values of input image are correct (floats between 0-1). Has anyone faces such an issue? Is there a way to debug aot generated code? |
@cancan101 @skye @petecoup I also checked with a graph that has a just an input node and a following identity node as output. Even in this case the result from xla is buffer with all values either 0.000 or -nan |
@lissyx , I'm trying to do basically the same thing, cross-compile tfcompile binary to raspberrypi. However, I'm using the VGG16 network in Keras. How did you find the targets needed for your model |
@ruppeshnalwaya1993 were you able to get pix2pix running on ios ? How did you debug it further ? |
@powderluv yes, I was able to run pix2pix using XLA AOT compilation by I did not finally use it as there were no gains in speed as compared to regular tensorflow. |
@ruppeshnalwaya1993 can you share your BUILD file to cross-compile your model to both android and ios? I managed to use aot to compile my model into a shared library and run on linux, but cannot find anything workable in android and ios. Thanks! |
can u share something? |
This issue is stale because it has been open for 180 days with no activity. It will be closed if no further activity occurs. Thank you. |
This issue was closed because it has been inactive for 1 year. |
Tensorflow (using XLA) is able to AOT compile a graph using
tfcompile
. There does not seem to be a way to, or it it not documented, cross compile the graph (ie compile on OS X for deployment on iOS). (Related SO question).I suggest adding a means of performing this cross compilation.
The text was updated successfully, but these errors were encountered: