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

Function llama_sample_token_greedy

llama.cpp:8617–8631  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8615}
8616
8617llama_token llama_sample_token_greedy(struct llama_context * ctx, llama_token_data_array * candidates) {
8618 const int64_t t_start_sample_us = ggml_time_us();
8619
8620 // Find max element
8621 auto * max_iter = std::max_element(candidates->data, candidates->data + candidates->size, [](const llama_token_data & a, const llama_token_data & b) {
8622 return a.logit < b.logit;
8623 });
8624
8625 llama_token result = max_iter->id;
8626 if (ctx) {
8627 ctx->t_sample_us += ggml_time_us() - t_start_sample_us;
8628 ctx->n_sample++;
8629 }
8630 return result;
8631}
8632
8633llama_token llama_sample_token(struct llama_context * ctx, llama_token_data_array * candidates) {
8634 GGML_ASSERT(ctx);

Callers 3

llama_sampling_sampleFunction · 0.85
mainFunction · 0.85
sample_idFunction · 0.85

Calls 1

ggml_time_usFunction · 0.70

Tested by

no test coverage detected