[mlir][Linalg] Introduce a ContractionOpInterface
authorNicolas Vasilache <nicolas.vasilache@gmail.com>
Thu, 4 Feb 2021 16:49:09 +0000 (16:49 +0000)
committerNicolas Vasilache <nicolas.vasilache@gmail.com>
Thu, 4 Feb 2021 16:53:24 +0000 (16:53 +0000)
commite4a503a26d55bbb9c6589ceb7371ebad04b8a55e
tree9afd0cc5c58b56689d711742ee8b36f76643d671
parent727bd89b605b39659c793f338ce1e18dafc3581e
[mlir][Linalg] Introduce a ContractionOpInterface

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.

Differential revision: https://reviews.llvm.org/D95973
mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.h
mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOpsSpec.tc
mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h
mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp
mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
mlir/test/lib/Transforms/TestLinalgCodegenStrategy.cpp
mlir/test/lib/Transforms/TestLinalgTransforms.cpp
mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp