MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / float_from_bytes

Function float_from_bytes

oneflow/core/common/bfloat16_test.cpp:23–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21namespace test {
22
23float float_from_bytes(uint32_t sign, uint32_t exponent, uint32_t fraction) {
24 // reference: pytorch/c10/test/util/bfloat16_test.cpp
25 // https://github.com/pytorch/pytorch/blob/release/1.12/c10/test/util/bfloat16_test.cpp
26 uint32_t bytes = 0;
27 bytes |= sign;
28 bytes <<= 8;
29 bytes |= exponent;
30 bytes <<= 23;
31 bytes |= fraction;
32 float res = NAN;
33 std::memcpy(&res, &bytes, sizeof(res));
34 return res;
35}
36
37TEST(BFLOAT16MATH, Add) {
38 // 6.25

Callers 1

TESTFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected