-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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 10 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 |
---|---|---|
|
@@ -55,6 +55,7 @@ option(WITH_COVERAGE "Compile PaddlePaddle with code coverage" OFF) | |
option(COVERALLS_UPLOAD "Package code coverage data to coveralls" OFF) | ||
option(ON_TRAVIS "Exclude special unit test on Travis CI" OFF) | ||
option(WITH_C_API "Compile PaddlePaddle with C-API(Prediction)" OFF) | ||
option(WITH_FLUID "Compile PaddlePaddle fluid only" ON) | ||
option(WITH_GOLANG "Compile PaddlePaddle with GOLANG" OFF) | ||
option(GLIDE_INSTALL "Download and install go dependencies " ON) | ||
option(USE_NNPACK "Compile PaddlePaddle with NNPACK library" OFF) | ||
|
@@ -107,6 +108,10 @@ if (WITH_C_API AND WITH_PYTHON) | |
"different Python interpreter from compiling.") | ||
endif() | ||
|
||
if (WITH_C_API) | ||
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. 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 commentThe 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)) |
||
set(WITH_FLUID OFF CACHE STRING "Disable install fluid when compile the C_API" FORCE) | ||
endif() | ||
|
||
if(MOBILE_INFERENCE) | ||
set(THIRD_PARTY_BUILD_TYPE MinSizeRel) | ||
else() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,3 +84,10 @@ cc_test(op_kernel_type_test SRCS op_kernel_type_test.cc DEPS place device_contex | |
cc_test(cow_ptr_tests SRCS details/cow_ptr_test.cc) | ||
nv_test(data_device_transform_test SRCS data_device_transform_test.cu | ||
DEPS operator op_registry init math_function) | ||
|
||
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() | ||
|
||
# ptools | ||
# just for testing, we may need to change the storing format for inference_model | ||
|
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.
有一点我不确定,
WITH_FLUID
这个选项,设置了之后是只编译Fluid,而不是同时编译老Paddle和Fluid?可能需要在这里注解下,或者把这个描述语句改下,因为这个PR引入
WITH_FLUID
并没有实现Compile PaddlePaddle fluid only
这个功能。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.
DONE. 已经加了comments并改成“ompile PaddlePaddle fluid only(TODO)”。
是的。关于WITH_FLUID的默认值,可以在后续功能开发完毕后再讨论定为OFF还是ON。
好的,会在下一个PR中解决。