Errors importing models from ONNX Model Zoo

Hi,
I am trying to import some pre-trained ONNX models from here https://github.com/onnx/models.
I have met some issues, and I was wondering if there is something I can do about them apart from writing the models again from scratch (or importing them from frameworks other than ONNX).

  • AlexNet and ZFNet: error when building the models
    File "/.../tvm/topi/include/topi/nn/local_response_norm.h", line 58
    TVMError: Check failed: data->shape.size() == 4 (5 vs. 4) : LRN requires 4-D input

  • GoogleNet: error when building the model
    File "/../tvm/src/arithmetic/const_fold.h", line 198
    TVMError: Check failed: pb->value != 0 (0 vs. 0) : Divide by zero

Any advice? The models work fine if I run them on OnnxRuntime, so I doubt there are intrinsic errors in their structures. These look more like incompatibilities with TVM.

I meet the same problem when i convert inceptionv3 tflite to tvm. Do you solve this problem?

No I didn’t solve it yet. I managed to import a pre-trained model for AlexNet from MXNet and one for GoogleNet from TensorFlow, but this is not the ideal solution for me, since I am evaluating how ONNX models can work. I think it is just a matter of unsupported operators.

1 Like

The question still exist in latest tvm.
@kevinthesun

I met the same problem before.
Try to set opt_level=2 while build config

2 Likes

It worked for ZFNet, thank you!

But I still get the same error with GoogleNet (even with opt_level=1), and the error compiling AlexNet changed to:

File "/.../tvm/python/tvm/autotvm/task/space.py", line 163, in get_factors
    list.__add__, ([i, n//i] for i in range(1, int(math.sqrt(n)) + 1, step)
TypeError: reduce() of empty sequence with no initial value

I am facing the same issue while performing autotvm for TFLite auto encoder model.

Blockquote DEBUG:autotvm:No: 155 GFLOPS: 0.00/0.00 result: MeasureResult(costs=(TVMError(‘Traceback (most recent call last):\n [bt] (8) /usr/tvm/build/libtvm.so(TVMFuncCall+0x61) [0x7f7f05f6aa21]\n [bt] (7) /usr/tvm/build/libtvm.so(std::_Function_handler<void (tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*), void tvm::runtime::TypedPackedFunc<tvm::Map<tvm::tir::IterVar, tvm::Range, void, void> (tvm::te::Schedule const&)>::AssignTypedLambda<tvm::Map<tvm::tir::IterVar, tvm::Range, void, void> ()(tvm::te::Schedule const&)>(tvm::Map<tvm::tir::IterVar, tvm::Range, void, void> ()(tvm::te::Schedule const&))::{lambda(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*)#1}>::_M_invoke(std::_Any_data const&, tvm::runtime::TVMArgs&&, tvm::runtime::TVMRetValue*&&)+0x4e) [0x7f7f05aa9f4e]\n [bt] (6) /usr/tvm/build/libtvm.so(tvm::te::InferBound(tvm::te::Schedule const&)+0xf7a) [0x7f7f058d1a4a]\n [bt] (5) /usr/tvm/build/libtvm.so(tvm::te::InferRootBound(tvm::te::Stage const&, tvm::te::GraphContext const&, std::unordered_map<tvm::tir::IterVar, tvm::Range, std::hashtvm::tir::IterVar, std::equal_totvm::tir::IterVar, std::allocator<std::pair<tvm::tir::IterVar const, tvm::Range> > >)+0x1996) [0x7f7f058cf576]\n [bt] (4) /usr/tvm/build/libtvm.so(tvm::te::PassUpDomain(tvm::te::Stage const&, std::unordered_map<tvm::tir::IterVar, tvm::Range, std::hashtvm::tir::IterVar, std::equal_totvm::tir::IterVar, std::allocator<std::pair<tvm::tir::IterVar const, tvm::Range> > > const&, std::unordered_map<tvm::tir::IterVar, tvm::arith::IntSet, std::hashtvm::tir::IterVar, std::equal_totvm::tir::IterVar, std::allocator<std::pair<tvm::tir::IterVar const, tvm::arith::IntSet> > >)+0x3f2) [0x7f7f058c7062]\n [bt] (3) /usr/tvm/build/libtvm.so(tvm::te::PassUpDomain(tvm::te::FuseNode const*, std::unordered_map<tvm::tir::IterVar, tvm::Range, std::hashtvm::tir::IterVar, std::equal_totvm::tir::IterVar, std::allocator<std::pair<tvm::tir::IterVar const, tvm::Range> > > const&, tvm::arith::IntSet const&, tvm::arith::IntSet*, tvm::arith::IntSet*)+0x9ab) [0x7f7f058beb6b]\n [bt] (2) /usr/tvm/build/libtvm.so(tvm::indexdiv(tvm::PrimExpr, tvm::PrimExpr)+0x4b) [0x7f7f05a1fa4b]\n [bt] (1) /usr/tvm/build/libtvm.so(tvm::floordiv(tvm::PrimExpr, tvm::PrimExpr)+0x291) [0x7f7f05a1f261]\n [bt] (0) /usr/tvm/build/libtvm.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x32) [0x7f7f0571e592]\n File “/usr/tvm/src/tir/ir/…/…/arith/const_fold.h”, line 220\nTVMError: Check failed: pb->value != 0 (0 vs. 0) : Divide by zero’,),), error_no=2, all_cost=0.0320897102355957, timestamp=1580728910.4595814) [(‘tile_ic’, [-1, 3]), (‘tile_oc’, [-1, 6]), (‘tile_ow’, [-1, 23]), (‘unroll_kw’, True)],direct,None,154