Skip to content

Commit

Permalink
ggml: loop over all elements in view and src tensor
Browse files Browse the repository at this point in the history
  • Loading branch information
danbev committed Nov 30, 2024
1 parent 5869e0d commit 166b777
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions fundamentals/ggml/src/views.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand All @@ -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++) {
Expand Down

0 comments on commit 166b777

Please sign in to comment.