-
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] Introduce iterator (quasi)affine map detection. #6667
Conversation
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.
Some quick comments
|
||
|
||
def isplit(axis, factor): | ||
"""Fuse iterators""" |
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.
Typo
The input indices. | ||
|
||
input_iters : Map[Var, Range] | ||
The domain of each input iterators. |
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.
May be good to add Returns in comment here.
python/tvm/arith/iter_affine_map.py
Outdated
Additional scale to the split. | ||
""" | ||
|
||
def __init__(self, min_value, max_value): |
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.
Incorrect arguments
""" | ||
|
||
def __init__(self, min_value, max_value): | ||
self.__init_handle_by_constructor__(_ffi_api.IterMark, source, extent) |
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.
Inconsistent with function arguments
468db05
to
0260e33
Compare
The loop transformations (split, fuse) create bijective maps from a collection of source iterators to target iterators. DetectIterMap is a function that detects such bijective mappings from the lowered index expression. We choose the term quasi affine to be consistent with the terminology used by in polyhedral compilation. DetectIterMap can handle symbolic integers(in split/fuse) to some extent. The utility can be useful in detecting loop transformation patterns and data layout change patterns in TIR.
include/tvm/arith/iter_affine_map.h
Outdated
* \brief Base class of all iter map expressions. | ||
* | ||
* An IterMapExpr is a special expression to store | ||
* the result of IterMapDetection, it should not |
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.
Would be great to complete the comments
src/arith/iter_affine_map.cc
Outdated
} | ||
}; | ||
|
||
// Rewriter to rewrite oinformations in iter |
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.
Typo
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.
Other parts LGTM
results.push_back(rewriter.Rewrite(value)); | ||
if (rewriter.unresolved_count() != 0) return Array<IterSumExpr>(); | ||
} | ||
if (!rewriter.CheckBijective(results)) return Array<IterSumExpr>(); |
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.
Currently, the Independence check seems to only check that all input marks are iterated. Is that sufficient to ensure independence?
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.
It also checks all the intermediate marks(including the input) are being covered without overlapping
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.
If the indices are y, x, x+1
and input_iters are y, x
, will this be checked?
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, in this case, x and x+1 will contribute two Split entries to mark2split of x, (one contributed by x and another by x+1)
mark2split[x]= [ Split(x, extent), Split(x, extent)]
And it will results in an error because the two splits overlaps with each other
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.
The checks are via the TryNormalizeSplits function
Thanks @spectrometerHBH I addressed your comment and added more explaination about bijective check, I also added your example as a testcase |
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.
Thanks, @tqchen!
* [ARITH] Introduce iterator (quasi)affine map detection. The loop transformations (split, fuse) create bijective maps from a collection of source iterators to target iterators. DetectIterMap is a function that detects such bijective mappings from the lowered index expression. We choose the term quasi affine to be consistent with the terminology used by in polyhedral compilation. DetectIterMap can handle symbolic integers(in split/fuse) to some extent. The utility can be useful in detecting loop transformation patterns and data layout change patterns in TIR. * Update per feedback
* [ARITH] Introduce iterator (quasi)affine map detection. The loop transformations (split, fuse) create bijective maps from a collection of source iterators to target iterators. DetectIterMap is a function that detects such bijective mappings from the lowered index expression. We choose the term quasi affine to be consistent with the terminology used by in polyhedral compilation. DetectIterMap can handle symbolic integers(in split/fuse) to some extent. The utility can be useful in detecting loop transformation patterns and data layout change patterns in TIR. * Update per feedback
* [ARITH] Introduce iterator (quasi)affine map detection. The loop transformations (split, fuse) create bijective maps from a collection of source iterators to target iterators. DetectIterMap is a function that detects such bijective mappings from the lowered index expression. We choose the term quasi affine to be consistent with the terminology used by in polyhedral compilation. DetectIterMap can handle symbolic integers(in split/fuse) to some extent. The utility can be useful in detecting loop transformation patterns and data layout change patterns in TIR. * Update per feedback
* [ARITH] Introduce iterator (quasi)affine map detection. The loop transformations (split, fuse) create bijective maps from a collection of source iterators to target iterators. DetectIterMap is a function that detects such bijective mappings from the lowered index expression. We choose the term quasi affine to be consistent with the terminology used by in polyhedral compilation. DetectIterMap can handle symbolic integers(in split/fuse) to some extent. The utility can be useful in detecting loop transformation patterns and data layout change patterns in TIR. * Update per feedback
The loop transformations (split, fuse) create bijective
maps from a collection of source iterators to target iterators.
DetectIterMap is a function that detects such bijective mappings
from lowered index expressions.
We choose the term quasi affine to be consistent with the
terminology used in polyhedral compilation.
DetectIterMap can handle symbolic integers(in split/fuse) to some extent.
The utility can be useful in detecting loop transformation
patterns and data layout change patterns in TIR.