This is an archive of the discontinued LLVM Phabricator instance.

[mlir][linalg] Propagate attributes when doing named ops conversion.
ClosedPublic

Authored by hanchung on Sep 14 2022, 1:42 PM.

Details

Summary

Custom attributes can be set on the operation. It prevents them to be
removed when doing named ops conversion.

Diff Detail

Event Timeline

hanchung created this revision.Sep 14 2022, 1:42 PM
hanchung requested review of this revision.Sep 14 2022, 1:42 PM
hanchung updated this revision to Diff 460204.Sep 14 2022, 1:43 PM

delete unused includes

mravishankar requested changes to this revision.Sep 14 2022, 1:46 PM
mravishankar added inline comments.
mlir/lib/Dialect/Linalg/Transforms/NamedOpConversions.cpp
93–95

Might be a better way of doing this. All ops have an attrName list. These are names of attributes that are defined in the tablegen op definition. Copy over everything that is not that.

This revision now requires changes to proceed.Sep 14 2022, 1:46 PM
hanchung updated this revision to Diff 460265.Sep 14 2022, 4:55 PM

get attribute list properly

hanchung added inline comments.Sep 15 2022, 9:28 AM
mlir/lib/Dialect/Linalg/Transforms/NamedOpConversions.cpp
93–95

I finally figure out how to use the method. getAttributeNames only works at op level. It does not work at Operation* level. I think it does look better because we do declare elidedAttrs variable, which has better readability.

mravishankar accepted this revision.Sep 15 2022, 9:39 AM
mravishankar added inline comments.
mlir/lib/Dialect/Linalg/Transforms/NamedOpConversions.cpp
93–95

Thanks!. The kMemoizedIndexingMapAttrName is tricky.... thanks for catching that....

Ill stamp this, but probably something similar is needed in other places. Maybe moving it to a Linalg/Utils/Utils.h is worth it.
Also readability can be slightly better with TypeSwitch.

This revision is now accepted and ready to land.Sep 15 2022, 9:39 AM
hanchung updated this revision to Diff 460460.Sep 15 2022, 10:52 AM

Address comments.

  • Add the method to Utils.h
  • Use TypeSwitch
mlir/lib/Dialect/Linalg/Transforms/NamedOpConversions.cpp
93–95

Moved!

Yes, I like TypeSwitch better. I followed the logic so I did not change it. let's switch to use TypeSwitch.

hanchung updated this revision to Diff 460461.Sep 15 2022, 10:54 AM

delete unneeded includes