MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / main

Function main

examples/main/main.cpp:103–839  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101#endif
102
103int main(int argc, char ** argv) {
104 gpt_params params;
105 g_params = &params;
106
107 if (!gpt_params_parse(argc, argv, params)) {
108 return 1;
109 }
110 llama_sampling_params & sparams = params.sparams;
111
112#ifndef LOG_DISABLE_LOGS
113 log_set_target(log_filename_generator("main", "log"));
114 LOG_TEE("Log start\n");
115 log_dump_cmdline(argc, argv);
116#endif // LOG_DISABLE_LOGS
117
118 // TODO: Dump params ?
119 //LOG("Params perplexity: %s\n", LOG_TOSTR(params.perplexity));
120
121 // save choice to use color for later
122 // (note for later: this is a slightly awkward choice)
123 console::init(params.simple_io, params.use_color);
124 atexit([]() { console::cleanup(); });
125
126 if (params.logits_all) {
127 printf("\n************\n");
128 printf("%s: please use the 'perplexity' tool for perplexity calculations\n", __func__);
129 printf("************\n\n");
130
131 return 0;
132 }
133
134 if (params.embedding) {
135 printf("\n************\n");
136 printf("%s: please use the 'embedding' tool for embedding calculations\n", __func__);
137 printf("************\n\n");
138
139 return 0;
140 }
141
142 if (params.n_ctx != 0 && params.n_ctx < 8) {
143 LOG_TEE("%s: warning: minimum context size is 8, using minimum size.\n", __func__);
144 params.n_ctx = 8;
145 }
146
147 if (params.rope_freq_base != 0.0) {
148 LOG_TEE("%s: warning: changing RoPE frequency base to %g.\n", __func__, params.rope_freq_base);
149 }
150
151 if (params.rope_freq_scale != 0.0) {
152 LOG_TEE("%s: warning: scaling RoPE frequency by %g.\n", __func__, params.rope_freq_scale);
153 }
154
155 LOG_TEE("%s: build = %d (%s)\n", __func__, LLAMA_BUILD_NUMBER, LLAMA_COMMIT);
156 LOG_TEE("%s: built with %s for %s\n", __func__, LLAMA_COMPILER, LLAMA_BUILD_TARGET);
157
158 if (params.seed == LLAMA_DEFAULT_SEED) {
159 params.seed = time(NULL);
160 }

Callers

nothing calls this directly

Calls 15

gpt_params_parseFunction · 0.85
printfFunction · 0.85
gpt_random_promptFunction · 0.85
get_system_infoFunction · 0.85
llama_set_rng_seedFunction · 0.85
LOG_TOKENS_TOSTR_PRETTYFunction · 0.85
llama_kv_cache_seq_rmFunction · 0.85
llama_sampling_printFunction · 0.85
llama_sampling_initFunction · 0.85
llama_kv_cache_seq_shiftFunction · 0.85

Tested by

no test coverage detected