diff --git a/fundamentals/ggml/src/backend.c b/fundamentals/ggml/src/backend.c index 63de8bb9..5e73bcc4 100644 --- a/fundamentals/ggml/src/backend.c +++ b/fundamentals/ggml/src/backend.c @@ -1,8 +1,8 @@ #include -#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"); diff --git a/fundamentals/ggml/src/cont.c b/fundamentals/ggml/src/cont.c index 6c261ce2..5284e446 100644 --- a/fundamentals/ggml/src/cont.c +++ b/fundamentals/ggml/src/cont.c @@ -1,8 +1,8 @@ #include -#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"); diff --git a/fundamentals/ggml/src/dup.c b/fundamentals/ggml/src/dup.c index be0afcb7..ffdaafbc 100644 --- a/fundamentals/ggml/src/dup.c +++ b/fundamentals/ggml/src/dup.c @@ -1,8 +1,8 @@ #include -#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"); diff --git a/fundamentals/ggml/src/get_rows.c b/fundamentals/ggml/src/get_rows.c index ac2fe13e..5a74e4fd 100644 --- a/fundamentals/ggml/src/get_rows.c +++ b/fundamentals/ggml/src/get_rows.c @@ -1,8 +1,8 @@ #include -#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. diff --git a/fundamentals/ggml/src/ggml-quants.c b/fundamentals/ggml/src/ggml-quants.c index 27ac9921..0627072b 100644 --- a/fundamentals/ggml/src/ggml-quants.c +++ b/fundamentals/ggml/src/ggml-quants.c @@ -1,9 +1,10 @@ #include -#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 @@ -11,11 +12,15 @@ #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 = { @@ -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; } diff --git a/fundamentals/ggml/src/graph.c b/fundamentals/ggml/src/graph.c index ee350f1c..e6cde280 100644 --- a/fundamentals/ggml/src/graph.c +++ b/fundamentals/ggml/src/graph.c @@ -1,8 +1,8 @@ #include -#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"); diff --git a/fundamentals/ggml/src/matrix-mul.c b/fundamentals/ggml/src/matrix-mul.c index c382a5a6..34791a42 100644 --- a/fundamentals/ggml/src/matrix-mul.c +++ b/fundamentals/ggml/src/matrix-mul.c @@ -1,8 +1,8 @@ #include -#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"); diff --git a/fundamentals/ggml/src/permute.c b/fundamentals/ggml/src/permute.c index 548d05df..d591f15e 100644 --- a/fundamentals/ggml/src/permute.c +++ b/fundamentals/ggml/src/permute.c @@ -1,8 +1,8 @@ #include -#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"); diff --git a/fundamentals/ggml/src/reshape.c b/fundamentals/ggml/src/reshape.c index 3fc87859..737b8df4 100644 --- a/fundamentals/ggml/src/reshape.c +++ b/fundamentals/ggml/src/reshape.c @@ -1,8 +1,8 @@ #include -#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"); diff --git a/fundamentals/ggml/src/tensor.c b/fundamentals/ggml/src/tensor.c index 2c74df56..87b229bf 100644 --- a/fundamentals/ggml/src/tensor.c +++ b/fundamentals/ggml/src/tensor.c @@ -1,8 +1,8 @@ #include -#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"); @@ -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 diff --git a/fundamentals/ggml/src/transpose.c b/fundamentals/ggml/src/transpose.c index 05d1b4d3..5c5bd61f 100644 --- a/fundamentals/ggml/src/transpose.c +++ b/fundamentals/ggml/src/transpose.c @@ -1,8 +1,8 @@ #include -#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"); diff --git a/fundamentals/ggml/src/view.c b/fundamentals/ggml/src/view.c index 91fa1301..ff68fdb5 100644 --- a/fundamentals/ggml/src/view.c +++ b/fundamentals/ggml/src/view.c @@ -1,8 +1,8 @@ #include -#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");