Spaces:
Running
Running
Roland Rabien
commited on
Remove C++20 requirement (#257)
Browse files* Remove C++20 requirement
* Roll back C features not supported in VS2017
- ggml.c +4 -2
- whisper.cpp +21 -28
ggml.c
CHANGED
|
@@ -155,7 +155,8 @@ static inline float fp32_from_bits(uint32_t w) {
|
|
| 155 |
union {
|
| 156 |
uint32_t as_bits;
|
| 157 |
float as_value;
|
| 158 |
-
} fp32
|
|
|
|
| 159 |
return fp32.as_value;
|
| 160 |
}
|
| 161 |
|
|
@@ -163,7 +164,8 @@ static inline uint32_t fp32_to_bits(float f) {
|
|
| 163 |
union {
|
| 164 |
float as_value;
|
| 165 |
uint32_t as_bits;
|
| 166 |
-
} fp32
|
|
|
|
| 167 |
return fp32.as_bits;
|
| 168 |
}
|
| 169 |
|
|
|
|
| 155 |
union {
|
| 156 |
uint32_t as_bits;
|
| 157 |
float as_value;
|
| 158 |
+
} fp32;
|
| 159 |
+
fp32.as_bits = w;
|
| 160 |
return fp32.as_value;
|
| 161 |
}
|
| 162 |
|
|
|
|
| 164 |
union {
|
| 165 |
float as_value;
|
| 166 |
uint32_t as_bits;
|
| 167 |
+
} fp32;
|
| 168 |
+
fp32.as_value = f;
|
| 169 |
return fp32.as_bits;
|
| 170 |
}
|
| 171 |
|
whisper.cpp
CHANGED
|
@@ -735,10 +735,9 @@ static bool whisper_model_load(const std::string & fname, whisper_context & wctx
|
|
| 735 |
|
| 736 |
// create the ggml context
|
| 737 |
{
|
| 738 |
-
struct ggml_init_params params
|
| 739 |
-
|
| 740 |
-
|
| 741 |
-
};
|
| 742 |
|
| 743 |
model.ctx = ggml_init(params);
|
| 744 |
if (!model.ctx) {
|
|
@@ -945,10 +944,9 @@ static bool whisper_model_load(const std::string & fname, whisper_context & wctx
|
|
| 945 |
|
| 946 |
// create the ggml memory context
|
| 947 |
{
|
| 948 |
-
struct ggml_init_params params
|
| 949 |
-
|
| 950 |
-
|
| 951 |
-
};
|
| 952 |
|
| 953 |
model.ctx_mem = ggml_init(params);
|
| 954 |
if (!model.ctx_mem) {
|
|
@@ -1097,10 +1095,9 @@ static bool whisper_encode(
|
|
| 1097 |
const int n_mels = hparams.n_mels;
|
| 1098 |
assert(mel_inp.n_mel == n_mels);
|
| 1099 |
|
| 1100 |
-
struct ggml_init_params params
|
| 1101 |
-
|
| 1102 |
-
|
| 1103 |
-
};
|
| 1104 |
|
| 1105 |
struct ggml_context * ctx0 = ggml_init(params);
|
| 1106 |
|
|
@@ -1175,10 +1172,9 @@ static bool whisper_encode(
|
|
| 1175 |
|
| 1176 |
// create separate context for each layer to reduce memory usage
|
| 1177 |
|
| 1178 |
-
struct ggml_init_params paramsL
|
| 1179 |
-
|
| 1180 |
-
|
| 1181 |
-
};
|
| 1182 |
|
| 1183 |
struct ggml_context * ctxL = ggml_init(paramsL);
|
| 1184 |
|
|
@@ -1512,10 +1508,9 @@ static bool whisper_decode(
|
|
| 1512 |
const int N = n_tokens;
|
| 1513 |
const int M = wctx.exp_n_audio_ctx > 0 ? wctx.exp_n_audio_ctx : hparams.n_audio_ctx;
|
| 1514 |
|
| 1515 |
-
struct ggml_init_params params
|
| 1516 |
-
|
| 1517 |
-
|
| 1518 |
-
};
|
| 1519 |
|
| 1520 |
struct ggml_context * ctx0 = ggml_init(params);
|
| 1521 |
|
|
@@ -1538,10 +1533,9 @@ static bool whisper_decode(
|
|
| 1538 |
for (int il = 0; il < n_layer; ++il) {
|
| 1539 |
const auto & layer = model.layers_decoder[il];
|
| 1540 |
|
| 1541 |
-
struct ggml_init_params paramsL
|
| 1542 |
-
|
| 1543 |
-
|
| 1544 |
-
};
|
| 1545 |
|
| 1546 |
struct ggml_context * ctxL = ggml_init(paramsL);
|
| 1547 |
struct ggml_cgraph gf = {};
|
|
@@ -2915,10 +2909,9 @@ int whisper_full_parallel(
|
|
| 2915 |
|
| 2916 |
// create the ggml memory context
|
| 2917 |
{
|
| 2918 |
-
struct ggml_init_params params
|
| 2919 |
-
|
| 2920 |
-
|
| 2921 |
-
};
|
| 2922 |
|
| 2923 |
model.ctx_mem = ggml_init(params);
|
| 2924 |
if (!model.ctx_mem) {
|
|
|
|
| 735 |
|
| 736 |
// create the ggml context
|
| 737 |
{
|
| 738 |
+
struct ggml_init_params params;
|
| 739 |
+
params.mem_size = wctx.buf_model->size();
|
| 740 |
+
params.mem_buffer = wctx.buf_model->data();
|
|
|
|
| 741 |
|
| 742 |
model.ctx = ggml_init(params);
|
| 743 |
if (!model.ctx) {
|
|
|
|
| 944 |
|
| 945 |
// create the ggml memory context
|
| 946 |
{
|
| 947 |
+
struct ggml_init_params params;
|
| 948 |
+
params.mem_size = wctx.buf_memory.size();
|
| 949 |
+
params.mem_buffer = wctx.buf_memory.data();
|
|
|
|
| 950 |
|
| 951 |
model.ctx_mem = ggml_init(params);
|
| 952 |
if (!model.ctx_mem) {
|
|
|
|
| 1095 |
const int n_mels = hparams.n_mels;
|
| 1096 |
assert(mel_inp.n_mel == n_mels);
|
| 1097 |
|
| 1098 |
+
struct ggml_init_params params;
|
| 1099 |
+
params.mem_size = wctx.buf_compute.size();
|
| 1100 |
+
params.mem_buffer = wctx.buf_compute.data();
|
|
|
|
| 1101 |
|
| 1102 |
struct ggml_context * ctx0 = ggml_init(params);
|
| 1103 |
|
|
|
|
| 1172 |
|
| 1173 |
// create separate context for each layer to reduce memory usage
|
| 1174 |
|
| 1175 |
+
struct ggml_init_params paramsL;
|
| 1176 |
+
paramsL.mem_size = wctx.buf_compute_layer.size();
|
| 1177 |
+
paramsL.mem_buffer = wctx.buf_compute_layer.data();
|
|
|
|
| 1178 |
|
| 1179 |
struct ggml_context * ctxL = ggml_init(paramsL);
|
| 1180 |
|
|
|
|
| 1508 |
const int N = n_tokens;
|
| 1509 |
const int M = wctx.exp_n_audio_ctx > 0 ? wctx.exp_n_audio_ctx : hparams.n_audio_ctx;
|
| 1510 |
|
| 1511 |
+
struct ggml_init_params params;
|
| 1512 |
+
params.mem_size = wctx.buf_compute.size();
|
| 1513 |
+
params.mem_buffer = wctx.buf_compute.data();
|
|
|
|
| 1514 |
|
| 1515 |
struct ggml_context * ctx0 = ggml_init(params);
|
| 1516 |
|
|
|
|
| 1533 |
for (int il = 0; il < n_layer; ++il) {
|
| 1534 |
const auto & layer = model.layers_decoder[il];
|
| 1535 |
|
| 1536 |
+
struct ggml_init_params paramsL;
|
| 1537 |
+
paramsL.mem_size = wctx.buf_compute_layer.size();
|
| 1538 |
+
paramsL.mem_buffer = wctx.buf_compute_layer.data();
|
|
|
|
| 1539 |
|
| 1540 |
struct ggml_context * ctxL = ggml_init(paramsL);
|
| 1541 |
struct ggml_cgraph gf = {};
|
|
|
|
| 2909 |
|
| 2910 |
// create the ggml memory context
|
| 2911 |
{
|
| 2912 |
+
struct ggml_init_params params;
|
| 2913 |
+
params.mem_size = ctxs[i].buf_memory.size();
|
| 2914 |
+
params.mem_buffer = ctxs[i].buf_memory.data();
|
|
|
|
| 2915 |
|
| 2916 |
model.ctx_mem = ggml_init(params);
|
| 2917 |
if (!model.ctx_mem) {
|