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

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Feb 16 09:00:56 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)) {
----------------
srcarroll wrote:

Yah i know all `LinalgOp`s have these attrs and the corresponding getters.  But most of the structured ops don't have an explicit attr for indexing maps and iterator types. so if i unconditionally try to set them, i will end up with named ops with additional attrs that aren't at all associated with the implicit ones.  I'm sure there's a way to do this correctly. I just dont know.

I'm not sure how any of this would work without cloning the op (other than having a switch statement checking every single linalg op that exists).  Of course the alternative is to just always convert to a `linalg.generic` op. But I dont like that. I much prefer keeping the named op and that's why I chose to clone.

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


More information about the Mlir-commits mailing list