[Mlir-commits] [mlir] NfC fix comment in #119039 (PR #119727)
Nirvedh Meshram
llvmlistbot at llvm.org
Thu Dec 12 09:31:40 PST 2024
https://github.com/nirvedhmeshram created https://github.com/llvm/llvm-project/pull/119727
Missed commiting clang-fomrat in [119039](https://github.com/llvm/llvm-project/commit/a17ebcc53388259fd4c02fcf314e68a36638c989)
>From 9d9a40a0b1537e8515dd6949ff27aea023bd9a59 Mon Sep 17 00:00:00 2001
From: Nirvedh <nirvedh at gmail.com>
Date: Thu, 5 Dec 2024 18:46:50 -0600
Subject: [PATCH 1/4] [Tensor] Simplify tenor.pad tiling length calculations.
Signed-off-by: Nirvedh <nirvedh at gmail.com>
---
mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp b/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp
index 3caf93b1408df4..e647e53bc33af6 100644
--- a/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp
@@ -822,7 +822,6 @@ FailureOr<TilingResult> tensor::bubbleUpPadSlice(OpBuilder &b,
// the source tensor. (Similar to newOffset.)
// srcSize - newOffset represents how much length we have available
// and length - newLow represents how much length we want at most.
- // Note that there are many ways to order this indexing math to compute newLength, but we want to make sure that the final affine.min ops in the sequence are bounding the index to as small a value as possible. If ValueBoundsOpInterface is used, this calcuation will get upper bounds from the affine.min ops, so we want to use the smallest known value to set the bound at the end of the computation sequence. In this case, the index will be upper bounded by length - newLow.
OpFoldResult newLength = min(sub(srcSize, newOffset), sub(length, newLow));
// Optimization: If low = 0, then newLow = 0. then newLength >= 0 assuming
// length >= 0.
>From cab22d07b9ce392bf1bd5271154759ba09f1bdb3 Mon Sep 17 00:00:00 2001
From: Nirvedh <nirvedh at gmail.com>
Date: Thu, 12 Dec 2024 11:00:15 -0600
Subject: [PATCH 2/4] Address reviwer comments
Signed-off-by: Nirvedh <nirvedh at gmail.com>
---
mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp b/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp
index e647e53bc33af6..bcaf2ccdad1378 100644
--- a/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp
@@ -822,6 +822,11 @@ FailureOr<TilingResult> tensor::bubbleUpPadSlice(OpBuilder &b,
// the source tensor. (Similar to newOffset.)
// srcSize - newOffset represents how much length we have available
// and length - newLow represents how much length we want at most.
+ // In the dynamic case if ValueBoundsOpInterface is used this calcuation
+ // will lead to an upper bound of length - newLow. If we calculated the
+ // ending location as min(some expression, srcSize) and then subtracted
+ // the new offset then ValueBoundsOpInterface will upper bound by SrcSize
+ // which is larger than needed.
OpFoldResult newLength = min(sub(srcSize, newOffset), sub(length, newLow));
// Optimization: If low = 0, then newLow = 0. then newLength >= 0 assuming
// length >= 0.
>From c92ded3d12306a49ac0873f96ed1a8733d6b41c8 Mon Sep 17 00:00:00 2001
From: Nirvedh <nirvedh at gmail.com>
Date: Thu, 12 Dec 2024 11:22:44 -0600
Subject: [PATCH 3/4] Better comment
Signed-off-by: Nirvedh <nirvedh at gmail.com>
---
mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp b/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp
index bcaf2ccdad1378..3caf93b1408df4 100644
--- a/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp
@@ -822,11 +822,7 @@ FailureOr<TilingResult> tensor::bubbleUpPadSlice(OpBuilder &b,
// the source tensor. (Similar to newOffset.)
// srcSize - newOffset represents how much length we have available
// and length - newLow represents how much length we want at most.
- // In the dynamic case if ValueBoundsOpInterface is used this calcuation
- // will lead to an upper bound of length - newLow. If we calculated the
- // ending location as min(some expression, srcSize) and then subtracted
- // the new offset then ValueBoundsOpInterface will upper bound by SrcSize
- // which is larger than needed.
+ // Note that there are many ways to order this indexing math to compute newLength, but we want to make sure that the final affine.min ops in the sequence are bounding the index to as small a value as possible. If ValueBoundsOpInterface is used, this calcuation will get upper bounds from the affine.min ops, so we want to use the smallest known value to set the bound at the end of the computation sequence. In this case, the index will be upper bounded by length - newLow.
OpFoldResult newLength = min(sub(srcSize, newOffset), sub(length, newLow));
// Optimization: If low = 0, then newLow = 0. then newLength >= 0 assuming
// length >= 0.
>From a17ebcc53388259fd4c02fcf314e68a36638c989 Mon Sep 17 00:00:00 2001
From: Nirvedh <nirvedh at gmail.com>
Date: Thu, 12 Dec 2024 11:26:07 -0600
Subject: [PATCH 4/4] [NFC] fix clang-format in 119039
---
mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp b/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp
index 3caf93b1408df4..6e63cf068bce57 100644
--- a/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp
@@ -822,7 +822,13 @@ FailureOr<TilingResult> tensor::bubbleUpPadSlice(OpBuilder &b,
// the source tensor. (Similar to newOffset.)
// srcSize - newOffset represents how much length we have available
// and length - newLow represents how much length we want at most.
- // Note that there are many ways to order this indexing math to compute newLength, but we want to make sure that the final affine.min ops in the sequence are bounding the index to as small a value as possible. If ValueBoundsOpInterface is used, this calcuation will get upper bounds from the affine.min ops, so we want to use the smallest known value to set the bound at the end of the computation sequence. In this case, the index will be upper bounded by length - newLow.
+ // Note that there are many ways to order this indexing math to compute
+ // newLength, but we want to make sure that the final affine.min ops in the
+ // sequence are bounding the index to as small a value as possible. If
+ // ValueBoundsOpInterface is used, this calcuation will get upper bounds
+ // from the affine.min ops, so we want to use the smallest known value to
+ // set the bound at the end of the computation sequence. In this case, the
+ // index will be upper bounded by length - newLow.
OpFoldResult newLength = min(sub(srcSize, newOffset), sub(length, newLow));
// Optimization: If low = 0, then newLow = 0. then newLength >= 0 assuming
// length >= 0.
More information about the Mlir-commits
mailing list