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

Function main

examples/batched/batched.cpp:10–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8#include <vector>
9
10int main(int argc, char ** argv) {
11 gpt_params params;
12
13 if (argc == 1 || argv[1][0] == '-') {
14 printf("usage: %s MODEL_PATH [PROMPT] [PARALLEL] [LEN] [N_THREAD] [VRAM_BUDGET] [NGL]\n" , argv[0]);
15 return 1 ;
16 }
17
18 // number of parallel batches
19 int n_parallel = 1;
20
21 // total length of the sequences including the prompt
22 int n_len = 32;
23
24 // number of layers to offload to the GPU
25 int n_gpu_layers = 0;
26
27 // vram budget in GiB
28 double vram_budget = -1;
29
30 if (argc >= 2) {
31 params.model = argv[1];
32 }
33
34 if (argc >= 3) {
35 params.prompt = argv[2];
36 }
37
38 if (argc >= 4) {
39 n_parallel = std::atoi(argv[3]);
40 }
41
42 if (argc >= 5) {
43 n_len = std::atoi(argv[4]);
44 }
45
46 if (argc >= 6) {
47 params.n_threads = std::atoi(argv[5]);
48 }
49
50 if (argc >= 7) {
51 vram_budget = std::atof(argv[6]);
52 }
53
54 if (argc >= 8) {
55 n_gpu_layers = std::atoi(argv[7]);
56 }
57
58 printf("params: model = %s, prompt = %s, n_parallel = %d, n_len = %d, n_gpu_layers = %d, n_threads = %d, vram_budget = %.2f GiB, reset_gpu_index = true\n",
59 params.model.c_str(), params.prompt.c_str(), n_parallel, n_len, n_gpu_layers, params.n_threads, vram_budget);
60
61 if (params.prompt.empty()) {
62 params.prompt = "Hello my name is";
63 }
64
65 // init LLM
66
67 llama_backend_init(params.numa);

Callers

nothing calls this directly

Calls 15

printfFunction · 0.85
fprintfFunction · 0.85
maxFunction · 0.85
llama_batch_addFunction · 0.85
llama_kv_cache_seq_cpFunction · 0.85
llama_batch_clearFunction · 0.85
llama_sample_top_kFunction · 0.85
llama_sample_top_pFunction · 0.85
llama_sample_tempFunction · 0.85
llama_sample_tokenFunction · 0.85
llama_print_timingsFunction · 0.85
reserveMethod · 0.80

Tested by

no test coverage detected