-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[MLIR][NFC] Adding a missing option in OneShotBufferizePass #130691
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
base: main
Are you sure you want to change the base?
Conversation
it missed one option which is inherited from BufferizationOptions.
@llvm/pr-subscribers-mlir Author: Alan Li (lialan) Changes#129850 removed let constructor for Full diff: https://github.com/llvm/llvm-project/pull/130691.diff 2 Files Affected:
diff --git a/mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.td b/mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.td
index 3bbb8b02c644e..b979f9df620d2 100644
--- a/mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.td
+++ b/mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.td
@@ -450,6 +450,10 @@ def OneShotBufferizePass : Pass<"one-shot-bufferize", "ModuleOp"> {
Option<"bufferAlignment", "buffer-alignment", "uint64_t",
/*default=*/"64",
"Sets the alignment of newly allocated buffers.">,
+ Option<"enforceAliasingInvariants", "enforce-aliasing-invariants", "bool",
+ /*default=*/"true",
+ "Enforce aliasing Op/Operand/OpResult invariants with buffer"
+ " copies.">,
];
let statistics = [
diff --git a/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp b/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
index c0e3fca428376..f4891a317476d 100644
--- a/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
+++ b/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
@@ -81,6 +81,7 @@ struct OneShotBufferizePass
opt.allowUnknownOps = allowUnknownOps;
opt.analysisFuzzerSeed = analysisFuzzerSeed;
opt.analysisHeuristic = parseHeuristicOption(analysisHeuristic);
+ opt.enforceAliasingInvariants = enforceAliasingInvariants;
opt.copyBeforeWrite = copyBeforeWrite;
opt.dumpAliasSets = dumpAliasSets;
opt.setFunctionBoundaryTypeConversion(
|
@llvm/pr-subscribers-mlir-bufferization Author: Alan Li (lialan) Changes#129850 removed let constructor for Full diff: https://github.com/llvm/llvm-project/pull/130691.diff 2 Files Affected:
diff --git a/mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.td b/mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.td
index 3bbb8b02c644e..b979f9df620d2 100644
--- a/mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.td
+++ b/mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.td
@@ -450,6 +450,10 @@ def OneShotBufferizePass : Pass<"one-shot-bufferize", "ModuleOp"> {
Option<"bufferAlignment", "buffer-alignment", "uint64_t",
/*default=*/"64",
"Sets the alignment of newly allocated buffers.">,
+ Option<"enforceAliasingInvariants", "enforce-aliasing-invariants", "bool",
+ /*default=*/"true",
+ "Enforce aliasing Op/Operand/OpResult invariants with buffer"
+ " copies.">,
];
let statistics = [
diff --git a/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp b/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
index c0e3fca428376..f4891a317476d 100644
--- a/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
+++ b/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
@@ -81,6 +81,7 @@ struct OneShotBufferizePass
opt.allowUnknownOps = allowUnknownOps;
opt.analysisFuzzerSeed = analysisFuzzerSeed;
opt.analysisHeuristic = parseHeuristicOption(analysisHeuristic);
+ opt.enforceAliasingInvariants = enforceAliasingInvariants;
opt.copyBeforeWrite = copyBeforeWrite;
opt.dumpAliasSets = dumpAliasSets;
opt.setFunctionBoundaryTypeConversion(
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we have test coverage for this option?
I looked and I don't think we have one. |
Can we get some? |
To be fair most (if not all) of those options in the bufferization passes do not have corresponding tests, so #129850 skipped a lot of checks and got merged. If we want tests we would need to also cover all those. But historically no tests were in place, and adding tests is beyond the scope of this quick patch, and requires some coordination. Our downstream does require to set this specific option, so this is just a quick patch to unblock downstream. |
I don’t think #129850 “skipped a lot of checks.” The issue isn’t with #129850 itself but rather the lack of testing for options. I did not check this pass option yet, so I don't know how hard it is to add a test, but I will do it tomorrow. |
@chelini Meanwhile can you approve this PR so we can get unblocked. |
I don't think it is OK to approve this PR because of downstream issue: if you have downstream issues you can always patch MLIR when you're consuming it downstream. Rushing PRs upstream because of quirks of your private downstream repo does not seem right to me. We shouldn't expose options that are not tested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Marking as needed changes)
Are you using this flag together with /// Certain ops have aliasing OpOperand/OpResult invariants (e.g., scf.for).
/// If this flag is set to `false`, those invariants are no longer enforced
/// with buffer copies.
///
/// Note: Deactivating this flag can lead to incorrect bufferization results
/// when used incorrectly. This flag is useful with
/// `AlwaysCopyAnalysisState` which bufferizes all writing tensor
/// OpOperands out-of-place.
bool enforceAliasingInvariants = true; If you set if (!state.getOptions().enforceAliasingInvariants ||
state.getOptions().copyBeforeWrite)
return success(); It's been a while since I looked at this, but maybe we can remove |
I am trying to add a simple test case but I don't see any difference in the IR and the bufferization analysis state, here the simple test case:
It triggers the option but there is no IR difference. I would have expected a copy if I set it to false here. |
What flag did you set? |
I am testing with:
|
On a high level, |
@lialan FYI: I commented out the option in IREE and run |
#129850 removed let constructor for
OneShotBufferizePass
, however the list of tablegen options missed one inherited fromBufferizationOptions
.