| 4577 | } |
| 4578 | |
| 4579 | struct ggml_tensor * ggml_reshape_4d( |
| 4580 | struct ggml_context * ctx, |
| 4581 | struct ggml_tensor * a, |
| 4582 | int64_t ne0, |
| 4583 | int64_t ne1, |
| 4584 | int64_t ne2, |
| 4585 | int64_t ne3) { |
| 4586 | GGML_ASSERT(ggml_is_contiguous(a)); |
| 4587 | GGML_ASSERT(ggml_nelements(a) == ne0*ne1*ne2*ne3); |
| 4588 | |
| 4589 | bool is_node = false; |
| 4590 | |
| 4591 | if (a->grad) { |
| 4592 | is_node = true; |
| 4593 | } |
| 4594 | |
| 4595 | const int64_t ne[4] = { ne0, ne1, ne2, ne3 }; |
| 4596 | struct ggml_tensor * result = ggml_new_tensor_impl(ctx, a->type, 4, ne, a, 0); |
| 4597 | ggml_format_name(result, "%s (reshaped)", a->name); |
| 4598 | |
| 4599 | result->op = GGML_OP_RESHAPE; |
| 4600 | result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL; |
| 4601 | result->src[0] = a; |
| 4602 | |
| 4603 | return result; |
| 4604 | } |
| 4605 | |
| 4606 | static struct ggml_tensor * ggml_view_impl( |
| 4607 | struct ggml_context * ctx, |
no test coverage detected