|
34 | 34 | #include "openvino/op/result.hpp" |
35 | 35 | #include "openvino/pass/manager.hpp" |
36 | 36 | #include "openvino/pass/serialize.hpp" |
| 37 | +#include "openvino/pass/visualize_tree.hpp" |
37 | 38 | #include "openvino/runtime/exec_model_info.hpp" |
38 | 39 | #include "openvino/util/common_util.hpp" |
39 | 40 | #include "utils/debug_capabilities.h" |
| 41 | +#include "utils/general_utils.h" |
40 | 42 | #include "utils/platform.h" |
41 | 43 |
|
42 | 44 | namespace ov::intel_cpu { |
43 | 45 |
|
44 | 46 | void serializeToCout(const Graph& graph); |
45 | 47 | void serializeToXML(const Graph& graph, const std::filesystem::path& path); |
| 48 | +void serializeToDot(const Graph& graph, const std::filesystem::path& path); |
46 | 49 |
|
47 | 50 | namespace { |
48 | 51 |
|
@@ -236,16 +239,37 @@ void serialize(const Graph& graph) { |
236 | 239 |
|
237 | 240 | if (pathStr == "cout") { |
238 | 241 | serializeToCout(graph); |
239 | | - } else if (std::filesystem::path p{pathStr}; p.extension() == ".xml") { |
240 | | - static int g_idx = 0; |
241 | | - const auto xmlPath = |
242 | | - p.parent_path() / (p.stem().string() + "_" + std::to_string(g_idx++) + p.extension().string()); |
243 | | - serializeToXML(graph, xmlPath); |
| 242 | + return; |
| 243 | + } |
| 244 | + |
| 245 | + std::filesystem::path p{pathStr}; |
| 246 | + const auto ext = p.extension(); |
| 247 | + |
| 248 | + if (none_of(ext, ".xml", ".dot")) { |
| 249 | + OPENVINO_THROW("Unknown serialize format. Should be either 'cout', '*.xml' or '*.dot'. Got ", pathStr); |
| 250 | + } |
| 251 | + |
| 252 | + static int g_idx = 0; |
| 253 | + const auto indexedFileName = p.stem().string() + "_" + std::to_string(g_idx++) + ext.string(); |
| 254 | + const auto indexedPath = p.parent_path() / indexedFileName; |
| 255 | + |
| 256 | + if (ext == ".xml") { |
| 257 | + serializeToXML(graph, indexedPath); |
244 | 258 | } else { |
245 | | - OPENVINO_THROW("Unknown serialize format. Should be either 'cout' or '*.xml'. Got ", pathStr); |
| 259 | + serializeToDot(graph, indexedPath); |
246 | 260 | } |
247 | 261 | } |
248 | 262 |
|
| 263 | +void serializeToDot(const Graph& graph, const std::filesystem::path& path) { |
| 264 | + if (path.empty()) { |
| 265 | + return; |
| 266 | + } |
| 267 | + |
| 268 | + ov::pass::Manager manager; |
| 269 | + manager.register_pass<ov::pass::VisualizeTree>(path.string(), nullptr, true); |
| 270 | + manager.run_passes(graph.dump()); |
| 271 | +} |
| 272 | + |
249 | 273 | void serializeToXML(const Graph& graph, const std::filesystem::path& path) { |
250 | 274 | if (path.empty()) { |
251 | 275 | return; |
|
0 commit comments