| 4502 | } |
| 4503 | |
| 4504 | struct ggml_tensor * ggml_reshape_1d( |
| 4505 | struct ggml_context * ctx, |
| 4506 | struct ggml_tensor * a, |
| 4507 | int64_t ne0) { |
| 4508 | GGML_ASSERT(ggml_is_contiguous(a)); |
| 4509 | GGML_ASSERT(ggml_nelements(a) == ne0); |
| 4510 | |
| 4511 | bool is_node = false; |
| 4512 | |
| 4513 | if (a->grad) { |
| 4514 | is_node = true; |
| 4515 | } |
| 4516 | |
| 4517 | const int64_t ne[1] = { ne0 }; |
| 4518 | struct ggml_tensor * result = ggml_new_tensor_impl(ctx, a->type, 1, ne, a, 0); |
| 4519 | ggml_format_name(result, "%s (reshaped)", a->name); |
| 4520 | |
| 4521 | result->op = GGML_OP_RESHAPE; |
| 4522 | result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL; |
| 4523 | result->src[0] = a; |
| 4524 | |
| 4525 | return result; |
| 4526 | } |
| 4527 | |
| 4528 | struct ggml_tensor * ggml_reshape_2d( |
| 4529 | struct ggml_context * ctx, |
no test coverage detected