ONNX provides an open source format for AI models, both deep learning and traditional ML. It defines an extensible computation graph model, as well as definitions of built-in operators and standard data types.
Signed-off-by: Andrew Davis <[email protected]> --- ...age-Protobuf-before-checking-if-it-w.patch | 25 ++++ .../recipes-framework/onnx/onnx_1.16.1.bb | 107 ++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 meta-arago-extras/recipes-framework/onnx/onnx/0001-Try-to-find-package-Protobuf-before-checking-if-it-w.patch create mode 100644 meta-arago-extras/recipes-framework/onnx/onnx_1.16.1.bb diff --git a/meta-arago-extras/recipes-framework/onnx/onnx/0001-Try-to-find-package-Protobuf-before-checking-if-it-w.patch b/meta-arago-extras/recipes-framework/onnx/onnx/0001-Try-to-find-package-Protobuf-before-checking-if-it-w.patch new file mode 100644 index 00000000..dceac1f4 --- /dev/null +++ b/meta-arago-extras/recipes-framework/onnx/onnx/0001-Try-to-find-package-Protobuf-before-checking-if-it-w.patch @@ -0,0 +1,25 @@ +From 7e118775c120ec802d13ac3e0125d726323aee87 Mon Sep 17 00:00:00 2001 +From: Andrew Davis <[email protected]> +Date: Thu, 16 Jan 2025 11:44:56 -0600 +Subject: [PATCH] Try to find package Protobuf before checking if it was found + +Upstream-Status: Pending + +Signed-off-by: Andrew Davis <[email protected]> +--- + CMakeLists.txt | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b666eec4..f6fbf159 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -127,6 +127,8 @@ if(ONNX_BUILD_TESTS) + set(googletest_STATIC_LIBRARIES GTest::gtest) + endif() + ++find_package(Protobuf) ++ + if((ONNX_USE_LITE_PROTO AND TARGET protobuf::libprotobuf-lite) OR ((NOT ONNX_USE_LITE_PROTO) AND TARGET protobuf::libprotobuf)) + # Sometimes we need to use protoc compiled for host architecture while linking + # libprotobuf against target architecture. See https://github.com/caffe2/caffe diff --git a/meta-arago-extras/recipes-framework/onnx/onnx_1.16.1.bb b/meta-arago-extras/recipes-framework/onnx/onnx_1.16.1.bb new file mode 100644 index 00000000..9624d061 --- /dev/null +++ b/meta-arago-extras/recipes-framework/onnx/onnx_1.16.1.bb @@ -0,0 +1,107 @@ +DESCRIPTION = "Open standard for machine learning interoperability" +SUMMARY = "ONNX Python package & C++ library" +HOMEPAGE = "https://www.onnx.ai/" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57" + +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" + +SRC_URI = "git://github.com/onnx/onnx.git;protocol=https;branch=rel-1.16.1" +SRC_URI += "file://0001-Try-to-find-package-Protobuf-before-checking-if-it-w.patch" +SRCREV = "595228d99e3977ac27cb79d5963adda262af99ad" + +S = "${WORKDIR}/git" + +DEPENDS += "\ + abseil-cpp \ + protobuf \ + protobuf-native \ + python3-protobuf \ + python3-protobuf-native \ +" + +PYTHON_DEPENDS = "\ + python3 \ + python3-numpy \ + python3-numpy-native \ + python3-pybind11 \ + python3-pybind11-native \ +" + +PYTHON_RDEPENDS = "\ + python3 \ + python3-numpy \ + python3-protobuf \ + python3-coloredlogs \ + python3-flatbuffers \ + python3-sympy \ +" + +PACKAGECONFIG ??= "python sharedlib unittests" + +PACKAGECONFIG[python] = "\ + -DBUILD_ONNX_PYTHON=ON \ + -DPYTHON_LIBRARY=${PYTHON_LIBRARY} \ + -DPYTHON_INCLUDE_DIRS=${PYTHON_INCLUDE_DIR}, \ + -DBUILD_ONNX_PYTHON=OFF, \ + ${PYTHON_DEPENDS} \ +" + +PACKAGECONFIG[sharedlib] = "-DBUILD_SHARED_LIBS=ON, -D-DBUILD_SHARED_LIBS=OFF" +PACKAGECONFIG[unittests] = "-DONNX_BUILD_TESTS=ON, -DONNX_BUILD_TESTS=OFF, googletest" + +EXTRA_OECMAKE:append = " \ + -DONNX_CUSTOM_PROTOC_EXECUTABLE=${STAGING_BINDIR_NATIVE}/protoc \ + -DONNX_USE_PROTOBUF_SHARED_LIBS=ON \ + -DONNX_DISABLE_STATIC_REGISTRATION=ON \ + -DONNX_ML=1 \ + -DCMAKE_VERBOSE_MAKEFILE=ON \ + --log-level=VERBOSE \ +" + +inherit python3native cmake + +python do_build_version_file() { + import os + import textwrap + + version_file_path = os.path.join(d.getVar('B'), "onnx", "version.py") + os.makedirs(os.path.dirname(version_file_path), exist_ok=True) + with open(version_file_path, "w", encoding="utf-8") as f: + f.write( + textwrap.dedent( + f"""\ + # This file is generated. DO NOT EDIT! + + + version = "{d.getVar('PV')}" + git_version = "{d.getVar('SRCREV')}" + """ + ) + ) +} +addtask build_version_file before do_install after do_compile + +do_install:append() { + CP_ARGS="-Prf --preserve=mode,timestamps --no-preserve=ownership" + + # Install the Python package. + if ${@bb.utils.contains('PACKAGECONFIG', 'python', 'true', 'false', d)}; then + install -d ${D}${PYTHON_SITEPACKAGES_DIR}/onnx + (cd ${S}/onnx; cp --parents $(find . -name "*.py*") ${D}${PYTHON_SITEPACKAGES_DIR}/onnx) + cp $CP_ARGS ${B}/onnx ${D}${PYTHON_SITEPACKAGES_DIR} + cp $CP_ARGS ${B}/onnx_cpp2py_export.so ${D}${PYTHON_SITEPACKAGES_DIR}/onnx + fi +} + +# Add Python package +PACKAGE_BEFORE_PN += "${PYTHON_PN}-${PN}" +FILES:${PYTHON_PN}-${PN} += "${PYTHON_SITEPACKAGES_DIR}" +RDEPENDS:${PYTHON_PN}-${PN} += "${PYTHON_RDEPENDS} onnx" + +# Output library is unversioned +SOLIBS = ".so" +FILES_SOLIBSDEV = "" + +# TODO: ONNXConfig.cmake in package onnx-dev contains reference to TMPDIR +INSANE_SKIP:${PN}-dev = "buildpaths" -- 2.39.2 -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#15703): https://lists.yoctoproject.org/g/meta-arago/message/15703 Mute This Topic: https://lists.yoctoproject.org/mt/110658460/21656 Group Owner: [email protected] Unsubscribe: https://lists.yoctoproject.org/g/meta-arago/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
