| 8062 | // ggml_compute_forward_sum |
| 8063 | |
| 8064 | static void ggml_compute_forward_sum_f32( |
| 8065 | const struct ggml_compute_params * params, |
| 8066 | const struct ggml_tensor * src0, |
| 8067 | struct ggml_tensor * dst) { |
| 8068 | assert(params->ith == 0); |
| 8069 | assert(ggml_is_scalar(dst)); |
| 8070 | |
| 8071 | if (params->type == GGML_TASK_INIT || params->type == GGML_TASK_FINALIZE) { |
| 8072 | return; |
| 8073 | } |
| 8074 | |
| 8075 | assert(ggml_is_scalar(dst)); |
| 8076 | assert(src0->nb[0] == sizeof(float)); |
| 8077 | |
| 8078 | GGML_TENSOR_LOCALS(int64_t, ne0, src0, ne) |
| 8079 | GGML_TENSOR_LOCALS(size_t, nb0, src0, nb) |
| 8080 | |
| 8081 | ggml_float sum = 0; |
| 8082 | ggml_float row_sum = 0; |
| 8083 | |
| 8084 | for (int64_t i03 = 0; i03 < ne03; i03++) { |
| 8085 | for (int64_t i02 = 0; i02 < ne02; i02++) { |
| 8086 | for (int64_t i01 = 0; i01 < ne01; i01++) { |
| 8087 | ggml_vec_sum_f32_ggf(ne00, |
| 8088 | &row_sum, |
| 8089 | (float *) ((char *) src0->data + i01*nb01 + i02*nb02 + i03*nb03)); |
| 8090 | sum += row_sum; |
| 8091 | } |
| 8092 | } |
| 8093 | } |
| 8094 | ((float *) dst->data)[0] = sum; |
| 8095 | } |
| 8096 | |
| 8097 | static void ggml_compute_forward_sum_f16( |
| 8098 | const struct ggml_compute_params * params, |
no test coverage detected