Skip to content

Commit 179e174

Browse files
[mlir][bufferization][NFC] More documentation for runOneShotBufferize (#90445)
1 parent 55c6bda commit 179e174

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,14 +1382,27 @@ LogicalResult
13821382
bufferization::runOneShotBufferize(Operation *op,
13831383
const OneShotBufferizationOptions &options,
13841384
BufferizationStatistics *statistics) {
1385+
// copy-before-write deactivates the analysis. It cannot be used together with
1386+
// test-analysis-only.
13851387
assert(!(options.copyBeforeWrite && options.testAnalysisOnly) &&
13861388
"invalid combination of bufferization flags");
1387-
if (!options.copyBeforeWrite) {
1388-
// If a buffer is copied before every write, no analysis is needed.
1389+
1390+
if (options.copyBeforeWrite) {
1391+
// Copy buffer before each write. No analysis is needed.
1392+
} else {
1393+
// Run One-Shot Analysis and insert buffer copies (on the tensor level)
1394+
// only where needed. This is the default and much more efficient than
1395+
// copy-before-write.
13891396
if (failed(insertTensorCopies(op, options, statistics)))
13901397
return failure();
1398+
1399+
// If test-analysis-only is set, the IR was annotated with RaW conflict
1400+
// markers (attributes) during One-Shot Analysis.
1401+
if (options.testAnalysisOnly)
1402+
return success();
13911403
}
1392-
if (options.testAnalysisOnly)
1393-
return success();
1404+
1405+
// Bufferize the op and its nested ops. If options.copyBeforeWrite is set,
1406+
// a new buffer copy is allocated every time a buffer is written to.
13941407
return bufferizeOp(op, options, statistics);
13951408
}

0 commit comments

Comments
 (0)