Search code examples
tensorflowbazel

Does "bazel build tensorflow/tools/graph_transforms:summarize_graph" build Tensorflow?


What the subject says.

I have a working Tensorflow installation via CUDA, CUDNN and pip. To examine a graph I followed a comment here which lead me to here, and accordingly I executed the command:

bazel build tensorflow/tools/graph_transforms:summarize_graph

Script kiddie that I am.

Ten minutes later I looked back at it and Bazel is furiously compiling C files with paths that look suspiciously like a source code checkout.

Is it actually compiling TF from source?!!!


Solution

  • Well yes, that is indeed what the bazel build command does.

    If you look at the actual BUILD file (tensorflow/tools/graph_transform/BUILD) you'll see that it has its build rules and dependencies, which basically includes all the source code in that directory. The summarize_graph command's logic is included in those (you'll find that in summarize_graph_main.cc under the same directory).

    You can follow the specific build rule to see what it does, or use a visualization tool. Here's what it looks like:

    tf_cc_binary(
        name = "summarize_graph",
        copts = tf_copts(),
        linkstatic = 1,
        visibility = ["//visibility:public"],
        deps = [
            ":summarize_graph_main_lib",
        ],
    )