| 363 | } |
| 364 | |
| 365 | static struct ggml_dyn_tallocr * ggml_dyn_tallocr_new(size_t alignment, size_t max_buffer_size) { |
| 366 | struct ggml_dyn_tallocr * alloc = (struct ggml_dyn_tallocr *)malloc(sizeof(struct ggml_dyn_tallocr)); |
| 367 | |
| 368 | *alloc = (struct ggml_dyn_tallocr) { |
| 369 | /*.alignment = */ alignment, |
| 370 | /*.max_chunk_size = */ MIN(max_buffer_size, SIZE_MAX/2), // clamp to avoid overflows |
| 371 | /*.chunks = */ {NULL}, |
| 372 | /*.n_chunks = */ 0, |
| 373 | #ifdef GGML_ALLOCATOR_DEBUG |
| 374 | /*.allocated_tensors = */ {{0}}, |
| 375 | #endif |
| 376 | }; |
| 377 | |
| 378 | ggml_dyn_tallocr_reset(alloc); |
| 379 | |
| 380 | return alloc; |
| 381 | } |
| 382 | |
| 383 | static void ggml_dyn_tallocr_free(struct ggml_dyn_tallocr * alloc) { |
| 384 | for (int i = 0; i < alloc->n_chunks; ++i) { |
no test coverage detected