Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
snnn committed Feb 7, 2025
1 parent 63f5866 commit d3c07d4
Show file tree
Hide file tree
Showing 18 changed files with 64 additions and 384 deletions.
2 changes: 1 addition & 1 deletion cmake/external/abseil-cpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ onnxruntime_fetchcontent_declare(
URL ${DEP_URL_abseil_cpp}
URL_HASH SHA1=${DEP_SHA1_abseil_cpp}
PATCH_COMMAND ${ABSL_PATCH_COMMAND}
FIND_PACKAGE_ARGS 20240722 NAMES absl
FIND_PACKAGE_ARGS 20250127 NAMES absl
EXCLUDE_FROM_ALL
)

Expand Down
10 changes: 5 additions & 5 deletions cmake/external/abseil-cpp.natvis
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="absl::lts_20240722::InlinedVector&lt;*&gt;">
<Type Name="absl::lts_20250127::InlinedVector&lt;*&gt;">
<Intrinsic Name="_size" Expression="storage_.metadata_.value >> 1"/>
<Intrinsic Name="_is_allocated" Expression="(storage_.metadata_.value &amp; 1) == 1"/>
<Intrinsic Name="_inlined_data" Expression="($T1*)storage_.data_.inlined.inlined_data"/>
Expand All @@ -24,7 +24,7 @@
</Expand>
</Type>
<!-- Should handle both flat hash_set and hash_map -->
<Type Name="absl::lts_20240116::container_internal::raw_hash_set&lt;*&gt;">
<Type Name="absl::lts_20250127::container_internal::raw_hash_set&lt;*&gt;">
<Intrinsic Name="_commonfields" Expression="settings_.value"/>
<Intrinsic Name="_size" Expression="settings_.value.compressed_tuple_.value"/>
<Intrinsic Name="_capacity" Expression="_commonfields().capacity_"/>
Expand All @@ -51,7 +51,7 @@
</Type>

<!-- Primitive types stored as a value -->
<Type Name="absl::lts_20240116::container_internal::Storage&lt;*,*,0&gt;">
<Type Name="absl::lts_20250127::container_internal::Storage&lt;*,*,0&gt;">
<DisplayString IncludeView="noparens">*($T1 *){value}</DisplayString>
<DisplayString ExcludeView="noparens">(*($T1 *){value})</DisplayString>
<Expand>
Expand All @@ -60,15 +60,15 @@
</Type>

<!-- For storage inherited from the type -->
<Type Name="absl::lts_20240116::container_internal::Storage&lt;*,*,1&gt;">
<Type Name="absl::lts_20250127::container_internal::Storage&lt;*,*,1&gt;">
<DisplayString IncludeView="noparens">*($T1 *)this</DisplayString>
<DisplayString ExcludeView="noparens">(*($T1 *)this)</DisplayString>
<Expand>
<ExpandedItem>*($T1 *)this</ExpandedItem>
</Expand>
</Type>

<Type Name="absl::lts_20240116::container_internal::map_slot_type&lt;*&gt;">
<Type Name="absl::lts_20250127::container_internal::map_slot_type&lt;*&gt;">
<DisplayString IncludeView="noparens">{value.first}, {value.second}</DisplayString>
<DisplayString ExcludeView="noparens">({value.first}, {value.second})</DisplayString>
<Expand>
Expand Down
25 changes: 3 additions & 22 deletions cmake/onnxruntime_unittests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ if(NOT IOS)
onnxruntime_add_include_to_target(onnx_test_runner_common onnxruntime_common onnxruntime_framework
onnxruntime_test_utils onnx onnx_proto re2::re2 flatbuffers::flatbuffers Boost::mp11 safeint_interface)

add_dependencies(onnx_test_runner_common onnx_test_data_proto ${onnxruntime_EXTERNAL_DEPENDENCIES})
add_dependencies(onnx_test_runner_common ${onnxruntime_EXTERNAL_DEPENDENCIES})
target_include_directories(onnx_test_runner_common PRIVATE ${eigen_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR} ${ONNXRUNTIME_ROOT})

Expand Down Expand Up @@ -906,7 +906,6 @@ AddTest(
SOURCES ${all_tests} ${onnxruntime_unittest_main_src}
LIBS
${onnx_test_runner_common_lib} ${onnxruntime_test_providers_libs} ${onnxruntime_test_common_libs}
onnx_test_data_proto
DEPENDS ${all_dependencies}
TEST_ARGS ${test_all_args}
)
Expand Down Expand Up @@ -1007,23 +1006,6 @@ endif()

set(test_data_target onnxruntime_test_all)

onnxruntime_add_static_library(onnx_test_data_proto ${TEST_SRC_DIR}/proto/tml.proto)
add_dependencies(onnx_test_data_proto onnx_proto ${onnxruntime_EXTERNAL_DEPENDENCIES})
#onnx_proto target should mark this definition as public, instead of private
target_compile_definitions(onnx_test_data_proto PRIVATE "-DONNX_API=")
onnxruntime_add_include_to_target(onnx_test_data_proto onnx_proto)
if (MSVC)
# Cutlass code has an issue with the following:
# warning C4100: 'magic': unreferenced formal parameter
target_compile_options(onnx_test_data_proto PRIVATE "/wd4100")
endif()
target_include_directories(onnx_test_data_proto PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
set_target_properties(onnx_test_data_proto PROPERTIES FOLDER "ONNXRuntimeTest")
if(NOT DEFINED onnx_SOURCE_DIR)
find_path(onnx_SOURCE_DIR NAMES "onnx/onnx-ml.proto3" "onnx/onnx-ml.proto" REQUIRED)
endif()
onnxruntime_protobuf_generate(APPEND_PATH IMPORT_DIRS ${onnx_SOURCE_DIR} TARGET onnx_test_data_proto)

#
# onnxruntime_ir_graph test data
#
Expand Down Expand Up @@ -1101,7 +1083,6 @@ endif()
set(onnx_test_libs
onnxruntime_test_utils
${ONNXRUNTIME_TEST_LIBS}
onnx_test_data_proto
${onnxruntime_EXTERNAL_LIBRARIES})

if (NOT IOS)
Expand Down Expand Up @@ -1258,7 +1239,7 @@ if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
#onnxruntime_common is kind of ok because it is thin, tiny and totally stateless.
set(onnxruntime_perf_test_libs
onnx_test_runner_common onnxruntime_test_utils onnxruntime_common
onnxruntime onnxruntime_flatbuffers onnx_test_data_proto
onnxruntime onnxruntime_flatbuffers
${onnxruntime_EXTERNAL_LIBRARIES}
${GETOPT_LIB_WIDE} ${SYS_PATH_LIB} ${CMAKE_DL_LIBS})
if(NOT WIN32)
Expand Down Expand Up @@ -1308,7 +1289,7 @@ if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
if(WIN32)
target_link_libraries(onnxruntime_qnn_ctx_gen PRIVATE debug dbghelp advapi32)
endif()
target_link_libraries(onnxruntime_qnn_ctx_gen PRIVATE onnx_test_runner_common onnxruntime_test_utils onnxruntime_common onnxruntime_graph onnxruntime_session onnxruntime_providers onnxruntime_framework onnxruntime_util onnxruntime_mlas onnxruntime_optimizer onnxruntime_flatbuffers onnx_test_data_proto ${onnxruntime_test_providers_libs} ${onnxruntime_EXTERNAL_LIBRARIES} ${GETOPT_LIB_WIDE} ${SYS_PATH_LIB} ${CMAKE_DL_LIBS})
target_link_libraries(onnxruntime_qnn_ctx_gen PRIVATE onnx_test_runner_common onnxruntime_test_utils onnxruntime_common onnxruntime_graph onnxruntime_session onnxruntime_providers onnxruntime_framework onnxruntime_util onnxruntime_mlas onnxruntime_optimizer onnxruntime_flatbuffers ${onnxruntime_test_providers_libs} ${onnxruntime_EXTERNAL_LIBRARIES} ${GETOPT_LIB_WIDE} ${SYS_PATH_LIB} ${CMAKE_DL_LIBS})

set_target_properties(onnxruntime_qnn_ctx_gen PROPERTIES FOLDER "ONNXRuntimeTest")
endif()
Expand Down
36 changes: 7 additions & 29 deletions cmake/vcpkg-ports/abseil/absl_windows.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/absl/base/attributes.h b/absl/base/attributes.h
index 5ea5ee3e..f4949898 100644
index ac2ca801..a5fad567 100644
--- a/absl/base/attributes.h
+++ b/absl/base/attributes.h
@@ -559,7 +559,7 @@
@@ -562,7 +562,7 @@
#undef ABSL_ATTRIBUTE_UNUSED
#define ABSL_ATTRIBUTE_UNUSED __attribute__((__unused__))
#else
Expand All @@ -11,28 +11,6 @@ index 5ea5ee3e..f4949898 100644
#endif

// ABSL_ATTRIBUTE_INITIAL_EXEC
diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h
index d4fe8f5c..27418d13 100644
--- a/absl/container/internal/raw_hash_set.h
+++ b/absl/container/internal/raw_hash_set.h
@@ -1924,7 +1924,7 @@ HashtablezInfoHandle SampleHashtablezInfo(size_t sizeof_slot, size_t sizeof_key,
// In SOO, we sample on the first insertion so if this is an empty SOO case
// (e.g. when reserve is called), then we still need to sample.
if (kSooEnabled && was_soo && c.size() == 0) {
- return Sample(sizeof_slot, sizeof_key, sizeof_value, SooCapacity());
+ return Sample(sizeof_slot, sizeof_key, sizeof_value, (int16_t)SooCapacity());
}
// For non-SOO cases, we sample whenever the capacity is increasing from zero
// to non-zero.
@@ -3525,7 +3525,7 @@ class raw_hash_set {
assert(is_soo());
if (!ShouldSampleHashtablezInfo<CharAlloc>()) return HashtablezInfoHandle{};
return Sample(sizeof(slot_type), sizeof(key_type), sizeof(value_type),
- SooCapacity());
+ (int16_t)SooCapacity());
}

inline void destroy_slots() {
diff --git a/absl/copts/GENERATED_AbseilCopts.cmake b/absl/copts/GENERATED_AbseilCopts.cmake
index da2282fe..4c7fc26f 100644
--- a/absl/copts/GENERATED_AbseilCopts.cmake
Expand Down Expand Up @@ -60,7 +38,7 @@ index b9e0071e..dd8410ec 100644
"/wd4800",
"/DNOMINMAX",
diff --git a/absl/copts/copts.py b/absl/copts/copts.py
index 2d85ac74..4875d668 100644
index d1cfe429..3685e023 100644
--- a/absl/copts/copts.py
+++ b/absl/copts/copts.py
@@ -118,10 +118,6 @@ MSVC_WARNING_FLAGS = [
Expand All @@ -75,18 +53,18 @@ index 2d85ac74..4875d668 100644
"/wd4503",
# forcing value to bool 'true' or 'false' (performance warning)
diff --git a/absl/debugging/symbolize.cc b/absl/debugging/symbolize.cc
index 638d3954..6b817075 100644
index 344436f9..d45452f9 100644
--- a/absl/debugging/symbolize.cc
+++ b/absl/debugging/symbolize.cc
@@ -14,7 +14,7 @@
@@ -16,7 +16,7 @@

#include "absl/debugging/symbolize.h"

-#ifdef _WIN32
+#if defined(_WIN32) && !defined(NDEBUG)
#include <winapifamily.h>
#if !(WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)) || \
WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// UWP doesn't have access to win32 APIs.
diff --git a/absl/debugging/symbolize_win32.inc b/absl/debugging/symbolize_win32.inc
index 53a099a1..34d210d6 100644
--- a/absl/debugging/symbolize_win32.inc
Expand Down
2 changes: 1 addition & 1 deletion cmake/vcpkg-ports/abseil/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO abseil/abseil-cpp
REF "${VERSION}"
SHA512 bd2cca8f007f2eee66f51c95a979371622b850ceb2ce3608d00ba826f7c494a1da0fba3c1427728f2c173fe50d59b701da35c2c9fdad2752a5a49746b1c8ef31
SHA512 2a021faad807ee3e23548716ffa4785dc2409edbb4be676cc4bc01d47885760de340f0a4afdcbf0aaa835affd6d78f7bc319bbf7d337dbc30e7a559d0088e4bd
HEAD_REF master
PATCHES absl_windows.patch
)
Expand Down
2 changes: 1 addition & 1 deletion cmake/vcpkg-ports/abseil/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "abseil",
"version": "20240722.0",
"version": "20250127.0",
"description": [
"Abseil is an open-source collection of C++ library code designed to augment the C++ standard library. The Abseil library code is collected from Google's own C++ code base, has been extensively tested and used in production, and is the same code we depend on in our daily coding lives.",
"In some cases, Abseil provides pieces missing from the C++ standard; in others, Abseil provides alternatives to the standard for special needs we've found through usage in the Google code base. We denote those cases clearly within the library code we provide you.",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d15d97ed..a483255f 100644
index d15d97ed..fe4bd27f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -496,6 +496,7 @@ if (MSVC)
endif()
else()
# On non-Windows, hide all symbols we don't need
+ set(EXTRA_FLAGS "-Wno-unused-parameter")
set(ONNX_API_DEFINE "-DONNX_API=__attribute__\(\(__visibility__\(\"default\"\)\)\)")
set_target_properties(onnx_proto PROPERTIES CXX_VISIBILITY_PRESET hidden)
set_target_properties(onnx_proto PROPERTIES VISIBILITY_INLINES_HIDDEN 1)
@@ -631,20 +632,9 @@ endif()
@@ -631,20 +631,9 @@ endif()
if(MSVC)
target_compile_options(onnx_proto
PRIVATE /MP
Expand Down
42 changes: 3 additions & 39 deletions cmake/vcpkg-ports/onnx/fix-cmakelists.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4dd56b6..2ff3e29 100644
index b666eec..66c234d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -65,6 +65,27 @@ endif()
@@ -63,6 +63,16 @@ endif()

include(GNUInstallDirs)

Expand All @@ -15,22 +15,11 @@ index 4dd56b6..2ff3e29 100644
+ ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx-operators-ml.proto3
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnx
+)
+# install python files
+if(BUILD_ONNX_PYTHON)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx_data_pb.py
+ ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx_data_pb2.py
+ ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx_ml_pb2.py
+ ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx_operators_ml_pb2.py
+ ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx_operators_pb.py
+ ${CMAKE_CURRENT_BINARY_DIR}/onnx/onnx_pb.py
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnx
+ )
+endif()
+
set(ONNX_ROOT ${PROJECT_SOURCE_DIR})

# Read ONNX version
@@ -116,7 +137,8 @@ endif()
@@ -104,7 +114,8 @@ endif()
# find_package Python has replaced PythonInterp and PythonLibs since cmake 3.12
# Use the following command in the future; now this is only compatible with the latest pybind11
# find_package(Python ${PY_VERSION} COMPONENTS Interpreter Development REQUIRED)
Expand All @@ -40,28 +29,3 @@ index 4dd56b6..2ff3e29 100644
if(BUILD_ONNX_PYTHON)
find_package(PythonLibs ${PY_VERSION})
endif()
@@ -434,6 +456,7 @@ target_link_libraries(onnx PUBLIC onnx_proto)
add_onnx_global_defines(onnx)

if(BUILD_ONNX_PYTHON)
+ find_package(Python3 ${PY_VERSION} COMPONENTS Development REQUIRED)
if("${PY_EXT_SUFFIX}" STREQUAL "")
if(MSVC)
set(PY_EXT_SUFFIX ".pyd")
@@ -452,10 +475,14 @@ if(BUILD_ONNX_PYTHON)
target_include_directories(onnx_cpp2py_export PRIVATE
$<BUILD_INTERFACE:${ONNX_ROOT}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
- $<INSTALL_INTERFACE:include>)
+ ${Python3_INCLUDE_DIRS})
+ target_link_directories(onnx_cpp2py_export PRIVATE
+ ${Python3_LIBRARY_DIRS})
+ target_link_libraries(onnx_cpp2py_export PRIVATE
+ ${Python3_LIBRARIES})

# pybind11 is a header only lib
- find_package(pybind11 2.2 CONFIG)
+ find_package(pybind11 2.2 CONFIG REQUIRED)
if(NOT pybind11_FOUND)
if(EXISTS "${ONNX_ROOT}/third_party/pybind11/include/pybind11/pybind11.h")
add_subdirectory("${ONNX_ROOT}/third_party/pybind11")
12 changes: 12 additions & 0 deletions cmake/vcpkg-ports/onnx/fix-cxx_standard.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 55869f4..e8b20cb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -524,6 +524,7 @@ else()
set_target_properties(onnx_proto PROPERTIES VISIBILITY_INLINES_HIDDEN 1)
endif()
target_compile_definitions(onnx_proto PRIVATE ${ONNX_API_DEFINE})
+target_compile_features(onnx_proto PUBLIC cxx_std_${CMAKE_CXX_STANDARD})

if(ONNX_USE_LITE_PROTO)
if(TARGET protobuf::libprotobuf-lite)
29 changes: 14 additions & 15 deletions cmake/vcpkg-ports/onnx/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,44 @@ vcpkg_from_github(
PATCHES
fix-cmakelists.patch
fix-dependency-protobuf.patch
other.patch
fix-cxx_standard.patch
binskim.patch
)

string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" USE_STATIC_RUNTIME)

# ONNX_CUSTOM_PROTOC_EXECUTABLE
find_program(PROTOC NAMES protoc PATHS "${CURRENT_HOST_INSTALLED_DIR}/tools/protobuf" REQUIRED NO_DEFAULT_PATH NO_CMAKE_PATH)

# ONNX_USE_PROTOBUF_SHARED_LIBS: find the library and check its file extension
find_library(PROTOBUF_LIBPATH NAMES protobuf PATHS "${CURRENT_INSTALLED_DIR}/bin" "${CURRENT_INSTALLED_DIR}/lib" REQUIRED)
get_filename_component(PROTOBUF_LIBNAME "${PROTOBUF_LIBPATH}" NAME)
if(PROTOBUF_LIBNAME MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}")
set(USE_PROTOBUF_SHARED ON)
else()
set(USE_PROTOBUF_SHARED OFF)
endif()

set(USE_PROTOBUF_SHARED OFF)



# Like protoc, python is required for codegen.
vcpkg_find_acquire_program(PYTHON3)

# PATH for .bat scripts so it can find 'python'
get_filename_component(PYTHON_DIR "${PYTHON3}" PATH)
vcpkg_add_to_path(PREPEND "${PYTHON_DIR}")

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS}
-DPython3_EXECUTABLE=${PYTHON3}
"-DPython3_EXECUTABLE:FILEPATH=${PYTHON3}"
"-DONNX_CUSTOM_PROTOC_EXECUTABLE:FILEPATH=${PROTOC}"
"-DProtobuf_PROTOC_EXECUTABLE:FILEPATH=${PROTOC}"
-DONNX_ML=ON
-DONNX_GEN_PB_TYPE_STUBS=ON
-DONNX_USE_PROTOBUF_SHARED_LIBS=${USE_PROTOBUF_SHARED}
-DONNX_USE_LITE_PROTO=OFF
-DONNX_USE_MSVC_STATIC_RUNTIME=${USE_STATIC_RUNTIME}
-DONNX_BUILD_TESTS=OFF
-DONNX_BUILD_BENCHMARKS=OFF
-DONNX_DISABLE_STATIC_REGISTRATION=ON
MAYBE_UNUSED_VARIABLES
ONNX_USE_MSVC_STATIC_RUNTIME
)

vcpkg_cmake_install()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/ONNX)
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/ONNX PACKAGE_NAME ONNX)

vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")

Expand Down
2 changes: 1 addition & 1 deletion cmake/vcpkg-ports/onnx/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "onnx",
"version-semver": "1.17.0",
"port-version": 1,
"description": "Open standard for machine learning interoperability",
"homepage": "https://onnx.ai",
"license": "Apache-2.0",
"supports": "!uwp",
"dependencies": [
"protobuf",
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ Status EinsumTypedComputeProcessor<T>::Run() {
{
TensorShapeVector reduced_dims;
TensorShapeVector preserved_dims; // dims which were not reduced
TensorShapeVector preserved_shape; // shape pertaining to only the dims that were preserved (not reduced)
reduced_dims.reserve(onnxruntime::narrow<size_t>(num_subscript_labels)); // num_subscript_labels is the upper bound. No harm in over-reserving.
preserved_dims.reserve(onnxruntime::narrow<size_t>(num_subscript_labels)); // num_subscript_labels is the upper bound. No harm in over-reserving.

Expand Down
Loading

0 comments on commit d3c07d4

Please sign in to comment.