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

Function write_logfile

examples/infill/infill.cpp:44–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42static bool is_interacting = false;
43
44static void write_logfile(
45 const llama_context * ctx, const gpt_params & params, const llama_model * model,
46 const std::vector<llama_token> & input_tokens, const std::string & output,
47 const std::vector<llama_token> & output_tokens
48) {
49 if (params.logdir.empty()) {
50 return;
51 }
52
53 const std::string timestamp = get_sortable_timestamp();
54
55 const bool success = create_directory_with_parents(params.logdir);
56 if (!success) {
57 fprintf(stderr, "%s: warning: failed to create logdir %s, cannot write logfile\n",
58 __func__, params.logdir.c_str());
59 return;
60 }
61
62 const std::string logfile_path = params.logdir + timestamp + ".yml";
63 FILE * logfile = fopen(logfile_path.c_str(), "w");
64
65 if (logfile == NULL) {
66 fprintf(stderr, "%s: failed to open logfile %s\n", __func__, logfile_path.c_str());
67 return;
68 }
69
70 fprintf(logfile, "binary: infill\n");
71 char model_desc[128];
72 llama_model_desc(model, model_desc, sizeof(model_desc));
73 dump_non_result_info_yaml(logfile, params, ctx, timestamp, input_tokens, model_desc);
74
75 fprintf(logfile, "\n");
76 fprintf(logfile, "######################\n");
77 fprintf(logfile, "# Generation Results #\n");
78 fprintf(logfile, "######################\n");
79 fprintf(logfile, "\n");
80
81 dump_string_yaml_multiline(logfile, "output", output.c_str());
82 dump_vector_int_yaml(logfile, "output_tokens", output_tokens);
83
84 llama_dump_timing_info_yaml(logfile, ctx);
85 fclose(logfile);
86}
87
88#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__)) || defined (_WIN32)
89static void sigint_handler(int signo) {

Callers 2

sigint_handlerFunction · 0.70
mainFunction · 0.70

Calls 10

get_sortable_timestampFunction · 0.85
fprintfFunction · 0.85
dump_vector_int_yamlFunction · 0.85
llama_model_descFunction · 0.50
emptyMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected