From 9428c969d480cce41aea9b946811621d55a40ec6 Mon Sep 17 00:00:00 2001 From: tianshuo78520a <707759223@qq.com> Date: Thu, 7 Jul 2022 17:01:52 +0800 Subject: [PATCH] Revert "make inference_c test linking only paddle_inference_c (#44126)" (#44149) This reverts commit bbe995556130f7cd77241df999b2eb0cebd4a146. --- paddle/fluid/inference/capi/CMakeLists.txt | 4 -- .../fluid/inference/capi_exp/CMakeLists.txt | 4 -- .../fluid/inference/tests/api/CMakeLists.txt | 60 ++++++++++++++++--- 3 files changed, 52 insertions(+), 16 deletions(-) diff --git a/paddle/fluid/inference/capi/CMakeLists.txt b/paddle/fluid/inference/capi/CMakeLists.txt index 73ba41607aa..25d8a39dc63 100644 --- a/paddle/fluid/inference/capi/CMakeLists.txt +++ b/paddle/fluid/inference/capi/CMakeLists.txt @@ -20,10 +20,6 @@ cc_library( SRCS ${C_API_SRCS} DEPS paddle_inference) -if(NOT ON_INFER) - return() -endif() - # Create inference capi shared library cc_library( paddle_inference_c_shared SHARED diff --git a/paddle/fluid/inference/capi_exp/CMakeLists.txt b/paddle/fluid/inference/capi_exp/CMakeLists.txt index e35e14a0c02..56de57cbb9c 100644 --- a/paddle/fluid/inference/capi_exp/CMakeLists.txt +++ b/paddle/fluid/inference/capi_exp/CMakeLists.txt @@ -20,10 +20,6 @@ cc_library( SRCS ${C_API_SRCS} DEPS paddle_inference) -if(NOT ON_INFER) - return() -endif() - # Create inference capi shared library cc_library( paddle_inference_c_shared SHARED diff --git a/paddle/fluid/inference/tests/api/CMakeLists.txt b/paddle/fluid/inference/tests/api/CMakeLists.txt index 1ed41417355..610883ad1ad 100644 --- a/paddle/fluid/inference/tests/api/CMakeLists.txt +++ b/paddle/fluid/inference/tests/api/CMakeLists.txt @@ -943,17 +943,28 @@ if(WITH_GPU AND TENSORRT_FOUND) SRCS analyzer_capi_exp_gpu_tester.cc EXTRA_DEPS - paddle_inference_c + ${INFERENCE_EXTRA_DEPS} ARGS --infer_model=${TRT_MODEL_INSTALL_DIR}/trt_inference_test_models) + if(WIN32) + target_link_libraries(test_analyzer_capi_exp_gpu paddle_inference_c_shared) + else() + target_link_libraries(test_analyzer_capi_exp_gpu paddle_inference_c) + endif() inference_analysis_test( test_analyzer_capi_exp_xpu SRCS analyzer_capi_exp_xpu_tester.cc EXTRA_DEPS - paddle_inference_c + ${INFERENCE_EXTRA_DEPS} ARGS --infer_model=${TRT_MODEL_INSTALL_DIR}/trt_inference_test_models) + if(WIN32) + target_link_libraries(test_analyzer_capi_exp_xpu paddle_inference_c_shared) + else() + target_link_libraries(test_analyzer_capi_exp_xpu paddle_inference_c) + endif() + set(TRT_MODEL_QUANT_RESNET_DIR "${INFERENCE_DEMO_INSTALL_DIR}/small_quant_model") if(NOT EXISTS ${INFERENCE_DEMO_INSTALL_DIR}/small_quant_model.tgz) @@ -1099,27 +1110,44 @@ inference_analysis_test( SRCS analyzer_capi_exp_tester.cc EXTRA_DEPS - paddle_inference_c + ${INFERENCE_EXTRA_DEPS} ARGS --infer_model=${RESNET50_MODEL_DIR}/model) +if(WIN32) + target_link_libraries(test_analyzer_capi_exp paddle_inference_c_shared) +else() + target_link_libraries(test_analyzer_capi_exp paddle_inference_c) +endif() inference_analysis_test( test_analyzer_capi_exp_pd_config SRCS analyzer_capi_exp_pd_config_tester.cc EXTRA_DEPS - paddle_inference_c + ${INFERENCE_EXTRA_DEPS} ARGS --infer_model=${MOBILENET_INSTALL_DIR}/model) +if(WIN32) + target_link_libraries(test_analyzer_capi_exp_pd_config + paddle_inference_c_shared) +else() + target_link_libraries(test_analyzer_capi_exp_pd_config paddle_inference_c) +endif() inference_analysis_test( test_analyzer_capi_exp_pd_tensor SRCS analyzer_capi_exp_pd_tensor_tester.cc EXTRA_DEPS - paddle_inference_c + ${INFERENCE_EXTRA_DEPS} ARGS --infer_model=${MOBILENET_INSTALL_DIR}/model) +if(WIN32) + target_link_libraries(test_analyzer_capi_exp_pd_tensor + paddle_inference_c_shared) +else() + target_link_libraries(test_analyzer_capi_exp_pd_tensor paddle_inference_c) +endif() if(NOT APPLE AND NOT WIN32) inference_analysis_test( @@ -1127,9 +1155,15 @@ if(NOT APPLE AND NOT WIN32) SRCS analyzer_capi_exp_pd_threads_tester.cc EXTRA_DEPS - paddle_inference_c + ${INFERENCE_EXTRA_DEPS} ARGS --infer_model=${MOBILENET_INSTALL_DIR}/model) + if(WIN32) + target_link_libraries(test_analyzer_capi_exp_pd_threads + paddle_inference_c_shared) + else() + target_link_libraries(test_analyzer_capi_exp_pd_threads paddle_inference_c) + endif() endif() inference_analysis_test( @@ -1171,9 +1205,14 @@ if(WITH_MKLDNN) SRCS analyzer_capi_exp_int_tester.cc EXTRA_DEPS - paddle_inference_c + ${INFERENCE_EXTRA_DEPS} ARGS --infer_model=${INT8_DATA_DIR}/resnet50/model) + if(WIN32) + target_link_libraries(test_analyzer_capi_exp_int paddle_inference_c_shared) + else() + target_link_libraries(test_analyzer_capi_exp_int paddle_inference_c) + endif() endif() inference_analysis_test( @@ -1181,9 +1220,14 @@ inference_analysis_test( SRCS analyzer_capi_exp_ner_tester.cc EXTRA_DEPS - paddle_inference_c + ${INFERENCE_EXTRA_DEPS} ARGS --infer_model=${CHINESE_NER_INSTALL_DIR}/model) +if(WIN32) + target_link_libraries(test_analyzer_capi_exp_ner paddle_inference_c_shared) +else() + target_link_libraries(test_analyzer_capi_exp_ner paddle_inference_c) +endif() if(WITH_GPU) inference_analysis_test( -- GitLab