| 225 | } |
| 226 | |
| 227 | void ggml_tallocr_reset(ggml_tallocr_t alloc) { |
| 228 | alloc->n_free_blocks = 1; |
| 229 | size_t align_offset = aligned_offset(alloc->base, 0, alloc->alignment); |
| 230 | alloc->free_blocks[0].addr = (char *)alloc->base + align_offset; |
| 231 | |
| 232 | if (alloc->measure) { |
| 233 | alloc->free_blocks[0].size = SIZE_MAX/2; // restrict maximum size of a measure allocator to half size_t max to avoid overflows |
| 234 | } else { |
| 235 | alloc->free_blocks[0].size = ggml_backend_buffer_get_size(alloc->buffer) - align_offset; |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | ggml_tallocr_t ggml_tallocr_new(void * data, size_t size, size_t alignment) { |
| 240 | struct ggml_backend_buffer * buffer = ggml_backend_cpu_buffer_from_ptr(NULL, data, size); |
no test coverage detected