[subgraphsDumper] Serialize the lightest operations from existing (#11097)

This commit is contained in:
Sofya Balandina 2022-03-24 16:43:46 +03:00 committed by GitHub
parent f156429b11
commit 0c6c3b0d74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,16 +15,17 @@ using namespace SubgraphsDumper;
void OPCache::update_ops_cache(const std::shared_ptr<ov::Node> &op,
const std::string &source_model) {
const bool op_found = [&] {
const std::shared_ptr<ov::Node> 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<ov::Node>{};
}();
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<ov::Node> &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();
}
}
}
}