Skip to content

Commit 8203d3b

Browse files
committed
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.
1 parent cd6983d commit 8203d3b

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
@@ -1110,17 +1110,23 @@ class vk_perf_logger {
11101110
return;
11111111
}
11121112
if (node->op == GGML_OP_MUL_MAT || node->op == GGML_OP_MUL_MAT_ID) {
1113-
const uint64_t m = node->src[0]->ne[1];
1114-
const uint64_t n = node->src[1]->ne[1];
1115-
const uint64_t k = node->src[1]->ne[0];
1116-
std::string name = ggml_op_name(node->op);
1117-
if (n == 1) {
1118-
name += "_VEC m=" + std::to_string(m) + " k=" + std::to_string(k);
1119-
} else {
1120-
name += " m=" + std::to_string(m) + " n=" + std::to_string(n) + " k=" + std::to_string(k);
1113+
const uint64_t m = node->src[0]->ne[1];
1114+
const uint64_t n = node->ne[1];
1115+
const uint64_t k = node->src[1]->ne[0];
1116+
const uint64_t batch = node->src[1]->ne[2] * node->src[1]->ne[3];
1117+
std::string name = ggml_op_name(node->op);
1118+
if ((node->op == GGML_OP_MUL_MAT && n == 1) ||
1119+
(node->op == GGML_OP_MUL_MAT_ID && node->src[2]->ne[1] == 1)) {
1120+
name += "_VEC";
1121+
}
1122+
name += " ";
1123+
name += ggml_type_name(node->src[0]->type);
1124+
name += " m=" + std::to_string(m) + " n=" + std::to_string(n) + " k=" + std::to_string(k);
1125+
if (batch > 1) {
1126+
name += " batch=" + std::to_string(batch);
11211127
}
11221128
timings[name].push_back(time);
1123-
flops[name].push_back(m * n * (k + (k - 1)));
1129+
flops[name].push_back(m * n * (k + (k - 1)) * batch);
11241130
return;
11251131
}
11261132
if (node->op == GGML_OP_CONV_2D) {

0 commit comments

Comments
 (0)