MCPcopy Create free account
hub / github.com/andrewkchan/deepseek.cpp / float_to_float8e5m2

Function float_to_float8e5m2

src/codec.h:49–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47 return half_to_float(val);
48}
49[[maybe_unused]] inline f8e5m2_t float_to_float8e5m2(float x) {
50 f16_t val = float_to_half(x);
51 f8e5m2_t out;
52#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
53 memcpy(&out, (char*)&val, sizeof(f8e5m2_t)); // TODO: round instead of truncate?
54#else
55 memcpy(&out, (char*)&val + sizeof(f8e5m2_t), sizeof(f8e5m2_t)); // TODO: round instead of truncate?
56#endif
57 return out;
58}
59
60// Quant of tensors saved in the file.
61// This corresponds to PyTorch tensor dtypes.

Callers 2

test_matmulFunction · 0.85

Calls 1

float_to_halfFunction · 0.85

Tested by 2

test_matmulFunction · 0.68