llvm-project
7ce315d1 - [mlir][vector] Improve shape_cast lowering (#140800)

Commit
192 days ago
[mlir][vector] Improve shape_cast lowering (#140800) Before this PR, a rank-m -> rank-n vector.shape_cast with m,n>1 was lowered to extracts/inserts of single elements, so that a shape_cast on a vector with N elements would always require N extracts/inserts. While this is necessary in the worst case scenario it is sometimes possible to use fewer, larger extracts/inserts. Specifically, the largest common suffix on the shapes of the source and result can be extracted/inserted. For example: ```mlir %0 = vector.shape_cast %arg0 : vector<10x2x3xf32> to vector<2x5x2x3xf32> ``` has common suffix of shape `2x3`. Before this PR, this would be lowered to 60 extract/insert pairs with extracts of the form `vector.extract %arg0 [a, b, c] : f32 from vector<10x2x3xf32>`. With this PR it is 10 extract/insert pairs with extracts of the form `vector.extract %arg0 [a] : vector<2x3xf32> from vector<10x2x3xf32>`.
Author
Parents
Loading