niko
niko

Reputation: 1168

Tensorflow source for autogenerated python modules from C++

Very often I want to check the source code for some tensorflow module. Usually, a a large part of the API is written in native python and the relevant file is easy to find on github. However, there are some important parts that I are written in C++ and I cannot find the source code for them. For example, according to the official TensorFlow documentation, most of the math ops are defined in tensorflow/python/ops/gen_math_ops.py. However, there is no such file on GitHub. My local installation of TF has this file, but checking the source on GitHub is much easier. I also want to understand where should I search for the rules which specify how a python file is generated. I am sorry if this is a stupid question, but I am not familiar with bazel.

Upvotes: 1

Views: 183

Answers (1)

Jin
Jin

Reputation: 13533

I also want to understand where should I search for the rules which specify how a python file is generated.

Use bazel query for this.

If you want to know which rule generates a file (e.g. $PROJECT/some/dir/file.py), run this command from the project root:

bazel query --output=build some/dir/file.py

For example, if I want to find out which rule generates a particular jar file, bazel query prints this:

$ bazel query --output=build examples/java-native/src/test/java/com/example/myproject/hello.jar
# /Users/foo/bazel/examples/java-native/src/test/java/com/example/myproject/BUILD:1:1
java_test(
  name = "hello",
  deps = ["//examples/java-native/src/main/java/com/example/myproject:hello-lib", "//third_party:junit4"],
  srcs = ["//examples/java-native/src/test/java/com/example/myproject:TestHello.java"],
  test_class = "com.example.myproject.TestHello",
)

Check out the Query how-to documentation page for more bazel query tips.

Upvotes: 2

Related Questions