如何查看SWIG接口TensorFlow背后的C ++函数调用 [英] How to see C++ function invocations behind the SWIG interface, TensorFlow

查看:97
本文介绍了如何查看SWIG接口TensorFlow背后的C ++函数调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究TensorFlow,我想知道SWIG接口背后的每个Python函数与相应的C ++函数之间的关系. 换句话说,我希望能够确切地知道我的TensorFlow应用程序的每一行Python代码都调用了哪些C ++函数.

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.

我已经在此处调试了Python代码>以及如何显示发生分段错误的代码在此处,但在通过这些方式,我只能看到错误的位置,而我希望能够知道每个C ++函数的调用,即使代码中没有错误(使用gdb进行调试时,我也可以看到系统调用和动态库调用,而不是C ++函数调用.

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).

推荐答案

大多数人编写的大部分代码用于图形构造.几乎所有的图构造都是完全在Python中完成的,它只是建立(Python)数据结构,例如Operation和Graph /master/tensorflow/python/framework/ops.py"rel =" nofollow noreferrer> ops.py .一个例外是形状推断,它会在您创建每个操作时发生.形状推断通过 cpp_shape_inference.i .建立计算图后,您可以通过创建Session并调用sess.run执行.这些都是包装TensorFlow的C API的Python函数.包装器可以在 tf_session.i .

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 and Graph defined in ops.py. The one exception is shape inference, which happens when you create every operation. Shape inference calls out to C++ via the interface defined in cpp_shape_inference.i. After you built up the computational graph, you execute it by creating a Session and calling sess.run. These are all Python function wrapping TensorFlow's C API. The wrappers can be found in tf_session.i.

这篇关于如何查看SWIG接口TensorFlow背后的C ++函数调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆