未验证 提交 c8cc0945 编写于 作者: F Feiyu Chan 提交者: GitHub

add template specialization for bfloat16 for gcc 4.8 compatability (#26985)

上级 3a2a7116
...@@ -207,6 +207,21 @@ void CheckNanInf<paddle::platform::float16>( ...@@ -207,6 +207,21 @@ void CheckNanInf<paddle::platform::float16>(
PrintNanInf(value, numel, print_num, op_type, var_name); PrintNanInf(value, numel, print_num, op_type, var_name);
} }
} }
template <>
void CheckNanInf<paddle::platform::bfloat16>(
const paddle::platform::bfloat16* value, const size_t numel, int print_num,
const std::string& op_type, const std::string& var_name) {
float sum = 0.0f;
#pragma omp parallel for reduction(+ : sum)
for (size_t i = 0; i < numel; ++i) {
sum += static_cast<float>(value[i] - value[i]);
}
if (std::isnan(sum) || std::isinf(sum)) {
PrintNanInf(value, numel, print_num, op_type, var_name);
}
}
#endif #endif
template <> template <>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册