Graph Packing with VTA and MobileNet1.0

Hi, I’m trying to alter the “Deploy Pretrained Vision Model from MxNet on VTA” to run MobileNet1.0 instead of ResNet-18. After looking through the relay module returned from tvm.relay.frontend.from_mxnet() I changed the start_name and stop_name to “nn.conv2d” and “nn.global_avg_pool2d” respectively to match MobileNet1.0

I’m currently getting the error below over an inequality in the src_shape.size() and src_axis.size(). Would anyone have an idea of where this error is coming from. The relay program from MobileNet1.0 doesn’t seem to use any different torch.nn operators than ResNet-18. Is there an

Traceback (most recent call last):
  File "mobilenetv2_mxnet_vtasim.py", line 190, in <module>
stop_name_idx=108
  File "/home/sachacon/SeniorDesign/tvm/vta/python/vta/top/graphpack.py", line 479, in graph_pack
return run_opt_pass(expr, transform.InferType())
  File "/home/sachacon/SeniorDesign/tvm/vta/python/vta/top/graphpack.py", line 30, in run_opt_pass
mod = opt_pass(mod)
  File "/home/sachacon/.local/lib/python3.6/site-packages/tvm-0.8.dev0-py3.6-linux-x86_64.egg/tvm/ir/transform.py", line 127, in __call__
return _ffi_transform_api.RunPass(self, mod)
  File "/home/sachacon/.local/lib/python3.6/site-packages/tvm-0.8.dev0-py3.6-linux-x86_64.egg/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] (7) /home/sachacon/.local/lib/python3.6/site-packages/tvm-0.8.dev0-py3.6-linux-x86_64.egg/tvm/libtvm.so(TVMFuncCall+0x65) [0x7fc81a703aa5]
  [bt] (6) /home/sachacon/.local/lib/python3.6/site-packages/tvm-0.8.dev0-py3.6-linux-x86_64.egg/tvm/libtvm.so(+0xd01b06) [0x7fc819c03b06]
  [bt] (5) /home/sachacon/.local/lib/python3.6/site-packages/tvm-0.8.dev0-py3.6-linux-x86_64.egg/tvm/libtvm.so(tvm::transform::ModulePassNode::operator()(tvm::IRModule, tvm::transform::PassContext const&) const+0x1ee) [0x7fc819c032de]
  [bt] (4) /home/sachacon/.local/lib/python3.6/site-packages/tvm-0.8.dev0-py3.6-linux-x86_64.egg/tvm/libtvm.so(+0x1619e88) [0x7fc81a51be88]
  [bt] (3) /home/sachacon/.local/lib/python3.6/site-packages/tvm-0.8.dev0-py3.6-linux-x86_64.egg/tvm/libtvm.so(+0x1619025) [0x7fc81a51b025]
  [bt] (2) /home/sachacon/.local/lib/python3.6/site-packages/tvm-0.8.dev0-py3.6-linux-x86_64.egg/tvm/libtvm.so(tvm::relay::TypeInferencer::Infer(tvm::GlobalVar, tvm::relay::Function)+0x67) [0x7fc81a51a4e7]
  [bt] (1) /home/sachacon/.local/lib/python3.6/site-packages/tvm-0.8.dev0-py3.6-linux-x86_64.egg/tvm/libtvm.so(tvm::relay::TypeSolver::Solve()+0xc39) [0x7fc81a3cacc9]
  [bt] (0) /home/sachacon/.local/lib/python3.6/site-packages/tvm-0.8.dev0-py3.6-linux-x86_64.egg/tvm/libtvm.so(+0x14c50f2) [0x7fc81a3c70f2]
  [bt] (8) /home/sachacon/.local/lib/python3.6/site-packages/tvm-0.8.dev0-py3.6-linux-x86_64.egg/tvm/libtvm.so(+0x1619e88) [0x7fc81a51be88]
  [bt] (7) /home/sachacon/.local/lib/python3.6/site-packages/tvm-0.8.dev0-py3.6-linux-x86_64.egg/tvm/libtvm.so(+0x1619025) [0x7fc81a51b025]
  [bt] (6) /home/sachacon/.local/lib/python3.6/site-packages/tvm-0.8.dev0-py3.6-linux-x86_64.egg/tvm/libtvm.so(tvm::relay::TypeInferencer::Infer(tvm::GlobalVar, tvm::relay::Function)+0x67) [0x7fc81a51a4e7]
  [bt] (5) /home/sachacon/.local/lib/python3.6/site-packages/tvm-0.8.dev0-py3.6-linux-x86_64.egg/tvm/libtvm.so(tvm::relay::TypeSolver::Solve()+0x375) [0x7fc81a3ca405]
  [bt] (4) /home/sachacon/.local/lib/python3.6/site-packages/tvm-0.8.dev0-py3.6-linux-x86_64.egg/tvm/libtvm.so(std::_Function_handler<void (tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*), tvm::runtime::TypedPackedFunc<bool (tvm::runtime::Array<tvm::Type, void> const&, int, tvm::Attrs const&, tvm::TypeReporter const&)>::AssignTypedLambda<bool (*)(tvm::runtime::Array<tvm::Type, void> const&, int, tvm::Attrs const&, tvm::TypeReporter const&)>(bool (*)(tvm::runtime::Array<tvm::Type, void> const&, int, tvm::Attrs const&, tvm::TypeReporter const&))::{lambda(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*)#1}>::_M_invoke(std::_Any_data const&, tvm::runtime::TVMArgs&&, tvm::runtime::TVMRetValue*&&)+0x63b) [0x7fc81a060b7b]
  [bt] (3) /home/sachacon/.local/lib/python3.6/site-packages/tvm-0.8.dev0-py3.6-linux-x86_64.egg/tvm/libtvm.so(bool tvm::relay::Conv2DRel<tvm::relay::Conv2DAttrs>(tvm::runtime::Array<tvm::Type, void> const&, int, tvm::Attrs const&, tvm::TypeReporter const&)+0x4a3) [0x7fc81a2013e3]
  [bt] (2) /home/sachacon/.local/lib/python3.6/site-packages/tvm-0.8.dev0-py3.6-linux-x86_64.egg/tvm/libtvm.so(tvm::tir::BijectiveLayout::ForwardShape(tvm::runtime::Array<tvm::PrimExpr, void> const&) const+0x42) [0x7fc819e38d22]
  [bt] (1) /home/sachacon/.local/lib/python3.6/site-packages/tvm-0.8.dev0-py3.6-linux-x86_64.egg/tvm/libtvm.so(tvm::tir::TransformShape(tvm::runtime::Array<tvm::PrimExpr, void> const&, tvm::runtime::Array<tvm::tir::IterVar, void> const&, tvm::runtime::Array<tvm::tir::IterVar, void> const&, tvm::runtime::Array<tvm::PrimExpr, void> const&)+0x127) [0x7fc819e3cf47]
  [bt] (0) /home/sachacon/.local/lib/python3.6/site-packages/tvm-0.8.dev0-py3.6-linux-x86_64.egg/tvm/libtvm.so(+0xf33192) [0x7fc819e35192]
  File "/home/sachacon/SeniorDesign/tvm/src/relay/analysis/type_solver.cc", line 621
TVMError:
---------------------------------------------------------------
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: false == false: [00:53:29] /home/sachacon/SeniorDesign/tvm/src/tir/ir/data_layout.cc:284: Check failed: src_shape.size() == src_axis.size() (6 vs. 4) :

Same error. :sob: Have you solved it?

Hello, I have the same problem. Have you solved it? I look forward to your reply. Thank you

This issue may caused by the start operator be pointed to first conv2d operator which bypassed from quantization, to apply graph_pack arbitrary network, user need to give the operator name and index to define start and end scope, please refer Deploy Pretrained Vision Detection Model from Darknet on VTA — tvm 0.8.dev0 documentation for a example. the scope define should like

pack_dict = {
    "mobilenet": ["nn.conv2d", "<end oprator>", <a number>, <a number>],
}

to get operator index user need to use “print(mod.astext(show_meta_data=False))” to print the text form.

请问这个问题你解决了吗?我也遇到了这个问题