Skip to content

Commit cb73e69

Browse files
Improve gpu::MemcpyOp verifier
Emit error in case either of the arguments are not ranked memrefs or have non identity layout.
1 parent 21198c0 commit cb73e69

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

mlir/lib/Dialect/GPU/IR/GPUDialect.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,8 +1838,14 @@ static void printOffloadingHandler(OpAsmPrinter &printer, Operation *op,
18381838
//===----------------------------------------------------------------------===//
18391839

18401840
LogicalResult MemcpyOp::verify() {
1841-
auto srcType = getSrc().getType();
1842-
auto dstType = getDst().getType();
1841+
auto srcType = getSrc().getType().dyn_cast<MemRefType>();
1842+
auto dstType = getDst().getType().dyn_cast<MemRefType>();
1843+
1844+
if (!srcType || !dstType)
1845+
return emitOpError("arguments must be ranked memrefs");
1846+
1847+
if (!srcType.getLayout().isIdentity() || !dstType.getLayout().isIdentity())
1848+
return emitOpError("arguments must have identity layout");
18431849

18441850
if (getElementTypeOrSelf(srcType) != getElementTypeOrSelf(dstType))
18451851
return emitOpError("arguments have incompatible element type");

0 commit comments

Comments
 (0)