MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / ggml_backend_tensor_copy_async

Function ggml_backend_tensor_copy_async

external/ggml/src/ggml-backend.cpp:500–519  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

498}
499
500void 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

Callers 1

Calls 3

ggml_are_same_layoutFunction · 0.85
ggml_backend_synchronizeFunction · 0.85
ggml_backend_tensor_copyFunction · 0.85

Tested by

no test coverage detected