summaryrefslogtreecommitdiff
path: root/mlir/lib/Dialect/Vector/Transforms/VectorLinearize.cpp
AgeCommit message (Collapse)Author
2025-10-17[mlir][Vector] Pattern to linearize broadcast (#163845)James Newling
The PR https://github.com/llvm/llvm-project/pull/162167 removed a pattern to linearize vector.splat, without adding the equivalent pattern for vector.broadcast. This PR adds such a pattern, hopefully brining vector.broadcast up to full parity with vector.splat that has now been removed. --------- Signed-off-by: James Newling <james.newling@gmail.com>
2025-10-10[MLIR][Vector] Remove vector.splat (#162167)James Newling
vector.splat has been deprecated (user: please use the very similar vector.broadcast instead) with the last PR landing about 6 weeks ago. The discourse discussion is at https://discourse.llvm.org/t/rfc-mlir-vector-deprecate-then-remove-vector-splat/87143/1 The last PR was #152230 This PR completely removes vector.splat. In addition to removing vector.splat from VectorOps.td, it - Updates the few remaining places where vector::SplatOp is created (now vector::BroadcastOp is created) - Removes temporary patterns where vector.splat is replaced by vector.broadcast The only place 'vector.splat' appears is now the files https://github.com/llvm/llvm-project/blob/main/mlir/utils/tree-sitter-mlir/test/corpus/op.txt and https://github.com/llvm/llvm-project/blob/main/mlir/utils/tree-sitter-mlir/dialect/vector.js --------- Signed-off-by: James Newling <james.newling@gmail.com>
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-09-15[mlir][vector] Use `source` as the source argument name (#158258)Andrzej Warzyński
This patch updates the following ops to use `source` (instead of `vector`) as the name for their source argument: * `vector.extract` * `vector.scalable.extract` * `vector.extract_strided_slice` This change ensures naming consistency with the "builders" for these Ops that already use the name `source` rather than `vector`. It also addresses part of: * https://github.com/llvm/llvm-project/issues/131602 Specifically, it ensures that we use `source` and `dest` for read and write operations, respectively (as opposed to `vector` and `dest`).
2025-09-11[mlir][vector] Add LinearizeVectorToElements (#157740)Erick Ochoa Lopez
Co-authored-by: James Newling <james.newling@gmail.com>
2025-08-27[mlir][vector] Follow-up improvements for multi-dimensional ↵Yang Bai
vector.from_elements support (#154664) This PR is a follow-up to #151175 that supported lowering multi-dimensional `vector.from_elements` op to LLVM by introducing a unrolling pattern. ## Changes ### Add `vector.shape_cast` based flattening pattern for `vector.from_elements` This change introduces a new linearization pattern that uses `vector.shape_cast` to flatten multi-dimensional `vector.from_elements` operations. This provides an alternative approach to the unrolling-based method introduced in #151175. **Example:** ```mlir // Before %v = vector.from_elements %e0, %e1, %e2, %e3 : vector<2x2xf32> // After %flat = vector.from_elements %e0, %e1, %e2, %e3 : vector<4xf32> %result = vector.shape_cast %flat : vector<4xf32> to vector<2x2xf32> ``` --------- Co-authored-by: Yang Bai <yangb@nvidia.com> Co-authored-by: James Newling <james.newling@gmail.com>
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-07-14[MLIR] [Vector] Linearization patterns for vector.load and vector.store ↵Nishant Patel
(#145115) This PR add inearizarion pattern for vector.load and vector.store. It is follow up PR to https://github.com/llvm/llvm-project/pull/143420#issuecomment-2967406606
2025-07-11[mlir][Vector] Support scalar `vector.extract` in VectorLinearize (#147440)Diego Caballero
It generates a linearized version of the `vector.extract` for scalar cases.
2025-07-07[mlir][Vector] Support scalar 'vector.insert' in vector linearization (#146954)Diego Caballero
This PR add support for linearizing the insertion of a scalar element by just linearizing the `vector.insert` op.
2025-05-20[mlir][NFC] Simplify constant checks with isOneInteger and renamed ↵Han-Chung Wang
isZeroInteger. (#139340) The revision adds isOneInteger helper, and simplifies the existing code with the two methods. It removes some lambda, which makes code cleaner. For downstream users, you can update the code with the below script. ```bash sed -i "s/isZeroIndex/isZeroInteger/g" **/*.h sed -i "s/isZeroIndex/isZeroInteger/g" **/*.cpp ``` --------- Signed-off-by: hanhanW <hanhan0912@gmail.com>
2025-05-15[mlir][vector] Address linearization comments (post commit) (#138075)James Newling
This PR adds some documentation to address comments in https://github.com/llvm/llvm-project/pull/136581 This PR adds a test for linearization across scf.for. This new test might be considered redundant by more experienced MLIRers, but might help newer users understand how to linearize scf/cf/func operations easily The documentation added in this PR also tightens our definition of linearization, to now exclude unrolling (which creates multiple ops from 1 op). We hadn't really specified what linearization meant before.
2025-05-14[mlir] [vector] Add linearization pattern for vector.create_mask (#138214)Nishant Patel
This PR is a breakdown [3 / 4] of the PR #136193 The PR adds linearization patterns for vector.create_mask
2025-05-14[mlir][vector] linearize vector.insert_strided_slice (flatten to ↵James Newling
vector.shuffle) (#138725) Extends the set of vector operations that we can linearize to include vector.insert_strided_slice. The new pattern reuses the ideas from vector.extract_strided_slice linearization.
2025-05-01[mlir][vector] Add linearization pattern for vector.splat (#137651)Nishant Patel
This PR is a breakdown [2 / 4] of the PR #136193 The PR adds linearization patterns for vector.splat.
2025-05-01[mlir][vector] Remove remaining bitwidths from linearization patterns (#138072)James Newling
In https://github.com/llvm/llvm-project/pull/136581 the bitwidth logic was supposed to be completely removed from the linearization patterns. But it was left in a few places. This PR removes the remainders (they were default valued constructor arguments that were unused).
2025-04-30[mlir][vector] Linearization: push 'bit width' logic out of patterns (#136581)James Newling
[NFC] Vector linearization is a collection of rewrite patterns that reduce the rank of vector operands and results. In https://github.com/llvm/llvm-project/pull/83314 an option to ignore (make 'legal') operations with large inner-most dimensions was added. This current PR is a step towards making that option live outside of upstream MLIR. The motivation is to remove non-core functionality (I would like to use this pass, but would prefer not to deal with 'targetVectorBitWidth` at all). As a follow-up to this PR, I propose that user(s) of the `targetVectorBitWidth` move the relevant code (now in mlir/test/lib/Dialect/Vector/TestVectorTransforms.cpp) to their code bases, and then eventually remove it from upstream. In addition the tests need to split out (I've intentionally not modified the lit tests here, to make it easier to confirm that this is a NFC). I'm happy to help make it easier to do this final step! The approach I've used is to move the logic pertaining to `targetVectorBitWidth` out the patterns, and into the conversion target, which the end user can control outside of core MLIR.
2025-04-07[mlir][vector] Standardise `valueToStore` Naming Across Vector Ops (NFC) ↵Andrzej Warzyński
(#134206) This change standardises the naming convention for the argument representing the value to store in various vector operations. Specifically, it ensures that all vector ops storing a value—whether into memory, a tensor, or another vector — use `valueToStore` for the corresponding argument name. Updated operations: * `vector.transfer_write`, `vector.insert`, `vector.scalable_insert`, `vector.insert_strided_slice`. For reference, here are operations that currently use `valueToStore`: * `vector.store` `vector.scatter`, `vector.compressstore`, `vector.maskedstore`. This change is non-functional (NFC) and does not affect the functionality of these operations. Implements #131602
2025-03-13[mlir][vector] VectorLinearize: `ub.poison` support (#128612)Ivan Butygin
Unify `arith.constant` and `up.poison` using `OpTraitConversionPattern<OpTrait::ConstantLike>`.
2025-01-27[mlir][vector] add support for linearizing vector.bitcast in VectorLinearize ↵Chao Chen
(#123110) This PR adds support for converting Vector::BitCastOp working on ND (N >1) vectors into the same op working on linearized (1D) vectors.
2025-01-03[mlir][Transforms] Support 1:N mappings in `ConversionValueMapping` (#116524)Matthias Springer
This commit updates the internal `ConversionValueMapping` data structure in the dialect conversion driver to support 1:N replacements. This is the last major commit for adding 1:N support to the dialect conversion driver. Since #116470, the infrastructure already supports 1:N replacements. But the `ConversionValueMapping` still stored 1:1 value mappings. To that end, the driver inserted temporary argument materializations (converting N SSA values into 1 value). This is no longer the case. Argument materializations are now entirely gone. (They will be deleted from the type converter after some time, when we delete the old 1:N dialect conversion driver.) Note for LLVM integration: Replace all occurrences of `addArgumentMaterialization` (except for 1:N dialect conversion passes) with `addSourceMaterialization`. --------- Co-authored-by: Markus Böck <markus.boeck02@gmail.com>
2024-10-05[mlir][NFC] Mark type converter in `populate...` functions as `const` (#111250)Matthias Springer
This commit marks the type converter in `populate...` functions as `const`. This is useful for debugging. Patterns already take a `const` type converter. However, some `populate...` functions do not only add new patterns, but also add additional type conversion rules. That makes it difficult to find the place where a type conversion was added in the code base. With this change, all `populate...` functions that only populate pattern now have a `const` type converter. Programmers can then conclude from the function signature that these functions do not register any new type conversion rules. Also some minor cleanups around the 1:N dialect conversion infrastructure, which did not always pass the type converter as a `const` object internally.
2024-09-04[mlir][vector] Bugfix of linearize `vector.extract` (#106836)Longsheng Mou
This patch add check for `vector.extract` with scalar type, which is not allowed when linearize `vector.extract`. Fix #106162.
2024-07-30[mlir][vector] Use `DenseI64ArrayAttr` for shuffle masks (#101163)Benjamin Maxwell
Follow on from #100997. This again removes from boilerplate conversions to/from IntegerAttr and int64_t (otherwise, this is a NFC).
2024-07-02mlir/LogicalResult: move into llvm (#97309)Ramkumar Ramachandra
This patch is part of a project to move the Presburger library into LLVM.
2024-06-21[mlir][vector] Use notifyMatchFailure instead of assert in VectorLinearize ↵Artem Kroviakov
(#93590) As it was [suggested](https://github.com/llvm/llvm-project/pull/92370#discussion_r1617592942), the `assert` is replaced by `notifyMatchFailure` for improved consistency.
2024-05-28[mlir][vector] Add support for linearizing Insert VectorOp in ↵Artem Kroviakov
VectorLinearize (#92370) Building on top of [#88204](https://github.com/llvm/llvm-project/pull/88204), this PR adds support for converting `vector.insert` into an equivalent `vector.shuffle` operation that operates on linearized (1-D) vectors.
2024-04-28Reapply "[mlir] Mark `isa/dyn_cast/cast/...` member functions depreca… ↵Christian Sigg
(#90406) …ted. (#89998)" (#90250) This partially reverts commit 7aedd7dc754c74a49fe84ed2640e269c25414087. This change removes calls to the deprecated member functions. It does not mark the functions deprecated yet and does not disable the deprecation warning in TypeSwitch. This seems to cause problems with MSVC.
2024-04-26Revert "[mlir] Mark `isa/dyn_cast/cast/...` member functions deprecated. ↵dyung
(#89998)" (#90250) This reverts commit 950b7ce0b88318f9099e9a7c9817d224ebdc6337. This change is causing build failures on a bot https://lab.llvm.org/buildbot/#/builders/216/builds/38157
2024-04-26[mlir] Mark `isa/dyn_cast/cast/...` member functions deprecated. (#89998)Christian Sigg
See https://mlir.llvm.org/deprecation and https://discourse.llvm.org/t/preferred-casting-style-going-forward.
2024-04-18[mlir][vector] Add support for linearizing Extract, ExtractStridedSlice, ↵Charitha Saumya
Shuffle VectorOps in VectorLinearize (#88204) This PR adds support for converting `vector.extract_strided_slice` and `vector.extract` operations to equivalent `vector.shuffle` operations that operates on linearized (1-D) vectors. `vector.shuffle` operations operating on n-D (n > 1) are also converted to equivalent shuffle operations working on linearized vectors.
2024-04-03[mlir][vector] Skip 0D vectors in vector linearization. (#87577)Han-Chung Wang
2024-03-28[mlir][vector] Add support for scalable vectors to VectorLinearize (#86786)Andrzej Warzyński
Adds support for scalable vectors to patterns defined in VectorLineralize.cpp. Linearization is disable in 2 notable cases: * vectors with more than 1 scalable dimension (we cannot represent vscale^2), * vectors initialised with arith.constant that's not a vector splat (such arith.constant Ops cannot be flattened).
2024-03-25[mlir][Vector] Fix an assertion on failing cast in ↵Balaji V. Iyer
vector-transfer-flatten-patterns (#86030) When the result is not a vectorType, there is an assert. This patch will do the check and bail when the result is not a VectorType.
2024-03-04[mlir][vector]Add Vector bitwidth target to Linearize Vectorizable and ↵Balaji V. Iyer
Constant Ops (#83314) Added a new flag `targetVectorBitwidth` to capture bit-width input.
2024-02-13[mlir][vector] ND vectors linearization pass (#81159)Ivan Butygin
Common backends (LLVM, SPIR-V) only supports 1D vectors, LLVM conversion handles ND vectors (N >= 2) as `array<array<... vector>>` and SPIR-V conversion doesn't handle them at all at the moment. Sometimes it's preferable to treat multidim vectors as linearized 1D. Add pass to do this. Only constants and simple elementwise ops are supported for now. @krzysz00 I've extracted yours result type conversion code from LegalizeToF32 and moved it to common place. Also, add ConversionPattern class operating on traits.