summaryrefslogtreecommitdiff
path: root/ggml.h
diff options
context:
space:
mode:
authorunbounded <haakon@likedan.net>2023-04-08 00:09:18 +0200
committerGitHub <noreply@github.com>2023-04-08 00:09:18 +0200
commit62cfc54f77e519057110265b52b0d614fa363e2a (patch)
tree899b22495ef99e5e1661891c7ec0fd6de45aa43e /ggml.h
parent698f7b5d6316a1f8453b3b32fd0d637d24952ffd (diff)
Add quantize-stats command for testing quantization (#728)
Command that calculates some statistics over the errors introduced by quantization, like mean square error, max error and some percentile errors for layer weights. Should be useful for testing quantization improvements. Exposes some internal state from ggml and llama for testing
Diffstat (limited to 'ggml.h')
-rw-r--r--ggml.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/ggml.h b/ggml.h
index 3c94efc3..2c636c2a 100644
--- a/ggml.h
+++ b/ggml.h
@@ -783,6 +783,30 @@ int ggml_cpu_has_blas(void);
int ggml_cpu_has_sse3(void);
int ggml_cpu_has_vsx(void);
+
+//
+// Internal types and functions exposed for tests and benchmarks
+//
+
+#ifdef __cplusplus
+// restrict not standard in C++
+#define GGML_RESTRICT
+#else
+#define GGML_RESTRICT restrict
+#endif
+typedef void (*dequantize_row_q_t)(const void * GGML_RESTRICT x, float * GGML_RESTRICT y, int k);
+typedef void (*quantize_row_q_t)(const float * GGML_RESTRICT x, void * GGML_RESTRICT y, int k);
+typedef void (*vec_dot_q_t)(const int n, float * GGML_RESTRICT s, const void * GGML_RESTRICT x, const void * GGML_RESTRICT y);
+
+typedef struct {
+ dequantize_row_q_t dequantize_row_q;
+ quantize_row_q_t quantize_row_q;
+ quantize_row_q_t quantize_row_q_reference;
+ vec_dot_q_t vec_dot_q;
+} quantize_fns_t;
+
+quantize_fns_t ggml_internal_get_quantize_fn(size_t i);
+
#ifdef __cplusplus
}
#endif