From 3cce374ee66373488e7b4c3e113cf4e65b20319b Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 12 May 2022 16:17:52 +0100 Subject: [PATCH] Various improvements suggested by river NFC. Differential Revision: https://reviews.llvm.org/D125471 --- mlir/include/mlir/IR/BuiltinAttributes.td | 8 ++++---- mlir/lib/IR/BuiltinAttributes.cpp | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/mlir/include/mlir/IR/BuiltinAttributes.td b/mlir/include/mlir/IR/BuiltinAttributes.td index 19c8a07b94cd7..2fab392088381 100644 --- a/mlir/include/mlir/IR/BuiltinAttributes.td +++ b/mlir/include/mlir/IR/BuiltinAttributes.td @@ -237,7 +237,7 @@ def Builtin_DenseIntOrFPElementsAttr : Builtin_Attr< /// element type of 'type'. 'type' must be a vector or tensor with static /// shape. /// - /// If the `values` array only has a single element, then this constructs + /// If the `values` array only has a single element, then this constructs /// splat of that value. static DenseElementsAttr getRaw(ShapedType type, size_t storageWidth, ArrayRef values); @@ -246,7 +246,7 @@ def Builtin_DenseIntOrFPElementsAttr : Builtin_Attr< /// Each APInt value is expected to have the same bitwidth as the element /// type of 'type'. 'type' must be a vector or tensor with static shape. /// - /// If the `values` array only has a single element, then this constructs + /// If the `values` array only has a single element, then this constructs /// splat of that value. static DenseElementsAttr getRaw(ShapedType type, size_t storageWidth, ArrayRef values); @@ -254,7 +254,7 @@ def Builtin_DenseIntOrFPElementsAttr : Builtin_Attr< /// Get or create a new dense elements attribute instance with the given raw /// data buffer. 'type' must be a vector or tensor with static shape. /// - /// If the `values` array only has a single element, then this constructs + /// If the `values` array only has a single element, then this constructs /// splat of that value. static DenseElementsAttr getRaw(ShapedType type, ArrayRef data); @@ -315,7 +315,7 @@ def Builtin_DenseStringElementsAttr : Builtin_Attr< let builders = [ AttrBuilderWithInferredContext<(ins "ShapedType":$type, "ArrayRef":$values), [{ - return $_get(type.getContext(), type, values, + return $_get(type.getContext(), type, values, /* isSplat */(values.size() == 1)); }]>, ]; diff --git a/mlir/lib/IR/BuiltinAttributes.cpp b/mlir/lib/IR/BuiltinAttributes.cpp index 1ecdf183d9ec2..76bb3a7bf1805 100644 --- a/mlir/lib/IR/BuiltinAttributes.cpp +++ b/mlir/lib/IR/BuiltinAttributes.cpp @@ -736,7 +736,8 @@ DenseElementsAttr DenseElementsAttr::get(ShapedType type, setBit(buff.data(), i, values[i]); } - if (isSplat) { // special encoding for splat. + // Splat of bool is encoded as a byte with all-ones in it. + if (isSplat) { buff.resize(1); buff[0] = values[0] ? -1 : 0; }