[Mlir-commits] [mlir] 5867c18 - [mlir][linalg] Generate additional interfaces for named ops.
Stella Laurenzo
llvmlistbot at llvm.org
Sat Feb 27 15:46:45 PST 2021
Author: Stella Laurenzo
Date: 2021-02-27T15:43:41-08:00
New Revision: 5867c18e2c0d403b51a594897d56d935286748e4
URL: https://github.com/llvm/llvm-project/commit/5867c18e2c0d403b51a594897d56d935286748e4
DIFF: https://github.com/llvm/llvm-project/commit/5867c18e2c0d403b51a594897d56d935286748e4.diff
LOG: [mlir][linalg] Generate additional interfaces for named ops.
* Adds ContractionOpInterface to polymorphic_matmul.
Differential Revision: https://reviews.llvm.org/D97601
Added:
Modified:
mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml
mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml b/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml
index 02f08145da92..43e41ab68fd2 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml
@@ -7,6 +7,8 @@ metadata: !LinalgOpMetadata
This op is presently here to test a new path for generation and will replace
the existing 'matmul' op when ready. Do not use.
+ implements:
+ - LinalgContractionOpInterface
structured_op: !LinalgStructuredOpConfig
args:
- !<LinalgTensorDef>
diff --git a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp
index 5925e5557459..f651b03e72fd 100644
--- a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp
+++ b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp
@@ -53,6 +53,7 @@ struct LinalgOpMetadata {
std::string name;
std::string cppOpName;
Optional<std::string> doc;
+ SmallVector<std::string> implements;
};
struct SerializedAffineMap {
@@ -197,6 +198,7 @@ struct MappingTraits<LinalgOpMetadata> {
io.mapRequired("name", info.name);
io.mapRequired("cpp_op_name", info.cppOpName);
io.mapOptional("doc", info.doc);
+ io.mapOptional("implements", info.implements);
}
};
@@ -387,11 +389,11 @@ static const char structuredOpOdsHeaderFormat[] = R"FMT(
// Op definition for {0}
//===----------------------------------------------------------------------===//
-def {0} : LinalgStructuredBase_Op<"{1}", [
+def {0} : LinalgStructuredBase_Op<"{1}", !listconcat([
AttrSizedOperandSegments,
DeclareOpInterfaceMethods<MemoryEffectsOpInterface>,
- SingleBlockImplicitTerminator<"YieldOp">
- /*extraInterfaces=*/{2}]> {
+ SingleBlockImplicitTerminator<"YieldOp">],
+ /*extraInterfaces=*/[{2}])> {
{3}
let arguments = (ins
Variadic<AnyShaped>:$inputs,
@@ -528,6 +530,8 @@ static LogicalResult generateNamedGenericOpOds(LinalgOpConfig &opConfig,
doc = llvm::formatv(docFmt, summary.trim(), description.trim());
}
+ interfaceNameList = interleaveToString(opConfig.metadata->implements, ", ");
+
os << llvm::formatv(structuredOpOdsHeaderFormat, opConfig.metadata->cppOpName,
opConfig.metadata->name, interfaceNameList, doc, attrList,
opConfig.structuredOp->args.size(), attrBuilder,
More information about the Mlir-commits
mailing list