1

I know that Tensorflow is written with a C++ engine, but I haven't found any C++ source code in my installation directory (I installed via pip). When I inspect the python codes, I got a sense that the python level is just a wrapper where the essence of the algorithm is not presented. For example, in tensorflow/python/ops/gradients.py, the gradients() function calls python_grad_func() to compute the gradients, which is a class method of DeFun.

My question is that, are all the essential part of Tensorflow written in C++ and the python are only serving as some APIs?

Neo223
  • 11
  • 1
  • That sounds likely, as the algorithms can be written in the language best suited for the problem and then you simply provide bindings to use the library in different languages. That's a fairly typical practice in my experience – SirGuy Dec 09 '16 at 14:12
  • @Neo223: Do you know how to get the actual c++ implementation/code for any operator from Tensorflow source code. Is there a way to get the backend c++ code in tensorflow? – dennis Dec 25 '19 at 14:55

1 Answers1

0

This is mostly correct, though there's a lot of sophisticated stuff implemented in Python. Instead of saying "algorithms" in C++, what I'd say is that the core dataflow execution engine and most of the ops (e.g., matmul, etc.) are in C++. A lot of the plumbing, as well as some functionality like defining gradients of functions, is in Python.

For more information and discussion about why it's this way, see this StackOverflow answer

dga
  • 21,757
  • 3
  • 44
  • 51