From 5bbe15ed51d479cb9e652aa60ee6c278c1208eab Mon Sep 17 00:00:00 2001 From: Yuting Gao <0711candy@gmail.com> Date: Sat, 2 Mar 2024 22:39:53 -0800 Subject: [PATCH 1/3] [template][21756] Support unsupported properties in TEMPLATE plugin. --- src/plugins/template/src/config.cpp | 56 +++++++++++++++++++++++++++++ src/plugins/template/src/config.hpp | 7 ++++ src/plugins/template/src/plugin.cpp | 10 ++++-- 3 files changed, 71 insertions(+), 2 deletions(-) diff --git a/src/plugins/template/src/config.cpp b/src/plugins/template/src/config.cpp index f83690e6b9f..684ce400890 100644 --- a/src/plugins/template/src/config.cpp +++ b/src/plugins/template/src/config.cpp @@ -83,6 +83,50 @@ Configuration::Configuration(const ov::AnyMap& config, const Configuration& defa log_level = value.as(); } else if (ov::hint::model_priority == key) { model_priority = value.as(); + } else if (ov::optimal_batch_size == key) { + try { + int tmp_i = value.as(); + if (tmp_i >= 0) + optimal_batch_size = tmp_i; + else + OPENVINO_THROW("Incorrect value, it should be unsigned integer: ", key); + } catch (const std::exception&) { + OPENVINO_THROW("Wrong value ", value.as(), "for property key ", key); + } + } else if (ov::max_batch_size == key) { + try { + int tmp_i = value.as(); + if (tmp_i >= 0) + max_batch_size = tmp_i; + else + OPENVINO_THROW("Incorrect value, it should be unsigned integer: ", key); + } catch (const std::exception&) { + OPENVINO_THROW("Wrong value ", value.as(), "for property key ", key); + } + } else if (ov::loaded_from_cache == key) { + loaded_from_cache = value.as(); + } else if (ov::enable_mmap == key) { + enable_mmap = value.as(); + } else if (ov::compilation_num_threads == key) { + try { + int tmp_i = value.as(); + if (tmp_i >= 0) + compilation_num_threads = tmp_i; + else + OPENVINO_THROW("Incorrect value, it should be unsigned integer: ", key); + } catch (const std::exception&) { + OPENVINO_THROW("Wrong value ", value.as(), "for property key ", key); + } + } else if (ov::inference_num_threads == key) { + try { + int tmp_i = value.as(); + if (tmp_i >= 0) + inference_num_threads = tmp_i; + else + OPENVINO_THROW("Incorrect value, it should be unsigned integer: ", key); + } catch (const std::exception&) { + OPENVINO_THROW("Wrong value ", value.as(), "for property key ", key); + } } else if (throwOnUnsupported) { OPENVINO_THROW("Property was not found: ", key); } @@ -116,6 +160,18 @@ ov::Any Configuration::Get(const std::string& name) const { return log_level; } else if (name == ov::hint::model_priority) { return model_priority; + } else if (name == ov::optimal_batch_size) { + return optimal_batch_size; + } else if (name == ov::max_batch_size) { + return max_batch_size; + } else if (name == ov::loaded_from_cache) { + return loaded_from_cache; + } else if (name == ov::enable_mmap) { + return enable_mmap; + } else if (name == ov::compilation_num_threads) { + return compilation_num_threads; + } else if (name == ov::inference_num_threads) { + return inference_num_threads; } else { OPENVINO_THROW("Property was not found: ", name); } diff --git a/src/plugins/template/src/config.hpp b/src/plugins/template/src/config.hpp index ada22f8835d..1d6b4f98126 100644 --- a/src/plugins/template/src/config.hpp +++ b/src/plugins/template/src/config.hpp @@ -47,6 +47,13 @@ struct Configuration { ov::log::Level log_level = ov::log::Level::NO; ov::hint::Priority model_priority = ov::hint::Priority::DEFAULT; + + int optimal_batch_size = 4; + int max_batch_size = 4; + bool loaded_from_cache = false; + bool enable_mmap = false; + int compilation_num_threads = 1; + int inference_num_threads = 1; }; // ! [configuration:header] diff --git a/src/plugins/template/src/plugin.cpp b/src/plugins/template/src/plugin.cpp index ad98e81aec2..e72e1867bc1 100644 --- a/src/plugins/template/src/plugin.cpp +++ b/src/plugins/template/src/plugin.cpp @@ -246,7 +246,10 @@ ov::Any ov::template_plugin::Plugin::get_property(const std::string& name, const ov::device::capabilities, ov::device::type, ov::range_for_async_infer_requests, - ov::execution_devices}; + ov::execution_devices, + ov::optimal_batch_size, + ov::max_batch_size, + ov::loaded_from_cache}; return ro_properties; }; const auto& default_rw_properties = []() { @@ -258,7 +261,10 @@ ov::Any ov::template_plugin::Plugin::get_property(const std::string& name, const ov::hint::execution_mode, ov::num_streams, ov::template_plugin::disable_transformations, - ov::log::level}; + ov::log::level, + ov::enable_mmap, + ov::compilation_num_threads, + ov::inference_num_threads}; return rw_properties; }; if (ov::supported_properties == name) { From c9b2dbe41caa0d69c1c5dd3abb87e90344ec0184 Mon Sep 17 00:00:00 2001 From: Yuting Gao <0711candy@gmail.com> Date: Fri, 8 Mar 2024 22:42:49 -0800 Subject: [PATCH 2/3] fixup --- src/plugins/template/src/config.cpp | 38 ++++++----------------------- src/plugins/template/src/config.hpp | 5 ++-- 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/src/plugins/template/src/config.cpp b/src/plugins/template/src/config.cpp index 684ce400890..d9dfb99d0bf 100644 --- a/src/plugins/template/src/config.cpp +++ b/src/plugins/template/src/config.cpp @@ -85,47 +85,29 @@ Configuration::Configuration(const ov::AnyMap& config, const Configuration& defa model_priority = value.as(); } else if (ov::optimal_batch_size == key) { try { - int tmp_i = value.as(); - if (tmp_i >= 0) - optimal_batch_size = tmp_i; - else - OPENVINO_THROW("Incorrect value, it should be unsigned integer: ", key); + auto tmp_i = value.as(); + optimal_batch_size = tmp_i; } catch (const std::exception&) { - OPENVINO_THROW("Wrong value ", value.as(), "for property key ", key); + OPENVINO_THROW("Incorrect value ", value.as(), "for property key ", key); } } else if (ov::max_batch_size == key) { try { - int tmp_i = value.as(); - if (tmp_i >= 0) - max_batch_size = tmp_i; - else - OPENVINO_THROW("Incorrect value, it should be unsigned integer: ", key); + auto tmp_i = value.as(); + max_batch_size = tmp_i; } catch (const std::exception&) { - OPENVINO_THROW("Wrong value ", value.as(), "for property key ", key); + OPENVINO_THROW("Incorrect value ", value.as(), "for property key ", key); } } else if (ov::loaded_from_cache == key) { loaded_from_cache = value.as(); - } else if (ov::enable_mmap == key) { - enable_mmap = value.as(); } else if (ov::compilation_num_threads == key) { try { - int tmp_i = value.as(); + auto tmp_i = value.as(); if (tmp_i >= 0) compilation_num_threads = tmp_i; else OPENVINO_THROW("Incorrect value, it should be unsigned integer: ", key); } catch (const std::exception&) { - OPENVINO_THROW("Wrong value ", value.as(), "for property key ", key); - } - } else if (ov::inference_num_threads == key) { - try { - int tmp_i = value.as(); - if (tmp_i >= 0) - inference_num_threads = tmp_i; - else - OPENVINO_THROW("Incorrect value, it should be unsigned integer: ", key); - } catch (const std::exception&) { - OPENVINO_THROW("Wrong value ", value.as(), "for property key ", key); + OPENVINO_THROW("Incorrect value ", value.as(), "for property key ", key); } } else if (throwOnUnsupported) { OPENVINO_THROW("Property was not found: ", key); @@ -166,12 +148,8 @@ ov::Any Configuration::Get(const std::string& name) const { return max_batch_size; } else if (name == ov::loaded_from_cache) { return loaded_from_cache; - } else if (name == ov::enable_mmap) { - return enable_mmap; } else if (name == ov::compilation_num_threads) { return compilation_num_threads; - } else if (name == ov::inference_num_threads) { - return inference_num_threads; } else { OPENVINO_THROW("Property was not found: ", name); } diff --git a/src/plugins/template/src/config.hpp b/src/plugins/template/src/config.hpp index 1d6b4f98126..ddc44e050f0 100644 --- a/src/plugins/template/src/config.hpp +++ b/src/plugins/template/src/config.hpp @@ -48,10 +48,9 @@ struct Configuration { ov::hint::Priority model_priority = ov::hint::Priority::DEFAULT; - int optimal_batch_size = 4; - int max_batch_size = 4; + int optimal_batch_size = 1; + int max_batch_size = 1; bool loaded_from_cache = false; - bool enable_mmap = false; int compilation_num_threads = 1; int inference_num_threads = 1; }; From b220986dd03afe65b23e1acc3d84d89b964f26e6 Mon Sep 17 00:00:00 2001 From: Yuting Gao <0711candy@gmail.com> Date: Fri, 8 Mar 2024 22:34:48 -0800 Subject: [PATCH 3/3] Remove enable_mmap test cases because for the moment only IR Frontend supports the property. --- .../shared/src/behavior/ov_plugin/properties_tests.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/tests/functional/plugin/shared/src/behavior/ov_plugin/properties_tests.cpp b/src/tests/functional/plugin/shared/src/behavior/ov_plugin/properties_tests.cpp index a8c09c97228..6ade14fc019 100644 --- a/src/tests/functional/plugin/shared/src/behavior/ov_plugin/properties_tests.cpp +++ b/src/tests/functional/plugin/shared/src/behavior/ov_plugin/properties_tests.cpp @@ -335,11 +335,6 @@ std::vector OVPropertiesTestsWithCompileModelProps::getRWOptionalPro } } - if (props.empty() || std::find(props.begin(), props.end(), ov::enable_mmap.name()) != props.end()) { - res.push_back({ov::enable_mmap(true)}); - res.push_back({ov::enable_mmap(false)}); - } - if (props.empty() || std::find(props.begin(), props.end(), ov::log::level.name()) != props.end()) { ov::log::Level log_levels[] = {ov::log::Level::NO , ov::log::Level::ERR, ov::log::Level::WARNING, ov::log::Level::INFO, ov::log::Level::DEBUG, ov::log::Level::TRACE}; @@ -375,10 +370,6 @@ std::vector OVPropertiesTestsWithCompileModelProps::getWrongRWOption res.push_back({{ov::hint::scheduling_core_type.name(), -1}}); } - if (props.empty() || std::find(props.begin(), props.end(), ov::enable_mmap.name()) != props.end()) { - res.push_back({{ov::enable_mmap.name(), -10}}); - } - if (props.empty() || std::find(props.begin(), props.end(), ov::log::level.name()) != props.end()) { res.push_back({{ov::log::level.name(), -3}}); }