<?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>topic How to add custom operators in tensorflow Lite? in eIQ Machine Learning Software</title>
    <link>https://community.nxp.com/t5/eIQ-Machine-Learning-Software/How-to-add-custom-operators-in-tensorflow-Lite/m-p/1311948#M381</link>
    <description>&lt;P&gt;Hi, we are trying to deploy the open-source object detection model (&amp;nbsp;&lt;A href="https://www.tensorflow.org/lite/examples/object_detection/overview" target="_blank" rel="noopener"&gt;https://www.tensorflow.org/lite/examples/object_detection/overview&lt;/A&gt;) on iMX.RT.1176 evk kit. We imported the tensorflow_lite_label_image example from the SDK v2.9.0. We have converted the object detection model .tflite file to c array using xxd. and replaced the model data and model length in the model_data.h file.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The object detection model contains custom operator TFLite_Detection_PostProcess as show below in the image.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ramson_0-1626930907325.png" style="width: 999px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/150563i8F457F3ED08E55B2/image-size/large?v=v2&amp;amp;px=999" role="button" title="Ramson_0-1626930907325.png" alt="Ramson_0-1626930907325.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;How to add the custom operator to the&amp;nbsp;tflite::MutableOpResolver ?&lt;/P&gt;&lt;P&gt;Since its not added, we are getting the following error:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;ERROR: Encountered unresolved custom op: TFLite_Detection_PostProcess.&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;ERROR: Node number 63 (TFLite_Detection_PostProcess) failed to prepare.&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Failed to allocate tensors!&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Failed initializing model&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Please help. Thanks in Advance&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ramson&lt;/P&gt;</description>
    <pubDate>Thu, 22 Jul 2021 10:50:47 GMT</pubDate>
    <dc:creator>Ramson</dc:creator>
    <dc:date>2021-07-22T10:50:47Z</dc:date>
    <item>
      <title>How to add custom operators in tensorflow Lite?</title>
      <link>https://community.nxp.com/t5/eIQ-Machine-Learning-Software/How-to-add-custom-operators-in-tensorflow-Lite/m-p/1311948#M381</link>
      <description>&lt;P&gt;Hi, we are trying to deploy the open-source object detection model (&amp;nbsp;&lt;A href="https://www.tensorflow.org/lite/examples/object_detection/overview" target="_blank" rel="noopener"&gt;https://www.tensorflow.org/lite/examples/object_detection/overview&lt;/A&gt;) on iMX.RT.1176 evk kit. We imported the tensorflow_lite_label_image example from the SDK v2.9.0. We have converted the object detection model .tflite file to c array using xxd. and replaced the model data and model length in the model_data.h file.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The object detection model contains custom operator TFLite_Detection_PostProcess as show below in the image.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ramson_0-1626930907325.png" style="width: 999px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/150563i8F457F3ED08E55B2/image-size/large?v=v2&amp;amp;px=999" role="button" title="Ramson_0-1626930907325.png" alt="Ramson_0-1626930907325.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;How to add the custom operator to the&amp;nbsp;tflite::MutableOpResolver ?&lt;/P&gt;&lt;P&gt;Since its not added, we are getting the following error:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;ERROR: Encountered unresolved custom op: TFLite_Detection_PostProcess.&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;ERROR: Node number 63 (TFLite_Detection_PostProcess) failed to prepare.&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Failed to allocate tensors!&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Failed initializing model&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Please help. Thanks in Advance&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ramson&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jul 2021 10:50:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/eIQ-Machine-Learning-Software/How-to-add-custom-operators-in-tensorflow-Lite/m-p/1311948#M381</guid>
      <dc:creator>Ramson</dc:creator>
      <dc:date>2021-07-22T10:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to add custom operators in tensorflow Lite?</title>
      <link>https://community.nxp.com/t5/eIQ-Machine-Learning-Software/How-to-add-custom-operators-in-tensorflow-Lite/m-p/1320963#M394</link>
      <description>&lt;P&gt;Hello Ramson,&lt;/P&gt;
&lt;P&gt;my first suggestion would be to move to SDK 2.10, as it contains all of the latest updates. With 2.10 we moved from TF Lite to TF Lite Micro, which is better optimized for MCUs. The inference engine still supports TF Lite models, it's just the computations and the library that are specifically optimized for ARM MCUs.&lt;/P&gt;
&lt;P&gt;Next, switch to the AllOpsResolver first, to make sure the operation is actually supported by TF Lite (Micro). If that works, then you can open the ops cpp file in the source/model folder, register all the required ops and remove all the unnecessary ones.&lt;/P&gt;
&lt;P&gt;If that fails, the only option left would be to implement or port an existing implementation of the operation into the tensorflow lite library.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;David&lt;/P&gt;</description>
      <pubDate>Tue, 10 Aug 2021 09:18:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/eIQ-Machine-Learning-Software/How-to-add-custom-operators-in-tensorflow-Lite/m-p/1320963#M394</guid>
      <dc:creator>david_piskula</dc:creator>
      <dc:date>2021-08-10T09:18:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to add custom operators in tensorflow Lite?</title>
      <link>https://community.nxp.com/t5/eIQ-Machine-Learning-Software/How-to-add-custom-operators-in-tensorflow-Lite/m-p/1328676#M406</link>
      <description>&lt;P&gt;Thanks for your suggestion&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/78209"&gt;@david_piskula&lt;/a&gt;&amp;nbsp;. Since the operator is not present. As you said i have ported the existing implementation of the operator. Thanks again&lt;/P&gt;</description>
      <pubDate>Tue, 24 Aug 2021 13:21:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/eIQ-Machine-Learning-Software/How-to-add-custom-operators-in-tensorflow-Lite/m-p/1328676#M406</guid>
      <dc:creator>Ramson</dc:creator>
      <dc:date>2021-08-24T13:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to add custom operators in tensorflow Lite?</title>
      <link>https://community.nxp.com/t5/eIQ-Machine-Learning-Software/How-to-add-custom-operators-in-tensorflow-Lite/m-p/1350029#M496</link>
      <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/78209"&gt;@david_piskula&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/189393"&gt;@Ramson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;suggested solution from me:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;source/model/model_mobilenet_ops.cpp&lt;/EM&gt; add:&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="cpp"&gt;#include "tensorflow/lite/kernels/custom_ops_register.h"&lt;/LI-CODE&gt;&lt;P&gt;and update resolver operations with (just add straight after existing &lt;EM&gt;&lt;STRONG&gt;resolver.AddBuiltin()&lt;/STRONG&gt;&lt;/EM&gt;&lt;LI-EMOJI id="lia_disappointed-face" title=":disappointed_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;resolver.AddCustom("TFLite_Detection_PostProcess", tflite::ops::custom::Register_TFLite_Detection_PostProcess());&lt;/LI-CODE&gt;&lt;UL&gt;&lt;LI&gt;&amp;nbsp;&lt;EM&gt;eiq/tensorflow-lite/tensorflow/lite/kernels/custom_ops_register.h&lt;/EM&gt; add:&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="cpp"&gt;TfLiteRegistration* Register_DETECTION_POSTPROCESS();
TfLiteRegistration* Register_TFLite_Detection_PostProcess() {
  return Register_DETECTION_POSTPROCESS();
}&lt;/LI-CODE&gt;&lt;P&gt;the same requirements as in first post, i.e. i.MXRT1170-EVK, SDK2.9.0, tensorflow_lite_label_image, model from &lt;A href="https://www.tensorflow.org/lite/examples/object_detection/overview" target="_blank" rel="noopener"&gt;https://www.tensorflow.org/lite/examples/object_detection/overview&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Oct 2021 12:30:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/eIQ-Machine-Learning-Software/How-to-add-custom-operators-in-tensorflow-Lite/m-p/1350029#M496</guid>
      <dc:creator>MarcinChelminsk</dc:creator>
      <dc:date>2021-10-04T12:30:31Z</dc:date>
    </item>
  </channel>
</rss>

