Skip to content

Commit

Permalink
ggml: update include paths in examples
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Bevenius <[email protected]>
  • Loading branch information
danbev committed Jun 30, 2024
1 parent 004fc0c commit 41ec511
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 35 deletions.
6 changes: 3 additions & 3 deletions fundamentals/ggml/src/backend.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <stdio.h>

#include "ggml/ggml.h"
#include "ggml/ggml-alloc.h"
#include "ggml/ggml-backend.h"
#include "ggml.h"
#include "ggml-alloc.h"
#include "ggml-backend.h"

void print_backend_info(ggml_backend_buffer_t buffer, struct ggml_context* ctx) {
printf("------- backend info -------\n");
Expand Down
6 changes: 3 additions & 3 deletions fundamentals/ggml/src/cont.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <stdio.h>

#include "ggml/ggml.h"
#include "ggml/ggml-alloc.h"
#include "ggml/ggml-backend.h"
#include "ggml.h"
#include "ggml-alloc.h"
#include "ggml-backend.h"

int main(int argc, char **argv) {
printf("GGML cont tensor examples\n");
Expand Down
6 changes: 3 additions & 3 deletions fundamentals/ggml/src/dup.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <stdio.h>

#include "ggml/ggml.h"
#include "ggml/ggml-alloc.h"
#include "ggml/ggml-backend.h"
#include "ggml.h"
#include "ggml-alloc.h"
#include "ggml-backend.h"

int main(int argc, char **argv) {
printf("GGML dup example\n");
Expand Down
6 changes: 3 additions & 3 deletions fundamentals/ggml/src/get_rows.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <stdio.h>

#include "ggml/ggml.h"
#include "ggml/ggml-alloc.h"
#include "ggml/ggml-backend.h"
#include "ggml.h"
#include "ggml-alloc.h"
#include "ggml-backend.h"

/*
* This is an example to help understand what ggml_get_rows does.
Expand Down
17 changes: 15 additions & 2 deletions fundamentals/ggml/src/ggml-quants.c
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
#include <stdio.h>

#include "ggml/ggml.h"
#include "ggml.h"
#include "ggml-quants.h"
#include "ggml-impl.h"

/*
#ifdef GGML_COMMON_DECL_C
#warning "[danbev] GGML_COMMON_DECL_C is defined"
#endif
#ifdef GGML_COMMON_DECL_CUDA
#warning "[danbev] GGML_COMMON_DECL_CUDA is defined"
#endif
*/

int main(int argc, char **argv) {
printf("GGML Quantization examples\n");

float data[] = {0.2, 0.3, 0.4, 0.5};
float data[] = {0.2, 0.3, 0.4, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0};

float d = 0.5 / 15.0;
block_q4_0 block_q4_0 = {
Expand All @@ -34,10 +39,18 @@ int main(int argc, char **argv) {
printf("data[%d]: %f\n", i, block_q4_0.qs[i] * ggml_compute_fp16_to_fp32(block_q4_0.d));
}

// Get the type_trait for Q4_0
ggml_type_traits_t q4_0 = ggml_internal_get_type_traits(GGML_TYPE_Q4_0);
printf("ggml type trait name: %s\n", q4_0.type_name);
printf("ggml type trait block size: %d\n", q4_0.blck_size);
printf("ggml type trait is_quantized: %s\n", q4_0.is_quantized ? "true" : "false");
// The type trait contains function pointers to the quantize and dequantize
// functions
q4_0.from_float(data, &block_q4_0, 32);
for (int i = 0; i < QK4_0/2; i++) {
printf("block_q4_0.qs[%d]: %d\n", i, block_q4_0.qs[i]);
}


return 0;
}
6 changes: 3 additions & 3 deletions fundamentals/ggml/src/graph.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <stdio.h>

#include "ggml/ggml.h"
#include "ggml/ggml-alloc.h"
#include "ggml/ggml-backend.h"
#include "ggml.h"
#include "ggml-alloc.h"
#include "ggml-backend.h"

int main(int argc, char **argv) {
printf("GGML compute graph example\n");
Expand Down
6 changes: 3 additions & 3 deletions fundamentals/ggml/src/matrix-mul.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <stdio.h>

#include "ggml/ggml.h"
#include "ggml/ggml-alloc.h"
#include "ggml/ggml-backend.h"
#include "ggml.h"
#include "ggml-alloc.h"
#include "ggml-backend.h"

int main(int argc, char **argv) {
printf("GGML matrix multiplication example\n");
Expand Down
6 changes: 3 additions & 3 deletions fundamentals/ggml/src/permute.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <stdio.h>

#include "ggml/ggml.h"
#include "ggml/ggml-alloc.h"
#include "ggml/ggml-backend.h"
#include "ggml.h"
#include "ggml-alloc.h"
#include "ggml-backend.h"

int main(int argc, char **argv) {
printf("GGML permute tensor examples\n");
Expand Down
6 changes: 3 additions & 3 deletions fundamentals/ggml/src/reshape.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <stdio.h>

#include "ggml/ggml.h"
#include "ggml/ggml-alloc.h"
#include "ggml/ggml-backend.h"
#include "ggml.h"
#include "ggml-alloc.h"
#include "ggml-backend.h"

int main(int argc, char **argv) {
printf("GGML reshape tensor examples\n");
Expand Down
7 changes: 4 additions & 3 deletions fundamentals/ggml/src/tensor.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <stdio.h>

#include "ggml/ggml.h"
#include "ggml/ggml-alloc.h"
#include "ggml/ggml-backend.h"
#include "ggml.h"
#include "ggml-alloc.h"
#include "ggml-backend.h"

int main(int argc, char **argv) {
printf("GGML tensor example\n");
Expand Down Expand Up @@ -67,6 +67,7 @@ int main(int argc, char **argv) {
for (int y = 0; y < ny; y++) {
for (int x = 0; x < nx; x++) {
float* value = (float *)( (char *) matrix->data + (y * matrix->nb[1]) + (x * matrix->nb[0]));
printf("value: %p\n", value);
// Since we want to perform byte-level operations and a char is 1 byte.
// If we don't do this the additions would be done of the size of the
// type, so 4 bytes for a float. And after we are done we need to
Expand Down
6 changes: 3 additions & 3 deletions fundamentals/ggml/src/transpose.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <stdio.h>

#include "ggml/ggml.h"
#include "ggml/ggml-alloc.h"
#include "ggml/ggml-backend.h"
#include "ggml.h"
#include "ggml-alloc.h"
#include "ggml-backend.h"

int main(int argc, char **argv) {
printf("GGML reshape tensor examples\n");
Expand Down
6 changes: 3 additions & 3 deletions fundamentals/ggml/src/view.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <stdio.h>

#include "ggml/ggml.h"
#include "ggml/ggml-alloc.h"
#include "ggml/ggml-backend.h"
#include "ggml.h"
#include "ggml-alloc.h"
#include "ggml-backend.h"

int main(int argc, char **argv) {
printf("GGML view examples\n");
Expand Down

0 comments on commit 41ec511

Please sign in to comment.