Skip to content

Commit 09dab87

Browse files
Try not using llvm::function_ref.
1 parent 20271d9 commit 09dab87

File tree

2 files changed

+23
-45
lines changed

2 files changed

+23
-45
lines changed

mlir/include/mlir/Interfaces/LoopLikeInterface.h

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,9 @@ class RewriterBase;
2222
/// `replaceWithAdditionalYields`. `newBbArgs` are the newly added region
2323
/// iter_args. This function should return as many values as there are block
2424
/// arguments in `newBbArgs`.
25-
using NewYieldValuesFn = llvm::function_ref<SmallVector<Value>(
25+
using NewYieldValuesFn = std::function<SmallVector<Value>(
2626
OpBuilder &b, Location loc, ArrayRef<BlockArgument> newBbArgs)>;
2727

28-
/// A function that allows returning additional yielded values during
29-
/// `yieldTiledValuesAndReplace`.
30-
/// - `ivs` induction variable for the loop.
31-
/// - `newBbArgs` basic block arguments corresponding to newly added iter_args.
32-
/// - `tiledValues` the tiled values to return. Must be of same size as
33-
/// `newbbArgs`, each element of this array is inserted into the corresponding
34-
/// element in `newbbArgs`.
35-
/// - `resultOffsets` is of the same size as `tiledValues` and represents
36-
/// the offsets to use when inserting corresponding element from `tiledValues`
37-
/// into the element from `newBbArgs`.
38-
/// - `resultSizes` is of the same size as `tiledValues` and represents
39-
/// the size of the corresponding element from `tiledValues` inserted into
40-
/// the element from `newBbArgs`.
41-
/// - `resultStrides` is of the same size as `tiledValues` and represents
42-
/// the strides to use when inserting corresponding element from `tiledValues`
43-
/// into the element from `newBbArgs`.
44-
using YieldTiledValuesFn = llvm::function_ref<LogicalResult(
45-
RewriterBase &rewriter, Location loc, ValueRange ivs, ValueRange newBbArgs,
46-
SmallVector<Value> &tiledValues,
47-
SmallVector<SmallVector<OpFoldResult>> &resultOffsets,
48-
SmallVector<SmallVector<OpFoldResult>> &resultSizes)>;
49-
5028
namespace detail {
5129
/// Verify invariants of the LoopLikeOpInterface.
5230
LogicalResult verifyLoopLikeOpInterface(Operation *op);

mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,25 @@ static OpFoldResult getBoundedTileSize(OpBuilder &b, Location loc,
9999
b, loc, minMap, SmallVector<OpFoldResult>{iv, tileSize, size});
100100
}
101101

102+
/// A function that allows returning additional yielded values during
103+
/// `yieldTiledValuesAndReplace`.
104+
/// - `ivs` induction variable for the loop.
105+
/// - `newBbArgs` basic block arguments corresponding to newly added iter_args.
106+
/// - `tiledValues` the tiled values to return. Must be of same size as
107+
/// `newbbArgs`, each element of this array is inserted into the corresponding
108+
/// element in `newbbArgs`.
109+
/// - `resultOffsets` is of the same size as `tiledValues` and represents
110+
/// the offsets to use when inserting corresponding element from `tiledValues`
111+
/// into the element from `newBbArgs`.
112+
/// - `resultSizes` is of the same size as `tiledValues` and represents
113+
/// the size of the corresponding element from `tiledValues` inserted into
114+
/// the element from `newBbArgs`.
115+
using YieldTiledValuesFn = std::function<LogicalResult(
116+
RewriterBase &rewriter, Location loc, ValueRange ivs, ValueRange newBbArgs,
117+
SmallVector<Value> &tiledValues,
118+
SmallVector<SmallVector<OpFoldResult>> &resultOffsets,
119+
SmallVector<SmallVector<OpFoldResult>> &resultSizes)>;
120+
102121
/// Clones the operation and updates the destination if the operation
103122
/// implements the `DestinationStyleOpInterface`.
104123
static Operation *cloneOpAndUpdateDestinationArgs(RewriterBase &rewriter,
@@ -288,25 +307,6 @@ static LogicalResult generateLoopNest(RewriterBase &rewriter, Location loc,
288307
return rewriter.notifyMatchFailure(loc, "unhandled loop type");
289308
}
290309

291-
/// A function that allows returning additional yielded values during
292-
/// `yieldTiledValuesAndReplace`.
293-
/// - `ivs` induction variable for the loop.
294-
/// - `newBbArgs` basic block arguments corresponding to newly added iter_args.
295-
/// - `tiledValues` the tiled values to return. Must be of same size as
296-
/// `newbbArgs`, each element of this array is inserted into the corresponding
297-
/// element in `newbbArgs`.
298-
/// - `resultOffsets` is of the same size as `tiledValues` and represents
299-
/// the offsets to use when inserting corresponding element from `tiledValues`
300-
/// into the element from `newBbArgs`.
301-
/// - `resultSizes` is of the same size as `tiledValues` and represents
302-
/// the size of the corresponding element from `tiledValues` inserted into
303-
/// the element from `newBbArgs`.
304-
using YieldTiledValuesFn = llvm::function_ref<LogicalResult(
305-
RewriterBase &rewriter, Location loc, ValueRange ivs, ValueRange newBbArgs,
306-
SmallVector<Value> &tiledValues,
307-
SmallVector<SmallVector<OpFoldResult>> &resultOffsets,
308-
SmallVector<SmallVector<OpFoldResult>> &resultSizes)>;
309-
310310
/// Append the specified additional `newInitOperands` operands to the
311311
/// loops existing `init` operands (or similar), and replace `loopOp` with
312312
/// the new loop that has the additional init operands. The loop body of
@@ -441,8 +441,8 @@ FailureOr<LoopLikeOpInterface> yieldTiledValuesAndReplaceLoop<scf::ForallOp>(
441441
FailureOr<LoopLikeOpInterface> yieldTiledValuesAndReplaceLoop(
442442
LoopLikeOpInterface loopLikeOp, RewriterBase &rewriter,
443443
ValueRange newInitOperands, YieldTiledValuesFn yieldTiledValuesFn) {
444-
return TypeSwitch<LoopLikeOpInterface, FailureOr<LoopLikeOpInterface>>(
445-
loopLikeOp)
444+
return TypeSwitch<Operation *, FailureOr<LoopLikeOpInterface>>(
445+
loopLikeOp.getOperation())
446446
.Case<scf::ForOp, scf::ForallOp>(
447447
[&](auto loopOp) -> FailureOr<LoopLikeOpInterface> {
448448
return yieldTiledValuesAndReplaceLoop(
@@ -460,7 +460,7 @@ FailureOr<LoopLikeOpInterface> yieldTiledValuesAndReplaceLoop(
460460
/// the additional values to yield form the innermost loop.
461461
static LogicalResult addInitOperandsToLoopNest(
462462
RewriterBase &rewriter, MutableArrayRef<LoopLikeOpInterface> loops,
463-
ValueRange newInitValues, const YieldTiledValuesFn &getNewTiledYieldsFn) {
463+
ValueRange newInitValues, YieldTiledValuesFn getNewTiledYieldsFn) {
464464
SmallVector<scf::ForOp> newLoops;
465465
if (loops.empty())
466466
return success();

0 commit comments

Comments
 (0)