[Mlir-commits] [mlir] [mlir][Linalg] Add transform to convert linalg.copy into memref.copy (PR #132422)

Pablo Antonio Martinez llvmlistbot at llvm.org
Fri Mar 28 10:45:01 PDT 2025


================
@@ -559,6 +559,40 @@ def InterchangeOp : Op<Transform_Dialect, "structured.interchange",
   }];
 }
 
+//===----------------------------------------------------------------------===//
+// LinalgCopyToMemrefOp
+//===----------------------------------------------------------------------===//
+
+def LinalgCopyToMemrefOp :
+    Op<Transform_Dialect, "structured.linalg_copy_to_memref",
+      [FunctionalStyleTransformOpTrait, MemoryEffectsOpInterface,
+       TransformEachOpTrait, TransformOpInterface]> {
+  let description = [{
+    Targeted rewrite of a linalg.copy on memrefs to a memref.copy.
+    This is useful when bufferizing copies to a linalg.copy, later applying some
+    transformations, and then rewriting the copy into a memref.copy.
+    If the input has different element type in the source and destination,
----------------
pabloantoniom wrote:

Well, actually no. It should also transform copies where memrefs have strides/offsets (unless this is unsupported by `memref.copy`, please correct me if I'm wrong), so just checking the type would result in non-transformed IR, where it should. Because of this little detail I have also added a new test to demonstrate that this is the intended behaviour and that this works properly.

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


More information about the Mlir-commits mailing list