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

Function main

smallthinker/examples/simple/simple.cpp:13–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11}
12
13int main(int argc, char ** argv) {
14 // path to the model gguf file
15 std::string model_path;
16 // prompt to generate text from
17 std::string prompt = "Hello my name is";
18 // number of layers to offload to the GPU
19 int ngl = 99;
20 // number of tokens to predict
21 int n_predict = 32;
22
23 // parse command line arguments
24
25 {
26 int i = 1;
27 for (; i < argc; i++) {
28 if (strcmp(argv[i], "-m") == 0) {
29 if (i + 1 < argc) {
30 model_path = argv[++i];
31 } else {
32 print_usage(argc, argv);
33 return 1;
34 }
35 } else if (strcmp(argv[i], "-n") == 0) {
36 if (i + 1 < argc) {
37 try {
38 n_predict = std::stoi(argv[++i]);
39 } catch (...) {
40 print_usage(argc, argv);
41 return 1;
42 }
43 } else {
44 print_usage(argc, argv);
45 return 1;
46 }
47 } else if (strcmp(argv[i], "-ngl") == 0) {
48 if (i + 1 < argc) {
49 try {
50 ngl = std::stoi(argv[++i]);
51 } catch (...) {
52 print_usage(argc, argv);
53 return 1;
54 }
55 } else {
56 print_usage(argc, argv);
57 return 1;
58 }
59 } else {
60 // prompt starts here
61 break;
62 }
63 }
64 if (model_path.empty()) {
65 print_usage(argc, argv);
66 return 1;
67 }
68 if (i < argc) {
69 prompt = argv[i++];
70 for (; i < argc; i++) {

Callers

nothing calls this directly

Calls 15

ggml_backend_load_allFunction · 0.85
fprintfFunction · 0.85
llama_model_get_vocabFunction · 0.85
llama_init_from_modelFunction · 0.85
llama_sampler_chain_initFunction · 0.85
llama_sampler_chain_addFunction · 0.85
printfFunction · 0.85
llama_sampler_sampleFunction · 0.85
llama_vocab_is_eogFunction · 0.85

Tested by

no test coverage detected