logo

overlay

My own overlay for experimentations, use with caution, no support is provided git clone https://hacktivis.me/git/overlay.git
commit: df0be5a79acf04244d2471bbdad044e48feddcf8
parent 8ea890a65d260d1b050c972e0e5bedc5e4e21f69
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Thu,  4 Nov 2021 22:44:20 +0100

sci-libs/onnxruntime: New Package, 1.9.1

Diffstat:

Asci-libs/onnxruntime/Manifest7+++++++
Asci-libs/onnxruntime/files/onnxruntime-1.9.1-system_libs.patch92+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asci-libs/onnxruntime/onnxruntime-1.9.1.ebuild88+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 187 insertions(+), 0 deletions(-)

diff --git a/sci-libs/onnxruntime/Manifest b/sci-libs/onnxruntime/Manifest @@ -0,0 +1,7 @@ +DIST SafeInt-a104e0cf23.zip 592915 BLAKE2B b4f7231d459cf75c400447358b746489c08a30855c082117a4554f4afce829d6553fdcbda6912775601bda16fa1a2ee0dce9d5bbab773a599d78bdb270a27e58 SHA512 48351fd769b44e924b00ebccb301fc7962fd4659a29f309904dfab9e817304c209fff4633cae5a878906597e71e4bffbd9cb44f9355ccbb600a88a3f428363a0 +DIST boost_mp11-21cace4e574.zip 237640 BLAKE2B 8440bde0a44ccf218580f56f164fdcdb993c29b0a323f3f017d5078b25aa417848992d06ece88fc59160e06a334795e29d9884d632b9d697d52348055349005c SHA512 0cdb32f16521e9cc4c515dbd1bb37fcba8beecd470b124775e3504f2b0c027c1f43e49ab13bd684e8be68c54003eb7be14190353b29a51430d92222d732cef29 +DIST flatbuffers-1.12.0.tar.gz 1145348 BLAKE2B 441123be124ad851efa30bda0d828a764ebaf79ba6692a6e5904000b33818e9de78c3a964037ac93ef562890980c58169141e55354dce86857c02bcd917150d6 SHA512 8a0b88d739fa4694a69d3630140fe89fdd70d50bba4dadd1758d9aa2920cda16700bcafb8d89fe2a09ac907d3f378240c3cb4abc7106318136799836aba4b063 +DIST onnx-1f63dcb7fc.zip 11993946 BLAKE2B 9c04df965bc89f26159b7e61cb706f5797fcb4093722b9069337251dac30378d98479dc2fac682f5c0e9a7d10a40488eb1de8d99b0fe07b30de8df5ced2406c1 SHA512 26503808e41a24a0ff2c42689e27945a83182f888c13520f11c7c5a6f484d5693110d53020658548fc4e5b006ec16ffe52bafd096a51deeed5fb96ab396c2bfc +DIST onnxruntime-1.9.1.tar.gz 290241910 BLAKE2B c0bbd2f987978f1d995c652904a79af32b520a2160e486cdb4b002ae00f730f511d827998a2d9da32fc6582d7ced7ab6f712b60ee2ce94a6bdd640d3a8a9d693 SHA512 66c4bff4c4f633885ba7d0601337d0f16c0eeef7e3c1f492f2d21f27f06f748260e28105083b5defbebf624f4f26dc59355de7e3e0ef81c6c27b01b936a98ce9 +DIST optional-lite-4acf4553ba.zip 65809 BLAKE2B 661cc0dcbad3171a1c1e50b3eec75ad7654adc2febf37cacab006c57c220ee24044485675d1fabb8cd2b8d54d4324890c5863314b7f86bee2a42ccd296db7663 SHA512 28580f45998228a315e9f6ed231f9475e827fc4f14e7e4a29f913f0455d84232745280a3e4f2960b0eea06a0d6a862a2a9f1857f535e26ebb4de9e91d4a27290 +DIST pytorch-cpuinfo-5916273f79.zip 3787933 BLAKE2B 169620d461103f271ae927d84af27282189509b2ba2fbed2c09f9ae387b5f392eea635dfdf2d3a23e1fc19b5d467bee3f13d3e473946e42bba4b6a9a2fd60e32 SHA512 6f1c8c931b62990ab0228679efb52207a6e21cb847139c11bf6117051b7315ff87c12ed1373670d006f0bc7e3d390d59f2d28a8250d0bd7df850583ae42afdf2 diff --git a/sci-libs/onnxruntime/files/onnxruntime-1.9.1-system_libs.patch b/sci-libs/onnxruntime/files/onnxruntime-1.9.1-system_libs.patch @@ -0,0 +1,92 @@ +diff --git a/CMakeLists.txt.old b/CMakeLists.txt +index 2534b99..d144047 100644 +--- a/CMakeLists.txt.old ++++ b/CMakeLists.txt +@@ -540,7 +540,7 @@ if (MSVC) + set(CMAKE_ASM_MASM_FLAGS "${CMAKE_ASM_MASM_FLAGS} /safeseh") + endif() + endif() +- ++ + + #Always enable exception handling, even for Windows ARM + if(NOT onnxruntime_DISABLE_EXCEPTIONS) +@@ -833,7 +833,13 @@ get_filename_component(ORTTRAINING_ROOT "${ORTTRAINING_ROOT}" ABSOLUTE) + get_filename_component(REPO_ROOT "${REPO_ROOT}" ABSOLUTE) + set(ONNXRUNTIME_INCLUDE_DIR ${REPO_ROOT}/include/onnxruntime) + +-add_subdirectory(external/date EXCLUDE_FROM_ALL) ++if(onnxruntime_PREFER_SYSTEM_LIB) ++ find_package(date REQUIRED) ++ add_library(date_interface ALIAS date::date) ++endif() ++if(NOT TARGET date::date) ++ add_subdirectory(external/date EXCLUDE_FROM_ALL) ++endif() + + set(SAFEINT_INCLUDE_DIR ${REPO_ROOT}/cmake/external/SafeInt) + add_library(safeint_interface INTERFACE) +@@ -844,16 +850,33 @@ if(onnxruntime_DISABLE_EXCEPTIONS) + add_compile_definitions(optional_CONFIG_NO_EXCEPTIONS=1) + endif() + +-add_subdirectory(external/mp11 EXCLUDE_FROM_ALL) ++if(onnxruntime_PREFER_SYSTEM_LIB) ++ find_package(boost_mp11) ++endif() ++if(NOT TARGET Boost::mp11) ++ add_subdirectory(external/mp11 EXCLUDE_FROM_ALL) ++endif() + +-set(JSON_BuildTests OFF CACHE INTERNAL "") +-set(JSON_Install OFF CACHE INTERNAL "") +-add_subdirectory(external/json EXCLUDE_FROM_ALL) ++if(onnxruntime_PREFER_SYSTEM_LIB) ++ find_package(nlohmann_json REQUIRED) ++endif() ++if(NOT TARGET nlohmann_json::nlohmann_json) ++ set(JSON_BuildTests OFF CACHE INTERNAL "") ++ set(JSON_Install OFF CACHE INTERNAL "") ++ add_subdirectory(external/json EXCLUDE_FROM_ALL) ++endif() + ++find_package(PkgConfig) + if(onnxruntime_PREFER_SYSTEM_LIB) +- find_package(re2) ++ pkg_check_modules(RE2 re2) + endif() +-if(NOT TARGET re2::re2) ++if(RE2_FOUND) ++ add_library(re2::re2 INTERFACE IMPORTED) ++ set_target_properties(re2::re2 PROPERTIES ++ INTERFACE_COMPILE_OPTIONS "${RE2_CFLAGS}" ++ INTERFACE_LINK_LIBRARIES "${RE2_LDFLAGS}" ++ ) ++else() + add_subdirectory(external/re2 EXCLUDE_FROM_ALL) + set_target_properties(re2 PROPERTIES FOLDER "External/re2") + set(RE2_INCLUDE_DIR ${REPO_ROOT}/cmake/external/re2) +@@ -885,12 +908,12 @@ else() + elseif(WINDOWS_STORE OR (WIN32 AND NOT CMAKE_CXX_STANDARD_LIBRARIES MATCHES kernel32.lib)) + message(WARNING "Cpuinfo not included in Windows Store or WCOS builds") + set(CPUINFO_SUPPORTED FALSE) +- endif() ++ endif() + elseif(NOT ${onnxruntime_target_platform} MATCHES "^(i[3-6]86|AMD64|x86(_64)?|armv[5-8].*|aarch64|arm64)$") + message(WARNING + "Target processor architecture \"${onnxruntime_target_platform}\" is not supported in cpuinfo. " + "cpuinfo not included.") +- set(CPUINFO_SUPPORTED FALSE) ++ set(CPUINFO_SUPPORTED FALSE) + endif() + endif() + +@@ -907,7 +930,7 @@ if(CPUINFO_SUPPORTED) + set(IOS ON CACHE INTERNAL "") + set(IOS_ARCH "${CMAKE_OSX_ARCHITECTURES}" CACHE INTERNAL "") + endif() +- ++ + string(APPEND CMAKE_CXX_FLAGS " -DCPUINFO_SUPPORTED") + add_subdirectory(external/pytorch_cpuinfo EXCLUDE_FROM_ALL) + if(MSVC) diff --git a/sci-libs/onnxruntime/onnxruntime-1.9.1.ebuild b/sci-libs/onnxruntime/onnxruntime-1.9.1.ebuild @@ -0,0 +1,88 @@ +# Copyright 2021 Haelwenn (lanodan) Monnier <contact@hacktivis.me> +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +inherit cmake + +CPUINFO_COMMIT=5916273f79a21551890fd3d56fc5375a78d1598d +ONNX_COMMIT=1f63dcb7fcc3a8bf5c3c8e326867ecd6f5c43f35 +MP11_COMMIT=21cace4e574180ba64d9307a5e4ea9e5e94d3e8d +OPTIONAL_LITE_COMMIT=4acf4553baa886e10e6613fe1452b706b0250e78 +SAFEINT_COMMIT=a104e0cf23be4fe848f7ef1f3e8996fe429b06bb +FLATBUFFERS_PV=1.12.0 + +DESCRIPTION="cross-platform, high performance ML inferencing and training accelerator" +HOMEPAGE="https://github.com/microsoft/onnxruntime" +SRC_URI=" + https://github.com/microsoft/${PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz + https://github.com/pytorch/cpuinfo/archive/${CPUINFO_COMMIT}.zip -> pytorch-cpuinfo-${CPUINFO_COMMIT:0:10}.zip + https://github.com/onnx/onnx/archive/${ONNX_COMMIT}.zip -> onnx-${ONNX_COMMIT:0:10}.zip + https://github.com/boostorg/mp11/archive/${MP11_COMMIT}.zip -> boost_mp11-${MP11_COMMIT:0:11}.zip + https://github.com/google/flatbuffers/archive/v${FLATBUFFERS_PV}.tar.gz -> flatbuffers-${FLATBUFFERS_PV}.tar.gz + https://github.com/martinmoene/optional-lite/archive/${OPTIONAL_LITE_COMMIT}.zip -> optional-lite-${OPTIONAL_LITE_COMMIT:0:10}.zip + https://github.com/dcleblanc/SafeInt/archive/${SAFEINT_COMMIT}.zip -> SafeInt-${SAFEINT_COMMIT:0:10}.zip +" +LICENSE="MIT" +SLOT="0" +KEYWORDS="~amd64" +IUSE="benchmark test" +RESTRICT="!test ( test )" + +S="${WORKDIR}/${P}/cmake" + +# Needs https://gitlab.com/libeigen/eigen/-/commit/d0e3791b1a0e2db9edd5f1d1befdb2ac5a40efe0.patch on eigen-3.4.0 +RDEPEND=" + dev-python/numpy + dev-libs/date:= + >=dev-libs/boost-1.66:= + dev-libs/protobuf:= + dev-libs/re2:= + dev-libs/flatbuffers:= + dev-cpp/nlohmann_json:= + dev-libs/nsync + dev-cpp/eigen:3 + benchmark? ( dev-cpp/benchmark ) +" +DEPEND=" + ${RDEPEND} + test? ( dev-cpp/gtest ) +" + +PATCHES=( + "${FILESDIR}/${P}-system_libs.patch" +) + +src_prepare() { + cmake_src_prepare + + rm -r "${S}/external/pytorch_cpuinfo" || die + mv "${WORKDIR}/cpuinfo-${CPUINFO_COMMIT}" "${S}/external/pytorch_cpuinfo" || die + + rm -r "${S}/external/onnx" || die + mv "${WORKDIR}/onnx-${ONNX_COMMIT}" "${S}/external/onnx" || die + + rm -r "${S}/external/mp11" || die + mv "${WORKDIR}/mp11-${MP11_COMMIT}" "${S}/external/mp11" || die + + rm -r "${S}/external/flatbuffers" || die + mv "${WORKDIR}/flatbuffers-${FLATBUFFERS_PV}" "${S}/external/flatbuffers" || die + + rm -r "${S}/external/optional-lite" || die + mv "${WORKDIR}/optional-lite-${OPTIONAL_LITE_COMMIT}" "${S}/external/optional-lite" || die + + rm -r "${S}/external/SafeInt/safeint" || die + mv "${WORKDIR}/SafeInt-${SAFEINT_COMMIT}" "${S}/external/SafeInt/safeint" || die +} + +src_configure() { + append-cppflags "-I/usr/include/eigen3" + + local mycmakeargs=( + -Donnxruntime_PREFER_SYSTEM_LIB=ON + -Donnxruntime_BUILD_BENCHMARKS=$(usex benchmark) + -Donnxruntime_BUILD_UNIT_TESTS=$(usex test) + ) + + cmake_src_configure +}