[Mlir-commits] [mlir] [mlirbc] Serialize dense elements attr i1 using packed (PR #182233)

Jacques Pienaar llvmlistbot at llvm.org
Thu Feb 19 00:27:51 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);
----------------
jpienaar wrote:

It should be empty yes. Are you wondering if the others should be assign instead too to match?

https://github.com/llvm/llvm-project/pull/182233


More information about the Mlir-commits mailing list