Uh oh!
There was an error while loading. Please reload this page.
GH-46739: [C++] Fix Float16 signed zero/NaN equality comparisons - #46973
Conversation
1 similar comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
9cb6072 to
f6b74b2Comparepitrou
commented
Aug 21, 2025
@benibus Is this ready for review again? |
benibus
commented
Aug 22, 2025
@pitrou Yes, sorry. Feel free to take another look. |
pitrou
left a comment
There was a problem hiding this comment.
LGTM in general, some additional comments below
There was a problem hiding this comment.
This doesn't fix GenerateTypedData when nan_probability_ is non-zero (it will use std::numeric_limits<uint16_t>::quiet_NaN() which is 0 and translates to Float16(0.0)).
There was a problem hiding this comment.
DistributionType will be std::uniform_int_distribution<uint16_t> which will certainly not respect the min and max values once translated to Float16?
There was a problem hiding this comment.
Perhaps ValueType needs to be Float16 here to make sure we don't misuse uint16_t like this, and DistributionType could be ::arrow::random::uniform_real_distribution<float>.
There was a problem hiding this comment.
I wouldn't expect these checks in a helper function, especially as we supposedly have unit tests for this already (otherwise we should add them).
There was a problem hiding this comment.
Perhaps use std::decay_t instead of std::remove_reference_t?
There was a problem hiding this comment.
We should probably keep the check here by using if constexpr as below?
There was a problem hiding this comment.
Since we are changing this, perhaps ASSERT_TRUE(set.emplace(...).second) would be better?
f6b74b2 to
866f533CompareTemporary for now
Since github.com/apache/pull/46981, HalfFloatBuilder now accepts Float16 values, making RealToCType's usage unnecessary in several places.
866f533 to
fb60726Compare| ARROW_LOG(INFO) << "min = " << min_value.ToFloat(); | ||
| ARROW_LOG(INFO) << "max = " << max_value.ToFloat(); |
There was a problem hiding this comment.
Ah, thanks! Just removed them.
pitrou
commented
Sep 4, 2025
@github-actions crossbow submit -g cpp |
Revision: 116b975 Submitted crossbow builds: ursacomputing/crossbow @ actions-868dcfc65b |
pitrou
commented
Sep 4, 2025
The Valgrind failure is unrelated, see #47496 |
pitrou
commented
Sep 4, 2025
Thanks a lot @benibus ! |
After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit caf4f70. There weren't enough matching historic benchmark results to make a call on whether there were regressions. The full Conbench report has more details. |
apache#46973) ### Rationale for this change Equality comparisons between half-floats (used in their scalar/array `Equals` methods) do not properly handle `EqualOptions::nans_equal` and `EqualOptions::signed_zeros_equal`. ### What changes are included in this PR? - Internal fixes to the current comparison behavior and additional tests as needed - Prevents Float16 NaNs from being randomly generated by test utilities by default (matching behavior for float/double) ### Are these changes tested? Yes ### Are there any user-facing changes? No * GitHub Issue: apache#46739 Authored-by: Benjamin Harkins <benpharkins@gmail.com> Signed-off-by: Antoine Pitrou <antoine@python.org>
apache#46973) ### Rationale for this change Equality comparisons between half-floats (used in their scalar/array `Equals` methods) do not properly handle `EqualOptions::nans_equal` and `EqualOptions::signed_zeros_equal`. ### What changes are included in this PR? - Internal fixes to the current comparison behavior and additional tests as needed - Prevents Float16 NaNs from being randomly generated by test utilities by default (matching behavior for float/double) ### Are these changes tested? Yes ### Are there any user-facing changes? No * GitHub Issue: apache#46739 Authored-by: Benjamin Harkins <benpharkins@gmail.com> Signed-off-by: Antoine Pitrou <antoine@python.org>
Rationale for this change
Equality comparisons between half-floats (used in their scalar/array
Equalsmethods) do not properly handleEqualOptions::nans_equalandEqualOptions::signed_zeros_equal.What changes are included in this PR?
Are these changes tested?
Yes
Are there any user-facing changes?
No