Skip to content

Commit

Permalink
Extrct common logic
Browse files Browse the repository at this point in the history
  • Loading branch information
aobolensk committed Jan 15, 2025
1 parent 6ac651e commit b302bab
Showing 1 changed file with 26 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,51 +86,35 @@ class BrgemmDebugParams : public snippets::lowered::pass::RangedPass {
}
}
ss << ',';
fprintf(stderr, "Before input\n");
size_t i = 0;
for (const auto& input : brgemm->inputs()) {
if (input.get_partial_shape().is_dynamic()) {
const auto& partial_shape = input.get_partial_shape();
for (const auto& dim : partial_shape) {
ss << dim << ' ';
}
} else {
const auto& shape =
ov::snippets::utils::get_planar_vdims(input.get_shape(),
brgemm_expr->get_input_port_descriptor(i)->get_layout());
for (const auto& dim : shape) {
ss << dim << ' ';
}
}
ss.seekp(-1, ss.cur);
ss << ';';
++i;
}
fprintf(stderr, "Before output\n");
ss.seekp(-1, ss.cur);
ss << ',';
i = 0;
for (const auto& output : brgemm->outputs()) {
if (output.get_partial_shape().is_dynamic()) {
const auto& partial_shape = output.get_partial_shape();
for (const auto& dim : partial_shape) {
ss << dim << ' ';
}
} else {
const auto& shape =
ov::snippets::utils::get_planar_vdims(output.get_shape(),
brgemm_expr->get_output_port_descriptor(i)->get_layout());
for (const auto& dim : shape) {
ss << dim << ' ';
auto append_shape_info = [&](const auto& ports, auto get_port_descriptor) {
size_t i = 0;
for (const auto& port : ports) {
if (port.get_partial_shape().is_dynamic()) {
const auto& partial_shape = port.get_partial_shape();
for (const auto& dim : partial_shape) {
ss << dim << ' ';
}
} else {
const auto& shape =
ov::snippets::utils::get_planar_vdims(port.get_shape(), get_port_descriptor(i)->get_layout());
for (const auto& dim : shape) {
ss << dim << ' ';
}
}
ss.seekp(-1, ss.cur);
ss << ';';
++i;
}
ss.seekp(-1, ss.cur);
ss << ';';
++i;
}
ss.seekp(-1, ss.cur);
ss << ',';
fprintf(stderr, "BrgemmDebugParams: %s\n", ss.str().c_str());
ss << ',';
};

append_shape_info(brgemm->inputs(), [&](size_t i) {
return brgemm_expr->get_input_port_descriptor(i);
});
append_shape_info(brgemm->outputs(), [&](size_t i) {
return brgemm_expr->get_output_port_descriptor(i);
});

const auto& in_0_desc = brgemm_expr->get_input_port_descriptor(0);
const auto& in_1_desc = brgemm_expr->get_input_port_descriptor(1);
Expand Down

0 comments on commit b302bab

Please sign in to comment.