MCPcopy Create free account
hub / github.com/PABannier/sam3.cpp / sam3_profile_print_op_summary

Function sam3_profile_print_op_summary

sam3.cpp:5003–5024  ·  view source on GitHub ↗

Print a per-op-type summary of a built graph.

Source from the content-addressed store, hash-verified

5001
5002// Print a per-op-type summary of a built graph.
5003static void sam3_profile_print_op_summary(struct ggml_cgraph* graph, const char* label) {
5004 int n = ggml_graph_n_nodes(graph);
5005
5006 // Count ops by name
5007 std::map<std::string, int> op_counts;
5008 std::map<std::string, int64_t> op_elements; // total output elements
5009 for (int i = 0; i < n; ++i) {
5010 auto* node = ggml_graph_node(graph, i);
5011 std::string name = ggml_op_name(node->op);
5012 op_counts[name]++;
5013 op_elements[name] += ggml_nelements(node);
5014 }
5015
5016 fprintf(stderr, "\n %-25s %5s %14s\n", "Op", "Count", "Out elements");
5017 fprintf(stderr, " %-25s %5s %14s\n",
5018 "-------------------------", "-----", "--------------");
5019 for (auto& kv : op_counts) {
5020 fprintf(stderr, " %-25s %5d %14lld\n",
5021 kv.first.c_str(), kv.second, (long long)op_elements[kv.first]);
5022 }
5023 fprintf(stderr, " %-25s %5d\n", "TOTAL", n);
5024}
5025
5026// Helper: capture op counts from a graph.
5027static std::map<std::string, int> sam3_profile_op_counts(struct ggml_cgraph* graph) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected