Add explicit support for bfloat16 in tensorflow/core/platform/strcat.h
PiperOrigin-RevId: 326729760 Change-Id: I36f681b20f91f3c08f4c5b795e488f90d17194aa
This commit is contained in:
parent
63dbe41c4c
commit
dab490a8bf
tensorflow/core/platform
@ -117,6 +117,8 @@ class AlphaNum {
|
||||
: piece_(digits_, FloatToBuffer(f, digits_)) {}
|
||||
AlphaNum(double f) // NOLINT(runtime/explicit)
|
||||
: piece_(digits_, DoubleToBuffer(f, digits_)) {}
|
||||
AlphaNum(bfloat16 bf) // NOLINT(runtime/explicit)
|
||||
: piece_(digits_, FloatToBuffer(static_cast<float>(bf), digits_)) {}
|
||||
|
||||
AlphaNum(Hex hex); // NOLINT(runtime/explicit)
|
||||
|
||||
|
@ -61,6 +61,21 @@ TEST(StrCat, Ints) {
|
||||
EXPECT_EQ(answer, "130");
|
||||
}
|
||||
|
||||
TEST(StrCat, Floats) {
|
||||
const int s = 0;
|
||||
const float f = 1.5f;
|
||||
const double d = 1.5;
|
||||
const bfloat16 bf(1.5f);
|
||||
|
||||
string answer;
|
||||
answer = tensorflow::strings::StrCat(s, f);
|
||||
EXPECT_EQ(answer, "01.5");
|
||||
answer = tensorflow::strings::StrCat(s, d);
|
||||
EXPECT_EQ(answer, "01.5");
|
||||
answer = tensorflow::strings::StrCat(s, bf);
|
||||
EXPECT_EQ(answer, "01.5");
|
||||
}
|
||||
|
||||
TEST(StrCat, Basics) {
|
||||
string result;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user