OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[CPU][DEBUG_CAPS] Include model name to IR dump path (#34397)
Egor Duplenskiia3c8ffea4a6c
diff --git a/src/plugins/intel_cpu/src/utils/ngraph_transformation.hpp b/src/plugins/intel_cpu/src/utils/ngraph_transformation.hppindex 7fd1a764e69..6f164b5aaa8 100644--- a/src/plugins/intel_cpu/src/utils/ngraph_transformation.hpp+++ b/src/plugins/intel_cpu/src/utils/ngraph_transformation.hpp@@ -40,7 +40,7 @@ public:if (!config.dumpIR.transformations.filter[prev]) {break;}- if (wasDumped()[prev]) {+ if (wasDumped(model->get_friendly_name())[prev]) {return;}}@@ -48,7 +48,7 @@ public:}~TransformationDumper() {dump("_out");- wasDumped().set(type);+ wasDumped(model->get_friendly_name()).set(type);}private:@@ -67,40 +67,47 @@ private:{TransformationType::PostLpt, {"postLpt", TransformationType::Lpt}},{TransformationType::Snippets, {"snippets", TransformationType::PostLpt}},{TransformationType::Specific, {"cpuSpecific", TransformationType::Snippets}}};- static std::bitset<TransformationType::NumOfTypes>& wasDumped() {- static std::bitset<TransformationType::NumOfTypes> wasDumped;- return wasDumped;+ static std::bitset<TransformationType::NumOfTypes>& wasDumped(const std::string& modelName) {+ static std::unordered_map<std::string, std::bitset<TransformationType::NumOfTypes>> wasDumpedPerModel;+ return wasDumpedPerModel[modelName];}+void dump(const std::string&& postfix) {- static int num = 0; // just to keep dumped IRs ordered in filesystem- const std::filesystem::path dumpDir{config.dumpIR.dir};- const auto pathAndName = dumpDir / ("ir_" + std::to_string(num) + '_' + infoMap.at(type).name + postfix);+ static std::unordered_map<std::string, int> numPerModel;+ const std::filesystem::path dir{config.dumpIR.dir};+ // include model name to a path so more than one model can be dumped without overriding dumps of each other+ const std::filesystem::path dumpDir{dir / model->get_friendly_name()};+ // add a serial number to the prefix to ensure the correct order in 'ls' output+ auto& num = numPerModel[model->get_friendly_name()];+ const std::filesystem::path irFileName{"ir_" + std::to_string(num) + '_' + infoMap.at(type).name + postfix};+ // fullPath example: intel_cpu_dump/<model_name>/ir_0_preLpt_in.xml+ const auto fullPath = dumpDir / irFileName;ov::util::create_directory_recursive(dumpDir);ov::pass::Manager serializer;if (config.dumpIR.format.filter[DebugCapsConfig::IrFormatFilter::XmlBin]) {- auto xmlPath = pathAndName;+ auto xmlPath = fullPath;xmlPath.replace_extension(".xml");serializer.register_pass<ov::pass::Serialize>(xmlPath, std::filesystem::path{});}if (config.dumpIR.format.filter[DebugCapsConfig::IrFormatFilter::Xml]) {- auto xmlFile = pathAndName;+ auto xmlFile = fullPath;xmlFile.replace_extension(".xml");serializer.register_pass<ov::pass::Serialize>(xmlFile, std::filesystem::path{NULL_STREAM});}if (config.dumpIR.format.filter[DebugCapsConfig::IrFormatFilter::Svg]) {- auto svgFile = pathAndName;+ auto svgFile = fullPath;svgFile.replace_extension(".svg");serializer.register_pass<ov::pass::VisualizeTree>(svgFile);}if (config.dumpIR.format.filter[DebugCapsConfig::IrFormatFilter::Dot]) {- auto dotFile = pathAndName;+ auto dotFile = fullPath;dotFile.replace_extension(".dot");serializer.register_pass<ov::pass::VisualizeTree>(dotFile);}