| 85 | #endif |
| 86 | |
| 87 | int main(int argc, char ** argv) { |
| 88 | std::setlocale(LC_NUMERIC, "C"); |
| 89 | |
| 90 | common_params params; |
| 91 | g_params = ¶ms; |
| 92 | |
| 93 | common_init(); |
| 94 | |
| 95 | if (!common_params_parse(argc, argv, params, LLAMA_EXAMPLE_COMPLETION, print_usage)) { |
| 96 | return 1; |
| 97 | } |
| 98 | |
| 99 | auto & sparams = params.sampling; |
| 100 | |
| 101 | // save choice to use color for later |
| 102 | // (note for later: this is a slightly awkward choice) |
| 103 | console::init(params.simple_io, params.use_color); |
| 104 | atexit([]() { console::cleanup(); }); |
| 105 | |
| 106 | if (params.embedding) { |
| 107 | LOG_ERR("************\n"); |
| 108 | LOG_ERR("%s: please use the 'embedding' tool for embedding calculations\n", __func__); |
| 109 | LOG_ERR("************\n\n"); |
| 110 | |
| 111 | return 0; |
| 112 | } |
| 113 | |
| 114 | if (params.n_ctx != 0 && params.n_ctx < 8) { |
| 115 | LOG_WRN("%s: warning: minimum context size is 8, using minimum size.\n", __func__); |
| 116 | params.n_ctx = 8; |
| 117 | } |
| 118 | |
| 119 | if (params.rope_freq_base != 0.0) { |
| 120 | LOG_WRN("%s: warning: changing RoPE frequency base to %g.\n", __func__, params.rope_freq_base); |
| 121 | } |
| 122 | |
| 123 | if (params.rope_freq_scale != 0.0) { |
| 124 | LOG_WRN("%s: warning: scaling RoPE frequency by %g.\n", __func__, params.rope_freq_scale); |
| 125 | } |
| 126 | |
| 127 | LOG_INF("%s: llama backend init\n", __func__); |
| 128 | |
| 129 | llama_backend_init(); |
| 130 | llama_numa_init(params.numa); |
| 131 | |
| 132 | llama_model * model = nullptr; |
| 133 | llama_context * ctx = nullptr; |
| 134 | common_sampler * smpl = nullptr; |
| 135 | |
| 136 | g_model = &model; |
| 137 | g_ctx = &ctx; |
| 138 | g_smpl = &smpl; |
| 139 | |
| 140 | std::vector<common_chat_msg> chat_msgs; |
| 141 | |
| 142 | // load the model and apply lora adapter, if any |
| 143 | LOG_INF("%s: load the model and apply lora adapter, if any\n", __func__); |
| 144 |
nothing calls this directly
no test coverage detected