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

Function main

subprojects/llama.cpp/tools/imatrix/imatrix.cpp:1191–1302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1189}
1190
1191int main(int argc, char ** argv) {
1192 common_params params;
1193
1194 params.out_file = "imatrix.gguf";
1195
1196 params.n_ctx = 512;
1197 params.escape = false;
1198
1199 if (!common_params_parse(argc, argv, params, LLAMA_EXAMPLE_IMATRIX, print_usage)) {
1200 return 1;
1201 }
1202
1203 if (params.show_statistics) {
1204 if (!show_statistics(params)) {
1205 return 1;
1206 }
1207 return 0;
1208 }
1209
1210 common_init();
1211
1212 const int32_t n_ctx = params.n_ctx;
1213
1214 if (n_ctx <= 0) {
1215 LOG_ERR("%s: imatrix tool requires '--ctx-size' > 0\n", __func__);
1216 return 1;
1217 }
1218
1219 {
1220 const int32_t n_seq = std::max(1, params.n_batch / n_ctx);
1221 const int32_t n_kv = n_seq * n_ctx;
1222
1223 params.n_parallel = n_seq;
1224 params.n_ctx = n_kv;
1225
1226 params.n_batch = std::min(params.n_batch, n_kv);
1227 }
1228
1229 g_collector.set_params(params);
1230
1231 for (const auto & in_file : params.in_files) {
1232 LOG_INF("%s : loading imatrix from '%s'\n", __func__, in_file.c_str());
1233 if (!g_collector.load_imatrix(in_file.c_str())) {
1234 LOG_ERR("%s : failed to load %s\n", __func__, in_file.c_str());
1235 return 1;
1236 }
1237 }
1238
1239 if (params.prompt.empty()) {
1240 LOG_INF("No prompt provided; combining precomputed matrices only.\n");
1241
1242 if (params.in_files.empty()) {
1243 LOG_ERR("Error: No prompt provided and no precomputed matrices (--in-file) to combine.\n");
1244 return 1;
1245 }
1246
1247 if (params.in_files.size() == 1) {
1248 LOG_INF("%s : saving imatrix to '%s'\n", __func__, params.out_file.c_str());

Callers

nothing calls this directly

Calls 15

common_params_parseFunction · 0.85
show_statisticsFunction · 0.85
common_initFunction · 0.85
maxFunction · 0.85
minFunction · 0.85
llama_backend_initFunction · 0.85
llama_numa_initFunction · 0.85
common_init_from_paramsFunction · 0.85
llama_model_n_ctx_trainFunction · 0.85
compute_imatrixFunction · 0.85
llama_perf_context_printFunction · 0.85

Tested by

no test coverage detected