diff --git a/paddle/phi/common/scalar.h b/paddle/phi/common/scalar.h index 4286dfcc1d0fac21ab138ea023dd98fb1d401aff..e8d789fc1494488ec72084da93162e89338b5028 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