Skip to content

Commit 059afdb

Browse files
committed
fix dyn_tallocr_max_size and initialization
1 parent 973d55b commit 059afdb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

ggml/src/ggml-alloc.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ static struct ggml_dyn_tallocr * ggml_dyn_tallocr_new(size_t alignment, size_t m
345345
/*.alignment = */ alignment,
346346
/*.n_free_blocks = */ 0,
347347
/*.n_chunks = */ 0,
348-
/*.free_blocks = */ {{0}},
348+
/*.free_blocks = */ {{{0}, 0}},
349349
/*.max_size = */ {0},
350350
/*.max_chunk_size = */ max_buffer_size,
351351
#ifdef GGML_ALLOCATOR_DEBUG
@@ -363,7 +363,11 @@ static void ggml_dyn_tallocr_free(struct ggml_dyn_tallocr * alloc) {
363363
}
364364

365365
static size_t ggml_dyn_tallocr_max_size(struct ggml_dyn_tallocr * alloc) {
366-
return alloc->max_size[alloc->n_chunks - 1];
366+
size_t max_size = 0;
367+
for (int i = 0; i < alloc->n_chunks; i++) {
368+
max_size += alloc->max_size[i];
369+
}
370+
return max_size;
367371
}
368372

369373

0 commit comments

Comments
 (0)