from_pytorch
fails to parse torch.zeros(shape)
in case when the shape is the mix of Expressions and Constants.
For example:
import torch
import tvm
from tvm import relay
class Net(torch.nn.Module):
def __init__(self):
super(Net, self).__init__()
def forward(self, b):
return torch.zeros((b,3,7,7))
b = torch.tensor(1)
net = Net()
net(b)
traced_net = torch.jit.trace(net, (b))
ctx = tvm.cpu(0)
target = 'llvm'
shape_list = [("input0", []),]
mod, params = relay.frontend.from_pytorch(traced_net, shape_list)
Error:
>>> mod, params = relay.frontend.from_pytorch(traced_net, shape_list)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/pivovaa/workspace/tvm/python/tvm/relay/frontend/pytorch.py", line 3224, in from_pytorch
ret = converter.convert_operators(_get_operator_nodes(graph.nodes()), outputs, ret_name)[0]
File "/Users/pivovaa/workspace/tvm/python/tvm/relay/frontend/pytorch.py", line 2645, in convert_operators
relay_out = relay_op(
File "/Users/pivovaa/workspace/tvm/python/tvm/relay/frontend/pytorch.py", line 687, in zeros
return self.full_impl(data, 0, dtype)
File "/Users/pivovaa/workspace/tvm/python/tvm/relay/frontend/pytorch.py", line 630, in full_impl
tmp.append(_op.cast(_op.expand_dims(dim, axis=0), "int64"))
File "/Users/pivovaa/workspace/tvm/python/tvm/relay/op/transform.py", line 110, in expand_dims
return _make.expand_dims(data, axis, num_newaxis)
File "/Users/pivovaa/workspace/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 237, in __call__
raise get_last_ffi_error()
tvm._ffi.base.TVMError: Traceback (most recent call last):
[bt] (5) 6 ??? 0x00007ffee5234d20 0x0 + 140732742716704
[bt] (4) 5 libffi.7.dylib 0x000000010b143e45 ffi_call_unix64 + 85
[bt] (3) 4 libtvm.dylib 0x000000012fff05d6 TVMFuncCall + 70
[bt] (2) 3 libtvm.dylib 0x000000012f9502b3 void tvm::runtime::TypedPackedFunc<tvm::RelayExpr (tvm::RelayExpr, int, int)>::AssignTypedLambda<tvm::RelayExpr (*)(tvm::RelayExpr, int, int)>(tvm::RelayExpr (*)(tvm::RelayExpr, int, int), std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)::'lambda'(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*)::operator()(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*) const + 723
[bt] (1) 2 libtvm.dylib 0x000000012f239549 tvm::runtime::TVMMovableArgValueWithContext_::operator tvm::RelayExpr<tvm::RelayExpr>() const + 329
[bt] (0) 1 libtvm.dylib 0x000000012efa319f dmlc::LogMessageFatal::~LogMessageFatal() + 111
[bt] (7) 8 ??? 0x00007ffee5234d20 0x0 + 140732742716704
[bt] (6) 7 libffi.7.dylib 0x000000010b143e45 ffi_call_unix64 + 85
[bt] (5) 6 libtvm.dylib 0x000000012fff05d6 TVMFuncCall + 70
[bt] (4) 5 libtvm.dylib 0x000000012f9502b3 void tvm::runtime::TypedPackedFunc<tvm::RelayExpr (tvm::RelayExpr, int, int)>::AssignTypedLambda<tvm::RelayExpr (*)(tvm::RelayExpr, int, int)>(tvm::RelayExpr (*)(tvm::RelayExpr, int, int), std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)::'lambda'(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*)::operator()(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*) const + 723
[bt] (3) 4 libtvm.dylib 0x000000012f23941c tvm::runtime::TVMMovableArgValueWithContext_::operator tvm::RelayExpr<tvm::RelayExpr>() const + 28
[bt] (2) 3 libtvm.dylib 0x000000012f239680 tvm::runtime::TVMMovableArgValue_::operator tvm::RelayExpr<tvm::RelayExpr, void>() const + 224
[bt] (1) 2 libtvm.dylib 0x000000012f239c07 tvm::RelayExpr tvm::runtime::TVMPODValue_::AsObjectRef<tvm::RelayExpr>() const + 1351
[bt] (0) 1 libtvm.dylib 0x000000012efa319f dmlc::LogMessageFatal::~LogMessageFatal() + 111
File "/Users/pivovaa/workspace/tvm/include/tvm/runtime/packed_func.h", line 687
TVMError: In function relay.op._make.expand_dims: error while converting argument 0: [22:13:23] /Users/pivovaa/workspace/tvm/include/tvm/runtime/packed_func.h:1584:
---------------------------------------------------------------
An internal invariant was violated during the execution of TVM.
Please read TVM's error reporting guidelines.
More details can be found here: https://discuss.tvm.ai/t/error-reporting/7793.
---------------------------------------------------------------
Check failed: type_code_ == kTVMObjectHandle (0 vs. 8) : expected Object but got int