| 139 | } |
| 140 | |
| 141 | static bool is_float_close(float a, float b, float abs_tol) { |
| 142 | // Check for non-negative tolerance |
| 143 | if (abs_tol < 0.0) { |
| 144 | throw std::invalid_argument("Tolerance must be non-negative"); |
| 145 | } |
| 146 | |
| 147 | // Exact equality check |
| 148 | if (a == b) { |
| 149 | return true; |
| 150 | } |
| 151 | |
| 152 | // Check for infinities |
| 153 | if (std::isinf(a) || std::isinf(b)) { |
| 154 | return false; |
| 155 | } |
| 156 | |
| 157 | // Regular comparison using the provided absolute tolerance |
| 158 | return std::fabs(b - a) <= abs_tol; |
| 159 | } |
| 160 | |
| 161 | #ifdef GGML_USE_CPU_HBM |
| 162 | #include <hbwmalloc.h> |