This is an archive of the discontinued LLVM Phabricator instance.

[mlir][OpDSL] Add arithmetic function attributes.
ClosedPublic

Authored by gysit on Feb 18 2022, 12:00 AM.

Details

Summary

The revision extends OpDSL with unary and binary function attributes. A function attribute, makes the operations used in the body of a structured operation configurable. For example, a pooling operation may take an aggregation function attribute that specifies if the op shall implement a min or a max pooling. The goal of this revision is to define less and more flexible operations.

We may thus for example define an element wise op:

linalg.elem(lhs, rhs, outs=[out], op=BinaryFn.mul)

If the op argument is not set the default operation is used.

Depends On D120109

Diff Detail

Event Timeline

gysit created this revision.Feb 18 2022, 12:00 AM
gysit requested review of this revision.Feb 18 2022, 12:00 AM
gysit updated this revision to Diff 410002.Feb 18 2022, 12:49 PM

Minor improvements.

gysit updated this revision to Diff 410241.Feb 21 2022, 1:03 AM

Use custom enum format.

gysit updated this revision to Diff 410256.Feb 21 2022, 2:23 AM

Rebase and fix formatting.

gysit updated this revision to Diff 410798.Feb 23 2022, 6:15 AM

Improve comments.

gysit updated this revision to Diff 411093.Feb 24 2022, 5:15 AM

Rebase.

nicolasvasilache accepted this revision.Feb 28 2022, 6:12 AM

Nice!

mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
240

why assert but still allow early exit below ?

This revision is now accepted and ready to land.Feb 28 2022, 6:12 AM
gysit added inline comments.Feb 28 2022, 6:23 AM
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
240

Yes will remove both of them and leave this to the verifier...

gysit updated this revision to Diff 411804.Feb 28 2022, 6:41 AM

Address comment.

aartbik accepted this revision.Feb 28 2022, 11:37 AM
aartbik added inline comments.
mlir/docs/Dialects/Linalg/OpDSL.md
227

computations?

mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
150

the code that mates to this class? I am not a native speaker, but this sounds a bit strange?

266–267

typically data members come after code? Any reason why this was moved?

gysit updated this revision to Diff 411984.Feb 28 2022, 11:33 PM
gysit marked 2 inline comments as done.

Address comments.

gysit updated this revision to Diff 411986.Feb 28 2022, 11:37 PM

Second try to address comments.

This revision was landed with ongoing or failed builds.Feb 28 2022, 11:46 PM
This revision was automatically updated to reflect the committed changes.