Spaces:
Running
Running
slaren
commited on
alloc : fix allocation data of pre-allocated leafs
Browse files- ggml-alloc.c +7 -2
ggml-alloc.c
CHANGED
|
@@ -701,8 +701,13 @@ bool ggml_gallocr_reserve_n(ggml_gallocr_t galloc, struct ggml_cgraph * graph, c
|
|
| 701 |
struct ggml_tensor * leaf = graph->leafs[i];
|
| 702 |
struct hash_node * hn = ggml_gallocr_hash_get(galloc, leaf);
|
| 703 |
galloc->leaf_allocs[i].buffer_id = hn->buffer_id;
|
| 704 |
-
|
| 705 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 706 |
}
|
| 707 |
|
| 708 |
// reallocate buffers if needed
|
|
|
|
| 701 |
struct ggml_tensor * leaf = graph->leafs[i];
|
| 702 |
struct hash_node * hn = ggml_gallocr_hash_get(galloc, leaf);
|
| 703 |
galloc->leaf_allocs[i].buffer_id = hn->buffer_id;
|
| 704 |
+
if (leaf->view_src || leaf->data) {
|
| 705 |
+
galloc->leaf_allocs[i].leaf.offset = SIZE_MAX;
|
| 706 |
+
galloc->leaf_allocs[i].leaf.size_max = 0;
|
| 707 |
+
} else {
|
| 708 |
+
galloc->leaf_allocs[i].leaf.offset = hn->offset;
|
| 709 |
+
galloc->leaf_allocs[i].leaf.size_max = ggml_backend_buft_get_alloc_size(galloc->bufts[hn->buffer_id], leaf);
|
| 710 |
+
}
|
| 711 |
}
|
| 712 |
|
| 713 |
// reallocate buffers if needed
|