[Mlir-commits] [mlir] [mlir][vector] Disable transpose -> shuffle lowering for scalable vectors (PR #79979)

Benjamin Maxwell llvmlistbot at llvm.org
Tue Jan 30 05:55:22 PST 2024


MacDue wrote:

> Do you have a plan about how we lower transpose ops for scalable vectors?

I have an SME (possibly usable for SVE too) rewrite that goes from:

```mlir
%illegalRead = vector.transfer_read %memref[%a, %b] : memref<?x?xf32>, vector<[8]x4xf32>
%legalType = vector.transpose %illegalRead, [1, 0]  : vector<[8]x4xf32> to vector<4x[8]xf32>
```

to:

```mlir
%readSubview = memref.subview %memref[%a, %b] [%c8_vscale, %c4] [%c1, %c1] : memref<?x?xf32> to memref<?x?xf32>
%transpose = memref.transpose %readSubview (d0, d1) -> (d1, d0) : memref<?x?xf32> to memref<?x?xf32>
%legalType = vector.transfer_read %transpose[%c0, %c0] : memref<?x?xf32>, vector<4x[8]xf32>
```

We can't directly lower the `vector.transpose` as `vector<[8]x4xf32>` is an illegal type (you can't have a leading scalable dimension and a fixed trailing dimension). But as the transpose is (normally) from a read of an illegal type to a legal type, we can instead lift the transpose to the memref (making a strided memref), and eliminate the illegal vector types.


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


More information about the Mlir-commits mailing list