[Mlir-commits] [mlir] Support folding of higher dimensional memeref subviews in XeGPUFoldAliasOps (PR #99593)

Adam Siemieniuk llvmlistbot at llvm.org
Fri Jul 19 10:53:48 PDT 2024


================
@@ -48,15 +50,51 @@ LogicalResult XegpuCreateNdDescOpSubViewOpFolder::matchAndRewrite(
     return rewriter.notifyMatchFailure(descOp, "not a subview producer");
   if (!subViewOp.hasUnitStride())
     return rewriter.notifyMatchFailure(descOp, "requires unit strides");
+  if (!subViewOp.getSource().getType().hasStaticShape())
+    return rewriter.notifyMatchFailure(descOp, "requires static shape");
 
   SmallVector<Value> resolvedOffsets;
   affine::resolveIndicesIntoOpWithOffsetsAndStrides(
       rewriter, descOp.getLoc(), subViewOp.getMixedOffsets(),
       subViewOp.getMixedStrides(), subViewOp.getDroppedDims(),
       descOp.getMixedOffsets(), resolvedOffsets);
 
+  auto updatedSource = subViewOp.getSource();
+  // If the source memref rank is greater than 2, we need to cast the source to
+  // 2D and compute the height, width offsets relative to that.
+  if (resolvedOffsets.size() > 2) {
----------------
adam-smnk wrote:

`memref.collapse_shape` seems more suitable here.

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


More information about the Mlir-commits mailing list