8000 tests : sync test-grad0 from ggml · Pints-AI/llama.cpp@65bdd52 · GitHub
[go: up one dir, main page]

Skip to content

Commit 65bdd52

Browse files
committed
tests : sync test-grad0 from ggml
1 parent fdd1860 commit 65bdd52

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/test-grad0.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
#define _CRT_SECURE_NO_DEPRECATE // Disables ridiculous "unsafe" warnigns on Windows
12
#include "ggml.h"
23

34
#include <math.h>
45
#include <stdio.h>
56
#include <stdlib.h>
67
#include <assert.h>
78

9+
#if defined(_MSC_VER)
10+
#pragma warning(disable: 4244 4267) // possible loss of data
11+
#endif
12+
813
#define MAX_NARGS 3
914

1015
#undef MIN
@@ -197,8 +202,23 @@ bool check_gradient(
197202
float max_error_abs,
198203
float max_error_rel) {
199204

205+
static int n_threads = -1;
206+
if (n_threads < 0) {
207+
n_threads = GGML_DEFAULT_N_THREADS;
208+
209+
const char *env = getenv("GGML_N_THREADS");
210+
if (env) {
211+
n_threads = atoi(env);
212+
}
213+
214+
printf("GGML_N_THREADS = %d\n", n_threads);
215+
}
216+
200217
struct ggml_cgraph gf = ggml_build_forward (f);
218+
gf.n_threads = n_threads;
219+
201220
struct ggml_cgraph gb = ggml_build_backward(ctx0, &gf, false);
221+
gb.n_threads = n_threads;
202222

203223
ggml_graph_compute(ctx0, &gf);
204224
ggml_graph_reset (&gf);

0 commit comments

Comments
 (0)
0