Skip to content

[ARITH] Introduce iterator (quasi)affine map detection. - #6667

Merged
tqchen merged 2 commits into
apache:mainfrom
tqchen:qaffine
Oct 14, 2020
Merged

[ARITH] Introduce iterator (quasi)affine map detection.#6667
tqchen merged 2 commits into
apache:mainfrom
tqchen:qaffine

Conversation

@tqchen

@tqchentqchen commented Oct 11, 2020

Copy link
Copy Markdown
Member

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.

@tqchen

Copy link
Copy Markdown
MemberAuthor

@spectrometerHBHspectrometerHBH left a comment

Copy link
Copy Markdown
Contributor

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"""

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor

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.

Comment threadpython/tvm/arith/iter_affine_map.py Outdated
Additional scale to the split.
"""

def __init__(self, min_value, max_value):

Copy link
Copy Markdown
Contributor

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent with function arguments

@tqchen
tqchenforce-pushed the qaffine branch 2 times, most recently from 468db05 to 0260e33CompareOctober 12, 2020 02:05
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.
Comment threadinclude/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

Copy link
Copy Markdown
Contributor

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

Comment threadsrc/arith/iter_affine_map.cc Outdated
}
};

// Rewriter to rewrite oinformations in iter

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

@spectrometerHBHspectrometerHBH left a comment

Copy link
Copy Markdown
Contributor

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>();

Copy link
Copy Markdown
Contributor

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?

@tqchentqchenOct 13, 2020

Copy link
Copy Markdown
MemberAuthor

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

Copy link
Copy Markdown
Contributor

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?

@tqchentqchenOct 14, 2020

Copy link
Copy Markdown
MemberAuthor

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

Copy link
Copy Markdown
MemberAuthor

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

@tqchen

Copy link
Copy Markdown
MemberAuthor

Thanks @spectrometerHBH I addressed your comment and added more explaination about bijective check, I also added your example as a testcase

@spectrometerHBHspectrometerHBH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @tqchen!

@tqchen
tqchen merged commit 60ed926 into apache:mainOct 14, 2020
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Oct 29, 2020
* [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
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Dec 2, 2020
* [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
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Dec 4, 2020
* [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
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Dec 4, 2020
* [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
@tqchen
tqchen deleted the qaffine branch February 26, 2023 13:55
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@tqchen@ZihengJiang@spectrometerHBH