From 4898665cb1f30bc4a04c3167961128788421949d Mon Sep 17 00:00:00 2001 From: Ruibin Cheung Date: Wed, 9 Aug 2023 11:29:36 +0800 Subject: [PATCH] fix: support str_value of Scalar is bool (#56068) --- paddle/phi/common/scalar.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/paddle/phi/common/scalar.h b/paddle/phi/common/scalar.h index 4286dfcc1d0..e8d789fc149 100644 --- a/paddle/phi/common/scalar.h +++ b/paddle/phi/common/scalar.h @@ -110,6 +110,12 @@ class ScalarBase { data_.f64 = -std::numeric_limits::infinity(); } else if (str_value == "nan") { data_.f64 = std::numeric_limits::quiet_NaN(); + } else if (str_value == "True") { + dtype_ = DataType::BOOL; + data_.b = true; + } else if (str_value == "Fasle") { + dtype_ = DataType::BOOL; + data_.b = false; } else { // NOTE(chenfeiyu): to support subnormal floating point number // std::stod cannot handle subnormal values -- GitLab