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 @@ -16081,7 +16081,7 @@ static int llama_decode_internal(
16081
16081
}
16082
16082
16083
16083
for (uint32_t i = 0; i < n_tokens_all; ++i) {
16084
- if (batch_all.token[i] < 0) {
16084
+ if (batch_all.token[i] < 0 || (uint32_t)batch_all.token[i] >= lctx.model.vocab.n_vocab ) {
16085
16085
LLAMA_LOG_ERROR("%s: invalid token[%d] = %d", __func__, i, batch_all.token[i]);
16086
16086
return -1;
16087
16087
}
@@ -16380,7 +16380,7 @@ static int llama_encode_internal(
16380
16380
}
16381
16381
16382
16382
for (uint32_t i = 0; i < n_tokens; ++i) {
16383
- if (batch.token[i] < 0) {
16383
+ if (batch.token[i] < 0 || (uint32_t)batch.token[i] >= lctx.model.vocab.n_vocab ) {
16384
16384
LLAMA_LOG_ERROR("%s: invalid token[%d] = %d", __func__, i, batch.token[i]);
16385
16385
return -1;
16386
16386
}
You can’t perform that action at this time.
0 commit comments