Verify unranked -> ranked casts and casts of dynamic sizes/offset/strides to static ones.
Depends On D138647
Differential D138671
[mlir][memref] Add runtime verification for memref::CastOp springerm on Nov 24 2022, 7:12 AM. Authored by
Details Verify unranked -> ranked casts and casts of dynamic sizes/offset/strides to static ones. Depends On D138647
Diff Detail
Event TimelineComment Actions Looks good to me. But can we add more tests. For example, the case below, here c2 should be verified by your code but c3 should fail, right? func.func @c1(%m: memref<?x?xf32>) -> memref<*xf32> { %0 = memref.cast %m : memref<?x?xf32> to memref<*xf32> return %0 : memref<*xf32> } func.func @c2(%m: memref<*xf32>) -> memref<?x?xf32> { %0 = memref.cast %m : memref<*xf32> to memref<?x?xf32> return %0 : memref<?x?xf32> } func.func @c3(%m: memref<*xf32>) -> memref<?xf32> { %0 = memref.cast %m : memref<*xf32> to memref<?xf32> return %0 : memref<?xf32> } func.func @main() { %a = memref.alloc() : memref<5x5xf32> %c = memref.cast %a : memref<5x5xf32> to memref<?x?xf32> %res = func.call @c1(%c) : (memref<?x?xf32>) -> memref<*xf32> func.call @c2(%res) : (memref<*xf32>) -> (memref<?x?xf32>) func.call @c3(%res) : (memref<*xf32>) -> (memref<?xf32>) return } Also, runtime error text does not tell me which code/location fails. It prints the following text for example. I am not sure you can print the location correctly, but can we at least print the problematic IR? |