From d6a6505018fa94fc82c4475053c50abb5b842b24 Mon Sep 17 00:00:00 2001 From: luoyu-intel Date: Fri, 26 Jan 2024 18:31:04 +0800 Subject: [PATCH] implement std::isinf for icpx with fast math. --- tests/test-backend-ops.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/test-backend-ops.cpp b/tests/test-backend-ops.cpp index 55ce14e0d..fc58c2d33 100644 --- a/tests/test-backend-ops.cpp +++ b/tests/test-backend-ops.cpp @@ -240,10 +240,17 @@ static std::string var_to_str(ggml_type type) { #define VARS_TO_STR10(a, b, c, d, e, f, g, h, i, j) VAR_TO_STR(a) + "," + VARS_TO_STR9(b, c, d, e, f, g, h, i, j) #define VARS_TO_STR11(a, b, c, d, e, f, g, h, i, j, k) VAR_TO_STR(a) + "," + VARS_TO_STR10(b, c, d, e, f, g, h, i, j, k) +#ifdef GGML_USE_SYCL +static bool inline _isinf(float f) { + return (*(uint32_t *)&f & 0x7fffffff) == 0x7f800000; +} +#else +static bool inline _isinf(float f) { return std::isinf(f); } +#endif // accept FLT_MAX as infinity static bool isinf_or_max(float f) { - return std::isinf(f) || f == FLT_MAX || f == -FLT_MAX; + return _isinf(f) || f == FLT_MAX || f == -FLT_MAX; } static bool ggml_is_view_op(enum ggml_op op) {