Skip to content

Commit 515543a

Browse files
authored
Merge pull request #2 from PaddlePaddle/develop
Merge from PaddlePaddle/develop
2 parents 2a9d71a + bd689cb commit 515543a

File tree

130 files changed

+7117
-811
lines changed

Some content is hidden

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

130 files changed

+7117
-811
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "book"]
2+
path = book
3+
url = https://github.com/PaddlePaddle/book.git

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
sha: c25201a00e6b0514370501050cf2a8538ac12270
33
hooks:
44
- id: remove-crlf
5-
files: (?!.*third_party)^.*$
5+
files: (?!.*third_party)^.*$ | (?!.*book)^.*$
66
- repo: https://github.com/reyoung/mirrors-yapf.git
77
sha: v0.13.2
88
hooks:
99
- id: yapf
10-
files: (.*\.(py|bzl)|BUILD|.*\.BUILD|WORKSPACE)$ # Bazel BUILD files follow Python syntax.
10+
files: (.*\.(py|bzl)|BUILD|.*\.BUILD|WORKSPACE)$
1111
- repo: https://github.com/pre-commit/pre-commit-hooks
1212
sha: 7539d8bd1a00a3c1bfd34cdb606d3a6372e83469
1313
hooks:
1414
- id: check-added-large-files
1515
- id: check-merge-conflict
1616
- id: check-symlinks
1717
- id: detect-private-key
18-
files: (?!.*third_party)^.*$
18+
files: (?!.*third_party)^.*$ | (?!.*book)^.*$
1919
- id: end-of-file-fixer
2020
- repo: https://github.com/PaddlePaddle/clang-format-pre-commit-hook.git
2121
sha: 28c0ea8a67a3e2dbbf4822ef44e85b63a0080a29

.travis.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,14 @@ cache:
44
- $HOME/third_party
55
- $HOME/.ccache
66
- $HOME/.cache/pip
7-
- $HOME/Library/Caches/Homebrew
87
sudo: required
98
dist: trusty
109
os:
1110
- linux
12-
- osx
1311
env:
1412
- JOB=DOCS
1513
- JOB=BUILD_AND_TEST
1614
- JOB=PRE_COMMIT
17-
matrix:
18-
exclude:
19-
- os: osx
20-
env: JOB=DOCS # Only generate documentation in linux.
21-
- os: osx
22-
env: JOB=PRE_COMMIT # Only check pre-commit hook in linux
2315

2416
addons:
2517
apt:
@@ -53,11 +45,10 @@ before_install:
5345
fi
5446
fi
5547
fi
56-
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then paddle/scripts/travis/before_install.osx.sh; fi
5748
- if [[ "$JOB" == "PRE_COMMIT" ]]; then sudo ln -s /usr/bin/clang-format-3.8 /usr/bin/clang-format; fi
5849
# Paddle is using protobuf 3.1 currently. Protobuf 3.2 breaks the compatibility. So we specify the python
5950
# protobuf version.
60-
- pip install numpy wheel 'protobuf==3.1' sphinx recommonmark sphinx_rtd_theme virtualenv pre-commit requests==2.9.2 LinkChecker
51+
- pip install numpy wheel 'protobuf==3.1' sphinx recommonmark sphinx-rtd-theme==0.1.9 virtualenv pre-commit requests==2.9.2 LinkChecker
6152
script:
6253
- paddle/scripts/travis/main.sh
6354
notifications:

authors

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@ Luo, Tao
2929
Lyu, Qin
3030
Mao, Hongyue
3131
Qian, Xiaojun
32+
Qiao, Longfei
3233
Qi, Jun
3334
Qin, Duohao
3435
Shen, Guolong
3536
Shi, Guangchuan
3637
Song, Xiang
38+
Wang, Helin
3739
Wang, Jiang
3840
Wang, Yanfei
41+
Wang, Yi
3942
Wang, Yong
4043
Weng, Renliang
4144
Xu, Tianbing

book

Submodule book added at 22ed2a0

cmake/FindSphinx.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function( Sphinx_add_target target_name builder conf cache source destination )
7272
${source}
7373
${destination}
7474
COMMENT "Generating sphinx documentation: ${builder}"
75-
COMMAND ln -sf ${destination}/index_*.html ${destination}/index.html
75+
COMMAND cd ${destination} && ln -s ./index_*.html index.html
7676
)
7777

7878
set_property(

cmake/coverallsGcovJsons.cmake

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,13 @@ endmacro()
110110

111111
# Get the coverage data.
112112
file(GLOB_RECURSE GCDA_FILES "${COV_PATH}" "*.gcda")
113-
message("GCDA files:")
113+
message("Process GCDA files:")
114+
message("===============================")
114115

115116
# Get a list of all the object directories needed by gcov
116117
# (The directories the .gcda files and .o files are found in)
117118
# and run gcov on those.
118119
foreach(GCDA ${GCDA_FILES})
119-
message("Process: ${GCDA}")
120-
message("------------------------------------------------------------------------------")
121120
get_filename_component(GCDA_DIR ${GCDA} PATH)
122121

123122
#
@@ -135,7 +134,7 @@ foreach(GCDA ${GCDA_FILES})
135134
# If -p is not specified then the file is named only "the_file.c.gcov"
136135
#
137136
execute_process(
138-
COMMAND ${GCOV_EXECUTABLE} -p -o ${GCDA_DIR} ${GCDA}
137+
COMMAND "${GCOV_EXECUTABLE} -p -o ${GCDA_DIR} ${GCDA} >/dev/null"
139138
WORKING_DIRECTORY ${GCDA_DIR}
140139
)
141140
endforeach()
@@ -383,7 +382,6 @@ foreach(NOT_COVERED_SRC ${COVERAGE_SRCS_REMAINING})
383382
set(GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}]")
384383

385384
# Generate the final JSON for this file.
386-
message("Generate JSON for non-gcov file: ${NOT_COVERED_SRC}...")
387385
string(CONFIGURE ${SRC_FILE_TEMPLATE} FILE_JSON)
388386
set(JSON_GCOV_FILES "${JSON_GCOV_FILES}${FILE_JSON}, ")
389387
endforeach()

cmake/external/protobuf.cmake

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,46 +14,50 @@
1414

1515
INCLUDE(ExternalProject)
1616

17-
SET(PROTOBUF_SOURCES_DIR ${THIRD_PARTY_PATH}/protobuf)
18-
SET(PROTOBUF_INSTALL_DIR ${THIRD_PARTY_PATH}/install/protobuf)
19-
SET(PROTOBUF_INCLUDE_DIR "${PROTOBUF_INSTALL_DIR}/include" CACHE PATH "protobuf include directory." FORCE)
17+
FIND_PACKAGE(Protobuf 3.1)
2018

21-
INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR})
19+
IF(NOT PROTOBUF_FOUND)
20+
SET(PROTOBUF_SOURCES_DIR ${THIRD_PARTY_PATH}/protobuf)
21+
SET(PROTOBUF_INSTALL_DIR ${THIRD_PARTY_PATH}/install/protobuf)
22+
SET(PROTOBUF_INCLUDE_DIR "${PROTOBUF_INSTALL_DIR}/include" CACHE PATH "protobuf include directory." FORCE)
23+
24+
IF(WIN32)
25+
SET(PROTOBUF_LITE_LIBRARY
26+
"${PROTOBUF_INSTALL_DIR}/lib/libprotobuf-lite.lib" CACHE FILEPATH "protobuf lite library." FORCE)
27+
SET(PROTOBUF_LIBRARY
28+
"${PROTOBUF_INSTALL_DIR}/lib/libprotobuf.lib" CACHE FILEPATH "protobuf library." FORCE)
29+
SET(PROTOBUF_PROTOC_LIBRARY
30+
"${PROTOBUF_INSTALL_DIR}/lib/libprotoc.lib" CACHE FILEPATH "protoc library." FORCE)
31+
SET(PROTOBUF_PROTOC_EXECUTABLE "${PROTOBUF_INSTALL_DIR}/bin/protoc.exe" CACHE FILEPATH "protobuf executable." FORCE)
32+
ELSE(WIN32)
33+
SET(PROTOBUF_LITE_LIBRARY
34+
"${PROTOBUF_INSTALL_DIR}/lib/libprotobuf-lite.a" CACHE FILEPATH "protobuf lite library." FORCE)
35+
SET(PROTOBUF_LIBRARY
36+
"${PROTOBUF_INSTALL_DIR}/lib/libprotobuf.a" CACHE FILEPATH "protobuf library." FORCE)
37+
SET(PROTOBUF_PROTOC_LIBRARY
38+
"${PROTOBUF_INSTALL_DIR}/lib/libprotoc.a" CACHE FILEPATH "protoc library." FORCE)
39+
SET(PROTOBUF_PROTOC_EXECUTABLE "${PROTOBUF_INSTALL_DIR}/bin/protoc" CACHE FILEPATH "protobuf executable." FORCE)
40+
ENDIF(WIN32)
2241

23-
IF(WIN32)
24-
SET(PROTOBUF_LITE_LIBRARY
25-
"${PROTOBUF_INSTALL_DIR}/lib/libprotobuf-lite.lib" CACHE FILEPATH "protobuf lite library." FORCE)
26-
SET(PROTOBUF_LIBRARY
27-
"${PROTOBUF_INSTALL_DIR}/lib/libprotobuf.lib" CACHE FILEPATH "protobuf library." FORCE)
28-
SET(PROTOBUF_PROTOC_LIBRARY
29-
"${PROTOBUF_INSTALL_DIR}/lib/libprotoc.lib" CACHE FILEPATH "protoc library." FORCE)
30-
SET(PROTOBUF_PROTOC_EXECUTABLE "${PROTOBUF_INSTALL_DIR}/bin/protoc.exe" CACHE FILEPATH "protobuf executable." FORCE)
31-
ELSE(WIN32)
32-
SET(PROTOBUF_LITE_LIBRARY
33-
"${PROTOBUF_INSTALL_DIR}/lib/libprotobuf-lite.a" CACHE FILEPATH "protobuf lite library." FORCE)
34-
SET(PROTOBUF_LIBRARY
35-
"${PROTOBUF_INSTALL_DIR}/lib/libprotobuf.a" CACHE FILEPATH "protobuf library." FORCE)
36-
SET(PROTOBUF_PROTOC_LIBRARY
37-
"${PROTOBUF_INSTALL_DIR}/lib/libprotoc.a" CACHE FILEPATH "protoc library." FORCE)
38-
SET(PROTOBUF_PROTOC_EXECUTABLE "${PROTOBUF_INSTALL_DIR}/bin/protoc" CACHE FILEPATH "protobuf executable." FORCE)
39-
ENDIF(WIN32)
42+
ExternalProject_Add(
43+
protobuf
44+
${EXTERNAL_PROJECT_LOG_ARGS}
45+
PREFIX ${PROTOBUF_SOURCES_DIR}
46+
UPDATE_COMMAND ""
47+
DEPENDS zlib
48+
GIT_REPOSITORY "https://github.com/google/protobuf.git"
49+
GIT_TAG "9f75c5aa851cd877fb0d93ccc31b8567a6706546"
50+
CONFIGURE_COMMAND
51+
${CMAKE_COMMAND} ${PROTOBUF_SOURCES_DIR}/src/protobuf/cmake
52+
-Dprotobuf_BUILD_TESTS=OFF
53+
-DZLIB_ROOT:FILEPATH=${ZLIB_ROOT}
54+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
55+
-DCMAKE_BUILD_TYPE=Release
56+
-DCMAKE_INSTALL_PREFIX=${PROTOBUF_INSTALL_DIR}
57+
-DCMAKE_INSTALL_LIBDIR=lib
58+
)
4059

41-
ExternalProject_Add(
42-
protobuf
43-
${EXTERNAL_PROJECT_LOG_ARGS}
44-
PREFIX ${PROTOBUF_SOURCES_DIR}
45-
UPDATE_COMMAND ""
46-
DEPENDS zlib
47-
GIT_REPOSITORY "https://github.com/google/protobuf.git"
48-
GIT_TAG "9f75c5aa851cd877fb0d93ccc31b8567a6706546"
49-
CONFIGURE_COMMAND
50-
${CMAKE_COMMAND} ${PROTOBUF_SOURCES_DIR}/src/protobuf/cmake
51-
-Dprotobuf_BUILD_TESTS=OFF
52-
-DZLIB_ROOT:FILEPATH=${ZLIB_ROOT}
53-
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
54-
-DCMAKE_BUILD_TYPE=Release
55-
-DCMAKE_INSTALL_PREFIX=${PROTOBUF_INSTALL_DIR}
56-
-DCMAKE_INSTALL_LIBDIR=lib
57-
)
60+
LIST(APPEND external_project_dependencies protobuf)
61+
ENDIF(NOT PROTOBUF_FOUND)
5862

59-
LIST(APPEND external_project_dependencies protobuf)
63+
INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR})

cmake/external/python.cmake

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,3 @@ ENDIF(PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND)
221221

222222
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIR})
223223
INCLUDE_DIRECTORIES(${PYTHON_NUMPY_INCLUDE_DIR})
224-
225-
MESSAGE("[Paddle] Python Executable: ${PYTHON_EXECUTABLE}")
226-
MESSAGE("[Paddle] Python Include: ${PYTHON_INCLUDE_DIRS}")
227-
MESSAGE("[Paddle] Python Libraries: ${PYTHON_LIBRARIES}")
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import paddle.v2 as paddle
16+
17+
__all__ = ['resnet_cifar10']
18+
19+
20+
def conv_bn_layer(input,
21+
ch_out,
22+
filter_size,
23+
stride,
24+
padding,
25+
active_type=paddle.activation.Relu(),
26+
ch_in=None):
27+
tmp = paddle.layer.img_conv(
28+
input=input,
29+
filter_size=filter_size,
30+
num_channels=ch_in,
31+
num_filters=ch_out,
32+
stride=stride,
33+
padding=padding,
34+
act=paddle.activation.Linear(),
35+
bias_attr=False)
36+
return paddle.layer.batch_norm(input=tmp, act=active_type)
37+
38+
39+
def shortcut(ipt, n_in, n_out, stride):
40+
if n_in != n_out:
41+
return conv_bn_layer(ipt, n_out, 1, stride, 0,
42+
paddle.activation.Linear())
43+
else:
44+
return ipt
45+
46+
47+
def basicblock(ipt, ch_out, stride):
48+
ch_in = ch_out * 2
49+
tmp = conv_bn_layer(ipt, ch_out, 3, stride, 1)
50+
tmp = conv_bn_layer(tmp, ch_out, 3, 1, 1, paddle.activation.Linear())
51+
short = shortcut(ipt, ch_in, ch_out, stride)
52+
return paddle.layer.addto(input=[tmp, short], act=paddle.activation.Relu())
53+
54+
55+
def layer_warp(block_func, ipt, features, count, stride):
56+
tmp = block_func(ipt, features, stride)
57+
for i in range(1, count):
58+
tmp = block_func(tmp, features, 1)
59+
return tmp
60+
61+
62+
def resnet_cifar10(ipt, depth=32):
63+
# depth should be one of 20, 32, 44, 56, 110, 1202
64+
assert (depth - 2) % 6 == 0
65+
n = (depth - 2) / 6
66+
nStages = {16, 64, 128}
67+
conv1 = conv_bn_layer(
68+
ipt, ch_in=3, ch_out=16, filter_size=3, stride=1, padding=1)
69+
res1 = layer_warp(basicblock, conv1, 16, n, 1)
70+
res2 = layer_warp(basicblock, res1, 32, n, 2)
71+
res3 = layer_warp(basicblock, res2, 64, n, 2)
72+
pool = paddle.layer.img_pool(
73+
input=res3, pool_size=8, stride=1, pool_type=paddle.pooling.Avg())
74+
return pool

0 commit comments

Comments
 (0)