提交 64bf3df0 编写于 作者: K Kexin Zhao 提交者: gongweibao

add print support to float16 (#9960)

上级 58335468
...@@ -873,6 +873,11 @@ HOSTDEVICE inline bool(isfinite)(const float16& a) { ...@@ -873,6 +873,11 @@ HOSTDEVICE inline bool(isfinite)(const float16& a) {
return !((isnan)(a)) && !((isinf)(a)); return !((isnan)(a)) && !((isinf)(a));
} }
inline std::ostream& operator<<(std::ostream& os, const float16& a) {
os << static_cast<float>(a);
return os;
}
} // namespace platform } // namespace platform
} // namespace paddle } // namespace paddle
......
...@@ -141,5 +141,10 @@ TEST(float16, lod_tensor_cpu) { ...@@ -141,5 +141,10 @@ TEST(float16, lod_tensor_cpu) {
} }
} }
TEST(float16, print) {
float16 a = float16(1.0f);
std::cout << a << std::endl;
}
} // namespace platform } // namespace platform
} // namespace paddle } // namespace paddle
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册