Skip to content

Commit

Permalink
Check for 'dot' tool presence in PATH before calling in VisualizeTree…
Browse files Browse the repository at this point in the history
… pass and make it debug only (#28432)

### Details:
Check for dot tool availability in PATH before execution:
- Ensure the Graphviz `dot` tool is installed and accessible in the
system PATH before attempting to execute it
- If the dot tool is not found, fail gracefully with a clear error
message instead of producing the uninformative output: `sh: 1: dot: not
found`
- Make external 'dot' process call only when `ENABLE_OPENVINO_DEBUG`
define is on
- Add missing `if (VISUALIZE_TESTS_TREE)` in tests where `VisualizeTree`
pass is invoked

### Tickets:
 - N/A
  • Loading branch information
aobolensk authored Jan 16, 2025
1 parent 518b23f commit 4e3c457
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4738,9 +4738,11 @@ TEST_F(TransformationTestsF, MaskPropagationComplexReshape) {
};

manager.register_pass<ov::pass::ShrinkWeights>();
manager.register_pass<pass::VisualizeTree>(
std::string(VISUALIZE_TREE_ROOT) + "MaskPropagationComplexReshapeWithMasks.svg",
modifier);
if (VISUALIZE_TESTS_TREE) {
manager.register_pass<pass::VisualizeTree>(
std::string(VISUALIZE_TREE_ROOT) + "MaskPropagationComplexReshapeWithMasks.svg",
modifier);
}
}
comparator.enable(FunctionsComparator::CmpValues::ACCURACY);
}
Expand Down Expand Up @@ -4929,10 +4931,12 @@ TEST_P(TransformationTestsBoolParamF, MaskPropagationReshapedPassThroughP) {
};

manager.register_pass<ov::pass::ShrinkWeights>();
auto postfix = (add_shape_of) ? "True" : "False";
manager.register_pass<pass::VisualizeTree>(
std::string(VISUALIZE_TREE_ROOT) + "MaskPropagationReverseFlattenWithMasks" + postfix + ".svg",
modifier);
if (VISUALIZE_TESTS_TREE) {
auto postfix = (add_shape_of) ? "True" : "False";
manager.register_pass<pass::VisualizeTree>(
std::string(VISUALIZE_TREE_ROOT) + "MaskPropagationReverseFlattenWithMasks" + postfix + ".svg",
modifier);
}
comparator.enable(FunctionsComparator::CmpValues::ACCURACY);
}

Expand Down
5 changes: 4 additions & 1 deletion src/core/src/pass/visualize_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,8 +690,11 @@ void ov::pass::VisualizeTree::render() const {
out.close();

if (!m_dot_only && ov::util::to_lower(ext) != ".dot") {
#ifndef _WIN32
#if defined(ENABLE_OPENVINO_DEBUG) && !defined(_WIN32)
std::stringstream ss;
if (system("command -v dot > /dev/null 2>&1") != 0) {
OPENVINO_THROW("Graphviz 'dot' command not found in PATH");
}
ss << "dot -T" << output_format << " " << dot_file << " -o" << m_name;
auto cmd = ss.str();
auto stream = popen(cmd.c_str(), "r");
Expand Down

0 comments on commit 4e3c457

Please sign in to comment.