ggml : make more compatible with c99 (#262)

This commit is contained in:
Georgi Gerganov 2022-12-16 18:00:12 +02:00
parent 5a5c5ddcca
commit 0f11759406
No known key found for this signature in database
GPG Key ID: 449E073F9DC10735
2 changed files with 25 additions and 26 deletions

5
ggml.c
View File

@ -14,9 +14,10 @@
#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__)

46
ggml.h
View File

@ -681,34 +681,32 @@ struct ggml_opt_params {
bool print_forward_graph;
bool print_backward_graph;
union {
// ADAM parameters
struct {
int n_iter;
// 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;
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;
// 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;
float eps; // convergence tolerance
float ftol; // line search tolerance
float wolfe;
float min_step;
float max_step;
enum ggml_linesearch linesearch;
} lbfgs;
};
enum ggml_linesearch linesearch;
} lbfgs;
};
struct ggml_opt_params ggml_opt_default_params(enum ggml_opt_type type);