This is an archive of the discontinued LLVM Phabricator instance.

[mlir][linalg] Add nicer builders for `map` and `reduce`.
ClosedPublic

Authored by olegshyshkov on Oct 27 2022, 4:45 AM.

Details

Summary

The new builders get a list of additional attrs, a lambda to build the region
body and infer return types from init.

Diff Detail

Event Timeline

olegshyshkov created this revision.Oct 27 2022, 4:45 AM
olegshyshkov requested review of this revision.Oct 27 2022, 4:45 AM
pifon2a accepted this revision.Oct 27 2022, 4:51 AM
This revision is now accepted and ready to land.Oct 27 2022, 4:51 AM

Create region empty region in TransposeOp::parse to fix test breakage.

pifon2a accepted this revision.Oct 27 2022, 8:54 AM

clang-format.

mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
271

I personally find it very confusing to have something named init that is just ignored..
Init suggests it must be initialized properly, out does not have that baggage (but has other problems).

As an analogy, consider how one would write c = a + b vs c += a + b.
I am yet unaware the best way to proceed as it has implications on the dependence chains for bufferization.
The tradeoff goes relatively deep and also impacts how higher levels (or IR programmers) should target this, it is not just a trivial bikeshedding thing.

This is part of the bigger discussion in https://reviews.llvm.org/D136875.
This commit may need to be reverted depending on what the discussion above yields.

pifon2a added inline comments.Oct 28 2022, 2:23 AM
mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
271

Technically, it is init for the DPS interface, but we can rename to $out in the MapOp definition in TableGen. Would it be fine? I commented in the bigger discussion in the https://reviews.llvm.org/D136875.