Forums - SNPE error when using 'snpe-net-run-udl'

8 posts / 0 new
Last post
SNPE error when using 'snpe-net-run-udl'
yanbophx
Join Date: 16 Oct 17
Posts: 17
Posted: Fri, 2018-01-12 02:49

Dear SNPE developers,

I've found such a problem when running my dlc file that contains udl layers using snpe-net-run-udl. see below for the error log:

------------------------------------------------------------------------------

UdlMyCustomScale::setup() of name conv1_1/negative
UdlMyCustomScale::setup() input size dim: 3686400, output: 3686400
UdlMyCustomScale::setup() got blob size 81
UdlMyCustomScale::setup() invalid weights
UdlMyCustomScale::close()
UdlMyCustomScale::close()
UdlMyCustomScale::close()
UdlMyCustomScale::close()
...

error_code=1103; error_message=UDL setup failed. Failed to set up successfully for layer conv1_1/negative; error_component=User-defined Layer; line_no=179; thread_id=140663334301568

-----------------------------------------------------------------------------------

For further information, the dlc file was created successfully using a prototxt file and a caffemodel. The prototxt file contains MyCustomScale layers that were made according to the tutorial. The dlc file can also be viewed using 'snpe-dlc-ino -i mydlc.dlc'.

snpe-net-run-udl was also created without flagging out any errors, and it can run the example of mnist.

In your opinion, what would be the cause for the error I encountered and what could be the solution to correct this issue?

Thanks very much!

Best regards,

 

  • Up0
  • Down0
yanbophx
Join Date: 16 Oct 17
Posts: 17
Posted: Tue, 2018-01-16 16:33

Dear SNPE team,

Would you please have a look at this post and point me to the right direction? Thanks very much

Best regards,

  • Up0
  • Down0
yanbophx
Join Date: 16 Oct 17
Posts: 17
Posted: Thu, 2018-02-01 04:04

Don't want to be a pest, but find no other way to get this message noticed by SNPE team rather than reply to my own post...

Dear SNPE team, just wonder if you've read this post or not? Your reply will be very much appreciated!

 

  • Up0
  • Down0
tingfan.wu
Join Date: 1 Aug 16
Posts: 3
Posted: Fri, 2018-02-02 12:03

If you read the source code

Quote:

    if (m_Params.weights_dim.size() != 1
            or m_Params.weights_dim[0] != inszdim) {
        std::cerr << "UdlMyCustomScale::setup() invalid weights" << std::endl;
        return false;
    }

You'll get error when inszdim != weights_dim[0]

Apparently your blob size 81 is way smaller than the input size 3686400

which lead to the error.

Either you need to fix the input dim or change the weight (specify by the blob)

 

-Tingfan

Umbo Computer Vision Inc

  • Up0
  • Down0
yanbophx
Join Date: 16 Oct 17
Posts: 17
Posted: Sun, 2018-02-04 19:36

Hi TIngfan,

Thanks so much for your reply. This is indeed very helpful!

Would you please share more thoughts on this topic as I am still baffled by other related cases in using UDL.

If I run the UDL example in SNPE tutorial , i.e., adding MyCustomScale layer to MNIST model, no error messges popped out. In this case, for the MyCustomScale layer, the blob_size is 2017 and the input dims are 500 (see below).  Apparently 2017 is not equal to 500, does this mean the blob_size can be equal or smaller than out dims?

---------------------------------------------------------------

UdlMyCustomScale::Setup() of name scale
UdlMyCustomScale::Setup() input size dim: 500, output: 500
UdlMyCustomScale::Setup() got blob size 2017

---------------------------------------------------------------

Am I correct in treating blob_size as a parameter predefined in caffemodel file whereas input and output dims are parameters specified in prototxt file? When creating the dlc file, how would the caffemodel and weights be matched? Thanks again for your time on this topic.

Best regards,

  • Up0
  • Down0
yanbophx
Join Date: 16 Oct 17
Posts: 17
Posted: Sun, 2018-02-04 19:41

Hi TIngfan,

Thanks so much for your reply. This is indeed very helpful!

Would you please share more thoughts on this topic as I am still baffled by other related cases in using UDL.

If I run the UDL example in SNPE tutorial , i.e., adding MyCustomScale layer to MNIST model, no error messges popped out. In this case, for the MyCustomScale layer, the blob_size is 2017 and the input dims are 500 (see below).  Apparently 2017 is not equal to 500, does this mean the blob_size can be greater or equal than in/out dims?

---------------------------------------------------------------

UdlMyCustomScale::Setup() of name scale
UdlMyCustomScale::Setup() input size dim: 500, output: 500
UdlMyCustomScale::Setup() got blob size 2017

---------------------------------------------------------------

Am I correct in treating blob_size as a parameter predefined in caffemodel file whereas input and output dims are parameters specified in prototxt file? When creating the dlc file, how would the caffemodel and weights be matched? Thanks again for your time on this topic.

Best regards,

  • Up0
  • Down0
tingfan.wu
Join Date: 1 Aug 16
Posts: 3
Posted: Mon, 2018-02-05 08:53

You may want to read this function in udlCustomLayer.cpp to understand the relationship between blobs and weight size.

 

bool UdlMyCustomScale::ParseMyCustomLayerParams(const void* buffer, size_t size,

            MyCustomScaleParams& params) {

 

    size_t r_size = size;

    uint8_t* r_buffer = (uint8_t*) buffer;

 

    // weights_dim

    // packing order:

    //   uint32_t containing # elements

    //   uint32_t[] containing values

    if(r_size < sizeof(uint32_t)) return false;

    uint32_t num_dims = *reinterpret_cast<uint32_t*>(r_buffer);

    r_size -= sizeof(uint32_t);

    r_buffer += sizeof(uint32_t);

 

    if(r_size < num_dims*sizeof(uint32_t)) return false;

    uint32_t* dims = reinterpret_cast<uint32_t*>(r_buffer);

    params.weights_dim = std::vector<uint32_t>(dims, dims+num_dims);

    r_size -= num_dims*sizeof(uint32_t);

    r_buffer += num_dims*sizeof(uint32_t);

 

    // weights_data

    // packing order:

    //   uint32_t containing # elements

    //   float[] containins values

    if(r_size < sizeof(uint32_t)) return false;

    uint32_t num_weights = *reinterpret_cast<uint32_t*>(r_buffer);

    r_size -= sizeof(uint32_t);

    r_buffer += sizeof(uint32_t);

 

    if(r_size < num_weights*sizeof(float)) return false;

    float* weights = reinterpret_cast<float*>(r_buffer);

    params.weights_data = std::vector<float>(weights, weights+num_weights);

    r_size -= num_weights*sizeof(float);

    r_buffer += num_weights*sizeof(float);

 

    return r_size == 0;

*/

}

  • Up0
  • Down0
yanbophx
Join Date: 16 Oct 17
Posts: 17
Posted: Mon, 2018-02-12 01:01

Thanks, Tingfan.

We actually realized that it was the size of the weights in this layers doesn't match the size of inputs. 

In caffe, we only need to assign weights for channels, and under the same channel, all the elments (size of height by width) share the same weight, which was not supported by SNPE custom scale layer by default. We got it right by tweaking the source code.

Cheers

 

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