From: Andrew Davis <afd@ti.com>
To: Chirag Shilwant <c-shilwant@ti.com>, <meta-arago@lists.yoctoproject.org>
Cc: Denys Dmytriyenko <denys@konsulko.com>, Ryan Eatmon <reatmon@ti.com>
Subject: Re: [meta-arago][scarthgap/master][PATCH 5/6] meta-arago-extras: Add recipe for ONNX
Date: Tue, 21 Jan 2025 12:59:59 -0600 [thread overview]
Message-ID: <553b95fc-e905-485d-8a8d-cd25e9ca1e24@ti.com> (raw)
In-Reply-To: <1fd5c056-6311-4c74-bd75-706f82b7d189@ti.com>
On 1/18/25 1:48 PM, Chirag Shilwant wrote:
> Hi Andrew,
>
> On 17/01/25 05:55, Andrew Davis wrote:
>> 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 <afd@ti.com>
>> ---
>> ...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 <afd@ti.com>
>> +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 <afd@ti.com>
>> +---
>> + 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 \
>
>
>
> Nitpick,
>
> To have a consistency across the entire recipe,
> I think it would be better to use PYTHON_PN (as done at PACKAGE_BEFORE_PN)
> OR keep it static as python3 for all references
>
Good idea, seems most recipes just use "python3" and not PYTHON_PN, so I'll
switch to that. Better to be explicit on which python we need. (I just hope
we never have to deal with a python4 someday :D)
Andrew
>
> --
> Chirag
>
>
>
>> + 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"
next prev parent reply other threads:[~2025-01-21 19:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-17 0:25 [meta-arago][scarthgap/master][PATCH 0/6] Add ONNX Runtime Andrew Davis
2025-01-17 0:25 ` [meta-arago][scarthgap/master][PATCH 1/6] flatbuffers: Remove this recipe Andrew Davis
2025-01-17 0:25 ` [meta-arago][scarthgap/master][PATCH 2/6] meta-arago-extras: Add recipe for arm-compute-library Andrew Davis
2025-01-17 0:25 ` [meta-arago][scarthgap/master][PATCH 3/6] meta-arago-extras: Add recipe for Arm NN Andrew Davis
2025-01-17 0:25 ` [meta-arago][scarthgap/master][PATCH 4/6] meta-arago-extras: Backport abseil-cpp from meta-oe master Andrew Davis
2025-01-22 23:02 ` Denys Dmytriyenko
2025-01-23 15:49 ` Andrew Davis
2025-01-23 15:56 ` Ryan Eatmon
2025-01-23 16:28 ` Andrew Davis
2025-01-17 0:25 ` [meta-arago][scarthgap/master][PATCH 5/6] meta-arago-extras: Add recipe for ONNX Andrew Davis
2025-01-18 19:48 ` Chirag Shilwant
2025-01-21 18:59 ` Andrew Davis [this message]
2025-01-21 19:25 ` Denys Dmytriyenko
2025-01-22 16:30 ` Ryan Eatmon
2025-01-24 21:14 ` Andrew Davis
2025-01-17 0:25 ` [meta-arago][scarthgap/master][PATCH 6/6] meta-arago-extras: Add recipe for ONNX Runtime Andrew Davis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=553b95fc-e905-485d-8a8d-cd25e9ca1e24@ti.com \
--to=afd@ti.com \
--cc=c-shilwant@ti.com \
--cc=denys@konsulko.com \
--cc=meta-arago@lists.yoctoproject.org \
--cc=reatmon@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.