Skip to content

Commit ae2b3cd

Browse files
authored
Merge pull request #1 from PaddlePaddle/develop
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle
2 parents e5fe893 + 6c0356e commit ae2b3cd

File tree

3,117 files changed

+132292
-58621
lines changed

Some content is hidden

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

3,117 files changed

+132292
-58621
lines changed

.copyright.hook

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
from __future__ import absolute_import
2+
from __future__ import print_function
3+
from __future__ import unicode_literals
4+
5+
import argparse
6+
import io, re
7+
import sys, os
8+
import subprocess
9+
import platform
10+
11+
COPYRIGHT = '''
12+
Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.
13+
14+
Licensed under the Apache License, Version 2.0 (the "License");
15+
you may not use this file except in compliance with the License.
16+
You may obtain a copy of the License at
17+
18+
http://www.apache.org/licenses/LICENSE-2.0
19+
20+
Unless required by applicable law or agreed to in writing, software
21+
distributed under the License is distributed on an "AS IS" BASIS,
22+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23+
See the License for the specific language governing permissions and
24+
limitations under the License.
25+
'''
26+
27+
LANG_COMMENT_MARK = None
28+
29+
NEW_LINE_MARK = None
30+
31+
COPYRIGHT_HEADER = None
32+
33+
if platform.system() == "Windows":
34+
NEW_LINE_MARK = "\r\n"
35+
else:
36+
NEW_LINE_MARK = '\n'
37+
COPYRIGHT_HEADER = COPYRIGHT.split(NEW_LINE_MARK)[1]
38+
p = re.search('(\d{4})', COPYRIGHT_HEADER).group(0)
39+
process = subprocess.Popen(["date", "+%Y"], stdout=subprocess.PIPE)
40+
date, err = process.communicate()
41+
date = date.decode("utf-8").rstrip("\n")
42+
COPYRIGHT_HEADER = COPYRIGHT_HEADER.replace(p, date)
43+
44+
45+
def generate_copyright(template, lang='C'):
46+
if lang == 'Python':
47+
LANG_COMMENT_MARK = '#'
48+
else:
49+
LANG_COMMENT_MARK = "//"
50+
51+
lines = template.split(NEW_LINE_MARK)
52+
BLANK = " "
53+
ans = LANG_COMMENT_MARK + BLANK + COPYRIGHT_HEADER + NEW_LINE_MARK
54+
for lino, line in enumerate(lines):
55+
if lino == 0 or lino == 1 or lino == len(lines) - 1: continue
56+
if len(line) == 0:
57+
BLANK = ""
58+
else:
59+
BLANK = " "
60+
ans += LANG_COMMENT_MARK + BLANK + line + NEW_LINE_MARK
61+
62+
return ans + "\n"
63+
64+
65+
def lang_type(filename):
66+
if filename.endswith(".py"):
67+
return "Python"
68+
elif filename.endswith(".h"):
69+
return "C"
70+
elif filename.endswith(".c"):
71+
return "C"
72+
elif filename.endswith(".hpp"):
73+
return "C"
74+
elif filename.endswith(".cc"):
75+
return "C"
76+
elif filename.endswith(".cpp"):
77+
return "C"
78+
elif filename.endswith(".cu"):
79+
return "C"
80+
elif filename.endswith(".cuh"):
81+
return "C"
82+
elif filename.endswith(".go"):
83+
return "C"
84+
elif filename.endswith(".proto"):
85+
return "C"
86+
else:
87+
print("Unsupported filetype %s", filename)
88+
exit(0)
89+
90+
91+
PYTHON_ENCODE = re.compile("^[ \t\v]*#.*?coding[:=][ \t]*([-_.a-zA-Z0-9]+)")
92+
93+
94+
def main(argv=None):
95+
parser = argparse.ArgumentParser(
96+
description='Checker for copyright declaration.')
97+
parser.add_argument('filenames', nargs='*', help='Filenames to check')
98+
args = parser.parse_args(argv)
99+
100+
retv = 0
101+
for filename in args.filenames:
102+
fd = io.open(filename, encoding="utf-8")
103+
first_line = fd.readline()
104+
second_line = fd.readline()
105+
if "COPYRIGHT (C)" in first_line.upper(): continue
106+
if first_line.startswith("#!") or PYTHON_ENCODE.match(
107+
second_line) != None or PYTHON_ENCODE.match(first_line) != None:
108+
continue
109+
original_contents = io.open(filename, encoding="utf-8").read()
110+
new_contents = generate_copyright(
111+
COPYRIGHT, lang_type(filename)) + original_contents
112+
print('Auto Insert Copyright Header {}'.format(filename))
113+
retv = 1
114+
with io.open(filename, 'w') as output_file:
115+
output_file.write(new_contents)
116+
117+
return retv
118+
119+
120+
if __name__ == '__main__':
121+
exit(main())

.gitignore

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
paddle/operators/check_t.save
2+
paddle/operators/check_tensor.ls
3+
paddle/operators/tensor.save
4+
python/paddle/v2/fluid/tests/book/image_classification_resnet.inference.model/
5+
python/paddle/v2/fluid/tests/book/image_classification_vgg.inference.model/
6+
python/paddle/v2/fluid/tests/book/label_semantic_roles.inference.model/
17
*.DS_Store
28
build/
39
build_doc/
@@ -19,13 +25,3 @@ third_party/
1925

2026
# clion workspace.
2127
cmake-build-*
22-
23-
# generated while compiling
24-
python/paddle/v2/fluid/core.so
25-
paddle/pybind/pybind.h
26-
CMakeFiles
27-
cmake_install.cmake
28-
paddle/.timestamp
29-
python/paddlepaddle.egg-info/
30-
paddle/pybind/pybind.h
31-
python/paddle/version.py

.pre-commit-config.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
repos:
12
- repo: https://github.com/Lucas-C/pre-commit-hooks.git
23
sha: v1.0.1
34
hooks:
@@ -25,9 +26,25 @@
2526
entry: bash ./.clang_format.hook -i
2627
language: system
2728
files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|proto)$
29+
- repo: local
30+
hooks:
31+
- id: cpplint-cpp-source
32+
name: cpplint
33+
description: Check C++ code style using cpplint.py.
34+
entry: bash ./tools/codestyle/cpplint_pre_commit.hook
35+
language: system
36+
files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx)$
2837
- repo: https://github.com/PaddlePaddle/pre-commit-golang
2938
sha: 8337620115c25ff8333f1b1a493bd031049bd7c0
3039
hooks:
3140
- id: go-fmt
3241
types:
3342
- go
43+
- repo: local
44+
hooks:
45+
- id: copyright_checker
46+
name: copyright_checker
47+
entry: python ./.copyright.hook
48+
language: system
49+
files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|proto|py)$
50+
exclude: (?!.*third_party)^.*$ | (?!.*book)^.*$

.travis.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ cache:
44
- $HOME/.ccache
55
- $HOME/.cache/pip
66
- $TRAVIS_BUILD_DIR/build/third_party
7+
- $TRAVIS_BUILD_DIR/build_android/third_party
78
sudo: required
89
dist: trusty
10+
services:
11+
- docker
912
os:
1013
- linux
1114
env:
1215
- JOB=build_doc
1316
- JOB=check_style
17+
- JOB=build_android
1418
addons:
1519
apt:
1620
packages:
@@ -30,7 +34,7 @@ addons:
3034
- automake
3135
- libtool
3236
- ccache
33-
ssh_known_hosts: 52.76.173.135
37+
ssh_known_hosts: 13.229.163.131
3438
before_install:
3539
- if [[ "$JOB" == "check_style" ]]; then sudo ln -s /usr/bin/clang-format-3.8 /usr/bin/clang-format; fi
3640
# Paddle is using protobuf 3.1 currently. Protobuf 3.2 breaks the compatibility. So we specify the python
@@ -41,16 +45,18 @@ before_install:
4145
function timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; }
4246
script:
4347
- |
44-
timeout 2580 paddle/scripts/travis/${JOB}.sh # 43min timeout
45-
RESULT=$?; if [ $RESULT -eq 0 ] || [ $RESULT -eq 142 ]; then true ;else exit 1; fi;
48+
# 43min timeout
49+
if [[ "$JOB" == "build_android" ]]; then timeout 2580 docker run -it --rm -v "$TRAVIS_BUILD_DIR:/paddle" paddlepaddle/paddle:latest-dev-android;
50+
else timeout 2580 paddle/scripts/travis/${JOB}.sh; fi;
51+
RESULT=$?; if [ $RESULT -eq 0 ] || [ $RESULT -eq 142 ]; then true; else exit 1; fi;
4652
- |
4753
if [[ "$JOB" != "build_doc" ]]; then exit 0; fi;
4854
if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then exit 0; fi;
4955
if [[ "$TRAVIS_BRANCH" != "develop" && ! "$TRAVIS_BRANCH" =~ ^v[[:digit:]]+\.[[:digit:]]+(\.[[:digit:]]+)?(-\S*)?$ ]]; then exit 0; fi;
5056
export DEPLOY_DOCS_SH=https://raw.githubusercontent.com/PaddlePaddle/PaddlePaddle.org/master/scripts/deploy/deploy_docs.sh
5157
export DOCS_DIR=`pwd`
5258
cd ..
53-
curl $DEPLOY_DOCS_SH | bash -s $CONTENT_DEC_PASSWD $TRAVIS_BRANCH $DOCS_DIR $DOCS_DIR/build/doc
59+
curl $DEPLOY_DOCS_SH | bash -s $CONTENT_DEC_PASSWD $TRAVIS_BRANCH $DOCS_DIR $DOCS_DIR/build/doc/
5460
notifications:
5561
email:
5662
on_success: change

AUTHORS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
| Github account | name |
22
|---|---|
3+
| abhinavarora | Abhinav Arora |
34
| backyes | Yan-Fei Wang |
45
| beckett1124 | Bin Qi |
5-
| Canpio | Jia-Yi Feng |
6+
| JiayiFeng | Jia-Yi Feng |
67
| chengxiaohua1105 | Xiao-Hua Cheng |
78
| cxwangyi, yiwangbaidu, wangkuiyi | Yi Wang |
89
| cxysteven | Xing-Yi Cheng |

CMakeLists.txt

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
1+
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@ set(PADDLE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
1919

2020
include(system)
2121

22-
project(paddle CXX C Go)
22+
project(paddle CXX C)
2323
message(STATUS "CXX compiler: ${CMAKE_CXX_COMPILER}, version: "
2424
"${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
2525
message(STATUS "C compiler: ${CMAKE_C_COMPILER}, version: "
@@ -31,18 +31,16 @@ if(NOT CMAKE_CROSSCOMPILING)
3131
endif(NOT CMAKE_CROSSCOMPILING)
3232
find_package(Git REQUIRED)
3333
find_package(Threads REQUIRED)
34-
if(NOT ANDROID AND NOT IOS)
35-
find_package(Boost QUIET)
36-
endif()
3734

3835
include(simd)
3936

4037
################################ Configurations #######################################
4138
option(WITH_GPU "Compile PaddlePaddle with NVIDIA GPU" ${CUDA_FOUND})
39+
option(WITH_AMD_GPU "Compile PaddlePaddle with AMD GPU" OFF)
4240
option(WITH_AVX "Compile PaddlePaddle with AVX intrinsics" ${AVX_FOUND})
4341
option(WITH_MKL "Compile PaddlePaddle with MKL support." ${AVX_FOUND})
4442
option(WITH_DSO "Compile PaddlePaddle with dynamic linked CUDA" ON)
45-
option(WITH_TESTING "Compile PaddlePaddle with unit testing" ON)
43+
option(WITH_TESTING "Compile PaddlePaddle with unit testing" OFF)
4644
option(WITH_SWIG_PY "Compile PaddlePaddle with inference api" ON)
4745
option(WITH_STYLE_CHECK "Compile PaddlePaddle with style check" ON)
4846
option(WITH_PYTHON "Compile PaddlePaddle with python interpreter" ON)
@@ -55,12 +53,14 @@ option(WITH_COVERAGE "Compile PaddlePaddle with code coverage" OFF)
5553
option(COVERALLS_UPLOAD "Package code coverage data to coveralls" OFF)
5654
option(ON_TRAVIS "Exclude special unit test on Travis CI" OFF)
5755
option(WITH_C_API "Compile PaddlePaddle with C-API(Prediction)" OFF)
56+
option(WITH_FLUID_ONLY "Compile PaddlePaddle fluid only" OFF)
5857
option(WITH_GOLANG "Compile PaddlePaddle with GOLANG" OFF)
5958
option(GLIDE_INSTALL "Download and install go dependencies " ON)
6059
option(USE_NNPACK "Compile PaddlePaddle with NNPACK library" OFF)
6160
option(WITH_DISTRIBUTE "Compile with grpc distributed support" OFF)
6261
option(USE_EIGEN_FOR_BLAS "Use matrix multiplication in Eigen" OFF)
6362
option(WITH_ARM_FP16 "Use half precision support on armv8.2-a cpu" OFF)
63+
option(WITH_FAST_BUNDLE_TEST "Bundle tests that can be run in a single process together to reduce launch overhead" OFF)
6464

6565
# CMAKE_BUILD_TYPE
6666
if(NOT CMAKE_BUILD_TYPE)
@@ -107,6 +107,10 @@ if (WITH_C_API AND WITH_PYTHON)
107107
"different Python interpreter from compiling.")
108108
endif()
109109

110+
if (WITH_C_API)
111+
set(WITH_FLUID_ONLY OFF CACHE STRING "Disable install fluid when compile the C_API" FORCE)
112+
endif()
113+
110114
if(MOBILE_INFERENCE)
111115
set(THIRD_PARTY_BUILD_TYPE MinSizeRel)
112116
else()
@@ -134,14 +138,18 @@ include(external/openblas) # download, build, install openblas
134138
include(external/mkldnn) # download, build, install mkldnn
135139
include(external/swig) # download, build, install swig
136140
include(external/warpctc) # download, build, install warpctc
141+
include(external/boost) # download boost
137142
include(external/any) # download libn::any
138143
include(external/eigen) # download eigen3
139144
include(external/pybind11) # download pybind11
140-
include(external/nccl)
141145
include(external/cares)
142146
include(external/grpc)
147+
include(external/snappy) # download snappy
148+
include(external/snappystream)
149+
include(external/threadpool)
143150

144151
include(cudnn) # set cudnn libraries, must before configure
152+
include(cupti)
145153
include(configure) # add paddle env configuration
146154
include(generic) # simplify cmake module
147155
include(package) # set paddle packages
@@ -152,27 +160,33 @@ include(rdma) # set rdma libraries
152160
include(flags) # set paddle compile flags
153161
include(version) # set PADDLE_VERSION
154162
include(coveralls) # set code coverage
163+
include(inference_lib) # add paddle fluid inference libraries
155164

156165

157166
include_directories("${PADDLE_SOURCE_DIR}")
158167
include_directories("${PADDLE_SOURCE_DIR}/paddle/cuda/include")
159168
include_directories("${CMAKE_CURRENT_BINARY_DIR}/proto")
160169
include_directories("${CMAKE_CURRENT_BINARY_DIR}/go/pserver/client/c")
161-
include_directories(${Boost_INCLUDE_DIRS})
162170

163171
set(EXTERNAL_LIBS
164-
${GFLAGS_LIBRARIES}
165-
${GLOG_LIBRARIES}
172+
gflags
173+
glog
166174
${CBLAS_LIBRARIES}
167-
${PROTOBUF_LIBRARY}
168-
${ZLIB_LIBRARIES}
175+
protobuf
176+
zlib
169177
${PYTHON_LIBRARIES}
170178
)
171179

172180
if(WITH_GPU)
173-
include(cuda)
181+
include(cuda)
182+
include(tensorrt)
174183
endif(WITH_GPU)
175184

185+
if(WITH_AMD_GPU)
186+
find_package(HIP)
187+
include(hip)
188+
endif(WITH_AMD_GPU)
189+
176190
if(WITH_MKLML)
177191
list(APPEND EXTERNAL_LIBS ${MKLML_IOMP_LIB})
178192
endif()
@@ -197,17 +211,18 @@ endif()
197211
# "add_subdirectory(paddle)" and "add_subdirectory(python)" should be
198212
# placed after this block, because they depends on it.
199213
if(WITH_GOLANG)
214+
enable_language(Go)
200215
add_subdirectory(go)
201216
endif(WITH_GOLANG)
202217

203218
set(PADDLE_PYTHON_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/python/build")
204219

205-
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
206-
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
220+
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
221+
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
207222

208223
add_subdirectory(paddle)
209224
if(WITH_PYTHON)
210-
add_subdirectory(python)
225+
add_subdirectory(python)
211226
endif()
212227

213228
if(WITH_DOC)

0 commit comments

Comments
 (0)