Repository navigation
Fix ambiguous std::isnan call on xnn_float16 in vbinary tester - #11545
Merged
copybara-service[bot] merged 1 commit intoOct 18, 2026
Merged
copybara-service[bot] merged 1 commit into
copybara-service[bot] merged 1 commit into
Conversation
Where the compiler and CPU support it, src/xnnpack/math.h defines
xnn_float16 as the native _Float16 type (XNN_HAVE_FLOAT16, e.g. x86_64
with F16C and clang >= 15 or GCC >= 12). std::isnan has no _Float16
overload, so the implicit conversions to float, double and long double
are all equally good candidates and overload resolution is ambiguous:
test/vbinary-microkernel-tester.cc:66:11: error: call to 'isnan' is ambiguous
if (std::isnan(y_ref[i])) {
Minimal reproduction under libstdc++ 15:
_Float16 x = 1.0f; std::isnan(x); // error: ambiguous
_Float16 x = 1.0f; std::isnan(float(x)); // compiles
This is the only compile error in a 797-target x86_64 build, so it
blocked every test that links vbinary-microkernel-tester. Cast to
float, matching how the surrounding lines already use
static_cast<float>(y_ref[i]).
Does not affect ARM64, where xnn_float16 is a struct with a single
operator float(), making the conversion unambiguous.
anagnorisis2peripeteia
force-pushed
the
fix-f16-isnan-overload-ambiguity
branch
from
October 7, 2026 15:57
8a094c4 to
58760a2
Compare
fbarchard
approved these changes
Oct 17, 2026
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.
Defect: the x86_64 test build does not compile
test/vbinary-microkernel-tester.cc:66fails to build on x86_64:Root cause
src/xnnpack/math.h:528-532enables native_Float16on x86 when F16C is present:std::isnanhas no_Float16overload, so the argument converts tofloat,doubleandlong doubleby equally-ranked floating conversions. Overload resolution cannot pick one.Minimal reproduction (libstdc++ 15):
Impact
This is the only compile error across a 797-target x86_64 build, so it blocks every test binary that links
vbinary-microkernel-tester.ninja -k 0reports exactly one distinct error.Fix
Cast to
float— the same conversion the surrounding lines already use (static_cast<float>(y_ref[i])appears three lines below). One line.Why ARM64 never saw it
On ARM64,
xnn_float16is the struct form (math.h:552-566) with a singleoperator float(), which is unambiguous. Only the native-_Float16path is affected.Verification
clang++ -std=gnu++17 -march=native -c test/vbinary-microkernel-tester.ccon x86_64 → error: call to 'isnan' is ambiguousvbinary-microkernel-testertarget still builds.1 file, +5/-1.
git diff --checkclean; no line exceeds 120 columns.