logo

overlay

My own overlay for experimentations, use with caution, no support is provided git clone https://anongit.hacktivis.me/git/overlay.git/

onnxruntime-1.9.1.ebuild (3067B)


  1. # Copyright 2021 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=7
  4. inherit cmake
  5. CPUINFO_COMMIT=5916273f79a21551890fd3d56fc5375a78d1598d
  6. ONNX_COMMIT=1f63dcb7fcc3a8bf5c3c8e326867ecd6f5c43f35
  7. MP11_COMMIT=21cace4e574180ba64d9307a5e4ea9e5e94d3e8d
  8. OPTIONAL_LITE_COMMIT=4acf4553baa886e10e6613fe1452b706b0250e78
  9. SAFEINT_COMMIT=a104e0cf23be4fe848f7ef1f3e8996fe429b06bb
  10. FLATBUFFERS_PV=1.12.0
  11. DESCRIPTION="cross-platform, high performance ML inferencing and training accelerator"
  12. HOMEPAGE="https://github.com/microsoft/onnxruntime"
  13. SRC_URI="
  14. https://github.com/microsoft/${PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
  15. https://github.com/pytorch/cpuinfo/archive/${CPUINFO_COMMIT}.tar.gz -> pytorch-cpuinfo-${CPUINFO_COMMIT:0:10}.tar.gz
  16. https://github.com/onnx/onnx/archive/${ONNX_COMMIT}.tar.gz -> onnx-${ONNX_COMMIT:0:10}.tar.gz
  17. https://github.com/boostorg/mp11/archive/${MP11_COMMIT}.tar.gz -> boost_mp11-${MP11_COMMIT:0:11}.tar.gz
  18. https://github.com/google/flatbuffers/archive/v${FLATBUFFERS_PV}.tar.gz -> flatbuffers-${FLATBUFFERS_PV}.tar.gz
  19. https://github.com/martinmoene/optional-lite/archive/${OPTIONAL_LITE_COMMIT}.tar.gz -> optional-lite-${OPTIONAL_LITE_COMMIT:0:10}.tar.gz
  20. https://github.com/dcleblanc/SafeInt/archive/${SAFEINT_COMMIT}.tar.gz -> SafeInt-${SAFEINT_COMMIT:0:10}.tar.gz
  21. "
  22. LICENSE="MIT"
  23. SLOT="0"
  24. KEYWORDS="~amd64"
  25. IUSE="benchmark test"
  26. # libonnxruntime_framework.so: undefined reference to `onnx::AttributeProto_AttributeType_Name[abi:cxx11](onnx::AttributeProto_AttributeType)'
  27. RESTRICT="test"
  28. S="${WORKDIR}/${P}/cmake"
  29. # Needs https://gitlab.com/libeigen/eigen/-/commit/d0e3791b1a0e2db9edd5f1d1befdb2ac5a40efe0.patch on eigen-3.4.0
  30. RDEPEND="
  31. dev-python/numpy
  32. dev-libs/date:=
  33. >=dev-libs/boost-1.66:=
  34. dev-libs/protobuf:=
  35. dev-libs/re2:=
  36. dev-libs/flatbuffers:=
  37. dev-cpp/nlohmann_json:=
  38. dev-libs/nsync
  39. dev-cpp/eigen:3
  40. benchmark? ( dev-cpp/benchmark )
  41. "
  42. DEPEND="
  43. ${RDEPEND}
  44. test? ( dev-cpp/gtest )
  45. "
  46. PATCHES=(
  47. "${FILESDIR}/${P}-system_libs.patch"
  48. )
  49. src_prepare() {
  50. cmake_src_prepare
  51. rm -r "${S}/external/pytorch_cpuinfo" || die
  52. mv "${WORKDIR}/cpuinfo-${CPUINFO_COMMIT}" "${S}/external/pytorch_cpuinfo" || die
  53. rm -r "${S}/external/onnx" || die
  54. mv "${WORKDIR}/onnx-${ONNX_COMMIT}" "${S}/external/onnx" || die
  55. rm -r "${S}/external/mp11" || die
  56. mv "${WORKDIR}/mp11-${MP11_COMMIT}" "${S}/external/mp11" || die
  57. rm -r "${S}/external/flatbuffers" || die
  58. mv "${WORKDIR}/flatbuffers-${FLATBUFFERS_PV}" "${S}/external/flatbuffers" || die
  59. rm -r "${S}/external/optional-lite" || die
  60. mv "${WORKDIR}/optional-lite-${OPTIONAL_LITE_COMMIT}" "${S}/external/optional-lite" || die
  61. rm -r "${S}/external/SafeInt/safeint" || die
  62. mv "${WORKDIR}/SafeInt-${SAFEINT_COMMIT}" "${S}/external/SafeInt/safeint" || die
  63. }
  64. src_configure() {
  65. append-cppflags "-I/usr/include/eigen3"
  66. local mycmakeargs=(
  67. -Donnxruntime_PREFER_SYSTEM_LIB=ON
  68. -Donnxruntime_BUILD_BENCHMARKS=$(usex benchmark)
  69. -Donnxruntime_BUILD_UNIT_TESTS=$(usex test)
  70. )
  71. cmake_src_configure
  72. }