Skip to content

Commit 0e6cbff

Browse files
committed
llama : fix compile warnings
1 parent 5d5817c commit 0e6cbff

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

examples/benchmark/benchmark-matmult.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ float tensor_sum_elements(struct ggml_tensor * tensor) {
3838

3939
#define TENSOR_TYPE_AS_STR(TYPE) TYPE == GGML_TYPE_F32 ? "FP32" : TYPE == GGML_TYPE_F16 ? "FP16" : TYPE == GGML_TYPE_Q4_0 ? "Q4_0" : TYPE == GGML_TYPE_Q4_1 ? "Q4_1" : "UNKNOWN"
4040

41-
#define TENSOR_DUMP(TENSOR) printf("%15s: type = %i (%5s) ne = %5ld x %5ld x %5ld, nb = (%5li, %5li, %5li) - ", #TENSOR, \
41+
#define TENSOR_DUMP(TENSOR) printf("%15s: type = %i (%5s) ne = %5d x %5d x %5d, nb = (%5li, %5li, %5li) - ", #TENSOR, \
4242
TENSOR->type,TENSOR_TYPE_AS_STR(TENSOR->type),\
43-
TENSOR->ne[0], TENSOR->ne[1], TENSOR->ne[2], TENSOR->nb[0], TENSOR->nb[1], TENSOR->nb[2]); \
43+
(int) TENSOR->ne[0], (int) TENSOR->ne[1], (int) TENSOR->ne[2], TENSOR->nb[0], TENSOR->nb[1], TENSOR->nb[2]); \
4444
{ float sum = tensor_sum_elements(TENSOR); printf("Sum of tensor %s is %6.2f\n",#TENSOR, sum); }
4545

4646
struct benchmark_params_struct {
@@ -138,7 +138,7 @@ int main(int argc, char ** argv) {
138138
ctx = ggml_init(params);
139139
if (!ctx) {
140140
fprintf(stderr, "%s: ggml_init() failed\n", __func__);
141-
return false;
141+
return 1;
142142
}
143143

144144

llama.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,7 +1702,7 @@ void llama_sample_temperature(struct llama_context * ctx, llama_token_data_array
17021702
}
17031703
}
17041704

1705-
void llama_sample_repetition_penalty(struct llama_context * ctx, llama_token_data_array * candidates, llama_token * last_tokens, size_t last_tokens_size, float penalty) {
1705+
void llama_sample_repetition_penalty(struct llama_context * ctx, llama_token_data_array * candidates, const llama_token * last_tokens, size_t last_tokens_size, float penalty) {
17061706
if (last_tokens_size == 0 || penalty == 1.0f) {
17071707
return;
17081708
}
@@ -1731,7 +1731,7 @@ void llama_sample_repetition_penalty(struct llama_context * ctx, llama_token_dat
17311731
}
17321732
}
17331733

1734-
void llama_sample_frequency_and_presence_penalties(struct llama_context * ctx, llama_token_data_array * candidates, llama_token * last_tokens_p, size_t last_tokens_size, float alpha_frequency, float alpha_presence) {
1734+
void llama_sample_frequency_and_presence_penalties(struct llama_context * ctx, llama_token_data_array * candidates, const llama_token * last_tokens_p, size_t last_tokens_size, float alpha_frequency, float alpha_presence) {
17351735
if (last_tokens_size == 0 || (alpha_frequency == 0.0f && alpha_presence == 0.0f)) {
17361736
return;
17371737
}

llama.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ extern "C" {
192192
// Sampling functions
193193

194194
/// @details Repetition penalty described in CTRL academic paper https://arxiv.org/abs/1909.05858, with negative logit fix.
195-
LLAMA_API void llama_sample_repetition_penalty(struct llama_context * ctx, llama_token_data_array * candidates, llama_token * last_tokens, size_t last_tokens_size, float penalty);
195+
LLAMA_API void llama_sample_repetition_penalty(struct llama_context * ctx, llama_token_data_array * candidates, const llama_token * last_tokens, size_t last_tokens_size, float penalty);
196196

197197
/// @details Frequency and presence penalties described in OpenAI API https://platform.openai.com/docs/api-reference/parameter-details.
198-
LLAMA_API void llama_sample_frequency_and_presence_penalties(struct llama_context * ctx, llama_token_data_array * candidates, llama_token * last_tokens, size_t last_tokens_size, float alpha_frequency, float alpha_presence);
198+
LLAMA_API void llama_sample_frequency_and_presence_penalties(struct llama_context * ctx, llama_token_data_array * candidates, const llama_token * last_tokens, size_t last_tokens_size, float alpha_frequency, float alpha_presence);
199199

200200
/// @details Sorts candidate tokens by their logits in descending order and calculate probabilities based on logits.
201201
LLAMA_API void llama_sample_softmax(struct llama_context * ctx, llama_token_data_array * candidates);

tests/test-sampling.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ void test_repetition_penalty(
131131
llama_token_data_array candidates_p = { candidates.data(), candidates.size(), false };
132132
llama_sample_softmax(nullptr, &candidates_p);
133133
DUMP(&candidates_p);
134-
llama_sample_repetition_penalty(nullptr, &candidates_p, (llama_token *)last_tokens.data(), last_tokens.size(), penalty);
134+
llama_sample_repetition_penalty(nullptr, &candidates_p, (const llama_token *) last_tokens.data(), last_tokens.size(), penalty);
135135
llama_sample_softmax(nullptr, &candidates_p);
136136
DUMP(&candidates_p);
137137

@@ -160,7 +160,7 @@ void test_frequency_presence_penalty(
160160
llama_token_data_array candidates_p = { candidates.data(), candidates.size(), false };
161161
llama_sample_softmax(nullptr, &candidates_p);
162162
// DUMP(&candidates_p);
163-
llama_sample_frequency_and_presence_penalties(nullptr, &candidates_p, (llama_token *)last_tokens.data(), last_tokens.size(), alpha_frequency, alpha_presence);
163+
llama_sample_frequency_and_presence_penalties(nullptr, &candidates_p, (const llama_token *) last_tokens.data(), last_tokens.size(), alpha_frequency, alpha_presence);
164164
llama_sample_softmax(nullptr, &candidates_p);
165165
// DUMP(&candidates_p);
166166

0 commit comments

Comments
 (0)