Skip to content

[mlir][bufferization][NFC] More documentation for runOneShotBufferize #90445

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1382,14 +1382,27 @@ LogicalResult
bufferization::runOneShotBufferize(Operation *op,
const OneShotBufferizationOptions &options,
BufferizationStatistics *statistics) {
// copy-before-write deactivates the analysis. It cannot be used together with
// test-analysis-only.
assert(!(options.copyBeforeWrite && options.testAnalysisOnly) &&
"invalid combination of bufferization flags");
if (!options.copyBeforeWrite) {
// If a buffer is copied before every write, no analysis is needed.

if (options.copyBeforeWrite) {
// Copy buffer before each write. No analysis is needed.
} else {
// Run One-Shot Analysis and insert buffer copies (on the tensor level)
// only where needed. This is the default and much more efficient than
// copy-before-write.
if (failed(insertTensorCopies(op, options, statistics)))
return failure();

// If test-analysis-only is set, the IR was annotated with RaW conflict
// markers (attributes) during One-Shot Analysis.
if (options.testAnalysisOnly)
return success();
}
if (options.testAnalysisOnly)
return success();

// Bufferize the op and its nested ops. If options.copyBeforeWrite is set,
// a new buffer copy is allocated every time a buffer is written to.
return bufferizeOp(op, options, statistics);
}