From c6874f9759fe4c4839254a20e46d4f2ccac10720 Mon Sep 17 00:00:00 2001
From: Haohui Mai <ricetons@gmail.com>
Date: Sat, 18 Nov 2023 20:51:09 -0800
Subject: [PATCH 1/3] Fix incorrect format strings and uninitialized variables.

---
 examples/server/server.cpp | 2 ++
 ggml-cuda.cu               | 2 +-
 ggml.c                     | 4 +++-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/examples/server/server.cpp b/examples/server/server.cpp
index bb87b532b2c1..01ed53e38d58 100644
--- a/examples/server/server.cpp
+++ b/examples/server/server.cpp
@@ -1095,6 +1095,7 @@ struct llama_server_context
         std::lock_guard<std::mutex> lock(mutex_results);
         task_result res;
         res.id = id;
+        res.stop = false;
         res.error = true;
         res.result_json = { { "content", error } };
         queue_results.push_back(res);
@@ -1255,6 +1256,7 @@ struct llama_server_context
         std::lock_guard<std::mutex> lock(mutex_tasks);
         task_server task;
         task.id = id_gen++;
+        task.target_id = 0;
         task.data = data;
         task.infill_mode = infill;
         task.embedding_mode = embedding;
diff --git a/ggml-cuda.cu b/ggml-cuda.cu
index 50e03de50074..8bd36a7de11c 100644
--- a/ggml-cuda.cu
+++ b/ggml-cuda.cu
@@ -8057,7 +8057,7 @@ bool ggml_cuda_compute_forward(struct ggml_compute_params * params, struct ggml_
     if (tensor->op == GGML_OP_MUL_MAT) {
         if (tensor->src[0]->ne[3] != tensor->src[1]->ne[3]) {
 #ifndef NDEBUG
-            fprintf(stderr, "%s: cannot compute %s: src0->ne[3] = %d, src1->ne[3] = %d - fallback to CPU\n", __func__, tensor->name, tensor->src[0]->ne[3], tensor->src[1]->ne[3]);
+            fprintf(stderr, "%s: cannot compute %s: src0->ne[3] = %ld, src1->ne[3] = %ld - fallback to CPU\n", __func__, tensor->name, tensor->src[0]->ne[3], tensor->src[1]->ne[3]);
 #endif
             return false;
         }
diff --git a/ggml.c b/ggml.c
index f92292b39c63..8b843b341377 100644
--- a/ggml.c
+++ b/ggml.c
@@ -1586,7 +1586,7 @@ inline static void ggml_vec_argmax_f32(const int n, int * s, const float * x) {
 // data types
 //
 
-static const char * GGML_OP_NAME[GGML_OP_COUNT] = {
+static const char * GGML_OP_NAME[GGML_OP_COUNT + 2] = {
     "NONE",
 
     "DUP",
@@ -1664,6 +1664,8 @@ static const char * GGML_OP_NAME[GGML_OP_COUNT] = {
 
     "CROSS_ENTROPY_LOSS",
     "CROSS_ENTROPY_LOSS_BACK",
+    "",
+    "",
 };
 
 static_assert(GGML_OP_COUNT == 68, "GGML_OP_COUNT != 68");

From 566785f560cd82a52f3e70ebc6108d94fb73a217 Mon Sep 17 00:00:00 2001
From: Haohui Mai <ricetons@gmail.com>
Date: Mon, 20 Nov 2023 22:04:21 -0800
Subject: [PATCH 2/3] Address comments

---
 ggml-cuda.cu | 2 +-
 ggml.c       | 4 +---
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/ggml-cuda.cu b/ggml-cuda.cu
index 8bd36a7de11c..c065d8ec6311 100644
--- a/ggml-cuda.cu
+++ b/ggml-cuda.cu
@@ -8057,7 +8057,7 @@ bool ggml_cuda_compute_forward(struct ggml_compute_params * params, struct ggml_
     if (tensor->op == GGML_OP_MUL_MAT) {
         if (tensor->src[0]->ne[3] != tensor->src[1]->ne[3]) {
 #ifndef NDEBUG
-            fprintf(stderr, "%s: cannot compute %s: src0->ne[3] = %ld, src1->ne[3] = %ld - fallback to CPU\n", __func__, tensor->name, tensor->src[0]->ne[3], tensor->src[1]->ne[3]);
+            fprintf(stderr, "%s: cannot compute %s: src0->ne[3] = " PRId64 ", src1->ne[3] = " PRId64 " - fallback to CPU\n", __func__, tensor->name, tensor->src[0]->ne[3], tensor->src[1]->ne[3]);
 #endif
             return false;
         }
diff --git a/ggml.c b/ggml.c
index 8b843b341377..f92292b39c63 100644
--- a/ggml.c
+++ b/ggml.c
@@ -1586,7 +1586,7 @@ inline static void ggml_vec_argmax_f32(const int n, int * s, const float * x) {
 // data types
 //
 
-static const char * GGML_OP_NAME[GGML_OP_COUNT + 2] = {
+static const char * GGML_OP_NAME[GGML_OP_COUNT] = {
     "NONE",
 
     "DUP",
@@ -1664,8 +1664,6 @@ static const char * GGML_OP_NAME[GGML_OP_COUNT + 2] = {
 
     "CROSS_ENTROPY_LOSS",
     "CROSS_ENTROPY_LOSS_BACK",
-    "",
-    "",
 };
 
 static_assert(GGML_OP_COUNT == 68, "GGML_OP_COUNT != 68");

From 9216e7bebaf329c4a87f185158bed6c209349a14 Mon Sep 17 00:00:00 2001
From: Haohui Mai <ricetons@gmail.com>
Date: Wed, 22 Nov 2023 08:16:34 -0800
Subject: [PATCH 3/3] Add the missing include statement

---
 ggml-cuda.cu | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ggml-cuda.cu b/ggml-cuda.cu
index c065d8ec6311..f0db7ae357a2 100644
--- a/ggml-cuda.cu
+++ b/ggml-cuda.cu
@@ -1,4 +1,5 @@
 #include <algorithm>
+#include <cinttypes>
 #include <cstddef>
 #include <cstdint>
 #include <limits>
