未验证 提交 7bb72e37 编写于 作者: H heliqi 提交者: GitHub

paddle2onnx update to 0.9.8 (#43742)

上级 2e79f81c
...@@ -26,6 +26,7 @@ include(ExternalProject) ...@@ -26,6 +26,7 @@ include(ExternalProject)
add_definitions(-DPADDLE_WITH_ONNXRUNTIME) add_definitions(-DPADDLE_WITH_ONNXRUNTIME)
set(ONNXRUNTIME_PROJECT "extern_onnxruntime") set(ONNXRUNTIME_PROJECT "extern_onnxruntime")
set(ONNXRUNTIME_VERSION "1.10.0")
set(ONNXRUNTIME_PREFIX_DIR ${THIRD_PARTY_PATH}/onnxruntime) set(ONNXRUNTIME_PREFIX_DIR ${THIRD_PARTY_PATH}/onnxruntime)
set(ONNXRUNTIME_SOURCE_DIR set(ONNXRUNTIME_SOURCE_DIR
${THIRD_PARTY_PATH}/onnxruntime/src/${ONNXRUNTIME_PROJECT}) ${THIRD_PARTY_PATH}/onnxruntime/src/${ONNXRUNTIME_PROJECT})
...@@ -40,21 +41,29 @@ set(CMAKE_BUILD_RPATH "${CMAKE_BUILD_RPATH}" "${ONNXRUNTIME_LIB_DIR}") ...@@ -40,21 +41,29 @@ set(CMAKE_BUILD_RPATH "${CMAKE_BUILD_RPATH}" "${ONNXRUNTIME_LIB_DIR}")
if(WIN32) if(WIN32)
set(ONNXRUNTIME_URL set(ONNXRUNTIME_URL
"https://github.com/microsoft/onnxruntime/releases/download/v1.10.0/onnxruntime-win-x64-1.10.0.zip" "https://github.com/microsoft/onnxruntime/releases/download/v${ONNXRUNTIME_VERSION}/onnxruntime-win-x64-${ONNXRUNTIME_VERSION}.zip"
) )
elseif(APPLE) elseif(APPLE)
set(ONNXRUNTIME_URL set(ONNXRUNTIME_URL
"https://github.com/microsoft/onnxruntime/releases/download/v1.10.0/onnxruntime-osx-x86_64-1.10.0.tgz" "https://github.com/microsoft/onnxruntime/releases/download/v${ONNXRUNTIME_VERSION}/onnxruntime-osx-x86_64-${ONNXRUNTIME_VERSION}.tgz"
) )
else() else()
set(ONNXRUNTIME_URL set(ONNXRUNTIME_URL
"https://github.com/microsoft/onnxruntime/releases/download/v1.10.0/onnxruntime-linux-x64-1.10.0.tgz" "https://github.com/microsoft/onnxruntime/releases/download/v${ONNXRUNTIME_VERSION}/onnxruntime-linux-x64-${ONNXRUNTIME_VERSION}.tgz"
) )
endif() endif()
# For ONNXRUNTIME code to include internal headers. # For ONNXRUNTIME code to include internal headers.
include_directories(${ONNXRUNTIME_INC_DIR}) include_directories(${ONNXRUNTIME_INC_DIR})
set(ONNXRUNTIME_LIB_NEW_NAME "libonnxruntime${CMAKE_SHARED_LIBRARY_SUFFIX}")
if(APPLE)
set(ONNXRUNTIME_LIB_NAME
"libonnxruntime.${ONNXRUNTIME_VERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}")
else()
set(ONNXRUNTIME_LIB_NAME
"libonnxruntime${CMAKE_SHARED_LIBRARY_SUFFIX}.${ONNXRUNTIME_VERSION}")
endif()
if(WIN32) if(WIN32)
set(ONNXRUNTIME_SOURCE_LIB set(ONNXRUNTIME_SOURCE_LIB
"${ONNXRUNTIME_SOURCE_DIR}/lib/onnxruntime.dll" "${ONNXRUNTIME_SOURCE_DIR}/lib/onnxruntime.dll"
...@@ -67,20 +76,20 @@ if(WIN32) ...@@ -67,20 +76,20 @@ if(WIN32)
CACHE FILEPATH "ONNXRUNTIME static library." FORCE) CACHE FILEPATH "ONNXRUNTIME static library." FORCE)
elseif(APPLE) elseif(APPLE)
set(ONNXRUNTIME_SOURCE_LIB set(ONNXRUNTIME_SOURCE_LIB
"${ONNXRUNTIME_SOURCE_DIR}/lib/libonnxruntime.1.10.0.dylib" "${ONNXRUNTIME_SOURCE_DIR}/lib/${ONNXRUNTIME_LIB_NAME}"
CACHE FILEPATH "ONNXRUNTIME source library." FORCE) CACHE FILEPATH "ONNXRUNTIME source library." FORCE)
set(ONNXRUNTIME_LIB set(ONNXRUNTIME_LIB
"${ONNXRUNTIME_INSTALL_DIR}/lib/libonnxruntime.1.10.0.dylib" "${ONNXRUNTIME_INSTALL_DIR}/lib/${ONNXRUNTIME_LIB_NAME}"
CACHE FILEPATH "ONNXRUNTIME static library." FORCE) CACHE FILEPATH "ONNXRUNTIME static library." FORCE)
set(ONNXRUNTIME_SHARED_LIB set(ONNXRUNTIME_SHARED_LIB
${ONNXRUNTIME_LIB} ${ONNXRUNTIME_LIB}
CACHE FILEPATH "ONNXRUNTIME shared library." FORCE) CACHE FILEPATH "ONNXRUNTIME shared library." FORCE)
else() else()
set(ONNXRUNTIME_SOURCE_LIB set(ONNXRUNTIME_SOURCE_LIB
"${ONNXRUNTIME_SOURCE_DIR}/lib/libonnxruntime.so.1.10.0" "${ONNXRUNTIME_SOURCE_DIR}/lib/${ONNXRUNTIME_LIB_NAME}"
CACHE FILEPATH "ONNXRUNTIME source library." FORCE) CACHE FILEPATH "ONNXRUNTIME source library." FORCE)
set(ONNXRUNTIME_LIB set(ONNXRUNTIME_LIB
"${ONNXRUNTIME_INSTALL_DIR}/lib/libonnxruntime.so.1.10.0" "${ONNXRUNTIME_INSTALL_DIR}/lib/${ONNXRUNTIME_LIB_NAME}"
CACHE FILEPATH "ONNXRUNTIME static library." FORCE) CACHE FILEPATH "ONNXRUNTIME static library." FORCE)
set(ONNXRUNTIME_SHARED_LIB set(ONNXRUNTIME_SHARED_LIB
${ONNXRUNTIME_LIB} ${ONNXRUNTIME_LIB}
...@@ -117,7 +126,8 @@ else() ...@@ -117,7 +126,8 @@ else()
INSTALL_COMMAND INSTALL_COMMAND
${CMAKE_COMMAND} -E copy ${ONNXRUNTIME_SOURCE_LIB} ${ONNXRUNTIME_LIB} && ${CMAKE_COMMAND} -E copy ${ONNXRUNTIME_SOURCE_LIB} ${ONNXRUNTIME_LIB} &&
${CMAKE_COMMAND} -E copy_directory ${ONNXRUNTIME_SOURCE_DIR}/include ${CMAKE_COMMAND} -E copy_directory ${ONNXRUNTIME_SOURCE_DIR}/include
${ONNXRUNTIME_INC_DIR} ${ONNXRUNTIME_INC_DIR} && ${CMAKE_COMMAND} -E create_symlink
${ONNXRUNTIME_LIB_NAME} ${ONNXRUNTIME_LIB_DIR}/${ONNXRUNTIME_LIB_NEW_NAME}
BUILD_BYPRODUCTS ${ONNXRUNTIME_LIB}) BUILD_BYPRODUCTS ${ONNXRUNTIME_LIB})
endif() endif()
......
...@@ -24,6 +24,7 @@ endif() ...@@ -24,6 +24,7 @@ endif()
include(ExternalProject) include(ExternalProject)
set(PADDLE2ONNX_PROJECT "extern_paddle2onnx") set(PADDLE2ONNX_PROJECT "extern_paddle2onnx")
set(PADDLE2ONNX_VERSION "0.9.8")
set(PADDLE2ONNX_PREFIX_DIR ${THIRD_PARTY_PATH}/paddle2onnx) set(PADDLE2ONNX_PREFIX_DIR ${THIRD_PARTY_PATH}/paddle2onnx)
set(PADDLE2ONNX_SOURCE_DIR set(PADDLE2ONNX_SOURCE_DIR
${THIRD_PARTY_PATH}/paddle2onnx/src/${PADDLE2ONNX_PROJECT}) ${THIRD_PARTY_PATH}/paddle2onnx/src/${PADDLE2ONNX_PROJECT})
...@@ -38,6 +39,15 @@ set(CMAKE_BUILD_RPATH "${CMAKE_BUILD_RPATH}" "${PADDLE2ONNX_LIB_DIR}") ...@@ -38,6 +39,15 @@ set(CMAKE_BUILD_RPATH "${CMAKE_BUILD_RPATH}" "${PADDLE2ONNX_LIB_DIR}")
# For PADDLE2ONNX code to include internal headers. # For PADDLE2ONNX code to include internal headers.
include_directories(${PADDLE2ONNX_INC_DIR}) include_directories(${PADDLE2ONNX_INC_DIR})
set(PADDLE2ONNX_LIB_NEW_NAME "libpaddle2onnx${CMAKE_SHARED_LIBRARY_SUFFIX}")
if(APPLE)
set(PADDLE2ONNX_LIB_NAME
"libpaddle2onnx.${PADDLE2ONNX_VERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}")
else()
set(PADDLE2ONNX_LIB_NAME
"libpaddle2onnx${CMAKE_SHARED_LIBRARY_SUFFIX}.${PADDLE2ONNX_VERSION}")
endif()
if(WIN32) if(WIN32)
set(PADDLE2ONNX_LIB set(PADDLE2ONNX_LIB
"${PADDLE2ONNX_INSTALL_DIR}/lib/paddle2onnx.dll" "${PADDLE2ONNX_INSTALL_DIR}/lib/paddle2onnx.dll"
...@@ -45,50 +55,65 @@ if(WIN32) ...@@ -45,50 +55,65 @@ if(WIN32)
set(PADDLE2ONNX_COMPILE_LIB set(PADDLE2ONNX_COMPILE_LIB
"${PADDLE2ONNX_INSTALL_DIR}/lib/paddle2onnx.lib" "${PADDLE2ONNX_INSTALL_DIR}/lib/paddle2onnx.lib"
CACHE FILEPATH "paddle2onnx compile library." FORCE) CACHE FILEPATH "paddle2onnx compile library." FORCE)
elseif(APPLE)
set(PADDLE2ONNX_LIB
"${PADDLE2ONNX_INSTALL_DIR}/lib/libpaddle2onnx.dylib"
CACHE FILEPATH "PADDLE2ONNX library." FORCE)
set(PADDLE2ONNX_COMPILE_LIB
"${PADDLE2ONNX_INSTALL_DIR}/lib/libpaddle2onnx.dylib"
CACHE FILEPATH "paddle2onnx compile library." FORCE)
else() else()
set(PADDLE2ONNX_SOURCE_LIB
"${PADDLE2ONNX_SOURCE_DIR}/lib/${PADDLE2ONNX_LIB_NAME}"
CACHE FILEPATH "PADDLE2ONNX source library." FORCE)
set(PADDLE2ONNX_LIB set(PADDLE2ONNX_LIB
"${PADDLE2ONNX_INSTALL_DIR}/lib/libpaddle2onnx.so" "${PADDLE2ONNX_LIB_DIR}/${PADDLE2ONNX_LIB_NAME}"
CACHE FILEPATH "PADDLE2ONNX library." FORCE) CACHE FILEPATH "PADDLE2ONNX library." FORCE)
set(PADDLE2ONNX_COMPILE_LIB set(PADDLE2ONNX_COMPILE_LIB
"${PADDLE2ONNX_INSTALL_DIR}/lib/libpaddle2onnx.so" ${PADDLE2ONNX_LIB}
CACHE FILEPATH "paddle2onnx compile library." FORCE) CACHE FILEPATH "paddle2onnx compile library." FORCE)
endif() endif()
if(WIN32) if(WIN32)
set(PADDLE2ONNX_URL set(PADDLE2ONNX_URL
"https://github.com/PaddlePaddle/Paddle2ONNX/releases/download/v0.9.7/paddle2onnx-win-x64-0.9.7.zip" "https://github.com/PaddlePaddle/Paddle2ONNX/releases/download/v${PADDLE2ONNX_VERSION}/paddle2onnx-win-x64-${PADDLE2ONNX_VERSION}.zip"
) )
elseif(APPLE) elseif(APPLE)
set(PADDLE2ONNX_URL set(PADDLE2ONNX_URL
"https://github.com/PaddlePaddle/Paddle2ONNX/releases/download/v0.9.7/paddle2onnx-osx-x86_64-0.9.7.tgz" "https://github.com/PaddlePaddle/Paddle2ONNX/releases/download/v${PADDLE2ONNX_VERSION}/paddle2onnx-osx-x86_64-${PADDLE2ONNX_VERSION}.tgz"
) )
else() else()
set(PADDLE2ONNX_URL set(PADDLE2ONNX_URL
"https://github.com/PaddlePaddle/Paddle2ONNX/releases/download/v0.9.7/paddle2onnx-linux-x64-0.9.7.tgz" "https://github.com/PaddlePaddle/Paddle2ONNX/releases/download/v${PADDLE2ONNX_VERSION}/paddle2onnx-linux-x64-${PADDLE2ONNX_VERSION}.tgz"
) )
endif() endif()
ExternalProject_Add( if(WIN32)
${PADDLE2ONNX_PROJECT} ExternalProject_Add(
${EXTERNAL_PROJECT_LOG_ARGS} ${PADDLE2ONNX_PROJECT}
URL ${PADDLE2ONNX_URL} ${EXTERNAL_PROJECT_LOG_ARGS}
PREFIX ${PADDLE2ONNX_PREFIX_DIR} URL ${PADDLE2ONNX_URL}
DOWNLOAD_NO_PROGRESS 1 PREFIX ${PADDLE2ONNX_PREFIX_DIR}
CONFIGURE_COMMAND "" DOWNLOAD_NO_PROGRESS 1
BUILD_COMMAND "" CONFIGURE_COMMAND ""
UPDATE_COMMAND "" BUILD_COMMAND ""
INSTALL_COMMAND UPDATE_COMMAND ""
${CMAKE_COMMAND} -E copy_directory ${PADDLE2ONNX_SOURCE_DIR}/lib INSTALL_COMMAND
${PADDLE2ONNX_LIB_DIR} && ${CMAKE_COMMAND} -E copy_directory ${CMAKE_COMMAND} -E copy_directory ${PADDLE2ONNX_SOURCE_DIR}/lib
${PADDLE2ONNX_SOURCE_DIR}/include ${PADDLE2ONNX_INC_DIR} ${PADDLE2ONNX_LIB_DIR} && ${CMAKE_COMMAND} -E copy_directory
BUILD_BYPRODUCTS ${PADDLE2ONNX_COMPILE_LIB}) ${PADDLE2ONNX_SOURCE_DIR}/include ${PADDLE2ONNX_INC_DIR}
BUILD_BYPRODUCTS ${PADDLE2ONNX_COMPILE_LIB})
else()
ExternalProject_Add(
${PADDLE2ONNX_PROJECT}
${EXTERNAL_PROJECT_LOG_ARGS}
URL ${PADDLE2ONNX_URL}
PREFIX ${PADDLE2ONNX_PREFIX_DIR}
DOWNLOAD_NO_PROGRESS 1
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
UPDATE_COMMAND ""
INSTALL_COMMAND
${CMAKE_COMMAND} -E copy ${PADDLE2ONNX_SOURCE_LIB}
${PADDLE2ONNX_COMPILE_LIB} && ${CMAKE_COMMAND} -E copy_directory
${PADDLE2ONNX_SOURCE_DIR}/include ${PADDLE2ONNX_INC_DIR} &&
${CMAKE_COMMAND} -E create_symlink ${PADDLE2ONNX_LIB_NAME}
${PADDLE2ONNX_LIB_DIR}/${PADDLE2ONNX_LIB_NEW_NAME}
BUILD_BYPRODUCTS ${PADDLE2ONNX_COMPILE_LIB})
endif()
add_library(paddle2onnx STATIC IMPORTED GLOBAL) add_library(paddle2onnx STATIC IMPORTED GLOBAL)
set_property(TARGET paddle2onnx PROPERTY IMPORTED_LOCATION set_property(TARGET paddle2onnx PROPERTY IMPORTED_LOCATION
......
...@@ -189,21 +189,7 @@ else() ...@@ -189,21 +189,7 @@ else()
endif() endif()
if(WITH_ONNXRUNTIME) if(WITH_ONNXRUNTIME)
if(WIN32) set(DEPS ${DEPS} onnxruntime paddle2onnx)
set(DEPS
${DEPS} ${PADDLE_LIB_THIRD_PARTY_PATH}onnxruntime/lib/onnxruntime.lib
paddle2onnx)
elseif(APPLE)
set(DEPS
${DEPS}
${PADDLE_LIB_THIRD_PARTY_PATH}onnxruntime/lib/libonnxruntime.1.10.0.dylib
paddle2onnx)
else()
set(DEPS
${DEPS}
${PADDLE_LIB_THIRD_PARTY_PATH}onnxruntime/lib/libonnxruntime.so.1.10.0
paddle2onnx)
endif()
endif() endif()
if(NOT WIN32) if(NOT WIN32)
......
...@@ -214,21 +214,7 @@ else() ...@@ -214,21 +214,7 @@ else()
endif() endif()
if(WITH_ONNXRUNTIME) if(WITH_ONNXRUNTIME)
if(WIN32) set(DEPS ${DEPS} onnxruntime paddle2onnx)
set(DEPS
${DEPS} ${PADDLE_LIB_THIRD_PARTY_PATH}onnxruntime/lib/onnxruntime.lib
paddle2onnx)
elseif(APPLE)
set(DEPS
${DEPS}
${PADDLE_LIB_THIRD_PARTY_PATH}onnxruntime/lib/libonnxruntime.1.10.0.dylib
paddle2onnx)
else()
set(DEPS
${DEPS}
${PADDLE_LIB_THIRD_PARTY_PATH}onnxruntime/lib/libonnxruntime.so.1.10.0
paddle2onnx)
endif()
endif() endif()
if(NOT WIN32) if(NOT WIN32)
......
...@@ -380,17 +380,10 @@ if(WITH_PYTHON) ...@@ -380,17 +380,10 @@ if(WITH_PYTHON)
# LD_LIBRARY_PATH. This is different with Windows platformm, which search # LD_LIBRARY_PATH. This is different with Windows platformm, which search
# *.dll in current directory automatically. # *.dll in current directory automatically.
if(WITH_ONNXRUNTIME) if(WITH_ONNXRUNTIME)
if(APPLE) set(PADDLE2ONNX_PYBIND_OUT
set(PADDLE2ONNX_PYBIND_OUT ${CMAKE_CURRENT_BINARY_DIR}/${PADDLE2ONNX_LIB_NAME})
${CMAKE_CURRENT_BINARY_DIR}/libpaddle2onnx.dylib) set(ONNXRUNTIME_PYBIND_OUT
set(ONNXRUNTIME_PYBIND_OUT ${CMAKE_CURRENT_BINARY_DIR}/${ONNXRUNTIME_LIB_NAME})
${CMAKE_CURRENT_BINARY_DIR}/libonnxruntime.1.10.0.dylib)
else()
set(PADDLE2ONNX_PYBIND_OUT
${CMAKE_CURRENT_BINARY_DIR}/libpaddle2onnx.so)
set(ONNXRUNTIME_PYBIND_OUT
${CMAKE_CURRENT_BINARY_DIR}/libonnxruntime.so.1.10.0)
endif()
add_custom_command( add_custom_command(
OUTPUT ${PADDLE2ONNX_PYBIND_OUT} OUTPUT ${PADDLE2ONNX_PYBIND_OUT}
......
...@@ -538,10 +538,8 @@ if '${WITH_ONNXRUNTIME}' == 'ON': ...@@ -538,10 +538,8 @@ if '${WITH_ONNXRUNTIME}' == 'ON':
shutil.copy('${PADDLE2ONNX_LIB}', libs_path) shutil.copy('${PADDLE2ONNX_LIB}', libs_path)
if os.name == 'nt': if os.name == 'nt':
package_data['paddle.libs']+=['paddle2onnx.dll', 'onnxruntime.dll'] package_data['paddle.libs']+=['paddle2onnx.dll', 'onnxruntime.dll']
elif sys.platform == 'darwin':
package_data['paddle.libs']+=['libpaddle2onnx.dylib', 'libonnxruntime.1.10.0.dylib']
else: else:
package_data['paddle.libs']+=['libpaddle2onnx.so', 'libonnxruntime.so.1.10.0'] package_data['paddle.libs']+=['${PADDLE2ONNX_LIB_NAME}', '${ONNXRUNTIME_LIB_NAME}']
if '${WITH_XPU}' == 'ON': if '${WITH_XPU}' == 'ON':
# only change rpath in Release mode, # only change rpath in Release mode,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册