[Mlir-commits] [mlir] [mlir][TilingInterface] Update documentation for `TilingInterface.td`. (PR #95178)
Quinn Dawkins
llvmlistbot at llvm.org
Tue Jun 11 16:44:13 PDT 2024
================
@@ -152,38 +224,69 @@ def TilingInterface : OpInterface<"TilingInterface"> {
>,
InterfaceMethod<
/*desc=*/[{
- Method to generate the tiled implementation of an operation from
- operand tile position.
+ Method to return the tile of the iteration domain that uses a given
+ tile of the operand.
- NOTE: For most operations, this should be a trivial composition of
- getIterationDomainTileFromOperandTile and getTiledImplementation.
+ This method is required to allow operations to be "tiled and fused"
+ with an (already tiled) producer. Given a tile of an operand,
+ returns the tile of the iteration space that uses this tile.
+ - `operandNumber` is the result of the producer used by the consumer.
+ - `offsets` is the offset of the slice of the producer result used by
+ the tiled implementation of the consumer.
+ - `sizes` is the size of the slice of the producer result used by the
+ consumer.
+ If it is illegal to fuse with a producer along the given operand for
+ an operation, or if this mapping cannot be computed, the
+ implementation should return a failure.
- Generates the IR that computes the tiled implementation of an
- operation from operand tile. The `offsets` and `sizes`
- describe the tile of the operand required. This is different from
- `getTiledImplementation` which generates the tiled
- implementation of the operation given a tile of the
- iteration space. This method generates a tiled
- implementation of the operation based on the tile of the
- operand required. This method enables consumer fusion by using
- tile and fuse. The method returns failure if the operation
- can't be tiled to generate the operand tile. In practical terms
- this implies it cannot be tiled and fused with its producers.
+ Note that unlike the "tile consumer and fuse producer" case, the
+ "tile producer and fuse consumer" requires an additional method to get
+ the iteration tile space that encompasses all uses of the given operand
+ tile. The reason for this is, consider
+ ```mlir
+ %1 = scf.for... {
+ %2 = <tiled_producer_op>
+ %3 = tensor.insert_slice %2 into ...
+ scf.yield %3
+ }
+ %4 = <consumer_op>)(... %1... )
+ ... <some_op>(... %4 ...)
+ ```
- - `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.
+ when fused this becomes
+ ```
+ %1 = scf.for... {
+ %2 = <tiled_producer_op>
+ %3 = <tiled_consumer_op>(... %2...)
+ %4 = tensor.insert_slice %3 into ...
+ scf.yield %4
+ }
+ ... <some_op>(... %1 ...)
+ ```
+
+ i.e, when fusing the consumer, the replacement for the result of the
+ consumer needs to be returned to replace the uses of the consumer.
+ For the tile+fuse algorithm to do this it needs information about
+ which tile of the iteration space encompasses all uses of the tile
+ produced and use that to compute what are the results produced.
+
+ Note that this method is only used as a way to implement the
+ transformation. It does not provide gaurantees on whether such a
----------------
qedawkins wrote:
```suggestion
transformation. It does not provide guarantees on whether such a
```
https://github.com/llvm/llvm-project/pull/95178
More information about the Mlir-commits
mailing list