| 389 | } |
| 390 | |
| 391 | static void test_reuse_and_free() { |
| 392 | dummy_backend backend = dummy_backend_init(40); |
| 393 | auto [ctx, graph, ctx_ptr] = make_context(); |
| 394 | |
| 395 | ggml_tensor * x[9]; |
| 396 | x[0] = make_input_with_size(ctx, 24); |
| 397 | x[1] = make_input_with_size(ctx, 8); |
| 398 | x[2] = make_input_with_size(ctx, 8); |
| 399 | x[3] = ggml_add(ctx, x[1], x[2]); // reuse, free x2 |
| 400 | x[4] = ggml_pad(ctx, x[0], 2, 0, 0, 0); // alloc new buffer, free x0 |
| 401 | x[5] = ggml_scale(ctx, x[4], 2.0f); // alloc from free block |
| 402 | x[6] = ggml_add(ctx, x[4], x[5]); // reuse, free x5 |
| 403 | x[7] = ggml_view_1d(ctx, x[6], 2, 8); // view |
| 404 | x[8] = ggml_add(ctx, x[3], x[7]); // reuse |
| 405 | assign_names(ctx); |
| 406 | |
| 407 | ggml_gallocr_ptr galloc = allocate_graph(graph, x[8], &backend.buffer_type); |
| 408 | check_all_allocated(graph); |
| 409 | check_no_overlap(graph); |
| 410 | check_max_size(ctx); |
| 411 | GGML_ASSERT(backend.context->allocated_total() <= 40 + 32 + 32); |
| 412 | } |
| 413 | |
| 414 | static void test_merge_free_block(size_t max_buffer_size) { |
| 415 | dummy_backend backend = dummy_backend_init(max_buffer_size); |
nothing calls this directly
no test coverage detected