-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
… fix_fwd_default_value
- Loading branch information
Showing
536 changed files
with
26,744 additions
and
11,129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
if (NOT WITH_ONNXRUNTIME) | ||
return() | ||
endif () | ||
|
||
if (WITH_ARM) | ||
message(SEND_ERROR "The current onnxruntime backend doesn't support ARM cpu") | ||
return() | ||
endif () | ||
|
||
INCLUDE(ExternalProject) | ||
|
||
add_definitions(-DPADDLE_WITH_ONNXRUNTIME) | ||
|
||
SET(ONNXRUNTIME_PROJECT "extern_onnxruntime") | ||
SET(ONNXRUNTIME_PREFIX_DIR ${THIRD_PARTY_PATH}/onnxruntime) | ||
SET(ONNXRUNTIME_SOURCE_DIR ${THIRD_PARTY_PATH}/onnxruntime/src/${ONNXRUNTIME_PROJECT}) | ||
SET(ONNXRUNTIME_INSTALL_DIR ${THIRD_PARTY_PATH}/install/onnxruntime) | ||
SET(ONNXRUNTIME_INC_DIR "${ONNXRUNTIME_INSTALL_DIR}/include" CACHE PATH "onnxruntime include directory." FORCE) | ||
SET(ONNXRUNTIME_LIB_DIR "${ONNXRUNTIME_INSTALL_DIR}/lib" CACHE PATH "onnxruntime lib directory." FORCE) | ||
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") | ||
elseif (APPLE) | ||
SET(ONNXRUNTIME_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.10.0/onnxruntime-osx-x86_64-1.10.0.tgz") | ||
else () | ||
SET(ONNXRUNTIME_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.10.0/onnxruntime-linux-x64-1.10.0.tgz") | ||
endif() | ||
|
||
|
||
INCLUDE_DIRECTORIES(${ONNXRUNTIME_INC_DIR}) # For ONNXRUNTIME code to include internal headers. | ||
if (WIN32) | ||
SET(ONNXRUNTIME_SOURCE_LIB "${ONNXRUNTIME_SOURCE_DIR}/lib/onnxruntime.dll" CACHE FILEPATH "ONNXRUNTIME source library." FORCE) | ||
SET(ONNXRUNTIME_SHARED_LIB "${ONNXRUNTIME_INSTALL_DIR}/lib/onnxruntime.dll" CACHE FILEPATH "ONNXRUNTIME shared library." FORCE) | ||
SET(ONNXRUNTIME_LIB "${ONNXRUNTIME_INSTALL_DIR}/lib/onnxruntime.lib" CACHE FILEPATH "ONNXRUNTIME static library." FORCE) | ||
elseif (APPLE) | ||
SET(ONNXRUNTIME_SOURCE_LIB "${ONNXRUNTIME_SOURCE_DIR}/lib/libonnxruntime.1.10.0.dylib" CACHE FILEPATH "ONNXRUNTIME source library." FORCE) | ||
SET(ONNXRUNTIME_LIB "${ONNXRUNTIME_INSTALL_DIR}/lib/libonnxruntime.1.10.0.dylib" 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" CACHE FILEPATH "ONNXRUNTIME source library." FORCE) | ||
SET(ONNXRUNTIME_LIB "${ONNXRUNTIME_INSTALL_DIR}/lib/libonnxruntime.so.1.10.0" CACHE FILEPATH "ONNXRUNTIME static library." FORCE) | ||
SET(ONNXRUNTIME_SHARED_LIB ${ONNXRUNTIME_LIB} CACHE FILEPATH "ONNXRUNTIME shared library." FORCE) | ||
endif () | ||
|
||
if (WIN32) | ||
ExternalProject_Add( | ||
${ONNXRUNTIME_PROJECT} | ||
${EXTERNAL_PROJECT_LOG_ARGS} | ||
URL ${ONNXRUNTIME_URL} | ||
PREFIX ${ONNXRUNTIME_PREFIX_DIR} | ||
DOWNLOAD_NO_PROGRESS 1 | ||
CONFIGURE_COMMAND "" | ||
BUILD_COMMAND "" | ||
UPDATE_COMMAND "" | ||
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy ${ONNXRUNTIME_SOURCE_LIB} ${ONNXRUNTIME_SHARED_LIB} && | ||
${CMAKE_COMMAND} -E copy ${ONNXRUNTIME_SOURCE_DIR}/lib/onnxruntime.lib ${ONNXRUNTIME_LIB} && | ||
${CMAKE_COMMAND} -E copy_directory ${ONNXRUNTIME_SOURCE_DIR}/include ${ONNXRUNTIME_INC_DIR} | ||
BUILD_BYPRODUCTS ${ONNXRUNTIME_LIB} | ||
) | ||
else () | ||
ExternalProject_Add( | ||
${ONNXRUNTIME_PROJECT} | ||
${EXTERNAL_PROJECT_LOG_ARGS} | ||
URL ${ONNXRUNTIME_URL} | ||
PREFIX ${ONNXRUNTIME_PREFIX_DIR} | ||
DOWNLOAD_NO_PROGRESS 1 | ||
CONFIGURE_COMMAND "" | ||
BUILD_COMMAND "" | ||
UPDATE_COMMAND "" | ||
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy ${ONNXRUNTIME_SOURCE_LIB} ${ONNXRUNTIME_LIB} && | ||
${CMAKE_COMMAND} -E copy_directory ${ONNXRUNTIME_SOURCE_DIR}/include ${ONNXRUNTIME_INC_DIR} | ||
BUILD_BYPRODUCTS ${ONNXRUNTIME_LIB} | ||
) | ||
endif() | ||
|
||
ADD_LIBRARY(onnxruntime STATIC IMPORTED GLOBAL) | ||
SET_PROPERTY(TARGET onnxruntime PROPERTY IMPORTED_LOCATION ${ONNXRUNTIME_LIB}) | ||
ADD_DEPENDENCIES(onnxruntime ${ONNXRUNTIME_PROJECT}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
if(NOT WITH_ONNXRUNTIME) | ||
return() | ||
endif() | ||
|
||
if (WITH_ARM) | ||
message(SEND_ERROR "The current onnxruntime backend doesn't support ARM cpu") | ||
return() | ||
endif () | ||
|
||
INCLUDE(ExternalProject) | ||
|
||
SET(PADDLE2ONNX_PROJECT "extern_paddle2onnx") | ||
SET(PADDLE2ONNX_PREFIX_DIR ${THIRD_PARTY_PATH}/paddle2onnx) | ||
SET(PADDLE2ONNX_INSTALL_DIR ${THIRD_PARTY_PATH}/install/paddle2onnx) | ||
SET(PADDLE2ONNX_INC_DIR "${PADDLE2ONNX_INSTALL_DIR}/include" CACHE PATH "paddle2onnx include directory." FORCE) | ||
SET(PADDLE2ONNX_REPOSITORY ${GIT_URL}/PaddlePaddle/Paddle2ONNX.git) | ||
SET(PADDLE2ONNX_TAG cpp) | ||
SET(LIBDIR "lib") | ||
SET(CMAKE_BUILD_RPATH "${CMAKE_BUILD_RPATH}" "${PADDLE2ONNX_INSTALL_DIR}/${LIBDIR}") | ||
|
||
INCLUDE_DIRECTORIES(${PADDLE2ONNX_INC_DIR}) # For PADDLE2ONNX code to include internal headers. | ||
if(WIN32) | ||
SET(PADDLE2ONNX_LIB "${PADDLE2ONNX_INSTALL_DIR}/${LIBDIR}/paddle2onnx.lib" CACHE FILEPATH "paddle2onnx static library." FORCE) | ||
SET(PADDLE2ONNX_SHARED_LIB "${PADDLE2ONNX_INSTALL_DIR}/${LIBDIR}/paddle2onnx.dll" CACHE FILEPATH "paddle2onnx shared library." FORCE) | ||
elseif(APPLE) | ||
SET(PADDLE2ONNX_LIB "${PADDLE2ONNX_INSTALL_DIR}/${LIBDIR}/libpaddle2onnx.dylib" CACHE FILEPATH "PADDLE2ONNX library." FORCE) | ||
else() | ||
SET(PADDLE2ONNX_LIB "${PADDLE2ONNX_INSTALL_DIR}/${LIBDIR}/libpaddle2onnx.so" CACHE FILEPATH "PADDLE2ONNX library." FORCE) | ||
endif(WIN32) | ||
|
||
|
||
# The protoc path is required to compile onnx. | ||
string(REPLACE "/" ";" PROTOC_BIN_PATH ${PROTOBUF_PROTOC_EXECUTABLE}) | ||
list(POP_BACK PROTOC_BIN_PATH) | ||
list(JOIN PROTOC_BIN_PATH "/" PROTOC_BIN_PATH) | ||
|
||
|
||
set(PADDLE2ONNX_OPTIONAL_ARGS | ||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} | ||
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} | ||
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} | ||
-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE} | ||
-DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG} | ||
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} | ||
-DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG} | ||
-DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE} | ||
-DONNX_CUSTOM_PROTOC_PATH=${PROTOC_BIN_PATH} | ||
-DWITH_STATIC=OFF | ||
-DCMAKE_INSTALL_PREFIX=${PADDLE2ONNX_INSTALL_DIR} | ||
-DCMAKE_POSITION_INDEPENDENT_CODE=ON | ||
-DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE} | ||
${EXTERNAL_OPTIONAL_ARGS} | ||
) | ||
|
||
if (WITH_PYTHON) | ||
set(PADDLE2ONNX_OPTIONAL_ARGS ${PADDLE2ONNX_OPTIONAL_ARGS} | ||
-DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE} | ||
-DPYTHON_INCLUDE_DIR:PATH=${PYTHON_INCLUDE_DIR} | ||
-DPYTHON_LIBRARY:FILEPATH=${PYTHON_LIBRARY} | ||
) | ||
endif () | ||
|
||
|
||
ExternalProject_Add( | ||
${PADDLE2ONNX_PROJECT} | ||
${EXTERNAL_PROJECT_LOG_ARGS} | ||
${SHALLOW_CLONE} | ||
GIT_REPOSITORY ${PADDLE2ONNX_REPOSITORY} | ||
GIT_TAG ${PADDLE2ONNX_TAG} | ||
DEPENDS protobuf | ||
PREFIX ${PADDLE2ONNX_PREFIX_DIR} | ||
UPDATE_COMMAND "" | ||
CMAKE_ARGS ${PADDLE2ONNX_OPTIONAL_ARGS} | ||
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${PADDLE2ONNX_INSTALL_DIR} | ||
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON | ||
-DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE} | ||
BUILD_BYPRODUCTS ${PADDLE2ONNX_LIB} | ||
) | ||
|
||
ADD_LIBRARY(paddle2onnx STATIC IMPORTED GLOBAL) | ||
SET_PROPERTY(TARGET paddle2onnx PROPERTY IMPORTED_LOCATION ${PADDLE2ONNX_LIB}) | ||
ADD_DEPENDENCIES(paddle2onnx ${PADDLE2ONNX_PROJECT}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
94a3442
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅Congratulation! Your pull request passed all required CI. You could ask reviewer(s) to approve and merge. 🎉