Forums - snpe-pytorch-to-dlc fails on example code

3 posts / 0 new
Last post
snpe-pytorch-to-dlc fails on example code
jason2
Join Date: 17 Aug 21
Posts: 14
Posted: Mon, 2022-08-15 11:17

Hi,

I downloaded snpe-1.64.0.3605, and ran the alexnet caffe examples without issue.  Next, I tried the pytorch example with resnet18.  I ran the following commands:

$ python3 // Python 3.6.9, Ubuntu 18.04

>>> import torch

>>> import torchvision.models as models

>>> resnet18_model = models.resnet18()

>>> input_shape = [1, 3, 224, 224]

>>> input_data = torch.randn(input_shape)

>>> script_model = torch.jit.trace(resnet18_model, input_data)

>>> script_model.save("resnet18.pt")

>>> exit()

$ snpe-pytorch-to-dlc --input_network resnet18.pt --input_dim input "1,3,224,224" --output_path resnet18.dlc 

Console Output ->
Check failed: (reporter->AssertEQ(data->shape[data->shape.size() - 1], weight->shape[1])) is false: DenseRel: input dimension doesn't match, data shape=[1, 512], weight shape=[512, 1000]

Please confirm I followed the steps correctly or if I did something wrong.

 

Thanks,

Jason

  • Up0
  • Down0
ss.pandiri
Join Date: 29 May 18
Posts: 58
Posted: Fri, 2022-08-19 08:49

hello 

The document mentions that --input-dim must be followed by value in quotes as follows:

snpe-pytorch-to-dlc --input_network resnet18.pt --input_dim 'input'  1,3,224,224 --output_path resnet18.dlc 

https://developer.qualcomm.com/sites/default/files/docs/snpe/tools.html

See here:

required arguments:
  -d INPUT_NAME INPUT_DIM, --input_dim INPUT_NAME INPUT_DIM
                        The names and dimensions of the network input layers
                        specified in the format [input_name comma-separated-
                        dimensions], for example: 'data' 1,3,224,224 Note that
                        the quotes should always be included in order to
                        handlespecial characters, spaces, etc. For multiple
                        inputs specify multiple --input_dim on the command
                        line like: --input_dim 'data1' 1,3,224,224 --input_dim
                        'data2' 1,50,100,3

 

 

  • Up0
  • Down0
jason2
Join Date: 17 Aug 21
Posts: 14
Posted: Mon, 2022-08-22 19:57

Hi ss.pandiri,

Thanks for your response.  I tried running the same command using quotes as you suggested, but I received the same error from TVM.  However, it turns out the issue was that I had installed pytorch 1.12.  After uninstalling pytorch and torchvision, then reinstalling pytorch (and torchvision) v1.8.1, I was able to run snpe-pytorch-to-dlc without issue.

Thank you for your help.

Jason

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