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/
 
參考文獻:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM