[Mlir-commits] [mlir] caf2661 - [mlir][linalg] Cleanup LinalgOp usage in comprehensive bufferization.

Tobias Gysi llvmlistbot at llvm.org
Mon Jun 7 02:08:55 PDT 2021


Author: Tobias Gysi
Date: 2021-06-07T09:08:13Z
New Revision: caf26612ddb527ad9e89588e7297b4de51013b83

URL: https://github.com/llvm/llvm-project/commit/caf26612ddb527ad9e89588e7297b4de51013b83
DIFF: https://github.com/llvm/llvm-project/commit/caf26612ddb527ad9e89588e7297b4de51013b83.diff

LOG: [mlir][linalg] Cleanup LinalgOp usage in comprehensive bufferization.

Replace the uses of deprecated Structured Op Interface methods in ComprehensiveBufferize.cpp. This patch is based on https://reviews.llvm.org/D103394.

Differential Revision: https://reviews.llvm.org/D103520

Added: 
    

Modified: 
    mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferize.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferize.cpp b/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferize.cpp
index d14281a6b19c8..1c2d32bba8183 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferize.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferize.cpp
@@ -124,7 +124,7 @@ OpResult getMatchingOpResult(LinalgOp linalgOp, OpOperand &opOperand) {
       opOperand.getOperandNumber() - linalgOp.getNumInputs();
   int64_t numOutputBuffers = 0;
   for (unsigned idx = 0; idx < outputOperandIndex; ++idx)
-    if (!linalgOp.getOutputShapedType(idx).isa<TensorType>())
+    if (!linalgOp.getOutputOperand(idx)->get().getType().isa<TensorType>())
       ++numOutputBuffers;
   return linalgOp->getResult(outputOperandIndex - numOutputBuffers);
 }
@@ -414,9 +414,9 @@ allocateBuffersForResults(OpBuilder &b, Location loc, LinalgOp op,
   SmallVector<Range, 4> loopRanges;
 
   // Linalg invariant: output tensors and result match 1-1.
-  assert(op.getNumOutputTensors() == op->getNumResults());
-  for (auto &opOperand : op.getOutputOpOperands()) {
-    Value output = opOperand.get();
+  assert(op.getOutputTensorOperands().size() == op->getNumResults());
+  for (OpOperand *opOperand : op.getOutputOperands()) {
+    Value output = opOperand->get();
     if (output.getType().isa<MemRefType>()) {
       resultBuffers.push_back(output);
       continue;
@@ -425,7 +425,7 @@ allocateBuffersForResults(OpBuilder &b, Location loc, LinalgOp op,
     // If output tensor is marked inPlace, just use the buffer.
     // The following uses internal knowledge of the position of tied operand /
     // results.
-    OpResult tiedResult = getMatchingOpResult(op, opOperand);
+    OpResult tiedResult = getMatchingOpResult(op, *opOperand);
     if (getInPlace(tiedResult) == InPlaceSpec::True) {
       Value v = lookup(bvm, output);
       if (!v)
@@ -440,7 +440,7 @@ allocateBuffersForResults(OpBuilder &b, Location loc, LinalgOp op,
     resultBuffers.push_back(alloc);
 
     // Additionally, if the output buffer is used, clone its value for now.
-    if (op.payloadUsesValueFromOpOperand(&opOperand)) {
+    if (op.payloadUsesValueFromOperand(opOperand)) {
       Value v = lookup(bvm, output);
       if (!v)
         return failure();
@@ -486,8 +486,8 @@ static LogicalResult bufferize(OpBuilder &b, LinalgOp op,
   Location loc = op.getLoc();
   SmallVector<Value, 2> newInputBuffers;
   newInputBuffers.reserve(op.getNumInputs());
-  for (Value in : op.getInputs()) {
-    Value v = lookup(bvm, in);
+  for (OpOperand *opOperand : op.getInputOperands()) {
+    Value v = lookup(bvm, opOperand->get());
     if (!v)
       return failure();
     newInputBuffers.push_back(v);


        


More information about the Mlir-commits mailing list