Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile and install the static library of fluid inference #7827

Merged
merged 18 commits into from
Mar 7, 2018
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions cmake/external/openblas.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ IF(NOT ${CBLAS_FOUND})
CONFIGURE_COMMAND ""
)
SET(CBLAS_PROVIDER openblas)
FILE(REMOVE_RECURSE ${CBLAS_INSTALL_DIR}/lib/cmake ${CBLAS_INSTALL_DIR}/lib/pkgconfig)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FILE命令应该是在执行cmake命令的时候执行的。extern_openblas是在make阶段执行的,也就是说,必须要执行完extern_openblas这个任务之后,才会生成${CBLAS_INSTALL_DIR}/lib/cmake${CBLAS_INSTALL_DIR}/lib/pkgconfig这两个目录。所以这条语句应该达不到删除的目的。应该使用execute_process语句删除,并且该语句需要依赖extern_openblas这个任务。

IF(WITH_C_API)
INSTALL(DIRECTORY ${CBLAS_INC_DIR} DESTINATION third_party/openblas)
# Because libopenblas.a is a symbolic link of another library, thus need to
Expand All @@ -100,11 +101,6 @@ IF(NOT ${CBLAS_FOUND})
\"${CBLAS_INSTALL_DIR}/lib -> ${CMAKE_INSTALL_PREFIX}/${TMP_INSTALL_DIR}\"
)"
)
INSTALL(CODE "execute_process(
COMMAND rm -r ${CMAKE_INSTALL_PREFIX}/${TMP_INSTALL_DIR}/cmake
${CMAKE_INSTALL_PREFIX}/${TMP_INSTALL_DIR}/pkgconfig
)"
)
ENDIF()
ENDIF(NOT ${CBLAS_FOUND})

Expand Down
10 changes: 8 additions & 2 deletions cmake/inference_lib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ IF(NOT PROTOBUF_FOUND)
)
ENDIF(NOT PROTOBUF_FOUND)

set(dst_dir "${CMAKE_INSTALL_PREFIX}/third_party/install/openblas")
copy(openblas_lib
SRCS ${CBLAS_INSTALL_DIR}/lib ${CBLAS_INSTALL_DIR}/include
DSTS ${dst_dir} ${dst_dir}
)

# paddle fluid module
set(src_dir "${PADDLE_SOURCE_DIR}/paddle")
set(dst_dir "${CMAKE_INSTALL_PREFIX}/paddle")
Expand All @@ -69,7 +75,7 @@ copy(memory_lib

set(module "inference")
copy(inference_lib DEPENDS paddle_fluid_shared
SRCS ${src_dir}/${module}/*.h ${PADDLE_BINARY_DIR}/paddle/inference/libpaddle_fluid.so
SRCS ${src_dir}/${module}/*.h ${PADDLE_BINARY_DIR}/paddle/inference/libpaddle_fluid.*
DSTS ${dst_dir}/${module} ${dst_dir}/${module}
)

Expand All @@ -87,4 +93,4 @@ copy(string_lib

add_custom_target(inference_lib_dist DEPENDS
inference_lib framework_lib memory_lib platform_lib string_lib
gflags_lib glog_lib protobuf_lib eigen3_lib)
gflags_lib glog_lib protobuf_lib eigen3_lib openblas_lib)
14 changes: 13 additions & 1 deletion paddle/inference/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,20 @@ cc_library(paddle_fluid_api
SRCS io.cc
DEPS ${FLUID_CORE_MODULES} ${GLOB_OP_LIB})

if(WITH_GPU)
set(GPU_DEPS gpu_info dynload_cuda)
endif()
# Merge all modules into a single static library
cc_library(paddle_fluid DEPS paddle_fluid_api ${FLUID_CORE_MODULES} ${GLOB_OP_LIB})
cc_library(paddle_fluid DEPS paddle_fluid_api
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memory模块一样,我们在每个模块最后加一个cc_library,将该模块里面所有的target都合并成一个静态库?

cc_library(paddle_memory
DEPS
memory
memcpy
meta_data
meta_cache
memory_block
buddy_allocator
system_allocator)

这样,在inference里面,我们只需要依赖paddle_memroy, paddle_framework, paddle_operators, paddle_string, paddle_platform。不过这样还是不能自动添加。

framework_proto ddim tensor place scope threadpool attribute
shape_inference cpu_info op_registry operator op_proto_maker op_info
data_transform data_device_transform data_type_transform data_layout_transform
selected_rows lod_tensor lod_rank_table dynload_warpctc dynamic_loader
device_context profiler reader feed_fetch_method
${GPU_DEPS}
${OP_MATH_MODULES}
${FLUID_CORE_MODULES}
${GLOB_OP_LIB})

# Create shared library
add_library(paddle_fluid_shared SHARED io.cc)
Expand Down
4 changes: 4 additions & 0 deletions paddle/operators/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ cc_test(selected_rows_functor_test SRCS selected_rows_functor_test.cc DEPS selec
cc_test(im2col_test SRCS im2col_test.cc DEPS math_function tensor)
cc_test(vol2col_test SRCS vol2col_test.cc DEPS vol2col tensor)
cc_test(sequence_padding_test SRCS sequence_padding_test.cc DEPS sequence_padding)

set(OP_MATH_MODULES math_function selected_rows_functor softmax cross_entropy pooling sequence_pooling
vol2col context_project sequence2batch sequence_padding sequence_scale lstm_compute maxouting
unpooling gru_compute cos_sim_functor activation_functions CACHE INTERNAL "Global OP Math Modules")