| 1443 | } |
| 1444 | |
| 1445 | static void copy_tensor_async_ints( |
| 1446 | const std::map<llama_seq_id, ggml_tensor*> & tensor_map, |
| 1447 | const buffer_view<llama_token> & sampled, |
| 1448 | const std::map<llama_seq_id, uint32_t> & seq_to_row, |
| 1449 | ggml_backend_sched_t sched) { |
| 1450 | if (!sampled.has_data()) { |
| 1451 | return; |
| 1452 | } |
| 1453 | |
| 1454 | for (const auto & [seq_id, tensor] : tensor_map) { |
| 1455 | auto it = seq_to_row.find(seq_id); |
| 1456 | if (it == seq_to_row.end()) { |
| 1457 | continue; |
| 1458 | } |
| 1459 | |
| 1460 | const uint32_t row = it->second; |
| 1461 | GGML_ASSERT(row < sampled.size); |
| 1462 | |
| 1463 | GGML_ASSERT(ggml_is_contiguous(tensor) && "sampled tokens tensor must be contiguous for async copy"); |
| 1464 | |
| 1465 | ggml_backend_t backend = ggml_backend_sched_get_tensor_backend(sched, tensor); |
| 1466 | ggml_backend_tensor_get_async(backend, tensor, sampled.data + row, 0, sizeof(sampled.data[row])); |
| 1467 | } |
| 1468 | } |
| 1469 | |
| 1470 | static void copy_tensor_async_floats( |
| 1471 | const std::map<llama_seq_id, ggml_tensor*> & tensor_map, |
no test coverage detected