| 33 | } |
| 34 | |
| 35 | int main(void) { |
| 36 | uint32_t x = UINT32_MAX; |
| 37 | do { |
| 38 | float f; |
| 39 | memcpy(&f, &x, sizeof(x)); |
| 40 | assert(!std::isfinite(f) || (round_orig(f) == round_float(f))); |
| 41 | } while (x--); |
| 42 | |
| 43 | #ifdef __F16C__ |
| 44 | // GELU and SILU implementations are used with a FP16 lookup table. |
| 45 | // The original and float-only results are not equal for all inputs after converting to FP16. |
| 46 | // GELU is an approximation anyway (tanh), not tested here. |
| 47 | // For SILU, verify that the results are at least the closest floating point numbers, if the FP16 values don't match. |
| 48 | for (x = 0; x <= UINT16_MAX; x++) { |
| 49 | float f = _cvtsh_ss(x); |
| 50 | const float so = silu_orig(f); |
| 51 | const float sf = silu_float(f); |
| 52 | assert( (_cvtss_sh(so, 0) == _cvtss_sh(sf, 0)) |
| 53 | || (nextafterf(so, sf) == sf) |
| 54 | || (nextafterf(sf, so) == so)); |
| 55 | } |
| 56 | #endif |
| 57 | } |
nothing calls this directly
no test coverage detected