Forums - diffrent result using uint8 and float as input

4 posts / 0 new
Last post
diffrent result using uint8 and float as input
danweil24
Join Date: 17 Nov 21
Posts: 12
Posted: Thu, 2022-03-10 01:32

Hey, I'm using user define buffer when running the snpe net in my 8350 DSP 

.

When I choose an uint8 input buffer and do: 

input x in float.

1) x-> (round(255(x-min)/range) , then clamping and casting to uint8

were min and range are taken from dlc (using snpe-dlc-info) after quantizing my net. 

and when I insert the input as float I get different results on some images. 

How does snpe casting float values to uint8 to run on DSP?

Is it the same as 1) and if so what could cause the difference?

and does the snpe doing the casting in DSP or CPU (the net is running of DSP)

Tnks. Dan 

  • Up0
  • Down0
weihuan
Join Date: 12 Apr 20
Posts: 270
Posted: Thu, 2022-03-31 01:37

Dear customer,

Regarding the computation for input tenfor from float to fixed point on SNPE, we will get the encoding from model info.

You can look at the sample from snpe sample code for how to compute the float tensor to fixed point.

The sample located at <SNPE_SDK>/examples/NativeCpp/SampleCode.

BR.

Wei

  • Up0
  • Down0
danweil24
Join Date: 17 Nov 21
Posts: 12
Posted: Thu, 2022-03-31 07:06

Dear Weihuan

Thanks for your response. As suggested, I looked into the snpe 1.6.0 examples code. I got the quantization info using

  snpe->getInputOutputBufferAttributes(name); 

When I use user define buffer as uint8 , I load the input buffer map exactly as in the example (the same process of translating float to uint8) but I get a different result (not much but still not bit-exact)  compared to using user definer buffer as USERBUFFER_FLOAT. 

Both running on DSP   . 

I load the input map when  USERBUFFER_FLOAT.using : 

std::memcpy(&applicationBuffers.at(name)[0], input_buf, input_size * sizeof(float));

So my question is when I use snpe->envoke on  USERBUFFER_FLOAT.  snpe lib does the same computation for me ? and is it in DSP or CPU?  

BR , Dan 

  • Up0
  • Down0
weihuan
Join Date: 12 Apr 20
Posts: 270
Posted: Sat, 2022-05-21 19:16

Dear customer,

The computing behavior is for processing the float for the CPU and DSP both if you input with format of USERBUFFER_FLOAT.

But SNPE will transfer to Fixed point if you run on DSP runtime even you input Float data.

BR.

Wei

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