You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/08/05 04:38:38 UTC
[GitHub] [tvm] UniverseFly opened a new issue #8666: [TIR][Python] Misbehavior: {tir.const(1), tir.const(True)} throws ValueError
UniverseFly opened a new issue #8666:
URL: https://github.com/apache/tvm/issues/8666
To reproduce the problem:
```python
>>> from tvm import tir
>>> int_1, bool_t = tir.const(1), tir.const(True)
>>> s = {int_1, bool_t}
~tvm/python/tvm/tir/expr.py in __nonzero__(self)
171 def __nonzero__(self):
172 raise ValueError(
--> 173 "Cannot use and / or / not operator to Expr, hint: "
174 + "use tvm.tir.all / tvm.tir.any instead"
175 )
ValueError: Cannot use and / or / not operator to Expr, hint: use tvm.tir.all / tvm.tir.any instead
```
After some inspection, I guess I could elaborate on the steps leading to this issue:
- During the construction of `s`, the `__hash__` of `int_1` and `bool_t` are compared, which are both `1`.
- Since they have the same hash value, Python needs to further consider whether the two objects are the same before finishing set construction, which in turn concerns the `__eq__` operator.
- `__eq__` of `tir.IntImm` calls `_ffi_api._OpEQ`, which returns a `tir.EQ(int_1, bool_t)` given that constant folding doesn’t happen.
- Python wants to convert the this `tir.EQ` to `bool`, which calls `__bool__` of `tir.EQ` that inherits `__bool__` of `tir.ExprOp`, which calls `__nonzero__`, which finally raises `ValueError`.
I’m not sure whether this problem can be solved through simple fix since it involves the design of the operator sugar of TIR in Python-level.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] UniverseFly commented on issue #8666: [TIR][Python] Misbehavior: {tir.const(1), tir.const(True)} throws ValueError
Posted by GitBox <gi...@apache.org>.
UniverseFly commented on issue #8666:
URL: https://github.com/apache/tvm/issues/8666#issuecomment-898174216
Fixed in https://github.com/apache/tvm/pull/8706
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] UniverseFly closed issue #8666: [TIR][Python] Misbehavior: {tir.const(1), tir.const(True)} throws ValueError
Posted by GitBox <gi...@apache.org>.
UniverseFly closed issue #8666:
URL: https://github.com/apache/tvm/issues/8666
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org