Test re-using gallocr for a different graph. The new graph has the same total size, but one of the chunks is larger, so reallocation is required.
| 551 | // Test re-using gallocr for a different graph. The new graph has the same |
| 552 | // total size, but one of the chunks is larger, so reallocation is required. |
| 553 | static void test_reallocation() { |
| 554 | dummy_backend backend = dummy_backend_init(32, /*align*/ 4); |
| 555 | ggml_gallocr_ptr galloc; |
| 556 | { |
| 557 | auto [ctx, graph, ctx_ptr] = make_context(); |
| 558 | ggml_tensor * x[4]; |
| 559 | x[0] = make_input_with_size(ctx, 24); |
| 560 | x[1] = make_input_with_size(ctx, 16); |
| 561 | x[2] = ggml_view_1d(ctx, x[0], 4, 0); |
| 562 | x[3] = ggml_add(ctx, x[2], x[1]); |
| 563 | assign_names(ctx); |
| 564 | |
| 565 | galloc = allocate_graph(graph, x[3], &backend.buffer_type); |
| 566 | check_all_allocated(graph); |
| 567 | GGML_ASSERT(backend.context->allocated_total() == 40); |
| 568 | } |
| 569 | { |
| 570 | auto [ctx, graph, ctx_ptr] = make_context(); |
| 571 | ggml_tensor * x[3]; |
| 572 | x[0] = make_input_with_size(ctx, 20); |
| 573 | x[1] = make_input_with_size(ctx, 20); |
| 574 | x[2] = ggml_add(ctx, x[0], x[1]); |
| 575 | assign_names(ctx); |
| 576 | ggml_set_output(x[2]); |
| 577 | ggml_build_forward_expand(graph, x[2]); |
| 578 | |
| 579 | bool result = ggml_gallocr_alloc_graph(galloc.get(), graph); |
| 580 | GGML_ASSERT(result); |
| 581 | check_all_allocated(graph); |
| 582 | GGML_ASSERT(backend.context->allocated_total() == 40); |
| 583 | } |
| 584 | } |
| 585 | |
| 586 | static void run(const char * name, void (*f)()) { |
| 587 | printf("%s ", name); |
nothing calls this directly
no test coverage detected