[mlir] Fix DenseElementsAttr::mapValues(i1, splat).
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(). [1]: https://github.com/llvm/llvm-project/blob/e877b42e2c70813352c1963ea33e992f481d5cba/mlir/lib/IR/BuiltinAttributes.cpp#L984 Reviewed By: rriddle Differential Revision: https://reviews.llvm.org/D132767
Loading
Please sign in to comment