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

computeSliceParameters: use full slice if affine exprs are non-monotonic #407

Merged

Conversation

mgehre-amd
Copy link
Collaborator

@mgehre-amd mgehre-amd commented Dec 3, 2024

computeSliceParameters maps the loop range (given by lower bounds lbs and upper bounds ubs) into the operand tensor to compute the input slices that contains all indexed values.

The computation currently assumes that the affine expressions to map from loop iteration domain to tensor domain are monotonic, and use that information by just evaluating those at lbs and ubs to obtain the slice o the operand tensor.
For non-monotonic expressions, the maximum and minimum values might not be at the boundaries.
Detect that case, and then use the full slice to be safe.

Fixes llvm#111830

If shapes are static, we could be cleverer: sometimes we can prove that even though the affine expression is not monotonic in itself, it is monotonic on the range (lbs, ubs). For example when the affine expression contains a d0 mod 8, and the range is (0, 4).

@mgehre-amd mgehre-amd requested a review from josel-amd December 3, 2024 12:35
@mgehre-amd mgehre-amd requested a review from cferry-AMD December 3, 2024 13:32
Copy link
Collaborator

@cferry-AMD cferry-AMD left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for solving! That's much simpler than using the LexMin and LexMax which I imagined as a fix for that.

@mgehre-amd mgehre-amd enabled auto-merge December 3, 2024 14:32
@mgehre-amd mgehre-amd merged commit 573742a into feature/fused-ops Dec 3, 2024
4 checks passed
@mgehre-amd mgehre-amd deleted the matthias.fix_non_monotonic_slice_params branch December 3, 2024 14:33
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.

[mlir][linalg] Tiling: wrong offset computed when modulo operations are present in access maps
3 participants