[mlir][Linalg] Properly specify Linalg attribute.
authorNicolas Vasilache <nicolas.vasilache@gmail.com>
Tue, 13 Jul 2021 15:32:40 +0000 (15:32 +0000)
committerNicolas Vasilache <nicolas.vasilache@gmail.com>
Tue, 13 Jul 2021 16:33:33 +0000 (16:33 +0000)
This fixes undefined reference introduced by https://reviews.llvm.org/D105859

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

mlir/include/mlir/Dialect/Linalg/IR/LinalgBase.td
mlir/lib/Dialect/Linalg/IR/LinalgTypes.cpp

index ce36323dbb28a4077d10763e2b1cb6dfd359b4fe..50028929291a03f0a93f5a3315cbafc6565bfb2f 100644 (file)
@@ -49,7 +49,7 @@ def Linalg_Dialect : Dialect {
       kInplaceableAttrName = "linalg.inplaceable";
 
     /// Attribute name used to mark the bufferization layout for region
-    // arguments during linalg comprehensive bufferization.
+    /// arguments during linalg comprehensive bufferization.
     constexpr const static ::llvm::StringLiteral
       kBufferLayoutAttrName = "linalg.buffer_layout";
 
index 047e1e9a62be5874eefc54e7a50a628154ef1d98..0cc170ebeb8233413613683074b17ef6a757467c 100644 (file)
@@ -62,6 +62,10 @@ struct LinalgInlinerInterface : public DialectInlinerInterface {
 constexpr const ::llvm::StringLiteral
     LinalgDialect::kMemoizedIndexingMapsAttrName;
 
+/// Attribute name used to mark the bufferization layout for region
+/// arguments during linalg comprehensive bufferization.
+constexpr const ::llvm::StringLiteral LinalgDialect::kBufferLayoutAttrName;
+
 /// Attribute name used to mark region arguments that can be bufferized
 /// in-place during linalg comprehensive bufferization.
 constexpr const ::llvm::StringLiteral LinalgDialect::kInplaceableAttrName;
@@ -153,6 +157,16 @@ LogicalResult LinalgDialect::verifyOperationAttribute(Operation *op,
                              << " to be used on function-like operations";
     return success();
   }
+  if (attr.first == LinalgDialect::kBufferLayoutAttrName) {
+    if (!attr.second.isa<AffineMapAttr>()) {
+      return op->emitError() << "'" << LinalgDialect::kBufferLayoutAttrName
+                             << "' is expected to be a affine map attribute";
+    }
+    if (!op->hasTrait<OpTrait::FunctionLike>())
+      return op->emitError() << "expected " << attr.first
+                             << " to be used on function-like operations";
+    return success();
+  }
   if (attr.first == LinalgDialect::kMemoizedIndexingMapsAttrName)
     return success();
   return op->emitError() << "attribute '" << attr.first