c++tensorflowbazeltensorflow-xla

Cannot create the final binary using tensorflow AOT compilation for CPU backend


I followed the tutorial here: TensorFlow AOT compilation

According to Step 1 and 2, I compiled the subgraph and generated the header (test_graph_tfmatmul.h) and object (test_graph_tfmatmul.o) files;

According to Step 3, I used the example code (named as my_code.cc) to invoke the subgraph;

According to Step 4, I added the code snippet cc_binary to the existing BUILD file (//tensorflow/compiler/aot/tests/BUILD), and tried to create the final binary with the command:

bazel build //tensorflow/compiler/aot/tests:my_binary

but I got the following error:

undeclared inclusion(s) in rule '//tensorflow/compiler/aot/tests:my_binary':
this rule is missing dependency declarations for the following files included by 'tensorflow/compiler/aot/tests/tfcompile_test.cc':
'/home/tensorFlow_src/tensorflow/tensorflow/compiler/aot/tests/test_graph_tfmatmul.h'

Any advice is welcome. Thanks.


Solution

  • This problem is finally figured out by using tf_library to build the cc_library in Step 2, instead of using tfcompile directly. I.e., tf_library will run tfcompile to generate the header and object files.

    Please refer to https://github.com/tensorflow/tensorflow/issues/13482 for more detailed information.