[llvm-branch-commits] [mlir] 61e03b6 - Revert "[mlir][tensor] Refine the semantics of `createPadHighOp` (#109667)"
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Sep 26 11:17:50 PDT 2024
Author: Han-Chung Wang
Date: 2024-09-26T11:17:47-07:00
New Revision: 61e03b68511862ace5bc361565b2535e27fde833
URL: https://github.com/llvm/llvm-project/commit/61e03b68511862ace5bc361565b2535e27fde833
DIFF: https://github.com/llvm/llvm-project/commit/61e03b68511862ace5bc361565b2535e27fde833.diff
LOG: Revert "[mlir][tensor] Refine the semantics of `createPadHighOp` (#109667)"
This reverts commit 9c48a04328f1dfa739985f64b33f20b67e085277.
Added:
Modified:
mlir/include/mlir/Dialect/Tensor/Utils/Utils.h
mlir/lib/Dialect/Tensor/Utils/Utils.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Tensor/Utils/Utils.h b/mlir/include/mlir/Dialect/Tensor/Utils/Utils.h
index e63749eb384316..84d06d456bb689 100644
--- a/mlir/include/mlir/Dialect/Tensor/Utils/Utils.h
+++ b/mlir/include/mlir/Dialect/Tensor/Utils/Utils.h
@@ -14,10 +14,10 @@
namespace mlir {
namespace tensor {
-// Return a PadOp that pads `source` to `type` size. Output sizes (from `type`)
-// are assumed to be static and greater than the potentially dynamic input sizes
-// (from `source). The op performs "high" padding (i.e. it adds trailing padding
-// values until the desired size is met).
+// Return a PadOp that pads `source` to `type` size where the static
+// sizes are assumed to be greater than the dynamic sizes. If `type` has dynamic
+// dimensions the padding width is set to zero. The op performs "high" padding
+// (i.e. it adds trailing padding values until the desired size is met).
PadOp createPadHighOp(RankedTensorType type, Value source, Value pad,
bool nofold, Location loc, OpBuilder &builder);
diff --git a/mlir/lib/Dialect/Tensor/Utils/Utils.cpp b/mlir/lib/Dialect/Tensor/Utils/Utils.cpp
index 0cb16c28b829c2..a0d8a08fc6ba47 100644
--- a/mlir/lib/Dialect/Tensor/Utils/Utils.cpp
+++ b/mlir/lib/Dialect/Tensor/Utils/Utils.cpp
@@ -24,17 +24,12 @@ using namespace mlir::tensor;
PadOp mlir::tensor::createPadHighOp(RankedTensorType type, Value source,
Value pad, bool nofold, Location loc,
OpBuilder &b) {
-
- // TODO: Either relax or turn this into a failure
- assert(!ShapedType::isDynamicShape(type.getShape()) &&
- "The output type is dynamic - that's not supported ATM.");
-
- // Init "low" and "high" padding values ("low" is kept as is, "high" is
- // computed below).
SmallVector<OpFoldResult> low(type.getRank(), b.getIndexAttr(0));
SmallVector<OpFoldResult> high(type.getRank(), b.getIndexAttr(0));
-
for (const auto &en : enumerate(type.getShape())) {
+ // Pad only the static dimensions of the result tensor type.
+ if (ShapedType::isDynamic(en.value()))
+ continue;
// Compute the padding width.
AffineExpr d0;
bindDims(b.getContext(), d0);
More information about the llvm-branch-commits
mailing list