| 1475 | } |
| 1476 | |
| 1477 | static struct llama_sampler * llama_sampler_grammar_clone(const struct llama_sampler * smpl) { |
| 1478 | const auto * ctx = (const llama_sampler_grammar *) smpl->ctx; |
| 1479 | |
| 1480 | auto * result = llama_sampler_init_grammar_impl(ctx->vocab, nullptr, nullptr, false, nullptr, 0, nullptr, 0, nullptr, 0); |
| 1481 | GGML_ASSERT(result); |
| 1482 | |
| 1483 | // copy the state |
| 1484 | { |
| 1485 | auto * result_ctx = (llama_sampler_grammar *) result->ctx; |
| 1486 | |
| 1487 | if (ctx->grammar) { |
| 1488 | result_ctx->grammar_str = ctx->grammar_str; |
| 1489 | result_ctx->grammar_root = ctx->grammar_root; |
| 1490 | |
| 1491 | result_ctx->grammar = llama_grammar_clone_impl(*ctx->grammar); |
| 1492 | } |
| 1493 | } |
| 1494 | |
| 1495 | return result; |
| 1496 | } |
| 1497 | |
| 1498 | static void llama_sampler_grammar_free(struct llama_sampler * smpl) { |
| 1499 | const auto * ctx = (llama_sampler_grammar *) smpl->ctx; |
nothing calls this directly
no test coverage detected