From 166b777be907ff6636a0b82c3b5aeb2170bbe4c6 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Sat, 30 Nov 2024 08:01:22 +0100 Subject: [PATCH] ggml: loop over all elements in view and src tensor --- fundamentals/ggml/src/views.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fundamentals/ggml/src/views.c b/fundamentals/ggml/src/views.c index c1859d4..f42fcdb 100644 --- a/fundamentals/ggml/src/views.c +++ b/fundamentals/ggml/src/views.c @@ -56,6 +56,7 @@ int main(int argc, char **argv) { ggml_backend_graph_compute(backend, gf); { + printf("Loop over all dimensions in view:\n"); float buf[6]; ggml_backend_tensor_get(view, buf, 0, sizeof(buf)); for (int row = 0; row < view->ne[1]; row++) { @@ -67,6 +68,16 @@ int main(int argc, char **argv) { } { + printf("Loop over all elements in view:\n"); + float buf[6]; + ggml_backend_tensor_get(view, buf, 0, sizeof(buf)); + for (int i = 0; i < ggml_nelements(view); i++) { + printf("buf[%d] = %f\n", i, buf[i]); + } + } + + { + printf("Loop over all elements in src tensor:\n"); float buf[6]; ggml_backend_tensor_get(x, buf, 0, sizeof(buf)); for (int i = 0; i < x->ne[0]; i++) {