TensorFlow项目文件结构说明

本文介绍一下tensorflow(以下称TF)项目的主要文件目录结构。信息来自tensorflow的google group讨论。希望对想优化TF,或者想搞清楚TF底层细节的朋友有所帮助 _
首先看一下0.12版本的文件目录截图

tf目录结构

根据讨论组提供的信息,其项目文件的实现功能主要为以下内容

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)

翻译过来就是

后台实现部分

这部分的代码都在core/目录下

core/ 目录里面是C++代码和运行时,所以是核心代码。
core/ops/ 目录下是各种operation的签名'signature'。
core/kernels/ 目录下是各种operation的实现(包括CPU kernel和CUDA kernel)。
core/framework/ 目录下是计算图的抽象和一些其他有用的库。

core/platform/ 目录下对其他平台和导入库(protobuf等)的抽象代码。

TF的CPU和GPU计算严重依赖于Eigen库,尽管一些GPU kernel直接使用CUDA代码实现的。
bazel编译时,一部分C++代码用的是gcc或clang,一部分CUDA代码(后缀名是.cu.cc)用的是nvcc。

前台Python接口部分

python/ops/ 核心python接口
python/kernel_tests/ 单元测试代码和示例代码
python/framework/ python抽象图, a lot of which get serialized down to proto and/or get passed to swigged session calls.
python/platform/ 和上面C++部分的platform差不多, 对python I/O、单元测试等做了轻量级的包装。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 一个老人走出来 扯着嗓子叫她孙子的名字 叫了好几句 没人应 连回声都没有 看不清她脸上的表情 她没有像往常一样拄着...
    钟美好阅读 1,144评论 0 0
  • 按:小说三要素之环境,常规表述为社会环境、自然环境,其实大而不当,此处环境应该是特指共同情境。要学习小说写作,得先...
    我就是刘小胖子阅读 2,607评论 0 1
  • 3.0今天开班而2.0已经开班87天,也意味着早起运动我坚持了87天,以前觉得不可能的事,成为了现实。 人生总是会...
    易效能张倩阅读 1,706评论 0 1
  • 有段时间自己工作特别不顺心,想要辞职却又下不定决心,害怕凭自己仅有的那么点经验,找到的工作还不如现在的,每天...
    蹦跶的小蚂蚱阅读 2,087评论 0 0

友情链接更多精彩内容