| 3662 | // ggml_argmax |
| 3663 | |
| 3664 | struct ggml_tensor * ggml_argmax( |
| 3665 | struct ggml_context * ctx, |
| 3666 | struct ggml_tensor * a) { |
| 3667 | GGML_ASSERT(ggml_is_matrix(a)); |
| 3668 | bool is_node = false; |
| 3669 | |
| 3670 | if (a->grad) { |
| 3671 | GGML_ASSERT(false); |
| 3672 | is_node = true; |
| 3673 | } |
| 3674 | |
| 3675 | int64_t ne[GGML_MAX_DIMS] = { a->ne[1], 1, 1, 1 }; |
| 3676 | struct ggml_tensor * result = ggml_new_tensor(ctx, GGML_TYPE_I32, a->n_dims, ne); |
| 3677 | |
| 3678 | result->op = GGML_OP_ARGMAX; |
| 3679 | result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL; |
| 3680 | result->src[0] = a; |
| 3681 | |
| 3682 | return result; |
| 3683 | } |
| 3684 | |
| 3685 | // ggml_repeat |
| 3686 | |