MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / ggml_backend_tensor_copy

Function ggml_backend_tensor_copy

ggml/src/ggml-backend.cpp:477–498  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

475// backend copy
476
477void ggml_backend_tensor_copy(const struct ggml_tensor * src, struct ggml_tensor * dst) {
478 GGML_ASSERT(ggml_are_same_layout(src, dst) && "cannot copy tensors with different layouts");
479
480 if (src == dst) {
481 return;
482 }
483
484 if (ggml_backend_buffer_is_host(src->buffer)) {
485 ggml_backend_tensor_set(dst, src->data, 0, ggml_nbytes(src));
486 } else if (ggml_backend_buffer_is_host(dst->buffer)) {
487 ggml_backend_tensor_get(src, dst->data, 0, ggml_nbytes(src));
488 } else if (!ggml_backend_buffer_copy_tensor(src, dst)) {
489#ifndef NDEBUG
490 GGML_LOG_DEBUG("%s: warning: slow copy from %s to %s\n", __func__, ggml_backend_buffer_name(src->buffer), ggml_backend_buffer_name(dst->buffer));
491#endif // NDEBUG
492 size_t nbytes = ggml_nbytes(src);
493 void * data = malloc(nbytes);
494 ggml_backend_tensor_get(src, data, 0, nbytes);
495 ggml_backend_tensor_set(dst, data, 0, nbytes);
496 free(data);
497 }
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");

Callers 5

power_iterationFunction · 0.85
updateMethod · 0.85
graph_copy_init_tensorFunction · 0.85

Calls 7

ggml_are_same_layoutFunction · 0.85
ggml_backend_tensor_setFunction · 0.85
ggml_nbytesFunction · 0.85
ggml_backend_tensor_getFunction · 0.85
ggml_backend_buffer_nameFunction · 0.85

Tested by

no test coverage detected