[Mlir-commits] [mlir] [Tensor] Simplify tenor.pad tiling length calculations. (PR #119039)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Dec 12 08:52:27 PST 2024
================
@@ -825,16 +820,13 @@ FailureOr<TilingResult> tensor::bubbleUpPadSlice(OpBuilder &b,
// The original read could also have stopped in the high padding zone.
// In that case, set the end positition of the read should be the end of
// the source tensor. (Similar to newOffset.)
- //
- // endLoc = min(max(offset - low + length, 0), srcSize)
- //
- // The new ExtractSliceOp length is `endLoc - newOffset`.
- //
- // Optimization: If low = 0, then the formula can be simplified.
- OpFoldResult endLoc =
- hasLowPad ? min(max(add(sub(offset, low), length), zero), srcSize)
- : min(add(offset, length), srcSize);
- OpFoldResult newLength = sub(endLoc, newOffset);
+ // srcSize - newOffset represents how much length we have available
+ // and length - newLow represents how much length we want at most.
+ OpFoldResult newLength = min(sub(srcSize, newOffset), sub(length, newLow));
----------------
Max191 wrote:
Maybe it is worth adding a comment here explaining the ValueBoundsOpInterface quirk. Essentially that it is difficult for ValueBoundsOpInterface to get the smallest upper bound when there is a difference of 2 mins (with respect to the srcSize) as opposed to a single min (with respect to the length) of the difference.
https://github.com/llvm/llvm-project/pull/119039
More information about the Mlir-commits
mailing list