This is an archive of the discontinued LLVM Phabricator instance.

[mlir][linalg] adding operation to access the iteration index of enclosing linalg ops.
ClosedPublic

Authored by gysit on Apr 12 2021, 2:25 AM.

Details

Summary

The linalg.index operation provides access to the iteration indexes of immediately enclosing linalg operations. It takes a dimension dim attribute and returns the iteration index in the given dimension. Having linalg.index allows us to unify linalg.generic and linalg.indexed_generic and also enables index access in named operations.

Diff Detail

Event Timeline

gysit created this revision.Apr 12 2021, 2:25 AM
gysit requested review of this revision.Apr 12 2021, 2:25 AM
nicolasvasilache accepted this revision.Apr 12 2021, 3:03 AM

Nice, thank you for starting this unification effort!

mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td
622

I see in MemRefOps.td we have something like:

Confined<OptionalAttr<I64Attr>, [IntMinValue<0>]>:$alignment

I am not sure whether you can use with a C++ value instead of 0, but it should at least work for >= 0 (which isn't currently check IIUC).

This revision is now accepted and ready to land.Apr 12 2021, 3:03 AM
gysit updated this revision to Diff 336805.Apr 12 2021, 4:38 AM

Confine the dim attribute to values larger than zero.

gysit marked an inline comment as done.Apr 12 2021, 4:42 AM
gysit added inline comments.
mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td
622

Good point! I added IntMinValue to ensure the dim value needs to be larger than or equal to zero. I left the check for the upper bound of dim in the CPP since that check if very much operation specific.

gysit marked an inline comment as done.Apr 12 2021, 6:04 AM
pifon2a accepted this revision.Apr 12 2021, 6:21 AM