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

Function test_float8e5m2

tests/src/engine/test_float.cpp:368–405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

366}
367
368bool test_float8e5m2()
369{
370 float8e5m2_t f8i;
371 float8e5m2_t f8o;
372 float f32;
373 uint32_t errorCount = 0;
374 for (int i = 0; i < 256; ++i)
375 {
376 f8i.bits = i;
377 f32 = Float8E5M2ToFloat32(f8i);
378 f8o = Float32ToFloat8E5M2(f32);
379
380 bool pass;
381 if (isinf(f8i))
382 pass = std::isinf(f32) == isinf(f8o) && signbit(f8i) == signbit(f8o);
383 else if (isnan(f8i))
384 pass = std::isnan(f32) == isnan(f8o);
385 else
386 pass = f8o.bits == f8i.bits && std::isfinite(f32) == isfinite(f8o);
387
388 if (!pass)
389 {
390 ++errorCount;
391 if (errorCount < MAX_ERRORS)
392 {
393 fprintf(stderr, "E5M2 mismatch: expected 0x%02x, got 0x%02x, float value %f\n",
394 f8i.bits, f8o.bits, f32);
395 }
396 }
397 }
398
399 if (errorCount >= MAX_ERRORS)
400 {
401 fprintf(stderr, "... %u more error(s) ...\n", errorCount - MAX_ERRORS);
402 }
403
404 return errorCount == 0;
405}
406
407bool test_gpu_float8(nvrhi::IDevice* device, bool e5m2)
408{

Callers 1

mainFunction · 0.85

Calls 6

Float8E5M2ToFloat32Function · 0.85
Float32ToFloat8E5M2Function · 0.85
isinfFunction · 0.85
signbitFunction · 0.85
isnanFunction · 0.85
isfiniteFunction · 0.50

Tested by

no test coverage detected