[mlir][linalg] Remove GenericOpBase.
authorTobias Gysi <gysit@google.com>
Thu, 8 Jul 2021 07:02:15 +0000 (07:02 +0000)
committerTobias Gysi <gysit@google.com>
Thu, 8 Jul 2021 08:35:28 +0000 (08:35 +0000)
Remove the GenericOpBase class formerly used to factor out common logic shared be GenericOp and IndexedGenericOp. After removing IndexedGenericOp, the base class is not used anymore.

Differential Revision: https://reviews.llvm.org/D105307

mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td

index 18f5bee..fa17237 100644 (file)
@@ -503,41 +503,10 @@ def PoolingSumOp: SingleInputPoolingBase_Op<"pooling_sum"> {
 // Generic Linalg ops.
 //===----------------------------------------------------------------------===//
 
-class GenericOpBase<string mnemonic> : LinalgStructuredBase_Op<mnemonic, [
+def GenericOp : LinalgStructuredBase_Op<"generic", [
     AttrSizedOperandSegments,
     DeclareOpInterfaceMethods<MemoryEffectsOpInterface>,
     SingleBlockImplicitTerminator<"YieldOp">]> {
-  let arguments = (ins Variadic<AnyType>:$inputs,
-                       Variadic<AnyShaped>:$outputs,
-                       AffineMapArrayAttr:$indexing_maps,
-                       ArrayAttr:$iterator_types,
-                       OptionalAttr<StrAttr>:$doc,
-                       OptionalAttr<StrAttr>:$library_call);
-  let results = (outs Variadic<AnyRankedTensor>:$result_tensors);
-  let regions = (region AnyRegion:$region);
-  let extraClassDeclaration = structuredOpsBaseDecls # [{
-    SmallVector<StringRef, 8> linalgTraitAttrNames() {
-      return SmallVector<StringRef, 8>{
-        getDocAttrName(),
-        getIndexingMapsAttrName(), getLibraryCallAttrName(),
-        getIteratorTypesAttrName(),
-      };
-    }
-    std::string getLibraryCallName() {
-      return library_call().hasValue() ?
-        library_call()->str() : "op_has_no_registered_library_name";
-    }
-
-    static std::function<void(ImplicitLocOpBuilder &b, Block &block)>
-    getRegionBuilder() {
-      return nullptr;
-    }
-  }];
-  let printer = [{ return ::print(p, *this); }];
-  let parser = [{ return ::parseGenericOp(parser, result); }];
-}
-
-def GenericOp : GenericOpBase<"generic"> {
   let description = [{
     Generic Linalg op form where the key properties of the computation are
     specified as attributes. In pretty form, a `linalg.generic` op is written
@@ -636,6 +605,15 @@ def GenericOp : GenericOpBase<"generic"> {
     ```
   }];
 
+  let arguments = (ins Variadic<AnyType>:$inputs,
+                       Variadic<AnyShaped>:$outputs,
+                       AffineMapArrayAttr:$indexing_maps,
+                       ArrayAttr:$iterator_types,
+                       OptionalAttr<StrAttr>:$doc,
+                       OptionalAttr<StrAttr>:$library_call);
+  let results = (outs Variadic<AnyRankedTensor>:$result_tensors);
+  let regions = (region AnyRegion:$region);
+
   let builders = [
     OpBuilder<(ins "TypeRange":$resultTensorTypes, "ValueRange":$inputs,
       "ValueRange":$outputs, "ArrayRef<AffineMap>":$indexingMaps,
@@ -654,6 +632,29 @@ def GenericOp : GenericOpBase<"generic"> {
       "ArrayRef<AffineMap>":$indexingMaps, "ArrayRef<StringRef>":$iteratorTypes,
       CArg<"function_ref<void(OpBuilder &, Location, ValueRange)>", "nullptr">)>
   ];
+
+  let extraClassDeclaration = structuredOpsBaseDecls # [{
+    SmallVector<StringRef, 8> linalgTraitAttrNames() {
+      return SmallVector<StringRef, 8>{
+        getDocAttrName(),
+        getIndexingMapsAttrName(), getLibraryCallAttrName(),
+        getIteratorTypesAttrName(),
+      };
+    }
+    std::string getLibraryCallName() {
+      return library_call().hasValue() ?
+        library_call()->str() : "op_has_no_registered_library_name";
+    }
+
+    static std::function<void(ImplicitLocOpBuilder &b, Block &block)>
+    getRegionBuilder() {
+      return nullptr;
+    }
+  }];
+
+  let printer = [{ return ::print(p, *this); }];
+  let parser = [{ return ::parseGenericOp(parser, result); }];
+
   let verifier = [{ return ::verify(*this); }];
 
   let hasFolder = 1;