Commit 68eee55c authored by Nicolas Vasilache's avatar Nicolas Vasilache
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.
parent 821a51a9
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -342,6 +342,8 @@ void mlir::linalg::hoistRedundantVectorTransfers(FuncOp func) {
///   3. There exists an op with a region that is dominated by
///   `outermostEnclosingForOp` and that isn't a LoopLikeInterface or a
///    LinalgOp.
///   3. There exists an op with side effects that is dominated by
///    `outermostEnclosingForOp` and that isn't a LoopLikeInterface.
///
/// While ensuring prerequisites:
///   1. Fill the `backwardSlice` to contain the topologically sorted ops
@@ -383,6 +385,21 @@ hoistPaddingOnTensorsPrerequisites(linalg::SimplePadOp simplePadOp, int nLevels,
    return domInfo.dominates(outermostEnclosingForOp, op);
  });

  #if 0

  // Bail on any op with a region that is not a LoopLikeInterface or a LinalgOp.
  // Bail on any op with side effects that is not a LoopLikeInterface.
  if (llvm::any_of(backwardSlice, [](Operation *op) {
        if (isa<LoopLikeOpInterface>(op))
          return false;
        if (!MemoryEffectOpInterface::hasNoEffect(op))
          return true;
        return op->getNumRegions() > 0 && !isa<LinalgOp>(op);
      }))
    return failure();

  #else

  // Bail on any op with a region that is not a LoopLikeInterface or a LinalgOp.
  if (llvm::any_of(backwardSlice, [](Operation *op) {
        return op->getNumRegions() > 0 && !isa<LoopLikeOpInterface>(op) &&
@@ -390,6 +407,8 @@ hoistPaddingOnTensorsPrerequisites(linalg::SimplePadOp simplePadOp, int nLevels,
      }))
    return failure();

  #endif

  // Filter out the loops whose induction variable is not used to compute the
  // padded result. As a first approximation, just look for IVs that have no use
  // in the backwardSlice.
+2 −1
Original line number Diff line number Diff line
// RUN: mlir-opt %s -test-linalg-transform-patterns=test-tile-and-pad-pattern -canonicalize | FileCheck %s
// RUN: mlir-opt %s -test-linalg-transform-patterns=test-tile-and-pad-pattern -canonicalize
//| FileCheck %s

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