Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mlir][linalg] Cleanup MatmulOp TableGen formatting, NFC #117435

Closed
wants to merge 1 commit into from

Conversation

ubfx
Copy link
Member

@ubfx ubfx commented Nov 23, 2024

This just matches the indentation to the other ops.

@llvmbot
Copy link
Member

llvmbot commented Nov 23, 2024

@llvm/pr-subscribers-mlir

Author: Felix Schneider (ubfx)

Changes

This just matches the indentation to the other ops.


Full diff: https://github.com/llvm/llvm-project/pull/117435.diff

1 Files Affected:

  • (modified) mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td (+76-76)
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
index 37eec6e07963b1..a1b5e7f8197f75 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<AnyType>:$inputs,
-      Variadic<AnyShaped>:$outputs,
-      DefaultValuedOptionalAttr<AffineMapArrayAttr, "{}">:$indexing_maps,
-      DefaultValuedOptionalAttr<TypeFnAttr, "TypeFn::cast_signed">:$cast
-    );
-    let results = (outs Variadic<AnyRankedTensor>:$result_tensors);
-    let regions = (region AnyRegion:$region);
-
-    let skipDefaultBuilders = 1;
-    let builders = [
-      OpBuilder<
-      (ins "ValueRange":$inputs, "ValueRange":$outputs,
-            CArg<"ArrayRef<NamedAttribute>", "{}">:$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<NamedAttribute>", "{}">:$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<NamedAttribute>", "{}">:$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<utils::IteratorType> getIteratorTypesArray();
-
-      /// Implements the block region builder.
-      static void regionBuilder(ImplicitLocOpBuilder &b,
-                                Block &block, ArrayRef<NamedAttribute> attrs);
-
-      /// Returns a list of AffineMap with the typical matmul indexing charactristic.
-      static SmallVector<AffineMap> getDefaultIndexingMaps(MLIRContext *context);
-
-      /// Returns true if the given broadcast map \p bcastMap is valid for this op.
-      bool isValidLhsRhsBroadcastMap(AffineMap bcastMap);
-
-      static std::function<void(ImplicitLocOpBuilder &,
-                                Block &, ArrayRef<NamedAttribute>)>
-      getRegionBuilder() {
-        return regionBuilder;
-      }
+  }];
 
-      ::mlir::MutableOperandRange getDpsInitsMutable() {
-        return getOutputsMutable();
-      }
+  let arguments = (ins
+    Variadic<AnyType>:$inputs,
+    Variadic<AnyShaped>:$outputs,
+    DefaultValuedOptionalAttr<AffineMapArrayAttr, "{}">:$indexing_maps,
+    DefaultValuedOptionalAttr<TypeFnAttr, "TypeFn::cast_signed">:$cast
+  );
+  let results = (outs Variadic<AnyRankedTensor>:$result_tensors);
+  let regions = (region AnyRegion:$region);
+
+  let skipDefaultBuilders = 1;
+  let builders = [
+    OpBuilder<
+    (ins "ValueRange":$inputs, "ValueRange":$outputs,
+          CArg<"ArrayRef<NamedAttribute>", "{}">:$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<NamedAttribute>", "{}">:$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<NamedAttribute>", "{}">:$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<utils::IteratorType> getIteratorTypesArray();
+
+    /// Implements the block region builder.
+    static void regionBuilder(ImplicitLocOpBuilder &b,
+                              Block &block, ArrayRef<NamedAttribute> attrs);
+
+    /// Returns a list of AffineMap with the typical matmul indexing characteristic.
+    static SmallVector<AffineMap> getDefaultIndexingMaps(MLIRContext *context);
+
+    /// Returns true if the given broadcast map \p bcastMap is valid for this op.
+    bool isValidLhsRhsBroadcastMap(AffineMap bcastMap);
+
+    static std::function<void(ImplicitLocOpBuilder &,
+                              Block &, ArrayRef<NamedAttribute>)>
+    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();
+  }];
 }
 
 //===----------------------------------------------------------------------===//

@llvmbot
Copy link
Member

llvmbot commented Nov 23, 2024

@llvm/pr-subscribers-mlir-linalg

Author: Felix Schneider (ubfx)

Changes

This just matches the indentation to the other ops.


Full diff: https://github.com/llvm/llvm-project/pull/117435.diff

1 Files Affected:

  • (modified) mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td (+76-76)
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
index 37eec6e07963b1..a1b5e7f8197f75 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<AnyType>:$inputs,
-      Variadic<AnyShaped>:$outputs,
-      DefaultValuedOptionalAttr<AffineMapArrayAttr, "{}">:$indexing_maps,
-      DefaultValuedOptionalAttr<TypeFnAttr, "TypeFn::cast_signed">:$cast
-    );
-    let results = (outs Variadic<AnyRankedTensor>:$result_tensors);
-    let regions = (region AnyRegion:$region);
-
-    let skipDefaultBuilders = 1;
-    let builders = [
-      OpBuilder<
-      (ins "ValueRange":$inputs, "ValueRange":$outputs,
-            CArg<"ArrayRef<NamedAttribute>", "{}">:$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<NamedAttribute>", "{}">:$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<NamedAttribute>", "{}">:$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<utils::IteratorType> getIteratorTypesArray();
-
-      /// Implements the block region builder.
-      static void regionBuilder(ImplicitLocOpBuilder &b,
-                                Block &block, ArrayRef<NamedAttribute> attrs);
-
-      /// Returns a list of AffineMap with the typical matmul indexing charactristic.
-      static SmallVector<AffineMap> getDefaultIndexingMaps(MLIRContext *context);
-
-      /// Returns true if the given broadcast map \p bcastMap is valid for this op.
-      bool isValidLhsRhsBroadcastMap(AffineMap bcastMap);
-
-      static std::function<void(ImplicitLocOpBuilder &,
-                                Block &, ArrayRef<NamedAttribute>)>
-      getRegionBuilder() {
-        return regionBuilder;
-      }
+  }];
 
-      ::mlir::MutableOperandRange getDpsInitsMutable() {
-        return getOutputsMutable();
-      }
+  let arguments = (ins
+    Variadic<AnyType>:$inputs,
+    Variadic<AnyShaped>:$outputs,
+    DefaultValuedOptionalAttr<AffineMapArrayAttr, "{}">:$indexing_maps,
+    DefaultValuedOptionalAttr<TypeFnAttr, "TypeFn::cast_signed">:$cast
+  );
+  let results = (outs Variadic<AnyRankedTensor>:$result_tensors);
+  let regions = (region AnyRegion:$region);
+
+  let skipDefaultBuilders = 1;
+  let builders = [
+    OpBuilder<
+    (ins "ValueRange":$inputs, "ValueRange":$outputs,
+          CArg<"ArrayRef<NamedAttribute>", "{}">:$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<NamedAttribute>", "{}">:$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<NamedAttribute>", "{}">:$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<utils::IteratorType> getIteratorTypesArray();
+
+    /// Implements the block region builder.
+    static void regionBuilder(ImplicitLocOpBuilder &b,
+                              Block &block, ArrayRef<NamedAttribute> attrs);
+
+    /// Returns a list of AffineMap with the typical matmul indexing characteristic.
+    static SmallVector<AffineMap> getDefaultIndexingMaps(MLIRContext *context);
+
+    /// Returns true if the given broadcast map \p bcastMap is valid for this op.
+    bool isValidLhsRhsBroadcastMap(AffineMap bcastMap);
+
+    static std::function<void(ImplicitLocOpBuilder &,
+                              Block &, ArrayRef<NamedAttribute>)>
+    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();
+  }];
 }
 
 //===----------------------------------------------------------------------===//

@rengolin
Copy link
Member

is this really necessary? We don't have layout convention for table-gen, and this causes git blame history churn for no reason.

@ubfx ubfx closed this Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants