[CONFORMANCE] Fix memory leak in Subgraphs Dumper (#19172)
* [CONFORMANCE] Fix memory leak in Subgraphs Dumper * Update fused_names.cpp * Change inheritance of extractors * Check graph cache * Enable Op cache
This commit is contained in:
parent
5ff67fca40
commit
043cd86449
@ -49,8 +49,8 @@ protected:
|
||||
GraphCache() {
|
||||
ExtractorsManager::ExtractorsMap matchers = {
|
||||
// temporary disabling according mem leaks in CI and not using swap mem
|
||||
// { "fused_names", FusedNamesExtractor::Ptr(new FusedNamesExtractor) },
|
||||
// { "repeat_pattern", RepeatPatternExtractor::Ptr(new RepeatPatternExtractor) },
|
||||
{ "fused_names", FusedNamesExtractor::Ptr(new FusedNamesExtractor) },
|
||||
{ "repeat_pattern", RepeatPatternExtractor::Ptr(new RepeatPatternExtractor) },
|
||||
};
|
||||
m_manager.set_extractors(matchers);
|
||||
}
|
||||
|
@ -20,14 +20,14 @@ public:
|
||||
explicit iMatcherConfig(bool is_fallback_config) : is_fallback_config(is_fallback_config) {}
|
||||
|
||||
iMatcherConfig(
|
||||
std::vector<std::string> ignored_attributes,
|
||||
std::vector<size_t> ignored_ports,
|
||||
const std::vector<std::string>& ignored_attributes,
|
||||
const std::vector<size_t>& ignored_ports,
|
||||
bool is_fallback_config,
|
||||
bool ignore_matching = false)
|
||||
: ignored_attributes(std::move(ignored_attributes)),
|
||||
ignored_ports(std::move(ignored_ports)),
|
||||
is_fallback_config(is_fallback_config),
|
||||
ignore_matching(ignore_matching) {}
|
||||
bool ignore_matching = false) :
|
||||
ignored_attributes(ignored_attributes),
|
||||
ignored_ports(ignored_ports),
|
||||
is_fallback_config(is_fallback_config),
|
||||
ignore_matching(ignore_matching) {}
|
||||
|
||||
// Empty vectors stands for any of possible values
|
||||
std::vector<std::string> ignored_attributes;
|
||||
@ -43,8 +43,10 @@ struct MatcherConfig : public iMatcherConfig {
|
||||
public:
|
||||
MatcherConfig() : iMatcherConfig(sizeof...(OPTypes) == 0) {}
|
||||
|
||||
MatcherConfig(std::vector<std::string> ignored_attributes, std::vector<size_t> ignored_ports, bool ignore_matching = false) :
|
||||
iMatcherConfig(std::move(ignored_attributes), std::move(ignored_ports), sizeof...(OPTypes) == 0, ignore_matching) {}
|
||||
MatcherConfig(const std::vector<std::string>& ignored_attributes,
|
||||
const std::vector<size_t>& ignored_ports,
|
||||
bool ignore_matching = false) :
|
||||
iMatcherConfig(ignored_attributes, ignored_ports, sizeof...(OPTypes) == 0, ignore_matching) {}
|
||||
|
||||
MatcherConfig(bool ignore_matching) : iMatcherConfig({}, {}, sizeof...(OPTypes) == 0, ignore_matching) {}
|
||||
|
||||
|
@ -12,9 +12,11 @@ namespace ov {
|
||||
namespace tools {
|
||||
namespace subgraph_dumper {
|
||||
|
||||
class FusedNamesExtractor : public SubgraphExtractor {
|
||||
class FusedNamesExtractor final : public SubgraphExtractor {
|
||||
public:
|
||||
FusedNamesExtractor();
|
||||
~FusedNamesExtractor();
|
||||
|
||||
std::list<ExtractedPattern> extract(const std::shared_ptr<ov::Model> &model,
|
||||
bool is_extract_body = true) override;
|
||||
void set_target_device(const std::string& _device) { device = _device; }
|
||||
|
@ -14,7 +14,7 @@ namespace ov {
|
||||
namespace tools {
|
||||
namespace subgraph_dumper {
|
||||
|
||||
class RepeatPatternExtractor : public SubgraphExtractor {
|
||||
class RepeatPatternExtractor final : public SubgraphExtractor {
|
||||
public:
|
||||
RepeatPatternExtractor() {
|
||||
MatchersManager::MatchersMap matchers = {
|
||||
|
@ -31,6 +31,10 @@ FusedNamesExtractor::FusedNamesExtractor() {
|
||||
device = *(core->get_available_devices().begin());
|
||||
}
|
||||
|
||||
FusedNamesExtractor::~FusedNamesExtractor() {
|
||||
core.reset();
|
||||
}
|
||||
|
||||
std::list<ExtractedPattern>
|
||||
FusedNamesExtractor::extract(const std::shared_ptr<ov::Model> &model,
|
||||
bool is_extract_body) {
|
||||
|
@ -20,12 +20,13 @@ using namespace ov::tools::subgraph_dumper;
|
||||
|
||||
|
||||
// ======================= ExtractorsManagerTest Unit tests =======================
|
||||
class FusedNamesExtractorTest : public FusedNamesExtractor,
|
||||
public SubgraphsDumperBaseTest {
|
||||
class FusedNamesExtractorTest : public SubgraphsDumperBaseTest {
|
||||
FusedNamesExtractor extractor;
|
||||
|
||||
protected:
|
||||
void is_match(const std::shared_ptr<ov::Model>& model) {
|
||||
auto models_1 = this->extract(model);
|
||||
auto models_2 = this->extract(model);
|
||||
auto models_1 = extractor.extract(model);
|
||||
auto models_2 = extractor.extract(model);
|
||||
ASSERT_EQ(models_1.size(), models_2.size());
|
||||
auto it_model_1 = models_1.begin();
|
||||
auto it_model_2 = models_2.begin();
|
||||
|
@ -18,16 +18,17 @@ using namespace ov::tools::subgraph_dumper;
|
||||
|
||||
|
||||
// ======================= ExtractorsManagerTest Unit tests =======================
|
||||
class RepeatPatternExtractorTest : public RepeatPatternExtractor,
|
||||
public SubgraphsDumperBaseTest {
|
||||
class RepeatPatternExtractorTest : public SubgraphsDumperBaseTest {
|
||||
protected:
|
||||
RepeatPatternExtractor extractor;
|
||||
|
||||
bool is_match(const std::list<ExtractedPattern>& models,
|
||||
const std::vector<std::shared_ptr<ov::Model>>& ref_models) {
|
||||
size_t match_numbers = 0;
|
||||
for (const auto& model : models) {
|
||||
bool is_match = false;
|
||||
for (const auto& ref_model : ref_models) {
|
||||
if (this->match(std::get<0>(model), ref_model)) {
|
||||
if (extractor.match(std::get<0>(model), ref_model)) {
|
||||
is_match = true;
|
||||
++match_numbers;
|
||||
break;
|
||||
@ -43,21 +44,21 @@ protected:
|
||||
|
||||
TEST_F(RepeatPatternExtractorTest, extract_0) {
|
||||
auto test_model = Model_0();
|
||||
auto models = this->extract(test_model.get());
|
||||
auto models = extractor.extract(test_model.get());
|
||||
auto ref = test_model.get_repeat_pattern_ref();
|
||||
ASSERT_TRUE(is_match(models, ref));
|
||||
}
|
||||
|
||||
TEST_F(RepeatPatternExtractorTest, extract_1) {
|
||||
auto test_model = Model_1();
|
||||
auto models = this->extract(test_model.get());
|
||||
auto models = extractor.extract(test_model.get());
|
||||
auto ref = test_model.get_repeat_pattern_ref();
|
||||
ASSERT_TRUE(is_match(models, ref));
|
||||
}
|
||||
|
||||
TEST_F(RepeatPatternExtractorTest, extract_2) {
|
||||
auto test_model = Model_2();
|
||||
auto models = this->extract(test_model.get());
|
||||
auto models = extractor.extract(test_model.get());
|
||||
auto ref = test_model.get_repeat_pattern_ref();
|
||||
ASSERT_TRUE(is_match(models, ref));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user