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

WIP experiment with using isl to simplify affine exprs #347

Closed
wants to merge 2 commits into from
Closed

Conversation

ivanradanov
Copy link
Collaborator

Work in progress, currently only dimps the isl expressions and their simplified versions. the changes need to be brought back to mlir

An example of a good simplification we achieved:

 Got aff
{ [i0, i1, i2, i3, i4, i5] -> [(7 + floor((i0)/256) + floor((96 + i0 + 240*floor((i0)/23) + 112*floor((i0)/184) - 256*floor((i0)/256) + 16*floor((7 + 17i0 - 16*floor((i0)/16) + 6*floor((i0)/23))/374))/2160))] }
Gisted aff
{ [i0, i1, i2, i3, i4, i5] -> [(7 + floor((i0)/184) + floor((i0)/256))] }

But we do not manage to simplify everything, for example:

Got aff
{ [i0, i1, i2, i3, i4, i5] -> [(7 + floor((i0)/16) + 15*floor((i0)/23) + 7*floor((i0)/184) - 16*floor((i0)/256) + floor((7 + 17i0 - 16*floor((i0)/16) + 6*floor((i0)/23))/374) - 135*floor((112 + i0 + 240*floor((i0)/23) + 112*floor((i0)/184) - 256*floor((i0)/256) + 16*floor((7 + 17i0 - 16*floor((i0)/16) + 6*floor((i0)/23))/374))/2160))] }
Gisted aff
{ [i0, i1, i2, i3, i4, i5] -> [(7 + floor((i0)/16) + 15*floor((i0)/23) + 7*floor((i0)/184) - 16*floor((i0)/256) + floor((7 + 17i0 - 16*floor((i0)/16) + 6*floor((i0)/23))/374) - 135*floor((112 + i0 + 240*floor((i0)/23) + 112*floor((i0)/184) - 256*floor((i0)/256) + 16*floor((7 + 17i0 - 16*floor((i0)/16) + 6*floor((i0)/23))/374))/2160))] }

Copy link
Member

@wsmoses wsmoses left a comment

Choose a reason for hiding this comment

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

can you mark the formatter as not running on external?

case isl_ast_op_mul:
Res = (LHS * RHS);
break;
case isl_ast_op_div:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ftynse Do you have any insight on the AffineExpr floordiv/ceildiv/mod semantics and how they match the isl_ast_expr semantics regarding whether they floor to -inf or 0 or other edge cases I have not thought of?

@ivanradanov ivanradanov force-pushed the isl branch 2 times, most recently from 476edf4 to ed508c2 Compare February 25, 2025 10:09
@ivanradanov
Copy link
Collaborator Author

Merged manually.

Sign up for free to 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.

2 participants