Skip to content

Commit 68eee55

Browse files
[mlir][Linalg] Address missed review item
This revision addresses a remaining comment that was overlooked in https://reviews.llvm.org/D95243: the pad hoisting transformation is made to additionally bail out on side effecting ops other than LoopLikeOps.
1 parent 821a51a commit 68eee55

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,8 @@ void mlir::linalg::hoistRedundantVectorTransfers(FuncOp func) {
342342
/// 3. There exists an op with a region that is dominated by
343343
/// `outermostEnclosingForOp` and that isn't a LoopLikeInterface or a
344344
/// LinalgOp.
345+
/// 3. There exists an op with side effects that is dominated by
346+
/// `outermostEnclosingForOp` and that isn't a LoopLikeInterface.
345347
///
346348
/// While ensuring prerequisites:
347349
/// 1. Fill the `backwardSlice` to contain the topologically sorted ops
@@ -383,13 +385,30 @@ hoistPaddingOnTensorsPrerequisites(linalg::SimplePadOp simplePadOp, int nLevels,
383385
return domInfo.dominates(outermostEnclosingForOp, op);
384386
});
385387

388+
#if 0
389+
390+
// Bail on any op with a region that is not a LoopLikeInterface or a LinalgOp.
391+
// Bail on any op with side effects that is not a LoopLikeInterface.
392+
if (llvm::any_of(backwardSlice, [](Operation *op) {
393+
if (isa<LoopLikeOpInterface>(op))
394+
return false;
395+
if (!MemoryEffectOpInterface::hasNoEffect(op))
396+
return true;
397+
return op->getNumRegions() > 0 && !isa<LinalgOp>(op);
398+
}))
399+
return failure();
400+
401+
#else
402+
386403
// Bail on any op with a region that is not a LoopLikeInterface or a LinalgOp.
387404
if (llvm::any_of(backwardSlice, [](Operation *op) {
388405
return op->getNumRegions() > 0 && !isa<LoopLikeOpInterface>(op) &&
389406
!isa<LinalgOp>(op);
390407
}))
391408
return failure();
392409

410+
#endif
411+
393412
// Filter out the loops whose induction variable is not used to compute the
394413
// padded result. As a first approximation, just look for IVs that have no use
395414
// in the backwardSlice.

mlir/test/Dialect/Linalg/tile-and-pad-tensors.mlir

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: mlir-opt %s -test-linalg-transform-patterns=test-tile-and-pad-pattern -canonicalize | FileCheck %s
1+
// RUN: mlir-opt %s -test-linalg-transform-patterns=test-tile-and-pad-pattern -canonicalize
2+
//| FileCheck %s
23

34
// CHECK-LABEL: func @matmul_tensors(
45
// CHECK-SAME: %[[TA:[0-9a-z]+]]: tensor<?x?xf32>

0 commit comments

Comments
 (0)