The GitHub Actions job "Fory CI" on fory.git/main has failed.
Run started by GitHub user chaokunyang (triggered by chaokunyang).

Head commit for run:
1331381ae968d792a8c7ab54736bb8c5a0084100 / Chang-Yen (Brian) Li 
<[email protected]>
feat(go): add support for bfloat16 (#3310)

## Why?

We want to use `bfloat16` (BF16) in FDL to reduce payload size while
keeping a wide exponent range (common in ML/AI workflows). Fory
currently lacks a BF16 primitive and optimized arrays. This PR adds full
support for `bfloat16` in the Fory Go runtime and codegen.

## What does this PR do?

1.  **Compiler**:
    *   Adds `bfloat16` to the IR type system (`PrimitiveKind`).
* Updates the Go generator to map `bfloat16` to `bfloat16.BFloat16` and
handle imports.
    *   Adds codegen tests for `bfloat16`.
2.  **Go Runtime**:
* Adds a new package `go/fory/bfloat16` with a strong type `type
BFloat16 uint16`.
* Implements IEEE 754 compliant conversions between `float32` and
`bfloat16` (round-to-nearest, ties-to-even).
    *   Handles special values: NaN, Inf, ±0 correctly.
3.  **Serialization**:
* Implements optimized serializers for `bfloat16`, `[]bfloat16`, and
`[N]bfloat16`, mirroring the `float16` implementation structure.
4.  **Type System**:
* Updates `TypeResolver` to register `BFloat16`, `[]BFloat16`, and
`[N]BFloat16` types.
* Adds type resolution logic to distinguish `BFloat16` from `uint16`
(since it's an alias type) for correct serializer selection.
5. **Tests**: Adds comprehensive unit tests for conversions, rounding
logic, serialization, and codegen.

## Related issues

Fixes #3284

## Does this PR introduce any user-facing change?



- [x] Does this PR introduce any public API change?
- [x] Does this PR introduce any binary protocol compatibility change?

## Benchmark

Report URL: https://github.com/apache/fory/actions/runs/21924082509

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to