-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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] Support integer BufferLoad in IntervalSetEvaluator #10327
[Arith] Support integer BufferLoad in IntervalSetEvaluator #10327
Conversation
tests/python/unittest/test_tir_transform_compact_buffer_region.py
Outdated
Show resolved
Hide resolved
T.reads( | ||
A_indptr[i], | ||
A_indptr[i + 1], | ||
A_data[A_indptr[i] + 0 : A_indptr[i] + (A_indptr[i + 1] - A_indptr[i])], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A_data[A_indptr[i] + 0 : A_indptr[i] + (A_indptr[i + 1] - A_indptr[i])], | |
A_data[A_indptr[i] : A_indptr[i + 1]], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to some parser issue we're not allowed to simplify the expression for now:
error: Unsupported index type, expected int or tvm.tir.PrimExpr, but got <class 'tvm.script.tir.node.BufferSlice'>
--> tensorir.py:431:44
|
431 | T.reads(A_indptr[vi : vi + 1], A_data[A_indptr[vi]: A_indptr[vi + 1]])
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: run with `TVM_BACKTRACE=1` environment variable to display a backtrace.
I suppose this is some bug that can be easily fixed, though I didn't get enough time to take a deeper look into the parser.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One problem with this analysis is that we cannot assume A_indptr[i+1] >= A_indptr[i]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I never thought of this before. Is it okay by specifying assume_in_range(A_indptr[i + 1] - A_indptr[i], [0, 127])
in the future? (not pretty sure)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I think so, but we merge this one first.
97c8d56
to
4fe1bb4
Compare
…nge/loop start and end (apache#10370) A quick fix of the parser issue mentioned in apache#10327 . Ranges and loops require `start` and `stop` to be PrimExpr, however, `BufferSlice` is not always scalar so it's not a `PrimExpr`. This PR performs the transformation.
This PR introduces the support of integer BufferLoadNodes in
arith::IntervalSetEvaluator
as well as a unittest.Prior to this PR, the evaluator always return
IntervalSet::Everything()
(that is[-∞, +∞]
) once it encounters a BufferLoad. However, as long as 1) the buffer data is of type integer and 2) the indices of the BufferLoad contain no variable that needs to be relaxed during evaluation, we can keep the BufferLoad as it is.Besides, we're considering introducing
assume_in_range
for buffers for the use of range/region analysis. Withassume_in_range
, even when the indices of BufferLoad contain some variables to be relaxed, we can just return the asserted range, which is more compact, instead of the universe.cc @yzh119 @Hzfengsy @spectrometerHBH @junrushao1994 @tqchen