diff mbox series

[meta-tensorflow] tensorflow-lite: package headers

Message ID 20250913173840.3216545-1-skandigraun@gmail.com
State New
Headers show
Series [meta-tensorflow] tensorflow-lite: package headers | expand

Commit Message

Gyorgy Sarvari Sept. 13, 2025, 5:38 p.m. UTC
The headers are not packages with tensorflow-lite, making it not easy to
compile any applications using them.

This patch copies the headers from the source and output folder to
the includedir.

The patch was derived from the content of a pre-compiled tflite package[1],
and from compilation error messages that were returned by rpicam-apps
recipe (which uses this recipe as an optional dependency)

[1]: https://github.com/prepkg/tensorflow-lite-raspberrypi/releases/tag/2.20.0

Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
---
 .../tensorflow/tensorflow-lite_2.19.0.bb      | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)

Comments

Martin Jansa Nov. 13, 2025, 5:18 p.m. UTC | #1
Why should tensorflow-lite provide header files from flatbuffers,
cannot it use system headers from flatbuffers recipe? This breaks a
build for recipes which depend on both tensorflow-lite and flatbuffers
because of conflicts in RSS as in:
ERROR: foo-1.0-r0 do_prepare_recipe_sysroot: The file
/usr/include/flatbuffers/array.h is installed by both tensorflow-lite
and flatbuffers, aborting

I can send a patch to remove them (I have it locally).

On Sat, Sep 13, 2025 at 7:38 PM Gyorgy Sarvari via
lists.yoctoproject.org <skandigraun=gmail.com@lists.yoctoproject.org>
wrote:
>
> The headers are not packages with tensorflow-lite, making it not easy to
> compile any applications using them.
>
> This patch copies the headers from the source and output folder to
> the includedir.
>
> The patch was derived from the content of a pre-compiled tflite package[1],
> and from compilation error messages that were returned by rpicam-apps
> recipe (which uses this recipe as an optional dependency)
>
> [1]: https://github.com/prepkg/tensorflow-lite-raspberrypi/releases/tag/2.20.0
>
> Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
> ---
>  .../tensorflow/tensorflow-lite_2.19.0.bb      | 23 +++++++++++++++++++
>  1 file changed, 23 insertions(+)
>
> diff --git a/recipes-framework/tensorflow/tensorflow-lite_2.19.0.bb b/recipes-framework/tensorflow/tensorflow-lite_2.19.0.bb
> index 14a538a..786507e 100644
> --- a/recipes-framework/tensorflow/tensorflow-lite_2.19.0.bb
> +++ b/recipes-framework/tensorflow/tensorflow-lite_2.19.0.bb
> @@ -114,6 +114,29 @@ do_install() {
>          ${D}${datadir}/label_image
>
>
> +    # install the headers also
> +    cd ${S}
> +    for header in `find ./tensorflow/lite -type f -name *.h`; do
> +        install -D -m 0644 $header ${D}${includedir}/$header
> +    done
> +
> +    for header in `find ./tensorflow/compiler/mlir -type f -name *.h`; do
> +        install -D -m 0644 $header ${D}${includedir}/$header
> +    done
> +
> +    for header in `find ./tensorflow/core/public -type f -name *.h`; do
> +        install -D -m 0644 $header ${D}${includedir}/$header
> +    done
> +    cd -
> +
> +    cd ${WORKDIR}/bazel/output_base/external/flatbuffers/include
> +    for header in `find ./flatbuffers -type f`; do
> +        install -D -m 0644 $header ${D}${includedir}/$header
> +    done
> +    cd -
> +
> +    # header installation done
> +
>      #echo "Installing pip package"
>      install -d ${D}/${PYTHON_SITEPACKAGES_DIR}
>      ${STAGING_BINDIR_NATIVE}/pip3 install --disable-pip-version-check -v \
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#2186): https://lists.yoctoproject.org/g/yocto-patches/message/2186
> Mute This Topic: https://lists.yoctoproject.org/mt/115226423/3617156
> Group Owner: yocto-patches+owner@lists.yoctoproject.org
> Unsubscribe: https://lists.yoctoproject.org/g/yocto-patches/leave/13388836/3617156/66960823/xyzzy [martin.jansa@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
Gyorgy Sarvari Nov. 13, 2025, 6:40 p.m. UTC | #2
On 11/13/25 18:18, Martin Jansa via lists.yoctoproject.org wrote:
> Why should tensorflow-lite provide header files from flatbuffers,
> cannot it use system headers from flatbuffers recipe? This breaks a
> build for recipes which depend on both tensorflow-lite and flatbuffers
> because of conflicts in RSS as in:
> ERROR: foo-1.0-r0 do_prepare_recipe_sysroot: The file
> /usr/include/flatbuffers/array.h is installed by both tensorflow-lite
> and flatbuffers, aborting
>
> I can send a patch to remove them (I have it locally).

Hmmmm... that was a very long time ago, hard to remember the details... 

If there is a flatbuffers recipe, I guess it would be usable, and most
likely you are right, it would be more appropriate instead of this.
I remember I added this for libamera-apps in meta-rpi - I can test it
tomorrow and ping back, if that would be okay for you.

> On Sat, Sep 13, 2025 at 7:38 PM Gyorgy Sarvari via
> lists.yoctoproject.org <skandigraun=gmail.com@lists.yoctoproject.org>
> wrote:
>> The headers are not packages with tensorflow-lite, making it not easy to
>> compile any applications using them.
>>
>> This patch copies the headers from the source and output folder to
>> the includedir.
>>
>> The patch was derived from the content of a pre-compiled tflite package[1],
>> and from compilation error messages that were returned by rpicam-apps
>> recipe (which uses this recipe as an optional dependency)
>>
>> [1]: https://github.com/prepkg/tensorflow-lite-raspberrypi/releases/tag/2.20.0
>>
>> Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
>> ---
>>  .../tensorflow/tensorflow-lite_2.19.0.bb      | 23 +++++++++++++++++++
>>  1 file changed, 23 insertions(+)
>>
>> diff --git a/recipes-framework/tensorflow/tensorflow-lite_2.19.0.bb b/recipes-framework/tensorflow/tensorflow-lite_2.19.0.bb
>> index 14a538a..786507e 100644
>> --- a/recipes-framework/tensorflow/tensorflow-lite_2.19.0.bb
>> +++ b/recipes-framework/tensorflow/tensorflow-lite_2.19.0.bb
>> @@ -114,6 +114,29 @@ do_install() {
>>          ${D}${datadir}/label_image
>>
>>
>> +    # install the headers also
>> +    cd ${S}
>> +    for header in `find ./tensorflow/lite -type f -name *.h`; do
>> +        install -D -m 0644 $header ${D}${includedir}/$header
>> +    done
>> +
>> +    for header in `find ./tensorflow/compiler/mlir -type f -name *.h`; do
>> +        install -D -m 0644 $header ${D}${includedir}/$header
>> +    done
>> +
>> +    for header in `find ./tensorflow/core/public -type f -name *.h`; do
>> +        install -D -m 0644 $header ${D}${includedir}/$header
>> +    done
>> +    cd -
>> +
>> +    cd ${WORKDIR}/bazel/output_base/external/flatbuffers/include
>> +    for header in `find ./flatbuffers -type f`; do
>> +        install -D -m 0644 $header ${D}${includedir}/$header
>> +    done
>> +    cd -
>> +
>> +    # header installation done
>> +
>>      #echo "Installing pip package"
>>      install -d ${D}/${PYTHON_SITEPACKAGES_DIR}
>>      ${STAGING_BINDIR_NATIVE}/pip3 install --disable-pip-version-check -v \
>>
>>
>>
>>
>>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#2542): https://lists.yoctoproject.org/g/yocto-patches/message/2542
> Mute This Topic: https://lists.yoctoproject.org/mt/115226423/6084445
> Group Owner: yocto-patches+owner@lists.yoctoproject.org
> Unsubscribe: https://lists.yoctoproject.org/g/yocto-patches/leave/14038302/6084445/1344600526/xyzzy [skandigraun@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
Gyorgy Sarvari Nov. 14, 2025, 6:49 a.m. UTC | #3
Apparently the latest version of libcamera for rpi (or at least its
dependency, libpisp) doesn't compile anymore with the master branch...
from my end please feel free to modify tf-lite as you wish. 

Thanks for noticing the issue.

On 11/13/25 19:40, Gyorgy Sarvari via lists.yoctoproject.org wrote:
> On 11/13/25 18:18, Martin Jansa via lists.yoctoproject.org wrote:
>> Why should tensorflow-lite provide header files from flatbuffers,
>> cannot it use system headers from flatbuffers recipe? This breaks a
>> build for recipes which depend on both tensorflow-lite and flatbuffers
>> because of conflicts in RSS as in:
>> ERROR: foo-1.0-r0 do_prepare_recipe_sysroot: The file
>> /usr/include/flatbuffers/array.h is installed by both tensorflow-lite
>> and flatbuffers, aborting
>>
>> I can send a patch to remove them (I have it locally).
> Hmmmm... that was a very long time ago, hard to remember the details... 
>
> If there is a flatbuffers recipe, I guess it would be usable, and most
> likely you are right, it would be more appropriate instead of this.
> I remember I added this for libamera-apps in meta-rpi - I can test it
> tomorrow and ping back, if that would be okay for you.
>
>> On Sat, Sep 13, 2025 at 7:38 PM Gyorgy Sarvari via
>> lists.yoctoproject.org <skandigraun=gmail.com@lists.yoctoproject.org>
>> wrote:
>>> The headers are not packages with tensorflow-lite, making it not easy to
>>> compile any applications using them.
>>>
>>> This patch copies the headers from the source and output folder to
>>> the includedir.
>>>
>>> The patch was derived from the content of a pre-compiled tflite package[1],
>>> and from compilation error messages that were returned by rpicam-apps
>>> recipe (which uses this recipe as an optional dependency)
>>>
>>> [1]: https://github.com/prepkg/tensorflow-lite-raspberrypi/releases/tag/2.20.0
>>>
>>> Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
>>> ---
>>>  .../tensorflow/tensorflow-lite_2.19.0.bb      | 23 +++++++++++++++++++
>>>  1 file changed, 23 insertions(+)
>>>
>>> diff --git a/recipes-framework/tensorflow/tensorflow-lite_2.19.0.bb b/recipes-framework/tensorflow/tensorflow-lite_2.19.0.bb
>>> index 14a538a..786507e 100644
>>> --- a/recipes-framework/tensorflow/tensorflow-lite_2.19.0.bb
>>> +++ b/recipes-framework/tensorflow/tensorflow-lite_2.19.0.bb
>>> @@ -114,6 +114,29 @@ do_install() {
>>>          ${D}${datadir}/label_image
>>>
>>>
>>> +    # install the headers also
>>> +    cd ${S}
>>> +    for header in `find ./tensorflow/lite -type f -name *.h`; do
>>> +        install -D -m 0644 $header ${D}${includedir}/$header
>>> +    done
>>> +
>>> +    for header in `find ./tensorflow/compiler/mlir -type f -name *.h`; do
>>> +        install -D -m 0644 $header ${D}${includedir}/$header
>>> +    done
>>> +
>>> +    for header in `find ./tensorflow/core/public -type f -name *.h`; do
>>> +        install -D -m 0644 $header ${D}${includedir}/$header
>>> +    done
>>> +    cd -
>>> +
>>> +    cd ${WORKDIR}/bazel/output_base/external/flatbuffers/include
>>> +    for header in `find ./flatbuffers -type f`; do
>>> +        install -D -m 0644 $header ${D}${includedir}/$header
>>> +    done
>>> +    cd -
>>> +
>>> +    # header installation done
>>> +
>>>      #echo "Installing pip package"
>>>      install -d ${D}/${PYTHON_SITEPACKAGES_DIR}
>>>      ${STAGING_BINDIR_NATIVE}/pip3 install --disable-pip-version-check -v \
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#2543): https://lists.yoctoproject.org/g/yocto-patches/message/2543
> Mute This Topic: https://lists.yoctoproject.org/mt/115226423/6084445
> Group Owner: yocto-patches+owner@lists.yoctoproject.org
> Unsubscribe: https://lists.yoctoproject.org/g/yocto-patches/leave/14038302/6084445/1344600526/xyzzy [skandigraun@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
diff mbox series

Patch

diff --git a/recipes-framework/tensorflow/tensorflow-lite_2.19.0.bb b/recipes-framework/tensorflow/tensorflow-lite_2.19.0.bb
index 14a538a..786507e 100644
--- a/recipes-framework/tensorflow/tensorflow-lite_2.19.0.bb
+++ b/recipes-framework/tensorflow/tensorflow-lite_2.19.0.bb
@@ -114,6 +114,29 @@  do_install() {
         ${D}${datadir}/label_image
 
 
+    # install the headers also
+    cd ${S}
+    for header in `find ./tensorflow/lite -type f -name *.h`; do
+        install -D -m 0644 $header ${D}${includedir}/$header
+    done
+
+    for header in `find ./tensorflow/compiler/mlir -type f -name *.h`; do
+        install -D -m 0644 $header ${D}${includedir}/$header
+    done
+
+    for header in `find ./tensorflow/core/public -type f -name *.h`; do
+        install -D -m 0644 $header ${D}${includedir}/$header
+    done
+    cd -
+
+    cd ${WORKDIR}/bazel/output_base/external/flatbuffers/include
+    for header in `find ./flatbuffers -type f`; do
+        install -D -m 0644 $header ${D}${includedir}/$header
+    done
+    cd -
+
+    # header installation done
+
     #echo "Installing pip package"
     install -d ${D}/${PYTHON_SITEPACKAGES_DIR}
     ${STAGING_BINDIR_NATIVE}/pip3 install --disable-pip-version-check -v \