diff options
author | slaren <slarengh@gmail.com> | 2023-07-25 14:32:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-25 15:32:20 +0300 |
commit | da1889834a036a63ead2b0ca5c9ed8967712568c (patch) | |
tree | 0cdebeac93a7ff69bfc8b4cec1307d74d984f79c /ggml.h | |
parent | 82552b7f5403ca13957ac9a2cdc1732470057b62 (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.h | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -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; |