From 0c6c3b0d740ab9f1dddc0f9295a4b1dfe45b6865 Mon Sep 17 00:00:00 2001 From: Sofya Balandina Date: Thu, 24 Mar 2022 16:43:46 +0300 Subject: [PATCH] [subgraphsDumper] Serialize the lightest operations from existing (#11097) --- .../subgraphs_dumper/src/ops_cache.cpp | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/ops_cache.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/ops_cache.cpp index 9c379654336..ae128e5e0cf 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/ops_cache.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/ops_cache.cpp @@ -15,16 +15,17 @@ using namespace SubgraphsDumper; void OPCache::update_ops_cache(const std::shared_ptr &op, const std::string &source_model) { - const bool op_found = [&] { + const std::shared_ptr cachedOp = [&] { for (auto &&it : m_ops_cache) { if (manager.match_any(it.first, op, it.second)) { it.second.found_in_models[source_model] += 1; - return true; + return it.first; } } - return false; + return std::shared_ptr{}; }(); - if (!op_found) { + + auto saveOpToCash = [&] { const auto &clone_fn = SubgraphsDumper::ClonersMap::cloners.at(op->get_type_info()); LayerTestsUtils::OPInfo meta(source_model); try { @@ -37,6 +38,23 @@ void OPCache::update_ops_cache(const std::shared_ptr &op, } catch (std::exception &e) { std::cout << e.what() << std::endl; } + }; + + if (!cachedOp.get()) { + saveOpToCash(); + } else { + for (int i = 0; i < op->get_input_size(); i++) { + auto shape = op->get_input_shape(i); + unsigned long shapeSize = ov::shape_size(shape) * op->get_element_type().size(); + + auto cachedOpShape = cachedOp->get_input_shape(i); + unsigned long cachedOpShapeSize = ov::shape_size(cachedOpShape) * cachedOp->get_element_type().size(); + + if (shapeSize < cachedOpShapeSize) { + m_ops_cache.erase(cachedOp); + saveOpToCash(); + } + } } }