MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / test_reallocation

Function test_reallocation

tests/test-alloc.cpp:553–584  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

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.
553static 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
586static void run(const char * name, void (*f)()) {
587 printf("%s ", name);

Callers

nothing calls this directly

Calls 13

dummy_backend_initFunction · 0.85
make_contextFunction · 0.85
make_input_with_sizeFunction · 0.85
ggml_view_1dFunction · 0.85
ggml_addFunction · 0.85
assign_namesFunction · 0.85
allocate_graphFunction · 0.85
check_all_allocatedFunction · 0.85
ggml_set_outputFunction · 0.85
ggml_gallocr_alloc_graphFunction · 0.85
allocated_totalMethod · 0.80

Tested by

no test coverage detected