Commit 934e2f69 authored by Matthias Springer's avatar Matthias Springer
Browse files

[mlir][linalg] ComprehensiveBufferize: Do not copy InitTensorOp results

E.g.:

```
%2 = memref.alloc() {alignment = 128 : i64} : memref<256x256xf32>
%3 = memref.alloc() {alignment = 128 : i64} : memref<256x256xf32>

// ... (%3 is not written to)

linalg.copy(%3, %2) : memref<256x256xf32>, memref<256x256xf32>
vector.transfer_write %11, %2[%c0, %c0] {in_bounds = [true, true]} : vector<256x256xf32>, memref<256x256xf32>
```

Avoid copies of %3 if %3 came directly from an InitTensorOp.

Differential Revision: https://reviews.llvm.org/D109742
parent e90d55e1
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2190,6 +2190,7 @@ static LogicalResult bufferize(OpBuilder &b, VectorTransferOpInterface op,
    newInputBuffer = createNewAllocDeallocPairForShapedValue(
        b, loc, writeOp.source(), aliasInfo);
    Value v = lookup(bvm, writeOp.source());
    if (!isInitTensorOp(writeOp.source()))
      b.create<CopyOp>(loc, v, newInputBuffer);
  } else {
    // InPlace write will result in memref.tensor_load(x) which must