-
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
Build mobile inference library for minimum size #4509
Changes from 6 commits
3c66b30
bb07120
33299ef
ea4672b
d94dd75
6627801
adad8d9
8f2c48c
aa1e92e
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 |
---|---|---|
|
@@ -73,25 +73,43 @@ function(link_paddle_exe TARGET_NAME) | |
generate_rdma_links() | ||
endif() | ||
|
||
target_circle_link_libraries(${TARGET_NAME} | ||
ARCHIVE_START | ||
paddle_gserver | ||
paddle_function | ||
ARCHIVE_END | ||
paddle_pserver | ||
paddle_trainer_lib | ||
paddle_network | ||
paddle_math | ||
paddle_utils | ||
paddle_parameter | ||
paddle_proto | ||
paddle_cuda | ||
paddle_optimizer | ||
${EXTERNAL_LIBS} | ||
${CMAKE_THREAD_LIBS_INIT} | ||
${CMAKE_DL_LIBS} | ||
${RDMA_LD_FLAGS} | ||
${RDMA_LIBS}) | ||
if(MOBILE_INFERENCE) | ||
target_circle_link_libraries(${TARGET_NAME} | ||
ARCHIVE_START | ||
paddle_gserver | ||
paddle_function | ||
ARCHIVE_END | ||
paddle_math | ||
paddle_utils | ||
paddle_parameter | ||
paddle_proto | ||
paddle_cuda | ||
${EXTERNAL_LIBS} | ||
${CMAKE_THREAD_LIBS_INIT} | ||
${CMAKE_DL_LIBS} | ||
${RDMA_LD_FLAGS} | ||
${RDMA_LIBS}) | ||
else() | ||
target_circle_link_libraries(${TARGET_NAME} | ||
ARCHIVE_START | ||
paddle_gserver | ||
paddle_function | ||
ARCHIVE_END | ||
paddle_pserver | ||
paddle_trainer_lib | ||
paddle_network | ||
paddle_math | ||
paddle_utils | ||
paddle_parameter | ||
paddle_proto | ||
paddle_cuda | ||
paddle_optimizer | ||
${EXTERNAL_LIBS} | ||
${CMAKE_THREAD_LIBS_INIT} | ||
${CMAKE_DL_LIBS} | ||
${RDMA_LD_FLAGS} | ||
${RDMA_LIBS}) | ||
endif() | ||
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. Maybe we can use a new variable to specify which modules need to link, like:
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. I will fix this commit in the next pr. |
||
|
||
if(ANDROID) | ||
target_link_libraries(${TARGET_NAME} log) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
add_subdirectory(cuda) | ||
add_subdirectory(function) | ||
add_subdirectory(utils) | ||
add_subdirectory(testing) | ||
add_subdirectory(math) | ||
add_subdirectory(parameter) | ||
add_subdirectory(gserver) | ||
add_subdirectory(pserver) | ||
add_subdirectory(trainer) | ||
add_subdirectory(scripts) | ||
add_subdirectory(string) | ||
|
||
if(Boost_FOUND) | ||
add_subdirectory(memory) | ||
add_subdirectory(platform) | ||
add_subdirectory(framework) | ||
add_subdirectory(operators) | ||
add_subdirectory(pybind) | ||
endif() | ||
add_subdirectory(parameter) | ||
add_subdirectory(testing) | ||
|
||
if(WITH_C_API) | ||
if(MOBILE_INFERENCE) | ||
add_subdirectory(capi) | ||
endif() | ||
else() | ||
add_subdirectory(pserver) | ||
add_subdirectory(trainer) | ||
add_subdirectory(string) | ||
add_subdirectory(scripts) | ||
|
||
if(WITH_C_API) | ||
add_subdirectory(capi) | ||
endif() | ||
|
||
if(Boost_FOUND) | ||
add_subdirectory(memory) | ||
add_subdirectory(platform) | ||
add_subdirectory(framework) | ||
add_subdirectory(operators) | ||
add_subdirectory(pybind) | ||
endif() | ||
|
||
if(WITH_SWIG_PY) | ||
add_subdirectory(api) | ||
if(WITH_SWIG_PY) | ||
add_subdirectory(api) | ||
endif() | ||
endif() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,36 @@ if(NOT WITH_PYTHON) | |
dataproviders/PyDataProvider.h) | ||
endif() | ||
|
||
if(MOBILE_INFERENCE) | ||
# Remove evaluators | ||
list(REMOVE_ITEM GSERVER_SOURCES | ||
layers/ValidationLayer.cpp | ||
evaluators/Evaluator.cpp | ||
evaluators/DetectionMAPEvaluator.cpp | ||
evaluators/CTCErrorEvaluator.cpp | ||
evaluators/ChunkEvaluator.cpp) | ||
|
||
# Remove dataproviders | ||
list(REMOVE_ITEM GSERVER_SOURCES | ||
dataproviders/DataProvider.cpp | ||
dataproviders/MultiDataProvider.cpp | ||
dataproviders/ProtoDataProvider.cpp | ||
dataproviders/PyDataProvider2.cpp | ||
dataproviders/PyDataProvider.cpp) | ||
|
||
# Remove useless gradientmachines | ||
list(REMOVE_ITEM GSERVER_SOURCES | ||
gradientmachines/MultiNetwork.cpp | ||
gradientmachines/RecurrentGradientMachine.cpp | ||
gradientmachines/ParallelNeuralNetwork.cpp | ||
gradientmachines/GradientMachineMode.cpp | ||
gradientmachines/MultiGradientMachine.cpp) | ||
|
||
# Remove useless layers | ||
list(REMOVE_ITEM GSERVER_SOURCES | ||
layers/RecurrentLayerGroup.cpp) | ||
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. I am not sure whether 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. For For |
||
endif() | ||
|
||
if(WITH_GPU) | ||
cuda_add_library(paddle_gserver ${GSERVER_SOURCES}) | ||
else() | ||
|
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.
I'd like to not set
WITH_TESTING
toOFF
, because it is useful to check the linking error.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.
I agree that the WITH_TESTING switch needs to be opened, but this PR will lead to some test program compiler failure, so I turn off the WITH_TESTING for temporarily.
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.