| 348 | } |
| 349 | |
| 350 | void llama_context::synchronize() { |
| 351 | ggml_backend_sched_synchronize(sched.get()); |
| 352 | |
| 353 | // FIXME: if multiple single tokens are evaluated without a synchronization, |
| 354 | // the stats will be added to the prompt evaluation stats |
| 355 | // this should only happen when using batch size 1 to evaluate a batch |
| 356 | |
| 357 | // add the evaluation to the stats |
| 358 | if (n_queued_tokens == 1) { |
| 359 | if (!cparams.no_perf) { |
| 360 | t_eval_us += ggml_time_us() - t_compute_start_us; |
| 361 | } |
| 362 | n_eval++; |
| 363 | } else if (n_queued_tokens > 1) { |
| 364 | if (!cparams.no_perf) { |
| 365 | t_p_eval_us += ggml_time_us() - t_compute_start_us; |
| 366 | } |
| 367 | n_p_eval += n_queued_tokens; |
| 368 | } |
| 369 | |
| 370 | // get a more accurate load time, upon first eval |
| 371 | if (n_queued_tokens > 0 && !has_evaluated_once) { |
| 372 | t_load_us = ggml_time_us() - t_start_us; |
| 373 | has_evaluated_once = true; |
| 374 | } |
| 375 | |
| 376 | n_queued_tokens = 0; |
| 377 | t_compute_start_us = 0; |
| 378 | } |
| 379 | |
| 380 | const llama_model & llama_context::get_model() const { |
| 381 | return model; |
no test coverage detected