[all-commits] [llvm/llvm-project] ae60a4: [mlir] Fix DenseElementsAttr::mapValues(i1, splat).
Chenguang Wang via All-commits
all-commits at lists.llvm.org
Tue Sep 6 12:34:52 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: ae60a4a0efff337425638d04005b33a73dc5792f
https://github.com/llvm/llvm-project/commit/ae60a4a0efff337425638d04005b33a73dc5792f
Author: Chenguang Wang <w3cing at gmail.com>
Date: 2022-09-06 (Tue, 06 Sep 2022)
Changed paths:
M mlir/lib/IR/BuiltinAttributes.cpp
M mlir/unittests/IR/AttributeTest.cpp
Log Message:
-----------
[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
More information about the All-commits
mailing list