[mlir][linalg] Cleanup LinalgOp usage in bufferize, detensorize, and interchange.
authorTobias Gysi <gysit@google.com>
Thu, 3 Jun 2021 11:32:11 +0000 (11:32 +0000)
committerTobias Gysi <gysit@google.com>
Thu, 3 Jun 2021 12:07:29 +0000 (12:07 +0000)
Replace the uses of deprecated Structured Op Interface methods in Bufferize.cpp, Detensorize.cpp, and Interchange.cpp. The patch is based on https://reviews.llvm.org/D103394.

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

mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp
mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp
mlir/lib/Dialect/Linalg/Transforms/Interchange.cpp

index 1e627fe..757f336 100644 (file)
@@ -54,7 +54,8 @@ allocateBuffersForResults(Location loc, LinalgOp linalgOp, ValueRange outputs,
     Value resultTensor = outputs[resultIndex];
 
     // Clone output buffers whose value is actually used.
-    if (linalgOp.payloadUsesValueFromOutputOperandIndex(resultIndex)) {
+    OpOperand *tiedOpOperand = linalgOp.getOutputOperand(resultIndex);
+    if (linalgOp.payloadUsesValueFromOperand(tiedOpOperand)) {
       resultBuffers.push_back(cloneMemref(loc, resultTensor, b));
       continue;
     }
index c4056d9..fd26f67 100644 (file)
@@ -48,10 +48,11 @@ bool canBeDetensored(TensorType tensorType) {
 
 bool shouldBeDetensored(Operation *op, TypeConverter typeConverter) {
   GenericOp genericOp = dyn_cast_or_null<GenericOp>(op);
-  return genericOp && llvm::all_of(genericOp.getShapedOperandTypes(),
-                                   [&](ShapedType shapedType) {
-                                     return !typeConverter.isLegal(shapedType);
-                                   });
+  return genericOp &&
+         llvm::all_of(
+             genericOp.getInputAndOutputOperands(), [&](OpOperand *opOperand) {
+               return !typeConverter.isLegal(opOperand->get().getType());
+             });
 }
 
 /// A conversion patttern for detensoring `linalg.generic` ops.
index add8b40..d94fa30 100644 (file)
@@ -56,9 +56,8 @@ void mlir::linalg::interchangeGenericOp(PatternRewriter &rewriter,
 
   // 2. Compute the interchanged indexing maps.
   SmallVector<Attribute, 4> newIndexingMaps;
-  ArrayRef<Attribute> indexingMaps = genericOp.indexing_maps().getValue();
-  for (unsigned i = 0, e = genericOp.getNumShapedOperands(); i != e; ++i) {
-    AffineMap m = indexingMaps[i].cast<AffineMapAttr>().getValue();
+  for (OpOperand *opOperand : genericOp.getInputAndOutputOperands()) {
+    AffineMap m = genericOp.getTiedIndexingMap(opOperand);
     if (!permutationMap.isEmpty())
       m = m.compose(permutationMap);
     newIndexingMaps.push_back(AffineMapAttr::get(m));