| 4551 | } |
| 4552 | |
| 4553 | struct ggml_tensor * ggml_reshape_3d( |
| 4554 | struct ggml_context * ctx, |
| 4555 | struct ggml_tensor * a, |
| 4556 | int64_t ne0, |
| 4557 | int64_t ne1, |
| 4558 | int64_t ne2) { |
| 4559 | GGML_ASSERT(ggml_is_contiguous(a)); |
| 4560 | GGML_ASSERT(ggml_nelements(a) == ne0*ne1*ne2); |
| 4561 | |
| 4562 | bool is_node = false; |
| 4563 | |
| 4564 | if (a->grad) { |
| 4565 | is_node = true; |
| 4566 | } |
| 4567 | |
| 4568 | const int64_t ne[3] = { ne0, ne1, ne2 }; |
| 4569 | struct ggml_tensor * result = ggml_new_tensor_impl(ctx, a->type, 3, ne, a, 0); |
| 4570 | ggml_format_name(result, "%s (reshaped)", a->name); |
| 4571 | |
| 4572 | result->op = GGML_OP_RESHAPE; |
| 4573 | result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL; |
| 4574 | result->src[0] = a; |
| 4575 | |
| 4576 | return result; |
| 4577 | } |
| 4578 | |
| 4579 | struct ggml_tensor * ggml_reshape_4d( |
| 4580 | struct ggml_context * ctx, |
no test coverage detected