| 177 | */ |
| 178 | |
| 179 | static 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 | |
| 203 | static void llama_sampler_softmax_impl(llama_token_data_array * cur_p) { |
| 204 | GGML_ASSERT(cur_p->size > 0); |
no outgoing calls
no test coverage detected