Forums - SNPE does not support half_pixel_centers param for Resize Layer

8 posts / 0 new
Last post
SNPE does not support half_pixel_centers param for Resize Layer
diwu
Join Date: 15 Nov 21
Posts: 15
Posted: Mon, 2021-11-22 02:20

when .onnx is converted into .dlc, the error was as follows:

ValueError: Conversion Error: SNPE does not support half_pixel_centers param for Resize Layer.

It occurs when saving .dlc in snpe-onnx-to-dlc , the node is "resize_1",the error log was as follows:

2021-11-22 17:45:31,811 - 188 - INFO - INFO_DLC_SAVE_LOCATION: Saving model at /home/wudi/project/RobustVideoMatting-onnx/my_model.dlc
Encountered Error: Conversion Error: SNPE does not support half_pixel_centers param for Resize Layer.
 
  • Up0
  • Down0
ruzhongl
Join Date: 7 Jun 21
Posts: 42
Posted: Mon, 2021-11-22 02:45
could you help do experiments?
 
1# change to  opset = 11  when export onnx. for example
 
torch.onnx.export(
 
 model,
(dummy_input_a,dummy_input_b),
'full.onnx',
verbose=True,
opset_version=11,
input_names=input_names,
output_names=output_names
)
 
#2 set align cornet = Ture when use Upsample, for example
 
self.upsample = nn.Upsample(scale_factor =2,mode = 'bilinear',align_corners=True)
 
 
 
#3 change snpe converter  to align CPU results with onnx results
 
snpe-1.51.0.2663\lib\python\qti\aisw\converters\onnx\data_translations.py
 
OnnxResizeTranslation:
 
if not scales and len(src_op.input) > 2:
size_name = str(src_op.input[-1])
if graph.weights.has(size_name):
scales = graph.weights.fetch(size_name).astype(numpy.float32).tolist()
else:
scales = graph.get_buffer(size_name).shape.tolist()
# Opset 11 has 4th parameter as output sizes,
# here we are calculating scales from output sizes
scales[-1] = scales[-1] / input_width
scales[-2] = scales[-2] / input_height
+ else:
+ sizes = [1,input_shape[1],int(input_height*scales[-2]),int(input_width*scales[-1])]
+ scales = [1.0,float(input_shape[1]),input_height*scales[-2],input_width*scales[-1]]
+ scales[-1] = (scales[-1]-1) / (input_width-1) if align_corners else (scales[-1] / input_width)
+ scales[-2] = (scales[-2]-1) / (input_height-1) if align_corners else (scales[-2] / input_width)
  • Up0
  • Down0
diwu
Join Date: 15 Nov 21
Posts: 15
Posted: Mon, 2021-11-22 18:26

My .onnx model has been converted into .dlc successfully following your suggestion.

Thanks

  • Up0
  • Down0
diwu
Join Date: 15 Nov 21
Posts: 15
Posted: Mon, 2021-11-22 18:26

My .onnx model has been converted into .dlc successfully following your suggestion.

Thanks

  • Up0
  • Down0
diwu
Join Date: 15 Nov 21
Posts: 15
Posted: Mon, 2021-11-22 18:27

My .onnx model has been converted into .dlc successfully following your suggestion.

Thanks

  • Up0
  • Down0
diwu
Join Date: 15 Nov 21
Posts: 15
Posted: Mon, 2021-11-22 18:28

My .onnx model has been transformed into .dlc successfully following your suggestion.

Thank you.

  • Up0
  • Down0
d.n.alucard
Join Date: 17 Oct 21
Posts: 1
Posted: Tue, 2021-11-30 23:37

Hi, the same error occurs when saving .dlc in snpe-onnx-to-dlc, with the error code "SNPE does not support half_pixel_centers param for Resize Layer."

I tried change the code with your suggest but it did't work.

Could you help me to have a check with your answer in #3? Is that like as following?

if not scales and len(src_op.input) > 2:
          size_name = str(src_op.input[-1])
          if graph.weights.has(size_name):
                    scales = graph.weights.fetch(size_name).astype(numpy.float32).tolist()
          else:
                    scales = graph.get_buffer(size_name).shape.tolist()
          # Opset 11 has 4th parameter as output sizes,
          # here we are calculating scales from output sizes
          scales[-1] = scales[-1] / input_width
          scales[-2] = scales[-2] / input_height
else:
          sizes = [1,input_shape[1],int(input_height*scales[-2]),int(input_width*scales[-1])]
          scales = [1.0,float(input_shape[1]),input_height*scales[-2],input_width*scales[-1]]
          scales[-1] = (scales[-1]-1) / (input_width-1) if align_corners else (scales[-1] / input_width)
          scales[-2] = (scales[-2]-1) / (input_height-1) if align_corners else (scales[-2] / input_width)
  •  

 

  • Up0
  • Down0
ruzhongl
Join Date: 7 Jun 21
Posts: 42
Posted: Wed, 2021-12-08 22:40

Hi alucard:

 

step3 just fix the bug that onnx runtime output mismatch with CPU/DSP.

"SNPE does not support half_pixel_centers param for Resize Layer." ----> For this error, you have to pick up step 1 &  step 2.

If you already apply 1 &2, another reason I can image is SNPE verion, you can use SNPE 1.55 if you already apply 1 &2  

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