| 3921 | result->src[0] = a; |
| 3922 | result->src[1] = b; |
| 3923 | |
| 3924 | return result; |
| 3925 | } |
| 3926 | |
| 3927 | // ggml_set_rows |
| 3928 | |
| 3929 | struct ggml_tensor * ggml_set_rows( |
| 3930 | struct ggml_context * ctx, |
| 3931 | struct ggml_tensor * a, |
| 3932 | struct ggml_tensor * b, |
| 3933 | struct ggml_tensor * c) { |
| 3934 | GGML_ASSERT(a->ne[0] == b->ne[0]); |
| 3935 | GGML_ASSERT(a->ne[2] == b->ne[2]); |
| 3936 | GGML_ASSERT(a->ne[3] == b->ne[3]); |
| 3937 | GGML_ASSERT(b->ne[1] == c->ne[0]); |
| 3938 | GGML_ASSERT(b->ne[2] % c->ne[1] == 0); |
| 3939 | GGML_ASSERT(b->ne[3] % c->ne[2] == 0); |
| 3940 | GGML_ASSERT(c->ne[3] == 1); |
| 3941 | GGML_ASSERT(b->type == GGML_TYPE_F32); |
| 3942 | GGML_ASSERT(c->type == GGML_TYPE_I64 || c->type == GGML_TYPE_I32); |
| 3943 | |
| 3944 | GGML_ASSERT(ggml_is_contiguous_rows(a)); |
| 3945 | GGML_ASSERT(ggml_is_contiguous_rows(b)); |
| 3946 | |
| 3947 | struct ggml_tensor * result = ggml_view_tensor(ctx, a); |
| 3948 | |
| 3949 | result->op = GGML_OP_SET_ROWS; |
| 3950 | result->src[0] = b; |
| 3951 | result->src[1] = c; |
| 3952 | result->src[2] = a; // note: order is weird due to legacy reasons (https://github.com/ggml-org/llama.cpp/pull/16063#discussion_r2385795931) |