Forums - Failed to convert YOLOv4 to DLC with SNPE

3 posts / 0 new
Last post
Failed to convert YOLOv4 to DLC with SNPE
kitongyam
Join Date: 20 Jul 22
Posts: 2
Posted: Wed, 2023-03-01 18:40

Hi there,I have a question about snpe-to-dlc.

I am trying to convert a YOLOv4 ONNX model to DLC using SNPE-1.51.0.2663, but I am encountering an error: 

$ snpe-onnx-to-dlc --input_network yolov4.onnx -d 'input.1' 1,3,416,416 -o yolov4onnx.dlc

Traceback (most recent call last):                 

......

KeyError: 'No translation registered for op type onnx_softplus. Op is most likely not supported by the converter.' 2023-03-01 17:20:43,608 - 183 - ERROR - Node /backbone/conv1/activation/Softplus: 'No translation registered for op type onnx_softplus. Op is most likely not supported by the converter.'

Afterward, I wrote a .json file for the Softplus layer to use as an option for UDO.

{

    "UdoPackage_0":

    {

        "Operators": [

            {

            "type": "Softplus",

                "inputs":[

                    {"name":"X", "data_type": "FLOAT_32", "quantization_mode": "TF"}

                ],

                "outputs":[

                    {"name":"Y","data_type": "FLOAT_32", "quantization_mode": "TF"}

                ],

                "core_types": ["DSP"]

            }

        ],

        "UDO_PACKAGE_NAME": "SoftplusUdoPackage"

    }

}

Then it throws an error:

/snpe-1.51.0.2663/lib/python/qti/aisw/converters/common/converter_ir/axis_tracker.py", line 142, in <listcomp>

    return [shape[i] for i in order]

IndexError: list index out of range

 

During handling of the above exception, another exception occurred:

 

Traceback (most recent call last):

                 ......

ValueError: Unable to permute shape [] to NSC ordering

2023-03-01 17:23:03,964 - 183 - ERROR - Node /backbone/conv1/activation/Mul: Unable to permute shape [] to NSC ordering

I tried to modify the .json file, but it didn't work. However, removing the Softplus layer from the model's network structure allows the successful conversion to DLC. Could you please advise me on how to modify my .json file? Or should I modify the network structure to change the activation function?

I appreciate any guidance you can provide.

 

  • Up0
  • Down0
sanjjey.a.sanjjey
Join Date: 17 May 22
Posts: 67
Posted: Fri, 2023-03-03 00:50

Hi,

I have also tried the same Softplus activation layer for the core type CPU.... Please check the below lines of snippets and change the core_types to DSP for your use and please let me know.

{ 

  "UdoPackage_0": { 

    "Operators": [ 

      { 

        "type": "Softplus", 

        "inputs": [ 

          { 

            "name": "Placeholder", "data_type": "FLOAT_32" 

          } 

        ], 

        "outputs": [ 

          { 

            "name": "output","data_type": "FLOAT_32" 

          } 

        ], 

        "core_types": [ 

          "CPU" 

        ] 

      } 

    ], 

    "UDO_PACKAGE_NAME": "SoftplusUdoPackage" 

  } 

}

 

After your UDO package gets successful, follow the syntax given below for DLC with UDO can be quantized with snpe-dlc-quantize.

snpe-dlc-quantize --input_dlc <model.dlc>

                  --input_list <input-list.txt>
                  --udo_package_path <udo-registration-lib>
                  --output_dlc <quantized-model.dlc>

 Thanks

  • Up0
  • Down0
kitongyam
Join Date: 20 Jul 22
Posts: 2
Posted: Sun, 2023-03-12 22:49

Dear sanjjey

Sorry for replying to you after such a long time.I made the changes to the JSON file as you suggested, and it worked. I'm curious about why 'name' was using 'Placeholder' though. I only saw it in one sample code file, and couldn't find any detailed guidance about it in the official documentation.

Thank you for taking the time to help me!

 

 

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.