| 1 | #include "llama.h" |
|---|---|
| 2 | #include "get-model.h" |
| 3 | |
| 4 | #include <cstdlib> |
| 5 | |
| 6 | int main(int argc, char *argv[] ) { |
| 7 | auto * model_path = get_model_or_exit(argc, argv); |
| 8 | auto * file = fopen(filename: model_path, modes: "r"); |
| 9 | if (file == nullptr) { |
| 10 | fprintf(stderr, format: "no model at '%s' found\n", model_path); |
| 11 | return EXIT_FAILURE; |
| 12 | } |
| 13 | |
| 14 | fprintf(stderr, format: "using '%s'\n", model_path); |
| 15 | fclose(stream: file); |
| 16 | |
| 17 | llama_backend_init(); |
| 18 | auto params = llama_model_params{}; |
| 19 | params.use_mmap = false; |
| 20 | params.progress_callback = [](float progress, void * ctx){ |
| 21 | (void) ctx; |
| 22 | return progress > 0.50; |
| 23 | }; |
| 24 | auto * model = llama_model_load_from_file(path_model: model_path, params); |
| 25 | llama_backend_free(); |
| 26 | return model == nullptr ? EXIT_SUCCESS : EXIT_FAILURE; |
| 27 | } |
| 28 |