Skip to content
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] Updated arith::DetectIterMap to keep extent=1 components #10980

Merged
merged 3 commits into from
Apr 15, 2022

Conversation

Lunderberg
Copy link
Contributor

Previously, arith::DetectIterMap simplified the output expression by replacing iteration variables with extent==1 with their value. This prevented the return value from being used in arith::InverseAffineIterMap to solve for the variable, as it no longer existed in the returned expressions.

This commit changes arith::DetectIterMap to keep the iteration variable even if extent==1, and adds a motivating unit test that requires this updated behavior.

Previously, arith::DetectIterMap simplified the output expression by
replacing iteration variables with extent==1 with their value.  This
prevented the return value from being used in
arith::InverseAffineIterMap to solve for the variable, as it no longer
existed in the returned expressions.

This commit changes arith::DetectIterMap to keep the iteration
variable even if extent==1, and adds a motivating unit test that
requires this updated behavior.
@Lunderberg Lunderberg force-pushed the layout_transform_unitary_dimension branch from df4919c to bbe87af Compare April 12, 2022 19:30
@Lunderberg
Copy link
Contributor Author

Following a discussion with @vinx13. All tests in test_arith_iter_affine_map.py and test_transform_layout.py pass locally. It's possible that the change to DetectIterMap's simplifications will result in failures elsewhere, so I'm watching the CI.

@vinx13
Copy link
Member

vinx13 commented Apr 12, 2022

To avoid breaking existing test cases, updated to maintain the same
default behavior, but a flag to maintain trivial iterators in the
result.
@Lunderberg
Copy link
Contributor Author

CI confirms that there are definitely locations that rely on simplifications being performed as part of DetectIterMap. Taking a glance at the 24 failures, some would be short updates to the test cases, but others fail by breaking internal assumptions. I've added another commit to maintain the same default behavior of simplifying trivial iterators as part of DetectIterMap, but using a flag to maintain them in the output when needed.

@Lunderberg Lunderberg marked this pull request as ready for review April 14, 2022 15:07
@vinx13
Copy link
Member

vinx13 commented Apr 14, 2022

To make the API consistent, could you also update the FFI API https://github.com/apache/tvm/blob/main/src/arith/iter_affine_map.cc#L943-L948?

Copy link
Member

@Hzfengsy Hzfengsy left a comment

Choose a reason for hiding this comment

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

LGTM, if you can update the FFI API as @vinx13's suggestion

@Lunderberg
Copy link
Contributor Author

Certainly, and thank you for catching it! The FFI and the Python API have been updated to expose the simplify_trivial_iterators argument.

@vinx13 vinx13 merged commit 8bfe3bb into apache:main Apr 15, 2022
@Lunderberg Lunderberg deleted the layout_transform_unitary_dimension branch April 15, 2022 19:49
Lucien0 pushed a commit to Lucien0/tvm that referenced this pull request Apr 19, 2022
…che#10980)

* [Arith] Updated arith::DetectIterMap to keep extent=1 components

Previously, arith::DetectIterMap simplified the output expression by
replacing iteration variables with extent==1 with their value.  This
prevented the return value from being used in
arith::InverseAffineIterMap to solve for the variable, as it no longer
existed in the returned expressions.

This commit changes arith::DetectIterMap to keep the iteration
variable even if extent==1, and adds a motivating unit test that
requires this updated behavior.

* Updated to retain default behavior of DetectIterMap

To avoid breaking existing test cases, updated to maintain the same
default behavior, but a flag to maintain trivial iterators in the
result.

* Updated FFI and Python API for DetectIterMap
altanh pushed a commit to altanh/tvm that referenced this pull request Apr 28, 2022
…che#10980)

* [Arith] Updated arith::DetectIterMap to keep extent=1 components

Previously, arith::DetectIterMap simplified the output expression by
replacing iteration variables with extent==1 with their value.  This
prevented the return value from being used in
arith::InverseAffineIterMap to solve for the variable, as it no longer
existed in the returned expressions.

This commit changes arith::DetectIterMap to keep the iteration
variable even if extent==1, and adds a motivating unit test that
requires this updated behavior.

* Updated to retain default behavior of DetectIterMap

To avoid breaking existing test cases, updated to maintain the same
default behavior, but a flag to maintain trivial iterators in the
result.

* Updated FFI and Python API for DetectIterMap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants