Skip to content

Commit 20551dd

Browse files
reviwer comments 2
Signed-off-by: Nirvedh <[email protected]>
1 parent 1465643 commit 20551dd

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2178,22 +2178,22 @@ vectorizePadOpPrecondition(tensor::PadOp padOp,
21782178
inputVectorSizes)))
21792179
return failure();
21802180

2181-
// Low padding is currently unsupported for the general case as this
2182-
// would require shifting the results to the right for the low padded dims by
2183-
// the required amount of low padding. However, we do support low padding if
2184-
// the dims being low padded have result sizes of 1. The reason is when we
2185-
// have a low pad on a unit result dim, the input size of that dimension will
2186-
// be dynamically zero (as the sum of the low pad and input dim size has to be
2187-
// one) and hence we will create a zero mask as the lowering logic just makes
2188-
// the mask one for the input dim size - which is zero here. Hence we will
2189-
// load the pad value which is what we want in this case. If the low pad is
2190-
// dynamically zero then the lowering is correct as well as no shifts are
2191-
// necessary.
2181+
// Padding with non-zero low pad values is not supported, unless the
2182+
// corresponding result dim is 1 as this would require shifting the results to
2183+
// the right for the low padded dims by the required amount of low padding.
2184+
// However, we do support low padding if the dims being low padded have result
2185+
// sizes of 1. The reason is when we have a low pad on a unit result dim, the
2186+
// input size of that dimension will be dynamically zero (as the sum of the
2187+
// low pad and input dim size has to be one) and hence we will create a zero
2188+
// mask as the lowering logic just makes the mask one for the input dim size -
2189+
// which is zero here. Hence we will load the pad value which is what we want
2190+
// in this case. If the low pad is dynamically zero then the lowering is
2191+
// correct as well as no shifts are necessary.
21922192
if (llvm::any_of(llvm::enumerate(padOp.getLow()), [&](const auto &en) {
21932193
Value padValue = en.value();
21942194
unsigned pos = en.index();
2195-
std::optional<int64_t> res = getConstantIntValue(padValue);
2196-
return (!res.has_value() || res.value() != 0) &&
2195+
std::optional<int64_t> pad = getConstantIntValue(padValue);
2196+
return (!pad.has_value() || pad.value() != 0) &&
21972197
resultTensorShape[pos] != 1;
21982198
})) {
21992199
LDBG("low pad must all be zero for all non unit dims: " << padOp << "\n");

mlir/test/Dialect/Linalg/vectorization-unsupported.mlir

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,10 @@ module attributes {transform.with_named_sequence} {
305305

306306
// -----
307307

308-
// Low padding is unsupported with the exception of the special case if the
309-
// result size of the padded dimension is unit. Here `%l0` being a non-zero
310-
// padding applied to a non-unit result dimension makes this case unsupported.
311-
func.func @test_masked_vectorize_lowpad(
308+
// Padding with non-zero low pad values is not supported, unless the corresponding
309+
// result dim is 1. Here `%l0` being a non-zero low pad applied to a
310+
// non-unit result dimension makes this case unsupported.
311+
func.func @tensor_pad_non_zero_low_pad(
312312
%0 : tensor<?x?xf32>, %h0 : index, %h1 : index, %l0 : index)
313313
-> tensor<2x4xf32> {
314314
// expected-error @+3 {{Attempted to vectorize, but failed}}

mlir/test/Dialect/Linalg/vectorization.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,8 +668,8 @@ module attributes {transform.with_named_sequence} {
668668
// This case is supported because low padding `%l0` is applied on
669669
// a unit dimension which is supported, non unit result dimension low
670670
// padding is currently unsupported.
671-
// CHECK-LABEL: func @test_masked_vectorize_unit_lowpad
672-
func.func @test_masked_vectorize_unit_lowpad(
671+
// CHECK-LABEL: func @test_masked_vectorize_non_zero_low_pad_unit_res_dim
672+
func.func @test_masked_vectorize_non_zero_low_pad_unit_res_dim(
673673
%0 : tensor<?x?xf32>, %h0 : index, %h1 : index, %l0 : index)
674674
-> tensor<1x4xf32>
675675
{

0 commit comments

Comments
 (0)