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

Method set_logits

smallthinker/common/sampling.cpp:115–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113 llama_token_data_array cur_p;
114
115 void set_logits(struct llama_context * ctx, int idx) {
116 const auto * logits = llama_get_logits_ith(ctx, idx);
117
118 const llama_model * model = llama_get_model(ctx);
119 const llama_vocab * vocab = llama_model_get_vocab(model);
120
121 const int n_vocab = llama_vocab_n_tokens(vocab);
122
123 cur.resize(n_vocab);
124
125 for (llama_token token_id = 0; token_id < n_vocab; token_id++) {
126 cur[token_id] = llama_token_data{token_id, logits[token_id], 0.0f};
127 }
128
129 cur_p = { cur.data(), cur.size(), -1, false };
130 }
131};
132
133std::string common_params_sampling::print() const {

Callers 1

common_sampler_sampleFunction · 0.80

Calls 7

llama_model_get_vocabFunction · 0.85
llama_vocab_n_tokensFunction · 0.85
llama_get_logits_ithFunction · 0.50
llama_get_modelFunction · 0.50
resizeMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected