File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -16077,7 +16077,7 @@ static int llama_decode_internal(
16077
16077
}
16078
16078
16079
16079
for (uint32_t i = 0; i < n_tokens_all; ++i) {
16080
- if (batch_all.token[i] < 0) {
16080
+ if (batch_all.token[i] < 0 || (uint32_t)batch_all.token[i] >= lctx.model.vocab.n_vocab ) {
16081
16081
LLAMA_LOG_ERROR("%s: invalid token[%d] = %d", __func__, i, batch_all.token[i]);
16082
16082
return -1;
16083
16083
}
@@ -16376,7 +16376,7 @@ static int llama_encode_internal(
16376
16376
}
16377
16377
16378
16378
for (uint32_t i = 0; i < n_tokens; ++i) {
16379
- if (batch.token[i] < 0) {
16379
+ if (batch.token[i] < 0 || (uint32_t)batch.token[i] >= lctx.model.vocab.n_vocab ) {
16380
16380
LLAMA_LOG_ERROR("%s: invalid token[%d] = %d", __func__, i, batch.token[i]);
16381
16381
return -1;
16382
16382
}
You can’t perform that action at this time.
0 commit comments