Skip to content

Commit

Permalink
Various improvements suggested by river NFC.
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D125471
  • Loading branch information
lattner committed May 12, 2022
1 parent f21896f commit 3cce374
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions mlir/include/mlir/IR/BuiltinAttributes.td
Expand Up @@ -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<APFloat> values);
Expand All @@ -246,15 +246,15 @@ 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<APInt> values);

/// 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<char> data);

Expand Down Expand Up @@ -315,7 +315,7 @@ def Builtin_DenseStringElementsAttr : Builtin_Attr<
let builders = [
AttrBuilderWithInferredContext<(ins "ShapedType":$type,
"ArrayRef<StringRef>":$values), [{
return $_get(type.getContext(), type, values,
return $_get(type.getContext(), type, values,
/* isSplat */(values.size() == 1));
}]>,
];
Expand Down
3 changes: 2 additions & 1 deletion mlir/lib/IR/BuiltinAttributes.cpp
Expand Up @@ -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;
}
Expand Down

0 comments on commit 3cce374

Please sign in to comment.