| 8615 | } |
| 8616 | |
| 8617 | llama_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 | |
| 8633 | llama_token llama_sample_token(struct llama_context * ctx, llama_token_data_array * candidates) { |
| 8634 | GGML_ASSERT(ctx); |
no test coverage detected