Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aobolensk committed Jan 17, 2025
1 parent c983eb9 commit c0bfa84
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 43 deletions.
15 changes: 4 additions & 11 deletions src/common/snippets/docs/debug_capabilities/parameters_dump.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,7 @@ Examples:
```

Output example:
```csv
name,subgraph_name,in_type,out_type,in_shapes,out_shapes,M,N,K,m_block,n_block,k_block,acc_max_time,avg_max_time
MatMul_437,FakeQuantize_456,i8;i8;f32,i32,1 16 128 64;1 16 64 128;1 16 64 128,1 16 128 128,128,128,64,32,-2,-2,37786,4723
MatMul_451,FakeQuantize_456,u8;i8,i32,1 16 128 128;1 16 128 64,1 16 128 64,128,64,128,32,-2,-2,18186,2273
MatMul_6069,FakeQuantize_6088,i8;i8;f32,i32,2 6 68 92;2 6 92 68;2 6 92 68,2 6 68 68,68,68,92,32,-2,-2,4433,2355
MatMul_6083,FakeQuantize_6088,u8;i8,i32,2 6 68 68;2 6 68 92,2 6 68 92,68,92,68,32,-2,-2,1549,1549
MatMul_12488,FakeQuantize_12507,i8;i8;f32,i32,? ? ? 100;? ? 100 128;? ? 100 128,? ? ? 128,-1,128,100,32,-2,-2,5823,5823
MatMul_12502,FakeQuantize_12507,u8;i8,i32,? ? ? 128;? ? 128 100,? ? ? 100,-1,100,128,32,-2,-2,4170,1107
MatMul_18789,FakeQuantize_18808,i8;i8;f32,i32,? ? ? ?;? ? ? ?;? ? ? ?,? ? ? ?,-1,-1,-1,32,-2,-2,4773,2757
MatMul_18803,FakeQuantize_18808,u8;i8,i32,? ? ? ?;? ? ? ?,? ? ? ?,-1,-1,-1,32,-2,-2,3901,1300
```
| subgraph_name | name | in_type | out_type | in_shapes | out_shapes | M | N | K | m_block | n_block | k_block | acc_max_time | avg_max_time |
|-------------------|------------|-------------|----------|--------------------------|--------------------------|-----|-----|-----|---------|---------|---------|--------------|--------------|
| FakeQuantize_456 | MatMul_437 | i8;i8;f32 | i32 | 1 16 128 64;1 16 64 128 | 1 16 64 128;1 16 128 128 | 128 | 128 | 64 | 32 | -2 | -2 | 37786 | 4723 |
| FakeQuantize_456 | MatMul_451 | u8;i8 | i32 | 1 16 128 128;1 16 128 64 | 1 16 128 64 | 128 | 64 | 128 | 32 | -2 | -2 | 18186 | 2273 |
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class BrgemmDebugParams : public snippets::lowered::pass::RangedPass {
snippets::lowered::LinearIR::constExprIt begin,
snippets::lowered::LinearIR::constExprIt end) override final { // NOLINT
OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::BrgemmDebugParams")
if (linear_ir.get_config().debug_config.dumpParams.csv_path.empty()) {
return false;
}
static size_t seq_number = 0;
bool modified = false;
for (auto expr_it = begin; expr_it != end; expr_it++) {
Expand Down Expand Up @@ -70,8 +73,8 @@ class BrgemmDebugParams : public snippets::lowered::pass::RangedPass {
const auto brgemm = ov::as_type_ptr<BRGEMM_TYPE>(brgemm_expr->get_node());
OPENVINO_ASSERT(brgemm, "Brgemm is nullptr!");
std::stringstream ss;
ss << brgemm_expr->get_node()->get_friendly_name() << ',';
ss << m_subgraph_name << ',';
ss << brgemm_expr->get_node()->get_friendly_name() << ',';
for (size_t i = 0; i < brgemm->get_input_size(); ++i) {
ss << brgemm->get_input_element_type(i);
if (i != brgemm->get_input_size() - 1) {
Expand All @@ -87,23 +90,11 @@ class BrgemmDebugParams : public snippets::lowered::pass::RangedPass {
}
ss << ',';
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);
for (size_t i = 0; i < ports.size(); ++i) {
const auto& shape = ov::snippets::utils::get_planar_vdims(get_port_descriptor(i)->get_shape(),
get_port_descriptor(i)->get_layout());
ss << utils::tensor2str(shape, " ");
ss << ';';
++i;
}
ss.seekp(-1, ss.cur);
ss << ',';
Expand Down
9 changes: 9 additions & 0 deletions src/common/snippets/include/snippets/utils/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,15 @@ void visit_path(const lowered::ExpressionPtr& expr,
std::function<void(lowered::ExpressionPtr)> func,
bool visit_parent_path);

/**
* @brief Converts a tensor to a string representation.
* Each value in the tensor is converted to a string. If the value is a full dimension, it is represented as
* "FULL_DIM". If the value is dynamic, it is represented as "?".
* @param tensor The tensor to be converted to a string.
* @return A string representation of the tensor.
*/
std::string tensor2str(const VectorDims& tensor, const std::string& delimiter = ", ");

} // namespace utils
} // namespace snippets
} // namespace ov
18 changes: 3 additions & 15 deletions src/common/snippets/src/lowered/expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,7 @@ ExpressionPtr Expression::clone() const {
}

bool Expression::visit_attributes(AttributeVisitor &visitor) {
auto subtensor2str = [](const VectorDims& subtensor) {
std::stringstream ss;
for (size_t i = 0; i < subtensor.size(); ++i) {
const auto& v = subtensor[i];
const auto v_str = utils::is_full_dim_value(v) ? "FULL_DIM" :
utils::is_dynamic_value(v) ? "?" : std::to_string(v);
const auto del = i < subtensor.size() - 1 ? ", " : "";
ss << v_str << del;
}
return ss.str();
};

std::ostringstream in_regs, out_regs;
std::vector<size_t> in_regs, out_regs;
std::vector<std::pair<std::string, ov::PartialShape>> shapes;
std::vector<std::pair<std::string, std::string>> subtensors;
std::vector<std::pair<std::string, std::vector<size_t>>> layouts;
Expand All @@ -194,7 +182,7 @@ bool Expression::visit_attributes(AttributeVisitor &visitor) {

const auto& subtensor = desc->get_subtensor();
if (!subtensor.empty())
subtensors.emplace_back("in_subtensor_" + std::to_string(i), subtensor2str(subtensor));
subtensors.emplace_back("in_subtensor_" + std::to_string(i), utils::tensor2str(subtensor));

const auto& layout = desc->get_layout();
if (!layout.empty() && !utils::is_planar_layout(layout))
Expand All @@ -210,7 +198,7 @@ bool Expression::visit_attributes(AttributeVisitor &visitor) {

const auto& subtensor = desc->get_subtensor();
if (!subtensor.empty())
subtensors.emplace_back("out_subtensor_" + std::to_string(i), subtensor2str(subtensor));
subtensors.emplace_back("out_subtensor_" + std::to_string(i), utils::tensor2str(subtensor));

const auto& layout = desc->get_layout();
if (!layout.empty() && !utils::is_planar_layout(layout))
Expand Down
12 changes: 12 additions & 0 deletions src/common/snippets/src/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,18 @@ void visit_path(const lowered::ExpressionPtr& expr,
}
}

std::string tensor2str(const VectorDims& tensor, const std::string& delimiter) {
std::stringstream ss;
for (size_t i = 0; i < tensor.size(); ++i) {
const auto& v = tensor[i];
const auto v_str =
utils::is_full_dim_value(v) ? "FULL_DIM" : utils::is_dynamic_value(v) ? "?" : std::to_string(v);
const auto del = i < tensor.size() - 1 ? delimiter : "";
ss << v_str << del;
}
return ss.str();
}

} // namespace utils
} // namespace snippets
} // namespace ov

0 comments on commit c0bfa84

Please sign in to comment.