This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SK-AM62A-LP: TFlite face detection model with Model Analyzer

Part Number: SK-AM62A-LP

Tool/software:

I am planning to develop for AM62Ax, and now I'm running the Model Analyzer.

I tried to compile the custom model. The model I'm currently using is "face_detection_front_128_integer_quant.tflite", which can be obtained from following URL:
https://s3.ap-northeast-2.wasabisys.com/pinto-model-zoo/030_BlazeFace/resources.tar.gz

I have checked that this model works fine on the CPU. I have tried compiling it several times based on the example notebook, but the compilation failed with following errors:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[3], line 1
----> 1 interpreter = tflite.Interpreter(model_path=tflite_model_path, experimental_delegates=tidl_delegate)
      2 #interpreter = tflite.Interpreter(model_path=tflite_model_path)

File /usr/local/lib/python3.10/dist-packages/tflite_runtime/interpreter.py:489, in Interpreter.__init__(self, model_path, model_content, experimental_delegates, num_threads, experimental_op_resolver_type, experimental_preserve_all_tensors)
    487   self._delegates = experimental_delegates
    488   for delegate in self._delegates:
--> 489     self._interpreter.ModifyGraphWithDelegate(
    490         delegate._get_native_delegate_pointer())  # pylint: disable=protected-access
    491 #self._signature_defs = self.get_signature_list() #PC-- commented for now. Workaround. Needs to be added to interpreter_wrapper2
    493 self._metrics = metrics.TFLiteMetrics()

ValueError: basic_string::_M_create

or

---------------------------------------------------------------------------
MemoryError                               Traceback (most recent call last)
Cell In[6], line 1
----> 1 interpreter = tflite.Interpreter(model_path=tflite_model_path, experimental_delegates=tidl_delegate)
      2 #interpreter = tflite.Interpreter(model_path=tflite_model_path)

File /usr/local/lib/python3.10/dist-packages/tflite_runtime/interpreter.py:489, in Interpreter.__init__(self, model_path, model_content, experimental_delegates, num_threads, experimental_op_resolver_type, experimental_preserve_all_tensors)
    487   self._delegates = experimental_delegates
    488   for delegate in self._delegates:
--> 489     self._interpreter.ModifyGraphWithDelegate(
    490         delegate._get_native_delegate_pointer())  # pylint: disable=protected-access
    491 #self._signature_defs = self.get_signature_list() #PC-- commented for now. Workaround. Needs to be added to interpreter_wrapper2
    493 self._metrics = metrics.TFLiteMetrics()

MemoryError: std::bad_alloc

log:74862.custon-model-tfl_out.log

On the other hand, I was able to compile and run this model using EdgeAI-TIDL-tools 10_01 on Ubuntu 22.04.

Why does changing EdgeAI-tools to a newer one make the compilation successful? (I recognize that Model Analyzer use EdgeAI-tools 09_02 or 10_00 because SDK ver. is 9.2)
Is there any way to succeed the compilation of this models on the Model Analyzer?

Python code:

import sys
import time
import os
import cv2
import numpy as np
import tflite_runtime.interpreter as tflite
from utils import loggerWriter, plot_TI_performance_data, get_benchmark_output
from PIL import Image
import matplotlib.pyplot as plt

output_dir = 'face_detection_quant'
tflite_model_path = './face_detection_front_128_integer_quant.tflite'
debug_level = 0
num_bits = 8
accuracy = 1
compile_options = {
    'tidl_tools_path' : os.environ['TIDL_TOOLS_PATH'],
    'artifacts_folder' : output_dir,
    'tensor_bits' : num_bits,
    'accuracy_level' : accuracy,
    'debug_level' : debug_level,
    'advanced_options:calibration_frames' : 1,
    'advanced_options:calibration_iterations' : 3,
    'advanced_options:add_data_convert_ops' : 1,
}
os.makedirs(output_dir, exist_ok=True)
for root, dirs, files in os.walk(output_dir, topdown=False):
    [os.remove(os.path.join(root, f)) for f in files]
    [os.rmdir(os.path.join(root, d)) for d in dirs]

tidl_delegate = [tflite.load_delegate(os.path.join(os.environ['TIDL_TOOLS_PATH'], 'tidl_model_import_tflite.so'), compile_options)]
interpreter = tflite.Interpreter(model_path=tflite_model_path, experimental_delegates=tidl_delegate)


Thanks

Fumiya

  • My compilation failure was resolved.
    I noticed that the compilation process terminated when processing certain layers.

    Adding "'deny_list' : '2, 22'" to compile option leads to successful compilation.

    I faced another problem.
    All padding layer is operated on the CPU for the reason "Padding is only supported for width/height axes".
    The model has many padding layers, so running the model without offloading takes a long time.

    Can I modify the model so that the padding layers can be offloaded?

    Total Nodes = 90
    -------------------------------------------------------------------------------
    |          Core           |      No. of Nodes       |   Number of Subgraphs   |
    -------------------------------------------------------------------------------
    | C7x                     |                      73 |                      12 |
    | CPU                     |                      17 |                       x |
    -------------------------------------------------------------------------------
    -------------------------------------------------------------------------------
    | Node |      Node Name     |                     Reason                      |
    -------------------------------------------------------------------------------
    | PAD  | channel_padding    | Padding is only supported for width/height axes |
    | PAD  | channel_padding_1  | Padding is only supported for width/height axes |
    | PAD  | channel_padding_2  | Padding is only supported for width/height axes |
    | PAD  | channel_padding_3  | Padding is only supported for width/height axes |
    | PAD  | channel_padding_4  | Padding is only supported for width/height axes |
    | PAD  | channel_padding_5  | Padding is only supported for width/height axes |
    | PAD  | channel_padding_6  | Padding is only supported for width/height axes |
    | PAD  | channel_padding_7  | Padding is only supported for width/height axes |
    | PAD  | channel_padding_8  | Padding is only supported for width/height axes |
    | PAD  | channel_padding_9  | Padding is only supported for width/height axes |
    | PAD  | channel_padding_10 | Padding is only supported for width/height axes |
    -------------------------------------------------------------------------------

  • Hi Fumiya,

    I am glad to hear that you already resolved the issue you are facing with the model analyzer. 

    Can I modify the model so that the padding layers can be offloaded?

    Depending on the layer which tries to implement the padding, you can update the model by adding a reshape layer before and after the padding layer so that the padding is still in the width/height access. 

    Please, let me know if this solution is feasible for you model.

    Best regards,

    Qutaiba

  • Hi Qutaiba,

    Thank you for your reply and information.
    It seems feasible.

    I investigated why compilation terminated during processing of Reshape layer.
    There seems to be two ways to specify the output shape of Reshape layer: as an attribute or as an input argument.

    https://github.com/tensorflow/tensorflow/issues/45150


    My model uses former, but it doesn't seems to be supported by TIDL import. The latter is supported.
    By modifying my model to use the latter way, it is no longer necessary to specify a Reshape layer for 'deny_layer'.

    Then I'll try your suggestion. The results will be reported later.

    Best regards,

    Fumiya

  • Hi Fumiya,

    Thank you for sharing the information. It is our pleasure to help when needed. 

    Best regards,

    Qutaiba

  • Sorry for the late reply.
    Following your suggestions, I was able to modify the model so that all layers are offloaded.

    However, the offloaded model returns unexpected results.
    This model runs fine on CPU, so I think my compilation settings are wrong.
    My modified models and the SVG file generated by the compilation: face_landmark_float32.zip

    My compilation setting:

    compile_options = {
        'tidl_tools_path' : os.environ['TIDL_TOOLS_PATH'],
        'artifacts_folder' : output_dir,
        'tensor_bits' : 16,
        'accuracy_level' : 9,
        'debug_level' : 2,
        'advanced_options:calibration_frames' : 1,
        'advanced_options:quantization_scale_type' : 4,
        'advanced_options:channel_wise_quantization' : 1,
    }

    Why the difference caused?

  • Hi Fumiya,

    Would you please consider the following:

    Best regards,

    Qutaiba

  • Hi Qutaiba,

    First, the model is working fine on the ARM (without delegate). The result of running in Model Analyzer is shown on the left side of the image below.

    Inference result

    Second, I changed options 'tensor_bits' and 'accuracy_level' to 32 and 1 respectively, remove 'quantization_scale_type' and 'channel_wise_quantization', and run on the PC. The result is bad. No landmarks are displayed.
    The log:

     ****** In DelegatePrepare ****** 
    
     Number of subgraphs:1 , 102 nodes delegated out of 102 nodes 
     
    
     ****** In tidlDelegate::Init ****** 
    ************ in TIDL_subgraphRtCreate ************ 
     The soft limit is 2048
    The hard limit is 2048
    MEM: Init ... !!!
    MEM: Init ... Done !!!
     0.0s:  VX_ZONE_INIT:Enabled
     0.2s:  VX_ZONE_ERROR:Enabled
     0.2s:  VX_ZONE_WARNING:Enabled
     0.1451s:  VX_ZONE_INIT:[tivxInit:190] Initialization Done !!!
    ************ TIDL_subgraphRtCreate done ************ 
     
     ****** tidlDelegate::Prepare ****** 
     Outputs Tensor name and id -  Identity, 187
     Outputs Tensor name and id -  Identity_1, 196
    
     ****** tidlDelegate::Invoke ****** 
    *******   In TIDL_subgraphRtInvoke  ******** 
       0         1.00000        -1.00000         1.00000 6
       1         1.00000        -7.97479         9.33212 6
       2         1.00000        -1.43239         9.33212 6
       3         1.00000       -13.30939         9.66169 6
       4         1.00000       -11.05363        13.25985 6
       5         1.00000       -11.41895        17.74536 6
       6         1.00000       -18.59906        29.40535 6
       7         1.00000       -38.11623        28.22294 6
       8         1.00000       -39.23745        30.54165 6
       9         1.00000       -48.80751        56.41211 6
      10         1.00000       -19.78234        30.54165 6
      11         1.00000       -25.63276        27.73870 6
      12         1.00000       -19.78234        30.54165 6
      13         1.00000       -19.78234        30.54165 6
      14         1.00000       -19.78234        30.54165 6
      15         1.00000       -19.78234        30.54165 6
      16         1.00000       -19.78234        30.54165 6
      17         1.00000       -19.78234        30.54165 6
      18         1.00000       -19.78234        30.54165 6
      19         1.00000       -26.70293        33.66907 6
      20         1.00000       -57.84758        39.84492 6
      21         1.00000       -44.76255        40.21832 6
      22         1.00000       -56.93438        53.78516 6
      23         1.00000      -102.90575        74.99529 6
      24         1.00000      -104.60571        96.54486 6
      25         1.00000      -135.97630       150.33002 6
      26         1.00000       -87.97967       114.49819 6
      27         1.00000       -37.64352       150.33002 6
      28         1.00000       -48.99615        51.72040 6
      29         1.00000       -37.64352       150.33002 6
      30         1.00000       -37.64352       150.33002 6
      31         1.00000       -37.64352       150.33002 6
      32         1.00000       -37.64352       150.33002 6
      33         1.00000       -37.64352       150.33002 6
      34         1.00000       -37.64352       150.33002 6
      35         1.00000       -37.64352       150.33002 6
      36         1.00000       -74.30220       145.97676 6
      37         1.00000      -100.92263       165.20627 6
      38         1.00000      -137.83380        97.45766 6
      39         1.00000      -188.48828       140.63069 6
      40         1.00000      -146.22244       114.28890 6
      41         1.00000      -118.94566       169.19005 6
      42         1.00000      -219.97311       220.86731 6
      43         1.00000      -280.10388       285.55164 6
      44         1.00000      -157.71802       220.86731 6
      45         1.00000      -218.25610       173.05484 6
      46         1.00000      -157.71802       220.86731 6
      47         1.00000      -157.71802       220.86731 6
      48         1.00000      -157.71802       220.86731 6
      49         1.00000      -157.71802       220.86731 6
      50         1.00000      -157.71802       220.86731 6
      51         1.00000      -157.71802       220.86731 6
      52         1.00000      -157.71802       220.86731 6
      53         1.00000      -266.95056       258.72241 6
      54         1.00000      -313.59680       279.52313 6
      55         1.00000      -260.43643       434.69089 6
      56         1.00000      -339.33197       444.56656 6
      57         1.00000      -511.49326       653.26202 6
      58         1.00000      -805.98981       775.96240 6
      59         1.00000      -802.19696       960.08081 6
      60         1.00000      -964.96735      1668.23401 6
      61         1.00000     -1517.87463      1960.92126 6
      62         1.00000      -470.08441       960.08081 6
      63         1.00000     -1454.57300      2290.22217 6
      64         1.00000     -3435.93994      2436.64795 6
      65         1.00000     -2093.72583      1642.01099 6
      66         1.00000     -2640.11865      3074.12158 6
      67         1.00000     -3875.51611      3990.32202 6
      68         1.00000     -2681.62744      4305.88916 6
      69         1.00000     -4407.52051      5297.74707 6
      70         1.00000     -4431.04883      6803.41650 6
      71         1.00000     -3662.72119      4147.81055 6
      72         1.00000     -6291.97363      8673.03223 6
      73         1.00000     -1848.86572      4394.84619 6
      74         1.00000     -2809.49707      5297.74707 6
      75         1.00000     -4322.80469      6465.26465 6
      76         1.00000     -5886.97607      5125.64648 6
      77         1.00000     -5047.37158      2593.31079 6
      78         1.00000     -6900.16992      8040.19727 6
      79         1.00000     -6606.71729      9530.79297 6
      80         1.00000     -5583.27979      5674.75342 6
      81         1.00000     -9422.40234      9290.05078 6
      82         1.00000     -3031.00684      2630.21313 6
      83         1.00000      -573.16150      2630.21313 6
      84         1.00000     -1906.13782      1750.81653 6
      85         1.00000     -2258.44165      1703.35608 6
      86         1.00000     -2495.21289      2882.88232 6
      87         1.00000    -19408.89258     22331.73047 6
      88         1.00000     -2944.20728      7217.48242 6
      89         1.00000     -2895.36572      2975.14209 6
      90         1.00000      -639.41663      2975.14209 6
      91         1.00000     -3042.58325      2860.23022 6
      92         1.00000     -4241.80371      2504.52417 6
      93         1.00000     -3092.73340      3485.20850 6
      94         1.00000     -7286.64160     27803.02539 6
      95         1.00000    -18599.34766     21512.75000 6
      96         1.00000     27803.02539     27803.02539 6
     Layer,   Layer Cycles,kernelOnlyCycles, coreLoopCycles,LayerSetupCycles,dmaPipeupCycles, dmaPipeDownCycles, PrefetchCycles,copyKerCoeffCycles,LayerDeinitCycles,LastBlockCycles, paddingTrigger,    paddingWait,LayerWithoutPad,LayerHandleCopy,   BackupCycles,  RestoreCycles,Multic7xContextCopyCycles,
         0,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
         1,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
         2,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
         3,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
         4,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
         5,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
         6,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
         7,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
         8,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
         9,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        10,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        11,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        12,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        13,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        14,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        15,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        16,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        17,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        18,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        19,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        20,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        21,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        22,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        23,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        24,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        25,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        26,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        27,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        28,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        29,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        30,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        31,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        32,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        33,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        34,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        35,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        36,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        37,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        38,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        39,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        40,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        41,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        42,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        43,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        44,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        45,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        46,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        47,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        48,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        49,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        50,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        51,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        52,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        53,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        54,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        55,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        56,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        57,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        58,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        59,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        60,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        61,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        62,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        63,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        64,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        65,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        66,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        67,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        68,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        69,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        70,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        71,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        72,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        73,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        74,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        75,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        76,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        77,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        78,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        79,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        80,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        81,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        82,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        83,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        84,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        85,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        86,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        87,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        88,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        89,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        90,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        91,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        92,              0,              0,              0,              0,              0,                 0,          i=0, 40203791
    Statistics : 
     Inferences Per Second   :   24.89 fps
     Inference Time Per Image :   40.18 ms  
     DDR BW Per Image        :  18446744073709.55 MB
        0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        93,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        94,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        95,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
        96,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
         0,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
         0,              0,              0,              0,              0,              0,                 0,              0,                 0,              0,              0,              0,              0,              0,              0,              0,              0,              0,
     Sum of Layer Cycles 0 
    Sub Graph Stats 44.000000 39869.000000 261.000000 
    *******  TIDL_subgraphRtInvoke done  ******** 
    ************ in ~tidlDelegate ************ 
     ************ in TIDL_subgraphRtDelete ************ 
     MEM: Deinit ... !!!
    MEM: Alloc's: 27 alloc's of 97065277 bytes 
    MEM: Free's : 27 free's  of 97065277 bytes 
    MEM: Open's : 0 allocs  of 0 bytes 
    MEM: Deinit ... Done !!!
    

    What do these results mean?

    Best regards,
    Fumiya

  • Hello Fumiya,

    I will step in from our side to help with accuracy 

    Can you confirm that you have the exact same input going into the network, both for TIDL (compiled with tensor_bits=32) and for standard Arm backend? If you are using edgeai-tidl-tools/example/osrt_python/tfl/tflrt_delegate.py, using the -d tag (disable_offload) will ensure this.

    • Otherwise, such a large difference in accuracy here suggests that our 32-bit floating point reference mode (i.e., tensor_bits=32) has an issue. We can expect any quantized version (tensor_bits=8 or 16) will also be wrong.

    ------------------------------------------------------------------------------------------------------------------------------------------------

    I notice that your model includes PreLU layers with a slope parameter. TIDL does not support this slope parameter for that layer type [0]. This seems the most likely culprit for accuracy issues. Since TIDL does not support slope, it will act like an ordinary RELU

    Is your model a pretrained network that you found online, or did you train yourself? It may be necessary to replace PRELU with another activation function, which would require retraining. You could try deny-listing those layers, but it will have huge impact on performance and negate most of the accelerator's performance lift. 

    I recall similar challenges faced with a face-mesh network from Google -- this looks like a similar model architecture

    Said another way, the PreLU layers in your model are not supported. These activations need to be replaced with another for TIDL to have suitable accuracy. Replacing activations generally requires retraining. 

    [0] https://github.com/TexasInstruments/edgeai-tidl-tools/blob/master/docs/supported_ops_rts_versions.md -- see PreLU

    BR,
    Reese

  • Hi Reese,

    It's sure that the input is the same.

    As you said, the model is based on the mediapipe face mesh model.
    I have made some modifications to it to avoid compilation errors.

    The training dataset of face-mesh doesn't seem to be available.
    Do I need to find a model that doesn't have PRELU layers?
    Or is there a way to run the model fine with TIDL?

    Best regards,
    Fumiya

  • Hello Fumiya, 

    Okay, that's what I suspected. This had caused similar challenge in the past (especially since Google has not published their dataset), and the developers I had worked with needed to find an alternate model, unfortunately. 

    Yes, you should find a model that does not include PreLU layers (or if they are included, slope parameter is not used). Since this is an activation function and used so many times in the network, we cannot designate it to run on Arm cores without huge performance penalty. I don't currently see a viable path to run this network in TIDL, until better support is added for this layer type.

    This is being investigated, but timeline on supporting this layer is not firm enough to be more specific. 

    BR,
    Reese

  • Hello Reese,

    Thank you for your help. I will try to find a model that meets requirements.

    Best regards,
    Fumiya