From 91bb3e4b89e5447b83a8f2bf07de071174aa4a70 Mon Sep 17 00:00:00 2001 From: Cheney Wang <38240633+Cheney-W@users.noreply.github.com> Date: Thu, 27 Jul 2023 10:51:16 +0800 Subject: [PATCH] [onnx/onnx-optimizer] update to v1.14.0 and 0.3.17 (#32542) --- ports/onnx-optimizer/fix-cmakelists.patch | 131 +++++++++++++--------- ports/onnx-optimizer/portfile.cmake | 10 +- ports/onnx-optimizer/vcpkg.json | 2 +- ports/onnx/portfile.cmake | 2 +- ports/onnx/vcpkg.json | 2 +- ports/openvino/003-fix-find-onnx.patch | 13 +++ ports/openvino/portfile.cmake | 1 + ports/openvino/vcpkg.json | 2 +- versions/baseline.json | 6 +- versions/o-/onnx-optimizer.json | 5 + versions/o-/onnx.json | 5 + versions/o-/openvino.json | 5 + 12 files changed, 117 insertions(+), 67 deletions(-) create mode 100644 ports/openvino/003-fix-find-onnx.patch diff --git a/ports/onnx-optimizer/fix-cmakelists.patch b/ports/onnx-optimizer/fix-cmakelists.patch index 4c54d77e05..1dbc271341 100644 --- a/ports/onnx-optimizer/fix-cmakelists.patch +++ b/ports/onnx-optimizer/fix-cmakelists.patch @@ -1,56 +1,75 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index c2e48b3..5716fbb 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -7,10 +7,18 @@ if(NOT MSVC) - set(CMAKE_CXX_STANDARD 11) - endif(NOT MSVC) - -+# Add MSVC RunTime Flag -+function(add_msvc_runtime_flag lib) -+ if(${ONNX_USE_MSVC_STATIC_RUNTIME}) -+ target_compile_options(${lib} PRIVATE $<$>:/MT> $<$:/MTd>) -+ else() -+ target_compile_options(${lib} PRIVATE $<$>:/MD> $<$:/MDd>) -+ endif() -+endfunction() - set(CMAKE_POSITION_INDEPENDENT_CODE ON) - --set(ONNX_ROOT ${PROJECT_SOURCE_DIR}/third_party/onnx) --add_subdirectory(${ONNX_ROOT}) -+find_package(protobuf CONFIG REQUIRED) -+find_package(ONNX CONFIG REQUIRED) - - file(READ "${PROJECT_SOURCE_DIR}/VERSION_NUMBER" ONNX_OPTIMIZER_VERSION) - string(STRIP "${ONNX_OPTIMIZER_VERSION}" ONNX_OPTIMIZER_VERSION) -@@ -31,6 +39,7 @@ add_executable(onnx_optimizer_exec examples/onnx_optimizer_exec.cpp) - target_link_libraries(onnx_optimizer_exec onnx_optimizer) - - if(BUILD_ONNX_PYTHON) -+ find_package(Python3 COMPONENTS Development REQUIRED) - if("${PY_EXT_SUFFIX}" STREQUAL "") - if(MSVC) - set(PY_EXT_SUFFIX ".pyd") -@@ -51,7 +60,7 @@ if(BUILD_ONNX_PYTHON) - $ - ${PYTHON_INCLUDE_DIR}) - # pybind11 is a header only lib -- find_package(pybind11 2.2) -+ find_package(pybind11 2.2 CONFIG REQUIRED) - if(pybind11_FOUND) - target_include_directories(onnx_opt_cpp2py_export PUBLIC - ${pybind11_INCLUDE_DIRS}) -@@ -87,11 +96,9 @@ if(BUILD_ONNX_PYTHON) - endif() - - target_link_libraries(onnx_opt_cpp2py_export PRIVATE onnx_optimizer) -- -+ target_link_directories(onnx_opt_cpp2py_export PRIVATE ${Python3_LIBRARY_DIRS}) -+ target_link_libraries(onnx_opt_cpp2py_export PRIVATE ${Python3_LIBRARIES}) - if(MSVC) -- find_package(PythonInterp ${PY_VERSION} REQUIRED) -- find_package(PythonLibs ${PY_VERSION} REQUIRED) -- target_link_libraries(onnx_opt_cpp2py_export PRIVATE ${PYTHON_LIBRARIES}) - target_compile_options(onnx_opt_cpp2py_export - PRIVATE /MP - /WX +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 0063385..64458ef 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -10,6 +10,15 @@ project(onnx_optimizer C CXX) + + set(CMAKE_CXX_STANDARD 17) + ++# Add MSVC RunTime Flag ++function(add_msvc_runtime_flag lib) ++ if(${ONNX_USE_MSVC_STATIC_RUNTIME}) ++ target_compile_options(${lib} PRIVATE $<$>:/MT> $<$:/MTd>) ++ else() ++ target_compile_options(${lib} PRIVATE $<$>:/MD> $<$:/MDd>) ++ endif() ++endfunction() ++ + set(CMAKE_POSITION_INDEPENDENT_CODE ON) + + include(cmake/utils.cmake) +@@ -23,12 +32,10 @@ option(ONNX_OPT_USE_SYSTEM_PROTOBUF "" OFF) + if(NOT ONNX_OPT_USE_SYSTEM_PROTOBUF) + option(protobuf_BUILD_TESTS "" OFF) + option(protobuf_MSVC_STATIC_RUNTIME "" ${ONNX_USE_MSVC_STATIC_RUNTIME}) +- add_subdirectory_if_no_target(${PROJECT_SOURCE_DIR}/third_party/protobuf/cmake libprotobuf) + endif() + +- +-set(ONNX_ROOT ${PROJECT_SOURCE_DIR}/third_party/onnx) +-add_subdirectory_if_no_target(${ONNX_ROOT} ${ONNX_TARGET_NAME}) ++find_package(protobuf CONFIG REQUIRED) ++find_package(ONNX CONFIG REQUIRED) + + file(READ "${PROJECT_SOURCE_DIR}/VERSION_NUMBER" ONNX_OPTIMIZER_VERSION) + string(STRIP "${ONNX_OPTIMIZER_VERSION}" ONNX_OPTIMIZER_VERSION) +@@ -70,7 +77,7 @@ if(BUILD_ONNX_PYTHON) + set(PY_EXT_SUFFIX ".so") + endif() + endif() +- find_package(Python COMPONENTS Interpreter REQUIRED) ++ find_package(Python3 COMPONENTS Development REQUIRED) + + onnxopt_add_library(onnx_opt_cpp2py_export MODULE "onnxoptimizer/cpp2py_export.cc") + set_target_properties(onnx_opt_cpp2py_export PROPERTIES PREFIX "") +@@ -84,7 +91,7 @@ if(BUILD_ONNX_PYTHON) + $ + ${Python_INCLUDE_DIR}) + # pybind11 is a header only lib +- find_package(pybind11 2.2) ++ find_package(pybind11 2.2 CONFIG REQUIRED) + if(pybind11_FOUND) + target_include_directories(onnx_opt_cpp2py_export PUBLIC + ${pybind11_INCLUDE_DIRS}) +@@ -121,9 +128,9 @@ if(BUILD_ONNX_PYTHON) + + target_link_libraries(onnx_opt_cpp2py_export PRIVATE onnx_optimizer) + ++ target_link_directories(onnx_opt_cpp2py_export PRIVATE ${Python3_LIBRARY_DIRS}) ++ target_link_libraries(onnx_opt_cpp2py_export PRIVATE ${Python3_LIBRARIES}) + if(MSVC) +- find_package(Python COMPONENTS Interpreter Development REQUIRED) +- target_link_libraries(onnx_opt_cpp2py_export PRIVATE ${Python_LIBRARIES}) + target_compile_options(onnx_opt_cpp2py_export + PRIVATE /MP + /WX +diff --git a/cmake/utils.cmake b/cmake/utils.cmake +index 6cca9f3..9d79f1a 100644 +--- a/cmake/utils.cmake ++++ b/cmake/utils.cmake +@@ -1,5 +1,3 @@ +-include(${PROJECT_SOURCE_DIR}/third_party/onnx/cmake/Utils.cmake) +- + # Poor man's FetchContent + function(add_subdirectory_if_no_target dir target) + if (NOT TARGET ${target}) diff --git a/ports/onnx-optimizer/portfile.cmake b/ports/onnx-optimizer/portfile.cmake index fe62f0304d..b4c4e02427 100644 --- a/ports/onnx-optimizer/portfile.cmake +++ b/ports/onnx-optimizer/portfile.cmake @@ -3,13 +3,15 @@ vcpkg_check_linkage(ONLY_STATIC_LIBRARY) vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO onnx/optimizer - REF v0.2.6 - SHA512 cc6373781f04bc6fafd3282d248e26eaf93556b86acbb0dee44b4aa7a5d59c634905c1a05d035e31a50fc0f06cfc686fa483b79a324dd973faa421747d4a681b + REF "v${VERSION}" + SHA512 919790201f0d4d3eb107de9ed34c71d289d3c442f38f62721c838c9f60067a8c3478e991682983d8dad59476cab93466e2d23cc6d10b8b921282b939c29a1ad7 HEAD_REF master PATCHES fix-cmakelists.patch ) +string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" USE_STATIC_RUNTIME) + vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS FEATURES pybind11 BUILD_ONNX_PYTHON @@ -26,6 +28,7 @@ vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" OPTIONS ${FEATURE_OPTIONS} + -DONNX_USE_MSVC_STATIC_RUNTIME=${USE_STATIC_RUNTIME} ) if("pybind11" IN_LIST FEATURES) # This target is not in install/export @@ -35,8 +38,7 @@ vcpkg_cmake_install() vcpkg_copy_pdbs() vcpkg_cmake_config_fixup(PACKAGE_NAME ONNXOptimizer CONFIG_PATH lib/cmake/ONNXOptimizer) -file(INSTALL "${SOURCE_PATH}/LICENSE" - DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share" "${CURRENT_PACKAGES_DIR}/include/onnxoptimizer/test" diff --git a/ports/onnx-optimizer/vcpkg.json b/ports/onnx-optimizer/vcpkg.json index f38496eb08..2a99c3f8da 100644 --- a/ports/onnx-optimizer/vcpkg.json +++ b/ports/onnx-optimizer/vcpkg.json @@ -1,6 +1,6 @@ { "name": "onnx-optimizer", - "version-semver": "0.2.6", + "version-semver": "0.3.17", "description": "Actively maintained ONNX Optimizer", "homepage": "https://github.com/onnx/optimizer", "license": "Apache-2.0", diff --git a/ports/onnx/portfile.cmake b/ports/onnx/portfile.cmake index c42088a9ea..ea4ed43372 100644 --- a/ports/onnx/portfile.cmake +++ b/ports/onnx/portfile.cmake @@ -4,7 +4,7 @@ vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO onnx/onnx REF "v${VERSION}" - SHA512 325859f591dece43a083a0945aefe3427bfdb68a98ef5922343bf7ed959528947e7664d6c8e3e3d35c390d6c20ef22d07c672e5311f80c72c199931be6c256c3 + SHA512 8a525b365fd203f0a59bcf82fa7f2e29d7e0563885ebe38269c596cd4eb949bcfc65d848b92b7abafa7ddecedcfc019f8779097ffcb5087f06037cace24462fc PATCHES fix-cmakelists.patch fix-dependency-protobuf.patch diff --git a/ports/onnx/vcpkg.json b/ports/onnx/vcpkg.json index 665f3577b1..7b7f52aec5 100644 --- a/ports/onnx/vcpkg.json +++ b/ports/onnx/vcpkg.json @@ -1,6 +1,6 @@ { "name": "onnx", - "version-semver": "1.13.1", + "version-semver": "1.14.0", "description": "Open standard for machine learning interoperability", "homepage": "https://onnx.ai", "license": "Apache-2.0", diff --git a/ports/openvino/003-fix-find-onnx.patch b/ports/openvino/003-fix-find-onnx.patch new file mode 100644 index 0000000000..7a8989a795 --- /dev/null +++ b/ports/openvino/003-fix-find-onnx.patch @@ -0,0 +1,13 @@ +diff --git a/thirdparty/dependencies.cmake b/thirdparty/dependencies.cmake +index e815baa..c0ccaaa 100644 +--- a/thirdparty/dependencies.cmake ++++ b/thirdparty/dependencies.cmake +@@ -580,7 +580,7 @@ endif() + # + + if(ENABLE_OV_ONNX_FRONTEND) +- find_package(ONNX 1.13.1 EXACT QUIET COMPONENTS onnx onnx_proto NO_MODULE) ++ find_package(ONNX 1.13.1 QUIET COMPONENTS onnx onnx_proto NO_MODULE) + + if(ONNX_FOUND) + # conan and vcpkg create imported targets 'onnx' and 'onnx_proto' diff --git a/ports/openvino/portfile.cmake b/ports/openvino/portfile.cmake index 1af7542d12..f2aded0665 100644 --- a/ports/openvino/portfile.cmake +++ b/ports/openvino/portfile.cmake @@ -6,6 +6,7 @@ vcpkg_from_github( PATCHES 001-disable-tools.patch 002-typo-in-default-option-value.patch + 003-fix-find-onnx.patch HEAD_REF master) function(ov_checkout_in_path PATH REPO REF SHA512) diff --git a/ports/openvino/vcpkg.json b/ports/openvino/vcpkg.json index 493d84b0d4..eba4fe55b8 100644 --- a/ports/openvino/vcpkg.json +++ b/ports/openvino/vcpkg.json @@ -2,7 +2,7 @@ "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", "name": "openvino", "version-date": "2023-06-11", - "port-version": 2, + "port-version": 3, "maintainers": "OpenVINO Developers ", "summary": "This is a port for Open Visual Inference And Optimization toolkit for AI inference", "description": [ diff --git a/versions/baseline.json b/versions/baseline.json index 9980ae5580..f8606686af 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -5909,11 +5909,11 @@ "port-version": 1 }, "onnx": { - "baseline": "1.13.1", + "baseline": "1.14.0", "port-version": 0 }, "onnx-optimizer": { - "baseline": "0.2.6", + "baseline": "0.3.17", "port-version": 0 }, "onnxruntime-gpu": { @@ -6102,7 +6102,7 @@ }, "openvino": { "baseline": "2023-06-11", - "port-version": 2 + "port-version": 3 }, "openvpn3": { "baseline": "3.7.0", diff --git a/versions/o-/onnx-optimizer.json b/versions/o-/onnx-optimizer.json index 3a6bc01dcb..8c204d1a69 100644 --- a/versions/o-/onnx-optimizer.json +++ b/versions/o-/onnx-optimizer.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "0bc5be29ebb8c6a63883d7e76fab6c2613273384", + "version-semver": "0.3.17", + "port-version": 0 + }, { "git-tree": "e98d775d36ccb84c9ffa20e2cf6f8ef1b7ab0461", "version-semver": "0.2.6", diff --git a/versions/o-/onnx.json b/versions/o-/onnx.json index a954f49364..d07e3e0e8b 100644 --- a/versions/o-/onnx.json +++ b/versions/o-/onnx.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "1937b77767085a7447df95efbe366e1d098a9b53", + "version-semver": "1.14.0", + "port-version": 0 + }, { "git-tree": "9b31a613878d713e6573b82752f4aa6b78e71820", "version-semver": "1.13.1", diff --git a/versions/o-/openvino.json b/versions/o-/openvino.json index 92a34e6036..2c45bf8037 100644 --- a/versions/o-/openvino.json +++ b/versions/o-/openvino.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "be798c823b9abdb477acbbe2541368067263f268", + "version-date": "2023-06-11", + "port-version": 3 + }, { "git-tree": "42a42b174342b956f51bfd641761787fc3ced98a", "version-date": "2023-06-11",