Skip to content

Commit 9f44a2f

Browse files
committed
replaced all API facing int's with int32_t
1 parent afefa31 commit 9f44a2f

File tree

2 files changed

+56
-57
lines changed

2 files changed

+56
-57
lines changed

llama.cpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7512,7 +7512,7 @@ void llama_sample_softmax(struct llama_context * ctx, llama_token_data_array * c
75127512
}
75137513
}
75147514

7515-
void llama_sample_top_k(struct llama_context * ctx, llama_token_data_array * candidates, int k, size_t min_keep) {
7515+
void llama_sample_top_k(struct llama_context * ctx, llama_token_data_array * candidates, int32_t k, size_t min_keep) {
75167516
const int64_t t_start_sample_us = ggml_time_us();
75177517

75187518
k = std::max(k, (int) min_keep);
@@ -7872,7 +7872,7 @@ void llama_sample_classifier_free_guidance(
78727872
}
78737873
}
78747874

7875-
llama_token llama_sample_token_mirostat(struct llama_context * ctx, llama_token_data_array * candidates, float tau, float eta, int m, float * mu) {
7875+
llama_token llama_sample_token_mirostat(struct llama_context * ctx, llama_token_data_array * candidates, float tau, float eta, int32_t m, float * mu) {
78767876
GGML_ASSERT(ctx);
78777877

78787878
auto N = float(llama_n_vocab(llama_get_model(ctx)));
@@ -9080,7 +9080,7 @@ struct llama_model_quantize_params llama_model_quantize_default_params() {
90809080
return result;
90819081
}
90829082

9083-
int llama_max_devices(void) {
9083+
int32_t llama_max_devices(void) {
90849084
return LLAMA_MAX_DEVICES;
90859085
}
90869086

@@ -9383,23 +9383,23 @@ enum llama_vocab_type llama_vocab_type(const struct llama_model * model) {
93839383
return model->vocab.type;
93849384
}
93859385

9386-
int llama_n_vocab(const struct llama_model * model) {
9386+
int32_t llama_n_vocab(const struct llama_model * model) {
93879387
return model->vocab.id_to_token.size();
93889388
}
93899389

9390-
int llama_n_ctx_train(const struct llama_model * model) {
9390+
int32_t llama_n_ctx_train(const struct llama_model * model) {
93919391
return model->hparams.n_ctx_train;
93929392
}
93939393

9394-
int llama_n_embd(const struct llama_model * model) {
9394+
int32_t llama_n_embd(const struct llama_model * model) {
93959395
return model->hparams.n_embd;
93969396
}
93979397

93989398
float llama_rope_freq_scale_train(const struct llama_model * model) {
93999399
return model->hparams.rope_freq_scale_train;
94009400
}
94019401

9402-
int llama_model_meta_val_str(const struct llama_model * model, const char * key, char * buf, size_t buf_size) {
9402+
int32_t llama_model_meta_val_str(const struct llama_model * model, const char * key, char * buf, size_t buf_size) {
94039403
const auto & it = model->gguf_kv.find(key);
94049404
if (it == model->gguf_kv.end()) {
94059405
if (buf_size > 0) {
@@ -9410,11 +9410,11 @@ int llama_model_meta_val_str(const struct llama_model * model, const char * key,
94109410
return snprintf(buf, buf_size, "%s", it->second.c_str());
94119411
}
94129412

9413-
int llama_model_meta_count(const struct llama_model * model) {
9413+
int32_t llama_model_meta_count(const struct llama_model * model) {
94149414
return (int)model->gguf_kv.size();
94159415
}
94169416

9417-
int llama_model_meta_key_by_index(const struct llama_model * model, int i, char * buf, size_t buf_size) {
9417+
int32_t llama_model_meta_key_by_index(const struct llama_model * model, int i, char * buf, size_t buf_size) {
94189418
if (i < 0 || i >= (int)model->gguf_kv.size()) {
94199419
if (buf_size > 0) {
94209420
buf[0] = '\0';
@@ -9426,7 +9426,7 @@ int llama_model_meta_key_by_index(const struct llama_model * model, int i, char
94269426
return snprintf(buf, buf_size, "%s", it->first.c_str());
94279427
}
94289428

9429-
int llama_model_meta_val_str_by_index(const struct llama_model * model, int i, char * buf, size_t buf_size) {
9429+
int32_t llama_model_meta_val_str_by_index(const struct llama_model * model, int32_t i, char * buf, size_t buf_size) {
94309430
if (i < 0 || i >= (int)model->gguf_kv.size()) {
94319431
if (buf_size > 0) {
94329432
buf[0] = '\0';
@@ -9438,7 +9438,7 @@ int llama_model_meta_val_str_by_index(const struct llama_model * model, int i, c
94389438
return snprintf(buf, buf_size, "%s", it->second.c_str());
94399439
}
94409440

9441-
int llama_model_desc(const struct llama_model * model, char * buf, size_t buf_size) {
9441+
int32_t llama_model_desc(const struct llama_model * model, char * buf, size_t buf_size) {
94429442
return snprintf(buf, buf_size, "%s %s %s",
94439443
llama_model_arch_name(model->arch).c_str(),
94449444
llama_model_type_name(model->type),
@@ -9465,7 +9465,7 @@ struct ggml_tensor * llama_get_model_tensor(struct llama_model * model, const ch
94659465
return ggml_get_tensor(model->ctx, name);
94669466
}
94679467

9468-
int llama_model_quantize(
9468+
uint32_t llama_model_quantize(
94699469
const char * fname_inp,
94709470
const char * fname_out,
94719471
const llama_model_quantize_params * params) {
@@ -9478,7 +9478,7 @@ int llama_model_quantize(
94789478
}
94799479
}
94809480

9481-
int llama_apply_lora_from_file(struct llama_context * ctx, const char * path_lora, float scale, const char * path_base_model, int n_threads) {
9481+
int32_t llama_apply_lora_from_file(struct llama_context * ctx, const char * path_lora, float scale, const char * path_base_model, int n_threads) {
94829482
try {
94839483
return llama_apply_lora_from_file_internal(ctx->model, path_lora, scale, path_base_model, n_threads);
94849484
} catch (const std::exception & err) {
@@ -9487,7 +9487,7 @@ int llama_apply_lora_from_file(struct llama_context * ctx, const char * path_lor
94879487
}
94889488
}
94899489

9490-
int llama_model_apply_lora_from_file(const struct llama_model * model, const char * path_lora, float scale, const char * path_base_model, int n_threads) {
9490+
int32_t llama_model_apply_lora_from_file(const struct llama_model * model, const char * path_lora, float scale, const char * path_base_model, int32_t n_threads) {
94919491
try {
94929492
return llama_apply_lora_from_file_internal(*model, path_lora, scale, path_base_model, n_threads);
94939493
} catch (const std::exception & err) {
@@ -9585,7 +9585,7 @@ void llama_kv_cache_view_update(const struct llama_context * ctx, struct llama_k
95859585
}
95869586
}
95879587

9588-
int llama_get_kv_cache_token_count(const struct llama_context * ctx) {
9588+
int32_t llama_get_kv_cache_token_count(const struct llama_context * ctx) {
95899589
int result = 0;
95909590

95919591
for (uint32_t i = 0; i < ctx->kv_self.size; i++) {
@@ -9595,7 +9595,7 @@ int llama_get_kv_cache_token_count(const struct llama_context * ctx) {
95959595
return result;
95969596
}
95979597

9598-
int llama_get_kv_cache_used_cells(const struct llama_context * ctx) {
9598+
int32_t llama_get_kv_cache_used_cells(const struct llama_context * ctx) {
95999599
return ctx->kv_self.used;
96009600
}
96019601

@@ -10075,7 +10075,7 @@ int llama_eval(
1007510075
struct llama_context * ctx,
1007610076
llama_token * tokens,
1007710077
int32_t n_tokens,
10078-
int n_past) {
10078+
int32_t n_past) {
1007910079
llama_kv_cache_seq_rm(ctx->kv_self, -1, n_past, -1);
1008010080

1008110081
const int ret = llama_decode_internal(*ctx, llama_batch_get_one(tokens, n_tokens, n_past, 0));
@@ -10090,7 +10090,7 @@ int llama_eval_embd(
1009010090
struct llama_context * ctx,
1009110091
float * embd,
1009210092
int32_t n_tokens,
10093-
int n_past) {
10093+
int32_t n_past) {
1009410094
llama_kv_cache_seq_rm(ctx->kv_self, -1, n_past, -1);
1009510095

1009610096
llama_batch batch = { n_tokens, nullptr, embd, nullptr, nullptr, nullptr, nullptr, n_past, 1, 0, };
@@ -10161,7 +10161,7 @@ void llama_batch_free(struct llama_batch batch) {
1016110161
if (batch.logits) free(batch.logits);
1016210162
}
1016310163

10164-
int llama_decode(
10164+
int32_t llama_decode(
1016510165
struct llama_context * ctx,
1016610166
struct llama_batch batch) {
1016710167
const int ret = llama_decode_internal(*ctx, batch);
@@ -10209,11 +10209,11 @@ llama_token llama_token_nl(const struct llama_model * model) {
1020910209
return model->vocab.linefeed_id;
1021010210
}
1021110211

10212-
int llama_add_bos_token(const struct llama_model * model) {
10212+
int32_t llama_add_bos_token(const struct llama_model * model) {
1021310213
return model->vocab.special_add_bos;
1021410214
}
1021510215

10216-
int llama_add_eos_token(const struct llama_model * model) {
10216+
int32_t llama_add_eos_token(const struct llama_model * model) {
1021710217
return model->vocab.special_add_eos;
1021810218
}
1021910219

@@ -10233,12 +10233,12 @@ llama_token llama_token_eot(const struct llama_model * model) {
1023310233
return model->vocab.special_eot_id;
1023410234
}
1023510235

10236-
int llama_tokenize(
10236+
int32_t llama_tokenize(
1023710237
const struct llama_model * model,
1023810238
const char * text,
10239-
int text_len,
10239+
int32_t text_len,
1024010240
llama_token * tokens,
10241-
int n_max_tokens,
10241+
int32_t n_max_tokens,
1024210242
bool add_bos,
1024310243
bool special) {
1024410244
auto res = llama_tokenize_internal(model->vocab, std::string(text, text_len), add_bos, special);
@@ -10266,7 +10266,7 @@ static std::string llama_decode_text(const std::string & text) {
1026610266
}
1026710267

1026810268
// does not write null-terminator to buf
10269-
int llama_token_to_piece(const struct llama_model * model, llama_token token, char * buf, int length) {
10269+
int32_t llama_token_to_piece(const struct llama_model * model, llama_token token, char * buf, int length) {
1027010270
if (0 <= token && token < llama_n_vocab(model)) {
1027110271
switch (llama_vocab_get_type(model->vocab)) {
1027210272
case LLAMA_VOCAB_TYPE_SPM: {

0 commit comments

Comments
 (0)