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 Michael via Apache TVM Discuss <no...@discuss.tvm.ai> on 2021/03/08 08:26:14 UTC
[Apache TVM Discuss] [Questions] If_scope in ir_builder
Hi, I'm using the ir_builder to contrust a cuda kernel, but I encounter a problem of if_scope
```
ib = tvm.tir.ir_builder.create()
n = te.size_var("n")
A = ib.pointer("float32", name="A")
tmod = tvm.tir.truncmod
with ib.for_range(0, n, name="i") as i:
with ib.if_scope(tmod(i, 2) == 0):
A[i] = A[i] + 1
b = 100
with ib.else_scope():
A[0] = A[i] + 2
b = 200
A[3] = b
```
I find some error occurred. The problem is that ir builder will fold the variable python automatically. In my case, this python code did not appeared in my if_else_scope. Is there any approach to solve this problem?
Appreciate for any explanation of this or any suggestions about this issue. Thanks in advance!
---
[Visit Topic](https://discuss.tvm.apache.org/t/if-scope-in-ir-builder/9332/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/3b2a1c7d032219dda12398c55e81d1185456b8ffd3636923e1ac43ef2d708133).
[Apache TVM Discuss] [Questions] If_scope in ir_builder
Posted by Michael via Apache TVM Discuss <no...@discuss.tvm.ai>.
Thank you @leeexyz. Yeah, we can use ```tvm.tir.const``` or a new buffer. I means, it there any mechanism to prevent users using python variables within a ```if_scope```. For example, error message to tell users to utilize ```tvm.tir.const``` since it's quite easy to confuse the python variable with tvm Expr. It still works sometimes event thought we define some python variables within a ```if_scope```. That really causes me a lot of trouble.
---
[Visit Topic](https://discuss.tvm.apache.org/t/if-scope-in-ir-builder/9332/3) 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/ee271675e3243c7cc65ce4c3ec8cca16cde2ab1cc549d855fc20d90261db3dfb).
[Apache TVM Discuss] [Questions] If_scope in ir_builder
Posted by leeexyz via Apache TVM Discuss <no...@discuss.tvm.ai>.
Hi @SYangDong, use `b = tvm.tir.const(100, dtype="float32")` instead of the assgiment directly.
---
[Visit Topic](https://discuss.tvm.apache.org/t/if-scope-in-ir-builder/9332/2) 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/e0e1f62852f51208b8ab25fb707618e687bb66ffa3c9cc065bdbbaa8847d010e).