This is an archive of the discontinued LLVM Phabricator instance.

[mlir][OpDSL] Add default value to index attributes.
ClosedPublic

Authored by gysit on Feb 7 2022, 3:31 AM.

Details

Summary

Index attributes had no default value, which means the attribute values had to be set on the operation. This revision adds a default parameter to IndexAttrDef. After the change, every index attribute has to define a default value. For example, we may define the following strides attribute:

When using the operation the default stride is used if the strides attribute is not set. The mechanism is implemented using DefaultValuedAttr.

Additionally, the revision uses the naming index attribute instead of attribute more consistently, which is a preparation for follow up revisions that will introduce function attributes.

Depends On D119125

Diff Detail

Event Timeline

gysit created this revision.Feb 7 2022, 3:31 AM
gysit requested review of this revision.Feb 7 2022, 3:31 AM
gysit updated this revision to Diff 406767.Feb 8 2022, 4:16 AM

Try to fix Windows build issue.

gysit updated this revision to Diff 407558.Feb 10 2022, 8:49 AM

Minor formatting improvements.

stellaraccident accepted this revision.Feb 10 2022, 9:02 AM
stellaraccident added inline comments.
mlir/test/python/integration/dialects/linalg/opsrun.py
135

I would have expected this to be NFC. What am I missing?

135

NM. I see now that you changed the test to exercise defaulting better.

This revision is now accepted and ready to land.Feb 10 2022, 9:02 AM
This revision was automatically updated to reflect the committed changes.