spectrometerHBH commented on a change in pull request #9699:
URL: https://github.com/apache/tvm/pull/9699#discussion_r772829564
##########
File path: src/arith/iter_affine_map.cc
##########
@@ -347,11 +372,24 @@ class IterMapRewriter : public ExprMutator {
// IterSplit(k,
scale=1)),
// extent=9)
// scale=1))
- std::unordered_map<IterSumExpr, IterMark, IterSumHash, IterSumEqual>
sum_fuse_map_;
+ // Example(2): expr = i*9 + j*2 + k, i in [0, 4) j in [0, 5) k in [0, 2)
+ // predicate: 1 <= j*2 + k < 9
+ // Then, flattened form = IterSum(IterSplit(i, scale=9),
+ // IterSplit(j, scale=2),
+ // IterSplit(k, scale=1))
+ // normal form = IterSum(IterSplit(i, scale=9),
Review comment:
I don't think it's a good idea to rewrite `i*9 + j*2 + k` into such a
normal form `(i*9 + (j*2 + k - 1) + 1)`.
The reason is that `j*2 + k - 1` has extent 8, it's weird that the scale of
i is 9. Actually `i*9 + j*2 + k` with predicate `1 <= j*2 + k < 9` doesn't
correspond to an iter, since the value of it is not continuous. Its value is
`[1, 8] \union [10, 17] \union [19, 26], ...`.
So it looks to me that we shouldn't allow lower bound constraints on
intermediate iters. We can only bound the final iter. In the above case, `i*9 +
j*2 + k >= 1` is legal. while `j*2 + k >= 1` is illegal. We should ban and fail
on such predicates.
This means what you need to do is to
1. Parse the predicate, and divide the predicates into 2 categories: lower
bound constraints and upper bound constraints.
2. Detect iter affine mapping with the input expressions and upper bound
constraints.
3. To check those lower bound constraints are legal, which means they can
only bound the final iter detected from input expressions. It's illegal to
bound the intermediate iters.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]