Skip to content

Commit

Permalink
refine and add nan test for f32/f64
Browse files Browse the repository at this point in the history
  • Loading branch information
zekai.zhou committed Feb 12, 2025
1 parent 264f5f1 commit 5715850
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions test_conformance/basic/test_fpmath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,19 @@ int verify_fp(std::vector<T> (&input)[2], std::vector<T> &output,
auto &inB = input[1];
for (size_t i = 0; i < output.size(); i++)
{
bool nan_test = true;

T r = test.ref(inA[i], inB[i]);
bool both_nan = false;

if (std::is_same<T, cl_half>::value)
nan_test = (isHalfNan(r) != isHalfNan(output[i]));
{
both_nan = isHalfNan(r) && isHalfNan(output[i]);
}
else if (std::is_floating_point<T>::value)
{
both_nan = std::isnan(r) && std::isnan(output[i]);
}

if (r != output[i] && !nan_test)
if (!both_nan && (r != output[i]))
{
log_error("FP math test for type: %s, vec size: %zu, failed at "
"index %zu, %a '%c' %a, expected %a, get %a\n",
Expand Down

0 comments on commit 5715850

Please sign in to comment.