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

Function test_float16_vectors

tests/src/engine/test_float.cpp:94–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94bool test_float16_vectors()
95{
96 // This test just checks if packing and shuffling works correctly,
97 // it doesn't need to cover various possible values.
98
99 float2 f32_2(1.f, -2.f); // negative [1] to test the upper (sign) bit in the int32 packed version
100 float16_t2 f16_2 = Float32ToFloat16x2(f32_2);
101 float2 f32_2_out = Float16ToFloat32x2(f16_2);
102
103 bool pass = true;
104 for (int i = 0; i < 2; ++i)
105 {
106 if (f32_2_out[i] != f32_2[i])
107 {
108 fprintf(stderr, "FLOAT16x2 [%d] mismatch: expected %f, got %f\n", i, f32_2[i], f32_2_out[i]);
109 pass = false;
110 }
111 }
112
113 float4 f32_4(1.f, -2.f, 3.f, -4.f); // negative [3] to test the upper (sign) bit in the int64 packed version
114 float16_t4 f16_4 = Float32ToFloat16x4(f32_4);
115 float4 f32_4_out = Float16ToFloat32x4(f16_4);
116
117 for (int i = 0; i < 4; ++i)
118 {
119 if (f32_4_out[i] != f32_4[i])
120 {
121 fprintf(stderr, "FLOAT16x4 [%d] mismatch: expected %f, got %f\n", i, f32_4[i], f32_4_out[i]);
122 pass = false;
123 }
124 }
125
126 return pass;
127}
128
129bool test_float16()
130{

Callers 1

mainFunction · 0.85

Calls 4

Float32ToFloat16x2Function · 0.85
Float16ToFloat32x2Function · 0.85
Float32ToFloat16x4Function · 0.85
Float16ToFloat32x4Function · 0.85

Tested by

no test coverage detected