From 9b0f621cfa80955394703dee5835e7637ee36cc6 Mon Sep 17 00:00:00 2001 From: Yuanle Liu Date: Thu, 18 May 2023 16:17:30 +0800 Subject: [PATCH] adjust inference lib dir (#53091) --- cmake/inference_lib.cmake | 28 ++++++------- cmake/phi_header.cmake | 59 +++++++++------------------ paddle/fluid/inference/CMakeLists.txt | 3 +- 3 files changed, 33 insertions(+), 57 deletions(-) diff --git a/cmake/inference_lib.cmake b/cmake/inference_lib.cmake index cb1fdf72b8e..8d47dbd5e9b 100755 --- a/cmake/inference_lib.cmake +++ b/cmake/inference_lib.cmake @@ -285,58 +285,56 @@ include_directories(${CMAKE_BINARY_DIR}/../paddle/fluid/framework/io) copy( inference_lib_dist SRCS ${PADDLE_SOURCE_DIR}/paddle/phi/api/ext/*.h - DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/phi/api/ext/) + DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/paddle/phi/api/ext/) copy( inference_lib_dist SRCS ${PADDLE_SOURCE_DIR}/paddle/phi/api/include/*.h - DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/phi/api/include/ -) + DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/paddle/phi/api/include/) copy( inference_lib_dist SRCS ${PADDLE_SOURCE_DIR}/paddle/phi/api/all.h - DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/phi/api/) + DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/paddle/phi/api/) copy( inference_lib_dist SRCS ${PADDLE_SOURCE_DIR}/paddle/phi/common/*.h - DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/phi/common/) + DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/paddle/phi/common/) copy( inference_lib_dist SRCS ${PADDLE_SOURCE_DIR}/paddle/phi/core/macros.h - DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/phi/core/) + DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/paddle/phi/core/) copy( inference_lib_dist SRCS ${PADDLE_SOURCE_DIR}/paddle/phi/core/visit_type.h - DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/phi/core/) + DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/paddle/phi/core/) copy( inference_lib_dist SRCS ${PADDLE_SOURCE_DIR}/paddle/phi/core/hostdevice.h - DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/phi/core/) + DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/paddle/phi/core/) copy( inference_lib_dist SRCS ${PADDLE_SOURCE_DIR}/paddle/fluid/platform/init_phi.h - DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/phi/) + DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/paddle/phi/) copy( inference_lib_dist SRCS ${PADDLE_SOURCE_DIR}/paddle/utils/any.h - DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/utils/) + DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/paddle/utils/) copy( inference_lib_dist SRCS ${PADDLE_SOURCE_DIR}/paddle/utils/optional.h - DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/utils/) + DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/paddle/utils/) copy( inference_lib_dist SRCS ${PADDLE_SOURCE_DIR}/paddle/utils/none.h - DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/utils/) + DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/paddle/utils/) copy( inference_lib_dist SRCS ${PADDLE_SOURCE_DIR}/paddle/utils/flat_hash_map.h - DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/utils/) + DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/paddle/utils/) copy( inference_lib_dist SRCS ${PADDLE_SOURCE_DIR}/paddle/extension.h - DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/) + DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/paddle/) -# the header file of phi is copied to the experimental directory, # the include path of phi needs to be changed to adapt to inference api path add_custom_command( TARGET inference_lib_dist diff --git a/cmake/phi_header.cmake b/cmake/phi_header.cmake index 910532f4838..ac633b747bc 100644 --- a/cmake/phi_header.cmake +++ b/cmake/phi_header.cmake @@ -17,57 +17,36 @@ set(PADDLE_INFERENCE_INSTALL_DIR function(phi_header_path_compat TARGET_PATH) message(STATUS "phi header path compat processing: ${TARGET_PATH}") - string(FIND ${TARGET_PATH} "experimental" pos) - if(pos GREATER 1) - file(GLOB HEADERS "${TARGET_PATH}/*" "*.h") - foreach(header ${HEADERS}) - if(${header} MATCHES ".*.h$") - file(READ ${header} HEADER_CONTENT) - string(REPLACE "paddle/phi/" "paddle/include/experimental/phi/" - HEADER_CONTENT "${HEADER_CONTENT}") - string(REPLACE "paddle/fluid/platform/" - "paddle/include/experimental/phi/" HEADER_CONTENT - "${HEADER_CONTENT}") - string(REPLACE "paddle/utils/" "paddle/include/experimental/utils/" - HEADER_CONTENT "${HEADER_CONTENT}") - file(WRITE ${header} "${HEADER_CONTENT}") - message(STATUS "phi header path compat processing complete: ${header}") - endif() - endforeach() - endif() + file(GLOB HEADERS "${TARGET_PATH}/*" "*.h") + foreach(header ${HEADERS}) + if(${header} MATCHES ".*.h$") + file(READ ${header} HEADER_CONTENT) + string(REPLACE "paddle/fluid/platform/" "paddle/phi/" HEADER_CONTENT + "${HEADER_CONTENT}") + file(WRITE ${header} "${HEADER_CONTENT}") + message(STATUS "phi header path compat processing complete: ${header}") + endif() + endforeach() endfunction() +phi_header_path_compat(${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/paddle) phi_header_path_compat( - ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental) + ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/paddle/phi) phi_header_path_compat( - ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/phi) + ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/paddle/phi/api) phi_header_path_compat( - ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/phi/api) + ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/paddle/phi/api/ext) phi_header_path_compat( - ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/phi/api/ext) + ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/paddle/phi/api/include) phi_header_path_compat( - ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/phi/api/include) + ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/paddle/phi/common) phi_header_path_compat( - ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/phi/common) -phi_header_path_compat( - ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/phi/core) + ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/paddle/phi/core) # NOTE(liuyuanle): In inference lib, no need include paddle/utils/pybind.h, so we delete this. -file(READ - ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/extension.h +file(READ ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/paddle/extension.h HEADER_CONTENT) string(REGEX REPLACE "#if !defined\\(PADDLE_ON_INFERENCE\\).*#endif" "" HEADER_CONTENT "${HEADER_CONTENT}") -file(WRITE - ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/extension.h +file(WRITE ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/paddle/extension.h "${HEADER_CONTENT}") - -# In order to be compatible with the original behavior, the header file name needs to be changed -file(RENAME - ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/extension.h - ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/ext_all.h) -# Included header file of training and inference can be unified as single file: paddle/extension.h -file(COPY ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/ext_all.h - DESTINATION ${PADDLE_INFERENCE_INSTALL_DIR}/paddle) -file(RENAME ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/ext_all.h - ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/extension.h) diff --git a/paddle/fluid/inference/CMakeLists.txt b/paddle/fluid/inference/CMakeLists.txt index 36d01c0f059..237a7608160 100644 --- a/paddle/fluid/inference/CMakeLists.txt +++ b/paddle/fluid/inference/CMakeLists.txt @@ -98,8 +98,7 @@ set(SHARED_INFERENCE_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/api/analysis_predictor.cc ${CMAKE_CURRENT_SOURCE_DIR}/api/paddle_infer_contrib.cc ${CMAKE_CURRENT_SOURCE_DIR}/api/details/zero_copy_tensor.cc - ${CMAKE_CURRENT_SOURCE_DIR}/utils/io_utils.cc - ${PADDLE_CUSTOM_OP_SRCS}) + ${CMAKE_CURRENT_SOURCE_DIR}/utils/io_utils.cc) # shared inference library deps list(REMOVE_ITEM fluid_modules standalone_executor -- GitLab