Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Commit 7e057f4

Browse files
authored
Merge pull request PaddlePaddle#824 from graphcore/develop_to_develop-ipu_032a649fefaeb0bcb78f4a8c1b185e24b97c7f93
[AUTO PR] Pulling [develop] into [develop-ipu] [2022-06-21 17:24:51+08:00]
2 parents 032a649 + 295f289 commit 7e057f4

File tree

131 files changed

+4425
-2742
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+4425
-2742
lines changed

cmake/external/onnxruntime.cmake

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ include(ExternalProject)
2626
add_definitions(-DPADDLE_WITH_ONNXRUNTIME)
2727

2828
set(ONNXRUNTIME_PROJECT "extern_onnxruntime")
29+
set(ONNXRUNTIME_VERSION "1.10.0")
2930
set(ONNXRUNTIME_PREFIX_DIR ${THIRD_PARTY_PATH}/onnxruntime)
3031
set(ONNXRUNTIME_SOURCE_DIR
3132
${THIRD_PARTY_PATH}/onnxruntime/src/${ONNXRUNTIME_PROJECT})
@@ -40,20 +41,29 @@ set(CMAKE_BUILD_RPATH "${CMAKE_BUILD_RPATH}" "${ONNXRUNTIME_LIB_DIR}")
4041

4142
if(WIN32)
4243
set(ONNXRUNTIME_URL
43-
"https://github.com/microsoft/onnxruntime/releases/download/v1.10.0/onnxruntime-win-x64-1.10.0.zip"
44+
"https://github.com/microsoft/onnxruntime/releases/download/v${ONNXRUNTIME_VERSION}/onnxruntime-win-x64-${ONNXRUNTIME_VERSION}.zip"
4445
)
4546
elseif(APPLE)
4647
set(ONNXRUNTIME_URL
47-
"https://github.com/microsoft/onnxruntime/releases/download/v1.10.0/onnxruntime-osx-x86_64-1.10.0.tgz"
48+
"https://github.com/microsoft/onnxruntime/releases/download/v${ONNXRUNTIME_VERSION}/onnxruntime-osx-x86_64-${ONNXRUNTIME_VERSION}.tgz"
4849
)
4950
else()
5051
set(ONNXRUNTIME_URL
51-
"https://github.com/microsoft/onnxruntime/releases/download/v1.10.0/onnxruntime-linux-x64-1.10.0.tgz"
52+
"https://github.com/microsoft/onnxruntime/releases/download/v${ONNXRUNTIME_VERSION}/onnxruntime-linux-x64-${ONNXRUNTIME_VERSION}.tgz"
5253
)
5354
endif()
5455

55-
include_directories(${ONNXRUNTIME_INC_DIR}
56-
)# For ONNXRUNTIME code to include internal headers.
56+
# For ONNXRUNTIME code to include internal headers.
57+
include_directories(${ONNXRUNTIME_INC_DIR})
58+
59+
set(ONNXRUNTIME_LIB_NEW_NAME "libonnxruntime${CMAKE_SHARED_LIBRARY_SUFFIX}")
60+
if(APPLE)
61+
set(ONNXRUNTIME_LIB_NAME
62+
"libonnxruntime.${ONNXRUNTIME_VERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}")
63+
else()
64+
set(ONNXRUNTIME_LIB_NAME
65+
"libonnxruntime${CMAKE_SHARED_LIBRARY_SUFFIX}.${ONNXRUNTIME_VERSION}")
66+
endif()
5767
if(WIN32)
5868
set(ONNXRUNTIME_SOURCE_LIB
5969
"${ONNXRUNTIME_SOURCE_DIR}/lib/onnxruntime.dll"
@@ -66,20 +76,20 @@ if(WIN32)
6676
CACHE FILEPATH "ONNXRUNTIME static library." FORCE)
6777
elseif(APPLE)
6878
set(ONNXRUNTIME_SOURCE_LIB
69-
"${ONNXRUNTIME_SOURCE_DIR}/lib/libonnxruntime.1.10.0.dylib"
79+
"${ONNXRUNTIME_SOURCE_DIR}/lib/${ONNXRUNTIME_LIB_NAME}"
7080
CACHE FILEPATH "ONNXRUNTIME source library." FORCE)
7181
set(ONNXRUNTIME_LIB
72-
"${ONNXRUNTIME_INSTALL_DIR}/lib/libonnxruntime.1.10.0.dylib"
82+
"${ONNXRUNTIME_INSTALL_DIR}/lib/${ONNXRUNTIME_LIB_NAME}"
7383
CACHE FILEPATH "ONNXRUNTIME static library." FORCE)
7484
set(ONNXRUNTIME_SHARED_LIB
7585
${ONNXRUNTIME_LIB}
7686
CACHE FILEPATH "ONNXRUNTIME shared library." FORCE)
7787
else()
7888
set(ONNXRUNTIME_SOURCE_LIB
79-
"${ONNXRUNTIME_SOURCE_DIR}/lib/libonnxruntime.so.1.10.0"
89+
"${ONNXRUNTIME_SOURCE_DIR}/lib/${ONNXRUNTIME_LIB_NAME}"
8090
CACHE FILEPATH "ONNXRUNTIME source library." FORCE)
8191
set(ONNXRUNTIME_LIB
82-
"${ONNXRUNTIME_INSTALL_DIR}/lib/libonnxruntime.so.1.10.0"
92+
"${ONNXRUNTIME_INSTALL_DIR}/lib/${ONNXRUNTIME_LIB_NAME}"
8393
CACHE FILEPATH "ONNXRUNTIME static library." FORCE)
8494
set(ONNXRUNTIME_SHARED_LIB
8595
${ONNXRUNTIME_LIB}
@@ -116,7 +126,8 @@ else()
116126
INSTALL_COMMAND
117127
${CMAKE_COMMAND} -E copy ${ONNXRUNTIME_SOURCE_LIB} ${ONNXRUNTIME_LIB} &&
118128
${CMAKE_COMMAND} -E copy_directory ${ONNXRUNTIME_SOURCE_DIR}/include
119-
${ONNXRUNTIME_INC_DIR}
129+
${ONNXRUNTIME_INC_DIR} && ${CMAKE_COMMAND} -E create_symlink
130+
${ONNXRUNTIME_LIB_NAME} ${ONNXRUNTIME_LIB_DIR}/${ONNXRUNTIME_LIB_NEW_NAME}
120131
BUILD_BYPRODUCTS ${ONNXRUNTIME_LIB})
121132
endif()
122133

cmake/external/paddle2onnx.cmake

Lines changed: 53 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ endif()
2424
include(ExternalProject)
2525

2626
set(PADDLE2ONNX_PROJECT "extern_paddle2onnx")
27+
set(PADDLE2ONNX_VERSION "0.9.9")
2728
set(PADDLE2ONNX_PREFIX_DIR ${THIRD_PARTY_PATH}/paddle2onnx)
2829
set(PADDLE2ONNX_SOURCE_DIR
2930
${THIRD_PARTY_PATH}/paddle2onnx/src/${PADDLE2ONNX_PROJECT})
@@ -34,71 +35,85 @@ set(PADDLE2ONNX_INC_DIR
3435
set(PADDLE2ONNX_LIB_DIR
3536
"${PADDLE2ONNX_INSTALL_DIR}/lib"
3637
CACHE PATH "onnxruntime lib directory." FORCE)
37-
set(CMAKE_BUILD_RPATH "${CMAKE_BUILD_RPATH}"
38-
"${PADDLE2ONNX_INSTALL_DIR}/${LIBDIR}")
38+
set(CMAKE_BUILD_RPATH "${CMAKE_BUILD_RPATH}" "${PADDLE2ONNX_LIB_DIR}")
39+
40+
# For PADDLE2ONNX code to include internal headers.
41+
include_directories(${PADDLE2ONNX_INC_DIR})
42+
set(PADDLE2ONNX_LIB_NEW_NAME "libpaddle2onnx${CMAKE_SHARED_LIBRARY_SUFFIX}")
43+
if(APPLE)
44+
set(PADDLE2ONNX_LIB_NAME
45+
"libpaddle2onnx.${PADDLE2ONNX_VERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}")
46+
else()
47+
set(PADDLE2ONNX_LIB_NAME
48+
"libpaddle2onnx${CMAKE_SHARED_LIBRARY_SUFFIX}.${PADDLE2ONNX_VERSION}")
49+
endif()
3950

40-
include_directories(${PADDLE2ONNX_INC_DIR}
41-
)# For PADDLE2ONNX code to include internal headers.
4251
if(WIN32)
43-
set(PADDLE2ONNX_SOURCE_LIB
44-
"${PADDLE2ONNX_SOURCE_DIR}/lib/libpaddle2onnx.dylib"
45-
CACHE FILEPATH "Paddle2ONNX source library." FORCE)
4652
set(PADDLE2ONNX_LIB
4753
"${PADDLE2ONNX_INSTALL_DIR}/lib/paddle2onnx.dll"
4854
CACHE FILEPATH "paddle2onnx library." FORCE)
4955
set(PADDLE2ONNX_COMPILE_LIB
5056
"${PADDLE2ONNX_INSTALL_DIR}/lib/paddle2onnx.lib"
5157
CACHE FILEPATH "paddle2onnx compile library." FORCE)
52-
elseif(APPLE)
53-
set(PADDLE2ONNX_SOURCE_LIB
54-
"${PADDLE2ONNX_SOURCE_DIR}/lib/libpaddle2onnx.dylib"
55-
CACHE FILEPATH "Paddle2ONNX source library." FORCE)
56-
set(PADDLE2ONNX_LIB
57-
"${PADDLE2ONNX_INSTALL_DIR}/lib/libpaddle2onnx.dylib"
58-
CACHE FILEPATH "PADDLE2ONNX library." FORCE)
59-
set(PADDLE2ONNX_COMPILE_LIB
60-
"${PADDLE2ONNX_INSTALL_DIR}/lib/libpaddle2onnx.dylib"
61-
CACHE FILEPATH "paddle2onnx compile library." FORCE)
6258
else()
6359
set(PADDLE2ONNX_SOURCE_LIB
64-
"${PADDLE2ONNX_SOURCE_DIR}/lib/libpaddle2onnx.so"
65-
CACHE FILEPATH "Paddle2ONNX source library." FORCE)
60+
"${PADDLE2ONNX_SOURCE_DIR}/lib/${PADDLE2ONNX_LIB_NAME}"
61+
CACHE FILEPATH "PADDLE2ONNX source library." FORCE)
6662
set(PADDLE2ONNX_LIB
67-
"${PADDLE2ONNX_INSTALL_DIR}/lib/libpaddle2onnx.so"
63+
"${PADDLE2ONNX_LIB_DIR}/${PADDLE2ONNX_LIB_NAME}"
6864
CACHE FILEPATH "PADDLE2ONNX library." FORCE)
6965
set(PADDLE2ONNX_COMPILE_LIB
70-
"${PADDLE2ONNX_INSTALL_DIR}/lib/libpaddle2onnx.so"
66+
${PADDLE2ONNX_LIB}
7167
CACHE FILEPATH "paddle2onnx compile library." FORCE)
7268
endif()
7369

7470
if(WIN32)
7571
set(PADDLE2ONNX_URL
76-
"https://github.com/PaddlePaddle/Paddle2ONNX/releases/download/v0.9.7/paddle2onnx-win-x64-0.9.7.zip"
72+
"https://github.com/PaddlePaddle/Paddle2ONNX/releases/download/v${PADDLE2ONNX_VERSION}/paddle2onnx-win-x64-${PADDLE2ONNX_VERSION}.zip"
7773
)
7874
elseif(APPLE)
7975
set(PADDLE2ONNX_URL
80-
"https://github.com/PaddlePaddle/Paddle2ONNX/releases/download/v0.9.7/paddle2onnx-osx-x86_64-0.9.7.tgz"
76+
"https://github.com/PaddlePaddle/Paddle2ONNX/releases/download/v${PADDLE2ONNX_VERSION}/paddle2onnx-osx-x86_64-${PADDLE2ONNX_VERSION}.tgz"
8177
)
8278
else()
8379
set(PADDLE2ONNX_URL
84-
"https://github.com/PaddlePaddle/Paddle2ONNX/releases/download/v0.9.7/paddle2onnx-linux-x64-0.9.7.tgz"
80+
"https://github.com/PaddlePaddle/Paddle2ONNX/releases/download/v${PADDLE2ONNX_VERSION}/paddle2onnx-linux-x64-${PADDLE2ONNX_VERSION}.tgz"
8581
)
8682
endif()
8783

88-
ExternalProject_Add(
89-
${PADDLE2ONNX_PROJECT}
90-
${EXTERNAL_PROJECT_LOG_ARGS}
91-
URL ${PADDLE2ONNX_URL}
92-
PREFIX ${PADDLE2ONNX_PREFIX_DIR}
93-
DOWNLOAD_NO_PROGRESS 1
94-
CONFIGURE_COMMAND ""
95-
BUILD_COMMAND ""
96-
UPDATE_COMMAND ""
97-
INSTALL_COMMAND
98-
${CMAKE_COMMAND} -E copy_directory ${PADDLE2ONNX_SOURCE_DIR}/lib
99-
${PADDLE2ONNX_LIB_DIR} && ${CMAKE_COMMAND} -E copy_directory
100-
${PADDLE2ONNX_SOURCE_DIR}/include ${PADDLE2ONNX_INC_DIR}
101-
BUILD_BYPRODUCTS ${PADDLE2ONNX_COMPILE_LIB})
84+
if(WIN32)
85+
ExternalProject_Add(
86+
${PADDLE2ONNX_PROJECT}
87+
${EXTERNAL_PROJECT_LOG_ARGS}
88+
URL ${PADDLE2ONNX_URL}
89+
PREFIX ${PADDLE2ONNX_PREFIX_DIR}
90+
DOWNLOAD_NO_PROGRESS 1
91+
CONFIGURE_COMMAND ""
92+
BUILD_COMMAND ""
93+
UPDATE_COMMAND ""
94+
INSTALL_COMMAND
95+
${CMAKE_COMMAND} -E copy_directory ${PADDLE2ONNX_SOURCE_DIR}/lib
96+
${PADDLE2ONNX_LIB_DIR} && ${CMAKE_COMMAND} -E copy_directory
97+
${PADDLE2ONNX_SOURCE_DIR}/include ${PADDLE2ONNX_INC_DIR}
98+
BUILD_BYPRODUCTS ${PADDLE2ONNX_COMPILE_LIB})
99+
else()
100+
ExternalProject_Add(
101+
${PADDLE2ONNX_PROJECT}
102+
${EXTERNAL_PROJECT_LOG_ARGS}
103+
URL ${PADDLE2ONNX_URL}
104+
PREFIX ${PADDLE2ONNX_PREFIX_DIR}
105+
DOWNLOAD_NO_PROGRESS 1
106+
CONFIGURE_COMMAND ""
107+
BUILD_COMMAND ""
108+
UPDATE_COMMAND ""
109+
INSTALL_COMMAND
110+
${CMAKE_COMMAND} -E copy ${PADDLE2ONNX_SOURCE_LIB}
111+
${PADDLE2ONNX_COMPILE_LIB} && ${CMAKE_COMMAND} -E copy_directory
112+
${PADDLE2ONNX_SOURCE_DIR}/include ${PADDLE2ONNX_INC_DIR} &&
113+
${CMAKE_COMMAND} -E create_symlink ${PADDLE2ONNX_LIB_NAME}
114+
${PADDLE2ONNX_LIB_DIR}/${PADDLE2ONNX_LIB_NEW_NAME}
115+
BUILD_BYPRODUCTS ${PADDLE2ONNX_COMPILE_LIB})
116+
endif()
102117

103118
add_library(paddle2onnx STATIC IMPORTED GLOBAL)
104119
set_property(TARGET paddle2onnx PROPERTY IMPORTED_LOCATION

0 commit comments

Comments
 (0)