diff --git a/mlir/include/mlir/IR/BuiltinAttributes.td b/mlir/include/mlir/IR/BuiltinAttributes.td --- a/mlir/include/mlir/IR/BuiltinAttributes.td +++ b/mlir/include/mlir/IR/BuiltinAttributes.td @@ -237,7 +237,7 @@ /// 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 @@ /// 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 @@ /// 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 @@ 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 --- a/mlir/lib/IR/BuiltinAttributes.cpp +++ b/mlir/lib/IR/BuiltinAttributes.cpp @@ -736,7 +736,8 @@ 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; }