[Mlir-commits] [mlir] [MLIR][Tensor, MemRef] Fold expand_shape and collapse_shape if identity (PR #80658)

Matthias Springer llvmlistbot at llvm.org
Mon Feb 19 09:49:06 PST 2024


================
@@ -462,6 +448,34 @@ func.func @collapse_shape_invalid_reassociation(%arg0: memref<?x?x?xf32>) {
 
 // -----
 
+// An (invalid) attempt at using collapse_shape to increase the rank might look
+// like this. Verify that a sensible error is emitted in this case.
+func.func @collapse_shape_invalid_reassociation_expansion(%arg0: memref<?xf32>) {
+  // expected-error @+1 {{reassociation indices must be contiguous}}
----------------
matthias-springer wrote:

nit: imo the error message is bit harder to understand than before. If we keep the extra rank check in the verifier, we could produce a nicer error message, something along the lines of `expected that result rank <= source rank`. But you are right, it is redundant because we would fail later anyway. Up to you, you can also merge it as is.


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


More information about the Mlir-commits mailing list