Forums - snpe-caffe-to-dlc-udl does not work

8 posts / 0 new
Last post
snpe-caffe-to-dlc-udl does not work
mudria
Join Date: 25 Jun 17
Posts: 4
Posted: Thu, 2017-08-10 23:40

I followed User-Defined Layers (UDL) Tutorial which you support.

When I execute following command,

    python snpe-caffe-to-dlc-udl --caffe_txt blabla...

It gave me following error.

File "snpe-caffe-to-dlc-udl", line 104, in if not converter.set_udl_factory_func(udl_factory_func()): AttributeError: 'CaffeSnapDnnConverter' object has no attribute 'set_udl_factory_func'

It seems that I didn't mistakes.

  • Up0
  • Down0
moljaca moderator
Join Date: 25 Jul 17
Location: San Diego
Posts: 40
Posted: Fri, 2017-08-11 19:47

Hi,

Thank you for interest in Snapdragon NPE. 

It seems that snpe-caffe-to-dlc-udl example script in examples/Python/UDLExample somehow uses older version of udl interface. 

Could you please edit snpe-caffe-to-dlc-udl file and change line 104 to

if not converter.set_udls(udl_supported_types):

and give it a try?

Thanks

  • Up0
  • Down0
mudria
Join Date: 25 Jun 17
Posts: 4
Posted: Mon, 2017-08-21 00:50

Thank you for reply.

As you suggested, I modified line 104 in snpe-caffe-to-dlc-udl in snpe-1.2.2/examples/Python/UdlExample.

After that I tried again, but still different error occurs.

 

Traceback (most recent call last):

    File "snpe-caffe-to-dlc-udl", line 104, in <module>

        if not converter.set_udls(udl_supported_types):

    File "/home/myaccount/snpe-1.2.2/lib/python/snpe/snpe_caffe_to_dlc.py", line 881, in set_udls

        self._udl_factory_func[up] = layer_obj.getLayerCallback()

AttributeError: 'function' object has no attribute 'getLayerCallback'

 

Could you check this error one more time?

  • Up0
  • Down0
mudria
Join Date: 25 Jun 17
Posts: 4
Posted: Wed, 2017-08-23 19:49

 

I posted the error some days ago like below:

As you suggested, I modified line 104 in snpe-caffe-to-dlc-udl in snpe-1.2.2/examples/Python/UdlExample. After that I tried again, but still different error occurs. Traceback (most recent call last): File "snpe-caffe-to-dlc-udl", line 104, in if not converter.set_udls(udl_supported_types): File "/home/myaccount/snpe-1.2.2/lib/python/snpe/snpe_caffe_to_dlc.py", line 881, in set_udls self._udl_factory_func[up] = layer_obj.getLayerCallback() AttributeError: 'function' object has no attribute 'getLayerCallback'

 

Please check it and reply.

  • Up0
  • Down0
moljaca moderator
Join Date: 25 Jul 17
Location: San Diego
Posts: 40
Posted: Thu, 2017-08-24 13:48

Sorry for the dalay in replying. Yeah, UDL example code needs more debugging. We will try to resove it as soon as possible. Will let you know.

  • Up0
  • Down0
moljaca moderator
Join Date: 25 Jul 17
Location: San Diego
Posts: 40
Posted: Fri, 2017-08-25 10:08

Hi,

Please try the following workaround

Python UDL example needs to make use of Udl class, which is defined in snpe_caffe_to_dlc_utils.py
 
* In original examples/Python/UdlExample/snpe-caffe-to-dlc-udl file *
 
= At line 44,  just below "from snpe import snpe_caffe_to_dlc", insert the following 
 
from snpe.common import snpe_axis_transformer
AxisAnnotation = snpe_axis_transformer.AxisAnnotation
 
 
= At line 85, just above "udl_supported_types", insert the following
 
# Instance of Udl class for mycustomscale layer
udl_mycustomscale = snpe_caffe_to_dlc_utils.Udl(udl_mycustomscale_func)
 
# Add SNPE udl's expected input axis order for 3D input and its output axis order
udl_mycustomscale.addAxisOrder([AxisAnnotation.HEIGHT,AxisAnnotation.WIDTH,AxisAnnotation.CHANNEL],
                              [AxisAnnotation.HEIGHT,AxisAnnotation.WIDTH,AxisAnnotation.CHANNEL])
# Add SNPE udl's expected input axis order for 2D input and its output axis order
udl_mycustomscale.addAxisOrder([AxisAnnotation.HEIGHT,AxisAnnotation.WIDTH],
                              [AxisAnnotation.HEIGHT,AxisAnnotation.WIDTH])
# Add SNPE udl's expected input axis order for 1D input and its output axis order
udl_mycustomscale.addAxisOrder([AxisAnnotation.CHANNEL],
                              [AxisAnnotation.CHANNEL])
 
# As Caffe supports batch dimension, we have an additional dimension here
# Add Caffe udl's expected input axis order for 4D input and its output axis order
udl_mycustomscale.addSrcAxisOrder([AxisAnnotation.BATCH, AxisAnnotation.CHANNEL, AxisAnnotation.HEIGHT,AxisAnnotation.WIDTH],
                                 [AxisAnnotation.BATCH, AxisAnnotation.CHANNEL, AxisAnnotation.HEIGHT,AxisAnnotation.WIDTH])
# Add Caffe udl's expected input axis order for 3D input and its output axis order
udl_mycustomscale.addSrcAxisOrder( [AxisAnnotation.CHANNEL,AxisAnnotation.HEIGHT,AxisAnnotation.WIDTH],
                                  [AxisAnnotation.CHANNEL,AxisAnnotation.HEIGHT,AxisAnnotation.WIDTH])
# Add Caffe udl's expected input axis order for 2D input and its output axis order
udl_mycustomscale.addSrcAxisOrder([AxisAnnotation.BATCH, AxisAnnotation.CHANNEL],
                                 [AxisAnnotation.BATCH, AxisAnnotation.CHANNEL])
 
 
= At line 88,  inside "udl_supported_types", 
replace 
 
'MyCustomScale': udl_mycustomscale_func
 
with
 
'MyCustomScale': udl_mycustomscale
 
 
= At line 103,  
replace 
 
if not converter.set_udl_factory_func(udl_factory_func()):
 
with
 
if not converter.set_udls(udl_supported_types):
 
= Line 92, you can delete udl_factory_func() 
 
NOTE that provided axis transformation code is reflecting default axis ordering in SNPE and Caffe. If your user layer needs diffeent ordering you need to update the above example axis transformation code accordingly.
 
  • Up0
  • Down0
1024768334
Join Date: 7 Sep 17
Posts: 6
Posted: Tue, 2017-09-19 01:37

I have made the example worked as you suggested, but I have a question. In "udl-tutorial.html", there is a command "ndk-build" after command "make -f Makefile.x86_64-linux-clang" , however, this command cannot work with the error information "ndk-build: command not found". Does the problem affect it's run on android?

  • Up0
  • Down0
gesqdn-forum
Join Date: 4 Nov 18
Posts: 184
Posted: Tue, 2019-06-25 05:20

Hi,
The "ndk-build: command not found" error is due to unavailability of the executable in the PATH mentioned. Kindly update the PATH with the source path of "ndk-build".

For example:  $ exportATH=/home/jin Pka/Android/Sdk/android-ndk-r11c:$PATH

  • 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.