I'm working on TensorFlow and I want to know the relationship between each Python function and the correspondent C++ functions behind the SWIG interface. In other words, I want to be able to know exactly which C++ functions are invoked for every line of Python code of my TensorFlow application.
I already saw how to debug the Python code here and how to display at which line of code a segmentation fault happens here, but in these ways I'm able to see only where an error is, while instead I want to be able to know every C++ function invocation, even when there are no bugs in the code (At the moment debugging with gdb I'm able to see the system calls and the dynamic library calls, but not the C++ function invocations).
The bulk of the code that most people write is for graph construction. Almost of all of graph construction happens completely in Python, which simply builds up the (Python) data structures such as
Operation
andGraph
defined inops.py
. The one exception is shape inference, which happens when you create every operation. Shape inference calls out to C++ via the interface defined incpp_shape_inference.i
. After you built up the computational graph, you execute it by creating aSession
and callingsess.run
. These are all Python function wrapping TensorFlow's C API. The wrappers can be found intf_session.i
.