| 498 | } |
| 499 | |
| 500 | void ggml_backend_tensor_copy_async(ggml_backend_t backend_src, ggml_backend_t backend_dst, const struct ggml_tensor * src, struct ggml_tensor * dst) { |
| 501 | GGML_ASSERT(ggml_are_same_layout(src, dst) && "cannot copy tensors with different layouts"); |
| 502 | |
| 503 | if (src == dst) { |
| 504 | return; |
| 505 | } |
| 506 | |
| 507 | GGML_ASSERT(backend_dst); |
| 508 | if (backend_dst->iface.cpy_tensor_async != NULL) { |
| 509 | if (backend_dst->iface.cpy_tensor_async(backend_src, backend_dst, src, dst)) { |
| 510 | return; |
| 511 | } |
| 512 | } |
| 513 | |
| 514 | // an async copy would normally happen after all the queued operations on both backends are completed |
| 515 | // to simulate the same behavior, we need to synchronize both backends first, and do a blocking copy |
| 516 | ggml_backend_synchronize(backend_src); |
| 517 | ggml_backend_synchronize(backend_dst); |
| 518 | ggml_backend_tensor_copy(src, dst); |
| 519 | } |
| 520 | |
| 521 | // events |
| 522 |
no test coverage detected