[llvm-branch-commits] [mlir] [mlir][memref] Add runtime verification for `memref.copy` (PR #130437)

Matthias Springer via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Mar 11 03:38:10 PDT 2025


================
@@ -182,6 +182,53 @@ struct CastOpInterface
   }
 };
 
+struct CopyOpInterface
+    : public RuntimeVerifiableOpInterface::ExternalModel<CopyOpInterface,
+                                                         CopyOp> {
+  void generateRuntimeVerification(Operation *op, OpBuilder &builder,
+                                   Location loc) const {
+    auto copyOp = cast<CopyOp>(op);
+    BaseMemRefType sourceType = copyOp.getSource().getType();
+    BaseMemRefType targetType = copyOp.getTarget().getType();
+    auto rankedSourceType = dyn_cast<MemRefType>(sourceType);
+    auto rankedTargetType = dyn_cast<MemRefType>(targetType);
+
+    // TODO: Verification for unranked memrefs is not supported yet.
+    if (!rankedSourceType || !rankedTargetType)
----------------
matthias-springer wrote:

It looks like mixed unranked/ranked memrefs are allowed by `SameOperandsShape`.

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


More information about the llvm-branch-commits mailing list