This test assumes a max of 16 buffer chunks, and tries to allocate tensors that would require more. Expectation is that the last buffer should grow to fit everything, leaving it to the backend to error out if it can't allocate that much.
| 326 | // require more. Expectation is that the last buffer should grow to fit everything, |
| 327 | // leaving it to the backend to error out if it can't allocate that much. |
| 328 | static void test_not_enough_chunks() { |
| 329 | const int max_chunks = 16; |
| 330 | const int max_size = 8; |
| 331 | |
| 332 | dummy_backend backend = dummy_backend_init(max_size); |
| 333 | auto [ctx, graph, ctx_ptr] = make_context(); |
| 334 | |
| 335 | ggml_tensor * x[max_chunks + 1]; |
| 336 | for (int i = 0; i < max_chunks + 1; ++i) { |
| 337 | x[i] = make_input_with_size(ctx, max_size); |
| 338 | } |
| 339 | ggml_tensor * acc = x[0]; |
| 340 | for (int i = 0; i < max_chunks; ++i) { |
| 341 | acc = ggml_add(ctx, acc, x[i + 1]); |
| 342 | } |
| 343 | assign_names(ctx); |
| 344 | |
| 345 | ggml_gallocr_ptr galloc = allocate_graph(graph, acc, &backend.buffer_type); |
| 346 | check_all_allocated(graph); |
| 347 | check_no_overlap(graph); |
| 348 | GGML_ASSERT(backend.context->allocated_total() > max_chunks * max_size); |
| 349 | } |
| 350 | |
| 351 | // Fill up leftover unallocated space of a chunk after allocating a large tensor that |
| 352 | // requires a new chunk. |
nothing calls this directly
no test coverage detected