Skip to content

Commit b3a11fd

Browse files
committed
Merge branch 'rm_reader_HasNext' into dev_double_buffer_for_cpp_reader
2 parents b1f647f + 6e5736e commit b3a11fd

File tree

83 files changed

+3105
-795
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+3105
-795
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ script:
5656
export DEPLOY_DOCS_SH=https://raw.githubusercontent.com/PaddlePaddle/PaddlePaddle.org/master/scripts/deploy/deploy_docs.sh
5757
export DOCS_DIR=`pwd`
5858
cd ..
59-
curl $DEPLOY_DOCS_SH | bash -s $CONTENT_DEC_PASSWD $TRAVIS_BRANCH $DOCS_DIR $DOCS_DIR/build/doc/v2
59+
curl $DEPLOY_DOCS_SH | bash -s $CONTENT_DEC_PASSWD $TRAVIS_BRANCH $DOCS_DIR $DOCS_DIR/build/doc/
6060
notifications:
6161
email:
6262
on_success: change

cmake/external/openblas.cmake

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ IF(NOT ${CBLAS_FOUND})
7777
INSTALL_DIR ${CBLAS_INSTALL_DIR}
7878
BUILD_IN_SOURCE 1
7979
BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} ${COMMON_ARGS} ${OPTIONAL_ARGS}
80-
INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install NO_SHARED=1 NO_LAPACK=1 PREFIX=<INSTALL_DIR>
80+
INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install NO_SHARED=1 NO_LAPACK=1 PREFIX=<INSTALL_DIR>
81+
&& rm -r ${CBLAS_INSTALL_DIR}/lib/cmake ${CBLAS_INSTALL_DIR}/lib/pkgconfig
8182
UPDATE_COMMAND ""
8283
CONFIGURE_COMMAND ""
8384
)
@@ -100,11 +101,6 @@ IF(NOT ${CBLAS_FOUND})
100101
\"${CBLAS_INSTALL_DIR}/lib -> ${CMAKE_INSTALL_PREFIX}/${TMP_INSTALL_DIR}\"
101102
)"
102103
)
103-
INSTALL(CODE "execute_process(
104-
COMMAND rm -r ${CMAKE_INSTALL_PREFIX}/${TMP_INSTALL_DIR}/cmake
105-
${CMAKE_INSTALL_PREFIX}/${TMP_INSTALL_DIR}/pkgconfig
106-
)"
107-
)
108104
ENDIF()
109105
ENDIF(NOT ${CBLAS_FOUND})
110106

cmake/generic.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ function(cc_library TARGET_NAME)
186186
add_library(${TARGET_NAME} SHARED ${cc_library_SRCS})
187187
else()
188188
add_library(${TARGET_NAME} STATIC ${cc_library_SRCS})
189+
find_fluid_modules(${TARGET_NAME})
189190
endif()
191+
190192
if(cc_library_DEPS)
191193
# Don't need link libwarpctc.so
192194
if("${cc_library_DEPS};" MATCHES "warpctc;")
@@ -263,7 +265,8 @@ function(nv_library TARGET_NAME)
263265
if (nv_library_SHARED OR nv_library_shared) # build *.so
264266
cuda_add_library(${TARGET_NAME} SHARED ${nv_library_SRCS})
265267
else()
266-
cuda_add_library(${TARGET_NAME} STATIC ${nv_library_SRCS})
268+
cuda_add_library(${TARGET_NAME} STATIC ${nv_library_SRCS})
269+
find_fluid_modules(${TARGET_NAME})
267270
endif()
268271
if (nv_library_DEPS)
269272
add_dependencies(${TARGET_NAME} ${nv_library_DEPS})

cmake/inference_lib.cmake

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
1+
set_property(GLOBAL PROPERTY FLUID_MODULES "")
2+
# find all fluid modules is used for paddle fluid static library
3+
function(find_fluid_modules TARGET_NAME)
4+
get_filename_component(__target_path ${TARGET_NAME} ABSOLUTE)
5+
string(FIND "${__target_path}" "fluid" pos)
6+
if(pos GREATER 1)
7+
get_property(fluid_modules GLOBAL PROPERTY FLUID_MODULES)
8+
set(fluid_modules ${fluid_modules} ${TARGET_NAME})
9+
set_property(GLOBAL PROPERTY FLUID_MODULES "${fluid_modules}")
10+
endif()
11+
endfunction(find_fluid_modules)
12+
113
# make package for paddle fluid shared and static library
214
function(copy TARGET)
315
set(options "")
416
set(oneValueArgs "")
517
set(multiValueArgs SRCS DSTS DEPS)
618
cmake_parse_arguments(copy_lib "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
19+
set(inference_lib_dist_dep ${TARGET} ${inference_lib_dist_dep} PARENT_SCOPE)
720

821
list(LENGTH copy_lib_SRCS copy_lib_SRCS_len)
922
list(LENGTH copy_lib_DSTS copy_lib_DSTS_len)
@@ -42,13 +55,21 @@ copy(glog_lib
4255
DSTS ${dst_dir} ${dst_dir}/lib
4356
)
4457

45-
IF(NOT PROTOBUF_FOUND)
58+
if(NOT PROTOBUF_FOUND)
4659
set(dst_dir "${CMAKE_INSTALL_PREFIX}/third_party/install/protobuf")
4760
copy(protobuf_lib
48-
SRCS ${PROTOBUF_INCLUDE_DIR} ${PROTOBUF_LITE_LIBRARY}
61+
SRCS ${PROTOBUF_INCLUDE_DIR} ${PROTOBUF_LIBRARY}
4962
DSTS ${dst_dir} ${dst_dir}/lib
5063
)
51-
ENDIF(NOT PROTOBUF_FOUND)
64+
endif()
65+
66+
if(NOT CBLAS_FOUND)
67+
set(dst_dir "${CMAKE_INSTALL_PREFIX}/third_party/install/openblas")
68+
copy(openblas_lib
69+
SRCS ${CBLAS_INSTALL_DIR}/lib ${CBLAS_INSTALL_DIR}/include
70+
DSTS ${dst_dir} ${dst_dir}
71+
)
72+
endif()
5273

5374
# paddle fluid module
5475
set(src_dir "${PADDLE_SOURCE_DIR}/paddle/fluid")
@@ -66,8 +87,8 @@ copy(memory_lib
6687
)
6788

6889
set(module "inference")
69-
copy(inference_lib DEPENDS paddle_fluid_shared
70-
SRCS ${src_dir}/${module}/*.h ${PADDLE_BINARY_DIR}/paddle/fluid/inference/libpaddle_fluid.so
90+
copy(inference_lib DEPS paddle_fluid_shared paddle_fluid
91+
SRCS ${src_dir}/${module}/*.h ${PADDLE_BINARY_DIR}/paddle/fluid/inference/libpaddle_fluid.*
7192
DSTS ${dst_dir}/${module} ${dst_dir}/${module}
7293
)
7394

@@ -83,6 +104,4 @@ copy(string_lib
83104
DSTS ${dst_dir}/${module} ${dst_dir}/${module}/tinyformat
84105
)
85106

86-
add_custom_target(inference_lib_dist DEPENDS
87-
inference_lib framework_lib memory_lib platform_lib string_lib
88-
gflags_lib glog_lib protobuf_lib eigen3_lib)
107+
add_custom_target(inference_lib_dist DEPENDS ${inference_lib_dist_dep})

doc/design/cpp_data_feeding.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ class ReaderBase {
2020
PADDLE_ENFORCE(!shapes_.empty());
2121
}
2222
// Read the next batch of data. (A 'batch' can be only one instance)
23+
// If the next batch doesn't exist, the '*out' will be an empty std::vector.
2324
virtual void ReadNext(std::vector<LoDTensor>* out) = 0;
24-
// Show whether the next bacth exists.
25-
virtual bool HasNext() const = 0;
2625

2726
// Reinitialize the reader and read the file from the begin.
2827
virtual void ReInit() = 0;
69 KB
Loading
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## how to use timeline tool to do profile
2+
3+
1. Add `with profiler.profiler(...)` to the main training loop. After run, the code will generate a profile record file `/tmp/profile`. **Warning**: Please do not run too many batches when use profiler to record timeline information, for the profile record will grow with the batch number.
4+
5+
```python
6+
with profiler.profiler('All', 'total', '/tmp/profile') as prof:
7+
for pass_id in range(pass_num):
8+
for batch_id, data in enumerate(train_reader()):
9+
exe.run(fluid.default_main_program(),
10+
feed=feeder.feed(data),
11+
fetch_list=[],
12+
use_program_cache=True)
13+
...
14+
```
15+
16+
1. Run `python paddle/tools/timeline.py` to process `/tmp/profile`, it will generate another
17+
file `/tmp/timeline` by default. You can change the path by cmd parameter, please take a look at
18+
[timeline.py](https://github.com/PaddlePaddle/Paddle/blob/develop/tools/timeline.py) for details.
19+
20+
1. Open chrome and visit <chrome://tracing/>, use `load` button to load the generated `timeline` file.
21+
22+
![chrome tracing](./tracing.jpeg)
23+
24+
1. The resulting timeline should be like:
25+
26+
27+
![chrome timeline](./timeline.jpeg)
29.9 KB
Loading

0 commit comments

Comments
 (0)