MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / test_reuse_and_free

Function test_reuse_and_free

subprojects/llama.cpp/tests/test-alloc.cpp:391–412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

389}
390
391static 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
414static void test_merge_free_block(size_t max_buffer_size) {
415 dummy_backend backend = dummy_backend_init(max_buffer_size);

Callers

nothing calls this directly

Calls 13

dummy_backend_initFunction · 0.85
make_contextFunction · 0.85
make_input_with_sizeFunction · 0.85
ggml_addFunction · 0.85
ggml_padFunction · 0.85
ggml_scaleFunction · 0.85
ggml_view_1dFunction · 0.85
assign_namesFunction · 0.85
allocate_graphFunction · 0.85
check_all_allocatedFunction · 0.85
check_no_overlapFunction · 0.85
check_max_sizeFunction · 0.85

Tested by

no test coverage detected