[AffineCFG] Re-arrange sum expression after recreateexpr optimization#2557
Open
xys-syx wants to merge 1 commit into
Open
[AffineCFG] Re-arrange sum expression after recreateexpr optimization#2557xys-syx wants to merge 1 commit into
xys-syx wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2557 +/- ##
=======================================
Coverage 25.46% 25.46%
=======================================
Files 223 223
Lines 44652 44669 +17
=======================================
+ Hits 11370 11375 +5
- Misses 33282 33294 +12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The minimal reproducer example is:
The bug here is:
when
CanonicalieForBoundsapply onaffine.for %j = 0 to affine_map<(d0)[s0] -> (-d0 + s0 - 1)>(%i)[%s]...'s upper bound, the upper bound map and operandsaffine_map<(d0)[s0] -> (-d0 + s0 - 1)>(%i)[%s]will not change, butrecreateExprEnzyme-JAX/src/enzyme_ad/jax/Passes/SimplifyAffineExprs.cpp
Line 453 in 6af35e7
change the tree associations of sum expression:
from
Add(Add(Mul(d0, C-1), s0), C-1)toAdd(Mul(d0, C-1), Add(s0, C-1))causing
--affine-cfgfails to converage.The fix:
I add a
canonicalizeSumto rearrange the sum expression, align with the rule in default mlirsimplifyAdd, https://github.com/llvm/llvm-project/blob/5db7e5b483a32f37d1d77a6f18d2bc4c59fa460a/mlir/lib/IR/AffineExpr.cpp#L662