Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions ggml/src/ggml.c
Original file line number Diff line number Diff line change
Expand Up @@ -7400,25 +7400,36 @@ void ggml_perf_accumulate(struct ggml_perf_totals totals[GGML_OP_COUNT], struct

if (op >= GGML_OP_COUNT) continue;

const int64_t node_perf_time_us = node->perf_time_us;
const int64_t node_perf_runs = node->perf_runs;
const int64_t node_tsi_kernel_runs = node->tsi_kernel_runs;

if (node_perf_runs == 0 && node_perf_time_us == 0 && node_tsi_kernel_runs == 0) {
continue;
}

totals[op].op_name = ggml_op_name(op);
totals[op].total_us += node->perf_time_us;
totals[op].runs += node->perf_runs;
totals[op].total_us += node_perf_time_us;
totals[op].runs += node_perf_runs;
totals[op].op_count++;

// Count backend runs
enum ggml_compute_backend_type be = node->ggml_compute_backend;
if (be >= GGML_COMPUTE_BACKEND_CPU && be < GGML_COMPUTE_BACKEND_COUNT) {
totals[op].backend_subtotals[be].total_us += node->perf_time_us;
totals[op].backend_subtotals[be].runs += node->perf_runs;
totals[op].backend_subtotals[be].tsi_kernel_count += node->tsi_kernel_runs;
totals[op].backend_subtotals[be].total_us += node_perf_time_us;
totals[op].backend_subtotals[be].runs += node_perf_runs;
totals[op].backend_subtotals[be].tsi_kernel_count += node_tsi_kernel_runs;
}

if (op == GGML_OP_UNARY) {
enum ggml_unary_op subop = ggml_get_unary_op(node);
totals[op].unary_subtotals[subop].total_us += node->perf_time_us;
totals[op].unary_subtotals[subop].runs += node->perf_runs;
totals[op].unary_subtotals[subop].tsi_kernel_count += node->tsi_kernel_runs;
totals[op].unary_subtotals[subop].total_us += node_perf_time_us;
totals[op].unary_subtotals[subop].runs += node_perf_runs;
totals[op].unary_subtotals[subop].tsi_kernel_count += node_tsi_kernel_runs;
}
node->perf_time_us = 0;
Comment thread
akapoor3518 marked this conversation as resolved.
Resolved
node->perf_runs = 0;
node->tsi_kernel_runs = 0;
}
}
#endif /* GML_PERF-related flags */
Expand All @@ -7438,7 +7449,6 @@ FILE * ggml_perf_log_open(const char *filename) {
return fp;
}


void ggml_perf_write_detailed_csv(struct ggml_cgraph * cgraph, FILE *fp) {
if (!fp || !cgraph) return;

Expand Down Expand Up @@ -7739,7 +7749,4 @@ void ggml_perf_write_detailed_csv(struct ggml_cgraph * cgraph, FILE *fp) {
free(aggs);
}




#endif /* GGML_PERF_DETAIL */
2 changes: 1 addition & 1 deletion src/llama-context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1102,12 +1102,12 @@ int llama_context::decode(const llama_batch & batch_inp) {
}
#elif defined(GGML_PERF_DETAIL)
if (res) {
ggml_perf_accumulate(perf_totals, res->get_gf());
if (!perf_all_shape_written_once && perf_all_shape_fp) {
ggml_perf_write_detailed_csv(res->get_gf(), perf_all_shape_fp);
fflush(perf_all_shape_fp);
perf_all_shape_written_once = true;
}
ggml_perf_accumulate(perf_totals, res->get_gf());
}
#endif /* GML_PERF-related flags */

Expand Down