From afa025fde815984d510e615922aded13b5fe5a68 Mon Sep 17 00:00:00 2001 From: "bengt.gustafsson" Date: Tue, 25 Mar 2025 16:28:30 +0100 Subject: [PATCH 1/2] Add if clause to avoid using float from_chars overload on gcc 11 and below. This could possibly be trimmed to 10, but I don't have a possibility to test this. --- include/onnxruntime/core/common/parse_string.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/onnxruntime/core/common/parse_string.h b/include/onnxruntime/core/common/parse_string.h index 6345b2a55490d..8de9f5b467c4b 100644 --- a/include/onnxruntime/core/common/parse_string.h +++ b/include/onnxruntime/core/common/parse_string.h @@ -16,7 +16,7 @@ namespace onnxruntime { namespace detail { // Whether we will use std::from_chars() to parse to `T`. -#if defined(_LIBCPP_VERSION) +#if defined(_LIBCPP_VERSION) || defined(__GNUC__) && __GNUC__ < 12 // Note: Currently (e.g., in LLVM 19), libc++'s std::from_chars() doesn't support floating point types yet. template constexpr bool ParseWithFromChars = !std::is_same_v && std::is_integral_v; From 19df87be7d2f0c8481487994d31a342657c0aa06 Mon Sep 17 00:00:00 2001 From: "bengt.gustafsson" Date: Tue, 25 Mar 2025 18:00:20 +0100 Subject: [PATCH 2/2] Another gcc 9 fix --- onnxruntime/contrib_ops/cpu/sparse/sparse_attention_base.h | 1 + 1 file changed, 1 insertion(+) diff --git a/onnxruntime/contrib_ops/cpu/sparse/sparse_attention_base.h b/onnxruntime/contrib_ops/cpu/sparse/sparse_attention_base.h index cccaec0b16ce5..4ef3a4cbe50b6 100644 --- a/onnxruntime/contrib_ops/cpu/sparse/sparse_attention_base.h +++ b/onnxruntime/contrib_ops/cpu/sparse/sparse_attention_base.h @@ -448,6 +448,7 @@ class SparseAttentionBase { v, head_size, output_current, hidden_size, MLFloat16(1.0f).val, static_cast(0) /*beta*/, nullptr); } else { + (void) output_current; // Silence gcc 9. size_t bytes = static_cast(head_size) * total_seq_len * sizeof(float); auto v_fp32 = allocator->Alloc(bytes); BufferUniquePtr scratch_buffer(v_fp32, BufferDeleter(allocator));