From f8d4e756b43d39151601fd3d4fac7f029f403504 Mon Sep 17 00:00:00 2001 From: Yiqun Liu Date: Mon, 6 Nov 2017 14:41:26 +0800 Subject: [PATCH] Fix the lack of linking libraries to libpaddle_capi_engine. (#5343) The engine library need to link paddle_pserver and paddle_network on linux. --- paddle/capi/CMakeLists.txt | 40 +++++++++++++++--------------- python/paddle/utils/merge_model.py | 24 +++++++++--------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/paddle/capi/CMakeLists.txt b/paddle/capi/CMakeLists.txt index e767856d5..d267b1465 100644 --- a/paddle/capi/CMakeLists.txt +++ b/paddle/capi/CMakeLists.txt @@ -29,32 +29,32 @@ add_style_check_target(paddle_capi ${CAPI_SOURCES} ${CAPI_HEADER} add_dependencies(paddle_capi paddle_proto) # TODO: paddle_capi_whole will be removed. +set(PADDLE_CAPI_LAYERS_LIBS + paddle_function + paddle_gserver) if(MOBILE_INFERENCE) - set(PADDLE_CAPI_INFER_LIBS - paddle_utils - paddle_parameter - paddle_math - paddle_cuda - paddle_function - paddle_gserver - paddle_proto) + set(PADDLE_CAPI_ENGINE_LIBS + paddle_utils + paddle_parameter + paddle_math + paddle_cuda + paddle_proto) else() - set(PADDLE_CAPI_INFER_LIBS - paddle_utils - paddle_parameter - paddle_math - paddle_cuda - paddle_function - paddle_gserver - paddle_proto - paddle_pserver - paddle_network) + set(PADDLE_CAPI_ENGINE_LIBS + paddle_utils + paddle_parameter + paddle_math + paddle_cuda + paddle_proto + paddle_pserver + paddle_network) endif() +set(PADDLE_CAPI_INFER_LIBS ${PADDLE_CAPI_LAYERS_LIBS} ${PADDLE_CAPI_ENGINE_LIBS}) cc_library(paddle_capi_whole DEPS paddle_capi ${PADDLE_CAPI_INFER_LIBS}) # Link the static library for inference -cc_library(paddle_capi_engine DEPS paddle_capi paddle_utils paddle_parameter paddle_math paddle_cuda paddle_proto) -cc_library(paddle_capi_layers DEPS paddle_function paddle_gserver) +cc_library(paddle_capi_engine DEPS paddle_capi ${PADDLE_CAPI_ENGINE_LIBS}) +cc_library(paddle_capi_layers DEPS ${PADDLE_CAPI_LAYERS_LIBS}) # Link the shared library for inference if(NOT IOS) diff --git a/python/paddle/utils/merge_model.py b/python/paddle/utils/merge_model.py index 48e5087cc..421e953d2 100644 --- a/python/paddle/utils/merge_model.py +++ b/python/paddle/utils/merge_model.py @@ -23,32 +23,32 @@ from paddle.v2.topology import Topology def merge_v2_model(net, param_file, output_file): - '''Integrate the model config and model parameters into one file. - + '''Merge the model config and parameters into one file. + The model configuration file describes the model structure which ends with .py. The parameters file stores the parameters of the model which ends with .tar.gz. - - @param net The output layer of the network. - @param param_file Path of the model parameters(.tar.gz) which is stored by v2 api. + + @param net The output layer of the network for inference. + @param param_file Path of the parameters (.tar.gz) which is stored by v2 api. @param output_file Path of the merged file which will be generated. - + Usage: - from paddle.util.merge_model import merge_v2_model + from paddle.utils.merge_model import merge_v2_model # import your network configuration - from mobilenet import mobile_net - - net = mobile_net(3*224*224, 102) + from example_net import net_conf + + net = net_conf(is_predict=True) param_file = './param_pass_00000.tar.gz' output_file = './output.paddle' - + merge_v2_model(net, param_file, output_file) ''' assert isinstance(net, LayerOutput), \ - "The net should be the output of the network" + "The net should be the output of the network for inference" assert os.path.exists(param_file), \ "The model parameters file %s does not exists " % (param_file) -- GitLab