MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / ggml_cpy_impl

Function ggml_cpy_impl

ggml.c:4350–4377  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4348// ggml_cpy
4349
4350static struct ggml_tensor * ggml_cpy_impl(
4351 struct ggml_context * ctx,
4352 struct ggml_tensor * a,
4353 struct ggml_tensor * b,
4354 bool inplace) {
4355 GGML_ASSERT(ggml_nelements(a) == ggml_nelements(b));
4356
4357 bool is_node = false;
4358
4359 if (!inplace && (a->grad || b->grad)) {
4360 is_node = true;
4361 }
4362
4363 // make a view of the destination
4364 struct ggml_tensor * result = ggml_view_tensor(ctx, b);
4365 if (strlen(b->name) > 0) {
4366 ggml_format_name(result, "%s (copy of %s)", b->name, a->name);
4367 } else {
4368 ggml_format_name(result, "%s (copy)", a->name);
4369 }
4370
4371 result->op = GGML_OP_CPY;
4372 result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL;
4373 result->src[0] = a;
4374 result->src[1] = b;
4375
4376 return result;
4377}
4378
4379struct ggml_tensor * ggml_cpy(
4380 struct ggml_context * ctx,

Callers 2

ggml_cpyFunction · 0.70
ggml_cpy_inplaceFunction · 0.70

Calls 4

ggml_nelementsFunction · 0.70
ggml_view_tensorFunction · 0.70
ggml_format_nameFunction · 0.70
ggml_dup_tensorFunction · 0.70

Tested by

no test coverage detected