Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit de398c4

Browse files
authored
Integration with ONNX==1.20.1 (#26579)
### Description <!-- Describe your changes. --> NOTE: Need #26597 ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. -->
1 parent addc812 commit de398c4

50 files changed

Lines changed: 963 additions & 553 deletions

File tree

Some content is hidden

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

cmake/deps.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ microsoft_gsl;https://github.com/microsoft/GSL/archive/refs/tags/v4.0.0.zip;cf36
3434
microsoft_wil;https://github.com/microsoft/wil/archive/refs/tags/v1.0.250325.1.zip;826c8bd47c2258ec61b8b218e031e5b33d27f761
3535
mimalloc;https://github.com/microsoft/mimalloc/archive/refs/tags/v2.1.1.zip;d5ee7d34223d0567892db5179849939c8769dc41
3636
mp11;https://github.com/boostorg/mp11/archive/refs/tags/boost-1.82.0.zip;9bc9e01dffb64d9e0773b2e44d2f22c51aace063
37-
onnx;https://github.com/onnx/onnx/archive/refs/tags/v1.19.1.zip;c5215b5697dcdfd71799f001b8c4054a6bba6b09
37+
onnx;https://github.com/onnx/onnx/archive/refs/tags/v1.20.1.zip;30b80c81a1a381188896e86abe460c3c3f3091fd
3838
# Use the latest commit of 10.9-GA
3939
onnx_tensorrt;https://github.com/onnx/onnx-tensorrt/archive/d5dce67db7c2e64b07e055571f5ec06f7f254de2.zip;01114d3b67650857281fa50faa2e412130a63b69
4040
protobuf;https://github.com/protocolbuffers/protobuf/archive/refs/tags/v21.12.zip;7cf2733949036c7d52fda017badcab093fe73bfa

cmake/external/onnx

Submodule onnx updated 852 files

cmake/onnxruntime_unittests.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ onnxruntime_add_static_library(onnx_test_data_proto ${TEST_SRC_DIR}/proto/tml.pr
11281128
add_dependencies(onnx_test_data_proto onnx_proto ${onnxruntime_EXTERNAL_DEPENDENCIES})
11291129
#onnx_proto target should mark this definition as public, instead of private
11301130
target_compile_definitions(onnx_test_data_proto PRIVATE "-DONNX_API=")
1131-
onnxruntime_add_include_to_target(onnx_test_data_proto onnx_proto)
1131+
onnxruntime_add_include_to_target(onnx_test_data_proto onnx_proto ${PROTOBUF_LIB})
11321132
if (MSVC)
11331133
# Cutlass code has an issue with the following:
11341134
# warning C4100: 'magic': unreferenced formal parameter

cmake/patches/onnx/onnx.patch

Lines changed: 33 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
diff --git a/CMakeLists.txt b/CMakeLists.txt
2-
index cc3ef140..f70312ba 100644
2+
index 584c0419a..5d4ffff99 100644
33
--- a/CMakeLists.txt
44
+++ b/CMakeLists.txt
5-
@@ -57,6 +57,7 @@ option(ONNX_USE_LITE_PROTO "Use lite protobuf instead of full." OFF)
5+
@@ -52,6 +52,7 @@ option(ONNX_USE_LITE_PROTO "Use lite protobuf instead of full." OFF)
66
option(ONNX_DISABLE_EXCEPTIONS "Disable exception handling." OFF)
77
option(ONNX_DISABLE_STATIC_REGISTRATION "Disable static registration for ONNX operator schemas." OFF)
88
option(ONNX_USE_UNITY_BUILD "Enable Unity (Jumbo) build for" OFF)
99
+option(ONNX_MINIMAL_BUILD "Build only essential ONNX components" OFF)
1010
if(WIN32)
1111
option(ONNX_USE_MSVC_STATIC_RUNTIME "Build with MSVC static runtime" OFF)
1212
endif()
13-
@@ -409,14 +410,28 @@ relative_protobuf_generate_cpp(ONNX_PROTO_SRCS
14-
15-
add_library(onnx_proto ${ONNX_PROTO_SRCS})
13+
@@ -397,14 +398,28 @@ relative_protobuf_generate_cpp(ONNX_PROTO_SRCS
14+
onnx/onnx-operators.in.proto
15+
onnx/onnx-data.in.proto)
1616

1717
-file(GLOB_RECURSE __tmp_srcs "${ONNX_ROOT}/onnx/*.h" "${ONNX_ROOT}/onnx/*.cc")
1818
-file(GLOB_RECURSE onnx_gtests_src "${ONNX_ROOT}/onnx/test/cpp/*.h"
1919
- "${ONNX_ROOT}/onnx/test/cpp/*.cc"
2020
- "${ONNX_ROOT}/onnx/backend/test/cpp/*.cc"
2121
- "${ONNX_ROOT}/onnx/backend/test/cpp/*.h")
2222
-list(REMOVE_ITEM __tmp_srcs "${ONNX_ROOT}/onnx/cpp2py_export.cc")
23-
-list(REMOVE_ITEM __tmp_srcs ${onnx_gtests_src})
23+
-list(REMOVE_ITEM __tmp_srcs ${onnx_gtests_src} "${ONNX_ROOT}/onnx/test/cmake/main.cc")
2424
-list(APPEND ONNX_SRCS ${__tmp_srcs})
2525
+if(ONNX_MINIMAL_BUILD)
2626
+ message(STATUS "Configuring ONNX minimal build")
@@ -41,54 +41,44 @@ index cc3ef140..f70312ba 100644
4141
+ "${ONNX_ROOT}/onnx/backend/test/cpp/*.cc"
4242
+ "${ONNX_ROOT}/onnx/backend/test/cpp/*.h")
4343
+ list(REMOVE_ITEM __tmp_srcs "${ONNX_ROOT}/onnx/cpp2py_export.cc")
44-
+ list(REMOVE_ITEM __tmp_srcs ${onnx_gtests_src})
44+
+ list(REMOVE_ITEM __tmp_srcs ${onnx_gtests_src} "${ONNX_ROOT}/onnx/test/cmake/main.cc")
4545
+ list(APPEND ONNX_SRCS ${__tmp_srcs})
4646
+endif()
4747

48-
# Hide all symbols we don't need
49-
set_target_properties(onnx_proto PROPERTIES CXX_VISIBILITY_PRESET hidden)
50-
@@ -438,19 +453,6 @@ add_onnx_global_defines(onnx_proto)
51-
target_include_directories(onnx_proto PUBLIC
52-
$<BUILD_INTERFACE:${ONNX_ROOT}>
53-
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
54-
-if(MSVC)
55-
- # For disabling Protobuf related warnings
56-
- target_compile_options(onnx_proto PUBLIC
57-
- /wd4146 # unary minus operator applied to unsigned type,
58-
- # result still unsigned
59-
- /wd4244 # 'argument': conversion from 'google::
60-
- # protobuf::uint64' to 'int', possible
61-
- # loss of data
62-
- /wd4267 # Conversion from 'size_t' to 'int',
63-
- # possible loss of data
64-
- /wd4141 # 'inline': used more than once
65-
- )
66-
-endif()
48+
set(LINKED_PROTOBUF_TARGET protobuf::libprotobuf)
49+
if(ONNX_USE_LITE_PROTO)
50+
diff --git a/cmake/Utils.cmake b/cmake/Utils.cmake
51+
index 07f2b9071..388d9f7a3 100644
52+
--- a/cmake/Utils.cmake
53+
+++ b/cmake/Utils.cmake
54+
@@ -31,18 +31,7 @@ endfunction()
6755

68-
if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
69-
# whole-archive linker option not available on AIX.
56+
function(add_onnx_compile_options target)
57+
if(MSVC)
58+
- # For disabling Protobuf related warnings
59+
- set(protobuf_warnings
60+
- /wd4146 # unary minus operator applied to unsigned type, result still
61+
- # unsigned
62+
- /wd4244 # 'argument': conversion from 'google::protobuf::uint64' to
63+
- # 'int', possible loss of data
64+
- /wd4267 # Conversion from 'size_t' to 'int', possible loss of data
65+
- /wd4141 # 'inline': used more than once
66+
- /wd4047 # '=': 'uintptr_t' differs in levels of indirection from 'void *'
67+
- )
68+
add_msvc_runtime_flag(${target})
69+
- target_compile_options(${target} PUBLIC ${protobuf_warnings})
70+
if(ONNX_WERROR)
71+
target_compile_options(${target} PRIVATE "/WX")
72+
endif()
7073
diff --git a/onnx/defs/nn/old.cc b/onnx/defs/nn/old.cc
71-
index ad6dd0c1..50259f32 100644
74+
index 887151217..ac2e8c463 100644
7275
--- a/onnx/defs/nn/old.cc
7376
+++ b/onnx/defs/nn/old.cc
74-
@@ -4091,7 +4091,6 @@ ONNX_OPERATOR_SET_SCHEMA(
77+
@@ -4152,7 +4152,6 @@ ONNX_OPERATOR_SET_SCHEMA(
7578
GroupNormalization,
7679
18,
7780
OpSchema()
7881
- .Deprecate()
7982
.SetDoc(GroupNormalization_ver18_doc)
8083
.Attr("epsilon", "The epsilon value to use to avoid division by zero.", AttributeProto::FLOAT, 1e-5f)
8184
.Attr(
82-
diff --git a/onnx/defs/schema.h b/onnx/defs/schema.h
83-
index 7e9bc27f..4b87c5a5 100644
84-
--- a/onnx/defs/schema.h
85-
+++ b/onnx/defs/schema.h
86-
@@ -999,7 +999,7 @@ class OpSchemaRegistry final : public ISchemaRegistry {
87-
class OpSchemaRegisterOnce final {
88-
public:
89-
// Export to cpp custom register macro
90-
- explicit OpSchemaRegisterOnce(
91-
+ OpSchemaRegisterOnce(
92-
OpSchema op_schema,
93-
int opset_version_to_load = 0,
94-
bool fail_duplicate_schema = true) {
Lines changed: 33 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
diff --git a/CMakeLists.txt b/CMakeLists.txt
2-
index cc3ef140..f70312ba 100644
2+
index 584c0419a..5d4ffff99 100644
33
--- a/CMakeLists.txt
44
+++ b/CMakeLists.txt
5-
@@ -57,6 +57,7 @@ option(ONNX_USE_LITE_PROTO "Use lite protobuf instead of full." OFF)
5+
@@ -52,6 +52,7 @@ option(ONNX_USE_LITE_PROTO "Use lite protobuf instead of full." OFF)
66
option(ONNX_DISABLE_EXCEPTIONS "Disable exception handling." OFF)
77
option(ONNX_DISABLE_STATIC_REGISTRATION "Disable static registration for ONNX operator schemas." OFF)
88
option(ONNX_USE_UNITY_BUILD "Enable Unity (Jumbo) build for" OFF)
99
+option(ONNX_MINIMAL_BUILD "Build only essential ONNX components" OFF)
1010
if(WIN32)
1111
option(ONNX_USE_MSVC_STATIC_RUNTIME "Build with MSVC static runtime" OFF)
1212
endif()
13-
@@ -409,14 +410,28 @@ relative_protobuf_generate_cpp(ONNX_PROTO_SRCS
14-
15-
add_library(onnx_proto ${ONNX_PROTO_SRCS})
13+
@@ -397,14 +398,28 @@ relative_protobuf_generate_cpp(ONNX_PROTO_SRCS
14+
onnx/onnx-operators.in.proto
15+
onnx/onnx-data.in.proto)
1616

1717
-file(GLOB_RECURSE __tmp_srcs "${ONNX_ROOT}/onnx/*.h" "${ONNX_ROOT}/onnx/*.cc")
1818
-file(GLOB_RECURSE onnx_gtests_src "${ONNX_ROOT}/onnx/test/cpp/*.h"
1919
- "${ONNX_ROOT}/onnx/test/cpp/*.cc"
2020
- "${ONNX_ROOT}/onnx/backend/test/cpp/*.cc"
2121
- "${ONNX_ROOT}/onnx/backend/test/cpp/*.h")
2222
-list(REMOVE_ITEM __tmp_srcs "${ONNX_ROOT}/onnx/cpp2py_export.cc")
23-
-list(REMOVE_ITEM __tmp_srcs ${onnx_gtests_src})
23+
-list(REMOVE_ITEM __tmp_srcs ${onnx_gtests_src} "${ONNX_ROOT}/onnx/test/cmake/main.cc")
2424
-list(APPEND ONNX_SRCS ${__tmp_srcs})
2525
+if(ONNX_MINIMAL_BUILD)
2626
+ message(STATUS "Configuring ONNX minimal build")
@@ -41,54 +41,44 @@ index cc3ef140..f70312ba 100644
4141
+ "${ONNX_ROOT}/onnx/backend/test/cpp/*.cc"
4242
+ "${ONNX_ROOT}/onnx/backend/test/cpp/*.h")
4343
+ list(REMOVE_ITEM __tmp_srcs "${ONNX_ROOT}/onnx/cpp2py_export.cc")
44-
+ list(REMOVE_ITEM __tmp_srcs ${onnx_gtests_src})
44+
+ list(REMOVE_ITEM __tmp_srcs ${onnx_gtests_src} "${ONNX_ROOT}/onnx/test/cmake/main.cc")
4545
+ list(APPEND ONNX_SRCS ${__tmp_srcs})
4646
+endif()
4747

48-
# Hide all symbols we don't need
49-
set_target_properties(onnx_proto PROPERTIES CXX_VISIBILITY_PRESET hidden)
50-
@@ -438,19 +453,6 @@ add_onnx_global_defines(onnx_proto)
51-
target_include_directories(onnx_proto PUBLIC
52-
$<BUILD_INTERFACE:${ONNX_ROOT}>
53-
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
54-
-if(MSVC)
55-
- # For disabling Protobuf related warnings
56-
- target_compile_options(onnx_proto PUBLIC
57-
- /wd4146 # unary minus operator applied to unsigned type,
58-
- # result still unsigned
59-
- /wd4244 # 'argument': conversion from 'google::
60-
- # protobuf::uint64' to 'int', possible
61-
- # loss of data
62-
- /wd4267 # Conversion from 'size_t' to 'int',
63-
- # possible loss of data
64-
- /wd4141 # 'inline': used more than once
65-
- )
66-
-endif()
48+
set(LINKED_PROTOBUF_TARGET protobuf::libprotobuf)
49+
if(ONNX_USE_LITE_PROTO)
50+
diff --git a/cmake/Utils.cmake b/cmake/Utils.cmake
51+
index 07f2b9071..388d9f7a3 100644
52+
--- a/cmake/Utils.cmake
53+
+++ b/cmake/Utils.cmake
54+
@@ -31,18 +31,7 @@ endfunction()
6755

68-
if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
69-
# whole-archive linker option not available on AIX.
56+
function(add_onnx_compile_options target)
57+
if(MSVC)
58+
- # For disabling Protobuf related warnings
59+
- set(protobuf_warnings
60+
- /wd4146 # unary minus operator applied to unsigned type, result still
61+
- # unsigned
62+
- /wd4244 # 'argument': conversion from 'google::protobuf::uint64' to
63+
- # 'int', possible loss of data
64+
- /wd4267 # Conversion from 'size_t' to 'int', possible loss of data
65+
- /wd4141 # 'inline': used more than once
66+
- /wd4047 # '=': 'uintptr_t' differs in levels of indirection from 'void *'
67+
- )
68+
add_msvc_runtime_flag(${target})
69+
- target_compile_options(${target} PUBLIC ${protobuf_warnings})
70+
if(ONNX_WERROR)
71+
target_compile_options(${target} PRIVATE "/WX")
72+
endif()
7073
diff --git a/onnx/defs/nn/old.cc b/onnx/defs/nn/old.cc
71-
index ad6dd0c1..50259f32 100644
74+
index 887151217..ac2e8c463 100644
7275
--- a/onnx/defs/nn/old.cc
7376
+++ b/onnx/defs/nn/old.cc
74-
@@ -4091,7 +4091,6 @@ ONNX_OPERATOR_SET_SCHEMA(
77+
@@ -4152,7 +4152,6 @@ ONNX_OPERATOR_SET_SCHEMA(
7578
GroupNormalization,
7679
18,
7780
OpSchema()
7881
- .Deprecate()
7982
.SetDoc(GroupNormalization_ver18_doc)
8083
.Attr("epsilon", "The epsilon value to use to avoid division by zero.", AttributeProto::FLOAT, 1e-5f)
8184
.Attr(
82-
diff --git a/onnx/defs/schema.h b/onnx/defs/schema.h
83-
index 7e9bc27f..4b87c5a5 100644
84-
--- a/onnx/defs/schema.h
85-
+++ b/onnx/defs/schema.h
86-
@@ -999,7 +999,7 @@ class OpSchemaRegistry final : public ISchemaRegistry {
87-
class OpSchemaRegisterOnce final {
88-
public:
89-
// Export to cpp custom register macro
90-
- explicit OpSchemaRegisterOnce(
91-
+ OpSchemaRegisterOnce(
92-
OpSchema op_schema,
93-
int opset_version_to_load = 0,
94-
bool fail_duplicate_schema = true) {

cmake/vcpkg-ports/onnx/fix-dependency-protobuf.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/CMakeLists.txt b/CMakeLists.txt
2-
index 47995579..1542b11f 100644
2+
index 4a7df7d71..257d77e61 100644
33
--- a/CMakeLists.txt
44
+++ b/CMakeLists.txt
5-
@@ -169,6 +169,7 @@ if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
5+
@@ -159,6 +159,7 @@ if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
66
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
77
endif()
88

@@ -11,14 +11,14 @@ index 47995579..1542b11f 100644
1111
if(NOT ONNX_BUILD_CUSTOM_PROTOBUF)
1212
if((ONNX_USE_LITE_PROTO AND TARGET protobuf::libprotobuf-lite) OR ((NOT ONNX_USE_LITE_PROTO) AND TARGET protobuf::libprotobuf))
1313
diff --git a/cmake/ONNXConfig.cmake.in b/cmake/ONNXConfig.cmake.in
14-
index a5129bfd..d450b51e 100644
14+
index aa1ef47d9..d450b51e5 100644
1515
--- a/cmake/ONNXConfig.cmake.in
1616
+++ b/cmake/ONNXConfig.cmake.in
1717
@@ -4,9 +4,8 @@
1818
# library version information
1919
set(ONNX_VERSION "@ONNX_VERSION@")
2020

21-
-if((NOT @@ONNX_USE_PROTOBUF_SHARED_LIBS@@) AND @@Build_Protobuf@@)
21+
-if(NOT @ONNX_USE_PROTOBUF_SHARED_LIBS@)
2222
- find_package(Protobuf REQUIRED CONFIG)
2323
-endif()
2424
+include(CMakeFindDependencyMacro)

cmake/vcpkg-ports/onnx/portfile.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ vcpkg_from_github(
44
OUT_SOURCE_PATH SOURCE_PATH
55
REPO onnx/onnx
66
REF "v${VERSION}"
7-
SHA512 cf6ff4c0bb6cc16ce5f4d6267480d35f3c7a5fde94d10e1358928ff6e4ec6d756a7c5d34a500e60bbd8eb1912c8af21aa763719321b330f56a0eb6b9b810ef60
7+
SHA512 4bbc4c09e4bb3eb6049d653ce49200564e8c5dcf1154a30f894f24e15f1986d1f2fe2f4ca32fe383c559e2a0b20681f33d649376bf63e4345df6972a2c78eac8
88
PATCHES
99
fix-cmakelists.patch
1010
fix-dependency-protobuf.patch

cmake/vcpkg-ports/onnx/vcpkg.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "onnx",
3-
"version-semver": "1.19.1",
3+
"version-semver": "1.20.1",
44
"port-version": 1,
55
"description": "Open standard for machine learning interoperability",
66
"homepage": "https://onnx.ai",

docs/How_To_Update_ONNX_Dev_Notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ git add onnx
3434

3535
1. Modify [cmake/vcpkg-ports/onnx/binskim.patch](/cmake/vcpkg-ports/onnx/binskim.patch) to be the same as [cmake/patches/onnx/onnx.patch](/cmake/patches/onnx/onnx.patch).
3636
2. The other patches are required/created by vcpkg repository to build ONNX. We just need to re-run diff to makes sure the patches can be applied in the updated ONNX version.
37+
a. VCPKG relies these patches to build ONNX.
3738
3. Update [cmake/vcpkg-ports/onnx/portfile.cmake](/cmake/vcpkg-ports/onnx/portfile.cmake) with the correct commit id and SHA512. (alternatively, build it with the wrong SHA and ORT should tell you the expected one.)
3839
4. Upload your package: [Follow the instructions](https://microsoft.sharepoint.com/:o:/r/teams/ONNX2/_layouts/15/Doc.aspx?sourcedoc=%7B170774BE-E1C6-4F8B-A3AE-984F211FE410%7D&wd=target(Development.one%7C63D3AB47-51D1-4A62-9965-66882234BD44%2FUpdate%20a%20VCPKG%20package%7CB6AE6A97-94FC-4436-8FC6-08C21AE895DA%2F)&wdpartid=%7BB5CF19CC-40FE-0EC7-32B6-8119B427B32A%7D%7B1%7D&wdsectionfileid=%7B9DD25660-A195-48EA-B9E0-DF8B902AFDD7%7D&ovuser=72f988bf-86f1-41af-91ab-2d7cd011db47%2Ctitaiwang%40microsoft.com&clickparams=eyJBcHBOYW1lIjoiVGVhbXMtRGVza3RvcCIsIkFwcFZlcnNpb24iOiI0OS8yNTA5MTExNjAxNiIsIkhhc0ZlZGVyYXRlZFVzZXIiOmZhbHNlfQ%3D%3D&CID=fb9dcaa1-c0b5-1000-5597-c19e3adf468c&cidOR=SPO)one%7C63d3ab47-51d1-4a62-9965-66882234bd44%2FAdd%20or%20Update%20a%20C%2B%2B%20dependency%7Cb6ae6a97-94fc-4436-8fc6-08c21ae895da%2F%29&wdorigin=NavigationUrl
3940

0 commit comments

Comments
 (0)