[Mlir-commits] [mlir] [mlir][vector] Extend vector.transfer_read drop unit dim pattern (PR #72142)

Cullen Rhodes llvmlistbot at llvm.org
Mon Nov 13 10:19:25 PST 2023


c-rhodes wrote:

For context, this and #72105 enable the lowering of a regular `linalg.matmul` to ArmSME (#72144). The integration test in #72144 can't currently be lowered because of the following sequence (taken from the inner loop):
```
%subview = memref.subview %arg0[%arg3, %arg5] [%2, 1] [1, 1] : memref<?x?xf32, strided<[?, ?], offset: ?>> to memref<?x1xf32, strided<[?, ?], offset: ?>>
%mask = vector.create_mask %2, %c1 : vector<[4]x1xi1>
%0 = vector.transfer_read %subview[%c0, %c0], %pad, %mask {in_bounds = [true, true]} : memref<?x1xf32, strided<[?, ?], offset: ?>>, vector<[4]x1xf32>
%1 = vector.transpose %0, [1, 0] : vector<[4]x1xf32> to vector<1x[4]xf32>
%2 = vector.extract %1[0] : vector<[4]xf32> from vector<1x[4]xf32>
```
the `vector.transfer_read` is of a rank-2 vector type with leading scalable dim. This can't be lowered in the generic path, as although arrays can now contain scalable vectors in LLVM, they can only contain a fixed quantity of scalable vectors, thus type conversion cannot happen.

With this change the unit-dim can be dropped such that the transfer_read is of a rank-1 `vector<[4]xf32>`.

I've posted this as a draft as I'm not entirely sure if semantically this transformation is correct when I look at the memref dialect and  subview op [1], that mentions:

> A subview operation may additionally reduce the rank of the resulting view by removing dimensions that are statically known to be of size 1.

but the vector.transfer_read is in-bounds.

Would appreciate any thoughts / feedback.

cc @dcaballe @nicolasvasilache @banach-space @MacDue 

[1] https://mlir.llvm.org/docs/Dialects/MemRef/#memrefsubview-memrefsubviewop

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


More information about the Mlir-commits mailing list