sacalo opened a new issue #8057:
URL: https://github.com/apache/tvm/issues/8057
After converting a pytorch model to torchscript using the tracing method, I
can successfully execute it and make inferences. But when trying to convert the
traced model following this code, it fails with the attached traceback error. I
can see that is has to do with the "deformable_conv2d" but I'm not able to
follow the cause deeper.
using the scripted_model:
```
import cv2
import torch
with open("./model.ts", "rb") as f:
ts_model = torch.jit.load(f)
original_image = cv2.imread("./test.jpg")
height, width = original_image.shape[:2]
image = original_image
image = torch.as_tensor(image.astype("float32").transpose(2, 0, 1))
result = ts_model(image)
```
converting scripted_model to relay:
```
import tvm
from tvm import relay
import torch
import torchvision
import cv2
with open("./model.ts", "rb") as f:
scripted_model = torch.jit.load(f)
img = cv2.imread("./test.jpg")
input = torch.as_tensor(img.astype("float32").transpose(2, 0, 1))
input_name = "input0"
shape_list = [(input_name, input.shape)]
mod, params = relay.frontend.from_pytorch(scripted_model, shape_list)
```
TRACEBACK ERROR:
```
Traceback (most recent call last):
File "", line 22, in <module>
mod, params = relay.frontend.from_pytorch(scripted_model, shape_list)
File
"./venv/lib/python3.8/site-packages/tvm-0.8.dev996+gb81f3f7a7-py3.8-linux-x86_64.egg/tvm/relay/frontend/pytorch.py",
line 3284, in from_pytorch
ret = converter.convert_operators(_get_operator_nodes(graph.nodes()),
outputs, ret_name)[0]
File
"./venv/lib/python3.8/site-packages/tvm-0.8.dev996+gb81f3f7a7-py3.8-linux-x86_64.egg/tvm/relay/frontend/pytorch.py",
line 2705, in convert_operators
relay_out = relay_op(
File
"./venv/lib/python3.8/site-packages/tvm-0.8.dev996+gb81f3f7a7-py3.8-linux-x86_64.egg/tvm/relay/frontend/pytorch.py",
line 2057, in deform_conv2d
return _op.nn.deformable_conv2d(
File
"./venv/lib/python3.8/site-packages/tvm-0.8.dev996+gb81f3f7a7-py3.8-linux-x86_64.egg/tvm/relay/op/nn/nn.py",
line 2746, in deformable_conv2d
return _make.deformable_conv2d(
File "tvm/_ffi/_cython/./packed_func.pxi", line 322, in
tvm._ffi._cy3.core.PackedFuncBase.__call__
File "tvm/_ffi/_cython/./packed_func.pxi", line 267, in
tvm._ffi._cy3.core.FuncCall
File "tvm/_ffi/_cython/./base.pxi", line 160, in tvm._ffi._cy3.core.CALL
tvm._ffi.base.TVMError: Traceback (most recent call last):
2: TVMFuncCall
1: tvm::runtime::TypedPackedFunc<tvm::RelayExpr (tvm::RelayExpr,
tvm::RelayExpr, tvm::RelayExpr, tvm::runtime::Array<tvm::PrimExpr, void>,
tvm::runtime::Array<tvm::PrimExpr, void>, tvm::runtime::Array<tvm::PrimExpr,
void>, int, int, int, tvm::runtime::Array<tvm::PrimExpr, void>,
tvm::runtime::String, tvm::runtime::String, tvm::runtime::String,
tvm::runtime::DataType)>::AssignTypedLambda<tvm::relay::{lambda(tvm::RelayExpr,
tvm::RelayExpr, tvm::RelayExpr, tvm::runtime::Array<tvm::PrimExpr, void>,
tvm::runtime::Array<tvm::PrimExpr, void>, tvm::runtime::Array<tvm::PrimExpr,
void>, int, int, int, tvm::runtime::Array<tvm::PrimExpr, void>,
tvm::runtime::String, tvm::runtime::String, tvm::runtime::String,
tvm::runtime::DataType)#27}>(tvm::relay::{lambda(tvm::RelayExpr,
tvm::RelayExpr, tvm::RelayExpr, tvm::runtime::Array<tvm::PrimExpr, void>,
tvm::runtime::Array<tvm::PrimExpr, void>, tvm::runtime::Array<tvm::PrimExpr,
void>, int, int, int, tvm::runtime::Array<tvm::PrimExpr, void>, tvm::r
untime::String, tvm::runtime::String, tvm::runtime::String,
tvm::runtime::DataType)#27}, std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> >)::{lambda(tvm::runtime::TVMArgs
const&, tvm::runtime::TVMRetValue*)#1}::operator()(tvm::runtime::TVMArgs const,
tvm::runtime::TVMRetValue) const
0: tvm::runtime::TVMMovableArgValueWithContext_::operator
tvm::runtime::Array<tvm::PrimExpr, void><tvm::runtime::Array<tvm::PrimExpr,
void> >() const
3: TVMFuncCall
2: tvm::runtime::TypedPackedFunc<tvm::RelayExpr (tvm::RelayExpr,
tvm::RelayExpr, tvm::RelayExpr, tvm::runtime::Array<tvm::PrimExpr, void>,
tvm::runtime::Array<tvm::PrimExpr, void>, tvm::runtime::Array<tvm::PrimExpr,
void>, int, int, int, tvm::runtime::Array<tvm::PrimExpr, void>,
tvm::runtime::String, tvm::runtime::String, tvm::runtime::String,
tvm::runtime::DataType)>::AssignTypedLambda<tvm::relay::{lambda(tvm::RelayExpr,
tvm::RelayExpr, tvm::RelayExpr, tvm::runtime::Array<tvm::PrimExpr, void>,
tvm::runtime::Array<tvm::PrimExpr, void>, tvm::runtime::Array<tvm::PrimExpr,
void>, int, int, int, tvm::runtime::Array<tvm::PrimExpr, void>,
tvm::runtime::String, tvm::runtime::String, tvm::runtime::String,
tvm::runtime::DataType)#27}>(tvm::relay::{lambda(tvm::RelayExpr,
tvm::RelayExpr, tvm::RelayExpr, tvm::runtime::Array<tvm::PrimExpr, void>,
tvm::runtime::Array<tvm::PrimExpr, void>, tvm::runtime::Array<tvm::PrimExpr,
void>, int, int, int, tvm::runtime::Array<tvm::PrimExpr, void>, tvm::r
untime::String, tvm::runtime::String, tvm::runtime::String,
tvm::runtime::DataType)#27}, std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> >)::{lambda(tvm::runtime::TVMArgs
const&, tvm::runtime::TVMRetValue*)#1}::operator()(tvm::runtime::TVMArgs const,
tvm::runtime::TVMRetValue) const
1: tvm::runtime::TVMMovableArgValueWithContext_::operator
tvm::runtime::Array<tvm::PrimExpr, void><tvm::runtime::Array<tvm::PrimExpr,
void> >() const
0: tvm::runtime::Array<tvm::PrimExpr, void>
tvm::runtime::TVMPODValue_::AsObjectRef<tvm::runtime::Array<tvm::PrimExpr,
void> >() const
File "../include/tvm/runtime/packed_func.h", line 713
TVMError: In function relay.op.nn._make.deformable_conv2d: error while
converting argument 3: [16:24:47] ../include/tvm/runtime/packed_func.h:1590:
---------------------------------------------------------------
An error occurred during the execution of TVM.
For more information, please see: https://tvm.apache.org/docs/errors.html
---------------------------------------------------------------
Check failed: (!checked_type.defined()) is false: Expected
Array[PrimExpr], but got Array[index 0: relay.Call]
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]