Skip to content

Commit c513cb1

Browse files
committed
more docs
1 parent 76c9b90 commit c513cb1

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,14 +1096,20 @@ class VectorExtractOpConversion
10961096
SmallVector<OpFoldResult> positionVec = getMixedValues(
10971097
adaptor.getStaticPosition(), adaptor.getDynamicPosition(), rewriter);
10981098

1099-
// Determine if we need to extract a scalar as the result. We extract
1100-
// a scalar if the extract is full rank i.e. the number of indices is equal
1101-
// to source vector rank.
1102-
bool isScalarExtract =
1103-
positionVec.size() == extractOp.getSourceVectorType().getRank();
1099+
// The LLVM lowering models multi dimension vectors as stacked 1-d vectors.
1100+
// The stacking is modeled using arrays. We do this conversion from a
1101+
// N-d vector extract to stacked 1-d vector extract in two steps:
1102+
// - Extract a 1-d vector or a stack of 1-d vectors (llvm.extractvalue)
1103+
// - Extract a scalar out of the 1-d vector if needed (llvm.extractelement)
1104+
11041105
// Determine if we need to extract a slice out of the original vector. We
11051106
// always need to extract a slice if the input rank >= 2.
11061107
bool isSlicingExtract = extractOp.getSourceVectorType().getRank() >= 2;
1108+
// Determine if we need to extract a scalar as the result. We extract
1109+
// a scalar if the extract is full rank i.e. the number of indices is equal
1110+
// to source vector rank.
1111+
bool isScalarExtract = static_cast<int64_t>(positionVec.size()) ==
1112+
extractOp.getSourceVectorType().getRank();
11071113

11081114
Value extracted = adaptor.getVector();
11091115
if (isSlicingExtract) {

0 commit comments

Comments
 (0)