@@ -1382,14 +1382,27 @@ LogicalResult
1382
1382
bufferization::runOneShotBufferize (Operation *op,
1383
1383
const OneShotBufferizationOptions &options,
1384
1384
BufferizationStatistics *statistics) {
1385
+ // copy-before-write deactivates the analysis. It cannot be used together with
1386
+ // test-analysis-only.
1385
1387
assert (!(options.copyBeforeWrite && options.testAnalysisOnly ) &&
1386
1388
" 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.
1389
1396
if (failed (insertTensorCopies (op, options, statistics)))
1390
1397
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 ();
1391
1403
}
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.
1394
1407
return bufferizeOp (op, options, statistics);
1395
1408
}
0 commit comments