MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / main

Function main

smallthinker/tests/test-double-float.cpp:35–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33}
34
35int 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}

Callers

nothing calls this directly

Calls 5

isfiniteFunction · 0.85
round_origFunction · 0.70
round_floatFunction · 0.70
silu_origFunction · 0.70
silu_floatFunction · 0.70

Tested by

no test coverage detected