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

Function llama_sampling_reset

common/sampling.cpp:39–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37}
38
39void llama_sampling_reset(llama_sampling_context * ctx) {
40 if (ctx->grammar != NULL) {
41 llama_grammar_free(ctx->grammar);
42 ctx->grammar = NULL;
43 }
44
45 if (!ctx->parsed_grammar.rules.empty()) {
46 std::vector<const llama_grammar_element *> grammar_rules(ctx->parsed_grammar.c_rules());
47
48 ctx->grammar = llama_grammar_init(
49 grammar_rules.data(),
50 grammar_rules.size(), ctx->parsed_grammar.symbol_ids.at("root"));
51 }
52
53 std::fill(ctx->prev.begin(), ctx->prev.end(), 0);
54 ctx->cur.clear();
55}
56
57void llama_sampling_cp(llama_sampling_context * src, llama_sampling_context * dst) {
58 if (dst->grammar) {

Callers 4

mainFunction · 0.85
update_slotsMethod · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 10

llama_grammar_freeFunction · 0.85
llama_grammar_initFunction · 0.85
fillFunction · 0.85
emptyMethod · 0.45
c_rulesMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected