[MLIR] Strided memrefs

Hi all,
I am trying to tile memrefs as tiles 32 x 32 (below):

<block argument> of type 'memref<500x500xf32, affine_map<(d0, d1) -> 
(d0 floordiv 32, d1 floordiv 32, d0 mod 32, d1 mod 32)>>' at index: 2

The issue arises when I attempt to lower an ExtractSliceOp to a SubViewOp - the following assert is thrown:

Assertion failed: (succeeded(res) && 
"SubViewOp expected strided memref type"), 
function inferResultType, file MemRefOps.cpp, line 1822.

My confusion arises as if I do not attempt to tile the memref and pass it as is (i.e. without striding and tiling), then it lowers without any issues. It is only when I attempt to provide a layout map that it requests striding.
My questions is what is the relationship between striding and layout maps, and how do I create strided and tiled memrefs? Thanks :slight_smile:

Check the documentation on what a strided memref is - Builtin Dialect - MLIR. It is a specific layout that has a well-behaved C-level representation. memref<500x500xf32, affine_map<(d0, d1) -> (d0 floordiv 32, d1 floordiv 32, d0 mod 32, d1 mod 32)>> is not strided. Most non-trivial memref operations work only on strided memrefs. It is impossible to lower memrefs other than strided to LLVM IR directly. You can try running --memref-normalize to extract layout maps into the explicit address computation before lowering further.