This is an archive of the discontinued LLVM Phabricator instance.

[mlir][linalg] Replace "string" iterator_types attr with enums in LinalgInterface.
ClosedPublic

Authored by olegshyshkov on Nov 8 2022, 10:14 AM.

Details

Summary

RFC: EnumAttr for iterator types in Linalg

This affect touches and probably breaks most of the code that creates linalg.generic. A fix would be to replace calls to getParallelIteratorTypeName/getReductionIteratorTypeName with mlir::utils::IteratorType::parallel/reduction and types from StringRef to mlir::utils::IteratorType.

Due to limitations of tablegen, shared C++ definition of IteratorType enum lives in StructuredOpsUtils.td, but each dialect should have it's own EnumAttr wrapper. To avoid conflict, all enums in a dialect are put into a separate file with a separate tablegen rule.

Test dialect td files are refactored a bit.

Printed format of linalg.generic temporarily remains unchanged to avoid breaking code and tests in the same change.

Diff Detail

Event Timeline

olegshyshkov created this revision.Nov 8 2022, 10:14 AM
olegshyshkov requested review of this revision.Nov 8 2022, 10:14 AM
pifon2a accepted this revision.Nov 9 2022, 3:21 AM

Nice!

This revision is now accepted and ready to land.Nov 9 2022, 3:21 AM

Was traveling last week and missed this, thanks @olegshyshkov nice stuff!

mehdi_amini added inline comments.Apr 24 2023, 11:31 PM
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
776

What's up with the progress on this?

mehdi_amini added inline comments.May 5 2023, 5:02 PM
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
776

Ping here @olegshyshkov ?

olegshyshkov added inline comments.May 6 2023, 12:50 AM
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
776

C++ side of things is done (attributes are now enums, not strings), but there are no current plans to change the print format. Mostly because even smaller changes to linalg.generic format were blocked as too much churn.

I'll prepare a patch to remove the TODO.