Skip to content

Commit

Permalink
paddle2onnx update to 0.9.8
Browse files Browse the repository at this point in the history
  • Loading branch information
heliqi committed Jun 21, 2022
1 parent 61591af commit cbd29d0
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 78 deletions.
26 changes: 18 additions & 8 deletions cmake/external/onnxruntime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ include(ExternalProject)
add_definitions(-DPADDLE_WITH_ONNXRUNTIME)

set(ONNXRUNTIME_PROJECT "extern_onnxruntime")
set(ONNXRUNTIME_VERSION "1.10.0")
set(ONNXRUNTIME_PREFIX_DIR ${THIRD_PARTY_PATH}/onnxruntime)
set(ONNXRUNTIME_SOURCE_DIR
${THIRD_PARTY_PATH}/onnxruntime/src/${ONNXRUNTIME_PROJECT})
Expand All @@ -40,21 +41,29 @@ set(CMAKE_BUILD_RPATH "${CMAKE_BUILD_RPATH}" "${ONNXRUNTIME_LIB_DIR}")

if(WIN32)
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)
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()
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()

# For ONNXRUNTIME code to include internal headers.
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)
set(ONNXRUNTIME_SOURCE_LIB
"${ONNXRUNTIME_SOURCE_DIR}/lib/onnxruntime.dll"
Expand All @@ -67,20 +76,20 @@ if(WIN32)
CACHE FILEPATH "ONNXRUNTIME static library." FORCE)
elseif(APPLE)
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)
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)
set(ONNXRUNTIME_SHARED_LIB
${ONNXRUNTIME_LIB}
CACHE FILEPATH "ONNXRUNTIME shared library." FORCE)
else()
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)
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)
set(ONNXRUNTIME_SHARED_LIB
${ONNXRUNTIME_LIB}
Expand Down Expand Up @@ -117,7 +126,8 @@ else()
INSTALL_COMMAND
${CMAKE_COMMAND} -E copy ${ONNXRUNTIME_SOURCE_LIB} ${ONNXRUNTIME_LIB} &&
${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})
endif()

Expand Down
77 changes: 51 additions & 26 deletions cmake/external/paddle2onnx.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ endif()
include(ExternalProject)

set(PADDLE2ONNX_PROJECT "extern_paddle2onnx")
set(PADDLE2ONNX_VERSION "0.9.8")
set(PADDLE2ONNX_PREFIX_DIR ${THIRD_PARTY_PATH}/paddle2onnx)
set(PADDLE2ONNX_SOURCE_DIR
${THIRD_PARTY_PATH}/paddle2onnx/src/${PADDLE2ONNX_PROJECT})
Expand All @@ -38,57 +39,81 @@ set(CMAKE_BUILD_RPATH "${CMAKE_BUILD_RPATH}" "${PADDLE2ONNX_LIB_DIR}")

# For PADDLE2ONNX code to include internal headers.
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)
set(PADDLE2ONNX_LIB
"${PADDLE2ONNX_INSTALL_DIR}/lib/paddle2onnx.dll"
CACHE FILEPATH "paddle2onnx library." FORCE)
set(PADDLE2ONNX_COMPILE_LIB
"${PADDLE2ONNX_INSTALL_DIR}/lib/paddle2onnx.lib"
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()
set(PADDLE2ONNX_SOURCE_LIB
"${PADDLE2ONNX_SOURCE_DIR}/lib/${PADDLE2ONNX_LIB_NAME}"
CACHE FILEPATH "PADDLE2ONNX source library." FORCE)
set(PADDLE2ONNX_LIB
"${PADDLE2ONNX_INSTALL_DIR}/lib/libpaddle2onnx.so"
"${PADDLE2ONNX_LIB_DIR}/${PADDLE2ONNX_LIB_NAME}"
CACHE FILEPATH "PADDLE2ONNX library." FORCE)
set(PADDLE2ONNX_COMPILE_LIB
"${PADDLE2ONNX_INSTALL_DIR}/lib/libpaddle2onnx.so"
${PADDLE2ONNX_LIB}
CACHE FILEPATH "paddle2onnx compile library." FORCE)
endif()

if(WIN32)
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)
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()
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()

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_directory ${PADDLE2ONNX_SOURCE_DIR}/lib
${PADDLE2ONNX_LIB_DIR} && ${CMAKE_COMMAND} -E copy_directory
${PADDLE2ONNX_SOURCE_DIR}/include ${PADDLE2ONNX_INC_DIR}
BUILD_BYPRODUCTS ${PADDLE2ONNX_COMPILE_LIB})
if(WIN32)
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_directory ${PADDLE2ONNX_SOURCE_DIR}/lib
${PADDLE2ONNX_LIB_DIR} && ${CMAKE_COMMAND} -E copy_directory
${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)
set_property(TARGET paddle2onnx PROPERTY IMPORTED_LOCATION
Expand Down
16 changes: 1 addition & 15 deletions paddle/fluid/inference/api/demo_ci/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,21 +189,7 @@ else()
endif()

if(WITH_ONNXRUNTIME)
if(WIN32)
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()
set(DEPS ${DEPS} onnxruntime paddle2onnx)
endif()

if(NOT WIN32)
Expand Down
16 changes: 1 addition & 15 deletions paddle/fluid/inference/tests/infer_ut/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,21 +214,7 @@ else()
endif()

if(WITH_ONNXRUNTIME)
if(WIN32)
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()
set(DEPS ${DEPS} onnxruntime paddle2onnx)
endif()

if(NOT WIN32)
Expand Down
15 changes: 4 additions & 11 deletions paddle/fluid/pybind/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -380,17 +380,10 @@ if(WITH_PYTHON)
# LD_LIBRARY_PATH. This is different with Windows platformm, which search
# *.dll in current directory automatically.
if(WITH_ONNXRUNTIME)
if(APPLE)
set(PADDLE2ONNX_PYBIND_OUT
${CMAKE_CURRENT_BINARY_DIR}/libpaddle2onnx.dylib)
set(ONNXRUNTIME_PYBIND_OUT
${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()
set(PADDLE2ONNX_PYBIND_OUT
${CMAKE_CURRENT_BINARY_DIR}/${PADDLE2ONNX_LIB_NAME})
set(ONNXRUNTIME_PYBIND_OUT
${CMAKE_CURRENT_BINARY_DIR}/${ONNXRUNTIME_LIB_NAME})

add_custom_command(
OUTPUT ${PADDLE2ONNX_PYBIND_OUT}
Expand Down
4 changes: 1 addition & 3 deletions python/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -538,10 +538,8 @@ if '${WITH_ONNXRUNTIME}' == 'ON':
shutil.copy('${PADDLE2ONNX_LIB}', libs_path)
if os.name == 'nt':
package_data['paddle.libs']+=['paddle2onnx.dll', 'onnxruntime.dll']
elif sys.platform == 'darwin':
package_data['paddle.libs']+=['libpaddle2onnx.dylib', 'libonnxruntime.1.10.0.dylib']
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':
# only change rpath in Release mode,
Expand Down

1 comment on commit cbd29d0

@paddle-bot-old
Copy link

@paddle-bot-old paddle-bot-old bot commented on cbd29d0 Jun 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕵️ CI failures summary

🔍 PR: #43742 Commit ID: cbd29d0 contains failed CI.

🔹 Failed: PR-CI-APPROVAL

Unknown Failed
Unknown Failed

🔹 Failed: PR-CI-Windows

Unknown Failed
Unknown Failed

Please sign in to comment.