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

Function gguf_split

smallthinker/tools/gguf-split/gguf-split.cpp:360–396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

358};
359
360static void gguf_split(const split_params & split_params) {
361 struct ggml_context * ctx_meta = NULL;
362
363 struct gguf_init_params params = {
364 /*.no_alloc = */ true,
365 /*.ctx = */ &ctx_meta,
366 };
367
368 std::ifstream f_input(split_params.input.c_str(), std::ios::binary);
369 if (!f_input.is_open()) {
370 fprintf(stderr, "%s: failed to open input GGUF from %s\n", __func__, split_params.input.c_str());
371 exit(EXIT_FAILURE);
372 }
373
374 auto * ctx_gguf = gguf_init_from_file(split_params.input.c_str(), params);
375 if (!ctx_gguf) {
376 fprintf(stderr, "%s: failed to load input GGUF from %s\n", __func__, split_params.input.c_str());
377 exit(EXIT_FAILURE);
378 }
379
380 // prepare the strategy
381 split_strategy strategy(split_params, f_input, ctx_gguf, ctx_meta);
382 int n_split = strategy.ctx_outs.size();
383 strategy.print_info();
384
385 if (!split_params.dry_run) {
386 // write all output splits
387 strategy.write();
388 }
389
390 // done, clean up
391 gguf_free(ctx_gguf);
392 f_input.close();
393
394 fprintf(stderr, "%s: %d gguf split written with a total of %d tensors.\n",
395 __func__, n_split, strategy.n_tensors);
396}
397
398static void gguf_merge(const split_params & split_params) {
399 fprintf(stderr, "%s: %s -> %s\n",

Callers 1

mainFunction · 0.85

Calls 9

fprintfFunction · 0.85
is_openMethod · 0.80
gguf_init_from_fileFunction · 0.50
gguf_freeFunction · 0.50
c_strMethod · 0.45
sizeMethod · 0.45
print_infoMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected