[Mlir-commits] [mlir] [mlir][transform] Implement `FlattenElementwiseLinalgOp` transform op (PR #81431)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Feb 27 14:38:03 PST 2024


================
@@ -1479,40 +1475,40 @@ Operation *createCollapsedOp(LinalgType op,
       resultTypes.push_back(newOutput.getType());
   }
 
-  if (isa<linalg::CopyOp>(op)) {
-    return rewriter.create<linalg::CopyOp>(loc, inputOperands[0],
-                                           outputOperands[0]);
-  }
+  Operation *collapsedOp = clone(
+      rewriter, op, resultTypes,
+      llvm::to_vector(llvm::concat<Value>(inputOperands, outputOperands)));
 
-  // Get the iterator types for the operand.
-  SmallVector<utils::IteratorType> iteratorTypes =
-      getCollapsedOpIteratorTypes(op.getIteratorTypesArray(), collapsingInfo);
+  if (op->hasAttr("indexing_maps")) {
----------------
srcarroll wrote:

i pushed a modified version of your suggestion. First, i templated the input and output op to enforce that the cloning should be same named op. Second, i didn't want to have both collapsed operands and collapsingInfo as arguments to a function because that leaves room for inconsistency.  And the collapsingInfo is needed for the generic's indexing map. So I did more refactoring with that in mind.  

https://github.com/llvm/llvm-project/pull/81431


More information about the Mlir-commits mailing list