Skip to content

Commit

Permalink
review: modify codes as review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zhou.weiguo committed Jun 14, 2024
1 parent b7a9d40 commit b56b984
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion examples/benchmark/benchmark-matmult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,23 @@ static float tensor_sum_elements(const ggml_tensor * tensor) {
}

if (tensor->type == GGML_TYPE_Q8_0) {
int blocks = 0;
block_q8_0 * quant_datas = (block_q8_0 *)tensor->data;
#if 1
ggml_type_traits_t qtype = ggml_internal_get_type_traits(tensor->type);
float * float32 = (float*)malloc(tensor->ne[0] * tensor->ne[1]);
if (NULL == float32) {
printf("malloc faled\n");
return 0.0;
}
qtype.to_float(quant_datas, float32, tensor->ne[0] * tensor->ne[1]);
for (int j = 0; j < tensor->ne[1]; j++) {
for (int k = 0; k < tensor->ne[0]; k++) {
sum += float32[j * tensor->ne[0] + k];
}
}
free(float32);
#else
int blocks = 0;
for (int j = 0; j < tensor->ne[1]; j++) {
blocks = tensor->ne[0] / QK8_0;
for (int i = 0; i < blocks; i++) {
Expand All @@ -82,6 +97,7 @@ static float tensor_sum_elements(const ggml_tensor * tensor) {
}
}
}
#endif
}

return sum;
Expand Down

0 comments on commit b56b984

Please sign in to comment.