diff options
author | Olivier Chafik <ochafik@users.noreply.github.com> | 2024-04-11 19:47:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-11 19:47:34 +0100 |
commit | cbaadc92942c50aab599a9e4c163afc1f44f7c26 (patch) | |
tree | 0a4b962430740a81a6b1789f1edd9ee50074dde3 /tests | |
parent | 1bbdaf6ecda6f0a360dfb307b256fcb6838c560b (diff) |
grammars: 1.5x faster inference w/ complex grammars (vector reserves / reuses) (#6609)
* grammars: reserve rejects & next candidates
* grammars: reuse new_stacks
* grammars: fix missing sig change in llama.h
* grammars: fix test (api changed)
* grammars: update gbnf-validator.cpp
* grammars: simpler syntax (no swap)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-grammar-integration.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/test-grammar-integration.cpp b/tests/test-grammar-integration.cpp index 0a9c3b6f..2d8f228e 100644 --- a/tests/test-grammar-integration.cpp +++ b/tests/test-grammar-integration.cpp @@ -38,7 +38,7 @@ number ::= [0-9]+)"""; for (auto it = code_points.begin(), end = code_points.end() - 1; it != end; ++it) { auto prev_stacks = grammar->stacks; - grammar->stacks = llama_grammar_accept(grammar->rules, grammar->stacks, *it); + llama_grammar_accept(grammar->rules, prev_stacks, *it, grammar->stacks); assert(!grammar->stacks.empty()); } @@ -138,7 +138,7 @@ ws ::= [ \t\n\r]?)"""; for (auto it = code_points.begin(), end = code_points.end() - 1; it != end; ++it) { ++pos; auto prev_stacks = grammar->stacks; - grammar->stacks = llama_grammar_accept(grammar->rules, grammar->stacks, *it); + llama_grammar_accept(grammar->rules, prev_stacks, *it, grammar->stacks); // Expect that each code point will not cause the grammar to fail if (grammar->stacks.empty()) { @@ -173,7 +173,7 @@ ws ::= [ \t\n\r]?)"""; for (auto it = code_points.begin(), end = code_points.end() - 1; it != end; ++it) { auto prev_stacks = grammar->stacks; - grammar->stacks = llama_grammar_accept(grammar->rules, grammar->stacks, *it); + llama_grammar_accept(grammar->rules, prev_stacks, *it, grammar->stacks); if (grammar->stacks.empty()) { parse_failed = true; break; |