TVM error when trying to define multiple modules with the same name
Opened this issue · 0 comments
zzzDavid commented
Description
It seems like defining multiple modules with the same function name is forbidden. But the tool directly prints out the TVM stack trace which is probably not the desired behaviour.
Module Definition
I am trying to implement a series of PEs with a for loop:
# define modules with loop
PE = []
for input_a in range(m):
for input_b in range(n):
@hcl.def_([(1,), (1,), (1,), ()])
def pe(a, b, o, x):
with hcl.if_(x == 0):
o += a * b
hcl.return_(a)
with hcl.else_():
hcl.return_(b)
PE.append(pe)
Error Message
❯ python systolic_array_module.py
Traceback (most recent call last):
File "systolic_array_module.py", line 162, in <module>
fs = systolic_large(2, 2, 2, dtype=hcl.Int(), target="llvm")
File "systolic_array_module.py", line 145, in systolic_large
f = hcl.build(s, target=target)
File "/Users/zhangniansong/.local/lib/python3.7/site-packages/heterocl-0.1-py3.7.egg/heterocl/api.py", line 318, in build
return _build(schedule.sch, new_inputs, target=target, name=name, stmt=stmt)
File "/Users/zhangniansong/.local/lib/python3.7/site-packages/heterocl-0.1-py3.7.egg/heterocl/tvm/build_module.py", line 618, in build
mhost = codegen.build_module(fhost, str(target_host))
File "/Users/zhangniansong/.local/lib/python3.7/site-packages/heterocl-0.1-py3.7.egg/heterocl/tvm/codegen.py", line 20, in build_module
return _Build(lowered_func, target)
File "/Users/zhangniansong/.local/lib/python3.7/site-packages/heterocl-0.1-py3.7.egg/heterocl/tvm/_ffi/function.py", line 280, in my_api_func
return flocal(*args)
File "/Users/zhangniansong/.local/lib/python3.7/site-packages/heterocl-0.1-py3.7.egg/heterocl/tvm/_ffi/_ctypes/function.py", line 183, in __call__
ctypes.byref(ret_val), ctypes.byref(ret_tcode)))
File "/Users/zhangniansong/.local/lib/python3.7/site-packages/heterocl-0.1-py3.7.egg/heterocl/tvm/_ffi/base.py", line 66, in check_call
raise TVMError(py_str(_LIB.TVMGetLastError()))
heterocl.tvm._ffi.base.TVMError: [09:36:51] src/codegen/llvm/codegen_llvm.cc:1336: Check failed: module_->getFunction(op->name) == nullptr Function pe already exist in module
Stack trace returned 10 entries:
[bt] (0) 0 libhcl.dylib 0x000000011078fe4e dmlc::StackTrace() + 254
[bt] (1) 1 libhcl.dylib 0x000000011078fbff dmlc::LogMessageFatal::~LogMessageFatal() + 47
[bt] (2) 2 libhcl.dylib 0x0000000110b82ad3 TVM::codegen::CodeGenLLVM::VisitStmt_(Halide::Internal::KernelDef const*) + 995
[bt] (3) 3 libhcl.dylib 0x000000011084063c TVM::IRFunctor<void (TVM::NodeRef const&, TVM::ir::StmtFunctor<void (Halide::Internal::Stmt const&)>*)>::operator()(TVM::NodeRef const&, TVM::ir::StmtFunctor<void (Halide::Internal::Stmt const&)>*) const + 316
[bt] (4) 4 libhcl.dylib 0x0000000110b81981 TVM::codegen::CodeGenLLVM::VisitStmt_(Halide::Internal::AttrStmt const*) + 2273
[bt] (5) 5 libhcl.dylib 0x000000011084063c TVM::IRFunctor<void (TVM::NodeRef const&, TVM::ir::StmtFunctor<void (Halide::Internal::Stmt const&)>*)>::operator()(TVM::NodeRef const&, TVM::ir::StmtFunctor<void (Halide::Internal::Stmt const&)>*) const + 316
[bt] (6) 6 libhcl.dylib 0x000000011084063c TVM::IRFunctor<void (TVM::NodeRef const&, TVM::ir::StmtFunctor<void (Halide::Internal::Stmt const&)>*)>::operator()(TVM::NodeRef const&, TVM::ir::StmtFunctor<void (Halide::Internal::Stmt const&)>*) const + 316
[bt] (7) 7 libhcl.dylib 0x0000000110b82607 non-virtual thunk to TVM::codegen::CodeGenLLVM::VisitStmt_(Halide::Internal::Block const*) + 23
[bt] (8) 8 libhcl.dylib 0x000000011084063c TVM::IRFunctor<void (TVM::NodeRef const&, TVM::ir::StmtFunctor<void (Halide::Internal::Stmt const&)>*)>::operator()(TVM::NodeRef const&, TVM::ir::StmtFunctor<void (Halide::Internal::Stmt const&)>*) const + 316
[bt] (9) 9 libhcl.dylib 0x0000000110b80d2a TVM::codegen::CodeGenLLVM::VisitStmt_(Halide::Internal::Allocate const*) + 1402