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 ONNXIFI build output and host dependencies #20112

Closed
wants to merge 8 commits into from
Closed
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
18 changes: 18 additions & 0 deletions ports/onnx/fix-cmakelists.patch
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,21 @@ index 628dcaa..300e4ea 100644
install(DIRECTORY ${ONNX_ROOT}/onnx
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING
@@ -639,7 +639,7 @@ endif()

if (NOT ANDROID AND NOT IOS)
# ---[ ONNXIFI wrapper
- add_library(onnxifi_wrapper MODULE onnx/onnxifi_wrapper.c)
+ add_library(onnxifi_wrapper onnx/onnxifi_wrapper.c)
JackBoosY marked this conversation as resolved.
Show resolved Hide resolved
if(MSVC)
add_msvc_runtime_flag(onnxifi_wrapper)
endif()
@@ -669,7 +669,7 @@ if (NOT ANDROID AND NOT IOS)
endif()

# ---[ ONNXIFI dummy backend
-add_library(onnxifi_dummy SHARED onnx/onnxifi_dummy.c)
+add_library(onnxifi_dummy onnx/onnxifi_dummy.c)

if(ONNXIFI_ENABLE_EXT)
add_definitions(-DONNXIFI_ENABLE_EXT=ON)
27 changes: 8 additions & 19 deletions ports/onnx/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,9 @@ vcpkg_from_github(
SHA512 a3eecc74ce4f22524603fb86367d21c87a143ba27eef93ef4bd2e2868c2cadeb724b84df58a429286e7824adebdeba7fa059095b7ab29df8dcea8777bd7f4101
PATCHES
fix-cmakelists.patch
wrap-onnxifi-targets.patch
)

if(VCPKG_TARGET_IS_WINDOWS)
string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" USE_STATIC_RUNTIME)
list(APPEND PLATFORM_OPTIONS
-DONNX_USE_MSVC_STATIC_RUNTIME=${USE_STATIC_RUNTIME}
)
endif()
string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" USE_STATIC_RUNTIME)

# 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)
Expand All @@ -30,35 +24,30 @@ endif()

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
pybind11 BUILD_ONNX_PYTHON
pybind11 BUILD_ONNX_PYTHON
protobuf-lite ONNX_USE_LITE_PROTO
)

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

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

if("pybind11" IN_LIST FEATURES)
# When BUILD_ONNX_PYTHON, we need Development component. Give a hint for FindPython3
list(APPEND FEATURE_OPTIONS
-DPython3_ROOT_DIR=${CURRENT_INSTALLED_DIR}
)
endif()

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS} ${PLATFORM_OPTIONS}
${FEATURE_OPTIONS}
-DPython3_EXECUTABLE=${PYTHON3}
-DONNX_ML=ON
-DONNX_GEN_PB_TYPE_STUBS=ON
-DONNX_USE_PROTOBUF_SHARED_LIBS=${USE_PROTOBUF_SHARED}
-DONNX_USE_LITE_PROTO=OFF
-DONNXIFI_ENABLE_EXT=OFF
-DONNX_USE_MSVC_STATIC_RUNTIME=${USE_STATIC_RUNTIME}
-DONNX_BUILD_TESTS=OFF
-DONNX_BUILD_BENCHMARKS=OFF
MAYBE_UNUSED_VARIABLES
ONNX_USE_MSVC_STATIC_RUNTIME
)

if("pybind11" IN_LIST FEATURES)
Expand Down
14 changes: 6 additions & 8 deletions ports/onnx/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
{
"name": "onnx",
"version-semver": "1.9.0",
"port-version": 1,
"description": "Open standard for machine learning interoperability",
"homepage": "https://onnx.ai",
"license": "Apache-2.0",
"supports": "!uwp",
"dependencies": [
"protobuf",
{
"name": "protobuf",
"host": true
},
{
"name": "python3",
"host": true
},
{
"name": "vcpkg-cmake",
"host": true
Expand All @@ -24,11 +22,11 @@
}
],
"features": {
"protobuf-lite": {
Copy link
Member

Choose a reason for hiding this comment

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

Features can't "remove" functionality or control alternatives; this should probably be a feature named protobuf which does the full thing and is in the default-features set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see. But I think default-features: ["protobuf"] can give misunderstanding.
Some users may think onnx[core,pybind11] is valid and it won't use protobuf.

protobuf in pybind11.dependencies will look weird.
But this one looks weird either in my opinion....

{
  "dependencies": [
    "protobuf",
    "python3"
  ],
  "default-features": [
    "protobuf"
  ],
  "features": {
    "protobuf": {
      "description": "Build with full protobuf library"
    },
    "protobuf-lite": {
      "description": "Use lite protobuf instead of full"
    },
    "pybind11": {
      "description": "Build Python binaries"
    }
  }
}

Copy link
Member

Choose a reason for hiding this comment

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

Some users may think onnx[core,pybind11] is valid and it won't use protobuf.

I believe that is unavoidable.

protobuf in pybind11.dependencies will look weird.

You can add onnx[core,protobuf] as a dependency of the pybind11 feature to express dependencies between features.

Does using protobuf-lite remove the protobuf dependency? If so, the dependency should be moved to the protobuf feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will add dependency to onnx[core,protobuf] for pybind11

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By the way, protobuf-lite also requires protobuf library and ptoroc in its tool.

"description": "Use lite protobuf instead of full"
},
"pybind11": {
"description": "Build Python binaries",
"dependencies": [
"pybind11"
]
"description": "Build Python binaries"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why delete the dependency pybind11?

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 was necessary when I tried to use FimdPython3 with find_package pybind11. But doing that blocks search of NumPy component. Same as the PR note

Copy link
Member

Choose a reason for hiding this comment

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

That is, the port needs Python 3 pybind but our pybind11 port is for Python 2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. It was quite confusing to me. Let me explain with PR comments...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. commented below. #20112 (comment)

}
}
}
44 changes: 0 additions & 44 deletions ports/onnx/wrap-onnxifi-targets.patch

This file was deleted.

2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -4710,7 +4710,7 @@
},
"onnx": {
"baseline": "1.9.0",
"port-version": 0
"port-version": 1
},
"onnx-optimizer": {
"baseline": "0.2.6",
Expand Down
5 changes: 5 additions & 0 deletions versions/o-/onnx.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "27724661edbd68109ff786713dffa66b8c31f234",
"version-semver": "1.9.0",
"port-version": 1
},
{
"git-tree": "b53c9c9e969928def925c57ea5ddcdfb09293693",
"version-semver": "1.9.0",
Expand Down