feat: remove a sampler from a chain
This commit is contained in:
parent
1b28061400
commit
4a2e5e0dc5
2 changed files with 14 additions and 0 deletions
|
@ -1056,6 +1056,9 @@ extern "C" {
|
|||
LLAMA_API struct llama_sampler * llama_sampler_chain_get(const struct llama_sampler * chain, int32_t i);
|
||||
LLAMA_API int llama_sampler_chain_n (const struct llama_sampler * chain);
|
||||
|
||||
// after removing a sampler, the chain will no longer own it, and it will not be freed when the chain is freed
|
||||
LLAMA_API void llama_sampler_chain_remove( struct llama_sampler * chain, int32_t i);
|
||||
|
||||
// available samplers:
|
||||
|
||||
LLAMA_API struct llama_sampler * llama_sampler_init_greedy (void);
|
||||
|
|
|
@ -356,6 +356,17 @@ struct llama_sampler * llama_sampler_chain_get(const struct llama_sampler * chai
|
|||
return p->samplers[i];
|
||||
}
|
||||
|
||||
void llama_sampler_chain_remove(struct llama_sampler * chain, int32_t i) {
|
||||
auto * p = (llama_sampler_chain *) chain->ctx;
|
||||
|
||||
if (i < 0 || i >= (int32_t) p->samplers.size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto * result = p->samplers[i];
|
||||
p->samplers.erase(p->samplers.begin() + i);
|
||||
}
|
||||
|
||||
int llama_sampler_chain_n(const struct llama_sampler * chain) {
|
||||
const auto * p = (const llama_sampler_chain *) chain->ctx;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue