| 4526 | } |
| 4527 | |
| 4528 | struct ggml_tensor * ggml_reshape_2d( |
| 4529 | struct ggml_context * ctx, |
| 4530 | struct ggml_tensor * a, |
| 4531 | int64_t ne0, |
| 4532 | int64_t ne1) { |
| 4533 | GGML_ASSERT(ggml_is_contiguous(a)); |
| 4534 | GGML_ASSERT(ggml_nelements(a) == ne0*ne1); |
| 4535 | |
| 4536 | bool is_node = false; |
| 4537 | |
| 4538 | if (a->grad) { |
| 4539 | is_node = true; |
| 4540 | } |
| 4541 | |
| 4542 | const int64_t ne[2] = { ne0, ne1 }; |
| 4543 | struct ggml_tensor * result = ggml_new_tensor_impl(ctx, a->type, 2, ne, a, 0); |
| 4544 | ggml_format_name(result, "%s (reshaped)", a->name); |
| 4545 | |
| 4546 | result->op = GGML_OP_RESHAPE; |
| 4547 | result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL; |
| 4548 | result->src[0] = a; |
| 4549 | |
| 4550 | return result; |
| 4551 | } |
| 4552 | |
| 4553 | struct ggml_tensor * ggml_reshape_3d( |
| 4554 | struct ggml_context * ctx, |
no test coverage detected