Skip to content

llama: fix some return values to match hparams types #8461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions include/llama.h
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,10 @@ extern "C" {
LLAMA_API enum llama_vocab_type llama_vocab_type (const struct llama_model * model);
LLAMA_API enum llama_rope_type llama_rope_type (const struct llama_model * model);

LLAMA_API int32_t llama_n_vocab (const struct llama_model * model);
LLAMA_API int32_t llama_n_ctx_train(const struct llama_model * model);
LLAMA_API int32_t llama_n_embd (const struct llama_model * model);
LLAMA_API int32_t llama_n_layer (const struct llama_model * model);
LLAMA_API uint32_t llama_n_vocab (const struct llama_model * model);
LLAMA_API uint32_t llama_n_ctx_train(const struct llama_model * model);
LLAMA_API uint32_t llama_n_embd (const struct llama_model * model);
LLAMA_API uint32_t llama_n_layer (const struct llama_model * model);

// Get the model's RoPE frequency scaling factor
LLAMA_API float llama_rope_freq_scale_train(const struct llama_model * model);
Expand Down
12 changes: 6 additions & 6 deletions src/llama.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17436,7 +17436,7 @@ void llama_sample_apply_guidance(
llama_log_softmax(logits, n_vocab);
llama_log_softmax(logits_guidance, n_vocab);

for (int i = 0; i < n_vocab; ++i) {
for (uint32_t i = 0; i < n_vocab; ++i) {
auto & l = logits[i];
const auto & g = logits_guidance[i];

Expand Down Expand Up @@ -19398,19 +19398,19 @@ enum llama_pooling_type llama_pooling_type(const struct llama_context * ctx) {
return ctx->cparams.pooling_type;
}

int32_t llama_n_vocab(const struct llama_model * model) {
uint32_t llama_n_vocab(const struct llama_model * model) {
return model->hparams.n_vocab;
}

int32_t llama_n_ctx_train(const struct llama_model * model) {
uint32_t llama_n_ctx_train(const struct llama_model * model) {
return model->hparams.n_ctx_train;
}

int32_t llama_n_embd(const struct llama_model * model) {
uint32_t llama_n_embd(const struct llama_model * model) {
return model->hparams.n_embd;
}

int32_t llama_n_layer(const struct llama_model * model) {
uint32_t llama_n_layer(const struct llama_model * model) {
return model->hparams.n_layer;
}

Expand Down Expand Up @@ -21160,7 +21160,7 @@ int32_t llama_token_to_piece(const struct llama_model * model, llama_token token
}
}

if (0 <= token && token < llama_n_vocab(model)) {
if (0 <= token && token < (llama_token)llama_n_vocab(model)) {
const std::string & token_text = model->vocab.id_to_token[token].text;
switch (llama_vocab_get_type(model->vocab)) {
case LLAMA_VOCAB_TYPE_WPM:
Expand Down
Loading