Source tree structure
Created by: wangkuiyi
This issue records an idea inspired by reading https://github.com/PaddlePaddle/Paddle/pull/2489/.
Majels' Style -- Extremely Deep Tree
It seems that Majel's philosophy of making each module a directory is pretty complex and makes it difficult to browse the source code. For example:
-
majel/include/majel/contrib/support/pinning.h
only declares two global functionspin_memory
andunpin_memory
, and whose implementations are in -
majel/include/majel/contrib/support/detail/pinning-inl.h
, andpin_memory
's body just callsmlock
andunpin_memory
callsmunlock
.
Caffe2 and MXNet's Style -- Extreme Shallow Tree
Most core concepts of Caffe2 are in https://github.com/caffe2/caffe2/tree/master/caffe2/core. There are 78 files in this directory -- too many to browse in a glance.
The header files of most core concepts of MXNet are in https://github.com/dmlc/mxnet/tree/master/include/mxnet. Implementations (.cc files) are in https://github.com/dmlc/mxnet/tree/master/src, which adopts TensorFlow's Style as described below:
TensorFlow's Style -- In-between Extremely Deep and Shallow
Comparing with Caffe2, TensorFlow has a second level directory:
tensorflow/core/platform
tensorflow/core/framework
tensorflow/core/...
and no header/source files in tensorflow/core
.
A Proposal for Paddle:
- Represent each module by a combination of x.h, x.cc/cu, and xx_test.cc/cu, so we could
- have two-level source tree like TensorFlow:
- paddle/core/platform -- class Place, malloc_
- paddle/core/memory -- management and allocation, tensor type, etc
- In each directory, if there are some facilities that are called only by code within the same directory, we put it into
detail
. For example:- paddle/core/memory/detail/buddy_allocator.{h,cc,_test.cc}