TensorFlow源码框架 杂记

一.为什么我们需要使用线程池技术(ThreadPool)

  线程:采用“即时创建,即时销毁”策略,即接受请求后,创建一个新的线程,执行任务,完毕后,线程退出;

  线程池:应用软件启动后,立即创建一定数量的线程,放入空闲队列;

  优缺点分析:使用线程处理多请求,低任务量问题时,不断创建、销毁线程,开销巨大;使用线程池能够减少创建销毁的开销;

 

二.C++11中使用unordered_map代替hash_map,另外增加了unique_ptr智能指针;(override GUARDED_BY等)

 

三.SWIG是一个非常优秀的开源工具,支持将C/C++代码与任何主流脚本语言相集成(包括Ruby,Perl、Tcl和Python)

 

四.阅读tensorflow源码

  1. https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/common_runtime/direct_session.cc

  
  代码注释写的十分详细,主要阅读部分.h文件。
 
  代码框架:
  
    core/ contains the main C++ code and runtimes.

  core/ops/ contains the "signatures" of the operations
  core/kernels/ contains the "implementations" of the operations (including CPU and CUDA kernels)
  core/framework/ contains the main abstract graph computation and other useful libraries
  core/platform/ contains code that abstracts away the platform and other imported libraries (protobuf, etc)

  TensorFlow relies heavily on the Eigen library for both CPU and GPU calculations.  Though some GPU kernels are implemented directly with CUDA code.

  bazel builds certain C++ code using gcc/clang, and certain CUDA code (files with extension .cu.cc) with nvcc.

  python/ops/ contain the core python interface
  python/kernel_tests/ contain the unit tests and lots of example code
  python/framework/ contains the python abstractions of graph, etc, a lot of which get serialized down to proto and/or get passed to swigged session calls.
  python/platform/ is similar to the C++ platform, adding lightweight wrappers for python I/O, unit testing, etc.

  contrib/*/ directories generally mimic the root tensorflow path (i.e., they have core/ops/, etc) 
 
五. 有意思的DeepLearning项目网址:http://deeplearninggallery.com/
 
参考文献:
posted @ 2017-03-01 20:16  kossle  阅读(3267)  评论(0编辑  收藏  举报