| 4348 | // ggml_cpy |
| 4349 | |
| 4350 | static 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 | |
| 4379 | struct ggml_tensor * ggml_cpy( |
| 4380 | struct ggml_context * ctx, |
no test coverage detected