Skip to content

Commit 16d1543

Browse files
committed
Fix a few warnings on Windows
1 parent c81f3bb commit 16d1543

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

ggml/src/ggml-common.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,13 @@ typedef sycl::half2 ggml_half2;
5959
#ifndef __cplusplus
6060
#ifndef static_assert
6161
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201100L)
62-
#define static_assert(cond, msg) _Static_assert(cond, msg)
63-
#else
62+
#if defined(_MSC_VER)
63+
// MS defines static_assert in assert.h (see -Wmicrosoft-static-assert)
64+
#include <assert.h>
65+
#else // Not msft
66+
#define stlatic_assert(cond, msg) _Static_assert(cond, msg)
67+
#endif
68+
#else // Older C
6469
#define static_assert(cond, msg) struct global_scope_noop_trick
6570
#endif
6671
#endif

ggml/src/ggml-cpu-impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static inline ggml_bf16_t ggml_compute_fp32_to_bf16(float s) {
139139

140140
#ifdef _MSC_VER
141141

142-
typedef uint16_t ggml_fp16_internal_t;
142+
typedef float16_t ggml_fp16_internal_t;
143143

144144
#define ggml_vld1q_u32(w,x,y,z) { ((w) + ((uint64_t)(x) << 32)), ((y) + ((uint64_t)(z) << 32)) }
145145

ggml/src/ggml.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ inline static void * ggml_calloc(size_t num, size_t size) {
468468
#endif
469469

470470
// floating point type used to accumulate sums
471-
typedef double ggml_float;
471+
typedef float ggml_float;
472472

473473
#undef MIN
474474
#undef MAX
@@ -13937,7 +13937,7 @@ static void ggml_compute_forward_soft_max_f32(
1393713937
ggml_float sum = ggml_vec_soft_max_f32(nc, dp, wp, max);
1393813938
assert(sum > 0.0);
1393913939

13940-
sum = 1.0/sum;
13940+
sum = 1.f/sum;
1394113941
ggml_vec_scale_f32(nc, dp, sum);
1394213942

1394313943
#ifndef NDEBUG
@@ -16020,7 +16020,7 @@ static void ggml_compute_forward_flash_attn_back_f32(
1602016020

1602116021
assert(sum > 0.0);
1602216022

16023-
sum = 1.0/sum;
16023+
sum = 1.f/sum;
1602416024
ggml_vec_scale_f32(masked_begin, SM, sum);
1602516025

1602616026
}
@@ -17091,7 +17091,7 @@ static void ggml_compute_forward_cross_entropy_loss_back_f32(
1709117091
ggml_vec_max_f32(nc, &max, s0);
1709217092
ggml_float sum = ggml_vec_soft_max_f32(nc, ds0, s0, max);
1709317093
assert(sum > 0.0);
17094-
ggml_vec_scale_f32(nc, ds0, 1.0/sum);
17094+
ggml_vec_scale_f32(nc, ds0, 1.f/sum);
1709517095

1709617096
// grad(src0) = (softmax(src0) - src1) * grad(cross_entropy_loss(src0, src1)) / nr
1709717097
ggml_vec_sub_f32(nc, ds0, ds0, s1);
@@ -19414,7 +19414,7 @@ static thread_ret_t ggml_graph_compute_secondary_thread(void* data);
1941419414
#include "windows.h"
1941519415

1941619416
// TODO: support > 64 CPUs
19417-
bool ggml_thread_apply_affinity(bool * mask) {
19417+
static bool ggml_thread_apply_affinity(bool * mask) {
1941819418
HANDLE h = GetCurrentThread();
1941919419
uint64_t bitmask = 0ULL;
1942019420

@@ -21081,13 +21081,13 @@ static enum ggml_opt_result ggml_opt_adam(
2108121081
float gnorm = 1.0f;
2108221082
if (gclip > 0.0f) {
2108321083
// gradient clipping
21084-
ggml_float sum = 0.0;
21084+
double sum = 0.0;
2108521085
for (int64_t i = 0; i < nx; ++i) {
21086-
sum += (ggml_float)(g[i]*g[i]);
21086+
sum += (double)(g[i]*g[i]);
2108721087
}
21088-
ggml_float norm = sqrt(sum);
21089-
if (norm > (ggml_float) gclip) {
21090-
gnorm = (float) ((ggml_float) gclip / norm);
21088+
ggml_float norm = (ggml_float) sqrt(sum);
21089+
if (norm > gclip) {
21090+
gnorm = (float) (gclip / norm);
2109121091
}
2109221092
}
2109321093
const float beta1h = alpha*sched/(1.0f - powf(beta1, opt->iter));

0 commit comments

Comments
 (0)