[Mlir-commits] [mlir] [mlir][vector] Add vector.to_elements unrolling (PR #157142)
Erick Ochoa Lopez
llvmlistbot at llvm.org
Wed Sep 10 07:34:58 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,
----------------
amd-eochoalo wrote:
Hi @newling:
* I don't think we want to unroll rank-1 to rank-0. To answer your high level question, if I undestand correctly, this pattern is supposed to mimic the lowering strategy for `vector.from_elements` (seen here https://github.com/llvm/llvm-project/pull/151175 ) but with `vector.to_elements`. According to @Groverkss we should be using unrolling as opposed to shape casting as the default option. And I think the motivation is indeed for supporting lowering rank-2+ for different targets (i.e., SPIR-V and LLVM).
* Regarding using an InsertionGuard inside the function, I would agree if there was an operation. But for values, these might be parameters being passed into a block or a function. If the value being passed in does not have a definition, do you want me to place the operations at the beginning of the current block? I think not using an InsertionGuard in this case makes sense, but happy to make changes.
https://github.com/llvm/llvm-project/pull/157142
More information about the Mlir-commits
mailing list