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.
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>
Thanks
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!