| 248 | } |
| 249 | |
| 250 | static bark_token gpt_sample( |
| 251 | std::vector<float>& logits, |
| 252 | std::mt19937& rng, |
| 253 | float temp, |
| 254 | float* eos_p, |
| 255 | int64_t* t_sample_us, |
| 256 | int64_t* n_sample) { |
| 257 | int64_t t_sample_start_us = ggml_time_us(); |
| 258 | |
| 259 | bark_token res; |
| 260 | if (temp == 0.0f) { |
| 261 | res = gpt_argmax_sample(logits, eos_p); |
| 262 | } else { |
| 263 | res = gpt_multinomial_sample(logits, rng, temp, eos_p); |
| 264 | } |
| 265 | |
| 266 | int64_t t_sample_end_us = ggml_time_us(); |
| 267 | *t_sample_us += (t_sample_end_us - t_sample_start_us); |
| 268 | *n_sample += 1; |
| 269 | |
| 270 | return res; |
| 271 | } |
| 272 | |
| 273 | static bool ggml_quantize_weights( |
| 274 | std::ifstream& fin, |
no test coverage detected