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

Function llama_sampler_temp_impl

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

Source from the content-addressed store, hash-verified

177*/
178
179static void llama_sampler_temp_impl(llama_token_data_array * cur_p, float temp) {
180 if (temp <= 0.0f) {
181 // find the token with the highest logit and set the rest to -inf
182 size_t max_i = 0;
183 float max_l = cur_p->data[0].logit;
184
185 for (size_t i = 1; i < cur_p->size; ++i) {
186 if (cur_p->data[i ].logit > max_l) {
187 cur_p->data[max_i].logit = -INFINITY;
188 max_i = i;
189 max_l = cur_p->data[i].logit;
190 } else {
191 cur_p->data[i].logit = -INFINITY;
192 }
193 }
194
195 return;
196 }
197
198 for (size_t i = 0; i < cur_p->size; ++i) {
199 cur_p->data[i].logit /= temp;
200 }
201}
202
203static void llama_sampler_softmax_impl(llama_token_data_array * cur_p) {
204 GGML_ASSERT(cur_p->size > 0);

Callers 2

llama_sampler_temp_applyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected