Hi, we are working on a custom embedded NPU.
Goal is to use BYOC in the C runtime with an AOT executor, much like Running TVM on bare metal Arm(R) Cortex(R)-M55 CPU and Ethos(TM)-U55 NPU — tvm 0.9.dev0 documentation . I’ve created this very simple relay example to get something in the pipeline. We use our own fork of TVM, but I rebased on upstream yesterday and the issue is still the same.
tensor_shape = (3, 3, 3)
data_type = "int8"
a = relay.var("a", tvm.relay.TensorType(tensor_shape, data_type))
b = relay.var("b", tvm.relay.TensorType(tensor_shape, data_type))
total = np.product(tensor_shape)
constant_tensor = np.arange(0, total, dtype=data_type)
constant_tensor = np.reshape(constant_tensor, tensor_shape)
c = relay.const(constant_tensor, tvm.relay.TensorType(tensor_shape, data_type))
sum_expr = relay.add(relay.add(a, b), c)
module = tvm.ir.IRModule()
module = module.from_expr(sum_expr)
When I compile just relay.add(a,b)
everything works fine, but if I add the constant, this error is triggered
Traceback (most recent call last):
File "soma_codegen.py", line 81, in <module>
compile_model(tvmc_model=model,
File "/home/josse/phd/tvm-fork/python/tvm/driver/tvmc/compiler.py", line 307, in compile_model
graph_module = relay.build(
File "/home/josse/phd/tvm-fork/python/tvm/relay/build_module.py", line 468, in build
graph_json, runtime_mod, params = bld_mod.build(
File "/home/josse/phd/tvm-fork/python/tvm/relay/build_module.py", line 196, in build
self._build(mod, target, target_host, executor, runtime, workspace_memory_pools, mod_name)
File "/home/josse/phd/tvm-fork/python/tvm/_ffi/_ctypes/packed_func.py", line 237, in __call__
raise get_last_ffi_error()
tvm._ffi.base.TVMError: Traceback (most recent call last):
7: TVMFuncCall
at /home/josse/phd/tvm-fork/src/runtime/c_runtime_api.cc:477
6: tvm::runtime::PackedFuncObj::CallPacked(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*) const
at /home/josse/phd/tvm-fork/include/tvm/runtime/packed_func.h:1204
5: tvm::runtime::PackedFuncObj::Extractor<tvm::runtime::PackedFuncSubObj<tvm::relay::backend::RelayBuildModule::GetFunction(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, tvm::runtime::ObjectPtr<tvm::runtime::Object> const&)::{lambda(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)#3}> >::Call(tvm::runtime::PackedFuncObj const*, tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)
at /home/josse/phd/tvm-fork/include/tvm/runtime/packed_func.h:1200
4: tvm::relay::backend::RelayBuildModule::GetFunction(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, tvm::runtime::ObjectPtr<tvm::runtime::Object> const&)::{lambda(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)#3}::operator()(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*) const
at /home/josse/phd/tvm-fork/src/relay/backend/build_module.cc:193
3: tvm::relay::backend::RelayBuildModule::Build(tvm::IRModule, tvm::runtime::Map<tvm::Integer, tvm::Target, void, void> const&, tvm::Target const&, tvm::relay::Executor const&, tvm::relay::Runtime const&, tvm::WorkspaceMemoryPools const&, tvm::runtime::String)
at /home/josse/phd/tvm-fork/src/relay/backend/build_module.cc:312
2: tvm::relay::backend::RelayBuildModule::BuildRelay(tvm::IRModule, tvm::runtime::String const&)
at /home/josse/phd/tvm-fork/src/relay/backend/build_module.cc:483
1: tvm::codegen::CreateMetadataModule(std::unordered_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, tvm::runtime::NDArray, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, tvm::runtime::NDArray> > > const&, tvm::runtime::Module, tvm::runtime::Array<tvm::runtime::Module, void> const&, tvm::Target, tvm::relay::Runtime, tvm::relay::backend::ExecutorCodegenMetadata)
at /home/josse/phd/tvm-fork/src/target/metadata_module.cc:95
0: tvm::runtime::TVMRetValue::operator std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >() const
at /home/josse/phd/tvm-fork/include/tvm/runtime/packed_func.h:823
File "/home/josse/phd/tvm-fork/include/tvm/runtime/packed_func.h", line 823
TVMError:
---------------------------------------------------------------
An error occurred during the execution of TVM.
For more information, please see: https://tvm.apache.org/docs/errors.html
---------------------------------------------------------------
Check failed: type_code_ == kTVMStr (8 vs. 11) : expected str but got Object
I’ve tried going through it with a debugger, using the script provided here: https://github.com/Lunderberg/tvm-gdb-extension . I can set breakpoints and everything, but the provided debugger output is really difficult to work with (might be because I’m inexperienced with GDB), as is also mentioned in this post: Debugging libtvm.so
I also noticed that some files that were involved in the error don’t have any documentation yet on tvm: tvm::codegen Namespace Reference Is this supposed to be this way?
Any help for fixing this issue or helping me debug is greatly appreciated, currently I’m kind of shotgun debugging this, which is not a nice way to work.
Thank you very much!
Kindly pinging @areusch @Mousius @manupa-arm