diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td index 37eec6e07963b..a1b5e7f8197f7 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td @@ -564,7 +564,7 @@ def MatmulOp : LinalgStructuredBase_Op<"matmul", [ let summary = [{ Performs a matrix multiplication of two 2D inputs without broadcast or transpose. - }]; + }]; let description = [{ Numeric casting is performed on the operands to the inner multiply, promoting them to the same data type as the accumulator/output. @@ -604,83 +604,83 @@ def MatmulOp : LinalgStructuredBase_Op<"matmul", [ ] ins(%arg0, %arg1 : memref<5x3xf32>, memref<7xf32>) outs(%arg2: memref<3x7xf32>) ``` - }]; - - let arguments = (ins - Variadic:$inputs, - Variadic:$outputs, - DefaultValuedOptionalAttr:$indexing_maps, - DefaultValuedOptionalAttr:$cast - ); - let results = (outs Variadic:$result_tensors); - let regions = (region AnyRegion:$region); - - let skipDefaultBuilders = 1; - let builders = [ - OpBuilder< - (ins "ValueRange":$inputs, "ValueRange":$outputs, - CArg<"ArrayRef", "{}">:$attributes), - [{ - buildMatmulOp($_builder, $_state, std::nullopt, inputs, outputs, - attributes, MatmulOp::getRegionBuilder(), - MatmulOp::getDefaultIndexingMaps($_builder.getContext())); - }]>, - OpBuilder< - (ins "TypeRange":$resultTensorTypes, "ValueRange":$inputs, - "ValueRange":$outputs, - CArg<"ArrayRef", "{}">:$attributes), - [{ - buildMatmulOp($_builder, $_state, resultTensorTypes, - inputs, outputs, attributes, MatmulOp::getRegionBuilder(), - MatmulOp::getDefaultIndexingMaps($_builder.getContext())); - }]>, - OpBuilder< - (ins "TypeRange":$resultTensorTypes, "ValueRange":$inputs, - "ValueRange":$outputs, - "Attribute":$cast, CArg<"ArrayRef", "{}">:$attributes), - [{ - $_state.addAttribute("cast", cast); - buildMatmulOp($_builder, $_state, resultTensorTypes, inputs, outputs, - attributes, MatmulOp::getRegionBuilder(), - MatmulOp::getDefaultIndexingMaps($_builder.getContext())); - }]> - - ]; - let hasCustomAssemblyFormat = 1; - let hasFolder = 1; - let hasVerifier = 1; - - let extraClassDeclaration = structuredOpsBaseDecls # [{ - SmallVector getIteratorTypesArray(); - - /// Implements the block region builder. - static void regionBuilder(ImplicitLocOpBuilder &b, - Block &block, ArrayRef attrs); - - /// Returns a list of AffineMap with the typical matmul indexing charactristic. - static SmallVector getDefaultIndexingMaps(MLIRContext *context); - - /// Returns true if the given broadcast map \p bcastMap is valid for this op. - bool isValidLhsRhsBroadcastMap(AffineMap bcastMap); - - static std::function)> - getRegionBuilder() { - return regionBuilder; - } + }]; - ::mlir::MutableOperandRange getDpsInitsMutable() { - return getOutputsMutable(); - } + let arguments = (ins + Variadic:$inputs, + Variadic:$outputs, + DefaultValuedOptionalAttr:$indexing_maps, + DefaultValuedOptionalAttr:$cast + ); + let results = (outs Variadic:$result_tensors); + let regions = (region AnyRegion:$region); + + let skipDefaultBuilders = 1; + let builders = [ + OpBuilder< + (ins "ValueRange":$inputs, "ValueRange":$outputs, + CArg<"ArrayRef", "{}">:$attributes), + [{ + buildMatmulOp($_builder, $_state, std::nullopt, inputs, outputs, + attributes, MatmulOp::getRegionBuilder(), + MatmulOp::getDefaultIndexingMaps($_builder.getContext())); + }]>, + OpBuilder< + (ins "TypeRange":$resultTensorTypes, "ValueRange":$inputs, + "ValueRange":$outputs, + CArg<"ArrayRef", "{}">:$attributes), + [{ + buildMatmulOp($_builder, $_state, resultTensorTypes, + inputs, outputs, attributes, MatmulOp::getRegionBuilder(), + MatmulOp::getDefaultIndexingMaps($_builder.getContext())); + }]>, + OpBuilder< + (ins "TypeRange":$resultTensorTypes, "ValueRange":$inputs, + "ValueRange":$outputs, + "Attribute":$cast, CArg<"ArrayRef", "{}">:$attributes), + [{ + $_state.addAttribute("cast", cast); + buildMatmulOp($_builder, $_state, resultTensorTypes, inputs, outputs, + attributes, MatmulOp::getRegionBuilder(), + MatmulOp::getDefaultIndexingMaps($_builder.getContext())); + }]> + + ]; + let hasCustomAssemblyFormat = 1; + let hasFolder = 1; + let hasVerifier = 1; + + let extraClassDeclaration = structuredOpsBaseDecls # [{ + SmallVector getIteratorTypesArray(); + + /// Implements the block region builder. + static void regionBuilder(ImplicitLocOpBuilder &b, + Block &block, ArrayRef attrs); + + /// Returns a list of AffineMap with the typical matmul indexing characteristic. + static SmallVector getDefaultIndexingMaps(MLIRContext *context); + + /// Returns true if the given broadcast map \p bcastMap is valid for this op. + bool isValidLhsRhsBroadcastMap(AffineMap bcastMap); + + static std::function)> + getRegionBuilder() { + return regionBuilder; + } + + ::mlir::MutableOperandRange getDpsInitsMutable() { + return getOutputsMutable(); + } - // Generic methods. - static unsigned getNumRegionArgs(); - std::string getLibraryCallName(); - bool hasDynamicIndexingMaps(); - /// Check if the op has broadcast and/or transpose semantic. Returns true if the - /// user defined indexing maps are not equal to default map. - bool hasUserDefinedMaps(); - }]; + // Generic methods. + static unsigned getNumRegionArgs(); + std::string getLibraryCallName(); + bool hasDynamicIndexingMaps(); + /// Check if the op has broadcast and/or transpose semantic. Returns true if the + /// user defined indexing maps are not equal to default map. + bool hasUserDefinedMaps(); + }]; } //===----------------------------------------------------------------------===//