Skip to content

[NFC] Rename hasSameElementsOrSplat to hasSameNumElementsOrSplat #133183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions mlir/lib/IR/BuiltinAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ static APInt readBits(const char *rawData, size_t bitPos, size_t bitWidth) {
/// Returns true if 'values' corresponds to a splat, i.e. one element, or has
/// the same element count as 'type'.
template <typename Values>
static bool hasSameElementsOrSplat(ShapedType type, const Values &values) {
static bool hasSameNumElementsOrSplat(ShapedType type, const Values &values) {
return (values.size() == 1) ||
(type.getNumElements() == static_cast<int64_t>(values.size()));
}
Expand Down Expand Up @@ -901,7 +901,7 @@ bool DenseElementsAttr::classof(Attribute attr) {

DenseElementsAttr DenseElementsAttr::get(ShapedType type,
ArrayRef<Attribute> values) {
assert(hasSameElementsOrSplat(type, values));
assert(hasSameNumElementsOrSplat(type, values));

Type eltType = type.getElementType();

Expand Down Expand Up @@ -985,7 +985,7 @@ DenseElementsAttr DenseElementsAttr::get(ShapedType type,

DenseElementsAttr DenseElementsAttr::get(ShapedType type,
ArrayRef<bool> values) {
assert(hasSameElementsOrSplat(type, values));
assert(hasSameNumElementsOrSplat(type, values));
assert(type.getElementType().isInteger(1));

std::vector<char> buff(llvm::divideCeil(values.size(), CHAR_BIT));
Expand Down Expand Up @@ -1020,15 +1020,15 @@ DenseElementsAttr DenseElementsAttr::get(ShapedType type,
DenseElementsAttr DenseElementsAttr::get(ShapedType type,
ArrayRef<APInt> values) {
assert(type.getElementType().isIntOrIndex());
assert(hasSameElementsOrSplat(type, values));
assert(hasSameNumElementsOrSplat(type, values));
size_t storageBitWidth = getDenseElementStorageWidth(type.getElementType());
return DenseIntOrFPElementsAttr::getRaw(type, storageBitWidth, values);
}
DenseElementsAttr DenseElementsAttr::get(ShapedType type,
ArrayRef<std::complex<APInt>> values) {
ComplexType complex = llvm::cast<ComplexType>(type.getElementType());
assert(llvm::isa<IntegerType>(complex.getElementType()));
assert(hasSameElementsOrSplat(type, values));
assert(hasSameNumElementsOrSplat(type, values));
size_t storageBitWidth = getDenseElementStorageWidth(complex) / 2;
ArrayRef<APInt> intVals(reinterpret_cast<const APInt *>(values.data()),
values.size() * 2);
Expand All @@ -1041,7 +1041,7 @@ DenseElementsAttr DenseElementsAttr::get(ShapedType type,
DenseElementsAttr DenseElementsAttr::get(ShapedType type,
ArrayRef<APFloat> values) {
assert(llvm::isa<FloatType>(type.getElementType()));
assert(hasSameElementsOrSplat(type, values));
assert(hasSameNumElementsOrSplat(type, values));
size_t storageBitWidth = getDenseElementStorageWidth(type.getElementType());
return DenseIntOrFPElementsAttr::getRaw(type, storageBitWidth, values);
}
Expand All @@ -1050,7 +1050,7 @@ DenseElementsAttr::get(ShapedType type,
ArrayRef<std::complex<APFloat>> values) {
ComplexType complex = llvm::cast<ComplexType>(type.getElementType());
assert(llvm::isa<FloatType>(complex.getElementType()));
assert(hasSameElementsOrSplat(type, values));
assert(hasSameNumElementsOrSplat(type, values));
ArrayRef<APFloat> apVals(reinterpret_cast<const APFloat *>(values.data()),
values.size() * 2);
size_t storageBitWidth = getDenseElementStorageWidth(complex) / 2;
Expand Down
Loading