danbev commited on
Commit
bfa2ae7
·
unverified ·
1 Parent(s): d237704

whisper : fix compiler warnings in whisper.cpp (#2895)

Browse files

This commit fixes compiler warnings in whisper.cpp by changing the type
of the loop index variable from int64_t to size_t.

Currently the following warnings are generated by the compiler:
```console
/whisper.cpp/src/whisper.cpp:209:27: warning: comparison of integers of different signs: 'int64_t' (aka 'long long') and 'size_t' (aka 'unsigned long') [-Wsign-compare]
209 | for (int64_t i = 0; i < nels; ++i) {
| ~ ^ ~~~~
/whisper.cpp/src/whisper.cpp:219:27: warning: comparison of integers of different signs: 'int64_t' (aka 'long long') and 'size_t' (aka 'unsigned long') [-Wsign-compare]
219 | for (int64_t i = 0; i < nels; ++i) {
| ~ ^ ~~~~
```

Files changed (1) hide show
  1. src/whisper.cpp +2 -2
src/whisper.cpp CHANGED
@@ -206,7 +206,7 @@ static ggml_tensor * whisper_set_f32(struct ggml_tensor * t, float v) {
206
  GGML_ASSERT(t->type == GGML_TYPE_F32);
207
  GGML_ASSERT(ggml_is_contiguous(t));
208
  size_t nels = ggml_nelements(t);
209
- for (int64_t i = 0; i < nels; ++i) {
210
  ((float *) t->data)[i] = v;
211
  }
212
  return t;
@@ -216,7 +216,7 @@ static ggml_tensor * whisper_set_i32(struct ggml_tensor * t, int32_t v) {
216
  GGML_ASSERT(t->type == GGML_TYPE_I32);
217
  GGML_ASSERT(ggml_is_contiguous(t));
218
  size_t nels = ggml_nelements(t);
219
- for (int64_t i = 0; i < nels; ++i) {
220
  ((int32_t *) t->data)[i] = v;
221
  }
222
  return t;
 
206
  GGML_ASSERT(t->type == GGML_TYPE_F32);
207
  GGML_ASSERT(ggml_is_contiguous(t));
208
  size_t nels = ggml_nelements(t);
209
+ for (size_t i = 0; i < nels; ++i) {
210
  ((float *) t->data)[i] = v;
211
  }
212
  return t;
 
216
  GGML_ASSERT(t->type == GGML_TYPE_I32);
217
  GGML_ASSERT(ggml_is_contiguous(t));
218
  size_t nels = ggml_nelements(t);
219
+ for (size_t i = 0; i < nels; ++i) {
220
  ((int32_t *) t->data)[i] = v;
221
  }
222
  return t;