Skip to content

Commit 5475357

Browse files
committed
fail llama_sampler_init_llg() at runtime
1 parent 437ff31 commit 5475357

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

common/llguidance.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
#ifdef LLAMA_USE_LLGUIDANCE
1+
#include "common.h"
2+
#include "sampling.h"
3+
#include "log.h"
4+
#include "llama.h"
25

3-
# include "common.h"
4-
# include "sampling.h"
5-
# include "log.h"
6-
# include "llama.h"
6+
#include <cmath>
77

8-
# include "llguidance.h"
8+
#ifdef LLAMA_USE_LLGUIDANCE
99

10-
# include <cmath>
10+
# include "llguidance.h"
1111

1212
struct llama_sampler_llg {
1313
const llama_vocab * vocab;
@@ -263,4 +263,11 @@ llama_sampler * llama_sampler_init_llg(const llama_vocab * vocab, const char * g
263263
};
264264
}
265265

266+
#else
267+
268+
llama_sampler * llama_sampler_init_llg(const llama_vocab *, const char *, const char *) {
269+
LOG_WRN("llguidance (cmake -DLLAMA_LLGUIDANCE=ON) is not enabled");
270+
return nullptr;
271+
}
272+
266273
#endif // LLAMA_USE_LLGUIDANCE

common/sampling.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,5 @@ std::string common_sampler_type_to_str(enum common_sampler_type cnstr);
103103
std::vector<enum common_sampler_type> common_sampler_types_from_names(const std::vector<std::string> & names, bool allow_alt_names);
104104
std::vector<enum common_sampler_type> common_sampler_types_from_chars(const std::string & chars);
105105

106-
#ifdef LLAMA_USE_LLGUIDANCE
107-
struct llama_sampler * llama_sampler_init_llg(const llama_vocab * vocab,
108-
const char * grammar_kind, const char * grammar_data);
109-
#endif // LLAMA_USE_LLGUIDANCE
106+
llama_sampler * llama_sampler_init_llg(const llama_vocab * vocab,
107+
const char * grammar_kind, const char * grammar_data);

0 commit comments

Comments
 (0)