Skip to content

Commit

Permalink
make inference_c test linking only paddle_inference_c (#44126)
Browse files Browse the repository at this point in the history
  • Loading branch information
betterpig authored Jul 6, 2022
1 parent aa18ae1 commit bbe9955
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 52 deletions.
4 changes: 4 additions & 0 deletions paddle/fluid/inference/capi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ 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
Expand Down
4 changes: 4 additions & 0 deletions paddle/fluid/inference/capi_exp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ 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
Expand Down
60 changes: 8 additions & 52 deletions paddle/fluid/inference/tests/api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -943,28 +943,17 @@ if(WITH_GPU AND TENSORRT_FOUND)
SRCS
analyzer_capi_exp_gpu_tester.cc
EXTRA_DEPS
${INFERENCE_EXTRA_DEPS}
paddle_inference_c
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
${INFERENCE_EXTRA_DEPS}
paddle_inference_c
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)
Expand Down Expand Up @@ -1110,60 +1099,37 @@ inference_analysis_test(
SRCS
analyzer_capi_exp_tester.cc
EXTRA_DEPS
${INFERENCE_EXTRA_DEPS}
paddle_inference_c
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
${INFERENCE_EXTRA_DEPS}
paddle_inference_c
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
${INFERENCE_EXTRA_DEPS}
paddle_inference_c
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(
test_analyzer_capi_exp_pd_threads
SRCS
analyzer_capi_exp_pd_threads_tester.cc
EXTRA_DEPS
${INFERENCE_EXTRA_DEPS}
paddle_inference_c
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(
Expand Down Expand Up @@ -1205,29 +1171,19 @@ if(WITH_MKLDNN)
SRCS
analyzer_capi_exp_int_tester.cc
EXTRA_DEPS
${INFERENCE_EXTRA_DEPS}
paddle_inference_c
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(
test_analyzer_capi_exp_ner
SRCS
analyzer_capi_exp_ner_tester.cc
EXTRA_DEPS
${INFERENCE_EXTRA_DEPS}
paddle_inference_c
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(
Expand Down

0 comments on commit bbe9955

Please sign in to comment.