| 4803 | // ggml_get_rows |
| 4804 | |
| 4805 | struct ggml_tensor * ggml_get_rows( |
| 4806 | struct ggml_context * ctx, |
| 4807 | struct ggml_tensor * a, |
| 4808 | struct ggml_tensor * b) { |
| 4809 | GGML_ASSERT(ggml_is_matrix(a) && ggml_is_vector(b) && b->type == GGML_TYPE_I32); |
| 4810 | |
| 4811 | bool is_node = false; |
| 4812 | |
| 4813 | if (a->grad || b->grad) { |
| 4814 | is_node = true; |
| 4815 | } |
| 4816 | |
| 4817 | // TODO: implement non F32 return |
| 4818 | //struct ggml_tensor * result = ggml_new_tensor_2d(ctx, a->type, a->ne[0], b->ne[0]); |
| 4819 | struct ggml_tensor * result = ggml_new_tensor_2d(ctx, GGML_TYPE_F32, a->ne[0], b->ne[0]); |
| 4820 | |
| 4821 | result->op = GGML_OP_GET_ROWS; |
| 4822 | result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL; |
| 4823 | result->src[0] = a; |
| 4824 | result->src[1] = b; |
| 4825 | |
| 4826 | return result; |
| 4827 | } |
| 4828 | |
| 4829 | // ggml_get_rows_back |
| 4830 | |