Skip to content

Commit 11487ed

Browse files
committed
fixed size_t/int comparison error
1 parent bf59e42 commit 11487ed

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

llama.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13044,7 +13044,7 @@ void llama_sample_min_p(struct llama_context * ctx, llama_token_data_array * can
1304413044
}
1304513045
}
1304613046

13047-
void llama_sample_dry(struct llama_context * ctx, llama_token_data_array * candidates, const llama_token * last_tokens, int last_token_size, float dry_base, float dry_multiplier, int dry_allowed_length, const llama_token * seq_breakers, int seq_breakers_size) {
13047+
void llama_sample_dry(struct llama_context * ctx, llama_token_data_array * candidates, const llama_token * last_tokens, size_t last_tokens_size, float dry_base, float dry_multiplier, int dry_allowed_length, const llama_token * seq_breakers, size_t seq_breakers_size) {
1304813048
// loop through each candidate
1304913049
for (size_t i = 0; i < candidates->size; ++i) {
1305013050

@@ -13056,7 +13056,7 @@ void llama_sample_dry(struct llama_context * ctx, llama_token_data_array * candi
1305613056
int max_match_length = 0;
1305713057

1305813058
// loop through each previous token
13059-
for (size_t j = 0; j < last_token_size; ++j) {
13059+
for (size_t j = 0; j < last_tokens_size; ++j) {
1306013060
// if the current candidate is the same as the previous token
1306113061
if (candidates->data[i].id == last_tokens[j]) {
1306213062
// greedily match sequence backwards starting from the current position with the end of prev
@@ -13069,13 +13069,13 @@ void llama_sample_dry(struct llama_context * ctx, llama_token_data_array * candi
1306913069

1307013070
// this shouldn't happen because (j - match_length) should always be smaller than (size - match_length)
1307113071
// but let's check here to avoid the unexpected
13072-
if(last_token_size - match_length < 0) break;
13072+
if(last_tokens_size - match_length < 0) break;
1307313073

1307413074
// compare token starts at our prev index, going backwards by match length
1307513075
auto compare_token = last_tokens[j - match_length];
1307613076

1307713077
// head token starts at the end of prev, going backwards by match length
13078-
auto head_token = last_tokens[last_token_size - match_length];
13078+
auto head_token = last_tokens[last_tokens_size - match_length];
1307913079

1308013080
// if compare token is part of the sequence breakers, break out of the match
1308113081
if(std::find(seq_breakers, seq_breakers + seq_breakers_size, compare_token) != seq_breakers + seq_breakers_size)

llama.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -927,12 +927,12 @@ extern "C" {
927927
struct llama_context * ctx,
928928
llama_token_data_array * candidates,
929929
const llama_token * last_tokens,
930-
int last_token_size,
930+
size_t last_tokens_size,
931931
float dry_base,
932932
float dry_multiplier,
933933
int dry_allowed_length,
934934
const llama_token * seq_breakers,
935-
int seq_breakers_size);
935+
size_t seq_breakers_size);
936936

937937
/// @details Tail Free Sampling described in https://www.trentonbricken.com/Tail-Free-Sampling/.
938938
LLAMA_API void llama_sample_tail_free(

0 commit comments

Comments
 (0)