From 5f54a7fe5a737bdb44bee117cfe3b88dedcddc61 Mon Sep 17 00:00:00 2001 From: YuanRisheng Date: Wed, 31 May 2023 16:02:26 +0800 Subject: [PATCH] [BugFix]Fix inference static lib bugs (#54207) * fix inference static lib bugs * add if for copy * fix py3 bugs --- cmake/inference_lib.cmake | 13 +++++++------ paddle/fluid/inference/CMakeLists.txt | 8 +++++--- paddle/phi/CMakeLists.txt | 10 ++++++++++ 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/cmake/inference_lib.cmake b/cmake/inference_lib.cmake index 3731d23b813..0e6ba8c497e 100755 --- a/cmake/inference_lib.cmake +++ b/cmake/inference_lib.cmake @@ -269,12 +269,13 @@ else() SRCS ${src_dir}/inference/api/paddle_*.h ${paddle_inference_lib} DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/lib) - - set(paddle_phi_lib ${PADDLE_BINARY_DIR}/paddle/phi/libphi.*) - copy( - inference_lib_dist - SRCS ${paddle_phi_lib} - DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/lib) + if(WITH_PHI_SHARED) + set(paddle_phi_lib ${PADDLE_BINARY_DIR}/paddle/phi/libphi.*) + copy( + inference_lib_dist + SRCS ${paddle_phi_lib} + DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/lib) + endif() endif() diff --git a/paddle/fluid/inference/CMakeLists.txt b/paddle/fluid/inference/CMakeLists.txt index 037025405fc..94bbb2bfe87 100644 --- a/paddle/fluid/inference/CMakeLists.txt +++ b/paddle/fluid/inference/CMakeLists.txt @@ -32,7 +32,8 @@ endif() # fluid_modules exclude API-interface of inference/api and inference/capi_exp get_property(fluid_modules GLOBAL PROPERTY FLUID_MODULES) -set(utils_modules pretty_log string_helper benchmark) +get_property(phi_modules GLOBAL PROPERTY PHI_MODULES) +set(utils_modules pretty_log string_helper benchmark utf8proc) add_subdirectory(api) @@ -63,8 +64,9 @@ else() # message("${fluid_modules}") # message("${STATIC_INFERENCE_API}") # message("${utils_modules}") - create_static_lib(paddle_inference ${fluid_modules} ${STATIC_INFERENCE_API} - ${utils_modules}) + # message("${phi_modules}") + create_static_lib(paddle_inference ${phi_modules} ${fluid_modules} + ${STATIC_INFERENCE_API} ${utils_modules}) endif() if(NOT APPLE) diff --git a/paddle/phi/CMakeLists.txt b/paddle/phi/CMakeLists.txt index 796e619ad6c..bd9702f73d3 100644 --- a/paddle/phi/CMakeLists.txt +++ b/paddle/phi/CMakeLists.txt @@ -45,6 +45,8 @@ set(PHI_DEPS cblas utf8proc) +set(INFERENCE_DEPS phi_profiler_proto auto_parallel_proto) + if(WITH_GPU) list(APPEND PHI_DEPS external_error_proto) endif() @@ -79,6 +81,7 @@ endif() if(WITH_MKLML) list(APPEND PHI_DEPS pocketfft dynload_mklml) + list(APPEND INFERENCE_DEPS dynload_mklml) endif() if(WITH_XPU) @@ -183,6 +186,13 @@ if(WITH_FLASHATTN) add_dependencies(phi flashattn) endif() +# for inference static library +if(NOT WITH_PHI_SHARED) + get_property(phi_modules GLOBAL PROPERTY PHI_MODULES) + set(phi_modules ${phi_modules} ${INFERENCE_DEPS} phi) + set_property(GLOBAL PROPERTY PHI_MODULES "${phi_modules}") +endif() + set(phi_extension_header_file ${CMAKE_CURRENT_SOURCE_DIR}/extension.h CACHE INTERNAL "phi/extension.h file") -- GitLab