-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Closed
Labels
frontend:pytorchpython/tvm/relay/frontend/torchpython/tvm/relay/frontend/torch
Description
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 (works OK):
import cv2
import torch
with open("./model.ts", "rb") as f:
ts_model = torch.jit.load(f)
image = cv2.imread("./test.jpg")
image = torch.as_tensor(image.astype("float32").transpose(2, 0, 1))
result = ts_model(image)
converting scripted_model to relay (fails with the error posted):
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::runtime::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::runtime::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]
cc @yelite
Metadata
Metadata
Assignees
Labels
frontend:pytorchpython/tvm/relay/frontend/torchpython/tvm/relay/frontend/torch