From d7f4690a0bc94624c509c1b47cee2a10c86efe85 Mon Sep 17 00:00:00 2001 From: lalalune Date: Mon, 22 Jun 2026 12:17:49 -0700 Subject: [PATCH] fix(omnivoice): silence -Werror=double-promotion in voice classifiers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ubuntu-24-llguidance CI job builds the fused omnivoice tool with -DLLAMA_FATAL_WARNINGS=ON, which turns -Wdouble-promotion into an error. Five intentional float→double accumulations in the scalar voice-classifier forwards (voice_speaker.c DC-removal, mel mean-centering, TDNN stats-pool mean; voice_diarizer.c instance-norm mean/var) promoted a float operand implicitly. Make each promotion explicit with a (double) cast — identical numerics, no more warning. The sibling conv/linear accumulators are float and correctly untouched. Co-Authored-By: Claude Opus 4.8 --- .../src/voice-classifiers/voice_classifier/voice_diarizer.c | 4 ++-- .../src/voice-classifiers/voice_classifier/voice_speaker.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/omnivoice/src/voice-classifiers/voice_classifier/voice_diarizer.c b/tools/omnivoice/src/voice-classifiers/voice_classifier/voice_diarizer.c index a10c729c0..1fda3c3da 100644 --- a/tools/omnivoice/src/voice-classifiers/voice_classifier/voice_diarizer.c +++ b/tools/omnivoice/src/voice-classifiers/voice_classifier/voice_diarizer.c @@ -114,11 +114,11 @@ static void inst_norm_1d_inplace(float *buf, int C, int L, for (int c = 0; c < C; ++c) { float *row = buf + (size_t)c * L; double sum = 0.0, sq = 0.0; - for (int i = 0; i < L; ++i) sum += row[i]; + for (int i = 0; i < L; ++i) sum += (double)row[i]; const float mean = (float)(sum / L); for (int i = 0; i < L; ++i) { const float d = row[i] - mean; - sq += (double)d * d; + sq += (double)d * (double)d; } const float var = (float)(sq / L); const float invstd = 1.0f / sqrtf(var + eps); diff --git a/tools/omnivoice/src/voice-classifiers/voice_classifier/voice_speaker.c b/tools/omnivoice/src/voice-classifiers/voice_classifier/voice_speaker.c index ff8d63b15..9d72e2f62 100644 --- a/tools/omnivoice/src/voice-classifiers/voice_classifier/voice_speaker.c +++ b/tools/omnivoice/src/voice-classifiers/voice_classifier/voice_speaker.c @@ -335,7 +335,7 @@ static int spk_compute_fbank(const struct voice_speaker_session *s, /* DC offset removal. */ double dc = 0.0; - for (int i = 0; i < SPK_WINDOW_LEN; ++i) dc += frame[i]; + for (int i = 0; i < SPK_WINDOW_LEN; ++i) dc += (double)frame[i]; dc /= (double)SPK_WINDOW_LEN; for (int i = 0; i < SPK_WINDOW_LEN; ++i) frame[i] -= (float)dc; @@ -370,7 +370,7 @@ static int spk_compute_fbank(const struct voice_speaker_session *s, /* Per-utterance CMN. */ for (int m = 0; m < SPK_N_MELS; ++m) { double mean = 0.0; - for (int t = 0; t < frames; ++t) mean += feats_out[t * SPK_N_MELS + m]; + for (int t = 0; t < frames; ++t) mean += (double)feats_out[t * SPK_N_MELS + m]; mean /= (double)frames; for (int t = 0; t < frames; ++t) feats_out[t * SPK_N_MELS + m] -= (float)mean; } @@ -572,7 +572,7 @@ int voice_speaker_embed(voice_speaker_handle h, for (int oh = 0; oh < 10; ++oh) { const float *slot = cur + ((size_t)oc * 10 + oh) * T_pool; double mean = 0.0; - for (int t = 0; t < T_pool; ++t) mean += slot[t]; + for (int t = 0; t < T_pool; ++t) mean += (double)slot[t]; mean /= (double)T_pool; double var = 0.0; for (int t = 0; t < T_pool; ++t) {