MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / ggml_compute_forward_get_rows_f16

Function ggml_compute_forward_get_rows_f16

ggml.c:10347–10373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10345}
10346
10347static void ggml_compute_forward_get_rows_f16(
10348 const struct ggml_compute_params * params,
10349 const struct ggml_tensor * src0,
10350 const struct ggml_tensor * src1,
10351 struct ggml_tensor * dst) {
10352 assert(params->ith == 0);
10353
10354 if (params->type == GGML_TASK_INIT || params->type == GGML_TASK_FINALIZE) {
10355 return;
10356 }
10357
10358 const int nc = src0->ne[0];
10359 const int nr = ggml_nelements(src1);
10360
10361 assert( dst->ne[0] == nc);
10362 assert( dst->ne[1] == nr);
10363 assert(src0->nb[0] == sizeof(ggml_fp16_t));
10364
10365 for (int i = 0; i < nr; ++i) {
10366 const int r = ((int32_t *) src1->data)[i];
10367
10368 for (int j = 0; j < nc; ++j) {
10369 ggml_fp16_t v = ((ggml_fp16_t *) ((char *) src0->data + r*src0->nb[1]))[j];
10370 ((float *) ((char *) dst->data + i*dst->nb[1]))[j] = GGML_FP16_TO_FP32(v);
10371 }
10372 }
10373}
10374
10375static void ggml_compute_forward_get_rows_f32(
10376 const struct ggml_compute_params * params,

Callers 1

Calls 1

ggml_nelementsFunction · 0.70

Tested by

no test coverage detected