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

Function main

smallthinker/tools/quantize/quantize.cpp:289–519  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

287}
288
289int main(int argc, char ** argv) {
290 if (argc < 3) {
291 usage(argv[0]);
292 }
293
294 llama_model_quantize_params params = llama_model_quantize_default_params();
295
296 int arg_idx = 1;
297 std::string imatrix_file;
298 std::vector<std::string> included_weights, excluded_weights;
299 std::vector<llama_model_kv_override> kv_overrides;
300 std::vector<tensor_quantization> tensor_types;
301
302 for (; arg_idx < argc && strncmp(argv[arg_idx], "--", 2) == 0; arg_idx++) {
303 if (strcmp(argv[arg_idx], "--leave-output-tensor") == 0) {
304 params.quantize_output_tensor = false;
305 } else if (strcmp(argv[arg_idx], "--output-tensor-type") == 0) {
306 if (arg_idx < argc-1) {
307 params.output_tensor_type = parse_ggml_type(argv[++arg_idx]);
308 if (params.output_tensor_type == GGML_TYPE_COUNT) {
309 usage(argv[0]);
310 }
311 } else {
312 usage(argv[0]);
313 }
314 } else if (strcmp(argv[arg_idx], "--token-embedding-type") == 0) {
315 if (arg_idx < argc-1) {
316 params.token_embedding_type = parse_ggml_type(argv[++arg_idx]);
317 if (params.token_embedding_type == GGML_TYPE_COUNT) {
318 usage(argv[0]);
319 }
320 } else {
321 usage(argv[0]);
322 }
323 } else if (strcmp(argv[arg_idx], "--tensor-type") == 0) {
324 if (arg_idx == argc-1 || !parse_tensor_type(argv[++arg_idx], tensor_types)) {
325 usage(argv[0]);
326 }
327 } else if (strcmp(argv[arg_idx], "--override-kv") == 0) {
328 if (arg_idx == argc-1 || !string_parse_kv_override(argv[++arg_idx], kv_overrides)) {
329 usage(argv[0]);
330 }
331 } else if (strcmp(argv[arg_idx], "--allow-requantize") == 0) {
332 params.allow_requantize = true;
333 } else if (strcmp(argv[arg_idx], "--pure") == 0) {
334 params.pure = true;
335 } else if (strcmp(argv[arg_idx], "--imatrix") == 0) {
336 if (arg_idx < argc-1) {
337 imatrix_file = argv[++arg_idx];
338 } else {
339 usage(argv[0]);
340 }
341 } else if (strcmp(argv[arg_idx], "--include-weights") == 0) {
342 if (arg_idx < argc-1) {
343 included_weights.emplace_back(argv[++arg_idx]);
344 } else {
345 usage(argv[0]);
346 }

Callers

nothing calls this directly

Calls 15

parse_ggml_typeFunction · 0.85
parse_tensor_typeFunction · 0.85
string_parse_kv_overrideFunction · 0.85
printfFunction · 0.85
prepare_imatrixFunction · 0.85
fprintfFunction · 0.85
substrMethod · 0.80
findMethod · 0.80
lengthMethod · 0.80
usageFunction · 0.70
try_parse_ftypeFunction · 0.70

Tested by

no test coverage detected