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.

EDGE-AI-STUDIO: Does tidlOnnxModelOptimize only supports models with single input?

Part Number: EDGE-AI-STUDIO
Other Parts Discussed in Thread: TDA4VM

Hi experts,

I am trying to import mobilestereonet model using edgeai-tidl-tools. However, when runing tidlOnnxModelOptimize, it returns that the model is invalid.

After examining the code, it seems that this function only supports single-input models:

Would you please help me if I want to import models with multiple inputs? We are working with customers who are developing stereo applications with AM62A.

  • Hi experts,

    I modified the code to support multi-input models. here is the patch

    diff --git a/scripts/osrt_model_tools/onnx_tools/onnx_model_opt.py b/scripts/osrt_model_tools/onnx_tools/onnx_model_opt.py
    index 0fa77b0..16e5f44 100644
    --- a/scripts/osrt_model_tools/onnx_tools/onnx_model_opt.py
    +++ b/scripts/osrt_model_tools/onnx_tools/onnx_model_opt.py
    @@ -85,25 +85,33 @@ def tidlOnnxModelOptimize(in_model_path, out_model_path, scaleList=[0.0078125,0.
         inDims = tuple([x.dim_value for x in originalGraph.input[0].type.tensor_type.shape.dim])
         outDims = tuple([x.dim_value for x in originalGraph.output[0].type.tensor_type.shape.dim])
     
    -    #Construct bias & scale tensors
    -    biasTensor = helper.make_tensor("TIDL_preProc_Bias",TensorProto.FLOAT,[1,nInCh, 1, 1],np.array(meanList,dtype=np.float32))
    -    scaleTensor = helper.make_tensor("TIDL_preProc_Scale",TensorProto.FLOAT,[1, nInCh, 1, 1],np.array(scaleList,dtype=np.float32))
    +    for i in range(len(originalGraph.input)):
    +        #Construct bias & scale tensors
    +        biasTensor = helper.make_tensor(originalGraph.input[i].name+"TIDL_preProc_Bias",TensorProto.FLOAT,[1,nInCh, 1, 1],np.array(meanList,dtype=np.float32))
    +        scaleTensor = helper.make_tensor(originalGraph.input[i].name+"TIDL_preProc_Scale",TensorProto.FLOAT,[1, nInCh, 1, 1],np.array(scaleList,dtype=np.float32))
     
    -    #Add these tensors to initList:
    -    initList.append(biasTensor)
    -    initList.append(scaleTensor)
    +        #Add these tensors to initList:
    +        initList.append(biasTensor)
    +        initList.append(scaleTensor)
     
         #Cast Node:
         attrib_dict = {"to":TensorProto.FLOAT}
    -    cast = onnx.helper.make_node('Cast',inputs=[originalGraph.input[0].name+"Net_IN"],outputs=['TIDL_cast_in'], **attrib_dict)
     
    -    #Add Node:
    -    addNode = onnx.helper.make_node('Add',inputs=["TIDL_cast_in","TIDL_preProc_Bias"],outputs=["TIDL_Scale_In"])
    +    inputList = []
    +    for i in range(len(originalGraph.input)):
    +        cast = onnx.helper.make_node('Cast',inputs=[originalGraph.input[i].name+"Net_IN"],outputs=[originalGraph.input[i].name+'TIDL_cast_in'], **attrib_dict)
     
    -    #Scale Node:
    -    scaleNode = onnx.helper.make_node('Mul',inputs=["TIDL_Scale_In","TIDL_preProc_Scale"],outputs=[originalGraph.input[0].name]) #Assumption that input[0].name is the input node
    +        #Add Node:
    +        addNode = onnx.helper.make_node('Add',inputs=[originalGraph.input[i].name+"TIDL_cast_in",originalGraph.input[i].name+"TIDL_preProc_Bias"],outputs=[originalGraph.input[i].name+"TIDL_Scale_In"])
     
    -    nodeList = [cast, addNode, scaleNode] + nodeList #Toplogically Sorted
    +        #Scale Node:
    +        scaleNode = onnx.helper.make_node('Mul',inputs=[originalGraph.input[i].name+"TIDL_Scale_In",originalGraph.input[i].name+"TIDL_preProc_Scale"],outputs=[originalGraph.input[i].name]) #Assumption that input[0].name is the input node
    +
    +        nodeList = [cast, addNode, scaleNode] + nodeList #Toplogically Sorted
    +
    +        inputSequence = [helper.make_tensor_value_info(originalGraph.input[i].name+'Net_IN', TensorProto.UINT8,inDims)]
    +
    +        inputList = inputList + inputSequence
     
         outSequence = originalGraph.output
         #Check for Argmax:
    @@ -117,11 +125,12 @@ def tidlOnnxModelOptimize(in_model_path, out_model_path, scaleList=[0.0078125,0.
                     nodeList = nodeList + [cast_out] #Toplogically Sorted
                     outSequence = [helper.make_tensor_value_info(originalGraph.output[0].name+'TIDL_cast_out', TensorProto.UINT8,outDims)]
     
    +
         #Construct Graph:
         newGraph = helper.make_graph(
             nodeList,
             'Rev_Model',
    -        [helper.make_tensor_value_info(originalGraph.input[0].name+"Net_IN", TensorProto.UINT8, inDims)],
    +        inputList,
             outSequence,
             initList
             )
    

    But I am encountering another problem from tidl import tool:

    I have read the thread from https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1062228/tda4vm-tidl-model-import-fails-if-network-has-more-than-one-input

    However, I can not find the place to set config like

    "inWidth = 128 128
    inHeight = 1024 1024
    inNumChannels = 3 3"

    What should I do next?

  • Hi experts

    The newest info is that the tidlOnnxModelOptimize gives valid model after my modification. 

    But I am facing problem as follows,

    Preliminary subgraphs created = 1 
    Final number of subgraphs created are : 1, - Offloaded Nodes - 1, Total Nodes - 1 
    
    Preliminary subgraphs created = 1 
    Final number of subgraphs created are : 1, - Offloaded Nodes - 1, Total Nodes - 1 
    Traceback (most recent call last):
      File "/home/ht/.pyenv/versions/3.10.13/lib/python3.10/runpy.py", line 196, in _run_module_as_main
        return _run_code(code, main_globals, None,
      File "/home/ht/.pyenv/versions/3.10.13/lib/python3.10/runpy.py", line 86, in _run_code
        exec(code, run_globals)
      File "/home/ht/.vscode/extensions/ms-python.python-2022.4.1/pythonFiles/lib/python/debugpy/__main__.py", line 45, in <module>
        cli.main()
      File "/home/ht/.vscode/extensions/ms-python.python-2022.4.1/pythonFiles/lib/python/debugpy/../debugpy/server/cli.py", line 444, in main
        run()
      File "/home/ht/.vscode/extensions/ms-python.python-2022.4.1/pythonFiles/lib/python/debugpy/../debugpy/server/cli.py", line 285, in run_file
        runpy.run_path(target_as_str, run_name=compat.force_str("__main__"))
      File "/home/ht/.pyenv/versions/3.10.13/lib/python3.10/runpy.py", line 289, in run_path
        return _run_module_code(code, init_globals, run_name,
      File "/home/ht/.pyenv/versions/3.10.13/lib/python3.10/runpy.py", line 96, in _run_module_code
        _run_code(code, mod_globals, init_globals,
      File "/home/ht/.pyenv/versions/3.10.13/lib/python3.10/runpy.py", line 86, in _run_code
        exec(code, run_globals)
      File "/home/ht/edgeai-tidl-tools/examples/osrt_python/ort/onnxrt_mobilestereonet.py", line 226, in <module>
        run_model('mobilestereonet', 0)
      File "/home/ht/edgeai-tidl-tools/examples/osrt_python/ort/onnxrt_mobilestereonet.py", line 197, in run_model
        sess = rt.InferenceSession(model_path ,providers=EP_list, provider_options=[delegate_options, {}], sess_options=so)
      File "/home/ht/.pyenv/versions/3.10.13/envs/tidltools/lib/python3.10/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 362, in __init__
        self._create_inference_session(providers, provider_options, disabled_optimizers)
      File "/home/ht/.pyenv/versions/3.10.13/envs/tidltools/lib/python3.10/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 410, in _create_inference_session
        sess.initialize_session(providers, provider_options, disabled_optimizers)
    onnxruntime.capi.onnxruntime_pybind11_state.Fail: [ONNXRuntimeError] : 1 : FAIL : Failed to add kernel for TIDL_0 com.microsoft TIDLExecutionProvider: Conflicting with a registered kernel with op versions.
    
    

    The model has been check in tidlOnnxModelOptimize by onnx.checher.check_model, sot there should not be dangling nodes. 

    And since the model has been regenerated after tidlOnnxModelOptimize, there should not be version conflicts or unregistered custom nodes. 

    What could be the possible causes for this problem?

    the model can be downloaded from 

    GitHub - ibaiGorordo/ONNX-MobileStereoNet: Python scripts for performing stereo depth estimation using the MobileStereoNet model in ONNX

  • Hello, 

    We received your question. The expert on this matter is traveling but we will try to get back to you with an answer. 

    Best regards,

  • Hi Adam,

    Thank you for your query. Could you please save the model resulting from the tidlOnnxModelOptimize call and post that file here, along with any artifacts/output files that may have been created (even if it didn't finish) for this model? There is an option called "debug_level" that is passed when running compilation as well, and I would recommend setting this to '2'. The default value is within edgeai-tidl-tools/examples/osrt_python/common_utils.py. You can also run `export TIDL_RT_DEBUG=1` in the calling environment for more debugging messages.

    I notice that there is only 1 subgraph with 1 nodes being recognized thus far. This is surprising as it should be a number of nodes >100 for most models.

    The failure you are seeing with "Failed to add kernel" is strange. I'm not familiar with it. Could you please print the version of onnxruntime on your development PC and share? We have a fork of onnxruntime, and it's possible that you have installed an upstream version  that does not include TI Deep Learning. The TI fork is installed for python when calling the setup.sh script. We generally recommend using a virtual environment like venv or conda for managing dependencies, although this requires you to activate the environment in a new terminal session

    "inWidth = 128 128
    inHeight = 1024 1024
    inNumChannels = 3 3"

    This is used with the TIDL RT (TIDL runtime) interface, which is available by calling "tidl_model_import.out" from the tidl_tools subdirectory. We primarily support the python interface for compiling, although older documentation should still apply here.

    Best,
    Reese

  • Hi Reese,

    Thank you for your help!

    The model after tidlOnnxModelOptimize is uploaded along with the incomplete artifacts.

    I am using pyenv to manage my environment and the environment is setup using setup.sh. 

    (tidltools) ht@ht-HP-EliteBook-830-G5:~/edgeai-tidl-tools/examples/osrt_python/ort$ pip list | grep onnx
    caffe2onnx               1.0.2
    onnx                     1.13.0
    onnxruntime-tidl         1.14.0
    

    After setting the debug level, here is the entire log:

    (tidltools) ht@ht-HP-EliteBook-830-G5:~/edgeai-tidl-tools/examples/osrt_python/ort$ python3 onnxrt_mobilestereonet.py -c
    Available execution providers :  ['TIDLExecutionProvider', 'TIDLCompilationProvider', 'CPUExecutionProvider']
    
    Running_Model :  mobilestereonet  
    
    
    Running shape inference on model /home/ht/edgeai-tidl-tools/examples/osrt_python/ort/model_528_240_float32.onnx 
    
    Converted model is valid!
    tidl_tools_path                                 = /home/ht/edgeai-tidl-tools/tidl_tools 
    artifacts_folder                                = mobilestereo_artifacts/mobilestereonet/ 
    tidl_tensor_bits                                = 8 
    debug_level                                     = 3 
    num_tidl_subgraphs                              = 16 
    tidl_denylist                                   = 
    tidl_denylist_layer_name                        = 
    tidl_denylist_layer_type                         = 
    tidl_allowlist_layer_name                        = 
    model_type                                      =  
    tidl_calibration_accuracy_level                 = 7 
    tidl_calibration_options:num_frames_calibration = 2 
    tidl_calibration_options:bias_calibration_iterations = 5 
    mixed_precision_factor = -1.000000 
    model_group_id = 0 
    power_of_2_quantization                         = 2 
    ONNX QDQ Enabled                                = 0 
    enable_high_resolution_optimization             = 0 
    pre_batchnorm_fold                              = 1 
    add_data_convert_ops                          = 3 
    output_feature_16bit_names_list                 =  
    m_params_16bit_names_list                       =  
    reserved_compile_constraints_flag               = 1601 
    ti_internal_reserved_1                          = 
    
    
     ****** WARNING : Network not identified as Object Detection network : (1) Ignore if network is not Object Detection network (2) If network is Object Detection network, please specify "model_type":"OD" as part of OSRT compilation options******
    
    Supported TIDL layer type ---         Squeeze -- Squeeze_1017 
    
    Preliminary subgraphs created = 1 
    Final number of subgraphs created are : 1, - Offloaded Nodes - 1, Total Nodes - 1 
    Running runtimes graphviz - /home/ht/edgeai-tidl-tools/tidl_tools/tidl_graphVisualiser_runtimes.out mobilestereo_artifacts/mobilestereonet//allowedNode.txt mobilestereo_artifacts/mobilestereonet//tempDir/graphvizInfo.txt mobilestereo_artifacts/mobilestereonet//tempDir/runtimes_visualization.svg 
    
     ****** WARNING : Network not identified as Object Detection network : (1) Ignore if network is not Object Detection network (2) If network is Object Detection network, please specify "model_type":"OD" as part of OSRT compilation options******
    
    Supported TIDL layer type ---        Identity -- Identity_1018 
    
    Preliminary subgraphs created = 1 
    Final number of subgraphs created are : 1, - Offloaded Nodes - 1, Total Nodes - 1 
    Running runtimes graphviz - /home/ht/edgeai-tidl-tools/tidl_tools/tidl_graphVisualiser_runtimes.out mobilestereo_artifacts/mobilestereonet//allowedNode.txt mobilestereo_artifacts/mobilestereonet//tempDir/graphvizInfo.txt mobilestereo_artifacts/mobilestereonet//tempDir/runtimes_visualization.svg 
    Traceback (most recent call last):
      File "/home/ht/edgeai-tidl-tools/examples/osrt_python/ort/onnxrt_mobilestereonet.py", line 228, in <module>
        run_model('mobilestereonet', 0)
      File "/home/ht/edgeai-tidl-tools/examples/osrt_python/ort/onnxrt_mobilestereonet.py", line 198, in run_model
        sess = rt.InferenceSession(model_path_opt ,providers=EP_list, provider_options=[delegate_options, {}], sess_options=so)
      File "/home/ht/.pyenv/versions/tidltools/lib/python3.10/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 362, in __init__
        self._create_inference_session(providers, provider_options, disabled_optimizers)
      File "/home/ht/.pyenv/versions/tidltools/lib/python3.10/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 410, in _create_inference_session
        sess.initialize_session(providers, provider_options, disabled_optimizers)
    onnxruntime.capi.onnxruntime_pybind11_state.Fail: [ONNXRuntimeError] : 1 : FAIL : Failed to add kernel for TIDL_0 com.microsoft TIDLExecutionProvider: Conflicting with a registered kernel with op versions.
    
    

    I also tried with the older version by calling "tidl_model_import.out" from the tidl_tools subdirectory. Here is the log:

    ht@ht-HP-EliteBook-830-G5:~/test_tidl/test/out$ ./tidl_model_import.out tidl_import_regnetx1600.txt 
    ONNX Model (Proto) File  : model_528_240_float32_opt.onnx  
    TIDL Network File      : model_528_240_float32_tidl_net.bin  
    TIDL IO Info File      : model_528_240_float32_tidl_io_  
    Current ONNX OpSet Version   : 11  
     ONNX operator ReduceSum is not suported now..  By passing
    *** WARNING : Mul with constant tensor requires input dimensions of mul layer to be present as part of the network.      If present, this warning can be ignored. If not, please use open source runtimes offering to run this model or run shape inference on this model before executing import  *** 
    WARNING: Cannot read dims for variable input of Add/Mul operator, shape inference should be done on the model
    assuming 1D const input is channel broadcast, operator maps to BatchNorm Layer  ONNX operator If is not suported now..  By passing
     ONNX operator Equal is not suported now..  By passing
     ONNX operator Shape is not suported now..  By passing
    Error , Node 17134 : SIZES Input Tensor is not supported for Resize-11 operator
                    As a Workaround user can provide the resize factor using SCALES tensor 
                     instead of using SIZES. As an example instead of using 
                     interpolate(x, size=[W, H], mode='bilinear', align_corners=False)
                     user can use 
                     interpolate(x, scale_factor=(s1,s2), mode='bilinear', align_corners=False) 
                     where s1 and s2 are ratio of resize factor for width and height.
    
    *** WARNING : Code proceding with default resize ratio of 2 *** 
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator If is not suported now..  By passing
     ONNX operator Equal is not suported now..  By passing
     ONNX operator Shape is not suported now..  By passing
    Could not find const or initializer of layer Reshape_16952 !!!
    
    Unsupported Onnx import data type : 0 
    Could not find const or initializer of layer Reshape_16615 !!!
    
    Unsupported Onnx import data type : 0 
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
    Could not find const or initializer of layer Reshape_16278 !!!
    
    Unsupported Onnx import data type : 0 
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
    Could not find const or initializer of layer Reshape_15941 !!!
    
    Unsupported Onnx import data type : 0 
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
    Could not find const or initializer of layer Reshape_15604 !!!
    
    Unsupported Onnx import data type : 0 
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator If is not suported now..  By passing
    Could not find const or initializer of layer Reshape_15267 !!!
    
    Unsupported Onnx import data type : 0 
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator If is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Equal is not suported now..  By passing
    Could not find const or initializer of layer Reshape_14930 !!!
    
    Unsupported Onnx import data type : 0 
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator If is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Equal is not suported now..  By passing
    Could not find const or initializer of layer Reshape_14593 !!!
    
    Unsupported Onnx import data type : 0 
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator If is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Equal is not suported now..  By passing
     ONNX operator Shape is not suported now..  By passing
    Could not find const or initializer of layer Reshape_14256 !!!
    
    Unsupported Onnx import data type : 0 
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator If is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Equal is not suported now..  By passing
     ONNX operator Shape is not suported now..  By passing
    Could not find const or initializer of layer Reshape_13919 !!!
    
    Unsupported Onnx import data type : 0 
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator If is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Equal is not suported now..  By passing
     ONNX operator Shape is not suported now..  By passing
    Could not find const or initializer of layer Reshape_13582 !!!
    
    Unsupported Onnx import data type : 0 
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator If is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Equal is not suported now..  By passing
     ONNX operator Shape is not suported now..  By passing
    Could not find const or initializer of layer Reshape_13245 !!!
    
    Unsupported Onnx import data type : 0 
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator If is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Equal is not suported now..  By passing
     ONNX operator Shape is not suported now..  By passing
    Could not find const or initializer of layer Reshape_12908 !!!
    
    Unsupported Onnx import data type : 0 
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator If is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Equal is not suported now..  By passing
     ONNX operator Shape is not suported now..  By passing
    Could not find const or initializer of layer Reshape_12571 !!!
    
    Unsupported Onnx import data type : 0 
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Unsqueeze is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Expand is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator If is not suported now..  By passing
     ONNX operator Range is not suported now..  By passing
     ONNX operator Equal is not suported now..  By passing
     ONNX operator Shape is not suported now..  By passing
    ^C
    

    There are some unsupported versions reported. And I noticed there is IF layer in the model. Would the initial problem caused by unsupported logic operators?

    Regards,

    Adam

  • Hi Reese,

    To debug further more, I add print in each function possibly called.

    And I get the following log:

    TIDL_getSupportedNodesImport 
    TIDL_createOutputAdjacencyList 
    TIDL_createInputAdjacencyList 
    
     ****** WARNING : Network not identified as Object Detection network : (1) Ignore if network is not Object Detection network (2) If network is Object Detection network, please specify "model_type":"OD" as part of OSRT compilation options******
    
    TIDL_onnxAllowlistFusedLayers 
    TIDL_checkFusedCombinationSupported 
    TIDL_onnxAllowlistNode 
    TIDL_checkLayerInputDimConstraints 
    TIDL_onnxRtMapNode 
    Supported TIDL layer type ---         Squeeze -- Squeeze_1017 
    
    Preliminary subgraphs created = 1 
    optimizeGraphPartition 
    getSubgraphInfo 
    Final number of subgraphs created are : 1, - Offloaded Nodes - 1, Total Nodes - 1 
    TIDL_getGraphVisualizationInfo 
    Running runtimes graphviz - /home/ht/edgeai-tidl-tools/tidl_tools/tidl_graphVisualiser_runtimes.out mobilestereo_artifacts/mobilestereonet//allowedNode.txt mobilestereo_artifacts/mobilestereonet//tempDir/graphvizInfo.txt mobilestereo_artifacts/mobilestereonet//tempDir/runtimes_visualization.svg 
    TIDL_getSupportedNodesImport 
    TIDL_createOutputAdjacencyList 
    TIDL_createInputAdjacencyList 
    
     ****** WARNING : Network not identified as Object Detection network : (1) Ignore if network is not Object Detection network (2) If network is Object Detection network, please specify "model_type":"OD" as part of OSRT compilation options******
    
    TIDL_onnxAllowlistFusedLayers 
    TIDL_checkFusedCombinationSupported 
    TIDL_onnxAllowlistNode 
    TIDL_checkLayerInputDimConstraints 
    TIDL_onnxRtMapNode 
    Supported TIDL layer type ---        Identity -- Identity_1018 
    
    Preliminary subgraphs created = 1 
    optimizeGraphPartition 
    getSubgraphInfo 
    Final number of subgraphs created are : 1, - Offloaded Nodes - 1, Total Nodes - 1 
    
    

    Why is TIDL_getSupportedNodesImport called twice? Who is calling it? I think it may comes from what is written in TIDLCompilationProvider, so can you help debug the problem or send me a copy of the source code of TIDLCompilationProvider through email?

    Regards,

    Adam

  • Hi Adam,

    It looks like it runs that TIDL_getSupportedNodesImport for each layer, but I'm not entirely sure what the function call sequence is here. You can see into the import tool code by getting access to the firmware-builder (available through request link) and seeing the c7x-mma-tidl subdirectory of that package. One of our team members can approve your access. Reach out to me via email if it is not granted within a couple days, please!

    It does look like some of the network's layers are of unsupported types. See the list of supported layers here. Unsupported operators can cause issues. They typically are automatically identified and offload to arm, but I have seen some corner cases result in a software fault (e.g. bus error, seg fault) during compilation.

    And I noticed there is IF layer in the model.

    Is this "IF" an abbreviation for a layer or literally an 'if' (or decision) type of layer? Seeking clarification here because I am not familiar with this. You may want to add unsupported layers to the deny_list  by layer-type manually

    I didn't see the model or any partial artifacts in your post. Would you please include those again?

    Best,
    Reese

  • Hi Reese, 

    I have the firmware-builder and the screenshot of the code is from firmware builder tidl_onnxRtImport_RP.cpp. There is a comment  saying TIDL_getSupportedNodesImport is directly called from onnx runtime and I can not find anywhere this is called. IF layer refers to literally an 'if' operator. The model file is too large to upload and I will send you through email. 

    However, do we have any evaluated stereo depth estimation models available? I looked into our model zoo and only find depth estimation for single camera https://github.com/TexasInstruments/edgeai-modelzoo/tree/main/models/vision/depth_estimation

    Regards,

    Adam

  • Hi Adam,

    I received your email and I will provide more information as I view it.

    We have a fork of the onnxruntime; see here the TIDL execution provider. I see references to the function you mention in those files.

    I am also checking on any stereo depth estimation models, but I do not believe we have any available.

  • Hi Adam,

    Looking at this model, I'm concerned that it will not import well due to the number of the layers that are not supported. I see many groups of nodes with layers like If, Where, unsqueeze, etc. are being used. There are many instances of these layers, so delegating those unsupported layers to the CPU would exceed the number of subgraphs (16) that can be made for the accelerator. This model is very large (so large that Netron struggles to display and search for nodes within the model) as well. I think we will struggle to get this architecture accelerated well on the AM62A.

    I see in the runtime_visualizations.svg that there is only one node, an Identity being recognized, which I curiously cannot find within the network itself.

    Regarding other models, I understand that stereo depth neural networks often use 3D convolutions, which TIDL does not support. We have tried some stereo depth models in the past but found many do not perform as well as the result of DMPAC (depth and motion processing accelerator) that exists on devices like TDA4VM

    Best,
    Reese

  • Hi Reese,

    We have a fork of the onnxruntime; see here the TIDL execution provider

    Thanks for helping me find the source code.

    so large that Netron struggles to display and search for nodes within the model

    I have seen the same on my side, thus this model may not be able to imported to AM62A.

    We have tried some stereo depth models in the past

    Could you send me some tested models?