Repository navigation
GPU: the rectangle fallback's f16 narrowing keeps NaN and rounds ties to even - #326
Open
RenzoWit35 wants to merge 1 commit into
Open
RenzoWit35 wants to merge 1 commit into
RenzoWit35 wants to merge 1 commit into
Conversation
… to even (fxceless#245) The CPU rectangle expansion narrows the generated fourth corner of an R16_FLOAT element from f32. A NaN took the overflow path and became infinity, and normal values exactly halfway between two halves always rounded up (1 + 2^-11 gave 0x3c01, not 0x3c00). NaN now becomes a quiet NaN with its sign, and normal values round ties to the even mantissa as the subnormal path already did; overflow still gives infinity. Tests: the tie and a quiet NaN corner through expand_rects, NaN payloads only in dropped bits, and a check against a search-based ties-to-even reference over every half, every halfway point and its neighbours, and a sweep of f32 values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Duplicate of #315? |
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.
Fixes #245.
f32_to_halfin the CPU rectangle expansion sent NaN through the overflow branch (givinginfinity, 0x7c00) and rounded exact ties up (
1 + 2^-11gave 0x3c01). NaN now returns a quietNaN that keeps the sign (
sign | 0x7e00), and normal values round ties to even like thesubnormal path already did. A rounding carry still moves into the exponent, and overflow still
gives infinity.
Tests: the issue's tie and NaN corners through
expand_rects; NaN payloads, including one onlyin the dropped bits; and a hand-written ties-to-even reference compared against every half
value, every halfway point and its neighbours, and a strided f32 sweep. All failed before.
Testing
On Windows 11, MSVC Rust 1.98.1, branch alone on top of
main(2119b0e):cargo clippy --workspace --all-targets --locked -- -D warnings, the same with--all-features, andcargo test --workspace --lockedall pass. The new regression test fails onmainand passes here. All nine fix branches for #242-#250 also pass together when merged.🤖 Generated with Claude Code