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

Function common_params_parser_init

smallthinker/common/arg.cpp:1227–3380  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1225}
1226
1227common_params_context common_params_parser_init(common_params & params, llama_example ex, void(*print_usage)(int, char **)) {
1228 // load dynamic backends
1229 ggml_backend_load_all();
1230
1231 common_params_context ctx_arg(params);
1232 ctx_arg.print_usage = print_usage;
1233 ctx_arg.ex = ex;
1234
1235 std::string sampler_type_chars;
1236 std::string sampler_type_names;
1237 for (const auto & sampler : params.sampling.samplers) {
1238 sampler_type_chars += common_sampler_type_to_chr(sampler);
1239 sampler_type_names += common_sampler_type_to_str(sampler) + ";";
1240 }
1241 sampler_type_names.pop_back();
1242
1243
1244 /**
1245 * filter options by example
1246 * rules:
1247 * - all examples inherit options from LLAMA_EXAMPLE_COMMON
1248 * - if LLAMA_EXAMPLE_* is set (other than COMMON), we only show the option in the corresponding example
1249 * - if both {LLAMA_EXAMPLE_COMMON, LLAMA_EXAMPLE_*,} are set, we will prioritize the LLAMA_EXAMPLE_* matching current example
1250 */
1251 auto add_opt = [&](common_arg arg) {
1252 if ((arg.in_example(ex) || arg.in_example(LLAMA_EXAMPLE_COMMON)) && !arg.is_exclude(ex)) {
1253 ctx_arg.options.push_back(std::move(arg));
1254 }
1255 };
1256
1257
1258 add_opt(common_arg(
1259 {"-h", "--help", "--usage"},
1260 "print usage and exit",
1261 [](common_params & params) {
1262 params.usage = true;
1263 }
1264 ));
1265 add_opt(common_arg(
1266 {"--version"},
1267 "show version and build info",
1268 [](common_params &) {
1269 fprintf(stderr, "version: %d (%s)\n", LLAMA_BUILD_NUMBER, LLAMA_COMMIT);
1270 fprintf(stderr, "built with %s for %s\n", LLAMA_COMPILER, LLAMA_BUILD_TARGET);
1271 exit(0);
1272 }
1273 ));
1274 add_opt(common_arg(
1275 {"--completion-bash"},
1276 "print source-able bash completion script for llama.cpp",
1277 [](common_params & params) {
1278 params.completion = true;
1279 }
1280 ));
1281 add_opt(common_arg(
1282 {"--verbose-prompt"},
1283 string_format("print a verbose prompt before generation (default: %s)", params.verbose_prompt ? "true" : "false"),
1284 [](common_params & params) {

Callers 3

mainFunction · 0.85
common_params_parseFunction · 0.85
export_mdFunction · 0.85

Calls 15

ggml_backend_load_allFunction · 0.85
common_argClass · 0.85
fprintfFunction · 0.85
parse_cpu_maskFunction · 0.85
parse_cpu_rangeFunction · 0.85
maxFunction · 0.85
json_schema_to_grammarFunction · 0.85
get_all_kv_cache_typesFunction · 0.85

Tested by 1

mainFunction · 0.68