Skip to content

Commit 7899c67

Browse files
committed
cont : better indices
ggml-ci
1 parent 99c4a39 commit 7899c67

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/llama-sampling.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,12 +1814,12 @@ static void llama_sampler_infill_apply(struct llama_sampler * smpl, llama_token_
18141814

18151815
// combine tokens with common prefix
18161816
for (size_t i0 = 0; i0 < cur_p->size; ++i0) {
1817-
for (size_t j0 = 0; j0 < cur_p->size; ++j0) {
1817+
for (size_t i1 = 0; i1 < cur_p->size; ++i1) {
18181818
if (cur_p->data[i0].logit == -INFINITY) {
18191819
break;
18201820
}
18211821

1822-
if (i0 == j0 || cur_p->data[j0].logit == -INFINITY) {
1822+
if (i0 == i1 || cur_p->data[i1].logit == -INFINITY) {
18231823
continue;
18241824
}
18251825

@@ -1830,20 +1830,20 @@ static void llama_sampler_infill_apply(struct llama_sampler * smpl, llama_token_
18301830
assert(len0 > 0);
18311831
}
18321832

1833-
int len1 = llama_token_to_piece_impl(*ctx->vocab, cur_p->data[j0].id, ctx->buf1.data(), ctx->buf1.size(), 0, false);
1833+
int len1 = llama_token_to_piece_impl(*ctx->vocab, cur_p->data[i1].id, ctx->buf1.data(), ctx->buf1.size(), 0, false);
18341834
if (len1 < 0) {
18351835
ctx->buf1.resize(len1);
1836-
len1 = llama_token_to_piece_impl(*ctx->vocab, cur_p->data[j0].id, ctx->buf1.data(), ctx->buf1.size(), 0, false);
1836+
len1 = llama_token_to_piece_impl(*ctx->vocab, cur_p->data[i1].id, ctx->buf1.data(), ctx->buf1.size(), 0, false);
18371837
assert(len1 > 0);
18381838
}
18391839

1840-
// token i0 is a prefix of token j0
1840+
// token i0 is a prefix of token i1
18411841
if (len0 > 0 && len0 <= len1 && memcmp(ctx->buf0.data(), ctx->buf1.data(), len0) == 0) {
18421842
int dst = i0;
1843-
int src = j0;
1843+
int src = i1;
18441844

18451845
// merge into the token with higher probability
1846-
if (cur_p->data[j0].p > cur_p->data[i0].p) {
1846+
if (cur_p->data[i1].p > cur_p->data[i0].p) {
18471847
std::swap(dst, src);
18481848
}
18491849

0 commit comments

Comments
 (0)