This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Linalg] Introduce a ContractionOpInterface
ClosedPublic

Authored by nicolasvasilache on Feb 3 2021, 1:32 PM.

Details

Summary

This revision takes advantage of recent extensions to vectorization to refactor contraction detection into a bona fide Linalg interface.
The mlit-linalg-ods-gen parser is extended to support adding such interfaces.
The detection that was originally enabling vectorization is refactored to serve as both a test on a generic LinalgOp as well as to verify ops that declare to conform to that interface.

This is plugged through Linalg transforms and strategies but it quickly becomes evident that the complexity and rigidity of the C++ class based templating does not pay for itself.
Therefore, this revision changes the API for vectorization patterns to get rid of templates as much as possible.
Variadic templates are relegated to the internals of LinalgTransformationFilter as much as possible and away from the user-facing APIs.

It is expected other patterns / transformations will follow the same path and drop as much C++ templating as possible from the class definition.

Diff Detail

Event Timeline

nicolasvasilache requested review of this revision.Feb 3 2021, 1:32 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 3 2021, 1:32 PM
ftynse accepted this revision.Feb 4 2021, 1:45 AM
ftynse added inline comments.
mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp
45

Nit: I'd initialize this to nullptr to make the intent clear.

64

Nit: expand the type

101

This may return "wrong num operands" if the op just isn't a linalg op. Sounds a bit misleading to be.

This revision is now accepted and ready to land.Feb 4 2021, 1:45 AM
nicolasvasilache marked 2 inline comments as done.

Address review and add variadic helper interface.

nicolasvasilache marked an inline comment as done.Feb 4 2021, 8:54 AM
This revision was landed with ongoing or failed builds.Feb 4 2021, 9:03 AM
This revision was automatically updated to reflect the committed changes.