[Mlir-commits] [mlir] 5479428 - [mlir][interfaces] Drop `dest`/`tileDestOperands` from TilingInterface
Matthias Springer
llvmlistbot at llvm.org
Wed Aug 31 23:57:29 PDT 2022
Author: Matthias Springer
Date: 2022-09-01T08:53:53+02:00
New Revision: 547942841f7a9ecc04ed4ac8045c81e734f50e29
URL: https://github.com/llvm/llvm-project/commit/547942841f7a9ecc04ed4ac8045c81e734f50e29
DIFF: https://github.com/llvm/llvm-project/commit/547942841f7a9ecc04ed4ac8045c81e734f50e29.diff
LOG: [mlir][interfaces] Drop `dest`/`tileDestOperands` from TilingInterface
`getTiledImplementation`/`generateResultTileValue` only computes the tiled operation, but does not insert the result into any tensor.
Differential Revision: https://reviews.llvm.org/D133015
Added:
Modified:
mlir/include/mlir/Interfaces/TilingInterface.td
mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
mlir/lib/Dialect/Linalg/Transforms/Split.cpp
mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
mlir/lib/Dialect/Linalg/Transforms/TilingInterfaceImpl.cpp
mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp
mlir/lib/Dialect/Tensor/Transforms/SwapExtractSliceWithProducer.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Interfaces/TilingInterface.td b/mlir/include/mlir/Interfaces/TilingInterface.td
index 099e8f7eaac74..222c075e4eebf 100644
--- a/mlir/include/mlir/Interfaces/TilingInterface.td
+++ b/mlir/include/mlir/Interfaces/TilingInterface.td
@@ -72,19 +72,12 @@ def TilingInterface : OpInterface<"TilingInterface"> {
`getIterationDomain`. The caller provides the information of the
tile within this iteration space whose implementation the
caller needs.
- - `dest` are the Value into which the result of the tiled
- operation is to be inserted into. The type of the `dest`
- Values is same as the types returned by
- `getDestinationOperands` method.
- `offsets` provides the offset of the tile in the coordinate system
of the original iteration space, i.e., if an iteration space
dimension had non-zero offset, it must be included in the offset
provided here (as opposed to zero-based offset "relative" to the
iteration space).
- `sizes` provides the size of the tile.
- - `tileDestOperands` specifies whether to also tile `dest` operands
- or not. Avoiding tiling `dest` operands can be useful for
- composition with various looping container ops.
The method returns the operation that is the tiled
implementation.
@@ -93,10 +86,8 @@ def TilingInterface : OpInterface<"TilingInterface"> {
/*methodName=*/"getTiledImplementation",
/*args=*/(ins
"OpBuilder &":$b,
- "ValueRange ":$dest,
"ArrayRef<OpFoldResult> ":$offsets,
- "ArrayRef<OpFoldResult> ":$sizes,
- "bool ":$tileDestOperands),
+ "ArrayRef<OpFoldResult> ":$sizes),
/*methodBody=*/"",
/*defaultImplementation=*/[{
return {};
@@ -140,29 +131,20 @@ def TilingInterface : OpInterface<"TilingInterface"> {
tiled to generate the result tile. In practical terms this
implies it cannot be tiled and fused with its consumers.
- - `dest` are the Value into which the result of the tiled
- operation is to be inserted into. The type of the `dest`
- Values is same as the types returned by
- `getDestinationOperands` method.
- `offsets` provides the offset of the tile in the coordinate system
of the original iteration space, i.e., if an iteration space
dimension had non-zero offset, it must be included in the offset
provided here (as opposed to zero-based offset "relative" to the
iteration space).
- `sizes` provides the size of the tile.
- - `tileDestOperands` specifies whether to also tile `dest` operands
- or not. Avoiding tiling `dest` operands can be useful for
- composition with various looping container ops.
}],
/*retType=*/"FailureOr<Value>",
/*methodName=*/"generateResultTileValue",
/*args=*/(ins
"OpBuilder &":$b,
"unsigned":$resultNumber,
- "ValueRange":$dest,
"ArrayRef<OpFoldResult>":$offsets,
- "ArrayRef<OpFoldResult>":$sizes,
- "bool":$tileDestOperands),
+ "ArrayRef<OpFoldResult>":$sizes),
/*methodBody=*/"",
/*defaultImplementation=*/[{
return failure();
diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
index 819f34596f6a0..80e4d313c1ad1 100644
--- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
+++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
@@ -242,9 +242,6 @@ static FailureOr<SmallVector<Operation *>> tileAndFuse(Operation *producerOp,
if (sliceOps.empty())
return failure();
- SmallVector<Value> destinationOperands =
- tileableProducer.getDestinationOperands(rewriter);
-
// Try to fuse the producer in-place.
SmallVector<Operation *> fusedOps;
for (tensor::ExtractSliceOp sliceOp : sliceOps) {
@@ -253,8 +250,8 @@ static FailureOr<SmallVector<Operation *>> tileAndFuse(Operation *producerOp,
// Tile the producer.
FailureOr<Value> tiledProducer = tileableProducer.generateResultTileValue(
- rewriter, /*resultNumber=*/0, destinationOperands,
- sliceOp.getMixedOffsets(), sliceOp.getMixedSizes(), true);
+ rewriter, /*resultNumber=*/0, sliceOp.getMixedOffsets(),
+ sliceOp.getMixedSizes());
if (failed(tiledProducer))
return failure();
fusedOps.push_back(tiledProducer->getDefiningOp());
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Split.cpp b/mlir/lib/Dialect/Linalg/Transforms/Split.cpp
index c00a1f8568506..db7262d663f8e 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Split.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Split.cpp
@@ -42,8 +42,7 @@ createSplitPart(RewriterBase &b, Location loc, TilingInterface op,
// Create the part as it it were a single tile.
SmallVector<Operation *> tiled =
- op.getTiledImplementation(b, resultOperands, offsetsCopy, sizesCopy,
- /*tileDestOperands=*/true);
+ op.getTiledImplementation(b, offsetsCopy, sizesCopy);
assert(tiled.size() == 1 && "expected a single result from tiling");
auto part = cast<TilingInterface>(tiled.front());
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
index c24f37949a037..c6a252c674261 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
@@ -318,8 +318,7 @@ static FailureOr<ForeachThreadTilingResult> tileToForeachThreadOpImpl(
}
SmallVector<Operation *> tiledOps =
- op.getTiledImplementation(b, destOperands, tiledOffsets, tiledSizes,
- /*tileDestOperands=*/true);
+ op.getTiledImplementation(b, tiledOffsets, tiledSizes);
assert(tiledOps.size() == 1 && "expected a single produced tiled op");
tiledOp = tiledOps.front();
diff --git a/mlir/lib/Dialect/Linalg/Transforms/TilingInterfaceImpl.cpp b/mlir/lib/Dialect/Linalg/Transforms/TilingInterfaceImpl.cpp
index cfd3c125e0951..761be35cfc6a6 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/TilingInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/TilingInterfaceImpl.cpp
@@ -118,10 +118,9 @@ struct LinalgOpTilingInterface
// Instantiate the tiled implementation of the operation.
SmallVector<Operation *>
- getTiledImplementation(Operation *op, OpBuilder &b, ValueRange dest,
+ getTiledImplementation(Operation *op, OpBuilder &b,
ArrayRef<OpFoldResult> offsets,
- ArrayRef<OpFoldResult> sizes,
- bool tileDestOperands) const {
+ ArrayRef<OpFoldResult> sizes) const {
// Leave the `sizeBounds` value empty. That is only needed when the `sizes`
// specified could lead to out of bounds accesses.
Location loc = op->getLoc();
@@ -172,10 +171,8 @@ struct LinalgOpTilingInterface
FailureOr<Value> generateResultTileValue(Operation *op, OpBuilder &b,
unsigned resultNumber,
- ValueRange dest,
ArrayRef<OpFoldResult> offsets,
- ArrayRef<OpFoldResult> sizes,
- bool tileDestOperands) const {
+ ArrayRef<OpFoldResult> sizes) const {
auto linalgOp = cast<LinalgOp>(op);
// Check that the indexing map used for the output is a projected
@@ -210,7 +207,7 @@ struct LinalgOpTilingInterface
}
SmallVector<Operation *> tiledOp = tilingInterfaceOp.getTiledImplementation(
- b, dest, iterationTileOffsets, iterationTileSizes, tileDestOperands);
+ b, iterationTileOffsets, iterationTileSizes);
if (tiledOp.size() != 1)
return op->emitOpError("failed to generate tiled implementation");
diff --git a/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp b/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
index 03ee7612acb4a..8e55ce9613baf 100644
--- a/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
+++ b/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
@@ -257,8 +257,8 @@ scf::TileUsingSCFForOp::returningMatchAndRewrite(
if (!tilingResult.loops.empty())
rewriter.setInsertionPoint(
tilingResult.loops.back().getBody()->getTerminator());
- SmallVector<Operation *> tiledImplementation = op.getTiledImplementation(
- rewriter, op.getDestinationOperands(rewriter), offsets, sizes, true);
+ SmallVector<Operation *> tiledImplementation =
+ op.getTiledImplementation(rewriter, offsets, sizes);
if (tiledImplementation.size() != 1) {
return rewriter.notifyMatchFailure(
op, "expected tiled implementation to return a single op");
diff --git a/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp b/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp
index 04cab1bb11b2c..1897cde0d425e 100644
--- a/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp
@@ -61,10 +61,9 @@ struct PadOpTiling : public TilingInterface::ExternalModel<PadOpTiling, PadOp> {
}
SmallVector<Operation *>
- getTiledImplementation(Operation *op, OpBuilder &b, ValueRange dest,
+ getTiledImplementation(Operation *op, OpBuilder &b,
ArrayRef<OpFoldResult> offsets,
- ArrayRef<OpFoldResult> sizes,
- bool /*tileDestOperands*/) const {
+ ArrayRef<OpFoldResult> sizes) const {
Operation *result =
tensor::bubbleUpPadSlice(b, cast<PadOp>(op), offsets, sizes);
if (!result)
diff --git a/mlir/lib/Dialect/Tensor/Transforms/SwapExtractSliceWithProducer.cpp b/mlir/lib/Dialect/Tensor/Transforms/SwapExtractSliceWithProducer.cpp
index 87981646d0ffa..be7695e8b24e2 100644
--- a/mlir/lib/Dialect/Tensor/Transforms/SwapExtractSliceWithProducer.cpp
+++ b/mlir/lib/Dialect/Tensor/Transforms/SwapExtractSliceWithProducer.cpp
@@ -33,9 +33,8 @@ FailureOr<Value> tensor::replaceExtractSliceWithTiledProducer(
return failure();
FailureOr<Value> tiledResult = producerOp.generateResultTileValue(
- builder, producer.getResultNumber(),
- producerOp.getDestinationOperands(builder), sliceOp.getMixedOffsets(),
- sliceOp.getMixedSizes(), true);
+ builder, producer.getResultNumber(), sliceOp.getMixedOffsets(),
+ sliceOp.getMixedSizes());
if (failed(tiledResult))
return failure();
More information about the Mlir-commits
mailing list