Skip to content

Commit b7a9d40

Browse files
committed
examples: refine tensor dump in examples/benchmark/benchmark-matmult.cpp
1 parent 3695a2b commit b7a9d40

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

examples/benchmark/benchmark-matmult.cpp

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "common.h"
22
#include "ggml.h"
3+
#include "ggml-impl.h"
34

45
#include <locale.h>
56
#include <assert.h>
@@ -38,18 +39,6 @@ typedef struct {
3839
int8_t qs[QK8_0]; // quants
3940
} block_q8_0;
4041

41-
static inline float ggml_compute_fp16_to_fp32(uint16_t h) {
42-
#if defined(__ARM_NEON)
43-
__fp16 tmp;
44-
memcpy(&tmp, &h, sizeof(uint16_t));
45-
return (float) tmp;
46-
#else
47-
uint16_t tmp;
48-
memcpy(&tmp, &h, sizeof(uint16_t));
49-
return (float) tmp;
50-
#endif
51-
}
52-
5342
static float tensor_sum_elements(const ggml_tensor * tensor) {
5443
double sum = 0;
5544
float floatvalue = 0;
@@ -75,7 +64,7 @@ static float tensor_sum_elements(const ggml_tensor * tensor) {
7564
for (int j = 0; j < tensor->ne[1]; j++) {
7665
for (int k = 0; k < tensor->ne[0]; k++) {
7766
shortvalue = ((unsigned short *) tensor->data)[j * tensor->ne[0] + k];
78-
floatvalue = ggml_compute_fp16_to_fp32(shortvalue);
67+
floatvalue = GGML_FP16_TO_FP32(shortvalue);
7968
sum += floatvalue;
8069
}
8170
}
@@ -87,7 +76,7 @@ static float tensor_sum_elements(const ggml_tensor * tensor) {
8776
for (int j = 0; j < tensor->ne[1]; j++) {
8877
blocks = tensor->ne[0] / QK8_0;
8978
for (int i = 0; i < blocks; i++) {
90-
floatvalue = ggml_compute_fp16_to_fp32(quant_datas[j * blocks + i].d);
79+
floatvalue = GGML_FP16_TO_FP32(quant_datas[j * blocks + i].d);
9180
for (int k = 0; k < QK8_0; k++) {
9281
sum += (quant_datas[j * blocks + i].qs[k] * floatvalue);
9382
}

0 commit comments

Comments
 (0)