[Mlir-commits] [mlir] [mlir][loops] Add getters for multi dim loop variables in `LoopLikeOpInterface` (PR #94516)

Jorn Tuyls llvmlistbot at llvm.org
Thu Jun 6 10:54:09 PDT 2024


jtuyls wrote:

> > I am fine with this approach modulo inputs from others. @jtuyls had a separate approach where he was thinking of defining a new interface that would create an inherited interface for loops with induction variables. I am partial to the approach in this PR, but the other approach is valid as well.
> 
> i took a brief look at this. maybe i'm missing something, but i'm not much of a fan for a whole new interface just to get the multi induction/bounds/etc. but i'm certainly no authority on this

Initially, I used `optional<>`/empty list/setters returning a `LogicalResult` on all methods related to induction variables, but imo, having to do that is demonstrating that not all loops are equal (or all are, but some more equal than others) and that there is a distinction between loops with induction variables and ones without. By creating a new interface  you don't need the surrounding logic everywhere these methods are used to evaluate the return value and check whether it was valid or not to use this method on that operation or not. Also, this let's you reuse the existing induction variable related methods inside `scf.Forall`. But mainly, I think the point of an interface is to have a contract on what functionality is available for operations implementing the interface. Using `optional<>` on a set of methods, not a one-off, defeats that purpose and breaks the contract imo.

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


More information about the Mlir-commits mailing list