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

Function ggml_compute_forward_sum_f16

ggml.c:8097–8127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8095}
8096
8097static void ggml_compute_forward_sum_f16(
8098 const struct ggml_compute_params * params,
8099 const struct ggml_tensor * src0,
8100 struct ggml_tensor * dst) {
8101 assert(params->ith == 0);
8102 assert(ggml_is_scalar(dst));
8103
8104 if (params->type == GGML_TASK_INIT || params->type == GGML_TASK_FINALIZE) {
8105 return;
8106 }
8107
8108 assert(src0->nb[0] == sizeof(ggml_fp16_t));
8109
8110 GGML_TENSOR_LOCALS(int64_t, ne0, src0, ne)
8111 GGML_TENSOR_LOCALS(size_t, nb0, src0, nb)
8112
8113 float sum = 0;
8114 float row_sum = 0;
8115
8116 for (int64_t i03 = 0; i03 < ne03; i03++) {
8117 for (int64_t i02 = 0; i02 < ne02; i02++) {
8118 for (int64_t i01 = 0; i01 < ne01; i01++) {
8119 ggml_vec_sum_f16_ggf(ne00,
8120 &row_sum,
8121 (ggml_fp16_t *) ((char *) src0->data + i01 * nb01 + i02 * nb02 + i03 * nb03));
8122 sum += row_sum;
8123 }
8124 }
8125 }
8126 ((ggml_fp16_t *) dst->data)[0] = GGML_FP32_TO_FP16(sum);
8127}
8128
8129static void ggml_compute_forward_sum_i32(
8130 const struct ggml_compute_params * params,

Callers 1

ggml_compute_forward_sumFunction · 0.70

Calls 2

ggml_is_scalarFunction · 0.70
ggml_vec_sum_f16_ggfFunction · 0.70

Tested by

no test coverage detected