未验证 提交 57d9b800 编写于 作者: Y YuanRisheng 提交者: GitHub

[Cherry-Pick]Add PHI option in cmake (#54462) (#54576)

* Add PHI option in cmake (#54462)

* add phi option in cmake

* modify default option

* fix windows bugs

* perfect log

* change default mode

* change phi so on for py3

* fix mac bugs

* fix mac bugs

* delete code
上级 fbe8982f
......@@ -62,6 +62,7 @@ option(WITH_IPU "Compile PaddlePaddle with Graphcore IPU" OFF)
option(WITH_ONNXRUNTIME "Compile PaddlePaddle with ONNXRUNTIME" OFF)
option(WITH_CUSPARSELT "Compile PaddlePaddle with CUSPARSELT" OFF)
option(WITH_SETUP_INSTALL "Compile PaddlePaddle with setup.py" OFF)
option(WITH_SHARED_PHI "Compile PaddlePaddle with SHARED LIB of PHI" OFF)
# Note(zhouwei): It use option above, so put here
include(init)
include(generic) # simplify cmake module
......@@ -111,7 +112,7 @@ endif()
if(WIN32)
option(MSVC_STATIC_CRT "use static C Runtime library by default" ON)
message("Build static library of PHI")
set(CMAKE_SUPPRESS_REGENERATION ON)
set(CMAKE_STATIC_LIBRARY_PREFIX lib)
......
......@@ -236,18 +236,6 @@ if(WITH_CUDNN_FRONTEND)
add_definitions(-DPADDLE_WITH_CUDNN_FRONTEND)
endif()
set(WITH_PHI_SHARED
ON
CACHE BOOL "" FORCE)
if(WIN32
OR WITH_ROCM
OR WITH_XPU_KP
OR ON_INFER)
set(WITH_PHI_SHARED
OFF
CACHE BOOL "" FORCE)
endif()
if(WITH_PHI_SHARED)
if(WITH_SHARED_PHI)
add_definitions(-DPHI_SHARED)
endif()
......@@ -269,7 +269,7 @@ else()
SRCS ${src_dir}/inference/api/paddle_*.h ${paddle_inference_lib}
DSTS ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include
${PADDLE_INFERENCE_INSTALL_DIR}/paddle/lib)
if(WITH_PHI_SHARED)
if(WITH_SHARED_PHI)
set(paddle_phi_lib ${PADDLE_BINARY_DIR}/paddle/phi/libphi.*)
copy(
inference_lib_dist
......
......@@ -52,7 +52,7 @@ if(WIN32)
set(eager_generator_path "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}")
endif()
if(WITH_PHI_SHARED)
if(WITH_SHARED_PHI)
message("Copied phi.dll for Eager AutoCodeGen")
add_custom_command(
OUTPUT ${eager_generator_path}/phi.dll
......
......@@ -330,7 +330,7 @@ if(WITH_PYTHON)
")\n"
"exit /b 0")
if(WITH_PHI_SHARED)
if(WITH_SHARED_PHI)
add_custom_command(
OUTPUT ${op_impl_path}/phi.dll
COMMAND ${CMAKE_COMMAND} -E copy ${PHI_LIB} ${op_impl_path}
......
......@@ -97,7 +97,7 @@ set(PHI_SRCS
${infermeta_srcs}
${capi_srcs})
if(WITH_PHI_SHARED)
if(WITH_SHARED_PHI)
set(PHI_BUILD_TYPE
SHARED
CACHE INTERNAL "" FORCE)
......@@ -136,7 +136,7 @@ if(WIN32)
endif()
if(WIN32)
if(WITH_PHI_SHARED)
if(WITH_SHARED_PHI)
set_property(TARGET phi PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON)
set(PHI_NAME
phi.dll
......@@ -147,7 +147,7 @@ if(WIN32)
CACHE INTERNAL "" FORCE)
endif()
elseif(APPLE)
if(WITH_PHI_SHARED)
if(WITH_SHARED_PHI)
set(PHI_NAME
libphi.dylib
CACHE INTERNAL "" FORCE)
......@@ -157,7 +157,7 @@ elseif(APPLE)
CACHE INTERNAL "" FORCE)
endif()
else()
if(WITH_PHI_SHARED)
if(WITH_SHARED_PHI)
set(PHI_NAME
libphi.so
CACHE INTERNAL "" FORCE)
......@@ -187,7 +187,7 @@ if(WITH_FLASHATTN)
endif()
# for inference static library
if(NOT WITH_PHI_SHARED)
if(NOT WITH_SHARED_PHI)
get_property(phi_modules GLOBAL PROPERTY PHI_MODULES)
set(phi_modules ${phi_modules} ${INFERENCE_DEPS} phi)
set_property(GLOBAL PROPERTY PHI_MODULES "${phi_modules}")
......
此差异已折叠。
......@@ -12,7 +12,7 @@ env_dict={
'FLUID_CORE_NAME':'@FLUID_CORE_NAME@',
'PHI_LIB':'@PHI_LIB@',
'PHI_NAME':'@PHI_NAME@',
'WITH_PHI_SHARED':'@WITH_PHI_SHARED@',
'WITH_SHARED_PHI':'@WITH_SHARED_PHI@',
'WARPCTC_LIBRARIES':'@WARPCTC_LIBRARIES@',
'WARPRNNT_LIBRARIES':'@WARPRNNT_LIBRARIES@',
'FLASHATTN_LIBRARIES':'@FLASHATTN_LIBRARIES@',
......
......@@ -563,7 +563,7 @@ package_dir={
libs_path='${PADDLE_BINARY_DIR}/python/paddle/libs'
package_data['paddle.libs']= []
if('${WITH_PHI_SHARED}' == 'ON'):
if('${WITH_SHARED_PHI}' == 'ON'):
package_data['paddle.libs'] = [('libphi' if os.name != 'nt' else 'phi') + ext_name]
shutil.copy('${PHI_LIB}', libs_path)
......@@ -728,12 +728,12 @@ if '${CMAKE_BUILD_TYPE}' == 'Release':
if "@APPLE@" == "1":
commands = ["install_name_tool -id '@loader_path/../libs/' ${PADDLE_BINARY_DIR}/python/paddle/fluid/${FLUID_CORE_NAME}" + '.so']
commands.append("install_name_tool -add_rpath '@loader_path/../libs/' ${PADDLE_BINARY_DIR}/python/paddle/fluid/${FLUID_CORE_NAME}" + '.so')
if('${WITH_PHI_SHARED}' == 'ON'):
if('${WITH_SHARED_PHI}' == 'ON'):
# change rpath of phi.ext for loading 3rd party libb
commands.append("install_name_tool -add_rpath '@loader_path' ${PADDLE_BINARY_DIR}/python/paddle/libs/${PHI_NAME}")
else:
commands = ["patchelf --set-rpath '$ORIGIN/../libs/' ${PADDLE_BINARY_DIR}/python/paddle/fluid/${FLUID_CORE_NAME}" + '.so']
if('${WITH_PHI_SHARED}' == 'ON'):
if('${WITH_SHARED_PHI}' == 'ON'):
# change rpath of phi.ext for loading 3rd party lib
commands.append("patchelf --set-rpath '$ORIGIN' ${PADDLE_BINARY_DIR}/python/paddle/libs/${PHI_NAME}")
# The sw_64 not suppot patchelf, so we just disable that.
......
......@@ -967,7 +967,7 @@ def get_package_data_and_package_dir():
libs_path = paddle_binary_dir + '/python/paddle/libs'
package_data['paddle.libs'] = []
if env_dict.get("WITH_PHI_SHARED") == "ON":
if env_dict.get("WITH_SHARED_PHI") == "ON":
package_data['paddle.libs'] = [
('libphi' if os.name != 'nt' else 'phi') + ext_suffix
]
......@@ -1211,7 +1211,7 @@ def get_package_data_and_package_dir():
+ env_dict.get("FLUID_CORE_NAME")
+ '.so'
)
if env_dict.get("WITH_PHI_SHARED") == "ON":
if env_dict.get("WITH_SHARED_PHI") == "ON":
commands.append(
"install_name_tool -add_rpath '@loader_path' "
+ env_dict.get("PADDLE_BINARY_DIR")
......@@ -1226,7 +1226,7 @@ def get_package_data_and_package_dir():
+ env_dict.get("FLUID_CORE_NAME")
+ '.so'
]
if env_dict.get("WITH_PHI_SHARED") == "ON":
if env_dict.get("WITH_SHARED_PHI") == "ON":
commands.append(
"patchelf --set-rpath '$ORIGIN' "
+ env_dict.get("PADDLE_BINARY_DIR")
......
......@@ -168,7 +168,9 @@ if(${len} GREATER_EQUAL 1)
add_executable(${test_name} ${test_src})
target_link_libraries(${test_name} paddle_gtest_main_new)
target_link_libraries(${test_name} $<TARGET_LINKER_FILE:${paddle_lib}>)
target_link_libraries(${test_name} $<TARGET_LINKER_FILE:phi>)
if(WITH_SHARED_PHI)
target_link_libraries(${test_name} $<TARGET_LINKER_FILE:phi>)
endif()
add_dependencies(${test_name} ${paddle_lib} paddle_gtest_main_new)
if(WITH_GPU)
target_link_libraries(${test_name} ${CUDA_CUDART_LIBRARY}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册