From: Georgi Gerganov Date: Fri, 25 Aug 2023 13:56:09 +0000 (+0300) Subject: ggml : fix instructions for using data pointer X-Git-Tag: upstream/0.0.1642~1266 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=1a5d5f331de1d3c7ace40d86fe2373021a42f9ce;p=pkg%2Fggml%2Fsources%2Fggml ggml : fix instructions for using data pointer --- diff --git a/include/ggml/ggml.h b/include/ggml/ggml.h index 3c48fd27..2074fd04 100644 --- a/include/ggml/ggml.h +++ b/include/ggml/ggml.h @@ -130,13 +130,16 @@ // The data of the tensor is accessed via the "data" pointer. For example: // // { -// struct ggml_tensor * a = ggml_new_tensor_2d(ctx, GGML_TYPE_F32, 2, 3); +// const int nx = 2; +// const int ny = 3; // -// // a[2, 1] = 1.0f; -// *(float *) ((char *) a->data + 2*a->nb[1] + 1*a->nb[0]) = 1.0f; +// struct ggml_tensor * a = ggml_new_tensor_2d(ctx, GGML_TYPE_F32, nx, ny); // -// // a[0, 2] = 2.0f; -// *(float *) ((char *) a->data + 0*a->nb[1] + 2*a->nb[0]) = 2.0f; +// for (int y = 0; y < ny; y++) { +// for (int x = 0; x < nx; x++) { +// *(float *) ((char *) a->data + y*a->nb[1] + x*a->nb[0]) = x + y; +// } +// } // // ... // }