[Mlir-commits] [mlir] a285ba7 - Revert "[mlir][tensor] Refine the semantics of `createPadHighOp`" (#110153)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Sep 26 12:44:46 PDT 2024


Author: Han-Chung Wang
Date: 2024-09-26T12:44:43-07:00
New Revision: a285ba7529feaa7c49890e314facb5e9f4d8dc11

URL: https://github.com/llvm/llvm-project/commit/a285ba7529feaa7c49890e314facb5e9f4d8dc11
DIFF: https://github.com/llvm/llvm-project/commit/a285ba7529feaa7c49890e314facb5e9f4d8dc11.diff

LOG: Revert "[mlir][tensor] Refine the semantics of `createPadHighOp`" (#110153)

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 Mlir-commits mailing list