Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[Template]: Fix property test for template plugin(#21756) (#29224)

Simon Wang79d80270ffe8
diff --git a/src/plugins/template/src/config.cpp b/src/plugins/template/src/config.cpp
index 3b3a78e40c4..34e13fe06aa 100644
--- a/src/plugins/template/src/config.cpp
+++ b/src/plugins/template/src/config.cpp
@@ -82,6 +82,43 @@ Configuration::Configuration(const ov::AnyMap& config, const Configuration& defa
model_priority = value.as<ov::hint::Priority>();
} else if (ov::cache_encryption_callbacks == key) {
encryption_callbacks = value.as<EncryptionCallbacks>();
+ } else if (ov::hint::scheduling_core_type == key) {
+ try {
+ schedulingCoreType = value.as<ov::hint::SchedulingCoreType>();
+ } catch (const std::exception&) {
+ OPENVINO_THROW("Wrong value ", value.as<ov::hint::SchedulingCoreType>(), "for property key ", key);
+ }
+ } else if (key == ov::hint::enable_hyper_threading) {
+ try {
+ enableHyperThreading = value.as<bool>();
+ } catch (ov::Exception&) {
+ OPENVINO_THROW("Wrong value ",
+ value.as<std::string>(),
+ "for property key ",
+ key,
+ ". Expected only true/false.");
+ }
+ } else if (key == ov::hint::enable_cpu_pinning.name()) {
+ try {
+ enableCpuPinning = value.as<bool>();
+ } catch (ov::Exception&) {
+ OPENVINO_THROW("Wrong value ",
+ value.as<std::string>(),
+ "for property key ",
+ key,
+ ". Expected only true/false.");
+ }
+ } else if (ov::compilation_num_threads.name() == key) {
+ int val;
+ try {
+ val = value.as<int>();
+ } catch (const std::exception&) {
+ OPENVINO_THROW("Wrong value for property key ", key, ". Expected only positive numbers (#threads)");
+ }
+ if (val < 0) {
+ OPENVINO_THROW("Wrong value for property key ", key, ". Expected only positive numbers (#threads)");
+ }
+ compilation_thread_num = val;
} else if (ov::weights_path == key) {
weights_path = value.as<std::string>();
if (!weights_path.empty()) {
@@ -122,6 +159,14 @@ 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::compilation_num_threads) {
+ return {std::to_string(compilation_thread_num)};
+ } else if (name == ov::hint::scheduling_core_type) {
+ return schedulingCoreType;
+ } else if (name == ov::hint::enable_cpu_pinning) {
+ return enableCpuPinning;
+ } else if (name == ov::hint::enable_hyper_threading) {
+ return enableHyperThreading;
} else if (name == ov::weights_path) {
return weights_path.string();
} else if (name == ov::internal::compiled_model_runtime_properties) {
diff --git a/src/plugins/template/src/config.hpp b/src/plugins/template/src/config.hpp
index c3cd8ff1913..c462df44242 100644
--- a/src/plugins/template/src/config.hpp
+++ b/src/plugins/template/src/config.hpp
@@ -49,6 +49,10 @@ struct Configuration {
ov::hint::Priority model_priority = ov::hint::Priority::DEFAULT;
+ ov::hint::SchedulingCoreType schedulingCoreType = ov::hint::SchedulingCoreType::ANY_CORE;
+ bool enableCpuPinning = false;
+ bool enableHyperThreading = false;
+ int compilation_thread_num = 1;
EncryptionCallbacks encryption_callbacks{};
std::filesystem::path weights_path{};
AnyMap compiled_model_runtime_properties{};
diff --git a/src/plugins/template/src/plugin.cpp b/src/plugins/template/src/plugin.cpp
index cbd1f07f74e..5e69d20c310 100644
--- a/src/plugins/template/src/plugin.cpp
+++ b/src/plugins/template/src/plugin.cpp
@@ -347,6 +347,11 @@ ov::Any ov::template_plugin::Plugin::get_property(const std::string& name, const
ov::template_plugin::disable_transformations,
ov::log::level,
ov::hint::model_priority,
+ ov::hint::enable_hyper_threading,
+ ov::hint::enable_cpu_pinning,
+ ov::hint::scheduling_core_type,
+ ov::compilation_num_threads,
+ ov::inference_num_threads,
ov::weights_path,
ov::cache_mode,
};
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 85fb0ccf4d5..e1e169b26cf 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
@@ -352,11 +352,6 @@ OVPropertiesTestsWithCompileModelProps::getRWOptionalPropertiesValues(
}
}
- 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};
@@ -396,10 +391,6 @@ OVPropertiesTestsWithCompileModelProps::getWrongRWOptionalPropertiesValues(
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}});
}