[Mlir-commits] [mlir] [mlir][vector] Split `TransposeOpLowering` into 2 patterns (PR #91935)

Benjamin Maxwell llvmlistbot at llvm.org
Mon May 13 02:23:25 PDT 2024


https://github.com/MacDue approved this pull request.

Approving this PR, but I do wonder (with the benefit of hindsight), if the `Transpose2DWithUnitDimToShapeCast` lowering would be better as a (more specific) canonicalization of a `shape_cast + transpose`. Since what we really want here is for the illegal vector types (e.g. `vector<[4]x1xf32>`) to be eliminated, which won't _always_ happen if the transpose is replaced with a shape cast. 

E.g. the rewrite could be:

```
%0 = some_op 
%1 = vector.shape_cast %0 : vector<[4]xf32> to vector<[4]x1xf32>
%2 = vector.transpose %1 [1, 0] : vector<[4]x1xf32> to vector<1x[4]xf32>
```
->
```
%0 = some_op 
%1 = vector.shape_cast %0 : vector<[4]xf32> to vector<1x[4]xf32>
```



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


More information about the Mlir-commits mailing list