Splat of bool is encoded as a byte with all-ones in it [1]. Without this
change, this piece of code:
auto xs = builder.getI32TensorAttr({42, 42, 42, 42}); auto xs2 = xs.mapValues(builder.getI1Type(), [](const llvm::APInt &x) { return x.isZero() ? llvm::APInt::getZero(1) : llvm::APInt::getAllOnes(1); }); xs2.dump();
Prints:
dense<[true, false, false, false]> : tensor<4xi1>
Because only the first bit is set. This applies to both
DenseIntElementsAttr::mapValues() and DenseFPElementsAttr::mapValues().
This could likely be applied within the if (attr.isSplat()) { branch below, after the call to processElt; i.e. you could call and then check the result, fixing if necessary.