[CONFORMANCE][SUBGRAPHS DUMPER] Fix issue connected with fused_names extractor (#20522)

* [CONFORMANCE][SUBGRAPHS DUMPER] Fix issue connected with  extractor

* fix build
This commit is contained in:
Irina Efode authored and GitHub committed 2023-10-25 12:37:04 +04:00
1 parent e1a33f10d5
commit d138dd2f08
11 files changed
+33 -28

No files matched your search

@@ -36,8 +36,8 @@ public:
model_bytesize_gb >>= 30;
auto mem_size_gb = mem_size;
mem_size_gb >>= 30;
// std::cout << "[ WARNING ] Model " << model_path << " bytesize is " << model_bytesize_gb <<
// "is larger than RAM size: " << mem_size_gb << ". Model will be skipped!" << std::endl;
std::cout << "[ WARNING ] Model " << model_path << " bytesize is " << model_bytesize_gb <<
"is larger than RAM size: " << mem_size_gb << ". Model will be skipped!" << std::endl;
return true;
}
return false;
@@ -53,7 +53,7 @@ protected:
GraphCache(const std::string& device = "") {
ExtractorsManager::ExtractorsMap matchers = {
// temporary disabling according mem leaks in CI and not using swap mem
// { "fused_names", FusedNamesExtractor::Ptr(new FusedNamesExtractor(device)) },
{ "fused_names", FusedNamesExtractor::Ptr(new FusedNamesExtractor(device)) },
{ "repeat_pattern", RepeatPatternExtractor::Ptr(new RepeatPatternExtractor) },
};
m_manager.set_extractors(matchers);
@@ -17,16 +17,19 @@ static const char path_regex_message[] = "Optional. regular expression to be app
"folders recursive discovery";
static const char extract_body_message[] = "Optional. Allow to extract operation bodies to operation cache.";
static const char cache_type_message[] = "Optional. Specify caching type: OP, GRAPH. The default value is both";
static const char device_message[] = "Optional. Specify device to compile model for `fused_names` extractor. Default is `TEMPLATE` ";
static const char device_message[] = "Optional. Specify device to compile model for `fused_names` extractor. Default is `CPU` ";
static const char target_plugin_message[] =
"Optional. Name of plugin library. The example is `/path/to/libopenvino_template_plugin.so`. Use only with unregistered in OV Core devices";
DEFINE_bool(h, false, help_message);
DEFINE_string(input_folders, "", local_cache_message);
DEFINE_string(local_cache, "", input_folders_message);
DEFINE_string(output_folder, "output", output_folder_message);
DEFINE_string(device, ov::test::utils::DEVICE_TEMPLATE, device_message);
DEFINE_string(device, "CPU", device_message);
DEFINE_string(path_regex, ".*", output_folder_message);
DEFINE_bool(extract_body, true, extract_body_message);
DEFINE_string(cache_type, "", cache_type_message);
DEFINE_string(plugin_lib_name, "", target_plugin_message);
/**
* @brief This function shows a help message
@@ -44,5 +47,6 @@ static void showUsage() {
std::cout << " --extract_body \"<value>\" " << extract_body_message << "\n";
std::cout << " --cache_type \"<value>\" " << cache_type_message << "\n";
std::cout << " --device \"<value>\" " << device_message << "\n";
std::cout << " --plugin_lib_name \"<value>\" " << output_folder_message << std::endl;
std::cout << std::flush;
}
@@ -15,7 +15,6 @@ namespace subgraph_dumper {
class FusedNamesExtractor final : public SubgraphExtractor {
public:
FusedNamesExtractor(const std::string& device = "");
~FusedNamesExtractor();
std::vector<ExtractedPattern> extract(const std::shared_ptr<ov::Model> &modele) override;
@@ -24,7 +23,6 @@ protected:
void set_target_device(const std::string& _device);
std::string device;
std::shared_ptr<ov::Core> core;
};
} // namespace subgraph_dumper
@@ -15,7 +15,6 @@
#include "common_test_utils/file_utils.hpp"
#include "common_test_utils/test_constants.hpp"
#include "functional_test_utils/ov_plugin_cache.hpp"
#include "cache/cache.hpp"
#include "utils/node.hpp"
@@ -62,6 +61,8 @@ static std::map<ModelCacheStatus, std::string> model_cache_status_to_str = {
{ ModelCacheStatus::LARGE_MODELS_INCLUDED, "large_models_included" },
};
const std::shared_ptr<ov::Core> core = std::make_shared<ov::Core>();
std::pair<std::vector<std::string>, std::pair<ModelCacheStatus, std::vector<std::string>>>
find_models(const std::vector<std::string> &dirs, const std::string& regexp = ".*");
@@ -38,7 +38,7 @@ void GraphCache::update_cache(const std::shared_ptr<ov::Model>& model,
// check that Free RAM memory is enough. Serialize in other case
// serialize graph cache in case graph cache bytesize > 4GB to avoid long search the same graphs
if (m_graph_cache_bytesize + 2 * model_bytesize > mem_size || m_graph_cache_bytesize >> 20 != 0) {
// std::cout << "[ GRAPH CACHE ][ WARNING ] There are not enought RAM memory! Serialize graph cache" << std::endl;
std::cout << "[ GRAPH CACHE ][ WARNING ] There are not enought RAM memory! Serialize graph cache" << std::endl;
serialize_cache();
m_graph_cache_bytesize = 0;
}
@@ -48,8 +48,8 @@ void GraphCache::update_cache(const std::shared_ptr<ov::Model>& model,
model_bytesize_gb >>= 30;
auto mem_size_gb = mem_size;
mem_size_gb >>= 30;
// std::cout << "[ GRAPH CACHE ][ WARNING ] Model bytesize is " << model_bytesize_gb <<
// "GB. It is larger than 25% RAM size: " << mem_size_gb << ". Constants won't be copied!" << std::endl;
std::cout << "[ GRAPH CACHE ][ WARNING ] Model bytesize is " << model_bytesize_gb <<
"GB. It is larger than 25% RAM size: " << mem_size_gb << ". Constants won't be copied!" << std::endl;
}
auto extracted_patterns = m_manager.extract(model, extract_body, !is_large_model);
if (extracted_patterns.empty()) {
@@ -96,7 +96,7 @@ void GraphCache::update_cache(const std::shared_ptr<ov::Model>& extracted_model,
// std::cout << "[ GRAPH CACHE ][ INFO ] Reading cached model: " << serialized_model_path << std::endl;
auto bin_path = ov::test::utils::replaceExt(serialized_model_path, ".bin");
auto meta_path = ov::test::utils::replaceExt(serialized_model_path, ".meta");
auto cached_model = ov::test::utils::PluginCache::get().core()->read_model(serialized_model_path);
auto cached_model = core->read_model(serialized_model_path);
auto cached_meta = MetaInfo::read_meta_from_file(meta_path);
ov::test::utils::removeFile(serialized_model_path);
@@ -22,6 +22,16 @@ int main(int argc, char *argv[]) {
return 0;
}
if (!FLAGS_device.empty() && !FLAGS_plugin_lib_name.empty()) {
try {
core->register_plugin(FLAGS_plugin_lib_name + OV_BUILD_POSTFIX, FLAGS_device);
std::cout << "[ INFO ] Device: " << FLAGS_device << " is registred in OV core with " << FLAGS_plugin_lib_name << " lib" << std::endl;
} catch (const std::exception& e) {
std::cout << "[ ERROR ] Impossible to register device " << FLAGS_device << " with lib " << FLAGS_plugin_lib_name <<
std::endl << e.what() << std::endl;
}
}
std::vector<std::string> local_cache_dirs = ov::test::utils::splitStringByDelimiter(FLAGS_local_cache);
std::vector<std::string> dirs = ov::test::utils::splitStringByDelimiter(FLAGS_input_folders);
@@ -8,7 +8,6 @@
#include "openvino/op/loop.hpp"
#include "common_test_utils/common_utils.hpp"
#include "functional_test_utils/ov_plugin_cache.hpp"
#include "matchers/subgraph/fused_names.hpp"
#include "utils/model.hpp"
@@ -22,7 +21,8 @@ void FusedNamesExtractor::set_target_device(const std::string& _device) {
std::cout << "[ WARNING ][ GRAPH CACHE ] " << device <<
" will be used for `fused_names` extractor" << std::endl;
return;
} else if (std::find(available_devices.begin(),
} else if (_device != "TEMPLATE" &&
std::find(available_devices.begin(),
available_devices.end(),
_device) == available_devices.end()) {
std::string message = "Incorrect device ";
@@ -49,14 +49,9 @@ FusedNamesExtractor::extract_compiled_model_names(const std::shared_ptr<ov::Mode
}
FusedNamesExtractor::FusedNamesExtractor(const std::string& device) {
core = ov::test::utils::PluginCache::get().core();
set_target_device(device);
}
FusedNamesExtractor::~FusedNamesExtractor() {
core.reset();
}
std::vector<ExtractedPattern>
FusedNamesExtractor::extract(const std::shared_ptr<ov::Model> &model) {
auto compiled_op_name = extract_compiled_model_names(model);
@@ -3,7 +3,6 @@
//
#include "openvino/util/file_util.hpp"
#include "functional_test_utils/ov_plugin_cache.hpp"
#include "utils/model.hpp"
namespace ov {
@@ -46,7 +45,6 @@ find_models(const std::vector<std::string> &dirs, const std::string& regexp) {
try {
// models.emplace_back(file);
if (ov::util::file_exists(model_file)) {
auto core = ov::test::utils::PluginCache::get().core();
auto model_size = core->read_model(model_file)->get_graph_size();
models_sorted_by_size.insert({ model_size, model_file});
} else {
@@ -102,7 +100,6 @@ std::map<ModelCacheStatus, std::vector<std::string>> cache_models(
{ ModelCacheStatus::LARGE_MODELS_EXCLUDED, {} },
{ ModelCacheStatus::LARGE_MODELS_INCLUDED, {} },
};
auto core = ov::test::utils::PluginCache::get().core();
auto models_size = models.size();
for (size_t i = 0; i < models_size; ++i) {
@@ -121,8 +118,8 @@ std::map<ModelCacheStatus, std::vector<std::string>> cache_models(
cache_status[ModelCacheStatus::LARGE_MODELS_INCLUDED].push_back(model);
}
cache->update_cache(function, model, extract_body, from_cache);
} catch (std::exception) {
// std::cout << "[ ERROR ] Model processing failed with exception:" << std::endl << e.what() << std::endl;
} catch (std::exception& e) {
std::cout << "[ ERROR ] Model processing failed with exception:" << std::endl << e.what() << std::endl;
model_status = ModelCacheStatus::NOT_FULLY_CACHED;
}
} catch (std::exception) {
@@ -13,6 +13,7 @@
#include "cache/cache.hpp"
#include "cache/meta/meta_info.hpp"
#include "utils/model.hpp"
#include "base_test.hpp"
@@ -79,8 +80,7 @@ TEST_F(ICacheUnitTest, serialize_model) {
if (!ov::util::file_exists(meta_path)) {
throw std::runtime_error("Meta was not serilized!");
}
auto core = ov::Core();
auto serialized_model = core.read_model(xml_path, bin_path);
auto serialized_model = ov::tools::subgraph_dumper::core->read_model(xml_path, bin_path);
auto res = compare_functions(test_model, serialized_model, true, true, true, true, true, true);
if (!res.first) {
throw std::runtime_error("Serialized and runtime model are not equal!");
@@ -12,6 +12,7 @@
#include "cache/op_cache.hpp"
#include "utils/node.hpp"
#include "utils/model.hpp"
#include "base_test.hpp"
@@ -164,8 +165,7 @@ TEST_F(OpCacheUnitTest, serialize_op) {
auto serialized_model_path = ov::util::path_join({test_artifacts_dir,
"operation", "static", "Convert-0", "f16", "Convert-0_0.xml"});
ASSERT_TRUE(ov::util::file_exists(serialized_model_path));
auto core = ov::Core();
auto serialized_model = core.read_model(serialized_model_path);
auto serialized_model = core->read_model(serialized_model_path);
auto res = compare_functions(test_model, serialized_model, true, false, true, true, true, false);
ASSERT_TRUE(res.first);
}