import tvm
from tvm.ir.module import IRModule
from tvm import te
import numpy as np
A = te.placeholder((8,), dtype=“float32”, name=“A”)
B = te.compute((8,), lambda i:A[i]+1.0, name=“B”)
func = te.create_prim_func([A,B])
ir_module_from_te = IRModule({“main”: func})
mod_from_te = tvm.build(ir_module_from_te, target=“c”)
a = tvm.nd.array(np.arange(8).astype(“float32”))
print(a)
b = tvm.nd.array(np.zeros((8,)).astype(“float32”))
mod_from_te(a,b)
print(b)
target=“c” will cause problems “AttributeError: Module has no function ‘tvm_main ’”
Is there something wrong in the code?
RunyuLu
November 10, 2022, 12:38pm
3
Hi, I also met this problem. When I use llvm as the target, all works well. But if I specify the target is ‘C’, there will be this error.
RunyuLu
November 10, 2022, 12:41pm
4
It may be a problem which need to be explore further about the entry definition. I will study it as possible as I could.
denis
January 30, 2023, 3:51am
5
I met this problem, too. If I specify the target is ‘c’, it doesn’t work. However, when I use ‘llvm’ as the target, it works.
Here is the Tensor IR tutorial , in which target=“llvm”.
Rikora
September 10, 2024, 5:20pm
7
I am facing the same issue now. Is there a straightforward method to fix that without a ‘export-load’ hack?
By the way, for opencl program, ‘c’ as ‘target_host’, export the module and reload does not work. It still met Module has no function ‘tvm_main ’.
我现在也遇到这个问题了。现在可以正面解决这个问题了吗?
顺便,我试了试opencl程序,c作为host后端,导出共享库再导入依然会遇到找不到main的问题。