| 539 | } |
| 540 | |
| 541 | void llama_context::synchronize() { |
| 542 | if (!sched) { |
| 543 | return; |
| 544 | } |
| 545 | |
| 546 | ggml_backend_sched_synchronize(sched.get()); |
| 547 | |
| 548 | // FIXME: if multiple single tokens are evaluated without a synchronization, |
| 549 | // the stats will be added to the prompt evaluation stats |
| 550 | // this should only happen when using batch size 1 to evaluate a batch |
| 551 | |
| 552 | // add the evaluation to the stats |
| 553 | if (n_queued_tokens == 1) { |
| 554 | if (!cparams.no_perf) { |
| 555 | t_eval_us += ggml_time_us() - t_compute_start_us; |
| 556 | } |
| 557 | n_eval++; |
| 558 | } else if (n_queued_tokens > 1) { |
| 559 | if (!cparams.no_perf) { |
| 560 | t_p_eval_us += ggml_time_us() - t_compute_start_us; |
| 561 | } |
| 562 | n_p_eval += n_queued_tokens; |
| 563 | } |
| 564 | |
| 565 | // get a more accurate load time, upon first eval |
| 566 | if (n_queued_tokens > 0 && !has_evaluated_once) { |
| 567 | t_load_us = ggml_time_us() - t_start_us; |
| 568 | has_evaluated_once = true; |
| 569 | } |
| 570 | |
| 571 | n_queued_tokens = 0; |
| 572 | t_compute_start_us = 0; |
| 573 | } |
| 574 | |
| 575 | const llama_model & llama_context::get_model() const { |
| 576 | return model; |
no test coverage detected