Forums - snpe-pytorch-to-dlc fails to convert ConvTranspose2d layers

3 posts / 0 new
Last post
snpe-pytorch-to-dlc fails to convert ConvTranspose2d layers
gershon
Join Date: 24 Jul 22
Posts: 4
Posted: Wed, 2022-08-03 23:44

When trying to convert a pytorch model having a single node of type ConvTranspose2d - snpe-pytorch-to-dlc crashes.

SNPE Version: 1.64.0.3605

Code to create the model:

import torch
import torch.jit
import torch.nn as nn
 
class Net(nn.Module):
 
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = nn.ConvTranspose2d(4, 6, 5, dtype=torch.float32)
 
    def forward(self, x):
        return self.conv1(x)
 
net = Net()
 
input_shape = [1, 4, 32, 32]
input_data = torch.randn(input_shape)
script_model = torch.jit.trace(net, input_data)
script_model.save("test_pytorch.pt")
 
Command line to run snpe-pytorch-to-dlc
snpe-pytorch-to-dlc -i test_pytorch.pt -d x 1,4,32,32

 

Error message

2022-08-04 09:40:38,641 - 2972 - WARNING - Untyped Tensor found, assume it is float32
2022-08-04 09:40:38,694 - 272 - INFO - Using injective.cpu for layout_transform based on highest priority (10)
2022-08-04 09:40:38,725 - 272 - INFO - Using injective.cpu for expand_dims based on highest priority (10)
2022-08-04 09:40:38,749 - 272 - INFO - Using injective.cpu for expand_dims based on highest priority (10)
2022-08-04 09:40:38,775 - 272 - INFO - Using injective.cpu for layout_transform based on highest priority (10)
2022-08-04 09:40:39,160 - 209 - ERROR - Encountered Error: Traceback (most recent call last):
  15: TVMFuncCall
  14: std::_Function_handler<void (tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*), tvm::runtime::TypedPackedFunc<void (tvm::RelayExpr, tvm::runtime::PackedFunc)>::AssignTypedLambda<tvm::relay::{lambda(tvm::RelayExpr, tvm::runtime::PackedFunc)#1}>(tvm::relay::{lambda(tvm::RelayExpr, tvm::runtime::PackedFunc)#1}, std::string)::{lambda(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*)#1}>::_M_invoke(std::_Any_data const&, tvm::runtime::TVMArgs&&, tvm::runtime::TVMRetValue*&&)
  13: tvm::relay::PostOrderVisit(tvm::RelayExpr const&, std::function<void (tvm::RelayExpr const&)>)
  12: tvm::relay::ExprVisitor::VisitExpr(tvm::RelayExpr const&)
  11: tvm::relay::ExprFunctor<void (tvm::RelayExpr const&)>::VisitExpr(tvm::RelayExpr const&)
  10: tvm::relay::ExprVisitor::VisitExpr_(tvm::relay::FunctionNode const*)
  9: tvm::relay::ExprApplyVisit::VisitExpr(tvm::RelayExpr const&)
  8: tvm::relay::ExprVisitor::VisitExpr(tvm::RelayExpr const&)
  7: tvm::relay::ExprFunctor<void (tvm::RelayExpr const&)>::VisitExpr(tvm::RelayExpr const&)
  6: tvm::relay::ExprVisitor::VisitExpr_(tvm::relay::CallNode const*)
  5: tvm::relay::ExprApplyVisit::VisitExpr(tvm::RelayExpr const&)
  4: tvm::relay::ExprVisitor::VisitExpr(tvm::RelayExpr const&)
  3: tvm::relay::ExprFunctor<void (tvm::RelayExpr const&)>::VisitExpr(tvm::RelayExpr const&)
  2: tvm::relay::ExprVisitor::VisitExpr_(tvm::relay::CallNode const*)
  1: std::_Function_handler<void (tvm::RelayExpr const&), tvm::relay::{lambda(tvm::RelayExpr, tvm::runtime::PackedFunc)#1}::operator()(tvm::RelayExpr, tvm::runtime::PackedFunc) const::{lambda(tvm::RelayExpr const&)#1}>::_M_invoke(std::_Any_data const&, tvm::RelayExpr const&)
  0: std::_Function_handler<void (tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*), TVMFuncCreateFromCFunc::{lambda(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)#2}>::_M_invoke(std::_Any_data const&, tvm::runtime::TVMArgs&&, tvm::runtime::TVMRetValue*&&)
  File "/home/gershon/qc/snpe-1.64.0.3605/lib/python/qti/tvm/_ffi/_ctypes/packed_func.py", line 81, in cfun
    rv = local_pyfunc(*pyargs)
  File "/home/gershon/qc/snpe-1.64.0.3605/lib/python/qti/aisw/converters/relay/relay_to_ir.py", line 465, in visit_module
    RelayConverterFrontend.add_op(expr)
  File "/home/gershon/qc/snpe-1.64.0.3605/lib/python/qti/aisw/converters/relay/relay_to_ir.py", line 452, in add_op
    translation.add_op(expr, QUIR_GRAPH, converter_context=CONVERTER_CTX, relay_params=RELAY_PARAMS)
  File "/home/gershon/qc/snpe-1.64.0.3605/lib/python/qti/aisw/converters/relay/translations/relay_translations.py", line 61, in add_op
    attr_dict = self.extract_attributes(relay_expr, relay_params)
  File "/home/gershon/qc/snpe-1.64.0.3605/lib/python/qti/aisw/converters/relay/translations/nn_translations.py", line 448, in extract_attributes
    raise ValueError("Unsupported kernel layout {}".format(conv_attrs.kernel_layout))
ValueError: Unsupported kernel layout HWIO
 

 

  • Up0
  • Down0
weihuan
Join Date: 12 Apr 20
Posts: 103
Posted: Sat, 2022-08-06 19:53

Dear developer,

SNPE pytorch supported ConTranspose2d, Could you please help to check the encoding value about this ops as below?

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

BR.

Wei

  • Up0
  • Down0
gershon
Join Date: 24 Jul 22
Posts: 4
Posted: Mon, 2022-08-08 01:18

Wei,

the ConvTranspose2d op is documented as supported; however actually it is not.

I have attached a simple Python script to create a Pytorch scheme + command line arguments to convert it.

Can you please either tell me what am I doing wrong or fix the bug in snpe-pytorch-to-dlc ?

 

Best regards,

Gershon

 

 

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