Forums - Torch bilinear upsampling is different than dlc

2 posts / 0 new
Last post
Torch bilinear upsampling is different than dlc
lior.kadoch
Join Date: 21 Dec 21
Posts: 3
Posted: Wed, 2022-01-19 00:19

Hi

We notices that bilinear upsampling behave differently in torch and dlc, and there is discrepancy between the outputs.

Torch use different ratio when multiplying neighbors [0.75, 0.25] than DLC [0.5, 0.5], and the edges is quite different as well. We used snpe-onnx-to-dlc to convert the model.

Thanks, Lior

environement:

torch==1.9.1

onnx==1.6.0, onnx_opset_version==11 (BTW we tried opset==10, but torch output was not alligned with onnx)

snpe-sdk==1.56.2

For example for input:

array([[[[ 10.,  20.,  30.,  40.],
         [ 50.,  60.,  70.,  80.],
         [ 90., 100., 110., 120.],
         [130., 140., 150., 160.]]]], dtype=float32)
 
DLC output:
array([[[ 10.,  15.,  20.,  25.,  30.,  35.,  40.,  40.],
        [ 30.,  35.,  40.,  45.,  50.,  55.,  60.,  60.],
        [ 50.,  55.,  60.,  65.,  70.,  75.,  80.,  80.],
        [ 70.,  75.,  80.,  85.,  90.,  95., 100., 100.],
        [ 90.,  95., 100., 105., 110., 115., 120., 120.],
        [110., 115., 120., 125., 130., 135., 140., 140.],
        [130., 135., 140., 145., 150., 155., 160., 160.],
        [130., 135., 140., 145., 150., 155., 160., 160.]]], dtype=float32)
 
Torch output:
array([[[[ 10. ,  12.5,  17.5,  22.5,  27.5,  32.5,  37.5,  40. ],
         [ 20. ,  22.5,  27.5,  32.5,  37.5,  42.5,  47.5,  50. ],
         [ 40. ,  42.5,  47.5,  52.5,  57.5,  62.5,  67.5,  70. ],
         [ 60. ,  62.5,  67.5,  72.5,  77.5,  82.5,  87.5,  90. ],
         [ 80. ,  82.5,  87.5,  92.5,  97.5, 102.5, 107.5, 110. ],
         [100. , 102.5, 107.5, 112.5, 117.5, 122.5, 127.5, 130. ],
         [120. , 122.5, 127.5, 132.5, 137.5, 142.5, 147.5, 150. ],
         [130. , 132.5, 137.5, 142.5, 147.5, 152.5, 157.5, 160. ]]]], dtype=float32)

 

  • Up0
  • Down0
weihuan
Join Date: 12 Apr 20
Posts: 270
Posted: Thu, 2022-02-10 21:05

Dear customer,

Did you check the data with correct format? The data type SNPE recognize is NHWC but ONNX is NCHW.

So, you need to transformer the execution results from NHWC to NCHW and then take a comparsion with golden 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.