| 3640 | // ggml_mean |
| 3641 | |
| 3642 | struct ggml_tensor * ggml_mean( |
| 3643 | struct ggml_context * ctx, |
| 3644 | struct ggml_tensor * a) { |
| 3645 | bool is_node = false; |
| 3646 | |
| 3647 | if (a->grad) { |
| 3648 | GGML_ASSERT(false); // TODO: implement |
| 3649 | is_node = true; |
| 3650 | } |
| 3651 | |
| 3652 | int64_t ne[GGML_MAX_DIMS] = { 1, a->ne[1], a->ne[2], a->ne[3] }; |
| 3653 | struct ggml_tensor * result = ggml_new_tensor(ctx, GGML_TYPE_F32, a->n_dims, ne); |
| 3654 | |
| 3655 | result->op = GGML_OP_MEAN; |
| 3656 | result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL; |
| 3657 | result->src[0] = a; |
| 3658 | |
| 3659 | return result; |
| 3660 | } |
| 3661 | |
| 3662 | // ggml_argmax |
| 3663 | |