Skip to content

Commit a2fba89

Browse files
authored
hparams : add check for layer index in is_recurrent (ggml-org#16511)
* hparams : add check for layer index in is_recurrent This commit adds a check in the is_recurrent method to ensure that the provided layer index is within the valid range. The motivation for this change is to prevent potential out-of-bounds and also be consistent with other methods in the class that perform similar checks, like is_swa.
1 parent 20cc625 commit a2fba89

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/llama-hparams.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@ uint32_t llama_hparams::n_embd_s() const {
140140
}
141141

142142
bool llama_hparams::is_recurrent(uint32_t il) const {
143-
return recurrent_layer_arr[il];
143+
if (il < n_layer) {
144+
return recurrent_layer_arr[il];
145+
}
146+
147+
GGML_ABORT("%s: il (%u) out of bounds (n_layer: %u)\n", __func__, il, n_layer);
144148
}
145149

146150
uint32_t llama_hparams::n_pos_per_embd() const {

0 commit comments

Comments
 (0)