Skip to content

Commit aa5a7c6

Browse files
profiler: output all tensor names
1 parent dd0b9aa commit aa5a7c6

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

ggml/src/ggml-profile.cpp

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,38 @@ static inline void ggml_profile_format_op_types(char *str, struct ggml_tensor *t
111111
p += sprintf(p, "%3s", ggml_type_name(t->type));
112112
}
113113

114+
static inline void ggml_profile_format_op_names(char *str, const struct ggml_tensor *t)
115+
{
116+
char *p = str;
117+
118+
// append src0 and src1 (if any)
119+
if (t->src[0]) {
120+
p += sprintf(p, "%s", t->src[0]->name);
121+
122+
for (int i = 1; i < GGML_MAX_SRC && t->src[i]; i++) {
123+
p += sprintf(p, " x ");
124+
p += sprintf(p, "%s", t->src[i]->name);
125+
}
126+
127+
p += sprintf(p, " -> ");
128+
}
129+
130+
p += sprintf(p, "%s", t->name);
131+
}
132+
133+
114134
extern "C" void ggml_graph_profile_finish(struct ggml_cgraph *cg, int n_threads)
115135
{
116136
if (!cg->prof) { return; }
117137

118138
ggml_profile_output *out = cg->prof->output;
119139

120-
fprintf(out->stream, "%s| node idx | op name | proc (nsec) | sync (nsec) | total (nsec) | op dims | op types | tensor name |\n", out->prefix);
121-
fprintf(out->stream, "%s| -------: | :------ | ----------: | ----------: | -----------: | ------: | -------: | ----------: |\n", out->prefix);
140+
fprintf(out->stream, "%s| node idx | op name | proc (nsec) | sync (nsec) | total (nsec) | op dims | op types | tensor names |\n", out->prefix);
141+
fprintf(out->stream, "%s| -------: | :------ | ----------: | ----------: | -----------: | ------: | -------: | -----------: |\n", out->prefix);
122142

123143
char dims[64 * GGML_MAX_SRC];
124144
char types[16 * GGML_MAX_SRC];
145+
char names[128 * GGML_MAX_SRC];
125146

126147
for (int i = 0; i < cg->n_nodes; i++) {
127148
uint64_t p_nsec = 0;
@@ -143,11 +164,12 @@ extern "C" void ggml_graph_profile_finish(struct ggml_cgraph *cg, int n_threads)
143164

144165
ggml_profile_format_op_dims(dims, cg->nodes[i]);
145166
ggml_profile_format_op_types(types, cg->nodes[i]);
167+
ggml_profile_format_op_names(names, cg->nodes[i]);
146168

147169
fprintf(out->stream, "%s| %04d | %10s | %10lu | %10lu | %10lu | %46s | %22s | %20s |\n", out->prefix,
148170
i, ggml_op_name(cg->nodes[i]->op),
149171
(unsigned long) p_nsec, (unsigned long) s_nsec, (unsigned long) t_nsec,
150-
dims, types, cg->nodes[i]->name);
172+
dims, types, names);
151173
}
152174
fprintf(out->stream, "%s \n", out->prefix); // empty line to split tables
153175
}

0 commit comments

Comments
 (0)