Skip to content

Commit

Permalink
alloc : fix allocation data of pre-allocated leafs
Browse files Browse the repository at this point in the history
  • Loading branch information
slaren authored and ggerganov committed Mar 16, 2024
1 parent 00d80ff commit 906c73b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ggml-alloc.c
Expand Up @@ -701,8 +701,13 @@ bool ggml_gallocr_reserve_n(ggml_gallocr_t galloc, struct ggml_cgraph * graph, c
struct ggml_tensor * leaf = graph->leafs[i];
struct hash_node * hn = ggml_gallocr_hash_get(galloc, leaf);
galloc->leaf_allocs[i].buffer_id = hn->buffer_id;
galloc->leaf_allocs[i].leaf.offset = hn->offset;
galloc->leaf_allocs[i].leaf.size_max = ggml_backend_buft_get_alloc_size(galloc->bufts[hn->buffer_id], leaf);
if (leaf->view_src || leaf->data) {
galloc->leaf_allocs[i].leaf.offset = SIZE_MAX;
galloc->leaf_allocs[i].leaf.size_max = 0;
} else {
galloc->leaf_allocs[i].leaf.offset = hn->offset;
galloc->leaf_allocs[i].leaf.size_max = ggml_backend_buft_get_alloc_size(galloc->bufts[hn->buffer_id], leaf);
}
}

// reallocate buffers if needed
Expand Down

0 comments on commit 906c73b

Please sign in to comment.