diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp index e86e2a783f50..bb17b3e00de8 100644 --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -718,7 +718,10 @@ void ModulePrinter::printAttribute(Attribute attr, bool mayElideType) { static void printDenseIntElement(DenseElementsAttr attr, raw_ostream &os, unsigned index) { APInt value = *std::next(attr.getIntValues().begin(), index); - value.print(os, /*isSigned=*/value.getBitWidth() != 1); + if (value.getBitWidth() == 1) + os << (value.getBoolValue() ? "true" : "false"); + else + value.print(os, /*isSigned=*/true); } /// Print the float element of the given DenseElementsAttr at 'index'. diff --git a/mlir/test/IR/parser.mlir b/mlir/test/IR/parser.mlir index 5c13364addfd..6f0ad0671e1f 100644 --- a/mlir/test/IR/parser.mlir +++ b/mlir/test/IR/parser.mlir @@ -593,7 +593,7 @@ func @funcsimplemap(%arg0: index, %arg1: index) -> () { // CHECK-LABEL: func @splattensorattr func @splattensorattr() -> () { ^bb0: - // CHECK: "splatBoolTensor"() {bar = dense<0> : tensor} : () -> () + // CHECK: "splatBoolTensor"() {bar = dense : tensor} : () -> () "splatBoolTensor"(){bar = dense : tensor} : () -> () // CHECK: "splatIntTensor"() {bar = dense<5> : tensor<2x1x4xi32>} : () -> ()