File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change
1
+ #define _CRT_SECURE_NO_DEPRECATE // Disables ridiculous "unsafe" warnigns on Windows
1
2
#include "ggml.h"
2
3
3
4
#include <math.h>
4
5
#include <stdio.h>
5
6
#include <stdlib.h>
6
7
#include <assert.h>
7
8
9
+ #if defined(_MSC_VER )
10
+ #pragma warning(disable: 4244 4267) // possible loss of data
11
+ #endif
12
+
8
13
#define MAX_NARGS 3
9
14
10
15
#undef MIN
@@ -197,8 +202,23 @@ bool check_gradient(
197
202
float max_error_abs ,
198
203
float max_error_rel ) {
199
204
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
+
200
217
struct ggml_cgraph gf = ggml_build_forward (f );
218
+ gf .n_threads = n_threads ;
219
+
201
220
struct ggml_cgraph gb = ggml_build_backward (ctx0 , & gf , false);
221
+ gb .n_threads = n_threads ;
202
222
203
223
ggml_graph_compute (ctx0 , & gf );
204
224
ggml_graph_reset (& gf );
You can’t perform that action at this time.
0 commit comments