]> git.djapps.eu Git - pkg/ggml/sources/ggml/commitdiff
build : fix msvc warnings (#496)
authorBorislav Stanimirov <redacted>
Tue, 29 Aug 2023 13:36:59 +0000 (16:36 +0300)
committerGitHub <redacted>
Tue, 29 Aug 2023 13:36:59 +0000 (16:36 +0300)
examples/dolly-v2/main.cpp
examples/gpt-2/main.cpp
examples/gpt-j/main.cpp
examples/gpt-neox/main.cpp
examples/mpt/main.cpp
examples/replit/main.cpp
examples/sam/main.cpp
examples/starcoder/main.cpp
examples/starcoder/starcoder-mmap.cpp
examples/whisper/whisper.cpp
src/ggml.c

index 18ad1ad843fdb24d0325ce4946401b26c360b685..70200eb3a1f2c2ef5f49f0eda72f9933c695a971 100644 (file)
@@ -39,7 +39,7 @@ struct dollyv2_hparams {
     int32_t n_rot   = 20;    // rotary_pct[25%] * (n_embd / n_head)
     int32_t par_res = 1; // 1 = true, 0 = false
     int32_t ftype   = GGML_FTYPE_MOSTLY_F16;
-    float   eps     = 1e-5;
+    float   eps     = 1e-5f;
 };
 
 const std::string INSTRUCTION_KEY = "### Instruction:";
index 14caf2cc9d9dbed80c362e1ae8bde4ec32df80b4..81859ca5cd7fee0ba5c4910f1f47e9c08b6de4f5 100644 (file)
@@ -25,7 +25,7 @@ struct gpt2_hparams {
     int32_t n_head  = 12;
     int32_t n_layer = 12;
     int32_t ftype   = 1;
-    float   eps     = 1e-5;
+    float   eps     = 1e-5f;
 };
 
 struct gpt2_layer {
index d5fca51b0826d83998f558610c632607790367d4..e5ab5badf4dd8a8968220d0ea150809a51df2f61 100644 (file)
@@ -26,7 +26,7 @@ struct gptj_hparams {
     int32_t n_layer = 28;
     int32_t n_rot   = 64;
     int32_t ftype   = 1;
-    float   eps     = 1e-5;
+    float   eps     = 1e-5f;
 };
 
 struct gptj_layer {
index 68ba723dc1f4be4127cf4dace5349e90d2e49a72..457a58387166f5fb6f592e36a23dce5047e3afdc 100644 (file)
@@ -27,7 +27,7 @@ struct gpt_neox_hparams {
     int32_t n_rot   = 32; // rotary_pct * (n_embd / n_head)
     int32_t par_res = 1; // 1 = true, 0 = false
     int32_t ftype   = 1;
-    float   eps     = 1e-5;
+    float   eps     = 1e-5f;
 };
 
 struct gpt_neox_layer {
index 5fec3c12a23db2500c2d589bc5a8c72cb58a98e8..9b2fa02c22dbe0445570a03de826303b187d506d 100644 (file)
@@ -465,7 +465,7 @@ bool mpt_eval(const mpt_model & model, const int n_threads, const int n_past,
     const int n_head  = hparams.n_heads;
     const int n_vocab = hparams.n_vocab;
     const int n_ctx   = hparams.n_ctx;
-    const float eps   = 1e-5;
+    const float eps   = 1e-5f;
 
     static size_t buf_size = 256u * 1024 * 1024;
     static void * buf = malloc(buf_size);
index bd614399d1ae9997b12ab5debf3d8e51863740b6..b8338cbbdeb681e70dc3c0b0619c5050943cbf95 100644 (file)
@@ -450,7 +450,7 @@ bool replit_eval(const replit_model & model, const int n_threads, const int n_pa
     const int n_head = hparams.n_heads;
     const int n_vocab = hparams.n_vocab;
     const int n_ctx = hparams.max_seq_len;
-    const float eps = 1e-5;
+    const float eps = 1e-5f;
 
     static size_t buf_size = 256u * 1024 * 1024;
     static void * buf = malloc(buf_size);
index e8bfbb3de8545d15300dc816e8106fcc7d95a3a8..7a140006504df3f928364431730759860ef5c8c5 100644 (file)
@@ -1,4 +1,5 @@
 #define _USE_MATH_DEFINES // for M_PI
+#define _CRT_SECURE_NO_DEPRECATE // Disables ridiculous "unsafe" warnigns on Windows
 
 #include "ggml.h"
 #include "ggml-alloc.h"
 #include <vector>
 #include <thread>
 
+#if defined(_MSC_VER)
+#pragma warning(disable: 4244 4267) // possible loss of data
+#endif
+
 // default hparams (ViT-B SAM)
 struct sam_hparams {
     int32_t n_enc_state               = 768;
@@ -1106,7 +1111,7 @@ struct ggml_tensor * sam_fill_dense_pe(
 
     struct ggml_tensor * cur = ggml_mul_mat(ctx0, ggml_cont(ctx0, ggml_transpose(ctx0, enc.pe)), xy_embed_stacked);
 
-    cur = ggml_scale(ctx0, cur, ggml_new_f32(ctx0, 2.0f*M_PI));
+    cur = ggml_scale(ctx0, cur, ggml_new_f32(ctx0, float(2.0*M_PI)));
 
     // concat
     // ref: https://github.com/facebookresearch/segment-anything/blob/main/segment_anything/modeling/prompt_encoder.py#L192
@@ -1450,7 +1455,7 @@ prompt_encoder_result sam_encode_prompt(
 
     struct ggml_tensor * cur = ggml_mul_mat(ctx0, ggml_cont(ctx0, ggml_transpose(ctx0, enc.pe)), inp);
 
-    cur = ggml_scale(ctx0, cur, ggml_new_f32(ctx0, 2.0f*M_PI));
+    cur = ggml_scale(ctx0, cur, ggml_new_f32(ctx0, float(2.0*M_PI)));
 
     // concat
     // ref: https://github.com/facebookresearch/segment-anything/blob/main/segment_anything/modeling/prompt_encoder.py#L192
index 548ebed7738b5dc716acd6907734b5b846a2133a..946210b85915adb700c76a57e44bb8d6501b3e3a 100644 (file)
@@ -25,7 +25,7 @@ struct starcoder_hparams {
     int32_t n_head  = 16;
     int32_t n_layer = 24;
     int32_t ftype   = 1;
-    float   eps     = 1e-5;
+    float   eps     = 1e-5f;
 };
 
 struct starcoder_layer {
index b86926944726ecedc4ff9618168034fa8e832a34..a224115a1480518643575bcdb5dcfd32340dee4a 100644 (file)
@@ -40,7 +40,7 @@ struct starcoder_hparams {
     int32_t n_head  = 16;
     int32_t n_layer = 24;
     int32_t ftype   = 1;
-    float   eps     = 1e-5;
+    float   eps     = 1e-5f;
 };
 
 struct starcoder_layer {
index 2d1a70b80d187c170e50a0937f4702090e43faf7..cb124ec9b564b12ac03ec37d592a2c7ef98f92d8 100644 (file)
@@ -440,7 +440,7 @@ struct whisper_hparams {
     int32_t n_text_layer  = 4;
     int32_t n_mels        = 80;
     int32_t ftype         = 1;
-    float   eps           = 1e-5;
+    float   eps           = 1e-5f;
 };
 
 // audio encoding layer
index fb534c4cb59e464f9eb887ce5e3588c7ad32786d..74966f3c37673f077347aa9d18a9e14d27ac9f71 100644 (file)
 // disable "possible loss of data" to avoid hundreds of casts
 // we should just be careful :)
 #pragma warning(disable: 4244 4267)
+
+// disable POSIX deprecation warnigns
+// these functions are never going away, anyway
+#pragma warning(disable: 4996)
 #endif
 
 #if defined(_WIN32)