Made algorithm safer and more readable
This commit is contained in:
parent
3968369071
commit
acada1a5e7
1 changed files with 9 additions and 6 deletions
|
@ -1107,16 +1107,19 @@ static void llama_sample_xtc_apply(struct llama_sampler * smpl, llama_token_data
|
|||
}
|
||||
}
|
||||
|
||||
size_t to_remove = pos_last - (1 + pos_first);
|
||||
int to_remove = pos_last - (1 + pos_first);
|
||||
|
||||
if (cur_p->size - to_remove < ctx->min_keep || to_remove < 1) return;
|
||||
if (cur_p->size - to_remove >= ctx->min_keep && to_remove > 0) {
|
||||
|
||||
for (size_t i = pos_first + 1; i < cur_p->size - to_remove + 1; ++i) {
|
||||
size_t last_idx = cur_p->size - to_remove;
|
||||
|
||||
for (size_t i = pos_first + 1; i <= last_idx; ++i) {
|
||||
cur_p->data[i] = cur_p->data[i + to_remove];
|
||||
}
|
||||
|
||||
cur_p->size = cur_p->size - to_remove;
|
||||
}
|
||||
}
|
||||
|
||||
static struct llama_sampler * llama_sampler_xtc_clone(const struct llama_sampler * smpl) {
|
||||
const auto * ctx = (const llama_sampler_xtc *) smpl->ctx;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue