Skip to content

Commit f85d0b3

Browse files
committed
llama : remove redundant keywords (struct, enum)
ggml-ci
1 parent 4dbbde7 commit f85d0b3

File tree

6 files changed

+582
-582
lines changed

6 files changed

+582
-582
lines changed

include/llama.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ extern "C" {
471471

472472
LLAMA_API const struct llama_model * llama_get_model (const struct llama_context * ctx); // TODO: remove const?
473473
LLAMA_API struct llama_kv_cache * llama_get_kv_self ( struct llama_context * ctx);
474-
LLAMA_API enum llama_pooling_type llama_pooling_type(const struct llama_context * ctx);
474+
LLAMA_API enum llama_pooling_type llama_pooling_type(const struct llama_context * ctx); // TODO: rename to llama_get_pooling_type
475475

476476
LLAMA_API const struct llama_vocab * llama_model_get_vocab(const struct llama_model * model);
477477
LLAMA_API enum llama_rope_type llama_model_rope_type(const struct llama_model * model);

src/llama-context.cpp

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,7 +1591,7 @@ int32_t llama_context::graph_max_nodes() const {
15911591
}
15921592

15931593
ggml_cgraph * llama_context::graph_init() {
1594-
struct ggml_init_params params = {
1594+
ggml_init_params params = {
15951595
/*.mem_size =*/ buf_compute_meta.size(),
15961596
/*.mem_buffer =*/ buf_compute_meta.data(),
15971597
/*.no_alloc =*/ true,
@@ -1625,7 +1625,7 @@ llm_graph_result_ptr llama_context::graph_build(
16251625
}, gf, gtype);
16261626
}
16271627

1628-
enum ggml_status llama_context::graph_compute(
1628+
ggml_status llama_context::graph_compute(
16291629
ggml_cgraph * gf,
16301630
bool batched) {
16311631
int n_threads = batched ? cparams.n_threads_batch : cparams.n_threads;
@@ -2288,29 +2288,29 @@ llama_context * llama_init_from_model(
22882288
}
22892289

22902290
// deprecated
2291-
struct llama_context * llama_new_context_with_model(
2292-
struct llama_model * model,
2293-
struct llama_context_params params) {
2291+
llama_context * llama_new_context_with_model(
2292+
llama_model * model,
2293+
llama_context_params params) {
22942294
return llama_init_from_model(model, params);
22952295
}
22962296

2297-
void llama_free(struct llama_context * ctx) {
2297+
void llama_free(llama_context * ctx) {
22982298
delete ctx;
22992299
}
23002300

2301-
uint32_t llama_n_ctx(const struct llama_context * ctx) {
2301+
uint32_t llama_n_ctx(const llama_context * ctx) {
23022302
return ctx->n_ctx();
23032303
}
23042304

2305-
uint32_t llama_n_batch(const struct llama_context * ctx) {
2305+
uint32_t llama_n_batch(const llama_context * ctx) {
23062306
return ctx->n_batch();
23072307
}
23082308

2309-
uint32_t llama_n_ubatch(const struct llama_context * ctx) {
2309+
uint32_t llama_n_ubatch(const llama_context * ctx) {
23102310
return ctx->n_ubatch();
23112311
}
23122312

2313-
uint32_t llama_n_seq_max(const struct llama_context * ctx) {
2313+
uint32_t llama_n_seq_max(const llama_context * ctx) {
23142314
return ctx->n_seq_max();
23152315
}
23162316

@@ -2331,69 +2331,69 @@ enum llama_pooling_type llama_pooling_type(const llama_context * ctx) {
23312331
}
23322332

23332333
void llama_attach_threadpool(
2334-
struct llama_context * ctx,
2335-
ggml_threadpool_t threadpool,
2336-
ggml_threadpool_t threadpool_batch) {
2334+
llama_context * ctx,
2335+
ggml_threadpool_t threadpool,
2336+
ggml_threadpool_t threadpool_batch) {
23372337
ctx->attach_threadpool(threadpool, threadpool_batch);
23382338
}
23392339

2340-
void llama_detach_threadpool(struct llama_context * ctx) {
2340+
void llama_detach_threadpool(llama_context * ctx) {
23412341
ctx->detach_threadpool();
23422342
}
23432343

2344-
void llama_set_n_threads(struct llama_context * ctx, int32_t n_threads, int32_t n_threads_batch) {
2344+
void llama_set_n_threads(llama_context * ctx, int32_t n_threads, int32_t n_threads_batch) {
23452345
ctx->set_n_threads(n_threads, n_threads_batch);
23462346
}
23472347

2348-
int32_t llama_n_threads(struct llama_context * ctx) {
2348+
int32_t llama_n_threads(llama_context * ctx) {
23492349
return ctx->n_threads();
23502350
}
23512351

2352-
int32_t llama_n_threads_batch(struct llama_context * ctx) {
2352+
int32_t llama_n_threads_batch(llama_context * ctx) {
23532353
return ctx->n_threads_batch();
23542354
}
23552355

2356-
void llama_set_abort_callback(struct llama_context * ctx, bool (*abort_callback)(void * data), void * abort_callback_data) {
2356+
void llama_set_abort_callback(llama_context * ctx, bool (*abort_callback)(void * data), void * abort_callback_data) {
23572357
ctx->set_abort_callback(abort_callback, abort_callback_data);
23582358
}
23592359

2360-
void llama_set_embeddings(struct llama_context * ctx, bool embeddings) {
2360+
void llama_set_embeddings(llama_context * ctx, bool embeddings) {
23612361
ctx->set_embeddings(embeddings);
23622362
}
23632363

2364-
void llama_set_causal_attn(struct llama_context * ctx, bool causal_attn) {
2364+
void llama_set_causal_attn(llama_context * ctx, bool causal_attn) {
23652365
ctx->set_causal_attn(causal_attn);
23662366
}
23672367

2368-
void llama_synchronize(struct llama_context * ctx) {
2368+
void llama_synchronize(llama_context * ctx) {
23692369
ctx->synchronize();
23702370
}
23712371

2372-
float * llama_get_logits(struct llama_context * ctx) {
2372+
float * llama_get_logits(llama_context * ctx) {
23732373
ctx->synchronize();
23742374

23752375
return ctx->get_logits();
23762376
}
23772377

2378-
float * llama_get_logits_ith(struct llama_context * ctx, int32_t i) {
2378+
float * llama_get_logits_ith(llama_context * ctx, int32_t i) {
23792379
ctx->synchronize();
23802380

23812381
return ctx->get_logits_ith(i);
23822382
}
23832383

2384-
float * llama_get_embeddings(struct llama_context * ctx) {
2384+
float * llama_get_embeddings(llama_context * ctx) {
23852385
ctx->synchronize();
23862386

23872387
return ctx->get_embeddings();
23882388
}
23892389

2390-
float * llama_get_embeddings_ith(struct llama_context * ctx, int32_t i) {
2390+
float * llama_get_embeddings_ith(llama_context * ctx, int32_t i) {
23912391
ctx->synchronize();
23922392

23932393
return ctx->get_embeddings_ith(i);
23942394
}
23952395

2396-
float * llama_get_embeddings_seq(struct llama_context * ctx, llama_seq_id seq_id) {
2396+
float * llama_get_embeddings_seq(llama_context * ctx, llama_seq_id seq_id) {
23972397
ctx->synchronize();
23982398

23992399
return ctx->get_embeddings_seq(seq_id);
@@ -2402,28 +2402,28 @@ float * llama_get_embeddings_seq(struct llama_context * ctx, llama_seq_id seq_id
24022402
// llama adapter API
24032403

24042404
int32_t llama_set_adapter_lora(
2405-
struct llama_context * ctx,
2406-
struct llama_adapter_lora * adapter,
2405+
llama_context * ctx,
2406+
llama_adapter_lora * adapter,
24072407
float scale) {
24082408
ctx->set_adapter_lora(adapter, scale);
24092409

24102410
return 0;
24112411
}
24122412

24132413
int32_t llama_rm_adapter_lora(
2414-
struct llama_context * ctx,
2415-
struct llama_adapter_lora * adapter) {
2414+
llama_context * ctx,
2415+
llama_adapter_lora * adapter) {
24162416
bool res = ctx->rm_adapter_lora(adapter);
24172417

24182418
return res ? 0 : -1;
24192419
}
24202420

2421-
void llama_clear_adapter_lora(struct llama_context * ctx) {
2421+
void llama_clear_adapter_lora(llama_context * ctx) {
24222422
ctx->clear_adapter_lora();
24232423
}
24242424

24252425
int32_t llama_apply_adapter_cvec(
2426-
struct llama_context * ctx,
2426+
llama_context * ctx,
24272427
const float * data,
24282428
size_t len,
24292429
int32_t n_embd,
@@ -2438,7 +2438,7 @@ int32_t llama_apply_adapter_cvec(
24382438
// kv cache view
24392439
//
24402440

2441-
struct llama_kv_cache_view llama_kv_cache_view_init(const llama_context * ctx, int32_t n_seq_max) {
2441+
llama_kv_cache_view llama_kv_cache_view_init(const llama_context * ctx, int32_t n_seq_max) {
24422442
const auto * kv = ctx->get_kv_self();
24432443
if (kv == nullptr) {
24442444
LLAMA_LOG_WARN("%s: the context does not have a KV cache\n", __func__);
@@ -2609,50 +2609,50 @@ void llama_kv_cache_update(llama_context * ctx) {
26092609
// llama state API
26102610

26112611
// deprecated
2612-
size_t llama_get_state_size(struct llama_context * ctx) {
2612+
size_t llama_get_state_size(llama_context * ctx) {
26132613
return llama_state_get_size(ctx);
26142614
}
26152615

26162616
// deprecated
2617-
size_t llama_copy_state_data(struct llama_context * ctx, uint8_t * dst) {
2617+
size_t llama_copy_state_data(llama_context * ctx, uint8_t * dst) {
26182618
return llama_state_get_data(ctx, dst, -1);
26192619
}
26202620

26212621
// deprecated
2622-
size_t llama_set_state_data(struct llama_context * ctx, const uint8_t * src) {
2622+
size_t llama_set_state_data(llama_context * ctx, const uint8_t * src) {
26232623
return llama_state_set_data(ctx, src, -1);
26242624
}
26252625

26262626
// deprecated
2627-
bool llama_load_session_file(struct llama_context * ctx, const char * path_session, llama_token * tokens_out, size_t n_token_capacity, size_t * n_token_count_out) {
2627+
bool llama_load_session_file(llama_context * ctx, const char * path_session, llama_token * tokens_out, size_t n_token_capacity, size_t * n_token_count_out) {
26282628
return llama_state_load_file(ctx, path_session, tokens_out, n_token_capacity, n_token_count_out);
26292629
}
26302630

26312631
// deprecated
2632-
bool llama_save_session_file(struct llama_context * ctx, const char * path_session, const llama_token * tokens, size_t n_token_count) {
2632+
bool llama_save_session_file(llama_context * ctx, const char * path_session, const llama_token * tokens, size_t n_token_count) {
26332633
return llama_state_save_file(ctx, path_session, tokens, n_token_count);
26342634
}
26352635

26362636
// Returns the *actual* size of the state.
26372637
// Intended to be used when saving to state to a buffer.
2638-
size_t llama_state_get_size(struct llama_context * ctx) {
2638+
size_t llama_state_get_size(llama_context * ctx) {
26392639
return ctx->state_get_size();
26402640
}
26412641

2642-
size_t llama_state_get_data(struct llama_context * ctx, uint8_t * dst, size_t size) {
2642+
size_t llama_state_get_data(llama_context * ctx, uint8_t * dst, size_t size) {
26432643
ctx->synchronize();
26442644

26452645
return ctx->state_get_data(dst, size);
26462646
}
26472647

26482648
// Sets the state reading from the specified source address
2649-
size_t llama_state_set_data(struct llama_context * ctx, const uint8_t * src, size_t size) {
2649+
size_t llama_state_set_data(llama_context * ctx, const uint8_t * src, size_t size) {
26502650
ctx->synchronize();
26512651

26522652
return ctx->state_set_data(src, size);
26532653
}
26542654

2655-
bool llama_state_load_file(struct llama_context * ctx, const char * path_session, llama_token * tokens_out, size_t n_token_capacity, size_t * n_token_count_out) {
2655+
bool llama_state_load_file(llama_context * ctx, const char * path_session, llama_token * tokens_out, size_t n_token_capacity, size_t * n_token_count_out) {
26562656
ctx->synchronize();
26572657

26582658
try {
@@ -2663,7 +2663,7 @@ bool llama_state_load_file(struct llama_context * ctx, const char * path_session
26632663
}
26642664
}
26652665

2666-
bool llama_state_save_file(struct llama_context * ctx, const char * path_session, const llama_token * tokens, size_t n_token_count) {
2666+
bool llama_state_save_file(llama_context * ctx, const char * path_session, const llama_token * tokens, size_t n_token_count) {
26672667
ctx->synchronize();
26682668

26692669
try {
@@ -2674,23 +2674,23 @@ bool llama_state_save_file(struct llama_context * ctx, const char * path_session
26742674
}
26752675
}
26762676

2677-
size_t llama_state_seq_get_size(struct llama_context * ctx, llama_seq_id seq_id) {
2677+
size_t llama_state_seq_get_size(llama_context * ctx, llama_seq_id seq_id) {
26782678
return ctx->state_seq_get_size(seq_id);
26792679
}
26802680

2681-
size_t llama_state_seq_get_data(struct llama_context * ctx, uint8_t * dst, size_t size, llama_seq_id seq_id) {
2681+
size_t llama_state_seq_get_data(llama_context * ctx, uint8_t * dst, size_t size, llama_seq_id seq_id) {
26822682
ctx->synchronize();
26832683

26842684
return ctx->state_seq_get_data(seq_id, dst, size);
26852685
}
26862686

2687-
size_t llama_state_seq_set_data(struct llama_context * ctx, const uint8_t * src, size_t size, llama_seq_id seq_id) {
2687+
size_t llama_state_seq_set_data(llama_context * ctx, const uint8_t * src, size_t size, llama_seq_id seq_id) {
26882688
ctx->synchronize();
26892689

26902690
return ctx->state_seq_set_data(seq_id, src, size);
26912691
}
26922692

2693-
size_t llama_state_seq_save_file(struct llama_context * ctx, const char * filepath, llama_seq_id seq_id, const llama_token * tokens, size_t n_token_count) {
2693+
size_t llama_state_seq_save_file(llama_context * ctx, const char * filepath, llama_seq_id seq_id, const llama_token * tokens, size_t n_token_count) {
26942694
ctx->synchronize();
26952695

26962696
try {
@@ -2701,7 +2701,7 @@ size_t llama_state_seq_save_file(struct llama_context * ctx, const char * filepa
27012701
}
27022702
}
27032703

2704-
size_t llama_state_seq_load_file(struct llama_context * ctx, const char * filepath, llama_seq_id dest_seq_id, llama_token * tokens_out, size_t n_token_capacity, size_t * n_token_count_out) {
2704+
size_t llama_state_seq_load_file(llama_context * ctx, const char * filepath, llama_seq_id dest_seq_id, llama_token * tokens_out, size_t n_token_capacity, size_t * n_token_count_out) {
27052705
ctx->synchronize();
27062706

27072707
try {
@@ -2715,8 +2715,8 @@ size_t llama_state_seq_load_file(struct llama_context * ctx, const char * filepa
27152715
///
27162716

27172717
int32_t llama_encode(
2718-
struct llama_context * ctx,
2719-
struct llama_batch batch) {
2718+
llama_context * ctx,
2719+
llama_batch batch) {
27202720
const int ret = ctx->encode(batch);
27212721
if (ret != 0) {
27222722
LLAMA_LOG_ERROR("%s: failed to encode, ret = %d\n", __func__, ret);
@@ -2726,8 +2726,8 @@ int32_t llama_encode(
27262726
}
27272727

27282728
int32_t llama_decode(
2729-
struct llama_context * ctx,
2730-
struct llama_batch batch) {
2729+
llama_context * ctx,
2730+
llama_batch batch) {
27312731
const int ret = ctx->decode(batch);
27322732
if (ret != 0) {
27332733
LLAMA_LOG_ERROR("%s: failed to decode, ret = %d\n", __func__, ret);

src/llama-context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ struct llama_context {
156156
llm_graph_type gtype);
157157

158158
// returns the result of ggml_backend_sched_graph_compute_async execution
159-
enum ggml_status graph_compute(
159+
ggml_status graph_compute(
160160
ggml_cgraph * gf,
161161
bool batched);
162162

src/llama-kv-cache.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ bool llama_kv_cache_unified::init(
4949
auto ctx_for_buft = [&](ggml_backend_buffer_type_t buft) -> ggml_context * {
5050
auto it = ctx_map.find(buft);
5151
if (it == ctx_map.end()) {
52-
struct ggml_init_params params = {
52+
ggml_init_params params = {
5353
/*.mem_size =*/ size_t(2u*n_layer*ggml_tensor_overhead()),
5454
/*.mem_buffer =*/ NULL,
5555
/*.no_alloc =*/ true,
@@ -450,8 +450,8 @@ bool llama_kv_cache_unified::get_can_shift() const {
450450
return can_shift;
451451
}
452452

453-
struct llama_kv_cache_slot_info llama_kv_cache_unified::find_slot(
454-
const struct llama_ubatch & ubatch) {
453+
llama_kv_cache_slot_info llama_kv_cache_unified::find_slot(
454+
const llama_ubatch & ubatch) {
455455
const uint32_t n_tokens = ubatch.n_tokens;
456456
const uint32_t n_seqs = ubatch.n_seqs;
457457
const uint32_t n_seq_tokens = ubatch.n_seq_tokens;
@@ -1335,8 +1335,8 @@ bool llama_kv_cache_can_shift(const llama_kv_cache * kv) {
13351335
// kv cache view
13361336
//
13371337

1338-
struct llama_kv_cache_view llama_kv_cache_view_init(const struct llama_kv_cache & kv, int32_t n_seq_max) {
1339-
struct llama_kv_cache_view result = {
1338+
llama_kv_cache_view llama_kv_cache_view_init(const llama_kv_cache & kv, int32_t n_seq_max) {
1339+
llama_kv_cache_view result = {
13401340
/*.n_cells = */ 0,
13411341
/*.n_seq_max = */ n_seq_max,
13421342
/*.token_count = */ 0,
@@ -1350,7 +1350,7 @@ struct llama_kv_cache_view llama_kv_cache_view_init(const struct llama_kv_cache
13501350
return result;
13511351
}
13521352

1353-
void llama_kv_cache_view_free(struct llama_kv_cache_view * view) {
1353+
void llama_kv_cache_view_free(llama_kv_cache_view * view) {
13541354
if (view->cells != nullptr) {
13551355
free(view->cells);
13561356
view->cells = nullptr;
@@ -1361,7 +1361,7 @@ void llama_kv_cache_view_free(struct llama_kv_cache_view * view) {
13611361
}
13621362
}
13631363

1364-
void llama_kv_cache_view_update(struct llama_kv_cache_view * view, const struct llama_kv_cache * kv) {
1364+
void llama_kv_cache_view_update(llama_kv_cache_view * view, const llama_kv_cache * kv) {
13651365
// TODO: rework this in the future, for now quick hack
13661366
const llama_kv_cache_unified * kvu = dynamic_cast<const llama_kv_cache_unified *>(kv);
13671367
if (kvu == nullptr) {
@@ -1371,9 +1371,9 @@ void llama_kv_cache_view_update(struct llama_kv_cache_view * view, const struct
13711371

13721372
if (uint32_t(view->n_cells) < kvu->size || view->cells == nullptr) {
13731373
view->n_cells = int32_t(kvu->size);
1374-
void * p = realloc(view->cells, sizeof(struct llama_kv_cache_view_cell) * view->n_cells);
1374+
void * p = realloc(view->cells, sizeof(llama_kv_cache_view_cell) * view->n_cells);
13751375
GGML_ASSERT(p != nullptr && "Failed to alloc kv_cache_view cells");
1376-
view->cells = (struct llama_kv_cache_view_cell *)p;
1376+
view->cells = (llama_kv_cache_view_cell *)p;
13771377
p = realloc(view->cells_sequences, sizeof(llama_seq_id) * view->n_seq_max * view->n_cells);
13781378
GGML_ASSERT(p != nullptr && "Failed to alloc kv_cache_view cells sequences");
13791379
view->cells_sequences = (llama_seq_id *)p;

0 commit comments

Comments
 (0)