]> git.djapps.eu Git - pkg/ggml/sources/ggml/commitdiff
examples : adapt to ggml.h changes (#0)
authorGeorgi Gerganov <redacted>
Fri, 20 Sep 2024 18:50:16 +0000 (21:50 +0300)
committerGeorgi Gerganov <redacted>
Fri, 20 Sep 2024 19:03:57 +0000 (22:03 +0300)
ggml-ci

examples/common-ggml.cpp
examples/gpt-2/main-batched.cpp
examples/gpt-2/main-sched.cpp
examples/simple/simple-backend.cpp
examples/simple/simple-ctx.cpp
include/ggml.h
src/ggml.c
tests/test-conv-transpose-1d.cpp
tests/test-conv1d.cpp
tests/test-conv2d.cpp
tests/test-mul-mat.cpp

index a3f2c12f7ce679e8e5022df1e9b18196307ee813..760cd1f44be19ba7d1c34c3b243fead7db3fdb99 100644 (file)
@@ -215,6 +215,8 @@ bool ggml_common_quantize_0(
                 case GGML_TYPE_Q4_0_4_4:
                 case GGML_TYPE_Q4_0_4_8:
                 case GGML_TYPE_Q4_0_8_8:
+                case GGML_TYPE_TQ1_0:
+                case GGML_TYPE_TQ2_0:
                 case GGML_TYPE_COUNT:
                     {
                         fprintf(stderr, "%s: unsupported quantization type %d (%s)\n", __func__, ttype, ggml_type_name((ggml_type) ttype));
index ecf08b2b7ca002047b1bbeed876118b01bfa34b5..d504093eb738bf82148fc4048413176155a28ae8 100644 (file)
@@ -955,7 +955,7 @@ int gpt2_decode(
     //}
 
     // in this case, the output tensor is the last one in the graph
-    struct ggml_tensor * inpL = gf->nodes[gf->n_nodes - 1];
+    struct ggml_tensor * inpL = ggml_graph_node(gf, -1);
 
     if (batch.logits) {
         // return logits for all tokens
index 36571045e48fa14dd6ae1aea91581781eac2e478..ccbceca71c7c436ee93a8ff1a959a565d06449c6 100644 (file)
@@ -888,7 +888,7 @@ bool gpt2_eval(
     //}
 
     // in this case, the output tensor is the last one in the graph
-    struct ggml_tensor * inpL = gf->nodes[gf->n_nodes - 1];
+    struct ggml_tensor * inpL = ggml_graph_node(gf, -1);
 
     //embd_w.resize(n_vocab*N);
     //ggml_backend_tensor_get(inpL, embd_w.data(), 0, sizeof(float)*n_vocab*N);
index 64da9542f5a89309cb26dd637596d406de5c3fb6..203028c8060edcd492448d85cf048b09dfbde915 100644 (file)
@@ -140,7 +140,7 @@ struct ggml_tensor * compute(const simple_model & model, ggml_gallocr_t allocr)
     ggml_backend_graph_compute(model.backend, gf);
 
     // in this case, the output tensor is the last one in the graph
-    return gf->nodes[gf->n_nodes - 1];
+    return ggml_graph_node(gf, -1);
 }
 
 int main(void) {
index b2d4e4ba5be156e4c4acc9746a80fbd1ac2c39b9..283ec0a72edc626473d1f8d1099a7b1aae235772 100644 (file)
@@ -66,7 +66,7 @@ struct ggml_tensor * compute(const simple_model & model) {
     ggml_graph_compute_with_ctx(model.ctx, gf, n_threads);
 
     // in this case, the output tensor is the last one in the graph
-    return gf->nodes[gf->n_nodes - 1];
+    return ggml_graph_node(gf, -1);
 }
 
 int main(void) {
index 2035001e97d7e1c3825ed63ab028be2cb582e45d..76294fff4f18575aee5ccfd333db509f428c15a8 100644 (file)
@@ -1979,6 +1979,9 @@ extern "C" {
     typedef void (*ggml_custom2_op_t)(struct ggml_tensor * dst , const struct ggml_tensor * a, const struct ggml_tensor * b, int ith, int nth, void * userdata);
     typedef void (*ggml_custom3_op_t)(struct ggml_tensor * dst , const struct ggml_tensor * a, const struct ggml_tensor * b, const struct ggml_tensor * c, int ith, int nth, void * userdata);
 
+#define GGML_N_TASKS_MAX (-1)
+    // n_tasks == GGML_N_TASKS_MAX means to use max number of tasks
+
     GGML_API struct ggml_tensor * ggml_map_custom1(
             struct ggml_context   * ctx,
             struct ggml_tensor    * a,
index 201d5466a0e4b7e6cff37cb090796d4f1534e397..28e1937379072e5d1d1f2855778d148b3f51d84f 100644 (file)
@@ -289,7 +289,6 @@ void ggml_abort(const char * file, int line, const char * fmt, ...) {
 #define GGML_DEBUG 0
 #define GGML_GELU_FP16
 #define GGML_GELU_QUICK_FP16
-#define GGML_N_TASKS_MAX (-1)
 
 #define GGML_SOFT_MAX_UNROLL 4
 #define GGML_VEC_DOT_UNROLL  2
index c2e517dd95d1d87503886609fb4357bd29b2058f..36643ab9ae310979c9f0335af805b3d88d48a27e 100644 (file)
@@ -415,9 +415,9 @@ int main(void)
 
     struct ggml_tensor * conv1d_transpose_res_0 = NULL;
 
-    for(int i = 0; i < gf_res->n_nodes; i++) {
-       if(strcmp(ggml_get_name(gf_res->nodes[i]), "conv1d_transpose_res_0") == 0) {
-            conv1d_transpose_res_0 = gf_res->nodes[i];
+    for(int i = 0; i < ggml_graph_n_nodes(gf_res); i++) {
+       if(strcmp(ggml_get_name(ggml_graph_node(gf_res, i)), "conv1d_transpose_res_0") == 0) {
+            conv1d_transpose_res_0 = ggml_graph_node(gf_res, i);
         }
     }
 
@@ -434,9 +434,9 @@ int main(void)
 
     struct ggml_tensor * conv1d_transpose_res_1 = NULL;
 
-    for(int i = 0; i < gf_res->n_nodes; i++) {
-       if(strcmp(ggml_get_name(gf_res->nodes[i]), "conv1d_transpose_res_1") == 0) {
-            conv1d_transpose_res_1 = gf_res->nodes[i];
+    for(int i = 0; i < ggml_graph_n_nodes(gf_res); i++) {
+       if(strcmp(ggml_get_name(ggml_graph_node(gf_res, i)), "conv1d_transpose_res_1") == 0) {
+            conv1d_transpose_res_1 = ggml_graph_node(gf_res, i);
         }
     }
 
@@ -456,9 +456,9 @@ int main(void)
 
     struct ggml_tensor * conv1d_transpose_res_2 = NULL;
 
-    for(int i = 0; i < gf_res->n_nodes; i++) {
-       if(strcmp(ggml_get_name(gf_res->nodes[i]), "conv1d_transpose_res_2") == 0) {
-            conv1d_transpose_res_2 = gf_res->nodes[i];
+    for(int i = 0; i < ggml_graph_n_nodes(gf_res); i++) {
+       if(strcmp(ggml_get_name(ggml_graph_node(gf_res, i)), "conv1d_transpose_res_2") == 0) {
+            conv1d_transpose_res_2 = ggml_graph_node(gf_res, i);
         }
     }
 
@@ -475,9 +475,9 @@ int main(void)
 
     struct ggml_tensor * conv1d_transpose_res_3 = NULL;
 
-    for(int i = 0; i < gf_res->n_nodes; i++) {
-       if(strcmp(ggml_get_name(gf_res->nodes[i]), "conv1d_transpose_res_3") == 0) {
-            conv1d_transpose_res_3 = gf_res->nodes[i];
+    for(int i = 0; i < ggml_graph_n_nodes(gf_res); i++) {
+       if(strcmp(ggml_get_name(ggml_graph_node(gf_res, i)), "conv1d_transpose_res_3") == 0) {
+            conv1d_transpose_res_3 = ggml_graph_node(gf_res, i);
         }
     }
 
@@ -495,9 +495,9 @@ int main(void)
 
     struct ggml_tensor * conv1d_transpose_res_4 = NULL;
 
-    for(int i = 0; i < gf_res->n_nodes; i++) {
-       if(strcmp(ggml_get_name(gf_res->nodes[i]), "conv1d_transpose_res_4") == 0) {
-            conv1d_transpose_res_4 = gf_res->nodes[i];
+    for(int i = 0; i < ggml_graph_n_nodes(gf_res); i++) {
+       if(strcmp(ggml_get_name(ggml_graph_node(gf_res, i)), "conv1d_transpose_res_4") == 0) {
+            conv1d_transpose_res_4 = ggml_graph_node(gf_res, i);
         }
     }
 
@@ -516,9 +516,9 @@ int main(void)
 
     struct ggml_tensor * conv1d_transpose_res_5 = NULL;
 
-    for(int i = 0; i < gf_res->n_nodes; i++) {
-       if(strcmp(ggml_get_name(gf_res->nodes[i]), "conv1d_transpose_res_5") == 0) {
-            conv1d_transpose_res_5 = gf_res->nodes[i];
+    for(int i = 0; i < ggml_graph_n_nodes(gf_res); i++) {
+       if(strcmp(ggml_get_name(ggml_graph_node(gf_res, i)), "conv1d_transpose_res_5") == 0) {
+            conv1d_transpose_res_5 = ggml_graph_node(gf_res, i);
         }
     }
 
@@ -537,9 +537,9 @@ int main(void)
 
     struct ggml_tensor * conv1d_transpose_res_6 = NULL;
 
-    for(int i = 0; i < gf_res->n_nodes; i++) {
-       if(strcmp(ggml_get_name(gf_res->nodes[i]), "conv1d_transpose_res_6") == 0) {
-            conv1d_transpose_res_6 = gf_res->nodes[i];
+    for(int i = 0; i < ggml_graph_n_nodes(gf_res); i++) {
+       if(strcmp(ggml_get_name(ggml_graph_node(gf_res, i)), "conv1d_transpose_res_6") == 0) {
+            conv1d_transpose_res_6 = ggml_graph_node(gf_res, i);
         }
     }
 
@@ -559,9 +559,9 @@ int main(void)
 
     struct ggml_tensor * conv1d_transpose_res_7 = NULL;
 
-    for(int i = 0; i < gf_res->n_nodes; i++) {
-       if(strcmp(ggml_get_name(gf_res->nodes[i]), "conv1d_transpose_res_7") == 0) {
-            conv1d_transpose_res_7 = gf_res->nodes[i];
+    for(int i = 0; i < ggml_graph_n_nodes(gf_res); i++) {
+       if(strcmp(ggml_get_name(ggml_graph_node(gf_res, i)), "conv1d_transpose_res_7") == 0) {
+            conv1d_transpose_res_7 = ggml_graph_node(gf_res, i);
         }
     }
 
index d38d299369c7b5e9c9809d1f6c0d73d29662ba43..e98a4ca961e4c70982ea005b9987a2d8e0c9c454 100644 (file)
@@ -218,11 +218,11 @@ int main(void)
      struct ggml_tensor * im2col_res = NULL;
     struct ggml_tensor * conv1d_res = NULL;
 
-    for(int i = 0; i < gf_res->n_nodes; i++) {
-        if(strcmp(ggml_get_name(gf_res->nodes[i]), "im2col_res") == 0) {
-            im2col_res = gf_res->nodes[i];
-        } else if(strcmp(ggml_get_name(gf_res->nodes[i]), "conv1d_res") == 0) {
-            conv1d_res = gf_res->nodes[i];
+    for(int i = 0; i < ggml_graph_n_nodes(gf_res); i++) {
+        if(strcmp(ggml_get_name(ggml_graph_node(gf_res, i)), "im2col_res") == 0) {
+            im2col_res = ggml_graph_node(gf_res, i);
+        } else if(strcmp(ggml_get_name(ggml_graph_node(gf_res, i)), "conv1d_res") == 0) {
+            conv1d_res = ggml_graph_node(gf_res, i);
         }
     }
 
index 37942c5028f5e43a87c56556b60d7d0e20ff2f23..371277399f9438c6fc48bfbf0fd74de348621065 100644 (file)
@@ -221,11 +221,11 @@ int main(void)
     struct ggml_tensor * im2col_res = NULL;
     struct ggml_tensor * conv2d_res = NULL;
 
-    for(int i = 0; i < gf_res->n_nodes; i++) {
-        if(strcmp(ggml_get_name(gf_res->nodes[i]), "im2col_res") == 0) {
-            im2col_res = gf_res->nodes[i];
-        } else if(strcmp(ggml_get_name(gf_res->nodes[i]), "conv2d_res") == 0) {
-            conv2d_res = gf_res->nodes[i];
+    for(int i = 0; i < ggml_graph_n_nodes(gf_res); ++i) {
+        if(strcmp(ggml_get_name(ggml_graph_node(gf_res, i)), "im2col_res") == 0) {
+            im2col_res = ggml_graph_node(gf_res, i);
+        } else if(strcmp(ggml_get_name(ggml_graph_node(gf_res, i)), "conv2d_res") == 0) {
+            conv2d_res = ggml_graph_node(gf_res, i);
         }
     }
 
index f91e172aad8e901a87c841dd97110d70ea287b2a..1df9d1441b058f97e45eb8d7d3dc9fefe7ef18d4 100644 (file)
@@ -161,7 +161,7 @@ struct ggml_tensor* compute(const test_model & model, ggml_gallocr_t allocr) {
     //ggml_graph_print(gf);
 
     // in this case, the output tensor is the last one in the graph
-    return gf->nodes[gf->n_nodes - 1];
+    return ggml_graph_node(gf, -1);
 }