Forums - Add upsample layer with UDL

1 post / 0 new
Add upsample layer with UDL
shantou08
Join Date: 9 Sep 20
Posts: 2
Posted: Wed, 2020-09-09 18:56
SNPE SDK version is 1.40.0.2130.
I want to add upsample layer in my caffe model.
>>>>
In file my_udl_layers.py, add like following:
......
import caffe_custom_upsample_udl
......
    udl_mycustomupsample = snpe_udl_utils.Udl(layer_callback=caffe_custom_upsample_udl.udl_mycustomupsample_func,
                                           expected_axes_orders=[
                                            (  # input dims
                                             # [AxisTracker.AxisAnnotations.BATCH, AxisTracker.AxisAnnotations.CHANNEL,
                                              # AxisTracker.AxisAnnotations.HEIGHT, AxisTracker.AxisAnnotations.WIDTH],
                                             [AxisTracker.AxisAnnotations.BATCH, AxisTracker.AxisAnnotations.HEIGHT,
                                              AxisTracker.AxisAnnotations.WIDTH, AxisTracker.AxisAnnotations.CHANNEL],
                                             # output dims
                                             # [AxisTracker.AxisAnnotations.BATCH, AxisTracker.AxisAnnotations.CHANNEL,
                                              # AxisTracker.AxisAnnotations.HEIGHT, AxisTracker.AxisAnnotations.WIDTH]
                                             [AxisTracker.AxisAnnotations.BATCH, AxisTracker.AxisAnnotations.HEIGHT,
                                              AxisTracker.AxisAnnotations.WIDTH, AxisTracker.AxisAnnotations.CHANNEL]
                                            )
                                           ])
......
 
>>>>
In file caffe_custom_upsample_udl.py, add like following:
......
def udl_mycustomupsample_func(layer, weight_provider, input_dims):
    """
    Conversion callback function for MyCustomUpsample layer
    """
    # Initialize blob for our custom layer with the wrapper class
    blob = UdlBlobMyCustomUpsample(layer, weight_provider)
    scale = int(layer.upsample_param.scale)
    #output_dims = [[input_dims[0][0], input_dims[0][2] * scale, input_dims[0][3] * scale, input_dims[0][1]]]
    output_dims = [[input_dims[0][0], input_dims[0][1], input_dims[0][2] * scale, input_dims[0][3] * scale]]
    print('output_dims = ', output_dims)
    
    return snpe_udl_utils.UdlBlobOutput(blob=blob, out_dims=output_dims)
 
......
 
Am I right? Please give some advice. Input dims is [N, C, H, W]. My question is how to set output dims, [N, C, H, W] or [N, H, W, C] ?
 
 
  • Up0
  • Down0

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.