From: Borislav Stanimirov Date: Tue, 29 Aug 2023 13:36:59 +0000 (+0300) Subject: build : fix msvc warnings (#496) X-Git-Tag: upstream/0.0.1642~1255 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=7b5fcf5f2a676e6d7c018c6a15dcb6338d9b2a38;p=pkg%2Fggml%2Fsources%2Fggml build : fix msvc warnings (#496) --- diff --git a/examples/dolly-v2/main.cpp b/examples/dolly-v2/main.cpp index 18ad1ad8..70200eb3 100644 --- a/examples/dolly-v2/main.cpp +++ b/examples/dolly-v2/main.cpp @@ -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:"; diff --git a/examples/gpt-2/main.cpp b/examples/gpt-2/main.cpp index 14caf2cc..81859ca5 100644 --- a/examples/gpt-2/main.cpp +++ b/examples/gpt-2/main.cpp @@ -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 { diff --git a/examples/gpt-j/main.cpp b/examples/gpt-j/main.cpp index d5fca51b..e5ab5bad 100644 --- a/examples/gpt-j/main.cpp +++ b/examples/gpt-j/main.cpp @@ -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 { diff --git a/examples/gpt-neox/main.cpp b/examples/gpt-neox/main.cpp index 68ba723d..457a5838 100644 --- a/examples/gpt-neox/main.cpp +++ b/examples/gpt-neox/main.cpp @@ -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 { diff --git a/examples/mpt/main.cpp b/examples/mpt/main.cpp index 5fec3c12..9b2fa02c 100644 --- a/examples/mpt/main.cpp +++ b/examples/mpt/main.cpp @@ -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); diff --git a/examples/replit/main.cpp b/examples/replit/main.cpp index bd614399..b8338cbb 100644 --- a/examples/replit/main.cpp +++ b/examples/replit/main.cpp @@ -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); diff --git a/examples/sam/main.cpp b/examples/sam/main.cpp index e8bfbb3d..7a140006 100644 --- a/examples/sam/main.cpp +++ b/examples/sam/main.cpp @@ -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" @@ -18,6 +19,10 @@ #include #include +#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 diff --git a/examples/starcoder/main.cpp b/examples/starcoder/main.cpp index 548ebed7..946210b8 100644 --- a/examples/starcoder/main.cpp +++ b/examples/starcoder/main.cpp @@ -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 { diff --git a/examples/starcoder/starcoder-mmap.cpp b/examples/starcoder/starcoder-mmap.cpp index b8692694..a224115a 100644 --- a/examples/starcoder/starcoder-mmap.cpp +++ b/examples/starcoder/starcoder-mmap.cpp @@ -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 { diff --git a/examples/whisper/whisper.cpp b/examples/whisper/whisper.cpp index 2d1a70b8..cb124ec9 100644 --- a/examples/whisper/whisper.cpp +++ b/examples/whisper/whisper.cpp @@ -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 diff --git a/src/ggml.c b/src/ggml.c index fb534c4c..74966f3c 100644 --- a/src/ggml.c +++ b/src/ggml.c @@ -47,6 +47,10 @@ // 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)