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.20.0 #294

Merged
merged 6 commits into from
Nov 17, 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
1 change: 0 additions & 1 deletion .circleci/port-android.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ nsync
ruy
tensorflow-lite
dlpack
onnxruntime
43 changes: 32 additions & 11 deletions ports/onnxruntime/fix-cmake-coreml.patch
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,6 @@ index 0aa25a2..1cb768c 100644
if (IOS AND CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS 13.0)
message(WARNING "CoreML ML Program is not supported on iOS < 13.0. Excluding ML Program support from build.")
set(_enable_ML_PROGRAM OFF)
@@ -29,7 +29,9 @@ if (_enable_ML_PROGRAM)
endif()

# Compile CoreML proto definition to ${CMAKE_CURRENT_BINARY_DIR}/coreml_proto
-set(COREML_PROTO_ROOT ${coremltools_SOURCE_DIR}/mlmodel/format)
+if(NOT DEFINED COREML_PROTO_ROOT)
+ set(COREML_PROTO_ROOT ${coremltools_SOURCE_DIR}/mlmodel/format)
+endif()
file(GLOB coreml_proto_srcs "${COREML_PROTO_ROOT}/*.proto")

onnxruntime_add_static_library(coreml_proto ${coreml_proto_srcs})
@@ -62,7 +64,7 @@ endif()
# Separate source_group for each as the .proto files are in the repo and the .cc/.h files are generated in the build
# output directory.
Expand All @@ -40,3 +29,35 @@ index 0aa25a2..1cb768c 100644
endif()

# Add CoreML objective c++ source code
diff --git a/cmake/external/onnxruntime_external_deps.cmake b/cmake/external/onnxruntime_external_deps.cmake
index 6ab4a84..23495e9 100644
--- a/cmake/external/onnxruntime_external_deps.cmake
+++ b/cmake/external/onnxruntime_external_deps.cmake
@@ -625,6 +625,9 @@ if(onnxruntime_ENABLE_TRAINING OR (onnxruntime_ENABLE_TRAINING_APIS AND onnxrunt
endif()

if (onnxruntime_USE_COREML)
+ if(DEFINED COREML_PROTO_ROOT)
+ message(STATUS "apple/coremltools sources may not used if COREML_PROTO_ROOT contains .proto files")
+ endif()
FetchContent_Declare(
coremltools
URL ${DEP_URL_coremltools}
diff --git a/cmake/onnxruntime_providers_coreml.cmake b/cmake/onnxruntime_providers_coreml.cmake
index e138393..568394b 100644
--- a/cmake/onnxruntime_providers_coreml.cmake
+++ b/cmake/onnxruntime_providers_coreml.cmake
@@ -29,8 +29,12 @@ if (_enable_ML_PROGRAM)
endif()

# Compile CoreML proto definition to ${CMAKE_CURRENT_BINARY_DIR}/coreml_proto
-set(COREML_PROTO_ROOT ${coremltools_SOURCE_DIR}/mlmodel/format)
+if(NOT DEFINED COREML_PROTO_ROOT)
+ set(COREML_PROTO_ROOT ${coremltools_SOURCE_DIR}/mlmodel/format)
+endif()
file(GLOB coreml_proto_srcs "${COREML_PROTO_ROOT}/*.proto")
+list(LENGTH coreml_proto_srcs coreml_proto_srcs_count)
+message(STATUS "Found ${coreml_proto_srcs_count} proto files ${COREML_PROTO_ROOT}")

onnxruntime_add_static_library(coreml_proto ${coreml_proto_srcs})
target_include_directories(coreml_proto
18 changes: 0 additions & 18 deletions ports/onnxruntime/fix-cmake-cuda.patch
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index f829cea..bda2d4c 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -715,6 +715,13 @@ if (onnxruntime_USE_CUDA)
if (onnxruntime_USE_CUDA_NHWC_OPS)
add_compile_definitions(ENABLE_CUDA_NHWC_OPS)
endif()
+ # Give more hints for the generator, with FindCUDAToolkit.cmake
+ find_package(CUDAToolkit REQUIRED)
+ if(CMAKE_GENERATOR MATCHES "Visual Studio")
+ set(CMAKE_VS_PLATFORM_TOOLSET_CUDA "${CUDAToolkit_VERSION_MAJOR}.${CUDAToolkit_VERSION_MINOR}")
+ set(CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR "${CUDAToolkit_TARGET_DIR}/")
+ endif()
+ get_filename_component(CMAKE_CUDA_COMPILER "${CUDAToolkit_NVCC_EXECUTABLE}" ABSOLUTE)
enable_language(CUDA)
message( STATUS "CMAKE_CUDA_COMPILER_VERSION: ${CMAKE_CUDA_COMPILER_VERSION}")

diff --git a/cmake/onnxruntime_providers_cuda.cmake b/cmake/onnxruntime_providers_cuda.cmake
index 1346a9c..fd60dd8 100644
--- a/cmake/onnxruntime_providers_cuda.cmake
Expand Down
111 changes: 26 additions & 85 deletions ports/onnxruntime/fix-cmake.patch
Original file line number Diff line number Diff line change
@@ -1,95 +1,36 @@
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index 78c7bd1..19aefbd 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -38,6 +38,8 @@ include(CheckLanguage)
include(CMakeDependentOption)
include(FetchContent)
include(CheckFunctionExists)
+include(GNUInstallDirs) # onnxruntime_providers_* require CMAKE_INSTALL_* variables
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/external")
diff --git a/cmake/external/onnxruntime_external_deps.cmake b/cmake/external/onnxruntime_external_deps.cmake
index 8574602..6ab4a84 100644
--- a/cmake/external/onnxruntime_external_deps.cmake
+++ b/cmake/external/onnxruntime_external_deps.cmake
@@ -92,15 +92,15 @@ if (NOT WIN32)
URL ${DEP_URL_google_nsync}
URL_HASH SHA1=${DEP_SHA1_google_nsync}
PATCH_COMMAND ${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 < ${PROJECT_SOURCE_DIR}/patches/nsync/nsync_1.26.0.patch
- FIND_PACKAGE_ARGS NAMES nsync unofficial-nsync
+ FIND_PACKAGE_ARGS NAMES nsync_cpp unofficial-nsync
)
#nsync tests failed on Mac Build
set(NSYNC_ENABLE_TESTS OFF CACHE BOOL "" FORCE)
onnxruntime_fetchcontent_makeavailable(google_nsync)

# 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 927b4ac..7e992fb 100644
--- a/cmake/onnxruntime.cmake
+++ b/cmake/onnxruntime.cmake
@@ -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} )
+ if(NOT TARGET ${_LIB}) # if we didn't build from source. it may not a target
+ continue()
+ endif()
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}>)
@@ -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})
+ if(NOT TARGET ${_LIB}) # if we didn't build from source. it may not a target
+ continue()
+ endif()
GET_TARGET_PROPERTY(_LIB_TYPE ${_LIB} TYPE)
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 0c1e5e9..2418f9d 100644
--- a/cmake/onnxruntime_unittests.cmake
+++ b/cmake/onnxruntime_unittests.cmake
@@ -874,6 +874,9 @@ AddTest(
DEPENDS ${all_dependencies}
TEST_ARGS ${test_all_args}
)
+target_include_directories(onnxruntime_test_all PRIVATE
+ ${ONNXRUNTIME_ROOT}/core/flatbuffers/schema # ort.fbs.h
+)

if (MSVC)
# The warning means the type of two integral values around a binary operator is narrow than their result.
@@ -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")
-onnxruntime_protobuf_generate(APPEND_PATH IMPORT_DIRS ${onnx_SOURCE_DIR} TARGET onnx_test_data_proto)
+find_path(ONNX_IMPORT_DIR NAMES onnx/onnx-ml.proto REQUIRED)
+onnxruntime_protobuf_generate(APPEND_PATH IMPORT_DIRS ${ONNX_IMPORT_DIR} TARGET onnx_test_data_proto)

#
# onnxruntime_ir_graph test data
- if (google_nsync_SOURCE_DIR)
+ if (TARGET nsync_cpp AND NOT TARGET nsync::nsync_cpp)
add_library(nsync::nsync_cpp ALIAS nsync_cpp)
- target_include_directories(nsync_cpp PUBLIC ${google_nsync_SOURCE_DIR}/public)
+ message(STATUS "Aliasing nsync_cpp to nsync::nsync_cpp")
endif()
if(TARGET unofficial::nsync::nsync_cpp AND NOT TARGET nsync::nsync_cpp)
message(STATUS "Aliasing unofficial::nsync::nsync_cpp to nsync::nsync_cpp")
diff --git a/cmake/onnxruntime_mlas.cmake b/cmake/onnxruntime_mlas.cmake
index d888f80..b6b12c5 100644
index 0ba4694..32ce5fd 100644
--- a/cmake/onnxruntime_mlas.cmake
+++ b/cmake/onnxruntime_mlas.cmake
@@ -725,8 +725,7 @@ block()
@@ -725,7 +725,7 @@ block()
endblock()


-if (NOT onnxruntime_ORT_MINIMAL_BUILD)
-
+if (NOT onnxruntime_ORT_MINIMAL_BUILD AND NOT (CMAKE_SYSTEM_NAME STREQUAL "iOS"))
+if (FALSE)
#
# Command line tool for quantization and de-quantization of 2-D fp32 tensors
# based on block-wise quantization of int4
26 changes: 0 additions & 26 deletions ports/onnxruntime/fix-sources.patch

This file was deleted.

Loading
Loading