[uTVM] runtime unittest error

Hello,

When I run tests/python/unittest/test_runtime_micro.py on my STM32F746-discovery board. It fails at the test_add() and gives me the following error. Any thoughts about this issues?

finished alloc test
[press enter to continue]
Traceback (most recent call last):

  File "../../tvm/tests/python/unittest/test_runtime_micro.py", line 350, in <module>
    test_add()

  File "../../tvm/tests/python/unittest/test_runtime_micro.py", line 114, in test_add
    micro_mod = micro.create_micro_mod(c_mod, DEV_CONFIG_A)

  File "/home/wmchen/utvm/tvm/python/tvm/micro/base.py", line 212, in create_micro_mod
    micro_mod = tvm.runtime.load_module(lib_obj_path)

  File "/home/wmchen/utvm/tvm/python/tvm/runtime/module.py", line 405, in load_module
    return _ffi_api.ModuleLoadFromFile(path, fmt)

  File "/home/wmchen/utvm/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 225, in __call__
    raise get_last_ffi_error()

tvm._ffi.base.TVMError: Traceback (most recent call last):
  [bt] (7) /home/wmchen/utvm/tvm/build/libtvm.so(TVMFuncCall+0x63) [0x7ff91711f8f3]
  [bt] (6) /home/wmchen/utvm/tvm/build/libtvm.so(tvm::runtime::TypedPackedFunc<tvm::runtime::Module (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)>::AssignTypedLambda<tvm::runtime::Module (*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)>(tvm::runtime::Module (*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&))::{lambda(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*)#1}::operator()(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*) const+0xc9) [0x7ff91713d0d9]
  [bt] (5) /home/wmchen/utvm/tvm/build/libtvm.so(tvm::runtime::Module::LoadFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)+0x512) [0x7ff917139482]
  [bt] (4) /home/wmchen/utvm/tvm/build/libtvm.so(+0xf7f08a) [0x7ff9171bb08a]
  [bt] (3) /home/wmchen/utvm/tvm/build/libtvm.so(tvm::runtime::MicroSession::LoadBinary(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)+0x19b) [0x7ff9171c046b]
  [bt] (2) /home/wmchen/utvm/tvm/build/libtvm.so(tvm::runtime::MicroSession::AllocateInSection(tvm::runtime::SectionKind, unsigned long)+0x54) [0x7ff9171bfff4]
  [bt] (1) /home/wmchen/utvm/tvm/build/libtvm.so(tvm::runtime::MicroSectionAllocator::Allocate(unsigned long)+0x178) [0x7ff9171c5c28]
  [bt] (0) /home/wmchen/utvm/tvm/build/libtvm.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x79) [0x7ff9166b8e69]
  File "/home/wmchen/utvm/tvm/src/runtime/micro/micro_section_allocator.h", line 68
TVMError: Check failed: size_ + size < capacity_: cannot alloc 80 bytes in section "bss" (start_addr=0x20004718, used=540, capacity=600)

Hi,

Thanks for taking a look at µTVM! That script is just intended to test it using x86 functions to simulate device execution, and it serves as our CI for µTVM right now. I don’t think it will work on an STM device.

There is an analogous script tests/micro/test_runtime_micro_on_arm.py, but we can’t test that in our CI. Try running that, though. We’re hoping to have an improved functional test for connected hardware in the short-medium term.

Andrew

Thanks for the reply! I ran tests/micro/test_runtime_micro_on_arm.py, but it also gives me the same error.

That sounds like a regression then. That should work. I’ll pull master and see if I can replicate on my board.

@wmchen @areusch - it’s a regression alright. Fresh build here locally I’m seeing the same. It dies in the test_add unit test. Perhaps time to get serious about CI for uTVM.

finished alloc test
[press enter to continue]
Traceback (most recent call last):

  File "./test_runtime_micro_on_arm.py", line 357, in <module>
    test_add()

  File "./test_runtime_micro_on_arm.py", line 121, in test_add
    micro_mod = micro.create_micro_mod(c_mod, DEV_CONFIG_A)

  File "/home/tgall/tvm/tvm/python/tvm/micro/base.py", line 213, in create_micro_mod
    micro_mod = tvm.runtime.load_module(lib_obj_path)

  File "/home/tgall/tvm/tvm/python/tvm/runtime/module.py", line 405, in load_module
    return _ffi_api.ModuleLoadFromFile(path, fmt)

  File "/home/tgall/tvm/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 225, in __call__
    raise get_last_ffi_error()

tvm._ffi.base.TVMError: Traceback (most recent call last):
  [bt] (6) /home/tgall/tvm/tvm/build/libtvm.so(TVMFuncCall+0x63) [0x7f98d30e6ff3]
  [bt] (5) /home/tgall/tvm/tvm/build/libtvm.so(std::_Function_handler<void (tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*), tvm::runtime::TypedPackedFunc<tvm::runtime::Module (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)>::AssignTypedLambda<tvm::runtime::Module (*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)>(tvm::runtime::Module (*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&))::{lambda(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*)#1}>::_M_invoke(std::_Any_data const&, tvm::runtime::TVMArgs&&, tvm::runtime::TVMRetValue*&&)+0xa6) [0x7f98d30ffcd6]
  [bt] (4) /home/tgall/tvm/tvm/build/libtvm.so(tvm::runtime::Module::LoadFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)+0x1f3) [0x7f98d30fac83]
  [bt] (3) /home/tgall/tvm/tvm/build/libtvm.so(+0xf2fe1f) [0x7f98d316be1f]
  [bt] (2) /home/tgall/tvm/tvm/build/libtvm.so(tvm::runtime::MicroSession::LoadBinary(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)+0x19b) [0x7f98d31716bb]
  [bt] (1) /home/tgall/tvm/tvm/build/libtvm.so(tvm::runtime::MicroSession::AllocateInSection(tvm::runtime::SectionKind, unsigned long)+0x1a5) [0x7f98d3170f65]
  [bt] (0) /home/tgall/tvm/tvm/build/libtvm.so(+0xf32068) [0x7f98d316e068]
  File "/home/tgall/tvm/tvm/src/runtime/micro/micro_section_allocator.h", line 68
TVMError: Check failed: size_ + size < capacity_: cannot alloc 80 bytes in section "bss" (start_addr=0x20004718, used=540, capacity=600)

Pushed 5660 to fix this. I’m intending to solve this more robustly in the upcoming on-device runtime change, which will (mostly) decouple TVM from the link process.