summaryrefslogtreecommitdiff
path: root/mlir/lib/Dialect/Vector/Transforms/LowerVectorShapeCast.cpp
AgeCommit message (Collapse)Author
2025-10-11[mlir] Use llvm accumulate wrappers. NFCI. (#162957)Jakub Kuderski
Use wrappers around `std::accumulate` to make the code more concise and less bug-prone: https://github.com/llvm/llvm-project/pull/162129. With `std::accumulate`, it's the initial value that determines the accumulator type. `llvm::sum_of` and `llvm::product_of` pick the right accumulator type based on the range element type. Found some funny bugs like a local accumulate helper that calculated a sum with initial value of 1 -- we didn't hit the bug because the code was actually dead...
2025-10-02[mlir][vector] Simplify op rewrite pattern inheriting constructors. NFC. ↵Jakub Kuderski
(#161670) Use the `Base` type alias from https://github.com/llvm/llvm-project/pull/158433.
2025-07-22[mlir][NFC] update `mlir/Dialect` create APIs (24/n) (#149931)Maksim Levental
See https://github.com/llvm/llvm-project/pull/147168 for more info.
2025-06-05[mlir][vector] Improve shape_cast lowering (#140800)James Newling
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>`.
2025-03-24[mlir][Vector] Remove more special case uses for ↵Kunwar Grover
extractelement/insertelement (#130166) A number of places in our codebase special case to use extractelement/insertelement for 0D vectors, because extract/insert did not support 0D vectors previously. Since insert/extract support 0D vectors now, use them instead of special casing.
2025-02-07[mlir][Vector] Generate poison vectors in vector.shape_cast lowering (#125613)Diego Caballero
This is the first PR that introduces `ub.poison` vectors as part of a rewrite/conversion pattern in the Vector dialect. It replaces the `arith.constant dense<0>` vector initialization for `vector.insert_slice` ops with a poison vector. This PR depends on all the previous PRs that introduced support for poison in Vector operations such as `vector.shuffle`, `vector.extract`, `vector.insert`, including ODS, canonicalization and lowering support. This PR may improve end-to-end compilation time through LLVM, depending on the workloads.
2025-01-27[mlir][Vector] Support efficient shape cast lowering for n-D vectors (#123497)Diego Caballero
This PR implements a generalization of the existing more efficient lowering of shape casts from 2-D to 1D and 1-D to 2-D vectors. This significantly reduces code size and generates more performant code for n-D shape casts that make their way to LLVM/SPIR-V.
2024-07-02mlir/LogicalResult: move into llvm (#97309)Ramkumar Ramachandra
This patch is part of a project to move the Presburger library into LLVM.
2023-09-28[mlir][vector] add result type to vector.extract assembly format (#66499)Cullen Rhodes
The vector.extract assembly format currently only contains the source type, for example: %1 = vector.extract %0[1] : vector<3x7x8xf32> it's not immediately obvious if this is the source or result type. This patch improves the assembly format to make this clearer, so the above becomes: %1 = vector.extract %0[1] : vector<7x8xf32> from vector<3x7x8xf32>
2023-09-07[mlir][VectorOps] Add lowering for vector.shape_cast of scalable vectorsBenjamin Maxwell
This adds a lowering similar to the general shape_cast lowering, but instead moves elements a (scalable) subvector at a time via vector.scalable.extract/insert. It is restricted to the case where both the source and result vector types have a single trailing scalable dimension (due to limitations of the insert/extract ops). The current lowerings are now disabled for scalable vectors, as they produce incorrect results at runtime (due to assuming a fixed number of elements). Examples of casts that now work: // Flattening: %v = vector.shape_cast %arg0 : vector<4x[8]xi8> to vector<[32]xi8> // Un-flattening: %v = vector.shape_cast %arg0 : vector<[8]xi32> to vector<2x1x[4]xi32> Reviewed By: awarzynski, nicolasvasilache Differential Revision: https://reviews.llvm.org/D159217
2023-06-01[mlir][Vector] Add support for 0-D 'vector.shape_cast' loweringDiego Caballero
This PR adds support for shape casting from and to 0-D vectors. Reviewed By: nicolasvasilache, hanchung, awarzynski Differential Revision: https://reviews.llvm.org/D151851
2023-03-23[mlir][Vector] NFC - Reorganize vector patternsNicolas Vasilache
Vector dialect patterns have grown enormously in the past year to a point where they are now impenetrable. Start reorganizing them towards finer-grained control. Differential Revision: https://reviews.llvm.org/D146736