Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[onnxruntime] update to v1.19.0 #263

Merged
merged 4 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions ports/onnxruntime/cuDNN.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
add_library(CUDNN::cudnn_all INTERFACE IMPORTED)

find_path(
CUDNN_INCLUDE_DIR cudnn.h
HINTS $ENV{CUDNN_PATH} ${CUDNN_PATH} ${Python_SITEARCH}/nvidia/cudnn ${CUDAToolkit_INCLUDE_DIRS}
PATH_SUFFIXES include
REQUIRED
)

file(READ "${CUDNN_INCLUDE_DIR}/cudnn_version.h" cudnn_version_header)
string(REGEX MATCH "#define CUDNN_MAJOR [1-9]+" macrodef "${cudnn_version_header}")
string(REGEX MATCH "[1-9]+" CUDNN_MAJOR_VERSION "${macrodef}")

function(find_cudnn_library NAME)
find_library(
${NAME}_LIBRARY ${NAME} "lib${NAME}.so.${CUDNN_MAJOR_VERSION}"
HINTS $ENV{CUDNN_PATH} ${CUDNN_PATH} ${Python_SITEARCH}/nvidia/cudnn ${CUDAToolkit_LIBRARY_DIR}
PATH_SUFFIXES lib64 lib/x64 lib
REQUIRED
)

if(${NAME}_LIBRARY)
add_library(CUDNN::${NAME} UNKNOWN IMPORTED)
set_target_properties(
CUDNN::${NAME} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CUDNN_INCLUDE_DIR}
IMPORTED_LOCATION ${${NAME}_LIBRARY}
)
message(STATUS "${NAME} found at ${${NAME}_LIBRARY}.")
else()
message(STATUS "${NAME} not found.")
endif()


endfunction()

find_cudnn_library(cudnn)

include (FindPackageHandleStandardArgs)
find_package_handle_standard_args(
LIBRARY REQUIRED_VARS
CUDNN_INCLUDE_DIR cudnn_LIBRARY
)

if(CUDNN_INCLUDE_DIR AND cudnn_LIBRARY)

message(STATUS "cuDNN: ${cudnn_LIBRARY}")
message(STATUS "cuDNN: ${CUDNN_INCLUDE_DIR}")

set(CUDNN_FOUND ON CACHE INTERNAL "cuDNN Library Found")

else()

set(CUDNN_FOUND OFF CACHE INTERNAL "cuDNN Library Not Found")

endif()

target_include_directories(
CUDNN::cudnn_all
INTERFACE
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CUDNN_INCLUDE_DIR}>
)

target_link_libraries(
CUDNN::cudnn_all
INTERFACE
CUDNN::cudnn
)

if(CUDNN_MAJOR_VERSION EQUAL 8)
find_cudnn_library(cudnn_adv_infer)
find_cudnn_library(cudnn_adv_train)
find_cudnn_library(cudnn_cnn_infer)
find_cudnn_library(cudnn_cnn_train)
find_cudnn_library(cudnn_ops_infer)
find_cudnn_library(cudnn_ops_train)

target_link_libraries(
CUDNN::cudnn_all
INTERFACE
CUDNN::cudnn_adv_train
CUDNN::cudnn_ops_train
CUDNN::cudnn_cnn_train
CUDNN::cudnn_adv_infer
CUDNN::cudnn_cnn_infer
CUDNN::cudnn_ops_infer
)
elseif(CUDNN_MAJOR_VERSION EQUAL 9)
find_cudnn_library(cudnn_cnn)
find_cudnn_library(cudnn_adv)
find_cudnn_library(cudnn_graph)
find_cudnn_library(cudnn_ops)
find_cudnn_library(cudnn_engines_runtime_compiled)
find_cudnn_library(cudnn_engines_precompiled)
find_cudnn_library(cudnn_heuristic)

target_link_libraries(
CUDNN::cudnn_all
INTERFACE
CUDNN::cudnn_adv
CUDNN::cudnn_ops
CUDNN::cudnn_cnn
CUDNN::cudnn_graph
CUDNN::cudnn_engines_runtime_compiled
CUDNN::cudnn_engines_precompiled
CUDNN::cudnn_heuristic
)
endif()
6 changes: 1 addition & 5 deletions ports/onnxruntime/fix-cmake-cuda.patch
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,14 @@ diff --git a/cmake/onnxruntime_providers_cuda.cmake b/cmake/onnxruntime_provider
index 1346a9c..fd60dd8 100644
--- a/cmake/onnxruntime_providers_cuda.cmake
+++ b/cmake/onnxruntime_providers_cuda.cmake
@@ -211,8 +211,12 @@
@@ -211,8 +211,8 @@
target_link_libraries(${target} PRIVATE CUDA::cuda_driver)
endif()

- include(cutlass)
- target_include_directories(${target} PRIVATE ${cutlass_SOURCE_DIR}/include ${cutlass_SOURCE_DIR}/examples ${cutlass_SOURCE_DIR}/tools/util/include)
+ find_package(NvidiaCutlass REQUIRED)
+ target_link_libraries(${target} PRIVATE nvidia::cutlass::cutlass)
+ if(MSVC)
+ # CUTLASS_CONSTEXPR_IF_CXX17 must be constexpr. Correct the __cplusplus value with MSVC
+ target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler /Zc:__cplusplus>)
+ endif()

target_include_directories(${target} PRIVATE ${ONNXRUNTIME_ROOT} ${CMAKE_CURRENT_BINARY_DIR} ${eigen_INCLUDE_DIRS} ${TVM_INCLUDES}
PUBLIC ${CUDAToolkit_INCLUDE_DIRS})
38 changes: 27 additions & 11 deletions ports/onnxruntime/fix-cmake.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index 8edbb6ad6f..4987d5af5a 100644
index 78c7bd1..19aefbd 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -38,6 +38,8 @@ include(CheckLanguage)
Expand All @@ -11,11 +11,31 @@ index 8edbb6ad6f..4987d5af5a 100644

# TODO: update this once all system adapt c++20
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
@@ -1430,13 +1432,13 @@ endif()
set(ORT_BUILD_INFO "ORT Build Info: ")
find_package(Git)
if (Git_FOUND)
- execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%h
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- OUTPUT_VARIABLE ORT_GIT_COMMIT)
+ # execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%h
+ # WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ # OUTPUT_VARIABLE ORT_GIT_COMMIT)
string(STRIP "${ORT_GIT_COMMIT}" ORT_GIT_COMMIT)
- execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- OUTPUT_VARIABLE ORT_GIT_BRANCH)
+ # execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
+ # WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ # OUTPUT_VARIABLE ORT_GIT_BRANCH)
string(STRIP "${ORT_GIT_BRANCH}" ORT_GIT_BRANCH)
string(APPEND ORT_BUILD_INFO "git-branch=${ORT_GIT_BRANCH}, git-commit-id=${ORT_GIT_COMMIT}, ")
endif()
diff --git a/cmake/onnxruntime.cmake b/cmake/onnxruntime.cmake
index e15c8a046d..d3a2e64bb9 100644
index 927b4ac..7e992fb 100644
--- a/cmake/onnxruntime.cmake
+++ b/cmake/onnxruntime.cmake
@@ -308,6 +308,9 @@ if(onnxruntime_BUILD_APPLE_FRAMEWORK)
@@ -332,6 +332,9 @@ if(onnxruntime_BUILD_APPLE_FRAMEWORK)
# If it's an onnxruntime library, extract .o files from the original cmake build path to a separate directory for
# each library to avoid any clashes with filenames (e.g. utils.o)
foreach(_LIB ${onnxruntime_INTERNAL_LIBRARIES} )
Expand All @@ -25,7 +45,7 @@ index e15c8a046d..d3a2e64bb9 100644
GET_TARGET_PROPERTY(_LIB_TYPE ${_LIB} TYPE)
if(_LIB_TYPE STREQUAL "STATIC_LIBRARY")
set(CUR_STATIC_LIB_OBJ_DIR ${STATIC_LIB_TEMP_DIR}/$<TARGET_LINKER_FILE_BASE_NAME:${_LIB}>)
@@ -338,6 +341,9 @@ if(onnxruntime_BUILD_APPLE_FRAMEWORK)
@@ -362,6 +365,9 @@ if(onnxruntime_BUILD_APPLE_FRAMEWORK)

# for external libraries we create a symlink to the .a file
foreach(_LIB ${onnxruntime_EXTERNAL_LIBRARIES})
Expand All @@ -36,10 +56,10 @@ index e15c8a046d..d3a2e64bb9 100644
if(_LIB_TYPE STREQUAL "STATIC_LIBRARY")
add_custom_command(TARGET onnxruntime POST_BUILD
diff --git a/cmake/onnxruntime_unittests.cmake b/cmake/onnxruntime_unittests.cmake
index 66df115..bd313d8 100644
index 0c1e5e9..2418f9d 100644
--- a/cmake/onnxruntime_unittests.cmake
+++ b/cmake/onnxruntime_unittests.cmake
@@ -867,6 +867,9 @@ AddTest(
@@ -874,6 +874,9 @@ AddTest(
DEPENDS ${all_dependencies}
TEST_ARGS ${test_all_args}
)
Expand All @@ -49,11 +69,7 @@ index 66df115..bd313d8 100644

if (MSVC)
# The warning means the type of two integral values around a binary operator is narrow than their result.
diff --git a/cmake/onnxruntime_unittests.cmake b/cmake/onnxruntime_unittests.cmake
index 2ae07d5..9ee95a7 100644
--- a/cmake/onnxruntime_unittests.cmake
+++ b/cmake/onnxruntime_unittests.cmake
@@ -962,7 +962,8 @@ target_compile_definitions(onnx_test_data_proto PRIVATE "-DONNX_API=")
@@ -967,7 +970,8 @@ target_compile_definitions(onnx_test_data_proto PRIVATE "-DONNX_API=")
onnxruntime_add_include_to_target(onnx_test_data_proto onnx_proto)
target_include_directories(onnx_test_data_proto PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
set_target_properties(onnx_test_data_proto PROPERTIES FOLDER "ONNXRuntimeTest")
Expand Down
24 changes: 8 additions & 16 deletions ports/onnxruntime/onnxruntime_external_deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ if (onnxruntime_BUILD_UNIT_TESTS)
if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set(gtest_disable_pthreads ON)
endif()
if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")
set(gtest_disable_pthreads ON CACHE BOOL "gtest_disable_pthreads" FORCE)
endif()
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
if (IOS OR ANDROID)
# on mobile platforms the absl flags class dumps the flag names (assumably for binary size), which breaks passing
Expand Down Expand Up @@ -109,7 +106,6 @@ if (NOT WIN32)
endif()
if (google_nsync_SOURCE_DIR AND NOT TARGET nsync::nsync_cpp)
add_library(nsync::nsync_cpp ALIAS nsync_cpp)
message(STATUS "Aliasing nsync_cpp to nsync::nsync_cpp")
target_include_directories(nsync_cpp PUBLIC ${google_nsync_SOURCE_DIR}/public)
endif()
if(TARGET unofficial::nsync::nsync_cpp AND NOT TARGET nsync::nsync_cpp)
Expand Down Expand Up @@ -553,8 +549,8 @@ if(TARGET ONNX::onnx_proto AND NOT TARGET onnx_proto)
add_library(onnx_proto ALIAS ONNX::onnx_proto)
endif()

if(onnxruntime_USE_VCPKG)
find_package(Eigen3 CONFIG REQUIRED)
find_package(Eigen3 CONFIG)
if(Eigen3_FOUND)
get_target_property(eigen_INCLUDE_DIRS Eigen3::Eigen INTERFACE_INCLUDE_DIRECTORIES)
else()
include(eigen) # FetchContent
Expand Down Expand Up @@ -646,20 +642,16 @@ endif()

message(STATUS "Finished fetching external dependencies")


set(onnxruntime_LINK_DIRS )

if (onnxruntime_USE_CUDA)
#TODO: combine onnxruntime_CUDNN_HOME and onnxruntime_CUDA_HOME, assume they are the same
find_package(CUDAToolkit REQUIRED)
if (WIN32)
if(onnxruntime_CUDNN_HOME)
list(APPEND onnxruntime_LINK_DIRS ${onnxruntime_CUDNN_HOME}/lib ${onnxruntime_CUDNN_HOME}/lib/x64)
endif()
else()
if(onnxruntime_CUDNN_HOME)
list(APPEND onnxruntime_LINK_DIRS ${onnxruntime_CUDNN_HOME}/lib ${onnxruntime_CUDNN_HOME}/lib64)
endif()

if(onnxruntime_CUDNN_HOME)
file(TO_CMAKE_PATH ${onnxruntime_CUDNN_HOME} onnxruntime_CUDNN_HOME)
set(CUDNN_PATH ${onnxruntime_CUDNN_HOME})
endif()
include(cuDNN)
endif()

if(onnxruntime_USE_SNPE)
Expand Down
17 changes: 8 additions & 9 deletions ports/onnxruntime/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" BUILD_SHARED)
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO microsoft/onnxruntime
REF v1.18.1
SHA512 192cb95e131d7a7796f29556355d0c9055c05723e1120e21155ed21e05301d862f2ba3fd613d8f9289b61577f64cc4b406db7bb25d1bd666b75c29a0f29cc9d8
REF "v${VERSION}"
SHA512 da0cd297ffc11e2f627a91e55476952b2511e36bf97fb0d9a0a8b1e2cbd12a451e1a8ead1581bfe03d08c97946f0938434edd4637cbeb28f7007533d4b37ee55
PATCHES
fix-cmake.patch
fix-cmake-cuda.patch
Expand All @@ -14,8 +14,8 @@ vcpkg_from_github(
fix-sources.patch
fix-clang-cl-simd-compile.patch
)
# https://github.com/microsoft/onnxruntime/pull/21348
file(COPY "${CMAKE_CURRENT_LIST_DIR}/onnxruntime_external_deps.cmake" DESTINATION "${SOURCE_PATH}/cmake/external")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/cuDNN.cmake" DESTINATION "${SOURCE_PATH}/cmake/external")

find_program(PROTOC NAMES protoc
PATHS "${CURRENT_HOST_INSTALLED_DIR}/tools/protobuf"
Expand Down Expand Up @@ -43,7 +43,6 @@ vcpkg_execute_required_process(
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
python onnxruntime_ENABLE_PYTHON
python onnxruntime_ENABLE_LANGUAGE_INTEROP_OPS
training onnxruntime_ENABLE_TRAINING
training onnxruntime_ENABLE_TRAINING_APIS
# training onnxruntime_ENABLE_TRAINING_OPS
Expand Down Expand Up @@ -106,9 +105,9 @@ vcpkg_cmake_configure(
${GENERATOR_OPTIONS}
OPTIONS
${FEATURE_OPTIONS}
-DPython_EXECUTABLE:FILEPATH=${PYTHON3}
-DProtobuf_PROTOC_EXECUTABLE:FILEPATH=${PROTOC}
-DONNX_CUSTOM_PROTOC_EXECUTABLE:FILEPATH=${PROTOC}
"-DPython_EXECUTABLE:FILEPATH=${PYTHON3}"
"-DProtobuf_PROTOC_EXECUTABLE:FILEPATH=${PROTOC}"
"-DONNX_CUSTOM_PROTOC_EXECUTABLE:FILEPATH=${PROTOC}"
-DBUILD_PKGCONFIG_FILES=ON
-Donnxruntime_BUILD_SHARED_LIB=${BUILD_SHARED}
-Donnxruntime_BUILD_WEBASSEMBLY=OFF
Expand All @@ -129,8 +128,8 @@ vcpkg_cmake_configure(
-Donnxruntime_USE_NEURAL_SPEED=OFF
-DUSE_NEURAL_SPEED=OFF
# for ORT_BUILD_INFO
-DORT_GIT_COMMIT:STRING=387127404e6c1d84b3468c387d864877ed1c67fe
-DORT_GIT_BRANCH:STRING=v1.18.1
"-DORT_GIT_COMMIT:STRING=26250ae74d2c9a3c6860625ba4a147ddfb936907"
"-DORT_GIT_BRANCH:STRING=v${VERSION}"
--compile-no-warning-as-error
OPTIONS_DEBUG
-Donnxruntime_ENABLE_MEMLEAK_CHECKER=OFF
Expand Down
3 changes: 1 addition & 2 deletions ports/onnxruntime/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "onnxruntime",
"version-semver": "1.18.1",
"port-version": 2,
"version-semver": "1.19.0",
"description": "ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator",
"homepage": "https://onnxruntime.ai/",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@
"port-version": 1
},
"onnxruntime": {
"baseline": "1.18.1",
"port-version": 1
"baseline": "1.19.0",
"port-version": 0
},
"opencl": {
"baseline": "v2024.05.08",
Expand Down
5 changes: 5 additions & 0 deletions versions/o-/onnxruntime.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "af74437fc8574baf7c2f36f729493f7be3059d5a",
"version-semver": "1.19.0",
"port-version": 0
},
{
"git-tree": "8641a25170bba46fe4fc7c1cc873efa444ce5d04",
"version-semver": "1.18.1",
Expand Down
Loading