MCPcopy Create free account
hub / github.com/NVIDIA-RTX/Donut / check_known_float16

Function check_known_float16

tests/src/engine/test_float.cpp:46–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44constexpr uint32_t MAX_ERRORS = 16;
45
46bool check_known_float16(float in, uint16_t out)
47{
48 float16_t f16o = Float32ToFloat16(in);
49 float f32o = Float16ToFloat32(f16o);
50
51 bool pass = f16o.bits == out;
52 if (std::isinf(in))
53 pass = pass && isinf(f16o) && std::isinf(f32o);
54 else if (std::isnan(in))
55 pass = isnan(f16o) && std::isnan(f32o); // Exact NaN mantissa bits are allowed to mismatch
56
57 if (!pass)
58 {
59 fprintf(stderr, "Known FLOAT16 mismatch: expected 0x%04x, got 0x%04x, float value %f\n",
60 out, f16o.bits, in);
61 }
62 return pass;
63}
64
65bool test_known_float16()
66{

Callers 1

test_known_float16Function · 0.85

Calls 4

Float32ToFloat16Function · 0.85
Float16ToFloat32Function · 0.85
isinfFunction · 0.85
isnanFunction · 0.85

Tested by

no test coverage detected