Skip to content

Commit 6eb1f51

Browse files
danbevNeo Zhang
authored andcommitted
llama : suppress unary minus operator warning (ggml-org#8448)
This commit updates the _try_copy lambda and moves the unary minus operator to after the cast to int32_t. The motivation for this that currently the following warning is generated on windows: ```console llama.cpp\src\llama.cpp(21147,30): warning C4146: unary minus operator applied to unsigned type, result still unsigned ```
1 parent 276ef10 commit 6eb1f51

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/llama.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20886,6 +20886,20 @@ int32_t llama_token_to_piece(const struct llama_model * model, llama_token token
2088620886
return 0;
2088720887
}
2088820888

20889+
// copy piece chars to output text buffer
20890+
// skip up to 'lstrip' leading spaces before copying
20891+
auto _try_copy = [=] (const char * token, size_t size) -> int32_t {
20892+
for (int32_t i = 0; i < lstrip && size && *token == ' '; ++i) {
20893+
token++;
20894+
size--;
20895+
}
20896+
if (length < (int32_t)size) {
20897+
return -(int32_t) size;
20898+
}
20899+
memcpy(buf, token, size);
20900+
return (int32_t) size;
20901+
};
20902+
2088920903
// if we have a cache - use it
2089020904
{
2089120905
const auto & cache = model->vocab.cache_token_to_piece;

0 commit comments

Comments
 (0)