diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml b/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml @@ -7,6 +7,8 @@ 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: - ! 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 --- 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 @@ std::string name; std::string cppOpName; Optional doc; + SmallVector implements; }; struct SerializedAffineMap { @@ -197,6 +198,7 @@ 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 @@ // Op definition for {0} //===----------------------------------------------------------------------===// -def {0} : LinalgStructuredBase_Op<"{1}", [ +def {0} : LinalgStructuredBase_Op<"{1}", !listconcat([ AttrSizedOperandSegments, DeclareOpInterfaceMethods, - SingleBlockImplicitTerminator<"YieldOp"> - /*extraInterfaces=*/{2}]> { + SingleBlockImplicitTerminator<"YieldOp">], + /*extraInterfaces=*/[{2}])> { {3} let arguments = (ins Variadic:$inputs, @@ -528,6 +530,8 @@ 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,