Skip to content Skip to sidebar Skip to footer

Where Is The Bazel Rule Generating The `gen_io_ops.py` File When Building Tensorflow From Sources?

I'm trying to determine how the gen_io_ops module is generated by bazel when building TensorFlow from source. In tensorflow/python/ops/io_ops.py, there is this piece of code: from

Solution 1:

I finally got it.


There is indeed a call to tf_op_gen_wrapper_py but it's hidden in a call to tf_gen_op_wrapper_private_py:

deftf_gen_op_wrapper_private_py(name, out=None, deps=[],
                                 require_shape_functions=True,
                                 visibility=[]):
  ifnot name.endswith("_gen"):
    fail("name must end in _gen")
  [...]
  bare_op_name = name[:-4]
  tf_gen_op_wrapper_py(name=bare_op_name, ...

So the steps are the following.

In tensorflow/tensorflow/python/BUILD, there is this rule

tf_gen_op_wrapper_private_py(
    name = "io_ops_gen",
    [...]
)

And so, in this rule the _gen suffix will be removed (in tf_gen_op_wrapper_private_py) and a gen_ prefix will be added in tf_gen_op_wrapper_py and therefore the gen_io_ops.py module will be generated by this rule.

Post a Comment for "Where Is The Bazel Rule Generating The `gen_io_ops.py` File When Building Tensorflow From Sources?"