feat: Add IEEE 754 float16 (binary16) support to Rust runtime #3252
+695
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements full IEEE 754 half-precision (binary16)
float16support for the Rust runtime as requested in issue #3207.Implementation Details
Core Type (
fory-core/src/float16.rs)#[repr(transparent)] pub struct float16(u16)- 614 linesIntegration
buffer.rs):write_f16()andread_f16()using little-endianserializer/number.rs): FullSerializertrait +ForyDefaultimplementationtypes.rs): Added toBASIC_TYPES,PRIMITIVE_TYPES,PRIMITIVE_ARRAY_TYPES,BASIC_TYPE_NAMES,PRIMITIVE_ARRAY_TYPE_MAP,is_primitive_type_id()lib.rs): Public module withFloat16aliasTesting
Why?
Support for half-precision floats is essential for:
What does this PR do?
Adds production-ready IEEE 754 binary16 support to Rust runtime matching the exact specification in #3207, including:
Related issues
Closes #3207
Does this PR introduce any user-facing change?
Does this PR introduce any public API change?
float16(exported asFloat16)from_bits,to_bits,from_f32,to_f32, classification methods, arithmetic methodsZERO,NEG_ZERO,INFINITY,NEG_INFINITY,NAN,MAX,MIN_POSITIVE,MIN_POSITIVE_SUBNORMALDoes this PR introduce any binary protocol compatibility change?
FLOAT16(TypeId = 16) andFLOAT16_ARRAY(TypeId = 50) to wire formatBenchmark
Not applicable - this PR adds new functionality without modifying existing code paths. No performance impact on existing f32/f64 usage.