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.
This commit is contained in:
zzk0
2025-02-19 12:51:19 +08:00
committed by GitHub
parent 6d3d199b42
commit bdd0eb0b7e

View File

@@ -98,14 +98,20 @@ 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 = false;
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 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",