Skip to content

Commit 3553576

Browse files
committed
Merge remote-tracking branch 'baidu/develop' into feature/sppnet
2 parents e2c0713 + 65af9f9 commit 3553576

File tree

24 files changed

+227
-39
lines changed

24 files changed

+227
-39
lines changed

.travis.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,21 @@ addons:
3838
- curl
3939
- lcov
4040
- graphviz
41+
- swig
4142
before_install:
43+
- |
44+
if [ ${JOB} == "BUILD_AND_TEST" ]; then
45+
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
46+
TRAVIS_COMMIT_RANGE="FETCH_HEAD...$TRAVIS_BRANCH"
47+
fi
48+
git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(\.md$)' || {
49+
echo "Only markdown docs were updated, stopping build process."
50+
exit
51+
}
52+
fi
4253
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo paddle/scripts/travis/before_install.linux.sh; fi
4354
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then paddle/scripts/travis/before_install.osx.sh; fi
44-
- pip install wheel protobuf sphinx breathe recommonmark
55+
- pip install wheel protobuf sphinx breathe recommonmark virtualenv numpy
4556
script:
4657
- paddle/scripts/travis/main.sh
4758
notifications:

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,26 @@ if(NOT WITH_GPU)
9595
add_definitions(-DHPPL_STUB_FUNC)
9696
list(APPEND CMAKE_CXX_SOURCE_FILE_EXTENSIONS cu)
9797
else()
98+
if(${CUDA_VERSION_MAJOR} GREATER 6)
99+
if(COMPILER_SUPPORT_CXX11)
100+
LIST(APPEND CUDA_NVCC_FLAGS -std=c++11)
101+
endif()
102+
endif()
103+
98104
# TODO(yuyang18): Change it to remove std=c++11 in cuda compile.
99105
set(CUDA_PROPAGATE_HOST_FLAGS OFF)
100106
if(NOT CUDNN_FOUND)
101107
message(FATAL_ERROR "Paddle need cudnn to compile")
102108
endif()
109+
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-g -O3 --use_fast_math")
110+
111+
if(WITH_AVX)
112+
if(AVX_FOUND)
113+
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler -mavx")
114+
endif(AVX_FOUND)
115+
else(WITH_AVX)
116+
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler -msse3")
117+
endif(WITH_AVX)
103118

104119
if(WITH_DSO)
105120
set(CUDA_LIBRARIES "")

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ developed by Baidu scientists and engineers for the purpose of applying deep
1414
learning to many products at Baidu.
1515

1616
Our vision is to enable deep learning for everyone via PaddlePaddle.
17-
Please refer to our [release log](https://github.com/baidu/Paddle/releases) to track the latest feature of PaddlePaddle.
17+
Please refer to our [release announcement](https://github.com/baidu/Paddle/releases) to track the latest feature of PaddlePaddle.
1818

1919
## Features
2020

cmake/util.cmake

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,6 @@ macro(add_simple_unittest TARGET_NAME)
188188
add_unittest(${TARGET_NAME} ${TARGET_NAME}.cpp)
189189
endmacro()
190190

191-
macro(add_paddle_culib TARGET_NAME)
192-
set(NVCC_FLAG ${CUDA_NVCC_FLAGS})
193-
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};--use_fast_math)
194-
cuda_add_library(${TARGET_NAME} STATIC ${ARGN})
195-
set(CUDA_NVCC_FLAGS ${NVCC_FLAG})
196-
endmacro()
197-
198-
199191
# Creates C resources file from files in given resource file
200192
function(create_resources res_file output)
201193
# Create empty output file

demo/quick_start/preprocess.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,21 @@
2121
set -e
2222

2323
export LC_ALL=C
24+
UNAME_STR=`uname`
25+
26+
if [[ ${UNAME_STR} == 'Linux' ]]; then
27+
SHUF_PROG='shuf'
28+
else
29+
SHUF_PROG='gshuf'
30+
fi
2431

2532
mkdir -p data/tmp
2633
python preprocess.py -i data/reviews_Electronics_5.json.gz
2734
# uniq and shuffle
2835
cd data/tmp
2936
echo 'uniq and shuffle...'
30-
cat pos_*|sort|uniq|shuf> pos.shuffed
31-
cat neg_*|sort|uniq|shuf> neg.shuffed
37+
cat pos_*|sort|uniq|${SHUF_PROG}> pos.shuffed
38+
cat neg_*|sort|uniq|${SHUF_PROG}> neg.shuffed
3239

3340
min_len=`sed -n '$=' neg.shuffed`
3441
test_num=$((min_len/10))
@@ -42,8 +49,8 @@ head -n$train_num neg.shuffed >train.neg
4249
tail -n$test_num pos.shuffed >test.pos
4350
tail -n$test_num neg.shuffed >test.neg
4451

45-
cat train.pos train.neg|shuf>../train.txt
46-
cat test.pos test.neg|shuf>../test.txt
52+
cat train.pos train.neg | ${SHUF_PROG} >../train.txt
53+
cat test.pos test.neg | ${SHUF_PROG} >../test.txt
4754

4855
cd -
4956
echo 'data/train.txt' > data/train.list

doc_cn/demo/quick_start/index.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,8 @@ define_py_data_sources2(train_list='data/train.list',
134134
* obj="process": 指定生成数据的函数
135135
* args={"dictionary": word_dict}: 额外的参数,这里指定词典
136136

137-
更详细用例请参考文档<a href = "../../../doc/ui/data_provider/python_case.html">Python Use Case</a>,
138-
数据格式和详细文档请参考<a href = "../../../doc/ui/data_provider/pydataprovider2.html">
139-
PyDataProviderWrapper</a>。
137+
更详细数据格式和用例请参考<a href = "../../ui/data_provider/pydataprovider2.html">
138+
PyDataProvider2</a>。
140139

141140
## 网络结构(Network Architecture)
142141
本节我们将专注于网络结构的介绍。

doc_cn/faq/index.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,40 @@ PaddlePaddle的参数使用名字 :code:`name` 作为参数的ID,相同名字
177177
178178
pip install --upgrade pip
179179
180+
8. python相关的单元测试都过不了
181+
--------------------------------
182+
183+
如果出现以下python相关的单元测试都过不了的情况:
184+
185+
.. code-block:: bash
186+
187+
24 - test_PyDataProvider (Failed)
188+
26 - test_RecurrentGradientMachine (Failed)
189+
27 - test_NetworkCompare (Failed)
190+
28 - test_PyDataProvider2 (Failed)
191+
32 - test_Prediction (Failed)
192+
33 - test_Compare (Failed)
193+
34 - test_Trainer (Failed)
194+
35 - test_TrainerOnePass (Failed)
195+
36 - test_CompareTwoNets (Failed)
196+
37 - test_CompareTwoOpts (Failed)
197+
38 - test_CompareSparse (Failed)
198+
39 - test_recurrent_machine_generation (Failed)
199+
40 - test_PyDataProviderWrapper (Failed)
200+
41 - test_config_parser (Failed)
201+
42 - test_swig_api (Failed)
202+
43 - layers_test (Failed)
203+
204+
并且查询PaddlePaddle单元测试的日志,提示:
205+
206+
.. code-block:: bash
207+
208+
paddle package is already in your PYTHONPATH. But unittest need a clean environment.
209+
Please uninstall paddle package before start unittest. Try to 'pip uninstall paddle'.
210+
211+
解决办法是:卸载paddle包 :code:`pip uninstall paddle`。
212+
213+
原因是:单元测试使用了一个旧版本的python包,而没有测试到代码中实际修改的python包。即单元测试需要一个干净的环境:
214+
215+
* 如果paddle包已经在python的site-packages里面了,那么单元测试时使用的paddle包,就是site-packages里面的python包,而不是源码目录里 :code:`/python` 目录下的python包。
216+
* 即便设置了 :code:`PYTHONPATH` 到 :code:`/python` 也没用,因为python的搜索路径是优先已经安装的python包。

paddle/api/paddle_api_config.py.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
PADDLE_BUILD_DIR="@CMAKE_CURRENT_BINARY_DIR@/../"
22
WITH_GPU="@WITH_GPU@"
33
PROTOBUF_LIB="@PROTOBUF_LIBRARY@"
4+
ZLIB_LIB="@ZLIB_LIBRARIES@"
45
CMAKE_THREAD_LIB="@CMAKE_THREAD_LIBS_INIT@"
56
CMAKE_DL_LIBS="@CMAKE_DL_LIBS@"
67

@@ -15,3 +16,4 @@ GFLAGS_LOCATION="@GFLAGS_LOCATION@"
1516
CBLAS_LIBRARIES="@CBLAS_LIBS@"
1617

1718
CUDA_LIBRARIES="@CUDA_LIBRARIES@"
19+
WITH_COVERALLS="@ON_COVERALLS@"

paddle/api/paddle_ld_flags.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def __init__(self):
3838
self.paddle_build_dir = os.path.abspath(self.paddle_build_dir)
3939
self.with_gpu = PaddleLDFlag.cmake_bool(WITH_GPU)
4040
self.protolib = PROTOBUF_LIB
41+
self.zlib = ZLIB_LIB
4142
self.thread = CMAKE_THREAD_LIB
4243
self.dl_libs = CMAKE_DL_LIBS
4344
self.with_python = PaddleLDFlag.cmake_bool(WITH_PYTHON)
@@ -47,6 +48,7 @@ def __init__(self):
4748
self.glog_libs = LIBGLOG_LIBRARY
4849

4950
self.with_gflags = PaddleLDFlag.cmake_bool(WITH_GFLAGS)
51+
self.with_coverage = PaddleLDFlag.cmake_bool(WITH_COVERALLS)
5052
self.gflags_libs = GFLAGS_LIBRARIES
5153
self.gflags_location = GFLAGS_LOCATION
5254
self.cblas_libs = CBLAS_LIBRARIES
@@ -64,7 +66,7 @@ def libs_dir_str(self):
6466

6567
def parent_dir_str(self):
6668
libdirs = PARENT_LIB_DIRS
67-
return " ".join(map(lambda x: "-L" + os.path.join(self.paddle_build_dir, '..', x),
69+
return " ".join(map(lambda x: "-L" + os.path.join(self.paddle_build_dir, '..', x),
6870
libdirs))
6971

7072
def libs_str(self):
@@ -82,6 +84,7 @@ def libs_str(self):
8284
"-lpaddle_cuda",
8385
"-lpaddle_api",
8486
self.normalize_flag(self.protolib),
87+
self.normalize_flag(self.zlib),
8588
self.normalize_flag(self.thread),
8689
self.normalize_flag(self.dl_libs),
8790
self.normalize_flag(self.cblas_libs),
@@ -95,6 +98,8 @@ def libs_str(self):
9598
libs.append(self.normalize_flag(self.gflags_libs))
9699
if self.with_gpu:
97100
libs.append(self.normalize_flag(self.curt))
101+
if self.with_coverage:
102+
libs.append("-fprofile-arcs")
98103
return " ".join(filter(lambda l: len(l) != 0, libs))
99104

100105
def normalize_flag(self, cmake_flag):
@@ -131,8 +136,14 @@ def cmake_bool(cmake_str):
131136
return False
132137
else:
133138
return True
134-
139+
def c_flag(self):
140+
if self.with_coverage:
141+
return ["-fprofile-arcs", "-ftest-coverage", "-O0", "-g"]
142+
else:
143+
return None
135144
except ImportError:
136145
class PaddleLDFlag(object):
137146
def ldflag_str(self):
138147
pass
148+
def c_flag(self):
149+
pass

paddle/cuda/include/hl_base.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,15 @@ typedef struct {
209209
#define HL_FLOAT_MIN 2.2250738585072014e-308
210210
#endif
211211

212+
213+
/**
214+
* The maximum input value for exp, used to avoid overflow problem.
215+
*
216+
* Currently only used for tanh function.
217+
*/
218+
#define EXP_MAX_INPUT 40.0
219+
220+
212221
/**
213222
* @brief DIVUP(x, y) is similar to ceil(x / y).
214223
* @note For CUDA, DIVUP will be used to specify

0 commit comments

Comments
 (0)