Skip to content

Commit 2a92bfb

Browse files
committed
code style fixes
1 parent adc4aed commit 2a92bfb

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

common/json-schema-to-grammar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ std::string json_schema_to_grammar(const json & schema) {
999999
callbacks.resolve_refs(copy);
10001000
callbacks.add_schema("", copy);
10011001
});
1002-
#endif
1002+
#endif // LLAMA_USE_LLGUIDANCE
10031003
}
10041004

10051005
std::string build_grammar(const std::function<void(const llama_grammar_builder &)> & cb) {

common/llguidance.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#include "llguidance.h"
99

1010
struct llama_sampler_llg {
11-
const struct llama_model * model;
12-
const struct llama_vocab * vocab;
11+
const llama_model * model;
12+
const llama_vocab * vocab;
1313
std::string grammar_kind;
1414
std::string grammar_data;
1515
LlgTokenizer *tokenizer;
@@ -31,11 +31,11 @@ static LlgConstraint *llama_sampler_llg_new(LlgTokenizer *tokenizer,
3131
return c;
3232
}
3333

34-
static const char * llama_sampler_llg_name(const struct llama_sampler * /*smpl*/) {
34+
static const char * llama_sampler_llg_name(const llama_sampler * /*smpl*/) {
3535
return "llguidance";
3636
}
3737

38-
static void llama_sampler_llg_accept_impl(struct llama_sampler * smpl, llama_token token) {
38+
static void llama_sampler_llg_accept_impl(llama_sampler * smpl, llama_token token) {
3939
auto * ctx = (llama_sampler_llg *) smpl->ctx;
4040
if (ctx->grammar) {
4141
LlgCommitResult res;
@@ -44,7 +44,7 @@ static void llama_sampler_llg_accept_impl(struct llama_sampler * smpl, llama_tok
4444
}
4545
}
4646

47-
static void llama_sampler_llg_apply(struct llama_sampler * smpl, llama_token_data_array * cur_p) {
47+
static void llama_sampler_llg_apply(llama_sampler * smpl, llama_token_data_array * cur_p) {
4848
auto * ctx = (llama_sampler_llg *) smpl->ctx;
4949
if (ctx->grammar) {
5050
if (!ctx->has_llg_res) {
@@ -76,7 +76,7 @@ static void llama_sampler_llg_apply(struct llama_sampler * smpl, llama_token_dat
7676
}
7777
}
7878

79-
static void llama_sampler_llg_reset(struct llama_sampler * smpl) {
79+
static void llama_sampler_llg_reset(llama_sampler * smpl) {
8080
auto * ctx = (llama_sampler_llg *) smpl->ctx;
8181
if (!ctx->grammar) {
8282
return;
@@ -88,7 +88,7 @@ static void llama_sampler_llg_reset(struct llama_sampler * smpl) {
8888
ctx->has_llg_res = false;
8989
}
9090

91-
static struct llama_sampler * llama_sampler_llg_clone(const struct llama_sampler * smpl) {
91+
static llama_sampler * llama_sampler_llg_clone(const llama_sampler * smpl) {
9292
const auto * ctx = (const llama_sampler_llg *) smpl->ctx;
9393

9494
auto * result = llama_sampler_init_llg(ctx->model, nullptr, nullptr);
@@ -108,7 +108,7 @@ static struct llama_sampler * llama_sampler_llg_clone(const struct llama_sampler
108108
return result;
109109
}
110110

111-
static void llama_sampler_llg_free(struct llama_sampler * smpl) {
111+
static void llama_sampler_llg_free(llama_sampler * smpl) {
112112
const auto * ctx = (llama_sampler_llg *) smpl->ctx;
113113

114114
if (ctx->grammar) {
@@ -119,7 +119,7 @@ static void llama_sampler_llg_free(struct llama_sampler * smpl) {
119119
delete ctx;
120120
}
121121

122-
static struct llama_sampler_i llama_sampler_llg_i = {
122+
static llama_sampler_i llama_sampler_llg_i = {
123123
/* .name = */ llama_sampler_llg_name,
124124
/* .accept = */ llama_sampler_llg_accept_impl,
125125
/* .apply = */ llama_sampler_llg_apply,
@@ -135,24 +135,24 @@ static size_t llama_sampler_llg_tokenize_fn(const void *user_data,
135135
uint32_t *output_tokens,
136136
size_t output_tokens_len)
137137
{
138-
const struct llama_vocab *vocab = (const struct llama_vocab *)user_data;
138+
const llama_vocab *vocab = (const llama_vocab *)user_data;
139139
int r = llama_tokenize(vocab, (const char *) bytes, bytes_len,
140140
(int32_t*)output_tokens, output_tokens_len, false, true);
141141
if (r < 0)
142142
return -r;
143143
return r;
144144
}
145145

146-
static LlgTokenizer *llama_sampler_llg_new_tokenizer(const struct llama_model * model) {
146+
static LlgTokenizer *llama_sampler_llg_new_tokenizer(const llama_model * model) {
147147
// TODO store the tokenizer in the model somehow
148-
static const struct llama_model *model_cache;
148+
static const llama_model *model_cache;
149149
static LlgTokenizer *tokenizer_cache;
150150

151151
if (model_cache == model) {
152152
return llg_clone_tokenizer(tokenizer_cache);
153153
}
154154

155-
const struct llama_vocab *vocab = llama_model_get_vocab(model);
155+
const llama_vocab *vocab = llama_model_get_vocab(model);
156156

157157
auto tok_eos = llama_vocab_eot(vocab);
158158
if (tok_eos == LLAMA_TOKEN_NULL)
@@ -226,7 +226,7 @@ static LlgTokenizer *llama_sampler_llg_new_tokenizer(const struct llama_model *
226226
return tokenizer;
227227
}
228228

229-
struct llama_sampler * llama_sampler_init_llg(const struct llama_model * model,
229+
llama_sampler * llama_sampler_init_llg(const llama_model * model,
230230
const char * grammar_kind, const char * grammar_data) {
231231
auto * ctx = new llama_sampler_llg;
232232

@@ -263,4 +263,4 @@ struct llama_sampler * llama_sampler_init_llg(const struct llama_model * model,
263263
};
264264
}
265265

266-
#endif
266+
#endif // LLAMA_USE_LLGUIDANCE

common/sampling.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ struct common_sampler * common_sampler_init(const struct llama_model * model, co
157157
grmr = llama_sampler_init_llg(model, "lark", params.grammar.c_str());
158158
#else
159159
GGML_ABORT("llguidance (cmake -DLLAMA_LLGUIDANCE=ON) is not enabled");
160-
#endif
160+
#endif // LLAMA_USE_LLGUIDANCE
161161
} else {
162162
grmr = llama_sampler_init_grammar(vocab, params.grammar.c_str(), "root");
163163
}

common/sampling.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,6 @@ std::vector<enum common_sampler_type> common_sampler_types_from_names(const std:
104104
std::vector<enum common_sampler_type> common_sampler_types_from_chars(const std::string & chars);
105105

106106
#ifdef LLAMA_USE_LLGUIDANCE
107-
struct llama_sampler * llama_sampler_init_llg(const struct llama_model * model,
107+
struct llama_sampler * llama_sampler_init_llg(const llama_model * model,
108108
const char * grammar_kind, const char * grammar_data);
109-
#endif
109+
#endif // LLAMA_USE_LLGUIDANCE

0 commit comments

Comments
 (0)