-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 shared library of fluid inference #7572
Changes from 13 commits
3cf23be
816e556
984d09c
c0f0f23
2be7cf9
3635388
c96b7e8
fc75da7
5f202db
a12db45
f1c4c80
c0da87f
5c05653
acb13e7
8b442e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,3 +88,10 @@ cc_test(init_test SRCS init_test.cc DEPS init) | |
|
||
cc_test(op_kernel_type_test SRCS op_kernel_type_test.cc DEPS place device_context framework_proto) | ||
cc_test(cow_ptr_tests SRCS details/cow_ptr_test.cc) | ||
|
||
if(NOT WITH_C_API AND WITH_FLUID) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have to call CMake's install function in these CMakeLists.txt files? I am afraid that this would break the Bazel-style of the CMakeLists.txt files, which, was achieved by inventing the generic.cmake file. Could we not install these header and library files, but leave them in the source directory and the build directory, but let users just build PaddlePaddle and include/link to these header files and library files? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, We need to install
The style of CMake's install function is indeed different from Bazel-style. However, Bazel doesn't have a similar install function. Thus, it's hard for the user to deploy it. For example, building-tensorflow-as-a-standalone-project need to manually copy include and libraries for users.
I think that
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 后面的PR,会将
那么在 另外,需要 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
是的。#6346 已经考虑加
好的。 |
||
file(GLOB FRAMEWORK_HEADERS *.h) | ||
install(FILES ${FRAMEWORK_HEADERS} DESTINATION include/paddle/framework) | ||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/framework.pb.h DESTINATION include/paddle/framework) | ||
install(FILES details/cow_ptr.h details/op_registry.h DESTINATION include/paddle/framework/details) | ||
endif() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,28 @@ | ||
set(FLUID_CORE_MODULES | ||
backward proto_desc paddle_memory executor prune init ${GLOB_OP_LIB}) | ||
set(FLUID_CORE_MODULES proto_desc paddle_memory executor prune init) | ||
|
||
cc_library(paddle_fluid_api | ||
SRCS inference.cc | ||
DEPS ${FLUID_CORE_MODULES}) | ||
DEPS ${FLUID_CORE_MODULES} ${GLOB_OP_LIB}) | ||
|
||
# Merge all modules into a simgle static library | ||
cc_library(paddle_fluid DEPS paddle_fluid_api ${FLUID_CORE_MODULES}) | ||
# Merge all modules into a single static library | ||
cc_library(paddle_fluid DEPS paddle_fluid_api ${FLUID_CORE_MODULES} ${GLOB_OP_LIB}) | ||
|
||
# Create shared library | ||
add_library(paddle_fluid_shared SHARED inference.cc) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shared library不能直接叫 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 考虑到两点:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 一个是静态库,一个是动态库,名字也不能一样? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 比如,如果按照下面这样写:
cmake会报错:
不过能不能先编译出来,然后再在cmake里面改成一样的名字。 |
||
|
||
target_circle_link_libraries(paddle_fluid_shared | ||
ARCHIVE_START | ||
${GLOB_OP_LIB} | ||
ARCHIVE_END | ||
${FLUID_CORE_MODULES}) | ||
|
||
SET_TARGET_PROPERTIES(paddle_fluid_shared PROPERTIES OUTPUT_NAME paddle_fluid) | ||
|
||
# install library & headers | ||
if(NOT WITH_C_API AND WITH_FLUID) | ||
install(FILES inference.h DESTINATION include/paddle/inference) | ||
install(TARGETS paddle_fluid_shared DESTINATION lib) | ||
endif() | ||
|
||
add_executable(example example.cc) | ||
if(APPLE) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
cc_library(stringpiece SRCS piece.cc) | ||
cc_test(stringpiece_test SRCS piece_test.cc DEPS stringpiece glog gflags) | ||
|
||
cc_test(stringprintf_test SRCS printf_test.cc DEPS glog gflags) | ||
cc_test(to_string_test SRCS to_string_test.cc) | ||
|
||
if(NOT WITH_C_API AND WITH_FLUID) | ||
file(GLOB STRING_HEADERS *.h) | ||
install(FILES ${STRING_HEADERS} DESTINATION include/paddle/string) | ||
install(FILES tinyformat/tinyformat.h DESTINATION include/paddle/string/tinyformat) | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we rename WITH_C_API into PADDLE_BUILD_INFERENCE_LIB ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As WITH_C_API is used for a long time in old PaddlePaddle, users are familiar with it, we may remain it. And for fluid, we will add WITH_FLUID option for both training and inference. (see #7578 (comment))