feat(gf16): implement φ-optimized FMA/FMS operations#57
Merged
Conversation
Add three new fused operations to GF16: - phiFma(a, b, c): φ-dequantize inputs, compute a*b+c, φ-quantize result - phiFms(a, b, c): φ-dequantize inputs, compute a*b-c, φ-quantize result - fma(a, b, c): standard fused multiply-add (no φ scaling) Also adds C-ABI exports (gf16_phi_fma, gf16_phi_fms) and C header declarations, plus 6 new tests (3 GF16 core, 3 C-ABI). Closes #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Implements φ-optimized fused multiply-add and multiply-subtract for GF16, as requested in #4.
New Functions
GF16 core (
src/formats/golden_float16.zig):phiFma(a, b, c)— φ-dequantize all inputs, compute a*b+c in f32, φ-quantize resultphiFms(a, b, c)— φ-dequantize all inputs, compute a*b-c in f32, φ-quantize resultfma(a, b, c)— standard FMA without φ scaling (was only in c_abi, now also in GF16 struct)C-ABI (
src/c_abi.zig):gf16_phi_fma(a, b, c)— exported C functiongf16_phi_fms(a, b, c)— exported C functionC header (
src/c/gf16.h):Tests Added (6)
GF16 phi-fused multiply-addGF16 phi-fused multiply-subtractGF16 standard fused multiply-addC-ABI: gf16_phi_fmaC-ABI: gf16_phi_fmsC-ABI: gf16_fma(existing, kept)Closes #4