Hi, new Tensorflow user here. I am studying Tensorflow source code and have a very specific question. For every public function, I want to get the source code equivalent of it. https://www.tensorflow.org/api_docs/python/tf/all_symbols I tried using this but in the source code, public functions are named differently compared to the API symbols.
Is it possible to form the connection between source code and API symbols? For example, with the picture above, I want to connect tensor_util.constant_value to tf.get_static_value and retrieve all the source code equivalent of the public API symbols.
You can then use the functions __code__ property to extract whatever information you’re looking for. Here’s a function that prints out an API function’s name, module name, file name, and definition line number:
from tensorflow.python.util.tf_export import get_symbol_from_name
def print_api_info(api_name):
func = get_symbol_from_name(api_name)
if func is not None:
module = func.__module__
code_object = func.__code__
fname = code_object.co_filename
line_no = code_object.co_firstlineno
name = code_object.co_name
print(f'Name: {name}\nModule: {module}\nFile: {fname}\nLineNo: {line_no}\n')