Skip to content

Commit 10eb874

Browse files
committed
shadow : cont gcc
ggml-ci
1 parent f65e3d3 commit 10eb874

File tree

12 files changed

+509
-511
lines changed

12 files changed

+509
-511
lines changed

common/arg.cpp

Lines changed: 468 additions & 468 deletions
Large diffs are not rendered by default.

common/json-schema-to-grammar.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,8 @@ class SchemaConverter {
579579
seq.back().second = false;
580580
} else {
581581
std::string literal;
582-
auto is_non_literal = [&](char c) {
583-
return NON_LITERAL_SET.find(c) != NON_LITERAL_SET.end();
582+
auto is_non_literal = [&](char ch) {
583+
return NON_LITERAL_SET.find(ch) != NON_LITERAL_SET.end();
584584
};
585585
while (i < length) {
586586
if (sub_pattern[i] == '\\' && i < length - 1) {

common/log.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ struct common_log {
255255
thrd = std::thread([this]() {
256256
while (true) {
257257
{
258-
std::unique_lock<std::mutex> lock(mtx);
259-
cv.wait(lock, [this]() { return head != tail; });
258+
std::unique_lock<std::mutex> lock_thrd(mtx);
259+
cv.wait(lock_thrd, [this]() { return head != tail; });
260260

261261
cur = entries[head];
262262

examples/batched-bench/batched-bench.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ int main(int argc, char ** argv) {
6262
llama_batch batch = llama_batch_init(n_kv_max, 0, 1);
6363

6464
// decode in batches of ctx_params.n_batch tokens
65-
auto decode_helper = [](llama_context * ctx, llama_batch & batch, int32_t n_batch) {
65+
auto decode_helper = [&ctx, &batch](int32_t n_batch) {
6666
for (int32_t i = 0; i < (int32_t) batch.n_tokens; i += n_batch) {
6767
const int32_t n_tokens = std::min(n_batch, (int32_t) (batch.n_tokens - i));
6868

@@ -94,7 +94,7 @@ int main(int argc, char ** argv) {
9494
common_batch_add(batch, 0, i, { 0 }, false);
9595
}
9696

97-
if (!decode_helper(ctx, batch, ctx_params.n_batch)) {
97+
if (!decode_helper(ctx_params.n_batch)) {
9898
LOG_ERR("%s: llama_decode() failed\n", __func__);
9999
return 1;
100100
}
@@ -134,7 +134,7 @@ int main(int argc, char ** argv) {
134134

135135
llama_kv_cache_clear(ctx);
136136

137-
if (!decode_helper(ctx, batch, ctx_params.n_batch)) {
137+
if (!decode_helper(ctx_params.n_batch)) {
138138
LOG_ERR("%s: llama_decode() failed\n", __func__);
139139
return 1;
140140
}
@@ -156,7 +156,7 @@ int main(int argc, char ** argv) {
156156
common_batch_add(batch, 0, pp + i, { j }, true);
157157
}
158158

159-
if (!decode_helper(ctx, batch, ctx_params.n_batch)) {
159+
if (!decode_helper(ctx_params.n_batch)) {
160160
LOG_ERR("%s: llama_decode() failed\n", __func__);
161161
return 1;
162162
}

examples/llava/clip.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,7 +2082,7 @@ bool clip_image_preprocess(struct clip_ctx * ctx, const clip_image_u8 * img, cli
20822082
}
20832083
else if (ctx->has_qwen2vl_merger) {
20842084
clip_image_u8 * resized = clip_image_u8_init();
2085-
auto patch_size = clip_patch_size(ctx) * 2;
2085+
auto patch_size = clip_get_patch_size(ctx) * 2;
20862086
int nx = ceil((float)img->nx / patch_size) * patch_size;
20872087
int ny = ceil((float)img->ny / patch_size) * patch_size;
20882088
bicubic_resize(*img, *resized, nx, ny);
@@ -2293,15 +2293,15 @@ size_t clip_embd_nbytes_by_img(const struct clip_ctx * ctx, int img_h, int img_w
22932293
return clip_n_patches_by_img(ctx, &img) * clip_n_mmproj_embd(ctx) * sizeof(float);
22942294
}
22952295

2296-
int32_t clip_image_size(const struct clip_ctx * ctx) {
2296+
int32_t clip_get_image_size(const struct clip_ctx * ctx) {
22972297
return ctx->vision_model.hparams.image_size;
22982298
}
22992299

2300-
int32_t clip_patch_size(const struct clip_ctx * ctx) {
2300+
int32_t clip_get_patch_size(const struct clip_ctx * ctx) {
23012301
return ctx->vision_model.hparams.patch_size;
23022302
}
23032303

2304-
int32_t clip_hidden_size(const struct clip_ctx * ctx) {
2304+
int32_t clip_get_hidden_size(const struct clip_ctx * ctx) {
23052305
return ctx->vision_model.hparams.hidden_size;
23062306
}
23072307

examples/llava/clip.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ CLIP_API void clip_free(struct clip_ctx * ctx);
4747
CLIP_API size_t clip_embd_nbytes(const struct clip_ctx * ctx);
4848
CLIP_API size_t clip_embd_nbytes_by_img(const struct clip_ctx * ctx, int img_h, int img_w);
4949

50-
CLIP_API int32_t clip_image_size (const struct clip_ctx * ctx);
51-
CLIP_API int32_t clip_patch_size (const struct clip_ctx * ctx);
52-
CLIP_API int32_t clip_hidden_size(const struct clip_ctx * ctx);
50+
CLIP_API int32_t clip_get_image_size (const struct clip_ctx * ctx);
51+
CLIP_API int32_t clip_get_patch_size (const struct clip_ctx * ctx);
52+
CLIP_API int32_t clip_get_hidden_size(const struct clip_ctx * ctx);
5353

5454
// TODO: should be enum, not string
5555
CLIP_API const char * clip_patch_merge_type(const struct clip_ctx * ctx);

examples/llava/llava.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ static bool clip_llava_handle_patches(clip_ctx * ctx_clip, std::vector<float *>
105105
struct ggml_context * ctx;
106106
} model;
107107

108-
const int32_t image_size = clip_image_size(ctx_clip);
109-
const int32_t patch_size = clip_patch_size(ctx_clip);
108+
const int32_t image_size = clip_get_image_size(ctx_clip);
109+
const int32_t patch_size = clip_get_patch_size(ctx_clip);
110110

111111
int32_t num_patches_per_side = image_size / patch_size; // 336 / 14 = 24 - used for embedding-patching boxes (24*24 = 576 patches)
112112

@@ -353,7 +353,7 @@ static bool encode_image_with_clip(clip_ctx * ctx_clip, int n_threads, const cli
353353
img_res_v.size = 0;
354354
img_res_v.data = nullptr;
355355

356-
const int32_t image_size = clip_image_size(ctx_clip);
356+
const int32_t image_size = clip_get_image_size(ctx_clip);
357357

358358
struct clip_image_grid_shape grid_shape = get_anyres_image_grid_shape({img->nx,img->ny}, grid_pinpoints, image_size);
359359

examples/server/server.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3702,8 +3702,8 @@ int main(int argc, char ** argv) {
37023702
ctx_server.receive_cmpl_results_stream(task_ids, [&](server_task_result_ptr & result) -> bool {
37033703
json res_json = result->to_json();
37043704
if (res_json.is_array()) {
3705-
for (const auto & res : res_json) {
3706-
if (!server_sent_event(sink, "data", res)) {
3705+
for (const auto & item : res_json) {
3706+
if (!server_sent_event(sink, "data", item)) {
37073707
return false;
37083708
}
37093709
}
@@ -3973,9 +3973,9 @@ int main(int argc, char ** argv) {
39733973
std::unordered_set<int> task_ids = server_task::get_list_id(tasks);
39743974

39753975
ctx_server.receive_multi_results(task_ids, [&](std::vector<server_task_result_ptr> & results) {
3976-
for (auto & res : results) {
3977-
GGML_ASSERT(dynamic_cast<server_task_result_embd*>(res.get()) != nullptr);
3978-
responses.push_back(res->to_json());
3976+
for (auto & result : results) {
3977+
GGML_ASSERT(dynamic_cast<server_task_result_embd*>(result.get()) != nullptr);
3978+
responses.push_back(result->to_json());
39793979
}
39803980
}, [&](const json & error_data) {
39813981
res_error(res, error_data);
@@ -4063,9 +4063,9 @@ int main(int argc, char ** argv) {
40634063
std::unordered_set<int> task_ids = server_task::get_list_id(tasks);
40644064

40654065
ctx_server.receive_multi_results(task_ids, [&](std::vector<server_task_result_ptr> & results) {
4066-
for (auto & res : results) {
4067-
GGML_ASSERT(dynamic_cast<server_task_result_rerank*>(res.get()) != nullptr);
4068-
responses.push_back(res->to_json());
4066+
for (auto & result : results) {
4067+
GGML_ASSERT(dynamic_cast<server_task_result_rerank*>(result.get()) != nullptr);
4068+
responses.push_back(result->to_json());
40694069
}
40704070
}, [&](const json & error_data) {
40714071
res_error(res, error_data);

examples/simple-chat/simple-chat.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,8 @@ int main(int argc, char ** argv) {
110110
llama_token new_token_id;
111111
while (true) {
112112
// check if we have enough space in the context to evaluate this batch
113-
int n_ctx = llama_n_ctx(ctx);
114113
int n_ctx_used = llama_get_kv_cache_used_cells(ctx);
115-
if (n_ctx_used + batch.n_tokens > n_ctx) {
114+
if (n_ctx_used + batch.n_tokens > (int) llama_n_ctx(ctx)) {
116115
printf("\033[0m\n");
117116
fprintf(stderr, "context size exceeded\n");
118117
exit(0);

src/llama-model.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,9 @@ static buft_list_t make_gpu_buft_list(ggml_backend_dev_t dev, enum llama_split_m
311311
ggml_backend_reg_get_proc_address(reg, "ggml_backend_split_buffer_type");
312312
if (ggml_backend_split_buffer_type_fn) {
313313
size_t dev_index = [&]() {
314-
auto * reg = ggml_backend_dev_backend_reg(dev);
315-
for (size_t i = 0; i < ggml_backend_reg_dev_count(reg); ++i) {
316-
if (ggml_backend_reg_dev_get(reg, i) == dev) {
314+
ggml_backend_reg_t reg_dev = ggml_backend_dev_backend_reg(dev);
315+
for (size_t i = 0; i < ggml_backend_reg_dev_count(reg_dev); ++i) {
316+
if (ggml_backend_reg_dev_get(reg_dev, i) == dev) {
317317
return i;
318318
}
319319
}
@@ -1304,7 +1304,7 @@ bool llama_model::load_tensors(llama_model_loader & ml) {
13041304
const int act_gpu_layers = devices.empty() ? 0 : std::min(n_gpu_layers, (int)n_layer + 1);
13051305
auto get_layer_buft_list = [&](int il) -> llama_model::impl::layer_dev {
13061306
if (il < i_gpu_start || (il - i_gpu_start) >= act_gpu_layers) {
1307-
return {cpu_dev, &pimpl->cpu_buft_list};
1307+
return { cpu_dev, &pimpl->cpu_buft_list };
13081308
}
13091309
const int layer_gpu = std::upper_bound(splits.begin(), splits.begin() + n_devices(), float(il - i_gpu_start)/act_gpu_layers) - splits.begin();
13101310
auto * dev = devices.at(layer_gpu);
@@ -1453,7 +1453,6 @@ bool llama_model::load_tensors(llama_model_loader & ml) {
14531453
// avoid using a host buffer when using mmap
14541454
auto * buft_dev = ggml_backend_buft_get_device(buft);
14551455
if (ml.use_mmap && buft_dev && buft == ggml_backend_dev_host_buffer_type(buft_dev)) {
1456-
auto * cpu_dev = ggml_backend_dev_by_type(GGML_BACKEND_DEVICE_TYPE_CPU);
14571456
buft = ggml_backend_dev_buffer_type(cpu_dev);
14581457
}
14591458

@@ -3697,8 +3696,8 @@ ggml_backend_buffer_type_t llama_model::select_buft(int il) const {
36973696

36983697
const struct ggml_tensor * llama_model::get_tensor(const char * name) const {
36993698
auto it = std::find_if(tensors_by_name.begin(), tensors_by_name.end(),
3700-
[name](const std::pair<std::string, struct ggml_tensor *> & it) {
3701-
return it.first == name;
3699+
[name](const std::pair<std::string, struct ggml_tensor *> & entry) {
3700+
return entry.first == name;
37023701
});
37033702
if (it == tensors_by_name.end()) {
37043703
return nullptr;

0 commit comments

Comments
 (0)