rewrite ternary expressions

Co-authored-by: Henri Vasserman <henv@hot.ee>
This commit is contained in:
Evan Jones 2023-06-17 21:58:17 -04:00 committed by GitHub
parent 414f25104b
commit 18e6221ade
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2293,11 +2293,14 @@ void llama_sample_grammar(struct llama_context * ctx, llama_token_data_array * c
// prune tokens based on first char only - in `llama_grammar_accept_token` we will find the // prune tokens based on first char only - in `llama_grammar_accept_token` we will find the
// full matching prefix of the selected token // full matching prefix of the selected token
const bool valid = str[0] == ' ' bool valid = false;
? llama_grammar_peek(stacks_after_space, str[1]) if (id == eos) {
: str[0] || id == eos valid = llama_grammar_peek(grammar->stacks, 0);
? llama_grammar_peek(grammar->stacks, id == eos ? 0 : str[0]) } else if (str[0] == ' ') {
: false; valid = llama_grammar_peek(stacks_after_space, str[1]);
} else if (str[0] != 0) {
valid = llama_grammar_peek(grammar->stacks, str[0]);
}
if (!valid) { if (!valid) {
candidates->data[i].logit = -INFINITY; candidates->data[i].logit = -INFINITY;