-
Notifications
You must be signed in to change notification settings - Fork 0
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
[DISCUSS] Revisit Buffer Boundary Check & Region Cover Check #138
Comments
An insight from above examples is that block itself is not enough, the detailed data flow and dependency between blocks matter. But to calculate the exact IO regions is intractable. I'm trying to figure out ways to get around it. |
As far as I know, if a block is continuous, (which means it can produce any part of the buffer A as we want). It always can be compute_at, but may bring repeated calculation. However, if a block has limited elements that can be produced (e.g., a block can only write A[1], A[3], but cannot write A[2], A[4]), the compute_at for this block must be baned. |
In the particular case of reverse_compute_at. Let us focus on a more restricted condition than compute at that does not allow relaxation, which is most of our use cases. (e.g. conv2d follows bias add and bn |
To also specific discuss the problem below, there are possibly two options to check A's covering, both are related:
NOTE that the iterator coupling matters if we want to do conservative analysis. For example The analysis goes as follows, for each subexpr, we want to map it to an iterator plus the conservative bound of that iterator.
Related, canonical simplify: https://github.com/apache/incubator-tvm/blob/master/src/arith/canonical_simplify.cc#L88 |
apache/tvm#6667 Should provide the necessary utility. We might still make some enhancement based on the usecases we find(e.g. add predication => constraint, and better symbolic support) but the overal infra should solve the problem to some extent |
I've been revisiting
compute_at
and working onreverse_compute_at
these days, and I've been thinking over the issue of buffer boundary check apache/tvm#6596.I put some of my thoughts here for discussion.
A buffer boundary check problem in current compute_at
The basic logic of current
compute_at(input_block, input_loop)
isHence, after
compute_at
, input_block may produce more than before, which consumes more input and can lead to access out of input buffers' boundary.A clear solution to this problem is to add a predicate in block.where to do buffer boundary check.
Region Cover Check
I introduce region cover check in
compute_at
to restrict the data flow. It is still important inreverse_compute_at
.For example (see also #102 )
Before the transformation,
D
actually doesn't consume all the output of opaque_produce, and may consume elements out of the output of opaque_produce, we have to add a predicate to fix the data flow.However, it is not trivial to judge whether the region cover is satisfied.
Region Cover Check is non-trivial
See also #45
To check if A's output covers B's input under some loop i, we can not relax A's output region, otherwise, the data flow will be problematic and the check is meaningless.
The text was updated successfully, but these errors were encountered: