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

Function main

examples/quantize/quantize.cpp:90–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90int main(int argc, char ** argv) {
91 if (argc < 3) {
92 usage(argv[0]);
93 }
94
95 llama_model_quantize_params params = llama_model_quantize_default_params();
96
97 int arg_idx = 1;
98
99 for (; arg_idx < argc && strncmp(argv[arg_idx], "--", 2) == 0; arg_idx++) {
100 if (strcmp(argv[arg_idx], "--leave-output-tensor") == 0) {
101 params.quantize_output_tensor = false;
102 } else if (strcmp(argv[arg_idx], "--allow-requantize") == 0) {
103 params.allow_requantize = true;
104 } else if (strcmp(argv[arg_idx], "--pure") == 0) {
105 params.pure = true;
106 } else {
107 usage(argv[0]);
108 }
109 }
110
111 if (argc - arg_idx < 2) {
112 usage(argv[0]);
113 }
114
115 llama_backend_init(false);
116
117 // parse command line arguments
118 const std::string fname_inp = argv[arg_idx];
119 arg_idx++;
120 std::string fname_out;
121
122 std::string ftype_str;
123 if (try_parse_ftype(argv[arg_idx], params.ftype, ftype_str)) {
124 std::string fpath;
125 const size_t pos = fname_inp.find_last_of("/\\");
126 if (pos != std::string::npos) {
127 fpath = fname_inp.substr(0, pos + 1);
128 }
129 // export as [inp path]/ggml-model-[ftype].gguf
130 fname_out = fpath + "ggml-model-" + ftype_str + ".gguf";
131 arg_idx++;
132 if (ftype_str == "COPY") {
133 params.only_copy = true;
134 }
135 }
136 else {
137 fname_out = argv[arg_idx];
138 arg_idx++;
139
140 if (argc <= arg_idx) {
141 fprintf(stderr, "%s: missing ftype\n", __func__);
142 return 1;
143 }
144 if (!try_parse_ftype(argv[arg_idx], params.ftype, ftype_str)) {
145 fprintf(stderr, "%s: invalid ftype '%s'\n", __func__, argv[3]);
146 return 1;
147 }

Callers

nothing calls this directly

Calls 12

fprintfFunction · 0.85
printfFunction · 0.85
substrMethod · 0.80
usageFunction · 0.70
try_parse_ftypeFunction · 0.70
llama_backend_initFunction · 0.50
llama_time_usFunction · 0.50
llama_model_quantizeFunction · 0.50
llama_backend_freeFunction · 0.50
whatMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected