PSA: Changes to `TilingInterface` ABI

⚙ D145133 [mlir][TilingInterface] Modify `TilingInterface` methods to better return the state of the transformed IR. changes the ABI for a couple of methods of the TilingInterface as shown below

FailureOr<TilingResult> getTiledImplementation(OpBuilder &b,
    ArrayRef<OpFoldResult> offsets, ArrayRef<OpFoldResult> sizes)

and

FailureOr<TilingResult> generateResultTileValue(OpBuilder &b,
    unsigned resultNumber,  ArrayRef<OpFoldResult> offsets,
    ArrayRef<OpFoldResult> sizes)

where

struct TilingResult {
  SmallVector<Operation *> tiledOps;
  SmallVector<Value> tiledValues;
};

The change is necessitated by the recognition that the current interface method ABI does not allow the implementation to propagate the state of the IR post transformation effectively. Specifically,

  1. The getTiledImplementation returned a SmallVector<Operation *> . Failure of tiling was propagated by the returned vector being empty.
  2. Callers implicitly assumed that the returned operation results represent the tiled values for all the results of the operation. That is not necessarily true. Indeed, in general many operations might be needed for a full tiled implementation with different operations providing different tiled values.
  3. Passing the state of the transformed IR, though a list of operations that might themselves be operated on by future transformations was awkward because of the implicit assumption that tiled values are obtained by results of the returned operations.

The new ABI makes it explicit what the tiled values are, and returns the operations that are generated during the implementation.
The change above is ready to land, but I will wait for mid-to-late next week (around March 8th) to land that change. Should be fairly easy to adapt to the new API in downstream users, but please let me know if you have questions/clarifications.

2 Likes