MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / llama_sampler_grammar_clone

Function llama_sampler_grammar_clone

smallthinker/src/llama-sampling.cpp:1477–1496  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1475}
1476
1477static 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
1498static void llama_sampler_grammar_free(struct llama_sampler * smpl) {
1499 const auto * ctx = (llama_sampler_grammar *) smpl->ctx;

Callers

nothing calls this directly

Calls 2

llama_grammar_clone_implFunction · 0.85

Tested by

no test coverage detected