Skip to content

Commit 863d341

Browse files
authored
vulkan: perf_logger improvements (#15246)
* vulkan: perf_logger improvements - Account for batch dimension in flops calculation. - Fix how "_VEC" is detected for mat_mul_id. - Fix "n" dimension for mat_mul_id (in case of broadcasting). - Include a->type in name. * use <=mul_mat_vec_max_cols rather than ==1
1 parent d32e03f commit 863d341

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

ggml/src/ggml-vulkan/ggml-vulkan.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,17 +1111,23 @@ class vk_perf_logger {
11111111
return;
11121112
}
11131113
if (node->op == GGML_OP_MUL_MAT || node->op == GGML_OP_MUL_MAT_ID) {
1114-
const uint64_t m = node->src[0]->ne[1];
1115-
const uint64_t n = node->src[1]->ne[1];
1116-
const uint64_t k = node->src[1]->ne[0];
1117-
std::string name = ggml_op_name(node->op);
1118-
if (n == 1) {
1119-
name += "_VEC m=" + std::to_string(m) + " k=" + std::to_string(k);
1120-
} else {
1121-
name += " m=" + std::to_string(m) + " n=" + std::to_string(n) + " k=" + std::to_string(k);
1114+
const uint64_t m = node->src[0]->ne[1];
1115+
const uint64_t n = node->ne[1];
1116+
const uint64_t k = node->src[1]->ne[0];
1117+
const uint64_t batch = node->src[1]->ne[2] * node->src[1]->ne[3];
1118+
std::string name = ggml_op_name(node->op);
1119+
if ((node->op == GGML_OP_MUL_MAT && n <= mul_mat_vec_max_cols) ||
1120+
(node->op == GGML_OP_MUL_MAT_ID && node->src[2]->ne[1] == 1)) {
1121+
name += "_VEC";
1122+
}
1123+
name += " ";
1124+
name += ggml_type_name(node->src[0]->type);
1125+
name += " m=" + std::to_string(m) + " n=" + std::to_string(n) + " k=" + std::to_string(k);
1126+
if (batch > 1) {
1127+
name += " batch=" + std::to_string(batch);
11221128
}
11231129
timings[name].push_back(time);
1124-
flops[name].push_back(m * n * (k + (k - 1)));
1130+
flops[name].push_back(m * n * (k + (k - 1)) * batch);
11251131
return;
11261132
}
11271133
if (node->op == GGML_OP_CONV_2D) {

0 commit comments

Comments
 (0)