[Mlir-commits] [mlir] [MLIR] Determine contiguousness of memrefs with dynamic dimensions (PR #142421)

James Newling llvmlistbot at llvm.org
Tue Jun 3 10:01:31 PDT 2025


================
@@ -838,6 +838,20 @@ def Builtin_MemRef : Builtin_Type<"MemRef", "memref", [
     ///
     bool areTrailingDimsContiguous(int64_t n);
 
+    /// Return the maximum number of trailing dimensions that can be
----------------
newling wrote:

It might be easier to interpret if this function returned a value in [0, n-1] or [1, n] instead of [0, n]? It could then be defined/interpreted in terms of either the amount the rank can be reduced, or the number of trailing dimensions that can be merged. 

Maybe mention contiguity in the comment here? 

nit: the examples are clear, but I wonder if you could manage to show all the cases using the same rank-3 shape. Just in terms of keeping it as simple as possible!

```
memref<5x3x2xi8, strided<[6,2,1]>>
memref<5x3x2xi8, strided<[100,2,1]>>  
memref<5x3x2xi8, strided<[100,10,1]>>  
memref<5x3x2xi8, strided<[100,10,4]>>    
memref<?x3x2xi8, strided<[100,2,1]>>    
memref<5x?x2xi8, strided<[?,2,1]>> 
```


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


More information about the Mlir-commits mailing list