<?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 TFLite FullyConnected Layers on iMX8MPlus using NNAPI in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/TFLite-FullyConnected-Layers-on-iMX8MPlus-using-NNAPI/m-p/1475849#M191594</link>
    <description>&lt;P&gt;We are using the iMX8MPlus module and we are trying to deploy a self-developed tensorflow-lite model on the NPU.&lt;/P&gt;&lt;P&gt;The tf-lite version we are using is the lf-5.15.5_1.0.0 from source.codeaurora.org/external/imx/tensorflow-imx.git We are trying to use the NNAPI delegate to run the model on the NPU, sofar it works for all the convolutional layers, but the FULLY_CONNECTED layers are still having issues.&lt;/P&gt;&lt;P&gt;The error is shows is: Node 0 Operator Builtin Code 9 FULLY_CONNECTED (not delegated) and digging down the source code a bit deeper, we found it was failing in line if (builtin-&amp;gt;keep_num_dims) of the file nnapi_delegate.cc:&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;    case kTfLiteBuiltinFullyConnected: {
      ExpectMaxOpVersion(version, 5, &amp;amp;val_ctx);
      const auto output_type = context-&amp;gt;tensors[node-&amp;gt;outputs-&amp;gt;data[0]].type;
      Expect(output_type != kTfLiteInt16,
             NNAPIValidationFailureType::kUnsupportedOutputType,
             "Unsupported output of type kTfLiteInt16", &amp;amp;val_ctx);
      if (android_sdk_version &amp;lt; kMinSdkVersionForNNAPI12) {
        Expect(!IsHybridOperator(context, builtin_code, node),
               NNAPIValidationFailureType::kUnsupportedHybridOperator,
               "Hybrid operators not supported before NNAPI 1.2", &amp;amp;val_ctx);
        ExpectIsFloatOrUint8Operator(context, node, &amp;amp;val_ctx);
      }
      const auto input_type = context-&amp;gt;tensors[node-&amp;gt;inputs-&amp;gt;data[0]].type;
      if (android_sdk_version &amp;lt; kMinSdkVersionForNNAPI12 &amp;amp;&amp;amp;
          input_type == kTfLiteUInt8) {
        ExpectIsRestrictedScalesCompliant(context, node, &amp;amp;val_ctx);
      }
      auto builtin =
          reinterpret_cast&amp;lt;TfLiteFullyConnectedParams*&amp;gt;(node-&amp;gt;builtin_data);
      if (builtin-&amp;gt;keep_num_dims) {
        ExpectMinAndroidSdkVersion(android_sdk_version,
                                   kMinSdkVersionForNNAPI13, &amp;amp;val_ctx);
      }
    } break;&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;So if the flag keep_num_dims is true, then it requires a android sdk version of &amp;gt;= 30, whereas in this version of tf-lite (the NXP customized version) the android_sdk version is defined as 29.&lt;/P&gt;&lt;P&gt;We have been trying to figure out how to set the keep_num_dims flag in the model we are developing, however we cannot find much resource about it. Is there&amp;nbsp; any experience of someone else who has already faced such issue before?&lt;/P&gt;</description>
    <pubDate>Fri, 17 Jun 2022 08:42:39 GMT</pubDate>
    <dc:creator>khuang</dc:creator>
    <dc:date>2022-06-17T08:42:39Z</dc:date>
    <item>
      <title>TFLite FullyConnected Layers on iMX8MPlus using NNAPI</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/TFLite-FullyConnected-Layers-on-iMX8MPlus-using-NNAPI/m-p/1475849#M191594</link>
      <description>&lt;P&gt;We are using the iMX8MPlus module and we are trying to deploy a self-developed tensorflow-lite model on the NPU.&lt;/P&gt;&lt;P&gt;The tf-lite version we are using is the lf-5.15.5_1.0.0 from source.codeaurora.org/external/imx/tensorflow-imx.git We are trying to use the NNAPI delegate to run the model on the NPU, sofar it works for all the convolutional layers, but the FULLY_CONNECTED layers are still having issues.&lt;/P&gt;&lt;P&gt;The error is shows is: Node 0 Operator Builtin Code 9 FULLY_CONNECTED (not delegated) and digging down the source code a bit deeper, we found it was failing in line if (builtin-&amp;gt;keep_num_dims) of the file nnapi_delegate.cc:&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;    case kTfLiteBuiltinFullyConnected: {
      ExpectMaxOpVersion(version, 5, &amp;amp;val_ctx);
      const auto output_type = context-&amp;gt;tensors[node-&amp;gt;outputs-&amp;gt;data[0]].type;
      Expect(output_type != kTfLiteInt16,
             NNAPIValidationFailureType::kUnsupportedOutputType,
             "Unsupported output of type kTfLiteInt16", &amp;amp;val_ctx);
      if (android_sdk_version &amp;lt; kMinSdkVersionForNNAPI12) {
        Expect(!IsHybridOperator(context, builtin_code, node),
               NNAPIValidationFailureType::kUnsupportedHybridOperator,
               "Hybrid operators not supported before NNAPI 1.2", &amp;amp;val_ctx);
        ExpectIsFloatOrUint8Operator(context, node, &amp;amp;val_ctx);
      }
      const auto input_type = context-&amp;gt;tensors[node-&amp;gt;inputs-&amp;gt;data[0]].type;
      if (android_sdk_version &amp;lt; kMinSdkVersionForNNAPI12 &amp;amp;&amp;amp;
          input_type == kTfLiteUInt8) {
        ExpectIsRestrictedScalesCompliant(context, node, &amp;amp;val_ctx);
      }
      auto builtin =
          reinterpret_cast&amp;lt;TfLiteFullyConnectedParams*&amp;gt;(node-&amp;gt;builtin_data);
      if (builtin-&amp;gt;keep_num_dims) {
        ExpectMinAndroidSdkVersion(android_sdk_version,
                                   kMinSdkVersionForNNAPI13, &amp;amp;val_ctx);
      }
    } break;&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;So if the flag keep_num_dims is true, then it requires a android sdk version of &amp;gt;= 30, whereas in this version of tf-lite (the NXP customized version) the android_sdk version is defined as 29.&lt;/P&gt;&lt;P&gt;We have been trying to figure out how to set the keep_num_dims flag in the model we are developing, however we cannot find much resource about it. Is there&amp;nbsp; any experience of someone else who has already faced such issue before?&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2022 08:42:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/TFLite-FullyConnected-Layers-on-iMX8MPlus-using-NNAPI/m-p/1475849#M191594</guid>
      <dc:creator>khuang</dc:creator>
      <dc:date>2022-06-17T08:42:39Z</dc:date>
    </item>
  </channel>
</rss>

