ggerganov commited on
Commit
52bc68d
·
unverified ·
1 Parent(s): cd282f3

ggml : make more compatible with c99 (#262)

Browse files
Files changed (2) hide show
  1. ggml.c +3 -2
  2. ggml.h +26 -28
ggml.c CHANGED
@@ -14,9 +14,10 @@
14
  #include <stdint.h>
15
  #include <stdio.h>
16
 
17
- // if C99 - static_assert is nop
 
18
  #ifndef static_assert
19
- #define static_assert(cond, msg)
20
  #endif
21
 
22
  #if defined _MSC_VER || defined(__MINGW32__)
 
14
  #include <stdint.h>
15
  #include <stdio.h>
16
 
17
+ // if C99 - static_assert is noop
18
+ // ref: https://stackoverflow.com/a/53923785/4039976
19
  #ifndef static_assert
20
+ #define static_assert(cond, msg) struct global_scope_noop_trick
21
  #endif
22
 
23
  #if defined _MSC_VER || defined(__MINGW32__)
ggml.h CHANGED
@@ -681,34 +681,32 @@ struct ggml_opt_params {
681
  bool print_forward_graph;
682
  bool print_backward_graph;
683
 
684
- union {
685
- // ADAM parameters
686
- struct {
687
- int n_iter;
688
-
689
- float alpha; // learning rate
690
- float beta1;
691
- float beta2;
692
- float eps; // epsilon for numerical stability
693
- float eps_f; // epsilon for convergence test
694
- float eps_g; // epsilon for convergence test
695
- } adam;
696
-
697
- // LBFGS parameters
698
- struct {
699
- int m; // number of corrections to approximate the inv. Hessian
700
- int n_iter;
701
- int max_linesearch;
702
-
703
- float eps; // convergence tolerance
704
- float ftol; // line search tolerance
705
- float wolfe;
706
- float min_step;
707
- float max_step;
708
-
709
- enum ggml_linesearch linesearch;
710
- } lbfgs;
711
- };
712
  };
713
 
714
  struct ggml_opt_params ggml_opt_default_params(enum ggml_opt_type type);
 
681
  bool print_forward_graph;
682
  bool print_backward_graph;
683
 
684
+ // ADAM parameters
685
+ struct {
686
+ int n_iter;
687
+
688
+ float alpha; // learning rate
689
+ float beta1;
690
+ float beta2;
691
+ float eps; // epsilon for numerical stability
692
+ float eps_f; // epsilon for convergence test
693
+ float eps_g; // epsilon for convergence test
694
+ } adam;
695
+
696
+ // LBFGS parameters
697
+ struct {
698
+ int m; // number of corrections to approximate the inv. Hessian
699
+ int n_iter;
700
+ int max_linesearch;
701
+
702
+ float eps; // convergence tolerance
703
+ float ftol; // line search tolerance
704
+ float wolfe;
705
+ float min_step;
706
+ float max_step;
707
+
708
+ enum ggml_linesearch linesearch;
709
+ } lbfgs;
 
 
710
  };
711
 
712
  struct ggml_opt_params ggml_opt_default_params(enum ggml_opt_type type);