@@ -4373,12 +4373,12 @@ struct logit_info {
4373
4373
std::vector<llama_token_data> min_heap; // min-heap by logit
4374
4374
llama_token const k_min = std::min (static_cast <llama_token>(k), n_vocab);
4375
4375
min_heap.reserve (k_min);
4376
- for (llama_token token_id= 0 ; token_id< k_min ; ++token_id) {
4376
+ for (llama_token token_id = 0 ; token_id < k_min ; ++token_id) {
4377
4377
min_heap.push_back (get_token_data (token_id));
4378
4378
}
4379
4379
auto comp = [](llama_token_data const & a, llama_token_data const & b) { return a.logit > b.logit ; };
4380
4380
std::make_heap (min_heap.begin (), min_heap.end (), comp);
4381
- for (llama_token token_id= k_min ; token_id< n_vocab ; ++token_id) {
4381
+ for (llama_token token_id = k_min ; token_id < n_vocab ; ++token_id) {
4382
4382
if (min_heap.front ().logit < logits[token_id]) {
4383
4383
std::pop_heap (min_heap.begin (), min_heap.end (), comp);
4384
4384
min_heap.back ().id = token_id;
@@ -4489,9 +4489,9 @@ struct beam_search {
4489
4489
// Requires beams is not empty.
4490
4490
size_t find_common_prefix_length () {
4491
4491
size_t common_prefix_length = beams[0 ].tokens .size ();
4492
- for (size_t i= 1 ; i< beams.size () ; ++i) {
4492
+ for (size_t i = 1 ; i < beams.size () ; ++i) {
4493
4493
common_prefix_length = std::min (common_prefix_length, beams[i].tokens .size ());
4494
- for (size_t j= 0 ; j< common_prefix_length ; ++j) {
4494
+ for (size_t j = 0 ; j < common_prefix_length ; ++j) {
4495
4495
if (beams[0 ].tokens [j] != beams[i].tokens [j]) {
4496
4496
common_prefix_length = j;
4497
4497
break ;
@@ -4504,7 +4504,7 @@ struct beam_search {
4504
4504
// Construct beams_state to send back to caller via the callback function.
4505
4505
// Side effect: set common_prefix_length = find_common_prefix_length();
4506
4506
llama_beams_state get_beams_state (bool const last_call) {
4507
- for (size_t i= 0 ; i< beams.size () ; ++i) {
4507
+ for (size_t i = 0 ; i < beams.size () ; ++i) {
4508
4508
beam_views[i] = beams[i].view ();
4509
4509
}
4510
4510
common_prefix_length = find_common_prefix_length ();
@@ -4519,7 +4519,7 @@ struct beam_search {
4519
4519
void loop (llama_beam_search_callback_fn_t const callback, void * const callback_data) {
4520
4520
beams.push_back ({{}, 1 .0f , false }); // Start with one empty beam w/ probability = 1.0 and !eos.
4521
4521
auto const not_eos = [](llama_beam const & beam) { return !beam.eos ; };
4522
- for (int i= 0 ; i< n_predict && std::any_of (beams.begin (),beams.end (),not_eos) &&
4522
+ for (int i = 0 ; i < n_predict && std::any_of (beams.begin (),beams.end (),not_eos) &&
4523
4523
!beams[top_beam_index ()].eos ; ++i) {
4524
4524
callback (callback_data, get_beams_state (false )); // Sets common_prefix_length
4525
4525
update_beams_from_beam_views (); // Update values (p,eos) that callback may have changed.
@@ -4556,7 +4556,7 @@ struct beam_search {
4556
4556
4557
4557
// Copy (p,eos) for each beam which may have been changed by the callback.
4558
4558
void update_beams_from_beam_views () {
4559
- for (size_t i= 0 ; i< beams.size () ; ++i) {
4559
+ for (size_t i = 0 ; i < beams.size () ; ++i) {
4560
4560
beams[i].p = beam_views[i].p ;
4561
4561
beams[i].eos = beam_views[i].eos ;
4562
4562
}
0 commit comments