feat(cpp): add float16 to c++#3487
Conversation
…at16_t and float
…sentation for float16_t
0e2da14 to
7f948b9
Compare
9df42fe to
56592b2
Compare
…loads for float16_t
5ec9883 to
a884193
Compare
c31812d to
65d35fb
Compare
…et via if constexpr
65d35fb to
cf3a068
Compare
7c116a6 to
ad46532
Compare
|
|
||
| // A 16-bit floating point representation with 1 sign bit, 5 exponent bits, and | ||
| // 10 mantissa bits. | ||
| struct float16_t { |
There was a problem hiding this comment.
Please add a std::hash<fory::float16_t> specialization alongside the comparison operators. Right now std::unordered_map<float16_t, ...> / std::unordered_set<float16_t> do not compile at all; a minimal local compile probe fails immediately because the default std::hash is deleted.
| } | ||
| } | ||
|
|
||
| TEST(Float16SerializerTest, VectorRoundTrip) { |
There was a problem hiding this comment.
This round-trip only proves C++ can serialize and deserialize the same struct locally. It does not catch the wire-format regression here: std::vector<float16_t> still falls through the non-arithmetic vector serializer and emits LIST, because std::is_arithmetic_v<float16_t> is false. Please either wire float16_t into the typed-array path or assert here that the emitted type id is FLOAT16_ARRAY.
| EXPECT_EQ(deser.value(), original); | ||
| } | ||
|
|
||
| TEST(Float16SerializerTest, EmptyVectorRoundTrip) { |
There was a problem hiding this comment.
Please add a fixed-size array case in this serializer test block as well. std::array<float16_t, N> is still unsupported today, because the generic primitive-array serializer is gated on std::is_arithmetic_v<T> and there is no explicit float16_t specialization.
efaa045 to
e022eda
Compare
Why?
Implement float16_t (IEEE 754 binary16 / half-precision) as a primitive type in the C++ runtime, as required by issue #3208. No C++ standard type represents float16, so the framework needs its own strong type with correct IEEE 754 semantics and serialiser integration.
What does this PR do?
cpp/fory/util/float16.h / float16.cc — new fory::float16_t strong type:
cpp/fory/serialization/struct_serializer.h — serializer integration:
cpp/fory/util/float16_test.cc — exhaustive tests (1300+ lines, 61 test cases):
Related issues
AI Contribution Checklist
yesyes, I included a completed AI Contribution Checklist in this PR description and the requiredAI Usage Disclosure.AI Usage Disclosure
Does this PR introduce any user-facing change?