don't use allocate hash_map on context
because the context has no_alloc=True when using memory allocator resulting in NULL data pointers
This commit is contained in:
parent
fc826c8ea8
commit
d43741540b
1 changed files with 9 additions and 11 deletions
|
@ -1392,16 +1392,8 @@ struct hash_map {
|
||||||
};
|
};
|
||||||
static const size_t HASH_MAP_SIZE = sizeof(struct hash_map);
|
static const size_t HASH_MAP_SIZE = sizeof(struct hash_map);
|
||||||
|
|
||||||
struct hash_map * new_hash_map(struct ggml_context * ctx, struct ggml_tensor * * out_buf) {
|
struct hash_map * new_hash_map() {
|
||||||
struct ggml_tensor * buf = ggml_new_tensor_1d(ctx, GGML_TYPE_I8, HASH_MAP_SIZE);
|
struct hash_map * result = new struct hash_map;
|
||||||
if (out_buf) {
|
|
||||||
* out_buf = buf;
|
|
||||||
}
|
|
||||||
struct hash_map * result = (struct hash_map *) ((char *) buf->data);
|
|
||||||
*result = (struct hash_map) {
|
|
||||||
/*.keys =*/ { NULL },
|
|
||||||
/*.vals =*/ { NULL },
|
|
||||||
};
|
|
||||||
for (int i=0; i<GGML_GRAPH_HASHTABLE_SIZE; ++i) {
|
for (int i=0; i<GGML_GRAPH_HASHTABLE_SIZE; ++i) {
|
||||||
result->keys[i] = NULL;
|
result->keys[i] = NULL;
|
||||||
result->vals[i] = NULL;
|
result->vals[i] = NULL;
|
||||||
|
@ -1409,6 +1401,10 @@ struct hash_map * new_hash_map(struct ggml_context * ctx, struct ggml_tensor * *
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void free_hash_map(struct hash_map * map) {
|
||||||
|
delete map;
|
||||||
|
}
|
||||||
|
|
||||||
struct ggml_tensor * ggml_recompute_graph_node(
|
struct ggml_tensor * ggml_recompute_graph_node(
|
||||||
struct ggml_context * ctx,
|
struct ggml_context * ctx,
|
||||||
struct ggml_cgraph * graph,
|
struct ggml_cgraph * graph,
|
||||||
|
@ -1471,7 +1467,7 @@ void ggml_build_backward_gradient_checkpointing(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct hash_map * replacements = new_hash_map(ctx, NULL);
|
struct hash_map * replacements = new_hash_map();
|
||||||
|
|
||||||
// insert checkpoints in replacements
|
// insert checkpoints in replacements
|
||||||
for (int i = 0; i < n_checkpoints; ++i) {
|
for (int i = 0; i < n_checkpoints; ++i) {
|
||||||
|
@ -1498,6 +1494,8 @@ void ggml_build_backward_gradient_checkpointing(
|
||||||
// insert rewritten backward node with replacements made into resulting backward graph gb
|
// insert rewritten backward node with replacements made into resulting backward graph gb
|
||||||
ggml_build_forward_expand(gb, node);
|
ggml_build_forward_expand(gb, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free_hash_map(replacements);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ggml_tensor * llama_build_train_graphs(
|
struct ggml_tensor * llama_build_train_graphs(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue