Skip to content

Commit

Permalink
ggml: add memcpy example to galloc.c
Browse files Browse the repository at this point in the history
  • Loading branch information
danbev committed Oct 5, 2024
1 parent e1a5145 commit eac84ae
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fundamentals/ggml/src/galloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "ggml-backend.h"

#include <stdio.h>
#include <string.h>

int main(int argc, char **argv) {
printf("GGML galloc (graph allocator) example\n");
Expand Down Expand Up @@ -34,6 +35,8 @@ int main(int argc, char **argv) {
ggml_backend_buffer_t buffer = ggml_backend_alloc_ctx_tensors(ctx, backend);
ggml_backend_tensor_set(a, a_data, 0, ggml_nbytes(a));
ggml_backend_tensor_set(b, b_data, 0, ggml_nbytes(b));
// For the CPU backend this is pretty much just a memcpy:
memcpy((char *)b->data + 0, b_data, ggml_nbytes(b));

ggml_gallocr_t galloc = ggml_gallocr_new(ggml_backend_get_default_buffer_type(backend));
ggml_gallocr_alloc_graph(galloc, c_graph);
Expand Down

0 comments on commit eac84ae

Please sign in to comment.