| 10489 | } |
| 10490 | |
| 10491 | static void ggml_compute_forward_get_rows_back_f32( |
| 10492 | const struct ggml_compute_params * params, |
| 10493 | const struct ggml_tensor * src0, |
| 10494 | const struct ggml_tensor * src1, |
| 10495 | struct ggml_tensor * dst) { |
| 10496 | GGML_ASSERT(params->ith == 0); |
| 10497 | GGML_ASSERT(ggml_is_contiguous(dst)); |
| 10498 | |
| 10499 | // ggml_compute_forward_dup_same_cont(params, opt0, dst); |
| 10500 | |
| 10501 | if (params->type == GGML_TASK_INIT) { |
| 10502 | memset(dst->data, 0, ggml_nbytes(dst)); |
| 10503 | } |
| 10504 | |
| 10505 | if (params->type == GGML_TASK_INIT || params->type == GGML_TASK_FINALIZE) { |
| 10506 | return; |
| 10507 | } |
| 10508 | |
| 10509 | const int nc = src0->ne[0]; |
| 10510 | const int nr = ggml_nelements(src1); |
| 10511 | |
| 10512 | GGML_ASSERT( dst->ne[0] == nc); |
| 10513 | GGML_ASSERT(src0->nb[0] == sizeof(float)); |
| 10514 | |
| 10515 | for (int i = 0; i < nr; ++i) { |
| 10516 | const int r = ((int32_t *) src1->data)[i]; |
| 10517 | |
| 10518 | ggml_vec_add_f32(nc, |
| 10519 | (float *) ((char *) dst->data + r*dst->nb[1]), |
| 10520 | (float *) ((char *) dst->data + r*dst->nb[1]), |
| 10521 | (float *) ((char *) src0->data + i*src0->nb[1])); |
| 10522 | } |
| 10523 | } |
| 10524 | |
| 10525 | static void ggml_compute_forward_get_rows_back( |
| 10526 | const struct ggml_compute_params * params, |
no test coverage detected