[Mlir-commits] [mlir] [mlir][Vector] Fix vector.extract lowering to llvm for 0-d vectors (PR #117731)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Tue Nov 26 09:20:08 PST 2024
================
@@ -1096,43 +1096,56 @@ class VectorExtractOpConversion
SmallVector<OpFoldResult> positionVec = getMixedValues(
adaptor.getStaticPosition(), adaptor.getDynamicPosition(), rewriter);
- // Extract entire vector. Should be handled by folder, but just to be safe.
- ArrayRef<OpFoldResult> position(positionVec);
- if (position.empty()) {
- rewriter.replaceOp(extractOp, adaptor.getVector());
- return success();
- }
-
- // One-shot extraction of vector from array (only requires extractvalue).
- // Except for extracting 1-element vectors.
- if (isa<VectorType>(resultType) &&
- position.size() !=
- static_cast<size_t>(extractOp.getSourceVectorType().getRank())) {
- if (extractOp.hasDynamicPosition())
- return failure();
-
- Value extracted = rewriter.create<LLVM::ExtractValueOp>(
- loc, adaptor.getVector(), getAsIntegers(position));
- rewriter.replaceOp(extractOp, extracted);
- return success();
- }
+ // The LLVM lowering models multi dimension vectors as stacked 1-d vectors.
----------------
banach-space wrote:
It's not really the LLVM lowering, but the Vector dialect:
* https://mlir.llvm.org/docs/Dialects/Vector/#llvm-lowering-tradeoffs
Note that over there it's referred to as "nested aggregates" rather than "stacking".
https://github.com/llvm/llvm-project/pull/117731
More information about the Mlir-commits
mailing list