Skip to content

Commit 6497834

Browse files
ggerganovslaren
andauthored
ggml : add asserts (#14720)
* ggml : add asserts ggml-ci * cont : fix constant type Co-authored-by: Diego Devesa <slarengh@gmail.com> --------- Co-authored-by: Diego Devesa <slarengh@gmail.com>
1 parent 6ffd4e9 commit 6497834

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

ggml/src/ggml-cpu/ops.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4015,6 +4015,9 @@ static void ggml_compute_forward_rms_norm_f32(
40154015

40164016
const float scale = 1.0f/sqrtf(mean + eps);
40174017

4018+
// if you hit this, likely you got an inf somewhere earlier
4019+
assert(scale > 0.0f);
4020+
40184021
ggml_vec_scale_f32(ne00, y, scale);
40194022
}
40204023
}

ggml/src/ggml-cpu/vec.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ void ggml_vec_dot_f16(int n, float * GGML_RESTRICT s, size_t bs, ggml_fp16_t * G
221221
for (int i = np; i < n; ++i) {
222222
sumf += (ggml_float)(GGML_CPU_FP16_TO_FP32(x[i])*GGML_CPU_FP16_TO_FP32(y[i]));
223223
}
224+
225+
// if you hit this, you are likely running outside the FP range
226+
assert(!isnan(sumf) && !isinf(sumf));
224227
#else
225228
for (int i = 0; i < n; ++i) {
226229
sumf += (ggml_float)(GGML_CPU_FP16_TO_FP32(x[i])*GGML_CPU_FP16_TO_FP32(y[i]));

0 commit comments

Comments
 (0)