[onnx/onnx-optimizer] update to v1.14.0 and 0.3.17 (#32542)

This commit is contained in:
Cheney Wang 2023-07-27 10:51:16 +08:00 committed by GitHub
parent f4b60013ae
commit 91bb3e4b89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 117 additions and 67 deletions

View File

@ -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 $<$<NOT:$<CONFIG:Debug>>:/MT> $<$<CONFIG:Debug>:/MTd>)
+ else()
+ target_compile_options(${lib} PRIVATE $<$<NOT:$<CONFIG:Debug>>:/MD> $<$<CONFIG:Debug>:/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)
$<INSTALL_INTERFACE:include>
${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 $<$<NOT:$<CONFIG:Debug>>:/MT> $<$<CONFIG:Debug>:/MTd>)
+ else()
+ target_compile_options(${lib} PRIVATE $<$<NOT:$<CONFIG:Debug>>:/MD> $<$<CONFIG:Debug>:/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)
$<INSTALL_INTERFACE:include>
${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})

View File

@ -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"

View File

@ -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",

View File

@ -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

View File

@ -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",

View File

@ -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'

View File

@ -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)

View File

@ -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 <openvino@intel.com>",
"summary": "This is a port for Open Visual Inference And Optimization toolkit for AI inference",
"description": [

View File

@ -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",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "0bc5be29ebb8c6a63883d7e76fab6c2613273384",
"version-semver": "0.3.17",
"port-version": 0
},
{
"git-tree": "e98d775d36ccb84c9ffa20e2cf6f8ef1b7ab0461",
"version-semver": "0.2.6",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "1937b77767085a7447df95efbe366e1d098a9b53",
"version-semver": "1.14.0",
"port-version": 0
},
{
"git-tree": "9b31a613878d713e6573b82752f4aa6b78e71820",
"version-semver": "1.13.1",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "be798c823b9abdb477acbbe2541368067263f268",
"version-date": "2023-06-11",
"port-version": 3
},
{
"git-tree": "42a42b174342b956f51bfd641761787fc3ced98a",
"version-date": "2023-06-11",