From bdd0eb0b7ee4ff12e0122ea2215553ba0342ce3b Mon Sep 17 00:00:00 2001 From: zzk0 <30856589+zzk0@users.noreply.github.com> Date: Wed, 19 Feb 2025 12:51:19 +0800 Subject: [PATCH] bugfix nan test for basic fpmath (#2268) This PR fixes the validation logic for cases where the data type is not half. Because the variable nan_test is always false, types like float never trigger a validation failure. --- test_conformance/basic/test_fpmath.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test_conformance/basic/test_fpmath.cpp b/test_conformance/basic/test_fpmath.cpp index 77247bba..fc7b9108 100644 --- a/test_conformance/basic/test_fpmath.cpp +++ b/test_conformance/basic/test_fpmath.cpp @@ -98,14 +98,20 @@ int verify_fp(std::vector (&input)[2], std::vector &output, auto &inB = input[1]; for (size_t i = 0; i < output.size(); i++) { - bool nan_test = false; - T r = test.ref(inA[i], inB[i]); + bool both_nan = false; if (std::is_same::value) - nan_test = !(isHalfNan(r) && isHalfNan(output[i])); + { + both_nan = isHalfNan(r) && isHalfNan(output[i]); + } + else if (std::is_floating_point::value) + { + both_nan = std::isnan(r) && std::isnan(output[i]); + } - if (r != output[i] && nan_test) + // If not both nan, check if the result is the same + 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",