mit-han-lab / temporal-shift-module

[ICCV 2019] TSM: Temporal Shift Module for Efficient Video Understanding
https://arxiv.org/abs/1811.08383
MIT License
2.05k stars 418 forks source link

conv2d dimension issue in online demo script #157

Open dhruvapatil opened 3 years ago

dhruvapatil commented 3 years ago

I am trying to run the online demo on GeForce RTX 2080. I am getting this error that I cannot solve:

conv2d: requires that 23, the input channels (23) divided by groups (1), must match the input channels of the weight 24, where the weight shape is ([144, 24, 1, 1]). The type inference pass was unable to infer a type for this expression. This usually occurs when an operator call is under constrained in some way, check other reported errors for hints of what may of happened.

The issue seems to be during model initialization for 3.conv and 4.conv layers, particularly in the Inverted ResidualWithShift Module.

Running a randomly initialized tensor gives the expected output, is there an issue with the input dimension from the webcam that might be giving this error? Please help. I reinstalled an older version of tvm to see if that resolves the issue, but it gave me the following error in the torch2tvm_module graph, tvm_module, params = tvm.relay.build(relay_module, target, params=params)

[15:19:08] /home/cwc/incubator-tvm/src/relay/ir/doc.h:50: text node: ' an internal invariant was violated while typechecking your program [15:19:08] /home/cwc/incubator-tvm/src/relay/op/tensor/transform.cc:1919: Check failed: begin_v < end_v (3 vs. -9223372036854775784) : strided_slice get empty slice at axis 1 Stack trace: [bt] (0) /usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x43) [0x7f6978a82b53] [bt] (1) /usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(tvm::relay::StridedSliceRel(tvm::Array<tvm::relay::Type, void> const&, int, tvm::Attrs const&, tvm::relay::TypeReporter const&)+0xfae) [0x7f6978f3455e] [bt] (2) /usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(std::_Function_handler<void (tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue), tvm::runtime::TypedPackedFunc<bool (tvm::Array<tvm::relay::Type, void> const&, int, tvm::Attrs const&, tvm::relay::TypeReporter const&)>::AssignTypedLambda<bool ()(tvm::Array<tvm::relay::Type, void> const&, int, tvm::Attrs const&, tvm::relay::TypeReporter const&)>(bool ()(tvm::Array<tvm::relay::Type, void> const&, int, tvm::Attrs const&, tvm::relay::TypeReporter const&))::{lambda(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue)#1}>::_M_invoke(std::_Any_data const&, tvm::runtime::TVMArgs&&, tvm::runtime::TVMRetValue*&&)+0xd6) [0x7f6978e41466] [bt] (3) /usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(tvm::relay::TypeSolver::Solve()+0xad4) [0x7f69790b1294] [bt] (4) /usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(tvm::relay::TypeInferencer::Infer(tvm::relay::Expr)+0x55) [0x7f697909b0c5] [bt] (5) /usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(tvm::relay::InferType(tvm::relay::Function const&, tvm::relay::Module const&, tvm::relay::GlobalVar const&)+0x1c5) [0x7f697909b825] [bt] (6) /usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(tvm::relay::ModuleNode::Add(tvm::relay::GlobalVar const&, tvm::relay::Function const&, bool)+0x356) [0x7f6979182826] [bt] (7) /usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(tvm::relay::ModuleNode::FromExpr(tvm::relay::Expr const&, tvm::Map<tvm::relay::GlobalVar, tvm::relay::Function, void, void> const&, tvm::Map<tvm::relay::GlobalTypeVar, tvm::relay::TypeData, void, void> const&)+0x24f) [0x7f697918336f] [bt] (8) /usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(+0xa5377b) [0x7f697918577b]

; ' should not has tab or newline. Traceback (most recent call last):

File "main.py", line 309, in main()

File "main.py", line 202, in main executor, ctx = get_executor()

File "main.py", line 113, in get_executor return torch2executor(torch_module, torch_inputs, target)

File "main.py", line 68, in torch2executor graph, tvm_module, params = torch2tvm_module(torch_module, torch_inputs, target)

File "main.py", line 44, in torch2tvm_module relay_module, params = tvm.relay.frontend.from_onnx(onnx_model, shape=input_shapes)

File "/usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/relay/frontend/onnx.py", line 1497, in from_onnx mod, params = g.from_onnx(graph, opset)

File "/usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/relay/frontend/onnx.py", line 1344, in from_onnx return _module.Module.from_expr(func), self._params

File "/usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/relay/module.py", line 233, in from_expr return _module.Module_FromExpr(expr, funcs, defs)

File "tvm/_ffi/_cython/./function.pxi", line 304, in core.FunctionBase.call

File "tvm/_ffi/_cython/./function.pxi", line 239, in core.FuncCall

File "tvm/_ffi/_cython/./function.pxi", line 228, in core.FuncCall3

File "tvm/_ffi/_cython/./base.pxi", line 160, in core.CALL

tvm._ffi.base.TVMError: Traceback (most recent call last): [bt] (7) /usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(TVMFuncCall+0x65) [0x7f697926a195] [bt] (6) /usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(+0xa5377b) [0x7f697918577b] [bt] (5) /usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(tvm::relay::ModuleNode::FromExpr(tvm::relay::Expr const&, tvm::Map<tvm::relay::GlobalVar, tvm::relay::Function, void, void> const&, tvm::Map<tvm::relay::GlobalTypeVar, tvm::relay::TypeData, void, void> const&)+0x24f) [0x7f697918336f] [bt] (4) /usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(tvm::relay::ModuleNode::Add(tvm::relay::GlobalVar const&, tvm::relay::Function const&, bool)+0x356) [0x7f6979182826] [bt] (3) /usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(tvm::relay::InferType(tvm::relay::Function const&, tvm::relay::Module const&, tvm::relay::GlobalVar const&)+0x1c5) [0x7f697909b825] [bt] (2) /usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(tvm::relay::TypeInferencer::Infer(tvm::relay::Expr)+0x71) [0x7f697909b0e1] [bt] (1) /usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(tvm::relay::ErrorReporter::RenderErrors(tvm::relay::Module const&, bool)+0x19bb) [0x7f697915f9cb] [bt] (0) /usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x43) [0x7f6978a82b53] [bt] (8) /usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(+0xa5377b) [0x7f697918577b] [bt] (7) /usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(tvm::relay::ModuleNode::FromExpr(tvm::relay::Expr const&, tvm::Map<tvm::relay::GlobalVar, tvm::relay::Function, void, void> const&, tvm::Map<tvm::relay::GlobalTypeVar, tvm::relay::TypeData, void, void> const&)+0x24f) [0x7f697918336f] [bt] (6) /usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(tvm::relay::ModuleNode::Add(tvm::relay::GlobalVar const&, tvm::relay::Function const&, bool)+0x356) [0x7f6979182826] [bt] (5) /usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(tvm::relay::InferType(tvm::relay::Function const&, tvm::relay::Module const&, tvm::relay::GlobalVar const&)+0x1c5) [0x7f697909b825] [bt] (4) /usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(tvm::relay::TypeInferencer::Infer(tvm::relay::Expr)+0x55) [0x7f697909b0c5] [bt] (3) /usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(tvm::relay::TypeSolver::Solve()+0xad4) [0x7f69790b1294] [bt] (2) /usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(std::_Function_handler<void (tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue), tvm::runtime::TypedPackedFunc<bool (tvm::Array<tvm::relay::Type, void> const&, int, tvm::Attrs const&, tvm::relay::TypeReporter const&)>::AssignTypedLambda<bool ()(tvm::Array<tvm::relay::Type, void> const&, int, tvm::Attrs const&, tvm::relay::TypeReporter const&)>(bool ()(tvm::Array<tvm::relay::Type, void> const&, int, tvm::Attrs const&, tvm::relay::TypeReporter const&))::{lambda(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue)#1}>::_M_invoke(std::_Any_data const&, tvm::runtime::TVMArgs&&, tvm::runtime::TVMRetValue*&&)+0xd6) [0x7f6978e41466] [bt] (1) /usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(tvm::relay::StridedSliceRel(tvm::Array<tvm::relay::Type, void> const&, int, tvm::Attrs const&, tvm::relay::TypeReporter const&)+0xfae) [0x7f6978f3455e] [bt] (0) /usr/local/lib/python3.6/dist-packages/tvm-0.6.0-py3.6-linux-x86_64.egg/tvm/libtvm.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x43) [0x7f6978a82b53] File "/home/cwc/incubator-tvm/src/relay/ir/error.cc", line 132 TVMError:

Please help me. Thanks!

Junan007 commented 3 years ago

I have the same problem, did you solve it?

leimao commented 3 years ago

I did not delve into the code and got the same problem.

Junan007 commented 3 years ago

i have solved this problem by reinstall tvm and pytorch. tvm==0.6 pytorch==1.2.0 or 1.3.0 onnxsim==0.3.5 onnx==1.9.0

and i change the opset_version to 9 on torch.onnx.export.

leimao commented 3 years ago

i have solved this problem by reinstall tvm and pytorch. tvm==0.6 pytorch==1.2.0 or 1.3.0 onnxsim==0.3.5 onnx==1.9.0

and i change the opset_version to 9 on torch.onnx.export.

Thank you. Downgrading PyTorch works. But ideally all the code should be compatible with the latest software.