diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgBase.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgBase.td --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgBase.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgBase.td @@ -49,7 +49,7 @@ 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"; diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgTypes.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgTypes.cpp --- a/mlir/lib/Dialect/Linalg/IR/LinalgTypes.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgTypes.cpp @@ -62,6 +62,10 @@ 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 @@ << " to be used on function-like operations"; return success(); } + if (attr.first == LinalgDialect::kBufferLayoutAttrName) { + if (!attr.second.isa()) { + return op->emitError() << "'" << LinalgDialect::kBufferLayoutAttrName + << "' is expected to be a affine map attribute"; + } + if (!op->hasTrait()) + 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