Skip to content

Commit

Permalink
Clamp vectorisation to avoid computing the padding with unrealistic v…
Browse files Browse the repository at this point in the history
…ectorisation lenghts
  • Loading branch information
lezcano committed Feb 11, 2025
1 parent 81ffce5 commit 164e9ac
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/Analysis/Allocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ ScratchConfig getScratchConfigForCvt(RankedTensorType srcTy,
unsigned contiguousShapeDim = scratchConfig.repShape[scratchConfig.order[0]];
scratchConfig.inVec = std::min(scratchConfig.inVec, contiguousShapeDim);
scratchConfig.outVec = std::min(scratchConfig.outVec, contiguousShapeDim);
// Clamp the vector length to 128 / element bitwidth as this is the max
// vectorisation
auto inBitWidth = isa<PointerType>(srcTy.getElementType())
? kPtrBitWidth
: srcTy.getElementTypeBitWidth();
auto outBitWidth = isa<PointerType>(dstTy.getElementType())
? kPtrBitWidth
: dstTy.getElementTypeBitWidth();
scratchConfig.inVec = std::min(scratchConfig.inVec, 128 / inBitWidth);
scratchConfig.outVec = std::min(scratchConfig.outVec, 128 / outBitWidth);

// No padding is required if the tensor is 1-D, or if all dimensions except
// the first accessed dimension have a size of 1.
Expand Down

0 comments on commit 164e9ac

Please sign in to comment.