Skip to content

Commit d156637

Browse files
committed
Revert "[mlir] Skip scalar operands when tiling to linalg.tiled_loop."
This reverts commit 69046b4. It did not really break anything, but it was decided to allow scalars and other non-shaped operands for tiled_loop.
1 parent 487f74a commit d156637

File tree

2 files changed

+3
-27
lines changed

2 files changed

+3
-27
lines changed

mlir/lib/Dialect/Linalg/Utils/Utils.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -284,19 +284,6 @@ void GenerateLoopNest<TiledLoopOp>::doit(
284284
SmallVector<Value, 4> lbs, ubs, steps;
285285
unpackRanges(loopRanges, lbs, ubs, steps);
286286

287-
auto dropNonShapedValues =
288-
[](ArrayRef<OpOperand *> operands) -> SmallVector<Value, 2> {
289-
SmallVector<Value, 2> filteredOperands;
290-
for (OpOperand *operand : operands) {
291-
Type type = operand->get().getType();
292-
if (type.isa<ShapedType>())
293-
filteredOperands.push_back(operand->get());
294-
}
295-
return filteredOperands;
296-
};
297-
auto inputOperands = dropNonShapedValues(linalgOp.getInputOperands());
298-
auto outputOperands = dropNonShapedValues(linalgOp.getOutputOperands());
299-
300287
auto wrappedBuilderFn = [&](OpBuilder &nestedBuilder, Location nestedLoc,
301288
ValueRange ivs, ValueRange inputs,
302289
ValueRange outputs) {
@@ -305,6 +292,9 @@ void GenerateLoopNest<TiledLoopOp>::doit(
305292
bodyBuilderFn(nestedBuilder, nestedLoc, ivs, outputTensors);
306293
nestedBuilder.create<linalg::YieldOp>(nestedLoc, results);
307294
};
295+
296+
SmallVector<Value> inputOperands = linalgOp.getInputOperands();
297+
SmallVector<Value> outputOperands = linalgOp.getOutputOperands();
308298
auto tiledLoop =
309299
b.create<TiledLoopOp>(loc, lbs, ubs, steps, inputOperands, outputOperands,
310300
b.getArrayAttr(iteratorTypes), wrappedBuilderFn);

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,3 @@ func @generic_op_tensors(
130130
// TLOOP-SAME: ins (%{{.*}} = %[[ARG_0]]: [[TY]], %{{.*}} = %[[ARG_1]]: [[TY]])
131131
// TLOOP-SAME: outs (%{{.*}} = %[[INIT]]: [[TY]])
132132
// TLOOP-SAME: distribution["block_x", "block_y", "none"] {
133-
134-
135-
func @fill(%arg0 : tensor<?x?x?xf32>) -> tensor<?x?x?xf32> {
136-
%c0 = constant 0.0 : f32
137-
%0 = linalg.fill(%c0, %arg0) : f32, tensor<?x?x?xf32> -> tensor<?x?x?xf32>
138-
return %0 : tensor<?x?x?xf32>
139-
}
140-
// CHECK-LABEL: func @fill
141-
142-
// TLOOP-LABEL: func @fill
143-
// TLOOP-NOT: ins
144-
// TLOOP: tensor.extract_slice
145-
// TLOOP-NEXT: linalg.fill
146-
// TLOOP-NEXT: tensor.insert_slice

0 commit comments

Comments
 (0)