# AttributeError: Module has no function '\_\_tvm\_main\_\_'

**URL:** <https://discuss.tvm.apache.org/t/attributeerror-module-has-no-function-tvm-main/13069>\
**Category:** Questions\
**Created:** [July 3, 2022, 2:56am UTC](https://discuss.tvm.apache.org/t/attributeerror-module-has-no-function-tvm-main/13069 "2022-07-03T02:56:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![eAzure](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/eazure/32/3763_2.png) [@eAzure](https://discuss.tvm.apache.org/u/eAzure)\
**Post date:** [July 3, 2022, 2:56am UTC](https://discuss.tvm.apache.org/t/attributeerror-module-has-no-function-tvm-main/13069/1 "2022-07-03T02:56:56Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![eAzure](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/eazure/32/3763_2.png) [@eAzure](https://discuss.tvm.apache.org/u/eAzure)\
**Post date:** [July 3, 2022, 2:59am UTC](https://discuss.tvm.apache.org/t/attributeerror-module-has-no-function-tvm-main/13069/2 "2022-07-03T02:59:32Z")

</div>

target=“c” will cause problems “AttributeError: Module has no function ‘ **tvm\_main** ’” Is there something wrong in the code？

---

<div class="post-metadata">

**Author:** ![RunyuLu](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/runyulu/32/4222_2.png) [@RunyuLu](https://discuss.tvm.apache.org/u/RunyuLu)\
**Post date:** [November 10, 2022, 12:38pm UTC](https://discuss.tvm.apache.org/t/attributeerror-module-has-no-function-tvm-main/13069/3 "2022-11-10T12:38:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![RunyuLu](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/runyulu/32/4222_2.png) [@RunyuLu](https://discuss.tvm.apache.org/u/RunyuLu)\
**Post date:** [November 10, 2022, 12:41pm UTC](https://discuss.tvm.apache.org/t/attributeerror-module-has-no-function-tvm-main/13069/4 "2022-11-10T12:41:17Z")

</div>

It may be a problem which need to be explore further about the entry definition. I will study it as possible as I could.

---

<div class="post-metadata">

**Author:** ![denis](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/denis/32/4166_2.png) [@denis](https://discuss.tvm.apache.org/u/denis)\
**Post date:** [January 30, 2023, 3:51am UTC](https://discuss.tvm.apache.org/t/attributeerror-module-has-no-function-tvm-main/13069/5 "2023-01-30T03:51:14Z")

</div>

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](https://tvm.apache.org/docs/tutorial/tensor_ir_blitz_course.html), in which target=“llvm”.

---

<div class="post-metadata">

**Author:** ![Rikora](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/rikora/32/5634_2.png) [@Rikora](https://discuss.tvm.apache.org/u/Rikora)\
**Post date:** [September 10, 2024, 5:20pm UTC](https://discuss.tvm.apache.org/t/attributeerror-module-has-no-function-tvm-main/13069/7 "2024-09-10T17:20:22Z")

</div>

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的问题。
