common : fix gpt_sampler_cp

ggml-ci
This commit is contained in:
Georgi Gerganov 2024-09-04 14:17:19 +03:00
parent ad436e9284
commit fdb52aa657
No known key found for this signature in database
GPG key ID: 449E073F9DC10735

View file

@ -110,12 +110,13 @@ void gpt_sampler_free(struct gpt_sampler * gsmpl) {
} }
struct gpt_sampler * gpt_sampler_cp(gpt_sampler * gsmpl) { struct gpt_sampler * gpt_sampler_cp(gpt_sampler * gsmpl) {
gpt_sampler * result = new gpt_sampler(); return new gpt_sampler {
/* .params = */ gsmpl->params,
result->grmr = llama_constraint_cp(gsmpl->grmr); /* .bias = */ llama_constraint_cp(gsmpl->bias),
result->smpl = llama_sampler_cp(gsmpl->smpl); /* .pnlt = */ llama_constraint_cp(gsmpl->pnlt),
/* .grmr = */ llama_constraint_cp(gsmpl->grmr),
return result; /* .smpl = */ llama_sampler_cp(gsmpl->smpl)
};
} }
void gpt_sampler_accept(struct gpt_sampler * gsmpl, llama_token token, bool apply_grammar) { void gpt_sampler_accept(struct gpt_sampler * gsmpl, llama_token token, bool apply_grammar) {
@ -145,7 +146,7 @@ llama_token gpt_sampler_last(const struct gpt_sampler * gsmpl) {
} }
void gpt_print_timings(struct llama_context * ctx, struct gpt_sampler * gsmpl) { void gpt_print_timings(struct llama_context * ctx, struct gpt_sampler * gsmpl) {
llama_print_timings(ctx, gsmpl->smpl); llama_print_timings(ctx, gsmpl ? gsmpl->smpl : nullptr);
} }
static llama_token gpt_sampler_sample( static llama_token gpt_sampler_sample(