[Mlir-commits] [mlir] [mlirbc] Serialize dense elements attr i1 using packed (PR #182233)
Matthias Springer
llvmlistbot at llvm.org
Thu Feb 19 00:17:42 PST 2026
================
@@ -148,6 +148,64 @@ static void writeFileLineColRangeLocs(DialectBytecodeWriter &writer,
writer.writeVarInt(range.getEndColumn());
}
+static LogicalResult
+readDenseIntOrFPElementsAttr(DialectBytecodeReader &reader, ShapedType type,
+ SmallVectorImpl<char> &rawData) {
+ ArrayRef<char> blob;
+ if (failed(reader.readBlob(blob)))
+ return failure();
+
+ // If the type is not i1, just copy the blob.
+ if (!type.getElementType().isInteger(1)) {
+ rawData.append(blob.begin(), blob.end());
+ return success();
+ }
+
+ // Check to see if this is using the packed format.
+ size_t numElements = type.getNumElements();
+ size_t packedSize = llvm::divideCeil(numElements, 8);
+ if (blob.size() == packedSize && blob.size() != numElements &&
+ blob.size() != 1) {
+ // Unpack the blob.
+ rawData.resize(numElements);
----------------
matthias-springer wrote:
Should this be `rawData.resize(rawData.size() + numElements)` or is the vector guaranteed to be empty?
https://github.com/llvm/llvm-project/pull/182233
More information about the Mlir-commits
mailing list