Forums - The running result of DSP is incorrect

3 posts / 0 new
Last post
The running result of DSP is incorrect
373303429
Join Date: 22 Jan 21
Posts: 4
Posted: Sun, 2022-05-29 02:39

I did a very simple test about DSP quantization model.

1. this is my simple pytorch model:

class Net(nn.Module):

    def __init__(self, show=False):
        super(Net, self).__init__()
        self.relu = nn.ReLU()
        self.avg_pool = nn.AdaptiveAvgPool2d(1)
        OUTPUT_DIM = 40
        self.fc1 = nn.Linear(10, OUTPUT_DIM, bias=False)
        nn.init.constant_(self.fc1.weight, 1.)
        self.conv0 = nn.Conv2d(3,10,1,1,padding=0,bias=True)
 
    def forward(self, x): # (1,3,20,20)
        x = self.conv0(x)
        x = self.relu(x)
        x = self.avg_pool(x)
        x = torch.flatten(x, 1)
        x = x * x
        x = self.fc1(x)
        return x

 

2. And i use AIMET to export quant model

dummy_input = torch.rand((1,3,20,20))
quantsim.export("./aimet_quat/", "tmp", dummy_input, onnx_params)
 
 
3. Convert onnx to DLC
./snpe-onnx-to-dlc --input_network tmp.onnx --output_path tmp.dlc --quantization_overrides tmp.encodings
./snpe-dlc-quantize --input_dlc tmp.dlc --input_list tmp_file.txt --output_dlc tmp_quat_aimet.dlc --override_params
 
 
4.Run the model on DSP

./snpe-net-run --container /sdcard/tmp_quat_aimet.dlc --input_list /sdcard/tmp_file_android.txt --use_dsp --debug

 

5.Result

FP32 pytorch model:

tensor([[0.2879, 0.2879, 0.2879, 0.2879, 0.2879, 0.2879, 0.2879, 0.2879, 0.2879,
         0.2879, 0.2879, 0.2879, 0.2879, 0.2879, 0.2879, 0.2879, 0.2879, 0.2879,
         0.2879, 0.2879, 0.2879, 0.2879, 0.2879, 0.2879, 0.2879, 0.2879, 0.2879,
         0.2879, 0.2879, 0.2879, 0.2879, 0.2879, 0.2879, 0.2879, 0.2879, 0.2879,
         0.2879, 0.2879, 0.2879, 0.2879]], grad_fn=<AddmmBackward>)
 
DSP:
logits.raw
(40,)
[0.28776518 0.28776518 0.28776518 0.28776518 0.28776518 0.28776518
 0.28776518 0.28776518 0.28776518 0.28776518 0.28776518 0.28776518
 0.28776518 0.28776518 0.28776518 0.28776518 0.28776518 0.28776518
 0.28776518 0.28776518 0.28776518 0.28776518 0.28776518 0.28776518
 0.28776518 0.28776518 0.28776518 0.28776518 0.28776518 0.28776518
 0.28776518 0.28776518 0.         0.         0.         0.
 0.         0.         0.         0.        ]
 
 
 
I checked the results of each layer on the DSP and found that the problem was in the Linear layer.
Only the first 32 were correct, which made me very confused
This problem is very bad. I'm not sure if I did something wrong. I hope I can get advice as soon as possible
 

 

 

 

 

 

  • Up0
  • Down0
weihuan
Join Date: 12 Apr 20
Posts: 270
Posted: Sun, 2022-05-29 05:24

Dear customer,

Which SNPE version and SOC you tested? We will release an SNPE UI tools for those model accuracy issues later.

BR.

Wei

  • Up0
  • Down0
373303429
Join Date: 22 Jan 21
Posts: 4
Posted: Wed, 2022-06-01 00:57

Hi

SNPE version: snpe-1.61.0.3358

Soc: SnapDragon 855

 

I also tested the SnapDragon 835, and the error still exists

 

 

 

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