<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>eIQ Machine Learning Softwareのトピック[Gatesgarth 5.10] TFLite static library issue</title>
    <link>https://community.nxp.com/t5/eIQ-Machine-Learning-Software/Gatesgarth-5-10-TFLite-static-library-issue/m-p/1261905#M360</link>
    <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I've just successfully built the image and the SDK of the new imx-linux version (gatesgarth) and I'm having an issue compiling Tensorflow-Lite c++ apps within the new SDK environment.&lt;/P&gt;&lt;P&gt;Here is the basic Yocto config I used to build the "imx-image-full" image and its SDK in a docker container:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Build Configuration:
BB_VERSION           = "1.48.0"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "ubuntu-18.04"
TARGET_SYS           = "aarch64-poky-linux"
MACHINE              = "imx8mpevk"
DISTRO               = "fsl-imx-wayland"
DISTRO_VERSION       = "5.10-gatesgarth"
TUNE_FEATURES        = "aarch64 armv8a crc cortexa53 crypto"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once I try to compile a custom Tensorflow lite application within the SDK, lots of linker errors show up such as this one:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;/home/user/gatesgarth_sdk/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/10.2.0/real-ld: /home/user/gatesgarth_sdk/sysroots/cortexa53-crypto-poky-linux/usr/lib/libtensorflow-lite.a(transpose_conv.cc.o): in function `ruy::Kernel&amp;lt;(ruy::Path)32, signed char, signed char, int, int&amp;gt;::Run(ruy::PMat&amp;lt;signed char&amp;gt; const&amp;amp;, ruy::PMat&amp;lt;signed char&amp;gt; const&amp;amp;, ruy::MulParams&amp;lt;int, int&amp;gt; const&amp;amp;, int, int, int, int, ruy::Mat&amp;lt;int&amp;gt;*) const':
/usr/src/debug/tensorflow-lite/2.4.0-r0/build/ruy/ruy/kernel_arm.h:123: undefined reference to `ruy::Kernel8bitNeonDotprodInOrder(ruy::KernelParams8bit&amp;lt;8, 8&amp;gt; const&amp;amp;)'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Most of the "undefined reference" errors are related to RUY functions that Tensorflow Lite uses so it seems that somehow these functions are missing in the static library (libtensorflow-lite.a - 179M). The app compilation command is based on the indications described in the i.MX Machine Learning User's Guide document:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$CC label_image.cc bitmap_helpers.cc ../../tools/evaluation/utils.cc \
-I=/usr/include/tensorflow/lite/tools/make/downloads/flatbuffers/include \
-I=/usr/include/tensorflow/lite/tools/make/downloads/absl \ -O1 -DTFLITE_WITHOUT_XNNPACK
-ltensorflow-lite -lstdc++ -lpthread -lm -ldl -lrt&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Even using a very simplified code, the errors show up when performing this basic declaration:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;tflite::ops::builtin::BuiltinOpResolver resolver;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've checked the "tensorflow-lite_2.4.0.bb" file used to build Tensorflow Lite for the "gatesgarth" yocto distribution and the following flags are explicitly specified:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;EXTRA_OECMAKE = "-DTFLITE_ENABLE_XNNPACK=on -DTFLITE_ENABLE_RUY=on -DTFLITE_ENABLE_NNAPI=on  ${S}/tensorflow/lite/"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, seems that RUY is enabled when compiling the static library but it does not work when compiling apps with it.&lt;/P&gt;&lt;P&gt;Any ideas of what it might be happening? I did not have this issue in the older "zeus" SDK.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;</description>
    <pubDate>Wed, 14 Apr 2021 09:54:31 GMT</pubDate>
    <dc:creator>danmartzla</dc:creator>
    <dc:date>2021-04-14T09:54:31Z</dc:date>
    <item>
      <title>[Gatesgarth 5.10] TFLite static library issue</title>
      <link>https://community.nxp.com/t5/eIQ-Machine-Learning-Software/Gatesgarth-5-10-TFLite-static-library-issue/m-p/1261905#M360</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I've just successfully built the image and the SDK of the new imx-linux version (gatesgarth) and I'm having an issue compiling Tensorflow-Lite c++ apps within the new SDK environment.&lt;/P&gt;&lt;P&gt;Here is the basic Yocto config I used to build the "imx-image-full" image and its SDK in a docker container:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Build Configuration:
BB_VERSION           = "1.48.0"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "ubuntu-18.04"
TARGET_SYS           = "aarch64-poky-linux"
MACHINE              = "imx8mpevk"
DISTRO               = "fsl-imx-wayland"
DISTRO_VERSION       = "5.10-gatesgarth"
TUNE_FEATURES        = "aarch64 armv8a crc cortexa53 crypto"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once I try to compile a custom Tensorflow lite application within the SDK, lots of linker errors show up such as this one:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;/home/user/gatesgarth_sdk/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/10.2.0/real-ld: /home/user/gatesgarth_sdk/sysroots/cortexa53-crypto-poky-linux/usr/lib/libtensorflow-lite.a(transpose_conv.cc.o): in function `ruy::Kernel&amp;lt;(ruy::Path)32, signed char, signed char, int, int&amp;gt;::Run(ruy::PMat&amp;lt;signed char&amp;gt; const&amp;amp;, ruy::PMat&amp;lt;signed char&amp;gt; const&amp;amp;, ruy::MulParams&amp;lt;int, int&amp;gt; const&amp;amp;, int, int, int, int, ruy::Mat&amp;lt;int&amp;gt;*) const':
/usr/src/debug/tensorflow-lite/2.4.0-r0/build/ruy/ruy/kernel_arm.h:123: undefined reference to `ruy::Kernel8bitNeonDotprodInOrder(ruy::KernelParams8bit&amp;lt;8, 8&amp;gt; const&amp;amp;)'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Most of the "undefined reference" errors are related to RUY functions that Tensorflow Lite uses so it seems that somehow these functions are missing in the static library (libtensorflow-lite.a - 179M). The app compilation command is based on the indications described in the i.MX Machine Learning User's Guide document:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$CC label_image.cc bitmap_helpers.cc ../../tools/evaluation/utils.cc \
-I=/usr/include/tensorflow/lite/tools/make/downloads/flatbuffers/include \
-I=/usr/include/tensorflow/lite/tools/make/downloads/absl \ -O1 -DTFLITE_WITHOUT_XNNPACK
-ltensorflow-lite -lstdc++ -lpthread -lm -ldl -lrt&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Even using a very simplified code, the errors show up when performing this basic declaration:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;tflite::ops::builtin::BuiltinOpResolver resolver;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've checked the "tensorflow-lite_2.4.0.bb" file used to build Tensorflow Lite for the "gatesgarth" yocto distribution and the following flags are explicitly specified:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;EXTRA_OECMAKE = "-DTFLITE_ENABLE_XNNPACK=on -DTFLITE_ENABLE_RUY=on -DTFLITE_ENABLE_NNAPI=on  ${S}/tensorflow/lite/"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, seems that RUY is enabled when compiling the static library but it does not work when compiling apps with it.&lt;/P&gt;&lt;P&gt;Any ideas of what it might be happening? I did not have this issue in the older "zeus" SDK.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 09:54:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/eIQ-Machine-Learning-Software/Gatesgarth-5-10-TFLite-static-library-issue/m-p/1261905#M360</guid>
      <dc:creator>danmartzla</dc:creator>
      <dc:date>2021-04-14T09:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: [Gatesgarth 5.10] TFLite static library issue</title>
      <link>https://community.nxp.com/t5/eIQ-Machine-Learning-Software/Gatesgarth-5-10-TFLite-static-library-issue/m-p/1283915#M368</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;For the L5.10.9_1.0.0 and L5.4.70_2.3.2 releases, the tensorflow-lite library is built as static. This causes object files (and symbols from them) which are dependencies of tensorflow-lite (ruy, absl, flatbuffers...) to be excluded. The solution is to compile tensorflow-lite library as dynamic to force the compiler to resolve the symbols at runtime.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;On&lt;/SPAN&gt;e can compile the dynamic version of libtensorflow-lite following the steps below. Refer to the attached archive containing the yocto recipes and use the version corresponding to the appropriate release.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;In the YOCTO build folder, overwrite the content of the 'sources/meta-imx' folder.&lt;/LI&gt;
&lt;LI&gt;Clean build tensorflow-lite&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE class="lia-code-sample  language-markup"&gt;&lt;CODE&gt;bitbake -f -c cleanall tensorflow-lite
bitbake -f -c compile tensorflow-lite&lt;/CODE&gt;&lt;/PRE&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;NOTE&lt;/STRONG&gt;: the lib should be successfully generated at this point, check:&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;---&amp;gt; 5.4.70_2.3.2: $YOCTO_BUILD_ROOT/build-xwayland/tmp/work/aarch64-poky-linux/tensorflow-lite/2.4.0-r0/build/libtensorflow-lite.so&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ---&amp;gt; 5.10.9_1.0.0: $YOCTO_BUILD_ROOT/build-xwayland/tmp/work/cortexa53-crypto-poky-linux/tensorflow-lite/2.4.0-r0/build/libtensorflow-lite.so&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Generate the toolchain: 'bitbake -c populate_sdk imx-image-full'&lt;/LI&gt;
&lt;LI&gt;Install the toolchain using the script at '$YOCTO_BUILD_ROOT/build-xwayland/tmp/deploy/sdk'&lt;BR /&gt;&lt;STRONG&gt;NOTE&lt;/STRONG&gt;: The lib should be included in the toolchain at this point, check:&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;---&amp;gt; 5.4.70_2.3.2: $YOCTO_SDK_ROOT/sysroots/aarch64-poky-linux/usr/lib/&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;---&amp;gt; 5.10.9_1.0.0: $YOCTO_SDK_ROOT/sysroots/cortexa53-crypto-poky-linux/usr/lib&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Copy the appropriate ‘libtensorflow-lite.so’ in the Yocto toolchain install:
&lt;P&gt;&amp;nbsp; &amp;nbsp; ---&amp;gt; 5.4.70_2.3.2: $YOCTO_SDK_ROOT/sysroots/aarch64-poky-linux/usr/lib/&lt;/P&gt;
&amp;nbsp; &amp;nbsp; ---&amp;gt; 5.10.9_1.0.0: $YOCTO_SDK_ROOT/sysroots/cortexa53-crypto-poky-linux/usr/lib&lt;/LI&gt;
&amp;nbsp;
&lt;LI&gt;Rebuild the app:&lt;BR /&gt;
&lt;PRE class="lia-code-sample  language-markup"&gt;&lt;CODE&gt;$CC label_image.cc bitmap_helpers.cc -o label_image ../../tools/evaluation/utils.cc -I=/usr/include/tensorflow/lite/tools/make/downloads/flatbuffers/include -I=/usr/include/tensorflow/lite/tools/make/downloads/absl -O1 -DTFLITE_WITHOUT_XNNPACK -ltensorflow-lite -lstdc++ -lpthread -lm -ldl -lrt​&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Build will be successful, the binary that is generated is ‘label_image’&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Deploy on the board in ‘/usr/bin/tensorflow-lite-2.4.0/examples':&lt;BR /&gt;
&lt;UL&gt;
&lt;LI&gt;The label_image that was just compiled (overwrite or rename the existing one)&lt;/LI&gt;
&lt;LI&gt;The ‘libtensorflow-lite.so'. Create symbolic link with version: ‘ln -s libtensorflow-lite.so libtensorflow-lite.so.2.4.0’&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;PRE class="lia-code-sample  language-markup"&gt;&lt;CODE&gt;$: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.​&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;Run the application&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;BR /&gt;&lt;FONT size="4" color="#339966"&gt;&lt;STRONG&gt;NOTE&lt;/STRONG&gt;: this issue will be fixed in the next YOCTO BSP release L5.10.9_2.0.0&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 May 2021 06:35:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/eIQ-Machine-Learning-Software/Gatesgarth-5-10-TFLite-static-library-issue/m-p/1283915#M368</guid>
      <dc:creator>raluca_popa</dc:creator>
      <dc:date>2021-05-28T06:35:48Z</dc:date>
    </item>
    <item>
      <title>Re: [Gatesgarth 5.10] TFLite static library issue</title>
      <link>https://community.nxp.com/t5/eIQ-Machine-Learning-Software/Gatesgarth-5-10-TFLite-static-library-issue/m-p/1287461#M371</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;Thank you so much for your answer. This workaround worked well and now I can compile TFLite 2.4.0 apps. Thank you again.&lt;/P&gt;&lt;P&gt;However, now I'm having the following messages when executing the apps with TFLite 2.x models:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;INFO: Created TensorFlow Lite delegate for NNAPI.
ERROR: ModifyGraphWithDelegate is disallowed when graph is immutable.
ERROR: Ignoring failed application of the default TensorFlow Lite delegate indexed at 0.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Despite of these "errors", the inference finishes well but I'm not sure whether this is affecting the model performance. Running the already pre-compiled "label_image" (with the TFLite static library) in the Yocto image does not show this error when using the same models. Yet, the average inference time is almost the same in both.&lt;/P&gt;&lt;P&gt;Furthermore, now it does not shows warnings referencing NNAPI non-compatible layers/operations. These layers (RESIZE_BILINEAR, LEAKY_RELU, ...) are still not compatible because they are still segmented according to the "benchmark_model" operation profiling logs.&lt;/P&gt;&lt;P&gt;Thank you again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jun 2021 10:15:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/eIQ-Machine-Learning-Software/Gatesgarth-5-10-TFLite-static-library-issue/m-p/1287461#M371</guid>
      <dc:creator>danmartzla</dc:creator>
      <dc:date>2021-06-04T10:15:41Z</dc:date>
    </item>
  </channel>
</rss>

