Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ARITH]const_int_bound doesn't allow INT64_MAX in expr #6913

Closed
lixiaoquan opened this issue Nov 13, 2020 · 3 comments
Closed

[ARITH]const_int_bound doesn't allow INT64_MAX in expr #6913

lixiaoquan opened this issue Nov 13, 2020 · 3 comments

Comments

@lixiaoquan
Copy link
Contributor

Patch to reproduce:

diff --git a/tests/python/unittest/test_arith_const_int_bound.py b/tests/python/unittest/test_arith_const_int_bound.py
index 84fc7fd64..0bcdff487 100644
--- a/tests/python/unittest/test_arith_const_int_bound.py
+++ b/tests/python/unittest/test_arith_const_int_bound.py
@@ -50,6 +50,15 @@ def test_cast_bound():
     assert bd.max_value == 2
 
 
+def test_bound():
+    import numpy as np
+    analyzer = tvm.arith.Analyzer()
+    x, y = te.var("x", "int64"), tvm.tir.const(-np.iinfo(np.int64).max, dtype="int64")
+    bd = analyzer.const_int_bound(x + y)
+    assert bd.min_value == bd.NEG_INF
+    assert bd.max_value == bd.POS_INF
+
+
 def test_add_sub_bound():
     analyzer = tvm.arith.Analyzer()
     x, y = te.var("x", "int64"), te.var("y", "int64")

Because the expr is (x + (int64)-9223372036854775807), it runs into this ICHECK

E             File "/home/xiaoquan.li/tvm/src/arith/const_int_bound.cc", line 455
E           TVMError: 
E           ---------------------------------------------------------------
E           An internal invariant was violated during the execution of TVM.
E           Please read TVM's error reporting guidelines.
E           More details can be found here: https://discuss.tvm.ai/t/error-reporting/7793.
E           ---------------------------------------------------------------
E             Check failed: y != kNegInf == false:

Since -INT64_MAX is used as kNegInf in const_int_bound, does it mean this value shouldn't be used in TIR?

@lixiaoquan lixiaoquan changed the title const_int_bound doesn't allow INT64_MAX in expr [ARITH]const_int_bound doesn't allow INT64_MAX in expr Nov 13, 2020
@masahi
Copy link
Member

masahi commented Nov 13, 2020

maybe related #6911

@tqchen
Copy link
Member

tqchen commented Nov 13, 2020

Please check if #6911 resolves the issue

@lixiaoquan
Copy link
Contributor Author

Thanks all, it is solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants