Skip to content

Commit bc202a5

Browse files
Add description for yieldTiledValuesAndReplace.
1 parent 0b91c98 commit bc202a5

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

mlir/include/mlir/Interfaces/LoopLikeInterface.td

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,41 @@ def LoopLikeOpInterface : OpInterface<"LoopLikeOpInterface"> {
222222
}]
223223
>,
224224
InterfaceMethod<[{
225-
TODO
225+
Append the specified additional "init" operands: replace this loop with
226+
a new loop that has the additional init operands. The loop body of
227+
this loop is moved over to the new loop.
228+
229+
This method is similar to `replaceWithAdditionalYields` but instead of
230+
returning the value that is actually yielded, this returns the tiles of
231+
the values that are yielded. This allows for unified handling of opreations
232+
like `scf.forall` which dont yield a value from the loop, but instead
233+
the terminator specifies where to insert the tile yielded by the body of
234+
the loop. For example,
235+
236+
```mlir
237+
%0 = scf.forall ... shared_outs(%arg0 = %arg1) {
238+
...
239+
%tiled_value
240+
scf.forall.in_parallel {
241+
tensor.parallel_insert_slice %tiled_value into %arg0[%o1, %o2]...
242+
}
243+
}
244+
```
245+
246+
For an `scf.for` the same computation would be represented as
247+
```mlir
248+
%0 = scf.for ... iter_args(%arg0 = %arg1) {
249+
...
250+
%tiled_value
251+
%insert = tensor.insert_slice %tiled_value into %arg0[%o1, %o2]...
252+
scf.yield %insert
253+
}
254+
```
255+
256+
So for the caller, the tiled value (`%tiled_values`) and the offsets
257+
`(%o1, %o2)` and sizes (not shown) are generated the same way, but
258+
the implementation method for the different loop constructs handles
259+
the difference in representation.
226260
}],
227261
/*retTy=*/"::mlir::FailureOr<::mlir::LoopLikeOpInterface>",
228262
/*methodName=*/"yieldTiledValuesAndReplace",

0 commit comments

Comments
 (0)