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

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Feb 16 22:08:58 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]);
-  }
-
-  // Get the iterator types for the operand.
-  SmallVector<utils::IteratorType> iteratorTypes =
-      getCollapsedOpIteratorTypes(op.getIteratorTypesArray(), collapsingInfo);
+  Operation *collapsedOp = clone(
+      rewriter, op, resultTypes,
+      llvm::to_vector(llvm::concat<Value>(inputOperands, outputOperands)));
+
+  // TODO: Find a more general way to determine if op requires explicit
+  // indexing_maps and iterator_types
+  if (isa<linalg::GenericOp>(op)) {
----------------
MaheshRavishankar wrote:

To start with you can just have the method return a `LogicalResult` and the default implementation return `failure()`and only add the implementation for ops that you want to support. Those can be filled in over time.

On second thought maybe instead of going full interface method, just add a templated method in this file for cloning? The default can be for handling named ops, and the generic op can get its specialization 

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


More information about the Mlir-commits mailing list