MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / main

Function main

subprojects/llama.cpp/tests/test-tokenizer-0.cpp:126–312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124}
125
126int main(int argc, char **argv) {
127 if (argc < 2) {
128 fprintf(stderr, "Usage: %s vocab-file [text-file]\n", argv[0]);
129 return 1;
130 }
131
132 const std::string fname = argv[1];
133
134 const std::string fname_inp = fname + ".inp";
135 const std::string fname_out = fname + ".out";
136
137 std::string fname_text;
138 if (argc > 2) {
139 fname_text = argv[2];
140 }
141
142 fprintf(stderr, "%s : reading vocab from: '%s'\n", __func__, fname.c_str());
143
144 llama_model * model;
145 llama_context * ctx;
146
147 llama_backend_init();
148
149 // load the vocab
150 {
151 auto mparams = llama_model_default_params();
152
153 mparams.vocab_only = true;
154
155 model = llama_model_load_from_file(fname.c_str(), mparams);
156
157 if (model == NULL) {
158 fprintf(stderr, "%s: error: failed to load vocab '%s'\n", __func__, fname.c_str());
159 return 1;
160 }
161
162 auto cparams = llama_context_default_params();
163
164 ctx = llama_init_from_model(model, cparams);
165
166 if (ctx == NULL) {
167 fprintf(stderr, "%s: error: failed to load vocab '%s'\n", __func__, fname.c_str());
168 llama_model_free(model);
169 return 1;
170 }
171 }
172
173#ifdef _WIN32
174 // We need this for unicode console support
175 console::init(false, false);
176 atexit([]() { console::cleanup(); });
177#endif
178
179 bool success = true;
180
181 const auto k_tests = [&]() -> llama_tests {
182 if (!fname_text.empty()) {
183 return {};

Callers

nothing calls this directly

Calls 15

llama_backend_initFunction · 0.85
llama_init_from_modelFunction · 0.85
llama_model_freeFunction · 0.85
cleanupFunction · 0.85
read_testsFunction · 0.85
common_tokenizeFunction · 0.85
common_detokenizeFunction · 0.85
common_token_to_pieceFunction · 0.85
stringClass · 0.85

Tested by

no test coverage detected