Check that views don't require any extra memory
| 369 | |
| 370 | // Check that views don't require any extra memory |
| 371 | static void test_view_inplace() { |
| 372 | dummy_backend backend = dummy_backend_init(32); |
| 373 | auto [ctx, graph, ctx_ptr] = make_context(); |
| 374 | |
| 375 | ggml_tensor * x[6]; |
| 376 | x[0] = make_input_1d(ctx, 4); // chunk 0, [0, 16) |
| 377 | x[1] = ggml_reshape_2d(ctx, x[0], 2, 2); // view of x0 |
| 378 | x[2] = ggml_permute(ctx, x[1], 1, 0, 2, 3); // view of x0 |
| 379 | x[3] = ggml_view_1d(ctx, x[2], 2, 4); // view of x0 |
| 380 | x[4] = make_input_1d(ctx, 2); // chunk 0, [16, 24) |
| 381 | x[5] = ggml_add(ctx, x[3], x[4]); // reuse (inplace add) |
| 382 | assign_names(ctx); |
| 383 | |
| 384 | ggml_gallocr_ptr galloc = allocate_graph(graph, x[5], &backend.buffer_type); |
| 385 | check_all_allocated(graph); |
| 386 | check_no_overlap(graph); |
| 387 | check_max_size(ctx); |
| 388 | GGML_ASSERT(backend.context->allocated_total() <= 24); |
| 389 | } |
| 390 | |
| 391 | static void test_reuse_and_free() { |
| 392 | dummy_backend backend = dummy_backend_init(40); |
nothing calls this directly
no test coverage detected