This is an archive of the discontinued LLVM Phabricator instance.

[mlir][OpDSL] Split arithmetic functions.
ClosedPublic

Authored by gysit on Feb 17 2022, 11:59 PM.

Details

Summary

Split arithmetic function into unary and binary functions. The revision prepares the introduction of unary and binary function attributes that work similar to type function attributes.

Depends On D120108

Diff Detail

Event Timeline

gysit created this revision.Feb 17 2022, 11:59 PM
gysit requested review of this revision.Feb 17 2022, 11:59 PM

LGTM for the sparse part

I had a broader look at this at well. It is actually surprising that this change does not touch more tests. Do we need a few more just for this change?

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

you have two examples of binary, so use two example of unary
(in particular, because _exp could be mistaken for expression at first glance ;-)

mlir/python/mlir/dialects/linalg/opdsl/lang/comprehension.py
331

see in the other revision, should we consider cast_signed?

mlir/python/mlir/dialects/linalg/opdsl/lang/emitter.py
382

here and below, dump both lhs and rhs in error?

gysit marked 3 inline comments as done.Feb 24 2022, 4:58 AM

I had a broader look at this at well. It is actually surprising that this change does not touch more tests. Do we need a few more just for this change?

Yes, I think one reason is that the revision before (https://reviews.llvm.org/D120108) - I have added you in meantime - refactors the function handling to make sure all function type share the same base logic below the hood. Additionally, the follow up revsion (https://reviews.llvm.org/D120110) finally introduces function attributes and introduces additional tests. In particular, it has a nice integration test for a configurable pooling operation.

I already ported back a test introduced in https://reviews.llvm.org/D120110 and will also add an additional test on the yaml generation side. There is also a number of existing tests that for example check the lowering of unary functions works end to end (generalize-named-polymorphic-ops.mlir lowers softmax to exps and logs).

mlir/python/mlir/dialects/linalg/opdsl/lang/comprehension.py
331

Yes, I will prepare a separate revsion!

gysit updated this revision to Diff 411092.Feb 24 2022, 5:14 AM
gysit marked an inline comment as done.

Rebase and address comments.

aartbik accepted this revision.Feb 24 2022, 10:53 AM
This revision is now accepted and ready to land.Feb 24 2022, 10:53 AM
This revision was automatically updated to reflect the committed changes.