[Mlir-commits] [mlir] [mlir][TilingInterface] Use `LoopLikeOpInterface` in tiling using SCF to unify tiling with `scf.for` and `scf.forall`. (PR #77874)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Jan 17 23:05:15 PST 2024


================
@@ -622,6 +626,47 @@ LogicalResult scf::ForallOp::promoteIfSingleIteration(RewriterBase &rewriter) {
   return success();
 }
 
+Block::BlockArgListType ForallOp::getRegionIterArgs() {
+  return getBody()->getArguments().drop_front(getRank());
+}
+
+MutableArrayRef<OpOperand> ForallOp::getInitsMutable() {
----------------
MaheshRavishankar wrote:

> I think you are missing a `getYieldedValuesMutable` implementation for `ForallOp`.
> 
> This is what the interface documentation says:
> 
> ```
>     Loop-carried variables can be exposed through this interface. There are
>     3 components to a loop-carried variable.
>     - The "region iter_arg" is the block argument of the entry block that
>       represents the loop-carried variable in each iteration.
>     - The "init value" is an operand of the loop op that serves as the initial
>       region iter_arg value for the first iteration (if any).
>     - The "yielded" value is the value that is forwarded from one iteration to
>       serve as the region iter_arg of the next iteration.
> 
>     If one of the respective interface methods is implemented, so must the other
>     two. The interface verifier ensures that the number of types of the region
>     iter_args, init values and yielded values match.
> ```

Obviously that definition does not work for `scf.forall`. Might need to update this since the `scf.forall` does not yield any value. The region iter arg and init value can stay though.

> 
> This is checked by the op verifier, so you should be seeing verification failures.
> 

I did. I fixed the verifier also, but I think as you note below, `getYieldedValuesMutable` should return an `std::optional<..>`


> On second thought, scf.forall should not implement getRegionIterArgs at all. The region iter_args in the loop like op interface are loop-carried variables, but the scf.forall does not have any loop-carried variables.

We probably dont need that.. the region iter args can still be tied to init. If there is no yield value, then the verifier can handle it appropriately.

https://github.com/llvm/llvm-project/pull/77874


More information about the Mlir-commits mailing list