You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by Sen Yang via Apache TVM Discuss <no...@discuss.tvm.ai> on 2021/08/16 17:32:40 UTC
[Apache TVM Discuss] [Questions] Can't build module after applying
pass MakePackedAPI
Hello, I am studying tir and tir pass recently. And I found after I applying pass `MakePackedAPI`, the function `tvm.build` will throw an error:
```
TVMError:
---------------------------------------------------------------
An error occurred during the execution of TVM.
For more information, please see: https://tvm.apache.org/docs/errors.html
---------------------------------------------------------------
Check failed: (it != info_map_.end()) is false: Load/Store of buffer arg_type_ids (0x55d15e9be390) occurred before its declaration.
```
I am curious about the reason why I can't do that?
Here is my code:
```python
import tvm
from tvm import te
def check_packed_func(target="llvm"):
ib = tvm.tir.ir_builder.create()
m = n = k = 16
a = te.placeholder((m, k), name="a", dtype="float64")
b = te.placeholder((k, n), name="b", dtype="float64")
k = te.reduce_axis((0, k), name="k")
c = te.compute((m, n), lambda i, j: te.sum(a[i, k] * b[k, j], axis=k), name="c")
a_buffer = tvm.tir.decl_buffer(
a.shape, a.dtype, name="a_buffer", offset_factor=1, strides=[te.var("s1"), 1]
)
b_buffer = tvm.tir.decl_buffer(
b.shape, b.dtype, name="b_buffer", offset_factor=1, strides=[te.var("s2"), 1]
)
c_buffer = tvm.tir.decl_buffer(
c.shape, c.dtype, name="c_buffer", offset_factor=1, strides=[te.var("s3"), 1]
)
with ib.for_range(0, 10, "i", kind="parallel"):
ib.emit(tvm.tir.call_packed("tvm.test_matmul", a_buffer, b_buffer, c_buffer))
stmt = ib.get()
# Construct a valid IRModule to be lowered:
mod = tvm.IRModule.from_expr(tvm.tir.PrimFunc([a_buffer, b_buffer, c_buffer], stmt))
target = tvm.target.Target(target)
mod = tvm.tir.transform.Apply(lambda f: f.with_attr("target", target))(mod)
mod = tvm.tir.transform.Apply(lambda f: f.with_attr("global_symbol", "main"))(mod)
mod = tvm.tir.transform.MakePackedAPI()(mod)
return mod
mod = check_packed_func()
tvm.build(mod)
```
---
[Visit Topic](https://discuss.tvm.apache.org/t/cant-build-module-after-applying-pass-makepackedapi/10814/1) to respond.
You are receiving this because you enabled mailing list mode.
To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/9b29fad834e9179b143b0327c7e5ae47d0093b39885e151382cc33dbb8eee8cd).