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] create a new port #18073

Merged
merged 19 commits into from
Aug 27, 2021
Merged
Show file tree
Hide file tree
Changes from 9 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
38 changes: 38 additions & 0 deletions ports/onnx/fix-cmakelists.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 628dcaa..6758666 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -635,7 +635,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)
if(MSVC)
add_msvc_runtime_flag(onnxifi_wrapper)
endif()
@@ -658,10 +658,6 @@ if (NOT ANDROID AND NOT IOS)
target_compile_definitions(onnxifi_wrapper PRIVATE "ONNXIFI_PUBLIC=__attribute__((__dllexport__))")
endif()
endif()
- if(APPLE)
- # By default CMake would use .so suffix on Mac
- set_target_properties(onnxifi_wrapper PROPERTIES SUFFIX ".dylib")
- endif()
endif()

# ---[ ONNXIFI dummy backend
@@ -712,8 +708,11 @@ install(FILES
install(EXPORT ONNXTargets DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ONNX")
install(TARGETS
onnx onnx_proto
- onnxifi onnxifi_dummy onnxifi_loader
- EXPORT ONNXTargets DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ onnxifi onnxifi_loader # onnxifi_dummy
+ EXPORT ONNXTargets
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})

if(NOT ANDROID AND NOT IOS)
install(TARGETS onnxifi_wrapper
32 changes: 32 additions & 0 deletions ports/onnx/fix-pybind11.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3861def..88265fb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -110,9 +110,11 @@ endif()

# find_package Python has replaced PythonInterp and PythonLibs since cmake 3.12
# Use the following command in the future; now this is only compatible with the latest pybind11
-# find_package(Python ${PY_VERSION} COMPONENTS Interpreter Development REQUIRED)
-find_package(PythonInterp ${PY_VERSION} REQUIRED)
-find_package(PythonLibs ${PY_VERSION})
+if(WIN32)
+ find_package(Python ${PY_VERSION} COMPONENTS Interpreter REQUIRED)
+else()
+ find_package(Python ${PY_VERSION} COMPONENTS Interpreter Development REQUIRED)
+endif()

if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
set(CMAKE_NO_SYSTEM_FROM_IMPORTED 1)
@@ -441,10 +439,10 @@ if(BUILD_ONNX_PYTHON)
$<BUILD_INTERFACE:${ONNX_ROOT}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:include>
- ${PYTHON_INCLUDE_DIR})
+ ${Python_INCLUDE_DIRS})

# 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_cpp2py_export PUBLIC
${pybind11_INCLUDE_DIRS})
99 changes: 99 additions & 0 deletions ports/onnx/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# uwp: LOAD_LIBRARY_SEARCH_DEFAULT_DIRS undefined identifier
vcpkg_fail_port_install(ON_TARGET "uwp")

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO onnx/onnx
REF v1.9.0
SHA512 a3eecc74ce4f22524603fb86367d21c87a143ba27eef93ef4bd2e2868c2cadeb724b84df58a429286e7824adebdeba7fa059095b7ab29df8dcea8777bd7f4101
PATCHES
fix-cmakelists.patch
fix-pybind11.patch
)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
pybind11 BUILD_ONNX_PYTHON
)

string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" USE_PROTOBUF_SHARED)
list(APPEND FEATURE_OPTIONS
-DONNX_USE_PROTOBUF_SHARED_LIBS=${USE_PROTOBUF_SHARED}
)
if(VCPKG_TARGET_IS_WINDOWS)
string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" USE_STATIC_RUNTIME)
list(APPEND FEATURE_OPTIONS
-DONNX_USE_MSVC_STATIC_RUNTIME=${USE_STATIC_RUNTIME}
)
endif()

vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
vcpkg_find_acquire_program(PYTHON3)

vcpkg_cmake_configure(
SOURCE_PATH ${SOURCE_PATH}
luncliff marked this conversation as resolved.
Show resolved Hide resolved
OPTIONS
${FEATURE_OPTIONS}
-DPYTHON_EXECUTABLE=${PYTHON3}
-DONNX_GEN_PB_TYPE_STUBS=ON
-DONNX_USE_LITE_PROTO=OFF
-DONNX_BUILD_TESTS=OFF
-DONNX_BUILD_BENCHMARKS=OFF
)

if("pybind11" IN_LIST FEATURES)
# This target is not in install/export
vcpkg_cmake_build(TARGET onnx_cpp2py_export)
endif()
vcpkg_cmake_install()
vcpkg_copy_pdbs()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/ONNX)

file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
luncliff marked this conversation as resolved.
Show resolved Hide resolved
# install protobuf files together
get_filename_component(CODEGEN_DIR ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/onnx ABSOLUTE)
file(INSTALL ${CODEGEN_DIR}/onnx-data.proto
${CODEGEN_DIR}/onnx-data.proto3
${CODEGEN_DIR}/onnx-ml.proto
${CODEGEN_DIR}/onnx-ml.proto3
${CODEGEN_DIR}/onnx-operators-ml.proto
${CODEGEN_DIR}/onnx-operators-ml.proto3
DESTINATION ${CURRENT_PACKAGES_DIR}/include/onnx
)
if("pybind11" IN_LIST FEATURES)
file(INSTALL ${CODEGEN_DIR}/onnx_data_pb.py
${CODEGEN_DIR}/onnx_data_pb2.py
${CODEGEN_DIR}/onnx_ml_pb2.py
${CODEGEN_DIR}/onnx_operators_ml_pb2.py
${CODEGEN_DIR}/onnx_operators_pb.py
${CODEGEN_DIR}/onnx_pb.py
DESTINATION ${CURRENT_PACKAGES_DIR}/include/onnx
)
endif()

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include
${CURRENT_PACKAGES_DIR}/debug/share
${CURRENT_PACKAGES_DIR}/include/onnx/onnx_ml
${CURRENT_PACKAGES_DIR}/include/onnx/onnx_data
${CURRENT_PACKAGES_DIR}/include/onnx/onnx_operators_ml
${CURRENT_PACKAGES_DIR}/include/onnx/onnx_cpp2py_export
# the others are empty
${CURRENT_PACKAGES_DIR}/include/onnx/backend
${CURRENT_PACKAGES_DIR}/include/onnx/tools
${CURRENT_PACKAGES_DIR}/include/onnx/test
${CURRENT_PACKAGES_DIR}/include/onnx/bin
${CURRENT_PACKAGES_DIR}/include/onnx/examples
${CURRENT_PACKAGES_DIR}/include/onnx/frontend
${CURRENT_PACKAGES_DIR}/include/onnx/defs/training
${CURRENT_PACKAGES_DIR}/include/onnx/defs/math
${CURRENT_PACKAGES_DIR}/include/onnx/defs/quantization
${CURRENT_PACKAGES_DIR}/include/onnx/defs/generator
${CURRENT_PACKAGES_DIR}/include/onnx/defs/reduction
${CURRENT_PACKAGES_DIR}/include/onnx/defs/logical
${CURRENT_PACKAGES_DIR}/include/onnx/defs/object_detection
${CURRENT_PACKAGES_DIR}/include/onnx/defs/traditionalml
${CURRENT_PACKAGES_DIR}/include/onnx/defs/sequence
${CURRENT_PACKAGES_DIR}/include/onnx/defs/controlflow
${CURRENT_PACKAGES_DIR}/include/onnx/defs/rnn
${CURRENT_PACKAGES_DIR}/include/onnx/defs/nn
)
luncliff marked this conversation as resolved.
Show resolved Hide resolved
26 changes: 26 additions & 0 deletions ports/onnx/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "onnx",
"version": "1.9.0",
luncliff marked this conversation as resolved.
Show resolved Hide resolved
"description": "Open standard for machine learning interoperability",
"homepage": "https://onnx.ai",
"supports": "!uwp",
"dependencies": [
"protobuf",
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
],
"features": {
"pybind11": {
"description": "Build Python binaries",
"dependencies": [
"pybind11"
]
}
}
}
4 changes: 4 additions & 0 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -4540,6 +4540,10 @@
"baseline": "6.9.4",
"port-version": 0
},
"onnx": {
"baseline": "1.9.0",
"port-version": 0
},
"onnxruntime-gpu": {
"baseline": "1.5.1",
"port-version": 0
Expand Down
9 changes: 9 additions & 0 deletions versions/o-/onnx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "963f7594dc1ae22d37e2d256ff154f813d73cf95",
"version": "1.9.0",
"port-version": 0
}
]
}