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

Method init

smallthinker/tools/run/run.cpp:63–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61class Opt {
62 public:
63 int init(int argc, const char ** argv) {
64 ctx_params = llama_context_default_params();
65 model_params = llama_model_default_params();
66 context_size_default = ctx_params.n_batch;
67 n_threads_default = ctx_params.n_threads;
68 ngl_default = model_params.n_gpu_layers;
69 common_params_sampling sampling;
70 temperature_default = sampling.temp;
71
72 if (argc < 2) {
73 printe("Error: No arguments provided.\n");
74 print_help();
75 return 1;
76 }
77
78 // Parse arguments
79 if (parse(argc, argv)) {
80 printe("Error: Failed to parse arguments.\n");
81 print_help();
82 return 1;
83 }
84
85 // If help is requested, show help and exit
86 if (help) {
87 print_help();
88 return 2;
89 }
90
91 ctx_params.n_batch = context_size >= 0 ? context_size : context_size_default;
92 ctx_params.n_ctx = ctx_params.n_batch;
93 ctx_params.n_threads = ctx_params.n_threads_batch = n_threads >= 0 ? n_threads : n_threads_default;
94 model_params.n_gpu_layers = ngl >= 0 ? ngl : ngl_default;
95 temperature = temperature >= 0 ? temperature : temperature_default;
96
97 return 0; // Success
98 }
99
100 llama_context_params ctx_params;
101 llama_model_params model_params;

Callers 2

downloadMethod · 0.45
mainFunction · 0.45

Calls 4

printeFunction · 0.85
parseFunction · 0.50

Tested by

no test coverage detected