[Mlir-commits] [mlir] [mlir][vector] Add vector.to_elements unrolling (PR #157142)
James Newling
llvmlistbot at llvm.org
Wed Sep 10 08:47:13 PDT 2025
================
@@ -255,6 +255,16 @@ using UnrollVectorOpFn =
LogicalResult unrollVectorOp(Operation *op, PatternRewriter &rewriter,
UnrollVectorOpFn unrollFn);
+/// Generic utility for mapping values of type vector<nxaxbx...>
+/// to n values of type vector<axbx...>
+/// Follows the following pattern:
+/// 1. Check if already 1-D. If so, return failure.
+/// 2. Check for scalable dimensions. If so, return failure.
+/// 3. Returns the values of n vector.extract operations corresponding
+/// to the outermost dimension.
+LogicalResult unrollVectorValue(Value vector, PatternRewriter &rewriter,
----------------
newling wrote:
Thanks @amd-eochoalo
- For this use case, stopping at rank-1 makes sense now (thanks for explaining). My only remaining doubt is whether a 'utility' API should stop at rank-1 or rank-0. But I'm fine with leaving it as rank-1.
- I was thinking `RewriterBase::InsertionGuard guard(rewriter);` at the start of the `unrollVectorValue` function. Maybe I'm misunderstanding how [this](https://github.com/llvm/llvm-project/blob/c82d09c96a4c0c5454143cc35c935557528bb86b/mlir/include/mlir/IR/Builders.h#L347) works.
https://github.com/llvm/llvm-project/pull/157142
More information about the Mlir-commits
mailing list