]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
ggml : make more compatible with c99 (#262)
authorGeorgi Gerganov <redacted>
Fri, 16 Dec 2022 16:00:12 +0000 (18:00 +0200)
committerGeorgi Gerganov <redacted>
Fri, 16 Dec 2022 16:00:12 +0000 (18:00 +0200)
ggml.c
ggml.h

diff --git a/ggml.c b/ggml.c
index e3c0db356c8b4c090776066d8199bec0c3cffb91..bab5cc71d0193b16afe6da291d607501451158be 100644 (file)
--- a/ggml.c
+++ b/ggml.c
 #include <stdint.h>
 #include <stdio.h>
 
-// if C99 - static_assert is nop
+// if C99 - static_assert is noop
+// ref: https://stackoverflow.com/a/53923785/4039976
 #ifndef static_assert
-#define static_assert(cond, msg)
+#define static_assert(cond, msg) struct global_scope_noop_trick
 #endif
 
 #if defined _MSC_VER || defined(__MINGW32__)
diff --git a/ggml.h b/ggml.h
index 6dd5d04462e5d406704fb20804bd4111a7158a47..7f24e5312f6b479b0bb477e6e3f7c369ec462bf6 100644 (file)
--- a/ggml.h
+++ b/ggml.h
@@ -681,34 +681,32 @@ struct ggml_opt_params {
     bool print_forward_graph;
     bool print_backward_graph;
 
-    union {
-        // ADAM parameters
-        struct {
-            int n_iter;
-
-            float alpha; // learning rate
-            float beta1;
-            float beta2;
-            float eps;   // epsilon for numerical stability
-            float eps_f; // epsilon for convergence test
-            float eps_g; // epsilon for convergence test
-        } adam;
-
-        // LBFGS parameters
-        struct {
-            int m; // number of corrections to approximate the inv. Hessian
-            int n_iter;
-            int max_linesearch;
-
-            float eps;      // convergence tolerance
-            float ftol;     // line search tolerance
-            float wolfe;
-            float min_step;
-            float max_step;
-
-            enum ggml_linesearch linesearch;
-        } lbfgs;
-    };
+    // ADAM parameters
+    struct {
+        int n_iter;
+
+        float alpha; // learning rate
+        float beta1;
+        float beta2;
+        float eps;   // epsilon for numerical stability
+        float eps_f; // epsilon for convergence test
+        float eps_g; // epsilon for convergence test
+    } adam;
+
+    // LBFGS parameters
+    struct {
+        int m; // number of corrections to approximate the inv. Hessian
+        int n_iter;
+        int max_linesearch;
+
+        float eps;      // convergence tolerance
+        float ftol;     // line search tolerance
+        float wolfe;
+        float min_step;
+        float max_step;
+
+        enum ggml_linesearch linesearch;
+    } lbfgs;
 };
 
 struct ggml_opt_params ggml_opt_default_params(enum ggml_opt_type type);