Skip to content

Commit 136a591

Browse files
committed
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into no_counter_on_pserver
2 parents 007e6c2 + 1185a1b commit 136a591

File tree

220 files changed

+4585
-1236
lines changed

Some content is hidden

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

220 files changed

+4585
-1236
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ include(rdma) # set rdma libraries
156156
include(flags) # set paddle compile flags
157157
include(version) # set PADDLE_VERSION
158158
include(coveralls) # set code coverage
159+
include(inference_lib) # add paddle fluid inference libraries
159160

160161

161162
include_directories("${PADDLE_SOURCE_DIR}")

cmake/external/eigen.cmake

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,3 @@ endif()
2828
add_dependencies(eigen3 extern_eigen3)
2929

3030
LIST(APPEND external_project_dependencies eigen3)
31-
32-
IF(NOT WITH_C_API AND WITH_FLUID)
33-
INSTALL(FILES ${EIGEN_INCLUDE_DIR}/Eigen/Core DESTINATION third_party/eigen3/Eigen)
34-
INSTALL(DIRECTORY ${EIGEN_INCLUDE_DIR}/Eigen/src DESTINATION third_party/eigen3/Eigen)
35-
INSTALL(DIRECTORY ${EIGEN_INCLUDE_DIR}/unsupported/Eigen DESTINATION third_party/eigen3/unsupported)
36-
ENDIF()

cmake/external/gflags.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ ADD_DEPENDENCIES(gflags extern_gflags)
5252

5353
LIST(APPEND external_project_dependencies gflags)
5454

55-
IF(WITH_C_API OR WITH_FLUID)
55+
IF(WITH_C_API)
5656
INSTALL(DIRECTORY ${GFLAGS_INCLUDE_DIR} DESTINATION third_party/gflags)
5757
IF(ANDROID)
5858
INSTALL(FILES ${GFLAGS_LIBRARIES} DESTINATION third_party/gflags/lib/${ANDROID_ABI})

cmake/external/glog.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ LINK_LIBRARIES(glog gflags)
6868

6969
LIST(APPEND external_project_dependencies glog)
7070

71-
IF(WITH_C_API OR WITH_FLUID)
71+
IF(WITH_C_API)
7272
INSTALL(DIRECTORY ${GLOG_INCLUDE_DIR} DESTINATION third_party/glog)
7373
IF(ANDROID)
7474
INSTALL(FILES ${GLOG_LIBRARIES} DESTINATION third_party/glog/lib/${ANDROID_ABI})

cmake/external/protobuf.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ IF(NOT PROTOBUF_FOUND)
250250
SET(PROTOBUF_PROTOC_LIBRARY ${extern_protobuf_PROTOC_LIBRARY}
251251
CACHE FILEPATH "protoc library." FORCE)
252252

253-
IF(WITH_C_API OR WITH_FLUID)
253+
IF(WITH_C_API)
254254
INSTALL(DIRECTORY ${PROTOBUF_INCLUDE_DIR} DESTINATION third_party/protobuf)
255255
IF(ANDROID)
256256
INSTALL(FILES ${PROTOBUF_LITE_LIBRARY} DESTINATION third_party/protobuf/lib/${ANDROID_ABI})

cmake/external/warpctc.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ ExternalProject_Add(
5252
-DWITH_TORCH=OFF
5353
-DCMAKE_DISABLE_FIND_PACKAGE_Torch=ON
5454
-DBUILD_SHARED=ON
55+
-DBUILD_TESTS=OFF
5556
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
5657
-DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}
5758
${EXTERNAL_OPTIONAL_ARGS}

cmake/generic.cmake

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,20 +179,24 @@ function(cc_library TARGET_NAME)
179179
set(oneValueArgs "")
180180
set(multiValueArgs SRCS DEPS)
181181
cmake_parse_arguments(cc_library "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
182-
if (cc_library_SRCS)
183-
if (cc_library_SHARED OR cc_library_shared) # build *.so
182+
if(cc_library_SRCS)
183+
if(cc_library_SHARED OR cc_library_shared) # build *.so
184184
add_library(${TARGET_NAME} SHARED ${cc_library_SRCS})
185185
else()
186186
add_library(${TARGET_NAME} STATIC ${cc_library_SRCS})
187187
endif()
188-
if (cc_library_DEPS)
188+
if(cc_library_DEPS)
189189
# Don't need link libwarpctc.so
190-
if ("${cc_library_DEPS};" MATCHES "warpctc;")
190+
if("${cc_library_DEPS};" MATCHES "warpctc;")
191191
list(REMOVE_ITEM cc_library_DEPS warpctc)
192192
add_dependencies(${TARGET_NAME} warpctc)
193193
endif()
194+
# Support linking flags: --whole-archive (Linux) / -force_load (MacOS)
195+
target_circle_link_libraries(${TARGET_NAME} ${cc_library_DEPS})
196+
if("${cc_library_DEPS}" MATCHES "ARCHIVE_START")
197+
list(REMOVE_ITEM cc_library_DEPS ARCHIVE_START ARCHIVE_END)
198+
endif()
194199
add_dependencies(${TARGET_NAME} ${cc_library_DEPS})
195-
target_link_libraries(${TARGET_NAME} ${cc_library_DEPS})
196200
endif()
197201

198202
# cpplint code style

cmake/inference_lib.cmake

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# make package for paddle fluid shared and static library
2+
function(copy TARGET)
3+
set(options "")
4+
set(oneValueArgs "")
5+
set(multiValueArgs SRCS DSTS DEPS)
6+
cmake_parse_arguments(copy_lib "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
7+
8+
list(LENGTH copy_lib_SRCS copy_lib_SRCS_len)
9+
list(LENGTH copy_lib_DSTS copy_lib_DSTS_len)
10+
if(NOT ${copy_lib_SRCS_len} EQUAL ${copy_lib_DSTS_len})
11+
message(FATAL_ERROR "${TARGET} source numbers are not equal to destination numbers")
12+
endif()
13+
math(EXPR len "${copy_lib_SRCS_len} - 1")
14+
15+
add_custom_target(${TARGET} DEPENDS ${copy_lib_DEPS})
16+
foreach(index RANGE ${len})
17+
list(GET copy_lib_SRCS ${index} src)
18+
list(GET copy_lib_DSTS ${index} dst)
19+
add_custom_command(TARGET ${TARGET} PRE_BUILD COMMAND mkdir -p "${dst}")
20+
if(IS_DIRECTORY ${src})
21+
add_custom_command(TARGET ${TARGET} PRE_BUILD COMMAND cp -r "${src}" "${dst}")
22+
else()
23+
add_custom_command(TARGET ${TARGET} PRE_BUILD COMMAND cp "${src}" "${dst}")
24+
endif()
25+
endforeach()
26+
endfunction()
27+
28+
# third party
29+
set(dst_dir "${CMAKE_INSTALL_PREFIX}/third_party/eigen3")
30+
copy(eigen3_lib
31+
SRCS ${EIGEN_INCLUDE_DIR}/Eigen/Core ${EIGEN_INCLUDE_DIR}/Eigen/src ${EIGEN_INCLUDE_DIR}/unsupported/Eigen
32+
DSTS ${dst_dir}/Eigen ${dst_dir}/Eigen ${dst_dir}/unsupported
33+
)
34+
35+
set(dst_dir "${CMAKE_INSTALL_PREFIX}/third_party/install/gflags")
36+
copy(gflags_lib
37+
SRCS ${GFLAGS_INCLUDE_DIR} ${GFLAGS_LIBRARIES}
38+
DSTS ${dst_dir} ${dst_dir}/lib
39+
)
40+
41+
set(dst_dir "${CMAKE_INSTALL_PREFIX}/third_party/install/glog")
42+
copy(glog_lib
43+
SRCS ${GLOG_INCLUDE_DIR} ${GLOG_LIBRARIES}
44+
DSTS ${dst_dir} ${dst_dir}/lib
45+
)
46+
47+
IF(NOT PROTOBUF_FOUND)
48+
set(dst_dir "${CMAKE_INSTALL_PREFIX}/third_party/install/protobuf")
49+
copy(protobuf_lib
50+
SRCS ${PROTOBUF_INCLUDE_DIR} ${PROTOBUF_LITE_LIBRARY}
51+
DSTS ${dst_dir} ${dst_dir}/lib
52+
)
53+
ENDIF(NOT PROTOBUF_FOUND)
54+
55+
# paddle fluid module
56+
set(src_dir "${PADDLE_SOURCE_DIR}/paddle")
57+
set(dst_dir "${CMAKE_INSTALL_PREFIX}/paddle")
58+
set(module "framework")
59+
copy(framework_lib DEPS framework_py_proto
60+
SRCS ${src_dir}/${module}/*.h ${src_dir}/${module}/details/*.h ${PADDLE_BINARY_DIR}/paddle/framework/framework.pb.h
61+
DSTS ${dst_dir}/${module} ${dst_dir}/${module}/details ${dst_dir}/${module}
62+
)
63+
64+
set(module "memory")
65+
copy(memory_lib
66+
SRCS ${src_dir}/${module}/*.h ${src_dir}/${module}/detail/*.h
67+
DSTS ${dst_dir}/${module} ${dst_dir}/${module}/detail
68+
)
69+
70+
set(module "inference")
71+
copy(inference_lib DEPENDS paddle_fluid_shared
72+
SRCS ${src_dir}/${module}/*.h ${PADDLE_BINARY_DIR}/paddle/inference/libpaddle_fluid.so
73+
DSTS ${dst_dir}/${module} ${dst_dir}/${module}
74+
)
75+
76+
set(module "platform")
77+
copy(platform_lib
78+
SRCS ${src_dir}/${module}/*.h ${src_dir}/${module}/dynload/*.h ${src_dir}/${module}/details/*.h
79+
DSTS ${dst_dir}/${module} ${dst_dir}/${module}/dynload ${dst_dir}/${module}/details
80+
)
81+
82+
set(module "string")
83+
copy(string_lib
84+
SRCS ${src_dir}/${module}/*.h ${src_dir}/${module}/tinyformat/*.h
85+
DSTS ${dst_dir}/${module} ${dst_dir}/${module}/tinyformat
86+
)
87+
88+
add_custom_target(inference_lib_dist DEPENDS
89+
inference_lib framework_lib memory_lib platform_lib string_lib
90+
gflags_lib glog_lib protobuf_lib eigen3_lib)
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)