aboutsummaryrefslogtreecommitdiff
path: root/ggml.h
diff options
context:
space:
mode:
authorslaren <slarengh@gmail.com>2023-07-25 14:32:20 +0200
committerGitHub <noreply@github.com>2023-07-25 15:32:20 +0300
commitda1889834a036a63ead2b0ca5c9ed8967712568c (patch)
tree0cdebeac93a7ff69bfc8b4cec1307d74d984f79c /ggml.h
parent82552b7f5403ca13957ac9a2cdc1732470057b62 (diff)
ggml : improve graph build time via hash table lookup (#2329)
* improve graph build time * ggml_tensor : use 1 bit per flag * use a hash table instead
Diffstat (limited to 'ggml.h')
-rw-r--r--ggml.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/ggml.h b/ggml.h
index 1870b62..c309f13 100644
--- a/ggml.h
+++ b/ggml.h
@@ -442,7 +442,7 @@ extern "C" {
void * extra; // extra things e.g. for ggml-cuda.cu
- char padding[8];
+ char padding[4];
};
static const size_t GGML_TENSOR_SIZE = sizeof(struct ggml_tensor);
@@ -463,6 +463,11 @@ extern "C" {
void * abort_callback_data;
};
+ // next prime after GGML_MAX_NODES
+ // #define GGML_GRAPH_HASHTABLE_SIZE 4099
+ // next prime after GGML_MAX_NODES * 2 (nodes + leafs)
+ #define GGML_GRAPH_HASHTABLE_SIZE 8273
+
// computation graph
struct ggml_cgraph {
int n_nodes;
@@ -472,6 +477,8 @@ extern "C" {
struct ggml_tensor * grads[GGML_MAX_NODES];
struct ggml_tensor * leafs[GGML_MAX_NODES];
+ void * visited_hash_table[GGML_GRAPH_HASHTABLE_SIZE];
+
// performance
int perf_runs;
int64_t perf_cycles;