If you work with Swift for TensorFlow project, sooner or later you will face the debug problem. The root of the issue is that lldb can’t get access to TensorFlow graph in you swift program.
Official documentation describes the compilation process:
Once the tensor operations are desugared, a transformation we call “partitioning” extracts the graph operations from the program and builds a new SIL function to represent the tensor code. In addition to removing the tensor operations from the host code, new calls are injected that call into our new runtime library to start up TensorFlow, rendezvous to collect any results, and send/receive values between the host and the tensor program as it runs. The bulk of the Graph Program Extraction transformation itself lives in TFPartition.cpp.
Once the tensor function is formed, it has some transformations applied to it, and is eventually emitted to a TensorFlow graph using the code in TFLowerGraph.cpp. After the TensorFlow graph is formed, we serialize it to a protobuf and encode the bits directly into the executable, making it easy to load at program runtime.
Actually the final graph is serialized into protobuf bytes and copied directly into the executable file.
I made a small debug tool, – Flow Inspector which can handle that problem.
You can find package template and readme on my GitHub page.